Skip to contentSkip to conversation

few more accessors

PATCH In review Stefano Stabellini 2 participants 3 messages Nov 26, 2008 – Dec 11, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 few more accessors

This patch introduces few more DisplayState accessors in hw/sm501.c.

hw/sm501.c +3 -3
diff -r d8ccc2d27955 hw/sm501.c
@@ -955,7 +955,7 @@
 
 static inline int get_depth_index(DisplayState *s)
 {
-    switch(s->depth) {
+    switch(ds_get_bits_per_pixel(s)) {
     default:
     case 8:
 	return 0;
@@ -985,7 +985,7 @@
 
     uint8_t  * src = s->local_mem;
     int src_bpp = 0;
-    int dst_bpp = s->ds->depth / 8 + (s->ds->depth % 8 ? 1 : 0);
+    int dst_bpp = ds_get_bytes_per_pixel(s->ds) + (ds_get_bits_per_pixel(s->ds) % 8 ? 1 : 0);
     uint32_t * palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE
 						    - SM501_DC_PANEL_PALETTE];
     int ds_depth_index = get_depth_index(s->ds);
@@ -1039,7 +1039,7 @@
 
 	/* draw line and change status */
 	if (update) {
-	    draw_line(&s->ds->data[y * width * dst_bpp], src, width, palette);
+	    draw_line(&(ds_get_data(s->ds)[y * width * dst_bpp]), src, width, palette);
 	    if (y_start < 0)
 		y_start = y;
 	    if (page0 < page_min)
#1 lore raw
Quoted 17 lines · Stefano Stabellini

This patch introduces few more DisplayState accessors in hw/sm501.c.

diff -r d8ccc2d27955 hw/sm501.c

hw/sm501.c +1 -1
@@ -955,7 +955,7 @@
 
 static inline int get_depth_index(DisplayState *s)
 {
-    switch(s->depth) {
+    switch(ds_get_bits_per_pixel(s)) {
     default:
     case 8:
 	return 0;

hw/sm501.c line 989

Quoted 6 lines
hw/sm501.c +1 -1
@@ -985,7 +985,7 @@
 
     uint8_t  * src = s->local_mem;
     int src_bpp = 0;
-    int dst_bpp = s->ds->depth / 8 + (s->ds->depth % 8 ? 1 : 0);
+    int dst_bpp = ds_get_bytes_per_pixel(s->ds) + (ds_get_bits_per_pixel(s->ds) % 8 ? 1 : 0);
 

There isn't a ds_get_bytes_per_pixel in console.h so this breaks the build. Is your patch missing something perhaps?

Regards,

Anthony Liguori

#2 lore raw
Quoted 3 lines · Anthony Liguori

There isn't a ds_get_bytes_per_pixel in console.h so this breaks the build. Is your patch missing something perhaps?

I created ds_get_bytes_per_pixel only in the third patch. I'll fix this.