Commit Graph

332 Commits

Author SHA1 Message Date
Kevin O'Connor 731c88d503 stdvgaio: Only read/write one color palette entry at a time
Introduce stdvga_dac_read_many() and stdvga_dac_write_many() for
writing multiple dac palette entries.  Convert the stdvga_dac_read()
and stdvga_dac_write() low-level IO access functions in stdvgaio.c to
access just one color palette entry.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-13 13:19:56 -04:00
Kevin O'Connor c5a361c09a stdvga: Add stdvga_set_vertical_size() helper function
Add helper function and update the bochsvga.c code to use it.  This
emphasizes the relationship between stdvga_get_vertical_size() and
stdvga_set_vertical_size() code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-05 17:59:49 -04:00
Kevin O'Connor 22c9141260 stdvga: Rename stdvga_get_vde() to stdvga_get_vertical_size()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-05 17:59:49 -04:00
Kevin O'Connor 549463dbc0 stdvga: Rename stdvga_set_scan_lines() to stdvga_set_character_height()
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-05 17:59:45 -04:00
Kevin O'Connor c67914ac42 stdvga: Rename stdvga_set_text_block_specifier() to stdvga_set_font_location()
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-05 17:59:42 -04:00
Kevin O'Connor aa94925d29 stdvga: Rework stdvga palette index paging interface functions
Rename the functions to make them a little easier to understand.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-05 17:59:42 -04:00
Kevin O'Connor 8de51a5af2 stdvga: Rename stdvga_toggle_intensity() to stdvga_set_palette_blinking()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-05 17:59:42 -04:00
Kevin O'Connor 96c7781ff4 stdvga: Add comments to interface functions in stdvga.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-05 17:59:42 -04:00
Kevin O'Connor 2996819f7d stdvga: Rename CGA palette functions
Rename stdvga_set_border_color() to stdvga_set_cga_background_color()
and stdvga_set_palette() to stdvga_set_cga_palette().  These functions
implement compatibility for old CGA cards - rename them so they are
not confused with the functions that manipulte the VGA palette.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-04-05 17:58:49 -04:00
Kevin O'Connor 9136808853 stdvgamodes: Improve naming of dac palette tables
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-03-31 23:13:07 -04:00
Kevin O'Connor 70f43981b7 stdvgamodes: No need to store pelmask in vga_modes[]
The pelmask is always 0xff so no need to store in a static table.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-03-31 21:33:59 -04:00
Kevin O'Connor 1588fd1437 vgasrc: Rename vgahw_get_linesize() to vgahw_minimum_linelength()
Make the relationship between vgahw_get_linelength() and
vgahw_get_linesize() more clear by renaming it to
vgahw_minimum_linelength().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-03-15 19:50:29 -04:00
Kevin O'Connor d73e18bb70 vgasrc: Use curmode_g instead of vmode_g when mode is the current video mode
Many functions are passed a pointer to the current video mode
vgamode_s struct.  Use the name 'curmode_g' for these functions and
use 'vmode_g' for functions that can accept an arbitrary video mode.
Hopefully this will make the goals of the functions more clear.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-03-15 10:58:57 -04:00
Daniel Verkamp 192e23b784 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.

<https://gitlab.com/qemu-project/qemu/-/issues/251>
<https://gitlab.com/qemu-project/qemu/-/issues/1862>

Signed-off-by: Daniel Verkamp <daniel@drv.nu>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-03-15 10:27:52 -04:00
Daniel Verkamp 3722c21de1 vgasrc: round up save/restore size
When calculating the size of the buffer required for the VGA/VBE state,
round up rather than truncating when dividing the number of bytes to get
the number of 64-byte blocks. Without this modification, the save state
function will write past the end of a buffer of the size requested.

Signed-off-by: Daniel Verkamp <daniel@drv.nu>
2024-03-12 10:27:40 -04:00
Daniel Verkamp 5d87ff2542 vbe: Add VBE 2.0+ OemData field to struct vbe_info
Per the VBE 2.0 specification, the VBE controller information is 512
bytes long when the "VBE2" signature is provided, instead of the
original 256 bytes.

src/bootsplash.c uses the original pre-VBE-2.0 256-byte structure while
also filling in the "VBE2" signature, so a video BIOS that makes use of
the VBE2 OemData area could write past the end of the allocated region.

The original bootsplash code did not have this bug; it was introduced
when the bootsplash VBE structures were merged with the VGA ROM struct
definitions.

Fixes: 69e941c159 ("Merge bootsplash and VGA ROM vbe structure definitions")
Signed-off-by: Daniel Verkamp <daniel@drv.nu>
2024-03-10 13:00:27 -04:00
Kevin O'Connor 0a1e7675f7 vgasrc: Don't use VAR16 in header files to fix gcc warning
Some versions of gcc complain when VAR16 is used in both the header
and C files - use only in the C file to fix the warning.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-12-18 12:00:16 -05:00
Gerd Hoffmann f9af71744a svgamodes: add standard 4k modes
Add all three 4k modes.  Computer monitors typically use
the first one (3840x2160).

