From patchwork Thu Sep 3 16:07:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 274661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F692C433E2 for ; Thu, 3 Sep 2020 16:11:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FEA320716 for ; Thu, 3 Sep 2020 16:11:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="f0Ij6uIv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FEA320716 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDrpt-0001Jt-2j for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 12:11:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDrmb-0007xk-Mn for qemu-devel@nongnu.org; Thu, 03 Sep 2020 12:08:17 -0400 Received: from mout.gmx.net ([212.227.17.20]:47577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDrmZ-0007lr-NN for qemu-devel@nongnu.org; Thu, 03 Sep 2020 12:08:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1599149272; bh=nnNlK5lEXtZIws7ZcRwRHZ3YQMN8yoczHrA5VaeDSoM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=f0Ij6uIvE2Dsjqk+ukhETOI5LaUq6S2RNWFVSj4eagMp5IObAu/BVm6IamlgWHoAb 6TXeZLRXFW1pvqgxF++8nasQwKU9E0wfTaWRCsxtdOAPb4CZkPXoTTVOBWNQMGtNtK auIiU/m5w1ORX8kWhQB+dbEZ4VkykJfRryLSnVqg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from ls3530.fritz.box ([92.116.138.28]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MC30P-1kPjLu3e6n-00CO9z; Thu, 03 Sep 2020 18:07:51 +0200 From: Helge Deller To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 09/10] hw/display/artist: Refactor x/y coordination extraction Date: Thu, 3 Sep 2020 18:07:45 +0200 Message-Id: <20200903160746.27491-10-deller@gmx.de> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200903160746.27491-1-deller@gmx.de> References: <20200903160746.27491-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:bYMNUoqq2uXBXRY2opA4yyv42Gwoehc/zZeiIgvhvkAuY1hwyRl L5/rJEQYO0H0ZDdxkif9+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/aDYI4zt2GbJ+hI0kwb3GVN5r4mZCMDeyarIX3byxZMWB9t5nu28n28d9OY5DT4H9W rXb9XUf/658zGAMajqZUqDABdMDxsH0fQrlGtVfL3xeqHJz9AkAzaKnNqwIw6V5DfGsGmVbH9 9YjX6Nl7OuaYtcJzazMpy9RuFXHQaafFUc7v4gbG2JaLvQZLhT2NQbHbHs3wTtXTUjkWeOIl7 50jmIcmEcfNP97Snye+PZJpsBYzzAU7kkH4rE/ETXBW2scsyu00gnObjxgAYbK+4uD/P2MbyL 5SIWnPshO8iPFaJxCREVB3a3ae6oqK7DBnNmrcmEBFf7ZXOKrjN25Ez9fqxf1e/iYStrl3kc0 p4F2GniHpqgaAmgD8 Received-SPF: pass client-ip=212.227.17.20; envelope-from=deller@gmx.de; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 12:08:01 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Helge Deller , Richard Henderson , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Simplify the code by using new introduced ADDR_TO_Y() and ADDR_TO_X() macros. Those macros extract the x/y-coordinate from the given uint32. As further simplification the extraction of the x/y coordinates for VRAM_WRITE_INCR_Y and VRAM_WRITE_INCR_X can be done centrally in vram_bit_write(), so move this code up into the function. ADDR_TO_Y() is still limited to 10 bits which allow to address up to of 1024 lines - this will be increased in a follow-up patch. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson --- hw/display/artist.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) -- 2.21.3 diff --git a/hw/display/artist.c b/hw/display/artist.c index ff1532fdc1..16d85c65f8 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -192,6 +192,10 @@ static const char *artist_reg_name(uint64_t addr) } #undef REG_NAME +/* artist has a fixed line length of 2048 bytes. */ +#define ADDR_TO_Y(addr) extract32(addr, 11, 10) +#define ADDR_TO_X(addr) extract32(addr, 0, 11) + static int16_t artist_get_x(uint32_t reg) { return reg >> 16; @@ -348,13 +352,13 @@ static void artist_invalidate_cursor(ARTISTState *s) y, s->cursor_height); } -static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, +static void vram_bit_write(ARTISTState *s, int posy, bool incr_x, int size, uint32_t data) { struct vram_buffer *buf; uint32_t vram_bitmask = s->vram_bitmask; int mask, i, pix_count, pix_length; - unsigned int offset, width; + unsigned int posx, offset, width; uint8_t *data8, *p; pix_count = vram_write_pix_per_transfer(s); @@ -366,6 +370,8 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, if (s->cmap_bm_access) { offset = s->vram_pos; } else { + posx = ADDR_TO_X(s->vram_pos >> 2); + posy += ADDR_TO_Y(s->vram_pos >> 2); offset = posy * width + posx; } @@ -858,7 +864,6 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { ARTISTState *s = opaque; - int posx, posy; int width, height; trace_artist_reg_write(size, addr, artist_reg_name(addr & ~3ULL), val); @@ -881,16 +886,12 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val, break; case VRAM_WRITE_INCR_Y: - posx = (s->vram_pos >> 2) & 0x7ff; - posy = (s->vram_pos >> 13) & 0x3ff; - vram_bit_write(s, posx, posy + s->vram_char_y++, false, size, val); + vram_bit_write(s, s->vram_char_y++, false, size, val); break; case VRAM_WRITE_INCR_X: case VRAM_WRITE_INCR_X2: - posx = (s->vram_pos >> 2) & 0x7ff; - posy = (s->vram_pos >> 13) & 0x3ff; - vram_bit_write(s, posx, posy + s->vram_char_y, true, size, val); + vram_bit_write(s, s->vram_char_y, true, size, val); break; case VRAM_IDX: @@ -1156,8 +1157,7 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val, { ARTISTState *s = opaque; struct vram_buffer *buf; - int posy = (addr >> 11) & 0x3ff; - int posx = addr & 0x7ff; + unsigned int posy, posx; unsigned int offset; trace_artist_vram_write(size, addr, val); @@ -1170,6 +1170,9 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val, } buf = vram_write_buffer(s); + posy = ADDR_TO_Y(addr); + posx = ADDR_TO_X(addr); + if (!buf->size) { return; } @@ -1212,7 +1215,7 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size) ARTISTState *s = opaque; struct vram_buffer *buf; uint64_t val; - int posy, posx; + unsigned int posy, posx; if (s->cmap_bm_access) { buf = &s->vram_buffer[ARTIST_BUFFER_CMAP]; @@ -1229,8 +1232,8 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size) return 0; } - posy = (addr >> 13) & 0x3ff; - posx = (addr >> 2) & 0x7ff; + posy = ADDR_TO_Y(addr); + posx = ADDR_TO_X(addr); if (posy > buf->height || posx > buf->width) { return 0;