From nobody Mon Feb 9 11:01:49 2026 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 149272203265926.551499760820093; Thu, 20 Apr 2017 14:00:32 -0700 (PDT) Received: from localhost ([::1]:55976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1JBn-0000ZF-C2 for importer@patchew.org; Thu, 20 Apr 2017 17:00:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1J80-0005er-Vt for qemu-devel@nongnu.org; Thu, 20 Apr 2017 16:56:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1J7z-00051P-0E for qemu-devel@nongnu.org; Thu, 20 Apr 2017 16:56:36 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:30672) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1J7y-00050Q-Mr; Thu, 20 Apr 2017 16:56:34 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 943BC7456CF; Thu, 20 Apr 2017 22:56:17 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id D5D7C7456D1; Thu, 20 Apr 2017 22:56:16 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Date: Thu, 20 Apr 2017 22:43:46 +0200 To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 Subject: [Qemu-devel] [PATCH v5 10/13] sm501: Add support for panel layer 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 , Magnus Damm , Aurelien Jarno , David Gibson 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" Signed-off-by: BALATON Zoltan Reviewed-by: Peter Maydell --- v2: Split off renaming a variable to separate clean up patch hw/display/sm501.c | 63 +++++++++++++++++++++++++++-----------------------= ---- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 2385f59..8abac8f 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -2,6 +2,7 @@ * QEMU SM501 Device * * Copyright (c) 2008 Shin-ichiro KAWASAKI + * Copyright (c) 2016 BALATON Zoltan * * 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 @@ -42,8 +43,11 @@ * - Minimum implementation for Linux console : mmio regs and CRT layer. * - 2D graphics acceleration partially supported : only fill rectangle. * - * TODO: + * Status: 2016/12/04 + * - Misc fixes: endianness, hardware cursor * - Panel support + * + * TODO: * - Touch panel support * - USB support * - UART support @@ -1301,18 +1305,16 @@ static inline int get_depth_index(DisplaySurface *s= urface) } } =20 -static void sm501_draw_crt(SM501State *s) +static void sm501_update_display(void *opaque) { + SM501State *s =3D (SM501State *)opaque; DisplaySurface *surface =3D qemu_console_surface(s->con); int y, c_x, c_y; - uint8_t *hwc_src, *src =3D s->local_mem; - int width =3D get_width(s, 1); - int height =3D get_height(s, 1); - int src_bpp =3D get_bpp(s, 1); + int crt =3D (s->dc_crt_control & SM501_DC_CRT_CONTROL_SEL) ? 1 : 0; + int width =3D get_width(s, crt); + int height =3D get_height(s, crt); + int src_bpp =3D get_bpp(s, crt); int dst_bpp =3D surface_bytes_per_pixel(surface); - uint32_t *palette =3D (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE - - SM501_DC_PANEL_PALETTE]; - uint8_t hwc_palette[3 * 3]; int dst_depth_index =3D get_depth_index(surface); draw_line_func *draw_line =3D NULL; draw_hwc_line_func *draw_hwc_line =3D NULL; @@ -1320,7 +1322,19 @@ static void sm501_draw_crt(SM501State *s) int y_start =3D -1; ram_addr_t page_min =3D ~0l; ram_addr_t page_max =3D 0l; - ram_addr_t offset =3D 0; + ram_addr_t offset; + uint32_t *palette; + uint8_t hwc_palette[3 * 3]; + uint8_t *hwc_src; + + if (!((crt ? s->dc_crt_control : s->dc_panel_control) + & SM501_DC_CRT_CONTROL_ENABLE)) { + return; + } + + palette =3D (uint32_t *)(crt ? &s->dc_palette[SM501_DC_CRT_PALETTE - + SM501_DC_PANEL_PALETTE] + : &s->dc_palette[0]); =20 /* choose draw_line function */ switch (src_bpp) { @@ -1334,20 +1348,19 @@ static void sm501_draw_crt(SM501State *s) draw_line =3D draw_line32_funcs[dst_depth_index]; break; default: - printf("sm501 draw crt : invalid DC_CRT_CONTROL=3D%x.\n", - s->dc_crt_control); + printf("sm501 update display : invalid control register value.\n"); abort(); break; } =20 /* set up to draw hardware cursor */ - if (is_hwc_enabled(s, 1)) { + if (is_hwc_enabled(s, crt)) { /* choose cursor draw line function */ draw_hwc_line =3D draw_hwc_line_funcs[dst_depth_index]; - hwc_src =3D get_hwc_address(s, 1); - c_x =3D get_hwc_x(s, 1); - c_y =3D get_hwc_y(s, 1); - get_hwc_palette(s, 1, hwc_palette); + hwc_src =3D get_hwc_address(s, crt); + c_x =3D get_hwc_x(s, crt); + c_y =3D get_hwc_y(s, crt); + get_hwc_palette(s, crt, hwc_palette); } =20 /* adjust console size */ @@ -1361,7 +1374,7 @@ static void sm501_draw_crt(SM501State *s) =20 /* draw each line according to conditions */ memory_region_sync_dirty_bitmap(&s->local_mem_region); - for (y =3D 0; y < height; y++) { + for (y =3D 0, offset =3D 0; y < height; y++, offset +=3D width * src_b= pp) { int update, update_hwc; ram_addr_t page0 =3D offset; ram_addr_t page1 =3D offset + width * src_bpp - 1; @@ -1379,7 +1392,7 @@ static void sm501_draw_crt(SM501State *s) d +=3D y * width * dst_bpp; =20 /* draw graphics layer */ - draw_line(d, src, width, palette); + draw_line(d, s->local_mem + offset, width, palette); =20 /* draw hardware cursor */ if (update_hwc) { @@ -1402,9 +1415,6 @@ static void sm501_draw_crt(SM501State *s) y_start =3D -1; } } - - src +=3D width * src_bpp; - offset +=3D width * src_bpp; } =20 /* complete flush to display */ @@ -1420,15 +1430,6 @@ static void sm501_draw_crt(SM501State *s) } } =20 -static void sm501_update_display(void *opaque) -{ - SM501State *s =3D (SM501State *)opaque; - - if (s->dc_crt_control & SM501_DC_CRT_CONTROL_ENABLE) { - sm501_draw_crt(s); - } -} - static const GraphicHwOps sm501_ops =3D { .gfx_update =3D sm501_update_display, }; --=20 2.7.4