Add 16 and 32 bpp variants.  24bpp is dead these days, and
software which is so old that still uses those modes most
likely doesn't even know what 4k is.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-12-18 11:54:52 -05:00
Sergei Trofimovich 6eff808598 vgasrc: ignore .node.gnu.property (binutils-2.36 support)
Modern binutils unconditionally tracks x86_64 ISA levels in intermediate
files in .note.gnu.property. Custom liker script does not handle the
section and complains about it:

    ld --gc-sections -T out/vgasrc/vgalayout.lds out/vgaccode16.o \
        out/vgaentry.o out/vgaversion.o -o out/vgarom.o
    ld: section .note.gnu.property LMA [0000000000000000,0000000000000027] \
        overlaps section .text LMA [0000000000000000,00000000000098af]

The change ignores .note* sections.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2021-05-26 10:07:01 -04:00
Kevin O'Connor 6ada2285d9 vgabios: Fix preserve memory flag in handle_1000
Commit 5108c69c made a change to the ordering of some code which broke
the check for the MF_NOCLEARMEM flag.

Reported by felix.von.s@posteo.de

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-07-13 18:50:52 -04:00
Gerd Hoffmann d11c751852 vga: fix cirrus bios
Little mistake, big effect.  The patch adding the ati driver broke
cirrus due to a missing "else", which effectively downgrades cirrus
to standard vga.

Fixes: 34b6ecc160 ("vga: add atiext driver")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-06-25 10:21:28 -04:00
Gerd Hoffmann 0c480648e3 ramfb: add copyright and license to ramfb.c
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-28 10:27:25 -04:00
Gerd Hoffmann edf4fe5eb0 bochsdisplay: add copyright and license to bochsdisplay.c
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-28 10:27:06 -04:00
Kevin O'Connor b9b923ed45 svgamodes: Add copyright notice to vgasrc/svgamodes.c
Commit 004f5b3a moved part of vgasrc/bochsvga.c to vgasrc/svgamodes.c
- copy over the copyright statements as well.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-28 10:23:59 -04:00
Uwe Kleine-König 120996f147 Remove dos line endings introduced in the last two commits
These were added somewhere between the mailing list server and Gerd's
working copy (as the patch I got via the mailing list is fine). These
don't disturb the compiler, but they look ugly so remove them.

Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Message-Id: <20191020200726.20116-1-uwe@kleine-koenig.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-21 08:49:53 +02:00
Uwe Kleine-König fc92d092ea Add additional resolutions for 16:9 displays: 1600x900 and 2560x1440
This allows to have qemu run at the native screen resolution of my
(physical) monitor.

This is inspired by a patch created by Andreas Dangel that I found on
https://adangel.org/2015/09/11/qemu-kvm-custom-resolutions/ .

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Message-Id: <20191017203353.18898-2-uwe@kleine-koenig.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-18 12:07:12 +02:00
Uwe Kleine-König dc5cc91aa1 cbvga: reuse svga modes definitions from svgamodes.c
For cbvga only modes with MM_DIRECT are usable, so skip the other ones.
This effectively adds the following modes:

    { 0x10D, { MM_DIRECT, 320,  200,  15, 8, 16, SEG_GRAPH } },
    { 0x10E, { MM_DIRECT, 320,  200,  16, 8, 16, SEG_GRAPH } },
    { 0x10F, { MM_DIRECT, 320,  200,  24, 8, 16, SEG_GRAPH } },
    { 0x140, { MM_DIRECT, 320,  200,  32, 8, 16, SEG_GRAPH } },

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Message-Id: <20191017203353.18898-1-uwe@kleine-koenig.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-18 12:07:12 +02:00
Gerd Hoffmann 020bc4fc5c ati-vga: add rage128 edid support
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-06-24 14:40:39 +02:00
Gerd Hoffmann af573dceef ati-vga: try vga ddc first
Try vga ddc bus before dvi ddc bus.
Return early in case we got valid data.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-06-24 14:39:27 +02:00
Gerd Hoffmann ae9a9796ec ati-vga: make i2c register and bits configurable
Prepare to support other ati cards.  Also log access mode and whenever
we got a valid edid block.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-06-24 14:37:40 +02:00
Gerd Hoffmann 136e2612bd ati-vga: fix ati_read()
Cut & paste bug probably.  Had no bad effect so far because the code
doesn't read registers larger than 0x100.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-06-24 14:35:38 +02:00
Gerd Hoffmann ce52a31f61 ati-vga: make less verbose
Reduce loglevel for mode line removals from 1 to 3.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-06-24 14:35:07 +02:00
Gerd Hoffmann a3fd63c234 bochsdisplay: parse resolution from edid.
Then use the resolution for the framebuffer.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-15 10:11:48 +02:00
Gerd Hoffmann 2f87fe393c bochsdisplay: add edid support.
Read EDID blob from mmio bar, store in VBE_edid.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-15 10:11:48 +02:00
Gerd Hoffmann 083801db10 bochsvga: add edid support.
Read EDID blob from mmio bar, store in VBE_edid.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-15 10:11:48 +02:00
Gerd Hoffmann 588eb12163 ati: add edid support.
Read EDID blob via i2c, store in VBE_edid.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-15 10:11:48 +02:00
Gerd Hoffmann a307d0adc5 vbe: add edid support.
VBE subfunction 0x15, read ddc data.

