From nobody Sat Nov 23 09:33:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=koconnor.net Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1710255335193230.09934847878878; Tue, 12 Mar 2024 07:55:35 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id B6766222DB; Tue, 12 Mar 2024 14:55:30 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 15F5E21D8F for ; Tue, 12 Mar 2024 14:55:14 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Tue, 12 Mar 2024 07:55:13 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id bi41-20020a05620a31a900b0078889846ca4sm524265qkb.5.2024.03.12.07.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 07:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koconnor.net; s=google; t=1710255313; x=1710860113; darn=seabios.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8/tpJUH0vZGlJTR6ppXiHd+2FJZHoC0rdrVubPMJU3U=; b=eNO0Gl2KEXzWEiNgh1kV20Mw6+VVlQFpKjVqrjONBUZoZ8tOEbhTbk2BaNGgKoBidi XApfLK4qXxQ1TYFaC/NdyAjh8B3C9bN9UjboQ7XDLmaCglp5akjwmI68LMpaQClseSQQ LLsQXe0IZR1P2rBumvvQFha2CU/7pdNdPngas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710255313; x=1710860113; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8/tpJUH0vZGlJTR6ppXiHd+2FJZHoC0rdrVubPMJU3U=; b=WmV2Vy/QSYGZNVLmfZDxrKPi3z84eL9mhiKvPcMyRS8yNzmQDJdy9ePgA2u+8J/W3g /OGOX8n7Pm+hJKm/RBHnsiBqXYj1gbR+Nm2rDB3cQoSgXAKDL13le6U6xtdGJWX0FfAj KFiWyUz+VOpzLseTFSNqod0HhE0prWJiACtazIGj/8P8hrRXnKIaxk7hpAoVUuvNwB04 qWKb7uLh429cg5XfYz5zFnr+xoI4uHLFnyUeiRA4eGNNqYMBLvlpN95icdrUo/jvKxOz 17FOxosJBdrpb8myBKnR6q/iHVxs/0OQ2eaxrHM74clwVIXcp5p3QqGj/aTogdvbvz5p akgA== X-Gm-Message-State: AOJu0Yxocl3oW174jDHnFRyag3awnkkCUF2V3zXuYf+brREgSDFOC3im FwxYVj6LqNAr5tDD1riXN7nquERTu4uySsJly8cWKSUcmxovIeTgrQiLFEARnEA= X-Google-Smtp-Source: AGHT+IEClBjbC4k02Ckgjdd4RGM9fCUo6Wz2kVzcreKZ7/pIA0pqNb+GWCtwowHRxWujDhMIlWCnGA== X-Received: by 2002:a05:620a:7f0:b0:788:4dd1:390c with SMTP id k16-20020a05620a07f000b007884dd1390cmr3346374qkk.68.1710255312804; Tue, 12 Mar 2024 07:55:12 -0700 (PDT) Date: Tue, 12 Mar 2024 10:55:12 -0400 From: Kevin O'Connor To: Daniel Verkamp Message-ID: References: <20240312032644.1439715-1-daniel@drv.nu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240312032644.1439715-1-daniel@drv.nu> Message-ID-Hash: SFEJTBX7LHI5QZ2NEDPGJ5434IPMNPQS X-Message-ID-Hash: SFEJTBX7LHI5QZ2NEDPGJ5434IPMNPQS X-MailFrom: kevin@koconnor.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: seabios@seabios.org X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] Re: [PATCH v2] vbe: implement function 09h (get/set palette data) List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: --- X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1710255336307100001 Content-Type: text/plain; charset="utf-8" On Mon, Mar 11, 2024 at 08:26:18PM -0700, Daniel Verkamp wrote: > Since the VBE mode attributes indicate that all modes are not VGA > compatible, applications must use VBE function 09h to manipulate the > palette rather than directly accessing the VGA registers. >=20 > This implementation uses the standard VGA registers for all hardware, > which may not be appropriate; I only verified qemu -device VGA. >=20 > Without this patch, the get/set palette function returns an error code, > so programs that use 8-bit indexed color modes fail. For example, Quake > (DOS) printed "Error: Unable to load VESA palette" and exited when > trying to set a SVGA mode like 640x480, but with the patch it succeeds. > This fixes qemu issue #251 and #1862. >=20 > > >=20 > Signed-off-by: Daniel Verkamp > --- >=20 > V2: use existing stdvga_dac_read/write() functions Thanks. How about the below instead? This alternate version checks for CONFIG_VGA_STDVGA_PORTS up front, uses GET/SET_FARVAR(), and directly calls stdvga_dac_read/write() (as vgabios.c does). I don't have a good way to test this. -Kevin From 03f5202aacfb18ca1b15691b1330262091e1a51f Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 11 Mar 2024 20:26:18 -0700 Subject: [PATCH] vbe: implement function 09h (get/set palette data) Since the VBE mode attributes indicate that all modes are not VGA compatible, applications must use VBE function 09h to manipulate the palette rather than directly accessing the VGA registers. This implementation uses the standard VGA registers for all hardware, which may not be appropriate; I only verified qemu -device VGA. Without this patch, the get/set palette function returns an error code, so programs that use 8-bit indexed color modes fail. For example, Quake (DOS) printed "Error: Unable to load VESA palette" and exited when trying to set a SVGA mode like 640x480, but with the patch it succeeds. This fixes qemu issue #251 and #1862. Signed-off-by: Daniel Verkamp Signed-off-by: Kevin O'Connor --- vgasrc/vbe.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c index 20437db..9068e91 100644 --- a/vgasrc/vbe.c +++ b/vgasrc/vbe.c @@ -376,6 +376,64 @@ fail: regs->ax =3D 0x014f; } =20 +static void +vbe_104f09(struct bregs *regs) +{ + if (!CONFIG_VGA_STDVGA_PORTS) { + // DAC palette support only available on devices with stdvga ports + debug_stub(regs); + regs->ax =3D 0x0100; + return; + } + + struct vgamode_s *vmode_g =3D get_current_mode(); + if (! vmode_g) + goto fail; + u8 memmodel =3D GET_GLOBAL(vmode_g->memmodel); + u8 depth =3D GET_GLOBAL(vmode_g->depth); + if (memmodel =3D=3D MM_DIRECT || memmodel =3D=3D MM_YUV || depth > 8) { + regs->ax =3D 0x034f; + return; + } + if (regs->dh) + goto fail; + u8 start =3D regs->dl; + int count =3D regs->cx; + int max_colors =3D 1 << depth; + if (start + count > max_colors) + goto fail; + u16 seg =3D regs->es; + u8 *data_far =3D (void*)(regs->di+0); + u8 rgb[3]; + int i; + switch (regs->bl) { + case 0x80: + case 0x00: + for (i =3D 0; i < count; i++) { + rgb[0] =3D GET_FARVAR(seg, data_far[i*4 + 2]); + rgb[1] =3D GET_FARVAR(seg, data_far[i*4 + 1]); + rgb[2] =3D GET_FARVAR(seg, data_far[i*4 + 0]); + stdvga_dac_write(GET_SEG(SS), rgb, start + i, 1); + } + break; + case 0x01: + for (i =3D 0; i < count; i++) { + stdvga_dac_read(GET_SEG(SS), rgb, start + i, 1); + SET_FARVAR(seg, data_far[i*4 + 0], rgb[2]); + SET_FARVAR(seg, data_far[i*4 + 1], rgb[1]); + SET_FARVAR(seg, data_far[i*4 + 2], rgb[0]); + SET_FARVAR(seg, data_far[i*4 + 3], 0); + } + break; + default: + goto fail; + } + regs->ax =3D 0x004f; + return; +fail: + regs->ax =3D 0x014f; +} + static void vbe_104f0a(struct bregs *regs) { @@ -456,6 +514,7 @@ handle_104f(struct bregs *regs) case 0x06: vbe_104f06(regs); break; case 0x07: vbe_104f07(regs); break; case 0x08: vbe_104f08(regs); break; + case 0x09: vbe_104f09(regs); break; case 0x0a: vbe_104f0a(regs); break; case 0x10: vbe_104f10(regs); break; case 0x15: vbe_104f15(regs); break; --=20 2.43.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org