arm: drop dead code for non-32-bit-RGB surfaces
cover arm: drop dead code for non-32-bit-RGB surfaces
This patchset removes dead code (including a couple of 'template' headers) for handling UI surfaces that are formats other than 32-bit RGB for the musicpal, tc6393xb and omap_lcdc display devices.
For a long time now the UI layer has guaranteed that the console surface is always 32 bits per pixel RGB, so the legacy code in these devices which was handling the possibility that the console surface was some other format can all be deleted.
Notes:
(1) the patch "hw/display/omap_lcdc: Drop broken bigendian ifdef" fixes a bug introduced in commit ea644cf343129 in 2016 in a previous partial start on this cleanup
(2) the omap_lcdc changes are tested only with 'make check' as I don't have any test images for the OMAP1.
With these plus the other on-list patches, the only remaining 'template' header files in hw/display are pl110 (which needs it to handle the different guest-side pixel formats) and the milkymist-vgafb device. Milkymist is in the 'deprecated and will be deleted in a few releases' bucket so it's not worth doing this cleanup for it, since it's not blocking any API transition. (I'll take this task off the BiteSizedTasks list shortly.)
After the musicpal cleanup and the tcx patch I just posted, there will be no more users of is_surface_bgr(), so that could then be deleted.
thanks
-- PMM
Peter Maydell (9):
hw/arm/musicpal: Remove dead code for non-32-bit-RGB surfaces hw/display/tc6393xb: Remove dead code for handling non-32bpp surfaces hw/display/tc6393xb: Expand out macros in template header hw/display/tc6393xb: Inline tc6393xb_draw_graphic32() at its callsite hw/display/omap_lcdc: Expand out macros in template header hw/display/omap_lcdc: Drop broken bigendian ifdef hw/display/omap_lcdc: Fix coding style issues in template header hw/display/omap_lcdc: Inline template header into C file hw/display/omap_lcdc: Delete unnecessary macro
hw/display/omap_lcd_template.h | 169 --------------------------------- hw/display/tc6393xb_template.h | 72 -------------- include/ui/console.h | 10 -- hw/arm/musicpal.c | 64 +++++-------- hw/display/omap_lcdc.c | 129 ++++++++++++++++++++++++- hw/display/tc6393xb.c | 48 ++++------ 6 files changed, 165 insertions(+), 327 deletions(-) delete mode 100644 hw/display/omap_lcd_template.h delete mode 100644 hw/display/tc6393xb_template.h
Signature · 1 line
2.20.1
PATCH 1/9 hw/arm/musicpal: Remove dead code for non-32-bit-RGB surfaces
For a long time now the UI layer has guaranteed that the console surface is always 32 bits per pixel RGB. Remove the legacy dead code from the milkymist display device which was handling the possibility that the console surface was some other format.
--- hw/arm/musicpal.c | 64 ++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 40 deletions(-)
hw/arm/musicpal.c +24 -40
@@ -512,53 +512,37 @@ static uint8_t scale_lcd_color(musicpal_lcd_state *s, uint8_t col) } } -#define SET_LCD_PIXEL (depth, type) \ -static inline void glue(set_lcd_pixel, depth) \ - (musicpal_lcd_state *s, int x, int y, type col) \ -{ \ - int dx, dy; \ - DisplaySurface *surface = qemu_console_surface(s->con); \ - type *pixel = &((type *) surface_data(surface))[(y * 128 * 3 + x) * 3]; \ -\ - for (dy = 0; dy < 3; dy++, pixel += 127 * 3) \ - for (dx = 0; dx < 3; dx++, pixel++) \ - *pixel = col; \ +static inline void set_lcd_pixel32 (musicpal_lcd_state *s, +int x,int y,uint32_t col) +{ +int dx, dy; +DisplaySurface *surface =qemu_console_surface (s->con); +uint32_t *pixel = + &((uint32_t *)surface_data (surface))[(y *128 *3 + x) *3 ]; + +for (dy =0 ; dy <3 ; dy++, pixel +=127 *3 ) { +for (dx =0 ; dx <3 ; dx++, pixel++) { + *pixel = col; + } + } } -SET_LCD_PIXEL(8, uint8_t) -SET_LCD_PIXEL(16, uint16_t) -SET_LCD_PIXEL(32, uint32_t)static void lcd_refresh (void *opaque) {musicpal_lcd_state *s = opaque; -DisplaySurface *surface =qemu_console_surface (s->con);int x, y, col; -switch (surface_bits_per_pixel (surface)) { -case 0 : -return ; -#define LCD_REFRESH (depth, func) \ - case depth: \ - col = func(scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 16) & 0xff), \ - scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 8) & 0xff), \ - scale_lcd_color(s, MP_LCD_TEXTCOLOR & 0xff)); \ - for (x = 0; x < 128; x++) { \ - for (y = 0; y < 64; y++) { \ - if (s->video_ram[x + (y/8)*128] & (1 << (y % 8))) { \ - glue(set_lcd_pixel, depth)(s, x, y, col); \ - } else { \ - glue(set_lcd_pixel, depth)(s, x, y, 0); \ - } \ - } \ - } \ - break; - LCD_REFRESH(8, rgb_to_pixel8) - LCD_REFRESH(16, rgb_to_pixel16) -LCD_REFRESH (32 , (is_surface_bgr (surface) ? - rgb_to_pixel32bgr : rgb_to_pixel32)) -default : -hw_error ("unsupported colour depth %i\n" , -surface_bits_per_pixel (surface)); + col =rgb_to_pixel32 (scale_lcd_color (s, (MP_LCD_TEXTCOLOR >>16 ) &0xff ), +scale_lcd_color (s, (MP_LCD_TEXTCOLOR >>8 ) &0xff ), +scale_lcd_color (s,MP_LCD_TEXTCOLOR &0xff )); +for (x =0 ; x <128 ; x++) { +for (y =0 ; y <64 ; y++) { +if (s->video_ram[x + (y /8 ) *128 ] & (1 << (y %8 ))) { +set_lcd_pixel32 (s, x, y, col); + }else { +set_lcd_pixel32 (s, x, y,0 ); + } + } }dpy_gfx_update (s->con,0 ,0 ,128 *3 ,64 *3 );
Signature · 1 line
2.20.1
PATCH 2/9 hw/display/tc6393xb: Remove dead code for handling non-32bpp surfaces
In reply to Peter MaydellFor a long time now the UI layer has guaranteed that the console surface is always 32 bits per pixel RGB. Remove the legacy dead code from the tc6393xb display device which was handling the possibility that the console surface was some other format.
--- include/ui/console.h | 10 ---------- hw/display/tc6393xb.c | 33 +-------------------------------- 2 files changed, 1 insertion(+), 42 deletions(-)
include/ui/console.h +0 -10
@@ -266,16 +266,6 @@ PixelFormat qemu_default_pixelformat(int bpp);DisplaySurface *qemu_create_displaysurface (int width,int height);void qemu_free_displaysurface (DisplaySurface *surface); -static inline int is_surface_bgr (DisplaySurface *surface) -{ -if (PIXMAN_FORMAT_BPP (surface->format) ==32 && -PIXMAN_FORMAT_TYPE (surface->format) ==PIXMAN_TYPE_ABGR ) { -return 1 ; - }else { -return 0 ; - } -} -static inline int is_buffer_shared (DisplaySurface *surface) {return !(surface->flags &QEMU_ALLOCATED_FLAG );
hw/display/tc6393xb.c +1 -32
@@ -410,43 +410,12 @@ static void tc6393xb_nand_writeb(TC6393xbState *s, hwaddr addr, uint32_t value) (uint32_t) addr, value & 0xff); } -#define BITS 8 -#include "tc6393xb_template.h" -#define BITS 15 -#include "tc6393xb_template.h" -#define BITS 16 -#include "tc6393xb_template.h" -#define BITS 24 -#include "tc6393xb_template.h" #define BITS 32#include "tc6393xb_template.h" static void tc6393xb_draw_graphic (TC6393xbState *s,int full_update) { -DisplaySurface *surface =qemu_console_surface (s->con); - -switch (surface_bits_per_pixel (surface)) { -case 8 : -tc6393xb_draw_graphic8 (s); -break ; -case 15 : -tc6393xb_draw_graphic15 (s); -break ; -case 16 : -tc6393xb_draw_graphic16 (s); -break ; -case 24 : -tc6393xb_draw_graphic24 (s); -break ; -case 32 : -tc6393xb_draw_graphic32 (s); -break ; -default : -printf ("tc6393xb: unknown depth %d\n" , -surface_bits_per_pixel (surface)); -return ; - } - +tc6393xb_draw_graphic32 (s);dpy_gfx_update_full (s->con); }
Signature · 1 line
2.20.1
PATCH 3/9 hw/display/tc6393xb: Expand out macros in template header
In reply to Peter MaydellNow the template header is included only for BITS==32, expand out all the macros that depended on the BITS setting.
--- hw/display/tc6393xb_template.h | 35 ++++------------------------------ 1 file changed, 4 insertions(+), 31 deletions(-)
hw/display/tc6393xb_template.h +4 -31
@@ -21,25 +21,7 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ -#if BITS ==8 -# define SET_PIXEL (addr, color) (*(uint8_t *)addr = color) -#elif BITS ==15 ||BITS ==16 -# define SET_PIXEL (addr, color) (*(uint16_t *)addr = color) -#elif BITS ==24 -# define SET_PIXEL (addr, color) \ - do { \ - addr[0] = color; \ - addr[1] = (color) >> 8; \ - addr[2] = (color) >> 16; \ - } while (0) -#elif BITS ==32 -# define SET_PIXEL (addr, color) (*(uint32_t *)addr = color) -#else -# error unknown bit depth -#endif - - -static void glue (tc6393xb_draw_graphic ,BITS )(TC6393xbState *s) +static void tc6393xb_draw_graphic32 (TC6393xbState *s) {DisplaySurface *surface =qemu_console_surface (s->con);int i;
@@ -49,24 +31,15 @@ static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s) data_buffer = s->vram_ptr; data_display =surface_data (surface);for (i =0 ; i < s->scr_height; i++) { -#if (BITS ==16 ) -memcpy (data_display, data_buffer, s->scr_width *2 ); - data_buffer += s->scr_width; - data_display +=surface_stride (surface); -#else int j; -for (j =0 ; j < s->scr_width; j++, data_display +=BITS /8 , data_buffer++) { +for (j =0 ; j < s->scr_width; j++, data_display +=4 , data_buffer++) {uint16_t color = *data_buffer; -uint32_t dest_color =glue (rgb_to_pixel,BITS )( +uint32_t dest_color =rgb_to_pixel32 ( ((color &0xf800 ) *0x108 ) >>11 , ((color &0x7e0 ) *0x41 ) >>9 , ((color &0x1f ) *0x21 ) >>2 ); -SET_PIXEL (data_display, dest_color); + *(uint32_t *)data_display = dest_color; } -#endif } } - -#undef BITS -#undef SET_PIXEL
Signature · 1 line
2.20.1
PATCH 4/9 hw/display/tc6393xb: Inline tc6393xb_draw_graphic32() at its callsite
In reply to Peter MaydellThe function tc6393xb_draw_graphic32() is called in exactly one place, so just inline the function body at its callsite. This allows us to drop the template header entirely.
The code move includes a single added space after 'for' to fix the coding style.
--- hw/display/tc6393xb_template.h | 45 ---------------------------------- hw/display/tc6393xb.c | 23 ++++++++++++++--- 2 files changed, 19 insertions(+), 49 deletions(-) delete mode 100644 hw/display/tc6393xb_template.h
hw/display/tc6393xb_template.h deleted +0 -45
@@ -1,45 +0,0 @@ -/* -* Toshiba TC6393XB I/O Controller. -* Found in Sharp Zaurus SL-6000 (tosa) or some -* Toshiba e-Series PDAs. -* -* FB support code. Based on G364 fb emulator -* -* Copyright (c) 2007 Hervé Poussineau -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -static void tc6393xb_draw_graphic32 (TC6393xbState *s) -{ -DisplaySurface *surface =qemu_console_surface (s->con); -int i; -uint16_t *data_buffer; -uint8_t *data_display; - - data_buffer = s->vram_ptr; - data_display =surface_data (surface); -for (i =0 ; i < s->scr_height; i++) { -int j; -for (j =0 ; j < s->scr_width; j++, data_display +=4 , data_buffer++) { -uint16_t color = *data_buffer; -uint32_t dest_color =rgb_to_pixel32 ( - ((color &0xf800 ) *0x108 ) >>11 , - ((color &0x7e0 ) *0x41 ) >>9 , - ((color &0x1f ) *0x21 ) >>2 - ); - *(uint32_t *)data_display = dest_color; - } - } -}
hw/display/tc6393xb.c +19 -4
@@ -410,12 +410,27 @@ static void tc6393xb_nand_writeb(TC6393xbState *s, hwaddr addr, uint32_t value) (uint32_t) addr, value & 0xff); } -#define BITS 32 -#include "tc6393xb_template.h" -static void tc6393xb_draw_graphic (TC6393xbState *s,int full_update) { -tc6393xb_draw_graphic32 (s); +DisplaySurface *surface =qemu_console_surface (s->con); +int i; +uint16_t *data_buffer; +uint8_t *data_display; + + data_buffer = s->vram_ptr; + data_display =surface_data (surface); +for (i =0 ; i < s->scr_height; i++) { +int j; +for (j =0 ; j < s->scr_width; j++, data_display +=4 , data_buffer++) { +uint16_t color = *data_buffer; +uint32_t dest_color =rgb_to_pixel32 ( + ((color &0xf800 ) *0x108 ) >>11 , + ((color &0x7e0 ) *0x41 ) >>9 , + ((color &0x1f ) *0x21 ) >>2 + ); + *(uint32_t *)data_display = dest_color; + } + }dpy_gfx_update_full (s->con); }
Signature · 1 line
2.20.1
Re: [PATCH 4/9] hw/display/tc6393xb: Inline tc6393xb_draw_graphic32() at its callsite
Quoted 7 lines · Peter Maydell
The function
tc6393xb_draw_graphic32()is called in exactly one place, so just inline the function body at its callsite. This allows us to drop the template header entirely.The code move includes a single added space after 'for' to fix the coding style.
Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>--- hw/display/tc6393xb_template.h | 45 ---------------------------------- hw/display/tc6393xb.c | 23 ++++++++++++++--- 2 files changed, 19 insertions(+), 49 deletions(-) delete mode 100644 hw/display/tc6393xb_template.h
PATCH 5/9 hw/display/omap_lcdc: Expand out macros in template header
In reply to Peter MaydellThe omap_lcdc template header is already only included once, for DEPTH==32, but it still has all the macro-driven parameterization for other depths. Expand out all the macros in the header.
--- hw/display/omap_lcd_template.h | 67 ++++++++++++++-------------------- 1 file changed, 28 insertions(+), 39 deletions(-)
hw/display/omap_lcd_template.h +28 -39
@@ -27,18 +27,11 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if DEPTH ==32 -# define BPP 4 -# define PIXEL_TYPE uint32_t -#else -# error unsupport depth -#endif -/* * 2-bit colour */ -static void glue (draw_line2_ ,DEPTH )(void *opaque, -uint8_t *d,const uint8_t *s,int width,int deststep) +static void draw_line2_32 (void *opaque,uint8_t *d,const uint8_t *s, +int width,int deststep) {uint16_t *pal = opaque;uint8_t v, r, g, b;
@@ -48,26 +41,26 @@ static void glue(draw_line2_, DEPTH)(void *opaque, r = (pal[v &3 ] >>4 ) &0xf0 ; g = pal[v &3 ] &0xf0 ; b = (pal[v &3 ] <<4 ) &0xf0 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); - d +=BPP ; + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); + d +=4 ; v >>=2 ; r = (pal[v &3 ] >>4 ) &0xf0 ; g = pal[v &3 ] &0xf0 ; b = (pal[v &3 ] <<4 ) &0xf0 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); - d +=BPP ; + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); + d +=4 ; v >>=2 ; r = (pal[v &3 ] >>4 ) &0xf0 ; g = pal[v &3 ] &0xf0 ; b = (pal[v &3 ] <<4 ) &0xf0 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); - d +=BPP ; + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); + d +=4 ; v >>=2 ; r = (pal[v &3 ] >>4 ) &0xf0 ; g = pal[v &3 ] &0xf0 ; b = (pal[v &3 ] <<4 ) &0xf0 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); - d +=BPP ; + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); + d +=4 ; s ++; width -=4 ; }while (width >0 );
@@ -76,8 +69,8 @@ static void glue(draw_line2_, DEPTH)(void *opaque,/* * 4-bit colour */ -static void glue (draw_line4_ ,DEPTH )(void *opaque, -uint8_t *d,const uint8_t *s,int width,int deststep) +static void draw_line4_32 (void *opaque,uint8_t *d,const uint8_t *s, +int width,int deststep) {uint16_t *pal = opaque;uint8_t v, r, g, b;
@@ -87,14 +80,14 @@ static void glue(draw_line4_, DEPTH)(void *opaque, r = (pal[v &0xf ] >>4 ) &0xf0 ; g = pal[v &0xf ] &0xf0 ; b = (pal[v &0xf ] <<4 ) &0xf0 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); - d +=BPP ; + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); + d +=4 ; v >>=4 ; r = (pal[v &0xf ] >>4 ) &0xf0 ; g = pal[v &0xf ] &0xf0 ; b = (pal[v &0xf ] <<4 ) &0xf0 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); - d +=BPP ; + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); + d +=4 ; s ++; width -=2 ; }while (width >0 );
@@ -103,8 +96,8 @@ static void glue(draw_line4_, DEPTH)(void *opaque,/* * 8-bit colour */ -static void glue (draw_line8_ ,DEPTH )(void *opaque, -uint8_t *d,const uint8_t *s,int width,int deststep) +static void draw_line8_32 (void *opaque,uint8_t *d,const uint8_t *s, +int width,int deststep) {uint16_t *pal = opaque;uint8_t v, r, g, b;
@@ -114,17 +107,17 @@ static void glue(draw_line8_, DEPTH)(void *opaque, r = (pal[v] >>4 ) &0xf0 ; g = pal[v] &0xf0 ; b = (pal[v] <<4 ) &0xf0 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); s ++; - d +=BPP ; + d +=4 ; }while (-- width !=0 ); }/* * 12-bit colour */ -static void glue (draw_line12_ ,DEPTH )(void *opaque, -uint8_t *d,const uint8_t *s,int width,int deststep) +static void draw_line12_32 (void *opaque,uint8_t *d,const uint8_t *s, +int width,int deststep) {uint16_t v;uint8_t r, g, b;
@@ -134,17 +127,17 @@ static void glue(draw_line12_, DEPTH)(void *opaque, r = (v >>4 ) &0xf0 ; g = v &0xf0 ; b = (v <<4 ) &0xf0 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); s +=2 ; - d +=BPP ; + d +=4 ; }while (-- width !=0 ); }/* * 16-bit colour */ -static void glue (draw_line16_ ,DEPTH )(void *opaque, -uint8_t *d,const uint8_t *s,int width,int deststep) +static void draw_line16_32 (void *opaque,uint8_t *d,const uint8_t *s, +int width,int deststep) {#if defined(HOST_WORDS_BIGENDIAN ) == defined(TARGET_WORDS_BIGENDIAN )memcpy (d, s, width *2 );
@@ -157,13 +150,9 @@ static void glue(draw_line16_, DEPTH)(void *opaque, r = (v >>8 ) &0xf8 ; g = (v >>3 ) &0xfc ; b = (v <<3 ) &0xf8 ; - ((PIXEL_TYPE *) d)[0 ] =glue (rgb_to_pixel,DEPTH )(r, g, b); + ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); s +=2 ; - d += BPP; + d += 4; }while (-- width !=0 );#endif } - -#undef DEPTH -#undef BPP -#undef PIXEL_TYPE
Signature · 1 line
2.20.1
PATCH 6/9 hw/display/omap_lcdc: Drop broken bigendian ifdef
In reply to Peter MaydellThe draw_line16_32() function in the omap_lcdc template header includes an ifdef for the case where HOST_WORDS_BIGENDIAN matches TARGET_WORDS_BIGENDIAN. This is trying to optimise for "source bitmap and destination bitmap format match", but it is broken, because in this function the formats don't match: the source is 16-bit colour and the destination is 32-bit colour, so a memcpy() will produce corrupted graphics output. Drop the bogus ifdef.
This bug was introduced in commit ea644cf343129, when we dropped support for DEPTH values other than 32 from the template header.
The old #if line was
#if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
and this was mistakenly changed to
#if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
rather than deleting the #if as now having an always-false condition.
--- hw/display/omap_lcd_template.h | 4 ---- 1 file changed, 4 deletions(-)
hw/display/omap_lcd_template.h +0 -4
@@ -139,9 +139,6 @@ static void draw_line12_32(void *opaque, uint8_t *d, const uint8_t *s,static void draw_line16_32 (void *opaque,uint8_t *d,const uint8_t *s,int width,int deststep) { -#if defined(HOST_WORDS_BIGENDIAN ) == defined(TARGET_WORDS_BIGENDIAN ) -memcpy (d, s, width *2 ); -#else uint16_t v;uint8_t r, g, b;
@@ -154,5 +151,4 @@ static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s, s +=2 ; d +=4 ; }while (-- width !=0 ); -#endif }
Signature · 1 line
2.20.1
Re: [PATCH 6/9] hw/display/omap_lcdc: Drop broken bigendian ifdef
Quoted 16 lines · Peter Maydell
The
draw_line16_32()function in theomap_lcdctemplate header includes an ifdef for the case whereHOST_WORDS_BIGENDIANmatchesTARGET_WORDS_BIGENDIAN. This is trying to optimise for "source bitmap and destination bitmap format match", but it is broken, because in this function the formats don't match: the source is 16-bit colour and the destination is 32-bit colour, so amemcpy()will produce corrupted graphics output. Drop the bogus ifdef.This bug was introduced in commit
ea644cf343129, when we dropped support for DEPTH values other than 32 from the template header.
The old #if line was
#if DEPTH == 16 &&defined(HOST_WORDS_BIGENDIAN)==defined(TARGET_WORDS_BIGENDIAN)
and this was mistakenly changed to
#ifdefined(HOST_WORDS_BIGENDIAN)==defined(TARGET_WORDS_BIGENDIAN)
rather than deleting the #if as now having an always-false condition.
Quoted 5 lines
Fixes ea644cf343129Signed-off-by Peter Maydell <[email protected]>--- hw/display/omap_lcd_template.h | 4 ---- 1 file changed, 4 deletions(-)
PATCH 7/9 hw/display/omap_lcdc: Fix coding style issues in template header
In reply to Peter MaydellFix some minor coding style issues in the template header, so checkpatch doesn't complain when we move the code.
--- hw/display/omap_lcd_template.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/display/omap_lcd_template.h +3 -3
@@ -61,7 +61,7 @@ static void draw_line2_32(void *opaque, uint8_t *d, const uint8_t *s, b = (pal[v &3 ] <<4 ) &0xf0 ; ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); d +=4 ; - s ++; + s++; width -=4 ; }while (width >0 ); }
@@ -88,7 +88,7 @@ static void draw_line4_32(void *opaque, uint8_t *d, const uint8_t *s, b = (pal[v &0xf ] <<4 ) &0xf0 ; ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); d +=4 ; - s ++; + s++; width -=2 ; }while (width >0 ); }
@@ -108,7 +108,7 @@ static void draw_line8_32(void *opaque, uint8_t *d, const uint8_t *s, g = pal[v] &0xf0 ; b = (pal[v] <<4 ) &0xf0 ; ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - s ++; + s++; d +=4 ; }while (-- width !=0 ); }
Signature · 1 line
2.20.1
Re: [PATCH 7/9] hw/display/omap_lcdc: Fix coding style issues in template header
Quoted 7 lines · Peter Maydell
Fix some minor coding style issues in the template header, so checkpatch doesn't complain when we move the code.
Signed-off-by Peter Maydell <[email protected]>--- hw/display/omap_lcd_template.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH 8/9 hw/display/omap_lcdc: Inline template header into C file
In reply to Peter MaydellWe only include the template header once, so just inline it into the source file for the device.
--- hw/display/omap_lcd_template.h | 154 --------------------------------- hw/display/omap_lcdc.c | 127 ++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 156 deletions(-) delete mode 100644 hw/display/omap_lcd_template.h
hw/display/omap_lcd_template.h deleted +0 -154
@@ -1,154 +0,0 @@ -/* -* QEMU OMAP LCD Emulator templates -* -* Copyright (c) 2006 Andrzej Zaborowski <[email protected]> -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -* 2-bit colour -*/ -static void draw_line2_32 (void *opaque,uint8_t *d,const uint8_t *s, -int width,int deststep) -{ -uint16_t *pal = opaque; -uint8_t v, r, g, b; - -do { - v =ldub_p ((void *) s); - r = (pal[v &3 ] >>4 ) &0xf0 ; - g = pal[v &3 ] &0xf0 ; - b = (pal[v &3 ] <<4 ) &0xf0 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - d +=4 ; - v >>=2 ; - r = (pal[v &3 ] >>4 ) &0xf0 ; - g = pal[v &3 ] &0xf0 ; - b = (pal[v &3 ] <<4 ) &0xf0 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - d +=4 ; - v >>=2 ; - r = (pal[v &3 ] >>4 ) &0xf0 ; - g = pal[v &3 ] &0xf0 ; - b = (pal[v &3 ] <<4 ) &0xf0 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - d +=4 ; - v >>=2 ; - r = (pal[v &3 ] >>4 ) &0xf0 ; - g = pal[v &3 ] &0xf0 ; - b = (pal[v &3 ] <<4 ) &0xf0 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - d +=4 ; - s++; - width -=4 ; - }while (width >0 ); -} - -/* -* 4-bit colour -*/ -static void draw_line4_32 (void *opaque,uint8_t *d,const uint8_t *s, -int width,int deststep) -{ -uint16_t *pal = opaque; -uint8_t v, r, g, b; - -do { - v =ldub_p ((void *) s); - r = (pal[v &0xf ] >>4 ) &0xf0 ; - g = pal[v &0xf ] &0xf0 ; - b = (pal[v &0xf ] <<4 ) &0xf0 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - d +=4 ; - v >>=4 ; - r = (pal[v &0xf ] >>4 ) &0xf0 ; - g = pal[v &0xf ] &0xf0 ; - b = (pal[v &0xf ] <<4 ) &0xf0 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - d +=4 ; - s++; - width -=2 ; - }while (width >0 ); -} - -/* -* 8-bit colour -*/ -static void draw_line8_32 (void *opaque,uint8_t *d,const uint8_t *s, -int width,int deststep) -{ -uint16_t *pal = opaque; -uint8_t v, r, g, b; - -do { - v =ldub_p ((void *) s); - r = (pal[v] >>4 ) &0xf0 ; - g = pal[v] &0xf0 ; - b = (pal[v] <<4 ) &0xf0 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - s++; - d +=4 ; - }while (-- width !=0 ); -} - -/* -* 12-bit colour -*/ -static void draw_line12_32 (void *opaque,uint8_t *d,const uint8_t *s, -int width,int deststep) -{ -uint16_t v; -uint8_t r, g, b; - -do { - v =lduw_le_p ((void *) s); - r = (v >>4 ) &0xf0 ; - g = v &0xf0 ; - b = (v <<4 ) &0xf0 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - s +=2 ; - d +=4 ; - }while (-- width !=0 ); -} - -/* -* 16-bit colour -*/ -static void draw_line16_32 (void *opaque,uint8_t *d,const uint8_t *s, -int width,int deststep) -{ -uint16_t v; -uint8_t r, g, b; - -do { - v =lduw_le_p ((void *) s); - r = (v >>8 ) &0xf8 ; - g = (v >>3 ) &0xfc ; - b = (v <<3 ) &0xf8 ; - ((uint32_t *) d)[0 ] =rgb_to_pixel32 (r, g, b); - s +=2 ; - d +=4 ; - }while (-- width !=0 ); -}
hw/display/omap_lcdc.c +125 -2
133 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 8/9] hw/display/omap_lcdc: Inline template header into C file
Quoted 9 lines · Peter Maydell
We only include the template header once, so just inline it into the source file for the device.
Signed-off-by Peter Maydell <[email protected]>--- hw/display/omap_lcd_template.h | 154 --------------------------------- hw/display/omap_lcdc.c | 127 ++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 156 deletions(-) delete mode 100644 hw/display/omap_lcd_template.h
PATCH 9/9 hw/display/omap_lcdc: Delete unnecessary macro
In reply to Peter MaydellThe macro draw_line_func is used only once; just expand it.
--- hw/display/omap_lcdc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/display/omap_lcdc.c +1 -3
@@ -70,8 +70,6 @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s)qemu_irq_lower (s->irq); } -#define draw_line_func drawfn -/* * 2-bit colour */
@@ -202,7 +200,7 @@ static void omap_update_display(void *opaque) {struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque;DisplaySurface *surface; -draw_line_func draw_line; +drawfn draw_line;int size, height, first, last;int width, linesize, step, bpp, frame_offset;hwaddr frame_base;
Signature · 1 line
2.20.1
Re: [PATCH 9/9] hw/display/omap_lcdc: Delete unnecessary macro
Quoted 6 lines · Peter Maydell
The macro
draw_line_funcis used only once; just expand it.Signed-off-by Peter Maydell <[email protected]>--- hw/display/omap_lcdc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 10 lines · Peter Maydell
Peter Maydell (9):
hw/arm/musicpal: Remove dead code for non-32-bit-RGB surfaces hw/display/tc6393xb: Remove dead code for handling non-32bpp surfaces hw/display/tc6393xb: Expand out macros in template header hw/display/tc6393xb: Inlinetc6393xb_draw_graphic32()at its callsite hw/display/omap_lcdc: Expand out macros in template header hw/display/omap_lcdc: Drop broken bigendian ifdef hw/display/omap_lcdc: Fix coding style issues in template header hw/display/omap_lcdc: Inline template header into C file hw/display/omap_lcdc: Delete unnecessary macro
r~