Add VBE_edid where drivers can fill in a EDID data blob.
If we find valid data there (checking the first two header
bytes), then report the function as supported and hand out
the data.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-15 10:11:48 +02:00
Gerd Hoffmann f4c6e4c19d vga: add ati bios tables
Needed to make drivers happy which try to gather
informations from these tables.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-15 09:59:25 +01:00
Gerd Hoffmann 34b6ecc160 vga: add atiext driver
Supports qemu emulated ati cards.  They have been added in qemu 4.0.
Acceleration support (in qemu) is pretty rough still.  A simple
framebuffer works fine though.

Available models:
 * ati rage 128 pro
 * ati rv100

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-15 09:59:21 +01:00
Gerd Hoffmann 03f5061c0a vga: make memcpy_high() public
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-14 13:07:27 +01:00
Gerd Hoffmann 004f5b3ae5 vga: move modelist from bochsvga.c to new svgamodes.c
So other drivers can simply use the same list too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-14 13:07:17 +01:00
Matt DeVillier bf8e4f902c SeaVGABios/cbvga: Fix bpp for coreboot framebuffer
Commit 4b42cc4 [SeaVGABios/cbvga: Advertise correct pixel format] neglected
to wrap the cbfb mask size components in GET_FARVAR(), which resulted in a
bogus value for bpp, breaking output on most/all devices.  Fix this by
adding GET_FARVAR() as appropriate.

Additionally, some newer ChromeOS devices still fail even with this fix,
so fall back to using the coreboot reported bit depth if the calculated
valid is invalid.

TEST: build/boot a variety of devices (google/[reef,eve], purism/librem_skl)
using coreboot framebuffer init, verify SeaBIOS boot menu prompt visible.

Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
2018-09-18 13:35:30 -04:00
Gerd Hoffmann 69ea6dabeb cbvga_set_mode: refine clear display logic
There is no need to skip text mode clearing.
Clearing the framebuffer should be safe on legacy calls too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-26 09:16:31 +02:00
Gerd Hoffmann d9a8b867a3 qemu: add qemu ramfb support
Add support for qemu ramfb.  This is a simple boot framebuffer device,
with normal ram being used to back the framebuffer and fw_cfg being used
to configure the device.

Use case (on x86): boot display for vgpu devices (which neither emulate
vga nor have a vgabios).

Sharing fw_cfg code with seabios turned out to be difficuilt due to
various dependencies the code has on infrastructure which only seabios
has.  So include a copy of the code here, with those dependencies
removed and also stripped down because we don't need a non-dma fallback
here.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22 07:44:07 +02:00
Gerd Hoffmann e1a9579acd vgasrc: add allocate_pmm()
Factor out pmm allocation function from stack allocator.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22 07:44:07 +02:00
Gerd Hoffmann 7bf9ffff1a bochs_display_setup: return error on failure
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22 07:44:07 +02:00
Gerd Hoffmann ddbb6da350 cbvga_set_mode: disable clearmem in windows x86 emulator.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22 07:44:07 +02:00
Gerd Hoffmann 0c2b3b1d95 cbvga_list_modes: don't list current mode twice
In case we've already added the framebuffer video mode
to the list do not add number 0x140.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22 07:44:07 +02:00
Gerd Hoffmann 902bacb5f0 cbvga_setup_modes: use real mode number instead of 0x140
In case the framebuffer size matches one of the cbvga video modes
just use that mode number instead of 0x140.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22 07:44:07 +02:00
Gerd Hoffmann 77404b450d qemu: add bochs-display support
Use coreboot text mode emulation to also support the qemu bochs-display
device.  This is a new display device supporting simple linear
framebuffers, using the bochs register interface.  No support for legacy
vga (text modes, planar modes, cga modes, 8bpp palette modes all
dropped).  The bochs interface is compatible with the qemu stdvga.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22 07:44:07 +02:00