From patchwork Mon May 16 14:29:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12850937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E7099C433EF for ; Mon, 16 May 2022 14:54:38 +0000 (UTC) Received: from localhost ([::1]:47494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqc7J-00074v-Pa for qemu-devel@archiver.kernel.org; Mon, 16 May 2022 10:54:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqbis-00038x-Vq for qemu-devel@nongnu.org; Mon, 16 May 2022 10:29:23 -0400 Received: from mout.gmx.net ([212.227.17.20]:59821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqbir-0004wO-5P for qemu-devel@nongnu.org; Mon, 16 May 2022 10:29:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652711351; bh=nFE54bnqkG6YAdVZIr18MUe31ug2M7jvMYLvH1spCtI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=bfkNUz7rZXAhqO8sIjMFyphQzP6eFFI/rM64XIerzDkQrRYUennuAiMgMgg7+CK4s TGGj6h6C/MpV9hKP4dVXA6nFTJ3k79YoK55M1c95J228bWD1AYLdZotySbQnqcv88Y G5gw6WkxZehI4I2WMYuokzuU7i7MLSeDomFSJQ6A= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.160.68]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MWici-1oNXri3te4-00X0W8; Mon, 16 May 2022 16:29:10 +0200 From: Helge Deller To: Mark Cave-Ayland , qemu-devel@nongnu.org, Richard Henderson , Sven Schnelle , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Cc: Helge Deller , Stefano Repici Subject: [PATCH v2 7/7] artist: Fix X cursor position calculation in X11 Date: Mon, 16 May 2022 16:29:07 +0200 Message-Id: <20220516142907.32827-8-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516142907.32827-1-deller@gmx.de> References: <20220516142907.32827-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:JqoITjPxJMAIGbvzruhbuyl8TwBv2nETtjr+/oWYRn37e22vpPS 7tOrKs5Ym2yupha+nziiGGAsKgQzWzopUDT8G63mTuCIgx35UBAegMJy0520oHSG3DmsUVY 7I6Dt/c3lmA1a4PDQiNO6ipwnWX6r2Z7mLcUYBm2G60hTbg2xeTmTKsfB77GWa2qqLW6ZJY uLKUWlE6dDHn52BWh7BUA== X-UI-Out-Filterresults: notjunk:1;V03:K0:G0K3rWamlM0=:1Fjs+VUzBNuK+eSB+KSPhV VkLBr/yjH88wJBLfzjWz0j0M33U1xb3wmbvQ7HBCH5QCtB5/rfvTI4cxivYbbvTQhls8ix3eh EbjzsPCljDxvhU8EvwFDzwn7an+PZWcCVz2vp9R65YbuDvw2fkofjD/aFeoSWqhVipaU11Q3r jE6LzzUxe+ia5jSeUR6xxlF00TFSUhZZUew3qxJkUGyIb9uJsL/2Icny92llNYR5nlf5Nf02Q Uw5bKZVK+FSTxEaCqOBRK2q6Tx9Mv5m+3qx7LV1ZhNVFOSDa3vR6s5kv8Yuj9Ift2kJVGnZ5w +ko0lrMKkeRtBkiw+17G+3OB3AUQKfY0+Fzb61SK+kpLXA6JofXez++Nslu8PhD92wERrQSXN k9JCU4miEnB6cXCJ7zJoj9MgN3IUW2C2ldZZv+JFzqlTQkfvrPuk3kjuIup1yRTLaAn6gFjhw qCaa65YGgWC35WOKovtZ8X0hW4DyW1V39D0NTakD0HpxDBgE+3RNp9depIW88iBEoXPdu63ZT RON4pKsamxKxAEnZ2DJy1QKSypJYqJJeiXn32FceBNZ0oTlQXHKkYCBn8rU67Z6yzmjiV1Ami L1YCQ9hs+FfwMa4CoI6d6mcaqhLXfpvQQEifKGTpC3+lY+SrkqWS7W5zA61fnmdz9BNjqaoIy PHIyL8pm48y2reEFb/5B6qkNQOps+hMdUK2LCf/bwqUAX+Zmleu4OQyhYP1IMd/Y8aAh4VFSY 6ZNLjMMvrbYD0oa6kHARgxTIKjJx0keVAjZlpag8dZrNUCHxesR4CDkVvnmfiuORVxG5SK0pV nAZ4VQeT/6nOXuX7IZ3ZZN9dus2KfQHa+O4DkbDoTDKb0MsIIgMUIyv4d5/+wiaf2Z5n57CYE dQsn8nBDn5j1l8YSjje4NYPaeb5FLruv2tT9pRFdbOntrBRL1K3ITrCcYfEK0qihkFRDB/gXn ddfMiMJrDj8atZJtyMNB6mtX2nsDA8UDYL5EeZypz1yzunbcskOjFTA32wIc8QNuZs9odfEpX r0bYyeBYy3U4w26VfoyPKAXguEg61Dd1c4KkZCFMvP4VJhKtl+v2/1PLymCZerjpEjrY/BB7M tpUey50hv+fvsg7TpQ7RBQRSGX/nTvLklLuacNLHpgz13qLNos1ZgqlTw== Received-SPF: pass client-ip=212.227.17.20; envelope-from=deller@gmx.de; helo=mout.gmx.net 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The X cursor postion can be calculated based on the backporch and interleave values. In the emulation we ignore the HP-UX settings for backporch and use instead twice the size of the emulated cursor. With those changes the X-position of the graphics cursor is now finally working correctly on HP-UX 10 and HP-UX 11. Based on coding in Xorg X11R6.6 Signed-off-by: Helge Deller --- hw/display/artist.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) -- 2.35.3 diff --git a/hw/display/artist.c b/hw/display/artist.c index 49dad2b824..8bf3bed79a 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -1,7 +1,8 @@ /* * QEMU HP Artist Emulation * - * Copyright (c) 2019 Sven Schnelle + * Copyright (c) 2019-2022 Sven Schnelle + * Copyright (c) 2022 Helge Deller * * This work is licensed under the terms of the GNU GPL, version 2 or later. */ @@ -313,19 +314,15 @@ static void artist_rop8(ARTISTState *s, struct vram_buffer *buf, static void artist_get_cursor_pos(ARTISTState *s, int *x, int *y) { /* - * Don't know whether these magic offset values are configurable via - * some register. They seem to be the same for all resolutions. - * The cursor values provided in the registers are: - * X-value: -295 (for HP-UX 11) and 338 (for HP-UX 10.20) up to 2265 - * Y-value: 1146 down to 0 * The emulated Artist graphic is like a CRX graphic, and as such * it's usually fixed at 1280x1024 pixels. - * Because of the maximum Y-value of 1146 you can not choose a higher - * vertical resolution on HP-UX (unless you disable the mouse). + * Other resolutions may work, but no guarantee. */ - static int offset = 338; - int lx; + unsigned int hbp_times_vi, horizBackPorch; + int16_t xHi, xLo; + const int videoInterleave = 4; + const int pipelineDelay = 4; /* ignore if uninitialized */ if (s->cursor_pos == 0) { @@ -333,16 +330,22 @@ static void artist_get_cursor_pos(ARTISTState *s, int *x, int *y) return; } - lx = artist_get_x(s->cursor_pos); - if (lx < offset) { - offset = lx; - } - *x = (lx - offset) / 2; + /* Calculate X position based on backporch and interleave values. + Based on code from Xorg X11R6.6 + */ + horizBackPorch = ((s->horiz_backporch & 0xff0000) >> 16) + + ((s->horiz_backporch & 0xff00) >> 8) + 2; + hbp_times_vi = horizBackPorch * videoInterleave; + xHi = s->cursor_pos >> 19; + *x = ((xHi + pipelineDelay) * videoInterleave) - hbp_times_vi; + + xLo = (s->cursor_pos >> 16) & 0x07; + *x += ((xLo - hbp_times_vi) & (videoInterleave - 1)) + 8 - 1; /* subtract cursor offset from cursor control register */ *x -= (s->cursor_cntrl & 0xf0) >> 4; - /* height minus nOffscreenScanlines is stored in cursor control register */ + /* Calculate Y position */ *y = s->height - artist_get_y(s->cursor_pos); *y -= (s->cursor_cntrl & 0x0f); @@ -1056,6 +1059,8 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val, break; case HORIZ_BACKPORCH: + /* overwrite HP-UX settings to fix X cursor position. */ + val = (NGLE_MAX_SPRITE_SIZE << 16) + (NGLE_MAX_SPRITE_SIZE << 8); combine_write_reg(addr, val, size, &s->horiz_backporch); break;