Add ASPEED VGA PCI device support
Subsystems (2)
v2 cover Add ASPEED VGA PCI device support
This series adds support for the ASPEED VGA PCI device found on AST2600 and AST2700 platforms.
The longer-term goal is to support the video path used by BMC KVM applications. The planned implementation consists of three stages:
1. Add an ASPEED VGA PCI device so that a host system running in QEMU can use the ASPEED VGA device as its display adapter. This series implements this stage.
2. Back the VGA framebuffer with shared memory, for example using a QEMU memory backend backed by /dev/shm/vram. This allows the framebuffer contents produced by the host QEMU instance to be accessed by another QEMU instance emulating the BMC.
3. Add an ASPEED Video Engine model to the AST2600/AST2700 BMC machine. The model will read the shared VGA framebuffer and emulate the video capture and JPEG compression path used by the BMC.
The intended setup runs two QEMU instances on the same host machine:
+-------------------------------------------------------------------+ | Host Machine | | | | +---------------------------+ | | | QEMU 1: VMM / Host Guest | | | | | | | | +---------------------+ | | | | | ASPEED VGA PCI | | | | | | device | | | | | +----------+----------+ | | | | | | | | | v | | | | +---------------------+ | | | | | VGA VRAM | | | | | +----------+----------+ | | | +-------------|-------------+ | | | | | | memory-backend-file | | v | | +-----------------------+ | | | /dev/shm/vram | | | | Shared VRAM file | | | +-----------+-----------+ | | | | | | read by | | v | | +---------------------------+ | | | QEMU 2: BMC | | | | AST2600 / AST2700 | | | | | | | | +---------------------+ | | | | | ASPEED Video Engine | | | | | | | | | | | | - Read VRAM | | | | | | - Capture frame | | | | | | - Compress video | | | | | +----------+----------+ | | | +-------------|-------------+ | | | | +----------------|--------------------------------------------------+
With the complete implementation, users will be able to view the display output of the emulated host through the OpenBMC KVM web interface.
This series adds the following devices:
- ``ast2600-vga`` Aspeed AST2600 VGA
- ``ast2700-vga`` Aspeed AST2700 VGA
The size of the framebuffer aperture is set with ``vgamem_mb``, 32 MiB by default. The device comes up with the standard VGA BIOS; pass ``romfile`` to use Aspeed's own option ROM instead, which can be downloaded from
https://www.aspeedtech.com/support_driver/
For example, the AST2700 VGA device can be used with an aarch64 virt machine as follows:
$ qemu-system-aarch64 \
-M virt \
-cpu neoverse-n1 -smp 8 -m 4G \
-bios edk2-aarch64-code.fd \
-device ast2700-vga,vgamem_mb=32,romfile=uefi_arm_2700_vga.rom \
-drive file=noble-server-cloudimg-arm64.img,format=qcow2 \
-device qemu-xhci,id=xhci \
-device usb-kbd,bus=xhci.0 \
-device usb-tablet,bus=xhci.0 \
-display vnc=0.0.0.0:0The disk image is an Ubuntu cloud image from
https://cloud-images.ubuntu.com/.
The output goes to the VNC backend on display 0, which listens on TCP port 5900, so point a VNC viewer at that port to see the screen.
v1:
1. Add ASPEED VGA display controller
2. Add the hardware overlay cursor
3. Add the 2D graphics engine
v2:
1. Drop "Add the ASPEED VGA device id" patch
Jamin Lin (6):
hw/display/vga: Allow a device to report vendor specific blanking hw/display/vga: Move VGA_HPEL_NEUTRAL to vga_int.h hw/display/aspeed-vga: Add ASPEED VGA display controller hw/display/aspeed-vga: Add the hardware overlay cursor hw/display/aspeed-vga: Add the 2D graphics engine docs/system/arm/aspeed: Document the VGA display controller
docs/system/arm/aspeed.rst | 37 +- hw/display/aspeed-vga.h | 61 +++ hw/display/vga_int.h | 9 + hw/display/aspeed-vga.c | 945 +++++++++++++++++++++++++++++++++++++ hw/display/vga.c | 11 +- hw/display/Kconfig | 6 + hw/display/meson.build | 1 + hw/display/trace-events | 7 + 8 files changed, 1066 insertions(+), 11 deletions(-) create mode 100644 hw/display/aspeed-vga.h create mode 100644 hw/display/aspeed-vga.c
Signature · 1 line
2.53.0
PATCH v2 1/6 hw/display/vga: Allow a device to report vendor specific blanking
The common code decides that the display is blanked by looking at bit 5 of the attribute controller index register. A device which instead gates the sync signals through vendor specific registers has no way to express that, and keeps scanning out the last image after its CRTC was disabled.
Add an optional is_blanked() callback for such a device to report it. Devices which leave it unset are unaffected.
--- hw/display/vga_int.h | 1 + hw/display/vga.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/display/vga_int.h +1 -0
@@ -99,6 +99,7 @@ typedef struct VGACommonState {uint8_t palette[768 ];int32_t bank_offset;int (*get_bpp)(struct VGACommonState *s); +bool (*is_blanked)(struct VGACommonState *s);void (*get_params)(struct VGACommonState *s,VGADisplayParams *params); void (*get_resolution)(struct VGACommonState *s, int *pwidth,
hw/display/vga.c +2 -2
@@ -1814,7 +1814,7 @@ static bool vga_update_display(void *opaque)/* nothing to do */ }else { full_update =0 ; -if (!(s->ar_index &0x20 )) { +if (!(s->ar_index &0x20 ) || (s->is_blanked && s->is_blanked (s))) { graphic_mode =GMODE_BLANK ; }else { graphic_mode = s->gr[VGA_GFX_MISC ] &VGA_GR06_GRAPHICS_MODE ;
@@ -1936,7 +1936,7 @@ static void vga_update_text(void *opaque, uint32_t *chardata)qemu_flush_coalesced_mmio_buffer (); -if (!(s->ar_index &0x20 )) { +if (!(s->ar_index &0x20 ) || (s->is_blanked && s->is_blanked (s))) { graphic_mode =GMODE_BLANK ; }else { graphic_mode = s->gr[VGA_GFX_MISC ] &VGA_GR06_GRAPHICS_MODE ;
Signature · 1 line
2.53.0
PATCH v2 2/6 hw/display/vga: Move VGA_HPEL_NEUTRAL to vga_int.h
In reply to Jamin LinVGA_HPEL_NEUTRAL is the pel panning value that means no shift. Move it to the header so that other VGA devices can use it.
No functional change.
--- hw/display/vga_int.h | 8 ++++++++ hw/display/vga.c | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-)
hw/display/vga_int.h +8 -0
@@ -38,6 +38,14 @@#define CH_ATTR_SIZE (160 * 100)#define VGA_MAX_HEIGHT 2048 +/* +* This value corresponds to a shift of zero pixels +* in 9-dot text mode. In other modes, bit 3 is undefined; +* we just ignore it, so that 8 corresponds to zero pixels +* in all modes. +*/ +#define VGA_HPEL_NEUTRAL 8 +struct vga_precise_retrace {int64_t ticks_per_char;int64_t total_chars;
hw/display/vga.c +0 -7
@@ -53,13 +53,6 @@ bool have_vga = true;/* Address mask for non-VESA modes. */ #define VGA_VRAM_SIZE (256 * KiB) -/* This value corresponds to a shift of zero pixels -* in 9-dot text mode. In other modes, bit 3 is undefined; -* we just ignore it, so that 8 corresponds to zero pixels -* in all modes. -*/ -#define VGA_HPEL_NEUTRAL 8 -/* * Video Graphics Array (VGA) *
Signature · 1 line
2.53.0
PATCH v2 3/6 hw/display/aspeed-vga: Add ASPEED VGA display controller
In reply to Jamin LinThe host reaches the display controller of the ASPEED BMC SoCs as a PCI VGA device. It follows the IBM VGA 1.0 specification and adds vendor specific CRTC registers that describe the linear framebuffer.
- BAR 0 is the framebuffer. CRAA reports its size.
- BAR 1 is a window over the SoC registers. Only the mirror of the legacy VGA I/O ports at offset 0x380 is modelled.
- The legacy VGA I/O ports and the 0xa0000 window let a VGA BIOS drive the device until the guest driver takes over. The bochs VBE ports are left out; the hardware has no such interface.
- The extended CRTC registers carry the color format (CRA3), the line offset (CR13, CRB0), the scanout address (CR0C, CR0D, CRAF) and the mode overflow bits (CRAC, CRAE). Until the driver sets a color format the device behaves as a standard VGA.
- Blanking follows CR17 and CRB6, which is how the driver turns the CRTC off.
Reset leaves the device as the BMC firmware would, so the driver does not try to POST the chip. That includes selecting the color I/O addresses, without which every access to the extended registers at 0x3d4/0x3d5 would be rejected as belonging to the monochrome range.
Port 0x3c3, the VGA enable register, is not in the common code and is handled here.
The AST2600 and AST2700 differ only in the PCI revision id the driver reads to tell the SoC generations apart, so that is a class attribute.
--- hw/display/aspeed-vga.h | 49 ++++ hw/display/aspeed-vga.c | 490 ++++++++++++++++++++++++++++++++++++++++ hw/display/Kconfig | 6 + hw/display/meson.build | 1 + hw/display/trace-events | 4 + 5 files changed, 550 insertions(+) create mode 100644 hw/display/aspeed-vga.h create mode 100644 hw/display/aspeed-vga.c
hw/display/aspeed-vga.h new file +49 -0
@@ -0,0 +1,49 @@ +/* +* ASPEED VGA display controller +* +* Copyright (c) 2026 ASPEED Technology Inc. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_DISPLAY_ASPEED_VGA_H +#define HW_DISPLAY_ASPEED_VGA_H + +#include "qemu/units.h" +#include "qom/object.h" +#include "hw/pci/pci_device.h" +#include "vga_int.h" + +#define TYPE_ASPEED_VGA "aspeed-vga" +#define TYPE_AST2600_VGA "ast2600-vga" +#define TYPE_AST2700_VGA "ast2700-vga" +OBJECT_DECLARE_TYPE (AspeedVGAState, AspeedVGAClass,ASPEED_VGA ) + +/* BAR 1 is a 128KB window over the SoC registers */ +#define ASPEED_VGA_MMIO_SIZE (128 * KiB) +/* VGA, offset 0x380 from the BAR 1 register base */ +#define ASPEED_VGA_IOPORT_OFFSET 0x380 +#define ASPEED_VGA_IOPORT_SIZE 0x80 + +struct AspeedVGAState { +PCIDevice parent_obj; + +VGACommonState vga; +MemoryRegion mmio; +MemoryRegion ioport; + +uint8_t vgaer; + +/* saved standard VGA handlers, used while the extended mode is off */ +int (*std_get_bpp)(VGACommonState *s); +void (*std_get_params)(VGACommonState *s,VGADisplayParams *params); +void (*std_get_resolution)(VGACommonState *s,int *pwidth,int *pheight); +}; + +struct AspeedVGAClass { +PCIDeviceClass parent_class; + +uint8_t revision; +}; + +#endif /* HW_DISPLAY_ASPEED_VGA_H */
hw/display/aspeed-vga.c new file +490 -0
490 lines not on this page · raw message
hw/display/Kconfig +6 -0
@@ -48,6 +48,12 @@ config VGA_PCI select VGA select EDID +config ASPEED_VGA + bool + default y if PCI_DEVICES + depends on PCI + select VGA + config VGA_ISA bool depends on ISA_BUS
hw/display/meson.build +1 -0
@@ -18,6 +18,7 @@ system_ss.add(when: 'CONFIG_SSD0303', if_true: files('ssd0303.c')) system_ss.add(when: 'CONFIG_SSD0323', if_true: files('ssd0323.c')) system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xenfb.c')) +system_ss.add(when: 'CONFIG_ASPEED_VGA', if_true: files('aspeed-vga.c')) system_ss.add(when: 'CONFIG_VGA_PCI', if_true: files('vga-pci.c')) system_ss.add(when: 'CONFIG_VGA_ISA', if_true: files('vga-isa.c')) system_ss.add(when: 'CONFIG_VGA_MMIO', if_true: files('vga-mmio.c'))
hw/display/trace-events +4 -0
@@ -138,6 +138,10 @@ vga_cirrus_write_blt(uint32_t offset, uint32_t val) "offset 0x%x, val 0x%x" vga_cirrus_write_gr(uint8_t index, uint8_t val) "GR addr 0x%02x, val 0x%02x" vga_cirrus_bitblt_start(uint8_t blt_rop, uint8_t blt_mode, uint8_t blt_modeext, int blt_width, int blt_height, int blt_dstpitch, int blt_srcpitch, uint32_t blt_dstaddr, uint32_t blt_srcaddr, uint8_t gr_val) "rop=0x%02x mode=0x%02x modeext=0x%02x w=%d h=%d dpitch=%d spitch=%d daddr=0x%08"PRIx32" saddr=0x%08"PRIx32" writemask=0x%02x" +# aspeed-vga.c +aspeed_vga_read_byte(uint32_t port, uint8_t val) "port 0x%03x, val 0x%02x" +aspeed_vga_write_byte(uint32_t port, uint8_t val) "port 0x%03x, val 0x%02x" + # sii9022.c sii9022_read_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x" sii9022_write_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
Signature · 1 line
2.53.0
PATCH v2 4/6 hw/display/aspeed-vga: Add the hardware overlay cursor
In reply to Jamin LinThe display controller draws a 64x64 cursor over the picture. CRC2 to CRCB hold its position, the address of its bitmap in the framebuffer, the offsets into that bitmap and the format.
Draw it through the common code's cursor callbacks. The position cannot be negative, so the offsets say how many rows and columns to skip when the cursor runs off the top or the left of the screen.
CRCB selects the format. Both are modelled: ARGB4444, and the one the datasheet calls 2 bpp, which is also two bytes per pixel but carries an AND and an XOR mask in the top two bits instead of an alpha.
--- hw/display/aspeed-vga.h | 2 + hw/display/aspeed-vga.c | 194 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+)
hw/display/aspeed-vga.h +2 -0
@@ -33,6 +33,8 @@ struct AspeedVGAState {MemoryRegion ioport;uint8_t vgaer; +uint32_t last_cursor_y; +bool last_cursor_on;/* saved standard VGA handlers, used while the extended mode is off */ int (*std_get_bpp)(VGACommonState *s);
hw/display/aspeed-vga.c +194 -0
233 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 5/6 hw/display/aspeed-vga: Add the 2D graphics engine
In reply to Jamin LinThe display controller has a 2D engine at BAR 1 + 0x8000. It was not modelled, so its status register read back as all ones, which bit 31 defines as a busy engine. ASPEED's UEFI driver waits for it and stops when it tries to scroll the console.
Add the engine as a second subregion of BAR 1 and model the BitBLT command, which is the one the firmware uses. Only the source copy raster operation is done; other operations, clipping, patterns and the transparent monochrome mask are logged and nothing is drawn. A rectangle that does not fit in the framebuffer is rejected rather than half copied.
The command carries a direction for each axis. When one is negative the coordinates are the last row or column, so an overlapping copy starts from that end and a scroll does not smear.
The status register reads as idle after reset, a write of one clears that bit, and it is set again when a command finishes.
--- hw/display/aspeed-vga.h | 10 ++ hw/display/aspeed-vga.c | 261 ++++++++++++++++++++++++++++++++++++++++ hw/display/trace-events | 3 + 3 files changed, 274 insertions(+)
hw/display/aspeed-vga.h +10 -0
@@ -25,13 +25,23 @@ OBJECT_DECLARE_TYPE(AspeedVGAState, AspeedVGAClass, ASPEED_VGA)#define ASPEED_VGA_IOPORT_OFFSET 0x380#define ASPEED_VGA_IOPORT_SIZE 0x80 +/* +* 2D Graphics Engine (G2D) +* +* Offset 0x8000 from the BAR 1 register base +*/ +#define ASPEED_VGA_G2D_OFFSET 0x8000 +#define ASPEED_VGA_G2D_NR_REGS (0x200 >> 2) +struct AspeedVGAState {PCIDevice parent_obj;VGACommonState vga;MemoryRegion mmio;MemoryRegion ioport; +MemoryRegion g2d; +uint32_t g2d_regs[ASPEED_VGA_G2D_NR_REGS ];uint8_t vgaer;uint32_t last_cursor_y;bool last_cursor_on;
hw/display/aspeed-vga.c +261 -0
285 lines not on this page · raw message
hw/display/trace-events +3 -0
@@ -141,6 +141,9 @@ vga_cirrus_bitblt_start(uint8_t blt_rop, uint8_t blt_mode, uint8_t blt_modeext, # aspeed-vga.c aspeed_vga_read_byte(uint32_t port, uint8_t val) "port 0x%03x, val 0x%02x" aspeed_vga_write_byte(uint32_t port, uint8_t val) "port 0x%03x, val 0x%02x" +aspeed_g2d_read(uint32_t reg, uint32_t val) "reg 0x%02x, val 0x%08x" +aspeed_g2d_write(uint32_t reg, uint32_t val) "reg 0x%02x, val 0x%08x" +aspeed_g2d_bitblt(uint32_t cmd, uint32_t w, uint32_t h, uint32_t sx, uint32_t sy, uint32_t dx, uint32_t dy, uint32_t bpp) "cmd 0x%08x, %ux%u, src %u,%u dst %u,%u, %u bytes/pixel" # sii9022.c sii9022_read_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
Signature · 1 line
2.53.0
PATCH v2 6/6 docs/system/arm/aspeed: Document the VGA display controller
In reply to Jamin LinThe display controller was listed as missing, which it no longer is. It does not belong with the rest of the machines' devices though: the host reaches it as a PCI VGA endpoint, so it is plugged into whichever machine stands in for the host rather than being part of the BMC machine.
Describe it that way, with the two flavours, the property that sizes the framebuffer aperture, the option ROM, and how to reach the screen.
--- docs/system/arm/aspeed.rst | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
docs/system/arm/aspeed.rst +35 -2
@@ -75,7 +75,6 @@ Missing devices * Slave GPIO Controller * Super I/O Controller * PCI-Express 1 Controller - * Graphic Display Controller * MCTP Controller * Mailbox Controller * Virtual UART
@@ -319,7 +318,6 @@ Missing devices * Slave GPIO Controller * Super I/O Controller * PCI-Express 1 Controller - * Graphic Display Controller * MCTP Controller * Mailbox Controller * Virtual UART
@@ -512,3 +510,38 @@ To boot a kernel directly from a Zephyr build tree: $ qemu-system-arm -M ast1030-evb -nographic \ -kernel zephyr.bin + +VGA display controller +====================== + +The display controller of the Aspeed SoCs is reached by the host as a PCI +VGA endpoint, so it is modelled as a device to be plugged into whichever +machine plays that host rather than as part of the BMC machines above: + +- ``ast2600-vga`` Aspeed AST2600 VGA +- ``ast2700-vga`` Aspeed AST2700 VGA + +The size of the framebuffer aperture is set with ``vgamem_mb``, 32 MiB by +default. The device comes up with the standard VGA BIOS; pass ``romfile`` +to use Aspeed's own option ROM instead, which can be downloaded from +https://www.aspeedtech.com/support_driver/ + +To plug one into an ``aarch64`` guest standing in for the host: + +.. code-block:: bash + + $ qemu-system-aarch64 \ + -M virt \ + -cpu neoverse-n1 -smp 8 -m 4G \ + -bios edk2-aarch64-code.fd \ + -device ast2700-vga,vgamem_mb=32,romfile=uefi_arm_2700_vga.rom \ + -drive file=noble-server-cloudimg-arm64.img,format=qcow2 \ + -device qemu-xhci,id=xhci \ + -device usb-kbd,bus=xhci.0 \ + -device usb-tablet,bus=xhci.0 \ + -display vnc=0.0.0.0:0 + +The disk image is an Ubuntu cloud image from +https://cloud-images.ubuntu.com/. The output goes to the VNC backend on +display 0, which listens on TCP port 5900, so point a VNC viewer at that +port to see the screen.
Signature · 1 line
2.53.0