From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LDOIm-00017G-2u for qemu-devel@nongnu.org; Thu, 18 Dec 2008 14:12:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LDOIk-00016G-U0 for qemu-devel@nongnu.org; Thu, 18 Dec 2008 14:12:51 -0500 Received: from [199.232.76.173] (port=42128 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LDOIk-00015w-Gn for qemu-devel@nongnu.org; Thu, 18 Dec 2008 14:12:50 -0500 Received: from smtp.eu.citrix.com ([62.200.22.115]:28473) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LDOIk-0004R9-8b for qemu-devel@nongnu.org; Thu, 18 Dec 2008 14:12:50 -0500 Message-ID: <494AA0B6.7050800@eu.citrix.com> Date: Thu, 18 Dec 2008 19:12:54 +0000 From: Stefano Stabellini MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 1 of 7] few more accessors Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This patch introduces few more DisplayState accessors in hw/sm501.c. Added the declaration of ds_get_bytes_per_pixel that was missing last time. Signed-off-by: Stefano Stabellini diff -r 20597e3d2632 console.h --- a/console.h Thu Dec 11 00:14:30 2008 +0000 +++ b/console.h Thu Dec 11 11:00:50 2008 +0000 @@ -139,6 +139,11 @@ return ds->depth; } +static inline int ds_get_bytes_per_pixel(DisplayState *ds) +{ + return (ds->depth / 8); +} + typedef unsigned long console_ch_t; static inline void console_write_ch(console_ch_t *dest, uint32_t ch) { diff -r 20597e3d2632 hw/sm501.c --- a/hw/sm501.c Thu Dec 11 00:14:30 2008 +0000 +++ b/hw/sm501.c Thu Dec 11 11:00:50 2008 +0000 @@ -940,7 +940,7 @@ static inline int get_depth_index(DisplayState *s) { - switch(s->depth) { + switch(ds_get_bits_per_pixel(s)) { default: case 8: return 0; @@ -970,7 +970,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); @@ -1024,7 +1024,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)