From nobody Sun May 5 06:11:05 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.zoho.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 1488810401572276.14907735350164; Mon, 6 Mar 2017 06:26:41 -0800 (PST) Received: from localhost ([::1]:44168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cktav-0005uL-4E for importer@patchew.org; Mon, 06 Mar 2017 09:26:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cktYP-0004NA-4x for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:24:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cktYL-0007Wj-1f for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:24:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52046) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cktYK-0007WO-Pb for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:23:56 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE13E64DA3; Mon, 6 Mar 2017 14:23:56 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v26ENtYw019177; Mon, 6 Mar 2017 09:23:55 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 4B97580BBE; Mon, 6 Mar 2017 15:23:53 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Mar 2017 15:23:49 +0100 Message-Id: <1488810230-31945-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1488810230-31945-1-git-send-email-kraxel@redhat.com> References: <1488810230-31945-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 06 Mar 2017 14:23:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] sm501: drop support for anything but 32bpp 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 , Gerd Hoffmann 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 qemu console code hands out 32bpp display surfaces only, when using qemu_console_resize or qemu_create_displaysurface (which sm501 does). So there is no need to ever generate other output. Drop the code. Signed-off-by: Gerd Hoffmann --- hw/display/sm501.c | 89 +++-----------------------------------------------= ---- 1 file changed, 4 insertions(+), 85 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 040a0b9..6c7717c 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1173,89 +1173,9 @@ typedef void draw_line_func(uint8_t *d, const uint8_= t *s, typedef void draw_hwc_line_func(SM501State * s, int crt, uint8_t * palette, int c_y, uint8_t *d, int width); =20 -#define DEPTH 8 -#include "sm501_template.h" - -#define DEPTH 15 -#include "sm501_template.h" - -#define BGR_FORMAT -#define DEPTH 15 -#include "sm501_template.h" - -#define DEPTH 16 -#include "sm501_template.h" - -#define BGR_FORMAT -#define DEPTH 16 -#include "sm501_template.h" - -#define DEPTH 32 -#include "sm501_template.h" - -#define BGR_FORMAT #define DEPTH 32 #include "sm501_template.h" =20 -static draw_line_func * draw_line8_funcs[] =3D { - draw_line8_8, - draw_line8_15, - draw_line8_16, - draw_line8_32, - draw_line8_32bgr, - draw_line8_15bgr, - draw_line8_16bgr, -}; - -static draw_line_func * draw_line16_funcs[] =3D { - draw_line16_8, - draw_line16_15, - draw_line16_16, - draw_line16_32, - draw_line16_32bgr, - draw_line16_15bgr, - draw_line16_16bgr, -}; - -static draw_line_func * draw_line32_funcs[] =3D { - draw_line32_8, - draw_line32_15, - draw_line32_16, - draw_line32_32, - draw_line32_32bgr, - draw_line32_15bgr, - draw_line32_16bgr, -}; - -static draw_hwc_line_func * draw_hwc_line_funcs[] =3D { - draw_hwc_line_8, - draw_hwc_line_15, - draw_hwc_line_16, - draw_hwc_line_32, - draw_hwc_line_32bgr, - draw_hwc_line_15bgr, - draw_hwc_line_16bgr, -}; - -static inline int get_depth_index(DisplaySurface *surface) -{ - switch (surface_bits_per_pixel(surface)) { - default: - case 8: - return 0; - case 15: - return 1; - case 16: - return 2; - case 32: - if (is_surface_bgr(surface)) { - return 4; - } else { - return 3; - } - } -} - static void sm501_draw_crt(SM501State * s) { DisplaySurface *surface =3D qemu_console_surface(s->con); @@ -1269,7 +1189,6 @@ static void sm501_draw_crt(SM501State * s) uint32_t * palette =3D (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE - SM501_DC_PANEL_PALETTE]; uint8_t hwc_palette[3 * 3]; - int ds_depth_index =3D get_depth_index(surface); draw_line_func * draw_line =3D NULL; draw_hwc_line_func * draw_hwc_line =3D NULL; int full_update =3D 0; @@ -1282,15 +1201,15 @@ static void sm501_draw_crt(SM501State * s) switch (s->dc_crt_control & 3) { case SM501_DC_CRT_CONTROL_8BPP: src_bpp =3D 1; - draw_line =3D draw_line8_funcs[ds_depth_index]; + draw_line =3D draw_line8_32; break; case SM501_DC_CRT_CONTROL_16BPP: src_bpp =3D 2; - draw_line =3D draw_line16_funcs[ds_depth_index]; + draw_line =3D draw_line16_32; break; case SM501_DC_CRT_CONTROL_32BPP: src_bpp =3D 4; - draw_line =3D draw_line32_funcs[ds_depth_index]; + draw_line =3D draw_line32_32; break; default: printf("sm501 draw crt : invalid DC_CRT_CONTROL=3D%x.\n", @@ -1312,7 +1231,7 @@ static void sm501_draw_crt(SM501State * s) } =20 /* choose cursor draw line function */ - draw_hwc_line =3D draw_hwc_line_funcs[ds_depth_index]; + draw_hwc_line =3D draw_hwc_line_32; } =20 /* adjust console size */ --=20 1.8.3.1 From nobody Sun May 5 06:11:05 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.zoho.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 1488810559887771.9909397719359; Mon, 6 Mar 2017 06:29:19 -0800 (PST) Received: from localhost ([::1]:44182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cktdT-000890-GI for importer@patchew.org; Mon, 06 Mar 2017 09:29:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cktYP-0004NB-5C for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:24:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cktYL-0007Wq-77 for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:24:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33746) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cktYK-0007WQ-Uq for qemu-devel@nongnu.org; Mon, 06 Mar 2017 09:23:57 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18FAD3A768E; Mon, 6 Mar 2017 14:23:57 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v26ENtaj007548; Mon, 6 Mar 2017 09:23:55 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 61FC280BCA; Mon, 6 Mar 2017 15:23:53 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Mar 2017 15:23:50 +0100 Message-Id: <1488810230-31945-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1488810230-31945-1-git-send-email-kraxel@redhat.com> References: <1488810230-31945-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Mar 2017 14:23:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] sm501: drop sm501_template.h 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 , Gerd Hoffmann 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" Now that we include sm501_template.h only once there is no need to keep this stuff in a separate file. FIXME: as peter mentioned the TARGET_WORDS_BIGENDIAN dependency looks suspious. Left as-is for now. Signed-off-by: Gerd Hoffmann --- hw/display/sm501.c | 110 +++++++++++++++++++++++++++++---- hw/display/sm501_template.h | 145 ----------------------------------------= ---- 2 files changed, 98 insertions(+), 157 deletions(-) delete mode 100644 hw/display/sm501_template.h diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 6c7717c..44171c1 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1170,11 +1170,101 @@ static const MemoryRegionOps sm501_2d_engine_ops = =3D { typedef void draw_line_func(uint8_t *d, const uint8_t *s, int width, const uint32_t *pal); =20 -typedef void draw_hwc_line_func(SM501State * s, int crt, uint8_t * palette, - int c_y, uint8_t *d, int width); +static void draw_line8(uint8_t *d, const uint8_t *s, + int width, const uint32_t *pal) +{ + uint8_t v, r, g, b; + do { + v =3D ldub_p(s); + r =3D (pal[v] >> 16) & 0xff; + g =3D (pal[v] >> 8) & 0xff; + b =3D (pal[v] >> 0) & 0xff; + ((uint32_t *) d)[0] =3D rgb_to_pixel32(r, g, b); + s ++; + d +=3D 4; + } while (-- width !=3D 0); +} =20 -#define DEPTH 32 -#include "sm501_template.h" +static void draw_line16(uint8_t *d, const uint8_t *s, + int width, const uint32_t *pal) +{ + uint16_t rgb565; + uint8_t r, g, b; + + do { + rgb565 =3D lduw_p(s); + r =3D ((rgb565 >> 11) & 0x1f) << 3; + g =3D ((rgb565 >> 5) & 0x3f) << 2; + b =3D ((rgb565 >> 0) & 0x1f) << 3; + ((uint32_t *) d)[0] =3D rgb_to_pixel32(r, g, b); + s +=3D 2; + d +=3D 4; + } while (-- width !=3D 0); +} + +static void draw_line32(uint8_t *d, const uint8_t *s, + int width, const uint32_t *pal) +{ + uint8_t r, g, b; + + do { + ldub_p(s); +#if defined(TARGET_WORDS_BIGENDIAN) + r =3D s[1]; + g =3D s[2]; + b =3D s[3]; +#else + b =3D s[0]; + g =3D s[1]; + r =3D s[2]; +#endif + ((uint32_t *) d)[0] =3D rgb_to_pixel32(r, g, b); + s +=3D 4; + d +=3D 4; + } while (-- width !=3D 0); +} + +/** + * Draw hardware cursor image on the given line. + */ +static void draw_hwc_line(SM501State * s, int crt, + uint8_t * palette, int c_y, uint8_t *d, int widt= h) +{ + int x, i; + uint8_t bitset =3D 0; + + /* get hardware cursor pattern */ + uint32_t cursor_addr =3D get_hwc_address(s, crt); + assert(0 <=3D c_y && c_y < SM501_HWC_HEIGHT); + cursor_addr +=3D 64 * c_y / 4; /* 4 pixels per byte */ + cursor_addr +=3D s->base; + + /* get cursor position */ + x =3D get_hwc_x(s, crt); + d +=3D x * 4; + + for (i =3D 0; i < SM501_HWC_WIDTH && x + i < width; i++) { + uint8_t v; + + /* get pixel value */ + if (i % 4 =3D=3D 0) { + bitset =3D ldub_phys(&address_space_memory, cursor_addr); + cursor_addr++; + } + v =3D bitset & 3; + bitset >>=3D 2; + + /* write pixel */ + if (v) { + v--; + uint8_t r =3D palette[v * 3 + 0]; + uint8_t g =3D palette[v * 3 + 1]; + uint8_t b =3D palette[v * 3 + 2]; + ((uint32_t *) d)[0] =3D rgb_to_pixel32(r, g, b); + } + d +=3D 4; + } +} =20 static void sm501_draw_crt(SM501State * s) { @@ -1190,7 +1280,6 @@ static void sm501_draw_crt(SM501State * s) - SM501_DC_PANEL_PALETTE]; uint8_t hwc_palette[3 * 3]; draw_line_func * draw_line =3D NULL; - draw_hwc_line_func * draw_hwc_line =3D NULL; int full_update =3D 0; int y_start =3D -1; ram_addr_t page_min =3D ~0l; @@ -1201,15 +1290,15 @@ static void sm501_draw_crt(SM501State * s) switch (s->dc_crt_control & 3) { case SM501_DC_CRT_CONTROL_8BPP: src_bpp =3D 1; - draw_line =3D draw_line8_32; + draw_line =3D draw_line8; break; case SM501_DC_CRT_CONTROL_16BPP: src_bpp =3D 2; - draw_line =3D draw_line16_32; + draw_line =3D draw_line16; break; case SM501_DC_CRT_CONTROL_32BPP: src_bpp =3D 4; - draw_line =3D draw_line32_32; + draw_line =3D draw_line32; break; default: printf("sm501 draw crt : invalid DC_CRT_CONTROL=3D%x.\n", @@ -1229,9 +1318,6 @@ static void sm501_draw_crt(SM501State * s) hwc_palette[i * 3 + 1] =3D (rgb565 & 0x07e0) >> 3; /* green */ hwc_palette[i * 3 + 2] =3D (rgb565 & 0x001f) << 3; /* blue */ } - - /* choose cursor draw line function */ - draw_hwc_line =3D draw_hwc_line_32; } =20 /* adjust console size */ @@ -1246,7 +1332,7 @@ static void sm501_draw_crt(SM501State * s) /* draw each line according to conditions */ memory_region_sync_dirty_bitmap(&s->local_mem_region); for (y =3D 0; y < height; y++) { - int update_hwc =3D draw_hwc_line ? within_hwc_y_range(s, y, 1) : 0; + int update_hwc =3D is_hwc_enabled(s, 1) && within_hwc_y_range(s, y, 1); int update =3D full_update || update_hwc; ram_addr_t page0 =3D offset; ram_addr_t page1 =3D offset + width * src_bpp - 1; diff --git a/hw/display/sm501_template.h b/hw/display/sm501_template.h deleted file mode 100644 index f33e499..0000000 --- a/hw/display/sm501_template.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Pixel drawing function templates for QEMU SM501 Device - * - * Copyright (c) 2008 Shin-ichiro KAWASAKI - * - * Permission is hereby granted, free of charge, to any person obtaining a= copy - * of this software and associated documentation files (the "Software"), t= o deal - * in the Software without restriction, including without limitation the r= ights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included= in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN - * THE SOFTWARE. - */ - -#if DEPTH =3D=3D 8 -#define BPP 1 -#define PIXEL_TYPE uint8_t -#elif DEPTH =3D=3D 15 || DEPTH =3D=3D 16 -#define BPP 2 -#define PIXEL_TYPE uint16_t -#elif DEPTH =3D=3D 32 -#define BPP 4 -#define PIXEL_TYPE uint32_t -#else -#error unsupport depth -#endif - -#ifdef BGR_FORMAT -#define PIXEL_NAME glue(DEPTH, bgr) -#else -#define PIXEL_NAME DEPTH -#endif /* BGR_FORMAT */ - - -static void glue(draw_line8_, PIXEL_NAME)( - uint8_t *d, const uint8_t *s, int width, const uint32_t *= pal) -{ - uint8_t v, r, g, b; - do { - v =3D ldub_p(s); - r =3D (pal[v] >> 16) & 0xff; - g =3D (pal[v] >> 8) & 0xff; - b =3D (pal[v] >> 0) & 0xff; - ((PIXEL_TYPE *) d)[0] =3D glue(rgb_to_pixel, PIXEL_NAME)(r, g, b); - s ++; - d +=3D BPP; - } while (-- width !=3D 0); -} - -static void glue(draw_line16_, PIXEL_NAME)( - uint8_t *d, const uint8_t *s, int width, const uint32_t *pal) -{ - uint16_t rgb565; - uint8_t r, g, b; - - do { - rgb565 =3D lduw_p(s); - r =3D ((rgb565 >> 11) & 0x1f) << 3; - g =3D ((rgb565 >> 5) & 0x3f) << 2; - b =3D ((rgb565 >> 0) & 0x1f) << 3; - ((PIXEL_TYPE *) d)[0] =3D glue(rgb_to_pixel, PIXEL_NAME)(r, g, b); - s +=3D 2; - d +=3D BPP; - } while (-- width !=3D 0); -} - -static void glue(draw_line32_, PIXEL_NAME)( - uint8_t *d, const uint8_t *s, int width, const uint32_t *pal) -{ - uint8_t r, g, b; - - do { - ldub_p(s); -#if defined(TARGET_WORDS_BIGENDIAN) - r =3D s[1]; - g =3D s[2]; - b =3D s[3]; -#else - b =3D s[0]; - g =3D s[1]; - r =3D s[2]; -#endif - ((PIXEL_TYPE *) d)[0] =3D glue(rgb_to_pixel, PIXEL_NAME)(r, g, b); - s +=3D 4; - d +=3D BPP; - } while (-- width !=3D 0); -} - -/** - * Draw hardware cursor image on the given line. - */ -static void glue(draw_hwc_line_, PIXEL_NAME)(SM501State * s, int crt, - uint8_t * palette, int c_y, uint8_t *d, int width) -{ - int x, i; - uint8_t bitset =3D 0; - - /* get hardware cursor pattern */ - uint32_t cursor_addr =3D get_hwc_address(s, crt); - assert(0 <=3D c_y && c_y < SM501_HWC_HEIGHT); - cursor_addr +=3D 64 * c_y / 4; /* 4 pixels per byte */ - cursor_addr +=3D s->base; - - /* get cursor position */ - x =3D get_hwc_x(s, crt); - d +=3D x * BPP; - - for (i =3D 0; i < SM501_HWC_WIDTH && x + i < width; i++) { - uint8_t v; - - /* get pixel value */ - if (i % 4 =3D=3D 0) { - bitset =3D ldub_phys(&address_space_memory, cursor_addr); - cursor_addr++; - } - v =3D bitset & 3; - bitset >>=3D 2; - - /* write pixel */ - if (v) { - v--; - uint8_t r =3D palette[v * 3 + 0]; - uint8_t g =3D palette[v * 3 + 1]; - uint8_t b =3D palette[v * 3 + 2]; - ((PIXEL_TYPE *) d)[0] =3D glue(rgb_to_pixel, PIXEL_NAME)(r, g,= b); - } - d +=3D BPP; - } -} - -#undef DEPTH -#undef BPP -#undef PIXEL_TYPE -#undef PIXEL_NAME -#undef BGR_FORMAT --=20 1.8.3.1