From nobody Fri May 17 00:49:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530697968986692.8210631690066; Wed, 4 Jul 2018 02:52:48 -0700 (PDT) Received: from localhost ([::1]:44959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeSu-0002e8-AI for importer@patchew.org; Wed, 04 Jul 2018 05:52:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeOo-0008D4-9d for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faeOk-0003vt-SQ for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:34 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:46771) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faeOk-0003vM-CZ for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:30 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id ECD4E7456C0; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 5CFDE7456C8; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Message-Id: <216f2ade44cffa51ec743113e1aaa869bc3df57d.1530697258.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Date: Wed, 04 Jul 2018 11:40:58 +0200 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 Subject: [Qemu-devel] [PATCH v3 1/7] sm501: Implement i2c part for reading monitor EDID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sebastian Bauer , Magnus Damm , Philippe Mathieu-Daude , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Emulate the i2c part of SM501 which is used to access the EDID info from a monitor. The vmstate structure is changed and its version is increased but SM501 is only used on SH and PPC sam460ex machines that don't support cross-version migration. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud\ufffd\ufffd --- v3: - Fixed resetting error bit in status reg - Add comment for ddc v2: - added constants for register bits - fix clearing error bit in reset reg - set max access size to 1 v1: fixed build with SH default-configs/ppc-softmmu.mak | 1 + default-configs/ppcemb-softmmu.mak | 1 + default-configs/sh4-softmmu.mak | 2 + default-configs/sh4eb-softmmu.mak | 2 + hw/display/sm501.c | 147 +++++++++++++++++++++++++++++++++= +++- 5 files changed, 149 insertions(+), 4 deletions(-) diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.= mak index 6f12bf8..3181bbf 100644 --- a/default-configs/ppc-softmmu.mak +++ b/default-configs/ppc-softmmu.mak @@ -25,6 +25,7 @@ CONFIG_ETSEC=3Dy CONFIG_SAM460EX=3Dy CONFIG_USB_EHCI_SYSBUS=3Dy CONFIG_SM501=3Dy +CONFIG_DDC=3Dy CONFIG_IDE_SII3112=3Dy CONFIG_I2C=3Dy CONFIG_BITBANG_I2C=3Dy diff --git a/default-configs/ppcemb-softmmu.mak b/default-configs/ppcemb-so= ftmmu.mak index 37af193..ac44f15 100644 --- a/default-configs/ppcemb-softmmu.mak +++ b/default-configs/ppcemb-softmmu.mak @@ -17,6 +17,7 @@ CONFIG_XILINX=3Dy CONFIG_XILINX_ETHLITE=3Dy CONFIG_USB_EHCI_SYSBUS=3Dy CONFIG_SM501=3Dy +CONFIG_DDC=3Dy CONFIG_IDE_SII3112=3Dy CONFIG_I2C=3Dy CONFIG_BITBANG_I2C=3Dy diff --git a/default-configs/sh4-softmmu.mak b/default-configs/sh4-softmmu.= mak index 546d855..caeccd5 100644 --- a/default-configs/sh4-softmmu.mak +++ b/default-configs/sh4-softmmu.mak @@ -9,6 +9,8 @@ CONFIG_PFLASH_CFI02=3Dy CONFIG_SH4=3Dy CONFIG_IDE_MMIO=3Dy CONFIG_SM501=3Dy +CONFIG_I2C=3Dy +CONFIG_DDC=3Dy CONFIG_ISA_TESTDEV=3Dy CONFIG_I82378=3Dy CONFIG_I8259=3Dy diff --git a/default-configs/sh4eb-softmmu.mak b/default-configs/sh4eb-soft= mmu.mak index 2d3fd49..53b9cd7 100644 --- a/default-configs/sh4eb-softmmu.mak +++ b/default-configs/sh4eb-softmmu.mak @@ -9,6 +9,8 @@ CONFIG_PFLASH_CFI02=3Dy CONFIG_SH4=3Dy CONFIG_IDE_MMIO=3Dy CONFIG_SM501=3Dy +CONFIG_I2C=3Dy +CONFIG_DDC=3Dy CONFIG_ISA_TESTDEV=3Dy CONFIG_I82378=3Dy CONFIG_I8259=3Dy diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 9dec0d3..05c964b 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qapi/error.h" +#include "qemu/log.h" #include "qemu-common.h" #include "cpu.h" #include "hw/hw.h" @@ -34,6 +35,8 @@ #include "hw/devices.h" #include "hw/sysbus.h" #include "hw/pci/pci.h" +#include "hw/i2c/i2c.h" +#include "hw/i2c/i2c-ddc.h" #include "qemu/range.h" #include "ui/pixel_ops.h" =20 @@ -216,6 +219,14 @@ #define SM501_I2C_SLAVE_ADDRESS (0x03) #define SM501_I2C_DATA (0x04) =20 +#define SM501_I2C_CONTROL_START (1 << 2) +#define SM501_I2C_CONTROL_ENABLE (1 << 0) + +#define SM501_I2C_STATUS_COMPLETE (1 << 3) +#define SM501_I2C_STATUS_ERROR (1 << 2) + +#define SM501_I2C_RESET_ERROR (1 << 2) + /* SSP base */ #define SM501_SSP (0x020000) =20 @@ -471,10 +482,12 @@ typedef struct SM501State { MemoryRegion local_mem_region; MemoryRegion mmio_region; MemoryRegion system_config_region; + MemoryRegion i2c_region; MemoryRegion disp_ctrl_region; MemoryRegion twoD_engine_region; uint32_t last_width; uint32_t last_height; + I2CBus *i2c_bus; =20 /* mmio registers */ uint32_t system_control; @@ -487,6 +500,11 @@ typedef struct SM501State { uint32_t misc_timing; uint32_t power_mode_control; =20 + uint8_t i2c_byte_count; + uint8_t i2c_status; + uint8_t i2c_addr; + uint8_t i2c_data[16]; + uint32_t uart0_ier; uint32_t uart0_lcr; uint32_t uart0_mcr; @@ -897,6 +915,109 @@ static const MemoryRegionOps sm501_system_config_ops = =3D { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 +static uint64_t sm501_i2c_read(void *opaque, hwaddr addr, unsigned size) +{ + SM501State *s =3D (SM501State *)opaque; + uint8_t ret =3D 0; + + switch (addr) { + case SM501_I2C_BYTE_COUNT: + ret =3D s->i2c_byte_count; + break; + case SM501_I2C_STATUS: + ret =3D s->i2c_status; + break; + case SM501_I2C_SLAVE_ADDRESS: + ret =3D s->i2c_addr; + break; + case SM501_I2C_DATA ... SM501_I2C_DATA + 15: + ret =3D s->i2c_data[addr - SM501_I2C_DATA]; + break; + default: + qemu_log_mask(LOG_UNIMP, "sm501 i2c : not implemented register rea= d." + " addr=3D0x%" HWADDR_PRIx "\n", addr); + } + + SM501_DPRINTF("sm501 i2c regs : read addr=3D%" HWADDR_PRIx " val=3D%x\= n", + addr, ret); + return ret; +} + +static void sm501_i2c_write(void *opaque, hwaddr addr, uint64_t value, + unsigned size) +{ + SM501State *s =3D (SM501State *)opaque; + SM501_DPRINTF("sm501 i2c regs : write addr=3D%" HWADDR_PRIx + " val=3D%" PRIx64 "\n", addr, value); + + switch (addr) { + case SM501_I2C_BYTE_COUNT: + s->i2c_byte_count =3D value & 0xf; + break; + case SM501_I2C_CONTROL: + if (value & SM501_I2C_CONTROL_ENABLE) { + if (value & SM501_I2C_CONTROL_START) { + int res =3D i2c_start_transfer(s->i2c_bus, + s->i2c_addr >> 1, + s->i2c_addr & 1); + s->i2c_status |=3D (res ? SM501_I2C_STATUS_ERROR : 0); + if (!res) { + int i; + SM501_DPRINTF("sm501 i2c : transferring %d bytes to 0x= %x\n", + s->i2c_byte_count + 1, s->i2c_addr >> 1); + for (i =3D 0; i <=3D s->i2c_byte_count; i++) { + res =3D i2c_send_recv(s->i2c_bus, &s->i2c_data[i], + !(s->i2c_addr & 1)); + if (res) { + SM501_DPRINTF("sm501 i2c : transfer failed" + " i=3D%d, res=3D%d\n", i, res); + s->i2c_status |=3D (res ? SM501_I2C_STATUS_ERR= OR : 0); + return; + } + } + if (i) { + SM501_DPRINTF("sm501 i2c : transferred %d bytes\n"= , i); + s->i2c_status =3D SM501_I2C_STATUS_COMPLETE; + } + } + } else { + SM501_DPRINTF("sm501 i2c : end transfer\n"); + i2c_end_transfer(s->i2c_bus); + s->i2c_status &=3D ~SM501_I2C_STATUS_ERROR; + } + } + break; + case SM501_I2C_RESET: + if ((value & SM501_I2C_RESET_ERROR) =3D=3D 0) { + s->i2c_status &=3D ~SM501_I2C_STATUS_ERROR; + } + break; + case SM501_I2C_SLAVE_ADDRESS: + s->i2c_addr =3D value & 0xff; + break; + case SM501_I2C_DATA ... SM501_I2C_DATA + 15: + s->i2c_data[addr - SM501_I2C_DATA] =3D value & 0xff; + break; + default: + qemu_log_mask(LOG_UNIMP, "sm501 i2c : not implemented register wri= te. " + "addr=3D0x%" HWADDR_PRIx " val=3D%" PRIx64 "\n", add= r, value); + } +} + +static const MemoryRegionOps sm501_i2c_ops =3D { + .read =3D sm501_i2c_read, + .write =3D sm501_i2c_write, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, + .endianness =3D DEVICE_LITTLE_ENDIAN, +}; + static uint32_t sm501_palette_read(void *opaque, hwaddr addr) { SM501State *s =3D (SM501State *)opaque; @@ -1577,6 +1698,10 @@ static void sm501_reset(SM501State *s) s->irq_mask =3D 0; s->misc_timing =3D 0; s->power_mode_control =3D 0; + s->i2c_byte_count =3D 0; + s->i2c_status =3D 0; + s->i2c_addr =3D 0; + memset(s->i2c_data, 0, 16); s->dc_panel_control =3D 0x00010000; /* FIFO level 3 */ s->dc_video_control =3D 0; s->dc_crt_control =3D 0x00010000; @@ -1615,6 +1740,12 @@ static void sm501_init(SM501State *s, DeviceState *d= ev, memory_region_set_log(&s->local_mem_region, true, DIRTY_MEMORY_VGA); s->local_mem =3D memory_region_get_ram_ptr(&s->local_mem_region); =20 + /* i2c */ + s->i2c_bus =3D i2c_init_bus(dev, "sm501.i2c"); + /* ddc */ + I2CDDCState *ddc =3D I2CDDC(qdev_create(BUS(s->i2c_bus), TYPE_I2CDDC)); + i2c_set_slave_address(I2C_SLAVE(ddc), 0x50); + /* mmio */ memory_region_init(&s->mmio_region, OBJECT(dev), "sm501.mmio", MMIO_SI= ZE); memory_region_init_io(&s->system_config_region, OBJECT(dev), @@ -1622,6 +1753,9 @@ static void sm501_init(SM501State *s, DeviceState *de= v, "sm501-system-config", 0x6c); memory_region_add_subregion(&s->mmio_region, SM501_SYS_CONFIG, &s->system_config_region); + memory_region_init_io(&s->i2c_region, OBJECT(dev), &sm501_i2c_ops, s, + "sm501-i2c", 0x14); + memory_region_add_subregion(&s->mmio_region, SM501_I2C, &s->i2c_region= ); memory_region_init_io(&s->disp_ctrl_region, OBJECT(dev), &sm501_disp_ctrl_ops, s, "sm501-disp-ctrl", 0x1000); @@ -1705,6 +1839,11 @@ static const VMStateDescription vmstate_sm501_state = =3D { VMSTATE_UINT32(twoD_destination_base, SM501State), VMSTATE_UINT32(twoD_alpha, SM501State), VMSTATE_UINT32(twoD_wrap, SM501State), + /* Added in version 2 */ + VMSTATE_UINT8(i2c_byte_count, SM501State), + VMSTATE_UINT8(i2c_status, SM501State), + VMSTATE_UINT8(i2c_addr, SM501State), + VMSTATE_UINT8_ARRAY(i2c_data, SM501State, 16), VMSTATE_END_OF_LIST() } }; @@ -1770,8 +1909,8 @@ static void sm501_reset_sysbus(DeviceState *dev) =20 static const VMStateDescription vmstate_sm501_sysbus =3D { .name =3D TYPE_SYSBUS_SM501, - .version_id =3D 1, - .minimum_version_id =3D 1, + .version_id =3D 2, + .minimum_version_id =3D 2, .fields =3D (VMStateField[]) { VMSTATE_STRUCT(state, SM501SysBusState, 1, vmstate_sm501_state, SM501State), @@ -1843,8 +1982,8 @@ static void sm501_reset_pci(DeviceState *dev) =20 static const VMStateDescription vmstate_sm501_pci =3D { .name =3D TYPE_PCI_SM501, - .version_id =3D 1, - .minimum_version_id =3D 1, + .version_id =3D 2, + .minimum_version_id =3D 2, .fields =3D (VMStateField[]) { VMSTATE_PCI_DEVICE(parent_obj, SM501PCIState), VMSTATE_STRUCT(state, SM501PCIState, 1, --=20 2.7.6 From nobody Fri May 17 00:49:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530697844369256.71768876083956; Wed, 4 Jul 2018 02:50:44 -0700 (PDT) Received: from localhost ([::1]:44945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeQk-0000mm-KA for importer@patchew.org; Wed, 04 Jul 2018 05:50:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeOo-0008D2-48 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faeOj-0003uo-Ag for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:34 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:46749) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faeOj-0003uU-4G for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:29 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id D70567456C7; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 600207456B9; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Message-Id: <9f1748f9606783e4bd84d9567a7d50b82c57553a.1530697258.git.balaton@eik.bme.hu> In-Reply-To: References: From: Sebastian Bauer Date: Wed, 04 Jul 2018 11:40:58 +0200 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 Subject: [Qemu-devel] [PATCH v3 2/7] sm501: Perform a full update after palette change X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sebastian Bauer , Magnus Damm , Philippe Mathieu-Daude , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sebastian Bauer Changing the palette of a color index has as an immediate effect on all pixels with the corresponding index on real hardware. Performing a full update after a palette change is a simple way to emulate this effect. Signed-off-by: Sebastian Bauer Signed-off-by: BALATON Zoltan --- v2: change type to bool hw/display/sm501.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 05c964b..b095134 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -487,6 +487,7 @@ typedef struct SM501State { MemoryRegion twoD_engine_region; uint32_t last_width; uint32_t last_height; + bool do_full_update; /* perform a full update next time */ I2CBus *i2c_bus; =20 /* mmio registers */ @@ -1042,6 +1043,7 @@ static void sm501_palette_write(void *opaque, hwaddr = addr, =20 assert(range_covers_byte(0, 0x400 * 3, addr)); *(uint32_t *)&s->dc_palette[addr] =3D value; + s->do_full_update =3D true; } =20 static uint64_t sm501_disp_ctrl_read(void *opaque, hwaddr addr, @@ -1630,6 +1632,12 @@ static void sm501_update_display(void *opaque) full_update =3D 1; } =20 + /* someone else requested a full update */ + if (s->do_full_update) { + s->do_full_update =3D false; + full_update =3D 1; + } + /* draw each line according to conditions */ snap =3D memory_region_snapshot_and_clear_dirty(&s->local_mem_region, offset, width * height * src_bpp, DIRTY_MEMORY_VGA); --=20 2.7.6 From nobody Fri May 17 00:49:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530698073173482.3627051718113; Wed, 4 Jul 2018 02:54:33 -0700 (PDT) Received: from localhost ([::1]:44964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeUa-0003pb-Ft for importer@patchew.org; Wed, 04 Jul 2018 05:54:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeOo-0008D8-Aq for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faeOk-0003vf-IL for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:34 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:46769) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faeOk-0003vH-BN for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:30 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id D91597456CA; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 6340A7456C0; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Message-Id: <9da35f5a69f3504c5ebc8bd0ae548c91ef0a3634.1530697258.git.balaton@eik.bme.hu> In-Reply-To: References: From: Sebastian Bauer Date: Wed, 04 Jul 2018 11:40:58 +0200 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH v3 3/7] sm501: Use values from the pitch register for 2D operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sebastian Bauer , Magnus Damm , Philippe Mathieu-Daude , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Before, crt_h_total was used for src_width and dst_width. This is a property of the current display setting and not relevant for the 2D operation that also can be done off-screen. The pitch register's purpose is to describe line pitch relevant of the 2D operation. Signed-off-by: Sebastian Bauer Signed-off-by: BALATON Zoltan --- hw/display/sm501.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index b095134..d4878f0 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -709,8 +709,8 @@ static void sm501_2d_operation(SM501State *s) /* get frame buffer info */ uint8_t *src =3D s->local_mem + (s->twoD_source_base & 0x03FFFFFF); uint8_t *dst =3D s->local_mem + (s->twoD_destination_base & 0x03FFFFFF= ); - int src_width =3D (s->dc_crt_h_total & 0x00000FFF) + 1; - int dst_width =3D (s->dc_crt_h_total & 0x00000FFF) + 1; + int src_width =3D s->twoD_pitch & 0x1FFF; + int dst_width =3D (s->twoD_pitch >> 16) & 0x1FFF; =20 if (addressing !=3D 0x0) { printf("%s: only XY addressing is supported.\n", __func__); --=20 2.7.6 From nobody Fri May 17 00:49:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530697965596380.68667901412243; Wed, 4 Jul 2018 02:52:45 -0700 (PDT) Received: from localhost ([::1]:44958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeSq-0002bV-VZ for importer@patchew.org; Wed, 04 Jul 2018 05:52:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeOo-0008D7-AQ for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faeOj-0003v7-Do for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:34 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:46728) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faeOj-0003uP-4J for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:29 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 908BB7456CC; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 67C297456C9; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Message-Id: <5336b4402ad41f178a5a816129e563709923d73f.1530697258.git.balaton@eik.bme.hu> In-Reply-To: References: From: Sebastian Bauer Date: Wed, 04 Jul 2018 11:40:58 +0200 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 Subject: [Qemu-devel] [PATCH v3 4/7] sm501: Implement negated destination raster operation mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sebastian Bauer , Magnus Damm , Philippe Mathieu-Daude , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add support for the negated destination operation mode. This is used e.g. by AmigaOS for the INVERSEVID drawing mode. With this change, the cursor in the shell and non-immediate window adjustment are working now. Signed-off-by: BALATON Zoltan --- hw/display/sm501.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index d4878f0..0b44d95 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -705,6 +705,8 @@ static void sm501_2d_operation(SM501State *s) uint32_t color =3D s->twoD_foreground; int format_flags =3D (s->twoD_stretch >> 20) & 0x3; int addressing =3D (s->twoD_stretch >> 16) & 0xF; + int rop_mode =3D (s->twoD_control >> 15) & 0x1; /* 1 for rop2, else ro= p3 */ + int rop =3D s->twoD_control & 0xFF; =20 /* get frame buffer info */ uint8_t *src =3D s->local_mem + (s->twoD_source_base & 0x03FFFFFF); @@ -729,6 +731,8 @@ static void sm501_2d_operation(SM501State *s) int y, x, index_d, index_s; = \ for (y =3D 0; y < operation_height; y++) { = \ for (x =3D 0; x < operation_width; x++) { = \ + _pixel_type val; = \ + = \ if (rtl) { = \ index_s =3D ((src_y - y) * src_width + src_x - x) * _b= pp; \ index_d =3D ((dst_y - y) * dst_width + dst_x - x) * _b= pp; \ @@ -736,7 +740,13 @@ static void sm501_2d_operation(SM501State *s) index_s =3D ((src_y + y) * src_width + src_x + x) * _b= pp; \ index_d =3D ((dst_y + y) * dst_width + dst_x + x) * _b= pp; \ } = \ - *(_pixel_type *)&dst[index_d] =3D *(_pixel_type *)&src[ind= ex_s];\ + if (rop_mode =3D=3D 1 && rop =3D=3D 5) { = \ + /* Invert dest */ = \ + val =3D ~*(_pixel_type *)&dst[index_d]; = \ + } else { = \ + val =3D *(_pixel_type *)&src[index_s]; = \ + } = \ + *(_pixel_type *)&dst[index_d] =3D val; = \ } = \ } = \ } --=20 2.7.6 From nobody Fri May 17 00:49:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530698077230803.0179388084247; Wed, 4 Jul 2018 02:54:37 -0700 (PDT) Received: from localhost ([::1]:44965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeUe-0003sO-KX for importer@patchew.org; Wed, 04 Jul 2018 05:54:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeOo-0008D6-AG for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faeOj-0003ux-Cs for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:34 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:46735) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faeOj-0003uR-5B for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:29 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id AD6BB7456B8; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 6BC7F7456C7; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Message-Id: <8412fd970b69ee1e3313d27590c90b31acc64e4c.1530697258.git.balaton@eik.bme.hu> In-Reply-To: References: From: Sebastian Bauer Date: Wed, 04 Jul 2018 11:40:58 +0200 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH v3 5/7] sm501: Log unimplemented raster operation modes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sebastian Bauer , Magnus Damm , Philippe Mathieu-Daude , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The sm501 currently implements only a very limited set of raster operation modes. After this change, unknown raster operation modes are logged so these can be easily spotted. Signed-off-by: BALATON Zoltan --- hw/display/sm501.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 0b44d95..ebd1390 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -706,6 +706,8 @@ static void sm501_2d_operation(SM501State *s) int format_flags =3D (s->twoD_stretch >> 20) & 0x3; int addressing =3D (s->twoD_stretch >> 16) & 0xF; int rop_mode =3D (s->twoD_control >> 15) & 0x1; /* 1 for rop2, else ro= p3 */ + /* 1 if rop2 source is the pattern, otherwise the source is the bitmap= */ + int rop2_source_is_pattern =3D (s->twoD_control >> 14) & 0x1; int rop =3D s->twoD_control & 0xFF; =20 /* get frame buffer info */ @@ -719,6 +721,27 @@ static void sm501_2d_operation(SM501State *s) abort(); } =20 + if (rop_mode =3D=3D 0) { + if (rop !=3D 0xcc) { + /* Anything other than plain copies are not supported */ + qemu_log_mask(LOG_UNIMP, "sm501: rop3 mode with rop %x is not " + "supported.\n", rop); + } + } else { + if (rop2_source_is_pattern && rop !=3D 0x5) { + /* For pattern source, we support only inverse dest */ + qemu_log_mask(LOG_UNIMP, "sm501: rop2 source being the pattern= and " + "rop %x is not supported.\n", rop); + } else { + if (rop !=3D 0x5 && rop !=3D 0xc) { + /* Anything other than plain copies or inverse dest is not + * supported */ + qemu_log_mask(LOG_UNIMP, "sm501: rop mode %x is not " + "supported.\n", rop); + } + } + } + if ((s->twoD_source_base & 0x08000000) || (s->twoD_destination_base & 0x08000000)) { printf("%s: only local memory is supported.\n", __func__); --=20 2.7.6 From nobody Fri May 17 00:49:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530697842395256.97579669900654; Wed, 4 Jul 2018 02:50:42 -0700 (PDT) Received: from localhost ([::1]:44943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeQj-0000lL-FL for importer@patchew.org; Wed, 04 Jul 2018 05:50:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeOo-0008D3-9F for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faeOj-0003vD-Fj for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:34 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:46740) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faeOj-0003uS-4u for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:29 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id CE6567456C9; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 6F2FF7456CA; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Message-Id: <6694adb928f6b76e418a10115d8d143927a3cbf8.1530697258.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Date: Wed, 04 Jul 2018 11:40:58 +0200 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH v3 6/7] sm501: Fix support for non-zero frame buffer start address X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sebastian Bauer , Magnus Damm , Philippe Mathieu-Daude , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Display updates and drawing hardware cursor did not work when frame buffer address was non-zero. Fix this by taking the frame buffer address into account in these cases. This fixes screen dragging on AmigaOS. Based on patch by Sebastian Bauer. Signed-off-by: Sebastian Bauer Signed-off-by: BALATON Zoltan --- v2: fixed crash with Linux setting extra bits and log unimplemented case hw/display/sm501.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index ebd1390..10ee008 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -586,6 +586,11 @@ static uint32_t get_local_mem_size_index(uint32_t size) return index; } =20 +static ram_addr_t get_fb_addr(SM501State *s, int crt) +{ + return (crt ? s->dc_crt_fb_addr : s->dc_panel_fb_addr) & 0x3FFFFF0; +} + static inline int get_width(SM501State *s, int crt) { int width =3D crt ? s->dc_crt_h_total : s->dc_panel_h_total; @@ -688,7 +693,8 @@ static inline void hwc_invalidate(SM501State *s, int cr= t) start *=3D w * bpp; end *=3D w * bpp; =20 - memory_region_set_dirty(&s->local_mem_region, start, end - start); + memory_region_set_dirty(&s->local_mem_region, + get_fb_addr(s, crt) + start, end - start); } =20 static void sm501_2d_operation(SM501State *s) @@ -1213,6 +1219,9 @@ static void sm501_disp_ctrl_write(void *opaque, hwadd= r addr, break; case SM501_DC_PANEL_FB_ADDR: s->dc_panel_fb_addr =3D value & 0x8FFFFFF0; + if (value & 0x8000000) { + qemu_log_mask(LOG_UNIMP, "Panel external memory not supported\= n"); + } break; case SM501_DC_PANEL_FB_OFFSET: s->dc_panel_fb_offset =3D value & 0x3FF03FF0; @@ -1273,6 +1282,9 @@ static void sm501_disp_ctrl_write(void *opaque, hwadd= r addr, break; case SM501_DC_CRT_FB_ADDR: s->dc_crt_fb_addr =3D value & 0x8FFFFFF0; + if (value & 0x8000000) { + qemu_log_mask(LOG_UNIMP, "CRT external memory not supported\n"= ); + } break; case SM501_DC_CRT_FB_OFFSET: s->dc_crt_fb_offset =3D value & 0x3FF03FF0; @@ -1615,7 +1627,7 @@ static void sm501_update_display(void *opaque) draw_hwc_line_func *draw_hwc_line =3D NULL; int full_update =3D 0; int y_start =3D -1; - ram_addr_t offset =3D 0; + ram_addr_t offset; uint32_t *palette; uint8_t hwc_palette[3 * 3]; uint8_t *hwc_src =3D NULL; @@ -1672,9 +1684,10 @@ static void sm501_update_display(void *opaque) } =20 /* draw each line according to conditions */ + offset =3D get_fb_addr(s, crt); snap =3D memory_region_snapshot_and_clear_dirty(&s->local_mem_region, offset, width * height * src_bpp, DIRTY_MEMORY_VGA); - for (y =3D 0, offset =3D 0; y < height; y++, offset +=3D width * src_b= pp) { + for (y =3D 0; y < height; y++, offset +=3D width * src_bpp) { int update, update_hwc; =20 /* check if hardware cursor is enabled and we're within its range = */ --=20 2.7.6 From nobody Fri May 17 00:49:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530698183725664.4472824727046; Wed, 4 Jul 2018 02:56:23 -0700 (PDT) Received: from localhost ([::1]:44979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeWD-00057L-IT for importer@patchew.org; Wed, 04 Jul 2018 05:56:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faeOo-0008D9-Ao for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faeOk-0003vg-J4 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:34 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:46770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faeOk-0003vI-BG for qemu-devel@nongnu.org; Wed, 04 Jul 2018 05:48:30 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id EB86A7456B9; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 732937456CB; Wed, 4 Jul 2018 11:48:27 +0200 (CEST) Message-Id: <7e1c5b2e14f70a7215ebff1f1ef27f793813b2f1.1530697258.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Date: Wed, 04 Jul 2018 11:40:58 +0200 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH v3 7/7] sm501: Set updated region dirty after 2D operation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sebastian Bauer , Magnus Damm , Philippe Mathieu-Daude , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Set the changed memory region dirty after performed a 2D operation to ensure that the screen is updated properly. Signed-off-by: BALATON Zoltan --- v2: fixed to work with non-zero fb_addr hw/display/sm501.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 10ee008..3661a89 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -715,12 +715,16 @@ static void sm501_2d_operation(SM501State *s) /* 1 if rop2 source is the pattern, otherwise the source is the bitmap= */ int rop2_source_is_pattern =3D (s->twoD_control >> 14) & 0x1; int rop =3D s->twoD_control & 0xFF; + uint32_t src_base =3D s->twoD_source_base & 0x03FFFFFF; + uint32_t dst_base =3D s->twoD_destination_base & 0x03FFFFFF; =20 /* get frame buffer info */ - uint8_t *src =3D s->local_mem + (s->twoD_source_base & 0x03FFFFFF); - uint8_t *dst =3D s->local_mem + (s->twoD_destination_base & 0x03FFFFFF= ); + uint8_t *src =3D s->local_mem + src_base; + uint8_t *dst =3D s->local_mem + dst_base; int src_width =3D s->twoD_pitch & 0x1FFF; int dst_width =3D (s->twoD_pitch >> 16) & 0x1FFF; + int crt =3D (s->dc_crt_control & SM501_DC_CRT_CONTROL_SEL) ? 1 : 0; + int fb_len =3D get_width(s, crt) * get_height(s, crt) * get_bpp(s, crt= ); =20 if (addressing !=3D 0x0) { printf("%s: only XY addressing is supported.\n", __func__); @@ -821,6 +825,15 @@ static void sm501_2d_operation(SM501State *s) abort(); break; } + + if (dst_base >=3D get_fb_addr(s, crt) && + dst_base <=3D get_fb_addr(s, crt) + fb_len) { + int dst_len =3D MIN(fb_len, ((dst_y + operation_height - 1) * dst_= width + + dst_x + operation_width) * (1 << format_flags)); + if (dst_len) { + memory_region_set_dirty(&s->local_mem_region, dst_base, dst_le= n); + } + } } =20 static uint64_t sm501_system_config_read(void *opaque, hwaddr addr, --=20 2.7.6