diff mbox series

[2/5] sm501: Perform a full update after palette change

Message ID bbdbc993bc9e492916abce1f2a5857f0227e2720.1529568501.git.balaton@eik.bme.hu
State New
Headers show
Series Misc sm501 improvements | expand

Commit Message

BALATON Zoltan June 21, 2018, 8:08 a.m. UTC
From: Sebastian Bauer <mail@sebastianbauer.info>

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 <mail@sebastianbauer.info>
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---

Notes:
    v4: Updated commit message

 hw/display/sm501.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Philippe Mathieu-Daudé June 22, 2018, 1:34 a.m. UTC | #1
On 06/21/2018 05:08 AM, BALATON Zoltan wrote:
> From: Sebastian Bauer <mail@sebastianbauer.info>
> 
> 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 <mail@sebastianbauer.info>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> 
> Notes:
>     v4: Updated commit message
> 
>  hw/display/sm501.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 0625cf5..a2ee6e3 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -479,6 +479,7 @@ typedef struct SM501State {
>      MemoryRegion twoD_engine_region;
>      uint32_t last_width;
>      uint32_t last_height;
> +    uint32_t do_full_update; /* perform a full update next time */

Can this be a bool?

>      I2CBus *i2c_bus;
>  
>      /* mmio registers */
> @@ -1032,6 +1033,7 @@ static void sm501_palette_write(void *opaque, hwaddr addr,
>  
>      assert(range_covers_byte(0, 0x400 * 3, addr));
>      *(uint32_t *)&s->dc_palette[addr] = value;
> +    s->do_full_update = 1;
>  }
>  
>  static uint64_t sm501_disp_ctrl_read(void *opaque, hwaddr addr,
> @@ -1620,6 +1622,12 @@ static void sm501_update_display(void *opaque)
>          full_update = 1;
>      }
>  
> +    /* someone else requested a full update */
> +    if (s->do_full_update) {
> +        s->do_full_update = 0;
> +        full_update = 1;
> +    }
> +
>      /* draw each line according to conditions */
>      snap = memory_region_snapshot_and_clear_dirty(&s->local_mem_region,
>                offset, width * height * src_bpp, DIRTY_MEMORY_VGA);
>
Sebastian Bauer June 22, 2018, 7:21 p.m. UTC | #2
Am 2018-06-22 03:34, schrieb Philippe Mathieu-Daudé:
> On 06/21/2018 05:08 AM, BALATON Zoltan wrote:
>> From: Sebastian Bauer <mail@sebastianbauer.info>
>> 
>> 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 <mail@sebastianbauer.info>
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>> 
>> Notes:
>>     v4: Updated commit message
>> 
>>  hw/display/sm501.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>> 
>> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
>> index 0625cf5..a2ee6e3 100644
>> --- a/hw/display/sm501.c
>> +++ b/hw/display/sm501.c
>> @@ -479,6 +479,7 @@ typedef struct SM501State {
>>      MemoryRegion twoD_engine_region;
>>      uint32_t last_width;
>>      uint32_t last_height;
>> +    uint32_t do_full_update; /* perform a full update next time */
> 
> Can this be a bool?

Yes, this can be a bool. Let me know if you think that this is required.

Bye
Sebastian
BALATON Zoltan June 22, 2018, 9:38 p.m. UTC | #3
On Fri, 22 Jun 2018, Sebastian Bauer wrote:
> Am 2018-06-22 03:34, schrieb Philippe Mathieu-Daudé:
>> On 06/21/2018 05:08 AM, BALATON Zoltan wrote:
>>> From: Sebastian Bauer <mail@sebastianbauer.info>
>>> 
>>> 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 <mail@sebastianbauer.info>
>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>> ---
>>> 
>>> Notes:
>>>     v4: Updated commit message
>>>
>>>  hw/display/sm501.c | 8 ++++++++
>>>  1 file changed, 8 insertions(+)
>>> 
>>> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
>>> index 0625cf5..a2ee6e3 100644
>>> --- a/hw/display/sm501.c
>>> +++ b/hw/display/sm501.c
>>> @@ -479,6 +479,7 @@ typedef struct SM501State {
>>>      MemoryRegion twoD_engine_region;
>>>      uint32_t last_width;
>>>      uint32_t last_height;
>>> +    uint32_t do_full_update; /* perform a full update next time */
>> 
>> Can this be a bool?
>
> Yes, this can be a bool. Let me know if you think that this is required.

I can take care of this in next submission, no need to resend the patch, I 
can change it to bool.

Regards,
BALATON Zoltan
diff mbox series

Patch

diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 0625cf5..a2ee6e3 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -479,6 +479,7 @@  typedef struct SM501State {
     MemoryRegion twoD_engine_region;
     uint32_t last_width;
     uint32_t last_height;
+    uint32_t do_full_update; /* perform a full update next time */
     I2CBus *i2c_bus;
 
     /* mmio registers */
@@ -1032,6 +1033,7 @@  static void sm501_palette_write(void *opaque, hwaddr addr,
 
     assert(range_covers_byte(0, 0x400 * 3, addr));
     *(uint32_t *)&s->dc_palette[addr] = value;
+    s->do_full_update = 1;
 }
 
 static uint64_t sm501_disp_ctrl_read(void *opaque, hwaddr addr,
@@ -1620,6 +1622,12 @@  static void sm501_update_display(void *opaque)
         full_update = 1;
     }
 
+    /* someone else requested a full update */
+    if (s->do_full_update) {
+        s->do_full_update = 0;
+        full_update = 1;
+    }
+
     /* draw each line according to conditions */
     snap = memory_region_snapshot_and_clear_dirty(&s->local_mem_region,
               offset, width * height * src_bpp, DIRTY_MEMORY_VGA);