From patchwork Fri Jul 5 11:47:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13725017 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 3D70CC38150 for ; Fri, 5 Jul 2024 11:49:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B6E6010EB85; Fri, 5 Jul 2024 11:49:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="AohUgv0M"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="SDqhQ5YX"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="AohUgv0M"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="SDqhQ5YX"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86ABC10EB83 for ; Fri, 5 Jul 2024 11:49:07 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 40E6F1FD00; Fri, 5 Jul 2024 11:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fLJtU5qrVBgJuCDgh+13cOQ/gWo/eqI+i2mq8PQTpBM=; b=AohUgv0MCHRXBViO8ZdTyOkMFRv+GwbVoqaxS/7ZMFx+W9C5Mtj0fzm45AKwHisOMg7JE0 zHnCe3YYf3u/S+ILlO1GlXIh5kA+BZ0iViWDPzsdDkcb5ZX6mGZLGQlAC8NL3bLtpJdAIM pbkj5WwPW9sZAwpr0oEQATQP1ZwRj3M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fLJtU5qrVBgJuCDgh+13cOQ/gWo/eqI+i2mq8PQTpBM=; b=SDqhQ5YXOqVqKHYHcxqUWk6UG8Jt3DpJ51/O33gtgIBp7oATpmvOZLdi/DgUxMMMG95qoh IUAuZt3+uOuNS9DQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=AohUgv0M; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=SDqhQ5YX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fLJtU5qrVBgJuCDgh+13cOQ/gWo/eqI+i2mq8PQTpBM=; b=AohUgv0MCHRXBViO8ZdTyOkMFRv+GwbVoqaxS/7ZMFx+W9C5Mtj0fzm45AKwHisOMg7JE0 zHnCe3YYf3u/S+ILlO1GlXIh5kA+BZ0iViWDPzsdDkcb5ZX6mGZLGQlAC8NL3bLtpJdAIM pbkj5WwPW9sZAwpr0oEQATQP1ZwRj3M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fLJtU5qrVBgJuCDgh+13cOQ/gWo/eqI+i2mq8PQTpBM=; b=SDqhQ5YXOqVqKHYHcxqUWk6UG8Jt3DpJ51/O33gtgIBp7oATpmvOZLdi/DgUxMMMG95qoh IUAuZt3+uOuNS9DQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F12A213974; Fri, 5 Jul 2024 11:49:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eHubObHdh2bUcQAAD6G6ig (envelope-from ); Fri, 05 Jul 2024 11:49:05 +0000 From: Thomas Zimmermann To: jfalempe@redhat.com, airlied@redhat.com, sam@ravnborg.org, emil.l.velikov@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v4 1/7] drm/mgag200: Use hexadecimal register indeces Date: Fri, 5 Jul 2024 13:47:44 +0200 Message-ID: <20240705114900.572-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705114900.572-1-tzimmermann@suse.de> References: <20240705114900.572-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: 40E6F1FD00 X-Spamd-Result: default: False [-1.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ravnborg.org,gmail.com,linux.intel.com,kernel.org,ffwll.ch]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In mgag200_set_mode_regs(), use hexadecimal indices for accessing registers. Aligns the code with the register indices in the Matrox programming manuals. Also convert to lower-case hexadecimal values. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/mgag200_mode.c | 50 +++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index d4550e4b3b01..4ceaa33e8d42 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -249,31 +249,31 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod ((vdisplay & 0x400) >> 3); crtcext5 = 0x00; - WREG_CRT(0, htotal - 4); - WREG_CRT(1, hdisplay); - WREG_CRT(2, hdisplay); - WREG_CRT(3, (htotal & 0x1F) | 0x80); - WREG_CRT(4, hsyncstart); - WREG_CRT(5, ((htotal & 0x20) << 2) | (hsyncend & 0x1F)); - WREG_CRT(6, vtotal & 0xFF); - WREG_CRT(7, ((vtotal & 0x100) >> 8) | - ((vdisplay & 0x100) >> 7) | - ((vsyncstart & 0x100) >> 6) | - ((vdisplay & 0x100) >> 5) | - ((vdisplay & 0x100) >> 4) | /* linecomp */ - ((vtotal & 0x200) >> 4) | - ((vdisplay & 0x200) >> 3) | - ((vsyncstart & 0x200) >> 2)); - WREG_CRT(9, ((vdisplay & 0x200) >> 4) | - ((vdisplay & 0x200) >> 3)); - WREG_CRT(16, vsyncstart & 0xFF); - WREG_CRT(17, (vsyncend & 0x0F) | 0x20); - WREG_CRT(18, vdisplay & 0xFF); - WREG_CRT(20, 0); - WREG_CRT(21, vdisplay & 0xFF); - WREG_CRT(22, (vtotal + 1) & 0xFF); - WREG_CRT(23, 0xc3); - WREG_CRT(24, vdisplay & 0xFF); + WREG_CRT(0x00, htotal - 4); + WREG_CRT(0x01, hdisplay); + WREG_CRT(0x02, hdisplay); + WREG_CRT(0x03, (htotal & 0x1f) | 0x80); + WREG_CRT(0x04, hsyncstart); + WREG_CRT(0x05, ((htotal & 0x20) << 2) | (hsyncend & 0x1f)); + WREG_CRT(0x06, vtotal & 0xff); + WREG_CRT(0x07, ((vtotal & 0x100) >> 8) | + ((vdisplay & 0x100) >> 7) | + ((vsyncstart & 0x100) >> 6) | + ((vdisplay & 0x100) >> 5) | + ((vdisplay & 0x100) >> 4) | /* linecomp */ + ((vtotal & 0x200) >> 4) | + ((vdisplay & 0x200) >> 3) | + ((vsyncstart & 0x200) >> 2)); + WREG_CRT(0x09, ((vdisplay & 0x200) >> 4) | + ((vdisplay & 0x200) >> 3)); + WREG_CRT(0x10, vsyncstart & 0xff); + WREG_CRT(0x11, (vsyncend & 0x0f) | 0x20); + WREG_CRT(0x12, vdisplay & 0xff); + WREG_CRT(0x14, 0); + WREG_CRT(0x15, vdisplay & 0xff); + WREG_CRT(0x16, (vtotal + 1) & 0xff); + WREG_CRT(0x17, 0xc3); + WREG_CRT(0x18, vdisplay & 0xff); WREG_ECRT(0x01, crtcext1); WREG_ECRT(0x02, crtcext2); From patchwork Fri Jul 5 11:47:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13725020 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 57A95C3DA41 for ; Fri, 5 Jul 2024 11:49:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C1A510EB78; Fri, 5 Jul 2024 11:49:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="fqdu27Uf"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="isPYFSLe"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="fqdu27Uf"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="isPYFSLe"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id F3C8610EB78 for ; Fri, 5 Jul 2024 11:49:07 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8BBD621923; Fri, 5 Jul 2024 11:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UHHV4gQy76cYap6RseEXnINexEmR1KmikzjY62BR+wg=; b=fqdu27UfgPbrt7HyPHa4gerQEXy2CGHpx3v5fKd1+2lals43B8vI6qeI/f1acp3xZtPult fWvOPWCB/rrBai7FzP8vqTrcxwi4iwqPOlbv5ZiXqxEipH3Px5bkQNPHQ4Kdj7+YFUTVo2 xTm1+Ts0a6gs0c9nHRLwDEhcRtc4w/o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UHHV4gQy76cYap6RseEXnINexEmR1KmikzjY62BR+wg=; b=isPYFSLeZEclAlHvg9rerH8ZveoyccHo19XLqNAEi+GIDVz5KixZJ7q1Gijof2GNyXWh1j +2C/fu3Bz0mscjBw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=fqdu27Uf; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=isPYFSLe DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UHHV4gQy76cYap6RseEXnINexEmR1KmikzjY62BR+wg=; b=fqdu27UfgPbrt7HyPHa4gerQEXy2CGHpx3v5fKd1+2lals43B8vI6qeI/f1acp3xZtPult fWvOPWCB/rrBai7FzP8vqTrcxwi4iwqPOlbv5ZiXqxEipH3Px5bkQNPHQ4Kdj7+YFUTVo2 xTm1+Ts0a6gs0c9nHRLwDEhcRtc4w/o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UHHV4gQy76cYap6RseEXnINexEmR1KmikzjY62BR+wg=; b=isPYFSLeZEclAlHvg9rerH8ZveoyccHo19XLqNAEi+GIDVz5KixZJ7q1Gijof2GNyXWh1j +2C/fu3Bz0mscjBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 471AD13889; Fri, 5 Jul 2024 11:49:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MBssELLdh2bUcQAAD6G6ig (envelope-from ); Fri, 05 Jul 2024 11:49:06 +0000 From: Thomas Zimmermann To: jfalempe@redhat.com, airlied@redhat.com, sam@ravnborg.org, emil.l.velikov@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v4 2/7] drm/mgag200: Align register field names with documentation Date: Fri, 5 Jul 2024 13:47:45 +0200 Message-ID: <20240705114900.572-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705114900.572-1-tzimmermann@suse.de> References: <20240705114900.572-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-1.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ravnborg.org,gmail.com,linux.intel.com,kernel.org,ffwll.ch]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 8BBD621923 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In mgag200_set_mode_regs(), align variable names with the field names given in the Matrox programming manuals. Makes the code and docs grep- able. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/mgag200_mode.c | 56 +++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 4ceaa33e8d42..09e2a5b80403 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -204,12 +204,12 @@ void mgag200_init_registers(struct mga_device *mdev) void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode) { const struct mgag200_device_info *info = mdev->info; - unsigned int hdisplay, hsyncstart, hsyncend, htotal; - unsigned int vdisplay, vsyncstart, vsyncend, vtotal; + unsigned int hdispend, hsyncstr, hsyncend, htotal; + unsigned int vdispend, vsyncstr, vsyncend, vtotal; u8 misc, crtcext1, crtcext2, crtcext5; - hdisplay = mode->hdisplay / 8 - 1; - hsyncstart = mode->hsync_start / 8 - 1; + hdispend = mode->hdisplay / 8 - 1; + hsyncstr = mode->hsync_start / 8 - 1; hsyncend = mode->hsync_end / 8 - 1; htotal = mode->htotal / 8 - 1; @@ -217,8 +217,8 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod if ((htotal & 0x07) == 0x06 || (htotal & 0x07) == 0x04) htotal++; - vdisplay = mode->vdisplay - 1; - vsyncstart = mode->vsync_start - 1; + vdispend = mode->vdisplay - 1; + vsyncstr = mode->vsync_start - 1; vsyncend = mode->vsync_end - 1; vtotal = mode->vtotal - 2; @@ -235,45 +235,45 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod misc &= ~MGAREG_MISC_VSYNCPOL; crtcext1 = (((htotal - 4) & 0x100) >> 8) | - ((hdisplay & 0x100) >> 7) | - ((hsyncstart & 0x100) >> 6) | - (htotal & 0x40); + ((hdispend & 0x100) >> 7) | + ((hsyncstr & 0x100) >> 6) | + (htotal & 0x40); if (info->has_vidrst) crtcext1 |= MGAREG_CRTCEXT1_VRSTEN | MGAREG_CRTCEXT1_HRSTEN; crtcext2 = ((vtotal & 0xc00) >> 10) | - ((vdisplay & 0x400) >> 8) | - ((vdisplay & 0xc00) >> 7) | - ((vsyncstart & 0xc00) >> 5) | - ((vdisplay & 0x400) >> 3); + ((vdispend & 0x400) >> 8) | + ((vdispend & 0xc00) >> 7) | + ((vsyncstr & 0xc00) >> 5) | + ((vdispend & 0x400) >> 3); crtcext5 = 0x00; WREG_CRT(0x00, htotal - 4); - WREG_CRT(0x01, hdisplay); - WREG_CRT(0x02, hdisplay); + WREG_CRT(0x01, hdispend); + WREG_CRT(0x02, hdispend); WREG_CRT(0x03, (htotal & 0x1f) | 0x80); - WREG_CRT(0x04, hsyncstart); + WREG_CRT(0x04, hsyncstr); WREG_CRT(0x05, ((htotal & 0x20) << 2) | (hsyncend & 0x1f)); WREG_CRT(0x06, vtotal & 0xff); WREG_CRT(0x07, ((vtotal & 0x100) >> 8) | - ((vdisplay & 0x100) >> 7) | - ((vsyncstart & 0x100) >> 6) | - ((vdisplay & 0x100) >> 5) | - ((vdisplay & 0x100) >> 4) | /* linecomp */ + ((vdispend & 0x100) >> 7) | + ((vsyncstr & 0x100) >> 6) | + ((vdispend & 0x100) >> 5) | + ((vdispend & 0x100) >> 4) | /* linecomp */ ((vtotal & 0x200) >> 4) | - ((vdisplay & 0x200) >> 3) | - ((vsyncstart & 0x200) >> 2)); - WREG_CRT(0x09, ((vdisplay & 0x200) >> 4) | - ((vdisplay & 0x200) >> 3)); - WREG_CRT(0x10, vsyncstart & 0xff); + ((vdispend & 0x200) >> 3) | + ((vsyncstr & 0x200) >> 2)); + WREG_CRT(0x09, ((vdispend & 0x200) >> 4) | + ((vdispend & 0x200) >> 3)); + WREG_CRT(0x10, vsyncstr & 0xff); WREG_CRT(0x11, (vsyncend & 0x0f) | 0x20); - WREG_CRT(0x12, vdisplay & 0xff); + WREG_CRT(0x12, vdispend & 0xff); WREG_CRT(0x14, 0); - WREG_CRT(0x15, vdisplay & 0xff); + WREG_CRT(0x15, vdispend & 0xff); WREG_CRT(0x16, (vtotal + 1) & 0xff); WREG_CRT(0x17, 0xc3); - WREG_CRT(0x18, vdisplay & 0xff); + WREG_CRT(0x18, vdispend & 0xff); WREG_ECRT(0x01, crtcext1); WREG_ECRT(0x02, crtcext2); From patchwork Fri Jul 5 11:47:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13725018 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 B7C22C3271E for ; Fri, 5 Jul 2024 11:49:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB56410EB86; Fri, 5 Jul 2024 11:49:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="ygPNx4O8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="29Kki0QW"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="ygPNx4O8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="29Kki0QW"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2153310EB83 for ; Fri, 5 Jul 2024 11:49:08 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D7D3F1FD26; Fri, 5 Jul 2024 11:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmCwM/64/MF3/xVu6IpHr7G4q7V2Gp0raKmxGvtYO9Y=; b=ygPNx4O8imY1a0Xs2qxWeWE0F0iHAp8JdnnJK61rKsoN5vFrFRMkFluquMT8O6U6TaMPMh JRqNYpPjxswnt/Ot2k2SuxsLvDY0t8ZCmdNmmTGseHewRtZ4nhbc6y8eU1oFnxNevblwYy EFk+Ra2I32DYDz07NakbD/U6tJiTlUI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmCwM/64/MF3/xVu6IpHr7G4q7V2Gp0raKmxGvtYO9Y=; b=29Kki0QWgx8yPsy9rj1kxNdWoKK9r7ZZ3Ml8Xdwswe9U9pCBMV/tNKQUdw/UQo/tw2e+Th tzGo8Mk5AUgFMaBg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmCwM/64/MF3/xVu6IpHr7G4q7V2Gp0raKmxGvtYO9Y=; b=ygPNx4O8imY1a0Xs2qxWeWE0F0iHAp8JdnnJK61rKsoN5vFrFRMkFluquMT8O6U6TaMPMh JRqNYpPjxswnt/Ot2k2SuxsLvDY0t8ZCmdNmmTGseHewRtZ4nhbc6y8eU1oFnxNevblwYy EFk+Ra2I32DYDz07NakbD/U6tJiTlUI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmCwM/64/MF3/xVu6IpHr7G4q7V2Gp0raKmxGvtYO9Y=; b=29Kki0QWgx8yPsy9rj1kxNdWoKK9r7ZZ3Ml8Xdwswe9U9pCBMV/tNKQUdw/UQo/tw2e+Th tzGo8Mk5AUgFMaBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9252213974; Fri, 5 Jul 2024 11:49:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IHVmIrLdh2bUcQAAD6G6ig (envelope-from ); Fri, 05 Jul 2024 11:49:06 +0000 From: Thomas Zimmermann To: jfalempe@redhat.com, airlied@redhat.com, sam@ravnborg.org, emil.l.velikov@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v4 3/7] drm/mgag200: Use adjusted mode values for CRTCs Date: Fri, 5 Jul 2024 13:47:46 +0200 Message-ID: <20240705114900.572-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705114900.572-1-tzimmermann@suse.de> References: <20240705114900.572-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-1.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ravnborg.org,gmail.com,linux.intel.com,kernel.org,ffwll.ch]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the values with the crtc_ prefix from struct drm_display_mode to program hardware. The DRM core adjusted these values to the requirements of CRTC hardware. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/mgag200_mode.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 09e2a5b80403..ccad5bd5960d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -208,19 +208,19 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod unsigned int vdispend, vsyncstr, vsyncend, vtotal; u8 misc, crtcext1, crtcext2, crtcext5; - hdispend = mode->hdisplay / 8 - 1; - hsyncstr = mode->hsync_start / 8 - 1; - hsyncend = mode->hsync_end / 8 - 1; - htotal = mode->htotal / 8 - 1; + hdispend = mode->crtc_hdisplay / 8 - 1; + hsyncstr = mode->crtc_hsync_start / 8 - 1; + hsyncend = mode->crtc_hsync_end / 8 - 1; + htotal = mode->crtc_htotal / 8 - 1; /* Work around hardware quirk */ if ((htotal & 0x07) == 0x06 || (htotal & 0x07) == 0x04) htotal++; - vdispend = mode->vdisplay - 1; - vsyncstr = mode->vsync_start - 1; - vsyncend = mode->vsync_end - 1; - vtotal = mode->vtotal - 2; + vdispend = mode->crtc_vdisplay - 1; + vsyncstr = mode->crtc_vsync_start - 1; + vsyncend = mode->crtc_vsync_end - 1; + vtotal = mode->crtc_vtotal - 2; misc = RREG8(MGA_MISC_IN); From patchwork Fri Jul 5 11:47:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13725019 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 44EF1C30658 for ; Fri, 5 Jul 2024 11:49:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B638010EB8A; Fri, 5 Jul 2024 11:49:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="bxX9rdwH"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="BP8uQ0Iv"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bxX9rdwH"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="BP8uQ0Iv"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93DC310EB78 for ; Fri, 5 Jul 2024 11:49:08 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2C7F4218ED; Fri, 5 Jul 2024 11:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xK/uBjtNTJUsP4JkfRHacUZH7DR0hL+1RYtao+gELn0=; b=bxX9rdwHWae+q2wzyvVZuN9DJ5rcfqOkhDGYhX214nEH62nq9n9tRE14Ljol0rHH32L499 i4l3m+evluuV0LRDJPKMX/GgP4DbW3iWRzd+MKwPYB6a9n7bO4h8tfHGze0NtPYVlvykDz 2/bfLEwZStZ1ht13IL9LAEzSTmaJkEI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xK/uBjtNTJUsP4JkfRHacUZH7DR0hL+1RYtao+gELn0=; b=BP8uQ0IviUiS/HkQKreqAhS1TAIZ0wrm2bfOkxpSuZH3bPUd4YliPiUCtm8Jaz4GfsmR3j Jt1Tb/teoKONQYCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xK/uBjtNTJUsP4JkfRHacUZH7DR0hL+1RYtao+gELn0=; b=bxX9rdwHWae+q2wzyvVZuN9DJ5rcfqOkhDGYhX214nEH62nq9n9tRE14Ljol0rHH32L499 i4l3m+evluuV0LRDJPKMX/GgP4DbW3iWRzd+MKwPYB6a9n7bO4h8tfHGze0NtPYVlvykDz 2/bfLEwZStZ1ht13IL9LAEzSTmaJkEI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xK/uBjtNTJUsP4JkfRHacUZH7DR0hL+1RYtao+gELn0=; b=BP8uQ0IviUiS/HkQKreqAhS1TAIZ0wrm2bfOkxpSuZH3bPUd4YliPiUCtm8Jaz4GfsmR3j Jt1Tb/teoKONQYCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DE8BE13889; Fri, 5 Jul 2024 11:49:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WDD3NLLdh2bUcQAAD6G6ig (envelope-from ); Fri, 05 Jul 2024 11:49:06 +0000 From: Thomas Zimmermann To: jfalempe@redhat.com, airlied@redhat.com, sam@ravnborg.org, emil.l.velikov@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v4 4/7] drm/mgag200: Add dedicated variables for blanking fields Date: Fri, 5 Jul 2024 13:47:47 +0200 Message-ID: <20240705114900.572-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705114900.572-1-tzimmermann@suse.de> References: <20240705114900.572-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-1.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ravnborg.org,gmail.com,linux.intel.com,kernel.org,ffwll.ch]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Represent fields for horizontal and vertical blanking with , , and . Aligns the code with the Matrox programming manuals. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/mgag200_mode.c | 29 ++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index ccad5bd5960d..1cd28e7bea32 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -204,23 +204,26 @@ void mgag200_init_registers(struct mga_device *mdev) void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode) { const struct mgag200_device_info *info = mdev->info; - unsigned int hdispend, hsyncstr, hsyncend, htotal; - unsigned int vdispend, vsyncstr, vsyncend, vtotal; + unsigned int hdispend, hsyncstr, hsyncend, htotal, hblkstr, hblkend; + unsigned int vdispend, vsyncstr, vsyncend, vtotal, vblkstr, vblkend; u8 misc, crtcext1, crtcext2, crtcext5; hdispend = mode->crtc_hdisplay / 8 - 1; hsyncstr = mode->crtc_hsync_start / 8 - 1; hsyncend = mode->crtc_hsync_end / 8 - 1; htotal = mode->crtc_htotal / 8 - 1; - /* Work around hardware quirk */ if ((htotal & 0x07) == 0x06 || (htotal & 0x07) == 0x04) htotal++; + hblkstr = mode->crtc_hblank_start / 8 - 1; + hblkend = htotal; vdispend = mode->crtc_vdisplay - 1; vsyncstr = mode->crtc_vsync_start - 1; vsyncend = mode->crtc_vsync_end - 1; vtotal = mode->crtc_vtotal - 2; + vblkstr = mode->crtc_vblank_start; + vblkend = vtotal + 1; misc = RREG8(MGA_MISC_IN); @@ -235,43 +238,43 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod misc &= ~MGAREG_MISC_VSYNCPOL; crtcext1 = (((htotal - 4) & 0x100) >> 8) | - ((hdispend & 0x100) >> 7) | + ((hblkstr & 0x100) >> 7) | ((hsyncstr & 0x100) >> 6) | - (htotal & 0x40); + (hblkend & 0x40); if (info->has_vidrst) crtcext1 |= MGAREG_CRTCEXT1_VRSTEN | MGAREG_CRTCEXT1_HRSTEN; crtcext2 = ((vtotal & 0xc00) >> 10) | ((vdispend & 0x400) >> 8) | - ((vdispend & 0xc00) >> 7) | + ((vblkstr & 0xc00) >> 7) | ((vsyncstr & 0xc00) >> 5) | ((vdispend & 0x400) >> 3); crtcext5 = 0x00; WREG_CRT(0x00, htotal - 4); WREG_CRT(0x01, hdispend); - WREG_CRT(0x02, hdispend); - WREG_CRT(0x03, (htotal & 0x1f) | 0x80); + WREG_CRT(0x02, hblkstr); + WREG_CRT(0x03, (hblkend & 0x1f) | 0x80); WREG_CRT(0x04, hsyncstr); - WREG_CRT(0x05, ((htotal & 0x20) << 2) | (hsyncend & 0x1f)); + WREG_CRT(0x05, ((hblkend & 0x20) << 2) | (hsyncend & 0x1f)); WREG_CRT(0x06, vtotal & 0xff); WREG_CRT(0x07, ((vtotal & 0x100) >> 8) | ((vdispend & 0x100) >> 7) | ((vsyncstr & 0x100) >> 6) | - ((vdispend & 0x100) >> 5) | + ((vblkstr & 0x100) >> 5) | ((vdispend & 0x100) >> 4) | /* linecomp */ ((vtotal & 0x200) >> 4) | ((vdispend & 0x200) >> 3) | ((vsyncstr & 0x200) >> 2)); - WREG_CRT(0x09, ((vdispend & 0x200) >> 4) | + WREG_CRT(0x09, ((vblkstr & 0x200) >> 4) | ((vdispend & 0x200) >> 3)); WREG_CRT(0x10, vsyncstr & 0xff); WREG_CRT(0x11, (vsyncend & 0x0f) | 0x20); WREG_CRT(0x12, vdispend & 0xff); WREG_CRT(0x14, 0); - WREG_CRT(0x15, vdispend & 0xff); - WREG_CRT(0x16, (vtotal + 1) & 0xff); + WREG_CRT(0x15, vblkstr & 0xff); + WREG_CRT(0x16, vblkend & 0xff); WREG_CRT(0x17, 0xc3); WREG_CRT(0x18, vdispend & 0xff); From patchwork Fri Jul 5 11:47:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13725021 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4608CC3271E for ; Fri, 5 Jul 2024 11:49:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B368F10EB88; Fri, 5 Jul 2024 11:49:12 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="uOcqXlGM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="AgXixSWG"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="uOcqXlGM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="AgXixSWG"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id F12BB10EB78 for ; Fri, 5 Jul 2024 11:49:08 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7864921941; Fri, 5 Jul 2024 11:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r52ymmrVx0WW8o1VMB+cpxjKuEtskGVIdVqZKNrp1Zg=; b=uOcqXlGMrhjNHdG+WgchuMjqrfVkGVJN26GUkA2ESg0SaR95MQzcBTje+Ue6zpZsBXcZlv Y6oIHuuKYA6GkcAObXcfc8WFtFDTRvD+rfhd0h9OXz8Y0woznipE6NF8ELBG/gnU9NcZWR 4ZvAFHmulZaRn/3hOjYBZdhlC4i5q/s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r52ymmrVx0WW8o1VMB+cpxjKuEtskGVIdVqZKNrp1Zg=; b=AgXixSWGzHLVhKOk4EliZ5hZ5dv1gBSTMefgveaqnPycVrMuMa5DAXCNUao0p+CnGgI5Lk AJrN3xVh8jw7uMDg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r52ymmrVx0WW8o1VMB+cpxjKuEtskGVIdVqZKNrp1Zg=; b=uOcqXlGMrhjNHdG+WgchuMjqrfVkGVJN26GUkA2ESg0SaR95MQzcBTje+Ue6zpZsBXcZlv Y6oIHuuKYA6GkcAObXcfc8WFtFDTRvD+rfhd0h9OXz8Y0woznipE6NF8ELBG/gnU9NcZWR 4ZvAFHmulZaRn/3hOjYBZdhlC4i5q/s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r52ymmrVx0WW8o1VMB+cpxjKuEtskGVIdVqZKNrp1Zg=; b=AgXixSWGzHLVhKOk4EliZ5hZ5dv1gBSTMefgveaqnPycVrMuMa5DAXCNUao0p+CnGgI5Lk AJrN3xVh8jw7uMDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 34BEB13974; Fri, 5 Jul 2024 11:49:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YEdrC7Pdh2bUcQAAD6G6ig (envelope-from ); Fri, 05 Jul 2024 11:49:07 +0000 From: Thomas Zimmermann To: jfalempe@redhat.com, airlied@redhat.com, sam@ravnborg.org, emil.l.velikov@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v4 5/7] drm/mgag200: Add dedicted variable for field Date: Fri, 5 Jul 2024 13:47:48 +0200 Message-ID: <20240705114900.572-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705114900.572-1-tzimmermann@suse.de> References: <20240705114900.572-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-1.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ravnborg.org,gmail.com,linux.intel.com,kernel.org,ffwll.ch]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Replace the line-compare value of with a dedicated variable . Improves readability and prepares for vblank support. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg --- drivers/gpu/drm/mgag200/mgag200_mode.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 1cd28e7bea32..da2cbe81d4e6 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -206,6 +206,7 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod const struct mgag200_device_info *info = mdev->info; unsigned int hdispend, hsyncstr, hsyncend, htotal, hblkstr, hblkend; unsigned int vdispend, vsyncstr, vsyncend, vtotal, vblkstr, vblkend; + unsigned int linecomp; u8 misc, crtcext1, crtcext2, crtcext5; hdispend = mode->crtc_hdisplay / 8 - 1; @@ -225,6 +226,8 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod vblkstr = mode->crtc_vblank_start; vblkend = vtotal + 1; + linecomp = vdispend; + misc = RREG8(MGA_MISC_IN); if (mode->flags & DRM_MODE_FLAG_NHSYNC) @@ -249,7 +252,7 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod ((vdispend & 0x400) >> 8) | ((vblkstr & 0xc00) >> 7) | ((vsyncstr & 0xc00) >> 5) | - ((vdispend & 0x400) >> 3); + ((linecomp & 0x400) >> 3); crtcext5 = 0x00; WREG_CRT(0x00, htotal - 4); @@ -263,12 +266,12 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod ((vdispend & 0x100) >> 7) | ((vsyncstr & 0x100) >> 6) | ((vblkstr & 0x100) >> 5) | - ((vdispend & 0x100) >> 4) | /* linecomp */ + ((linecomp & 0x100) >> 4) | ((vtotal & 0x200) >> 4) | ((vdispend & 0x200) >> 3) | ((vsyncstr & 0x200) >> 2)); WREG_CRT(0x09, ((vblkstr & 0x200) >> 4) | - ((vdispend & 0x200) >> 3)); + ((linecomp & 0x200) >> 3)); WREG_CRT(0x10, vsyncstr & 0xff); WREG_CRT(0x11, (vsyncend & 0x0f) | 0x20); WREG_CRT(0x12, vdispend & 0xff); @@ -276,7 +279,7 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod WREG_CRT(0x15, vblkstr & 0xff); WREG_CRT(0x16, vblkend & 0xff); WREG_CRT(0x17, 0xc3); - WREG_CRT(0x18, vdispend & 0xff); + WREG_CRT(0x18, linecomp & 0xff); WREG_ECRT(0x01, crtcext1); WREG_ECRT(0x02, crtcext2); From patchwork Fri Jul 5 11:47:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13725023 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 CF9F9C3DA41 for ; Fri, 5 Jul 2024 11:49:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B3BA810EB8E; Fri, 5 Jul 2024 11:49:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="i6pxU6F+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="dOFU3mBQ"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="i6pxU6F+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="dOFU3mBQ"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D0A410EB88 for ; Fri, 5 Jul 2024 11:49:09 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C559E2191A; Fri, 5 Jul 2024 11:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rFqKby0q2YfNfi8ldFgmMtjpGdVLeGRKR1VQ+3JYeOU=; b=i6pxU6F+4bdzzaV8LwzpC5qHupBXTmCLQCDF8BzraAcpUjh6Vznco4I9dM0QKbbr3QAUXO 1iANDoh0M2KRed6I7Txa+QX9R/aCOQnXp1M7rmXWVkJQY2iqCabGCWRDTAB1pPoRR7EvvN JBpMR0b8XDCBvS2owsiJ4GyERbTs1iY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rFqKby0q2YfNfi8ldFgmMtjpGdVLeGRKR1VQ+3JYeOU=; b=dOFU3mBQRGYT+gxbwj+ovgOg9xy8tlrpebChlOUZ6XZMgn09X72uxptQhmuQKYIgYDmmWc kO4/RQMbP/H1GxDw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=i6pxU6F+; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=dOFU3mBQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rFqKby0q2YfNfi8ldFgmMtjpGdVLeGRKR1VQ+3JYeOU=; b=i6pxU6F+4bdzzaV8LwzpC5qHupBXTmCLQCDF8BzraAcpUjh6Vznco4I9dM0QKbbr3QAUXO 1iANDoh0M2KRed6I7Txa+QX9R/aCOQnXp1M7rmXWVkJQY2iqCabGCWRDTAB1pPoRR7EvvN JBpMR0b8XDCBvS2owsiJ4GyERbTs1iY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rFqKby0q2YfNfi8ldFgmMtjpGdVLeGRKR1VQ+3JYeOU=; b=dOFU3mBQRGYT+gxbwj+ovgOg9xy8tlrpebChlOUZ6XZMgn09X72uxptQhmuQKYIgYDmmWc kO4/RQMbP/H1GxDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7FAB413889; Fri, 5 Jul 2024 11:49:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MEn6HbPdh2bUcQAAD6G6ig (envelope-from ); Fri, 05 Jul 2024 11:49:07 +0000 From: Thomas Zimmermann To: jfalempe@redhat.com, airlied@redhat.com, sam@ravnborg.org, emil.l.velikov@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann , Gerd Hoffmann Subject: [PATCH v4 6/7] drm/mgag200: Add vblank support Date: Fri, 5 Jul 2024 13:47:49 +0200 Message-ID: <20240705114900.572-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705114900.572-1-tzimmermann@suse.de> References: <20240705114900.572-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-1.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ravnborg.org,gmail.com,linux.intel.com,kernel.org,ffwll.ch]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[11]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: C559E2191A X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There's no VBLANK interrupt on Matrox chipsets. The workaround that is being used here and in other free Matrox drivers is to program to the value of and enable the VLINE interrupt. This triggers an interrupt at the time when VBLANK begins. VLINE uses separate registers for enabling and clearing pending interrupts. No extra synchronization between irq handler and the rest of the driver is required. v4: - recreate patch on latest upstream - use devm_request_irq() for managed cleanup - fail if vblanking cannot be initialized - rename register constants (Sam, Emil) - clear interrupt before registering handler (Ville) - move programming into separate commit - set to - fix typo in commit message v3: - set to + 1 to trigger at VBLANK - expand comment on linecomp v2: - only signal vblank on CRTC 0 - use constants for registers and fields - set VLINECLR before enabling interrupt - test against STATUS and IEN in irq handler - coding-style fixes Signed-off-by: Thomas Zimmermann Acked-by: Gerd Hoffmann Acked-by: Sam Ravnborg Tested-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/mgag200_drv.c | 47 ++++++++++++++++++++ drivers/gpu/drm/mgag200/mgag200_drv.h | 6 ++- drivers/gpu/drm/mgag200/mgag200_g200.c | 5 +++ drivers/gpu/drm/mgag200/mgag200_g200eh.c | 5 +++ drivers/gpu/drm/mgag200/mgag200_g200eh3.c | 5 +++ drivers/gpu/drm/mgag200/mgag200_g200er.c | 5 +++ drivers/gpu/drm/mgag200/mgag200_g200ev.c | 5 +++ drivers/gpu/drm/mgag200/mgag200_g200ew3.c | 5 +++ drivers/gpu/drm/mgag200/mgag200_g200se.c | 5 +++ drivers/gpu/drm/mgag200/mgag200_g200wb.c | 5 +++ drivers/gpu/drm/mgag200/mgag200_mode.c | 54 ++++++++++++++++++++++- drivers/gpu/drm/mgag200/mgag200_reg.h | 7 +++ 12 files changed, 152 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index 62080cf0f2da..62479de9e659 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -84,6 +85,35 @@ resource_size_t mgag200_probe_vram(void __iomem *mem, resource_size_t size) return offset - 65536; } +static irqreturn_t mgag200_irq_handler(int irq, void *arg) +{ + struct drm_device *dev = arg; + struct mga_device *mdev = to_mga_device(dev); + struct drm_crtc *crtc; + u32 status, ien, iclear; + + status = RREG32(MGAREG_STATUS); + + if (status & MGAREG_STATUS_VLINEPEN) { + ien = RREG32(MGAREG_IEN); + if (!(ien & MGAREG_IEN_VLINEIEN)) + goto out; + + crtc = drm_crtc_from_index(dev, 0); + if (WARN_ON_ONCE(!crtc)) + goto out; + drm_crtc_handle_vblank(crtc); + + iclear = RREG32(MGAREG_ICLEAR); + iclear |= MGAREG_ICLEAR_VLINEICLR; + WREG32(MGAREG_ICLEAR, iclear); + return IRQ_HANDLED; + } + +out: + return IRQ_NONE; +} + /* * DRM driver */ @@ -167,7 +197,9 @@ int mgag200_device_init(struct mga_device *mdev, const struct mgag200_device_funcs *funcs) { struct drm_device *dev = &mdev->base; + struct pci_dev *pdev = to_pci_dev(dev->dev); u8 crtcext3, misc; + u32 ien, iclear; int ret; mdev->info = info; @@ -192,6 +224,21 @@ int mgag200_device_init(struct mga_device *mdev, mutex_unlock(&mdev->rmmio_lock); + ien = RREG32(MGAREG_IEN); + ien &= ~(MGAREG_IEN_VLINEIEN); + WREG32(MGAREG_IEN, ien); + + iclear = RREG32(MGAREG_ICLEAR); + iclear |= MGAREG_ICLEAR_VLINEICLR; + WREG32(MGAREG_ICLEAR, iclear); + + ret = devm_request_irq(&pdev->dev, pdev->irq, mgag200_irq_handler, IRQF_SHARED, + dev->driver->name, dev); + if (ret) { + drm_err(dev, "Failed to acquire interrupt, error %d\n", ret); + return ret; + } + return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 7f7dfbd0f013..f7b22b195016 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -421,6 +421,8 @@ void mgag200_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_atomic void mgag200_crtc_reset(struct drm_crtc *crtc); struct drm_crtc_state *mgag200_crtc_atomic_duplicate_state(struct drm_crtc *crtc); void mgag200_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *crtc_state); +int mgag200_crtc_enable_vblank(struct drm_crtc *crtc); +void mgag200_crtc_disable_vblank(struct drm_crtc *crtc); #define MGAG200_CRTC_FUNCS \ .reset = mgag200_crtc_reset, \ @@ -428,7 +430,9 @@ void mgag200_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_st .set_config = drm_atomic_helper_set_config, \ .page_flip = drm_atomic_helper_page_flip, \ .atomic_duplicate_state = mgag200_crtc_atomic_duplicate_state, \ - .atomic_destroy_state = mgag200_crtc_atomic_destroy_state + .atomic_destroy_state = mgag200_crtc_atomic_destroy_state, \ + .enable_vblank = mgag200_crtc_enable_vblank, \ + .disable_vblank = mgag200_crtc_disable_vblank void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode); void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_info *format); diff --git a/drivers/gpu/drm/mgag200/mgag200_g200.c b/drivers/gpu/drm/mgag200/mgag200_g200.c index f874e2949840..77ce8d36cef0 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -403,5 +404,9 @@ struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct drm_mode_config_reset(dev); drm_kms_helper_poll_init(dev); + ret = drm_vblank_init(dev, 1); + if (ret) + return ERR_PTR(ret); + return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh.c b/drivers/gpu/drm/mgag200/mgag200_g200eh.c index 52bf49ead5c5..72bd8e3421c2 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200eh.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200eh.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -279,5 +280,9 @@ struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const stru drm_mode_config_reset(dev); drm_kms_helper_poll_init(dev); + ret = drm_vblank_init(dev, 1); + if (ret) + return ERR_PTR(ret); + return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c index e7f89b2a59fd..1bbb0745b84a 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -184,5 +185,9 @@ struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev, drm_mode_config_reset(dev); drm_kms_helper_poll_init(dev); + ret = drm_vblank_init(dev, 1); + if (ret) + return ERR_PTR(ret); + return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200er.c b/drivers/gpu/drm/mgag200/mgag200_g200er.c index 4e8a1756138d..3350baf08a45 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200er.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200er.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -318,5 +319,9 @@ struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const stru drm_mode_config_reset(dev); drm_kms_helper_poll_init(dev); + ret = drm_vblank_init(dev, 1); + if (ret) + return ERR_PTR(ret); + return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ev.c b/drivers/gpu/drm/mgag200/mgag200_g200ev.c index d884f3cb0ec7..88d8bcd6fe51 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200ev.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200ev.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -323,5 +324,9 @@ struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const stru drm_mode_config_reset(dev); drm_kms_helper_poll_init(dev); + ret = drm_vblank_init(dev, 1); + if (ret) + return ERR_PTR(ret); + return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c index 839401e8b465..9d08180f7612 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -204,5 +205,9 @@ struct mga_device *mgag200_g200ew3_device_create(struct pci_dev *pdev, drm_mode_config_reset(dev); drm_kms_helper_poll_init(dev); + ret = drm_vblank_init(dev, 1); + if (ret) + return ERR_PTR(ret); + return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c index a824bb8ad579..fcc8075627ef 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200se.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -523,5 +524,9 @@ struct mga_device *mgag200_g200se_device_create(struct pci_dev *pdev, const stru drm_mode_config_reset(dev); drm_kms_helper_poll_init(dev); + ret = drm_vblank_init(dev, 1); + if (ret) + return ERR_PTR(ret); + return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200wb.c b/drivers/gpu/drm/mgag200/mgag200_g200wb.c index 835df0f4fc13..4f8ef3465b9f 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200wb.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200wb.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -328,5 +329,9 @@ struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const stru drm_mode_config_reset(dev); drm_kms_helper_poll_init(dev); + ret = drm_vblank_init(dev, 1); + if (ret) + return ERR_PTR(ret); + return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index da2cbe81d4e6..ec6fb1277d6e 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "mgag200_ddc.h" #include "mgag200_drv.h" @@ -226,7 +227,14 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod vblkstr = mode->crtc_vblank_start; vblkend = vtotal + 1; - linecomp = vdispend; + /* + * There's no VBLANK interrupt on Matrox chipsets, so we use + * the VLINE interrupt instead. It triggers when the current + * has been reached. For VBLANK, this is the first + * non-visible line at the bottom of the screen. Therefore, + * keep in sync with . + */ + linecomp = vblkstr; misc = RREG8(MGA_MISC_IN); @@ -637,6 +645,8 @@ void mgag200_crtc_helper_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_s struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state); struct drm_device *dev = crtc->dev; struct mga_device *mdev = to_mga_device(dev); + struct drm_pending_vblank_event *event; + unsigned long flags; if (crtc_state->enable && crtc_state->color_mgmt_changed) { const struct drm_format_info *format = mgag200_crtc_state->format; @@ -646,6 +656,18 @@ void mgag200_crtc_helper_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_s else mgag200_crtc_set_gamma_linear(mdev, format); } + + event = crtc->state->event; + if (event) { + crtc->state->event = NULL; + + spin_lock_irqsave(&dev->event_lock, flags); + if (drm_crtc_vblank_get(crtc) != 0) + drm_crtc_send_vblank_event(crtc, event); + else + drm_crtc_arm_vblank_event(crtc, event); + spin_unlock_irqrestore(&dev->event_lock, flags); + } } void mgag200_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_state *old_state) @@ -676,6 +698,8 @@ void mgag200_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_ if (funcs->enable_vidrst) funcs->enable_vidrst(mdev); + + drm_crtc_vblank_on(crtc); } void mgag200_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_atomic_state *old_state) @@ -683,6 +707,8 @@ void mgag200_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_atomic struct mga_device *mdev = to_mga_device(crtc->dev); const struct mgag200_device_funcs *funcs = mdev->funcs; + drm_crtc_vblank_off(crtc); + if (funcs->disable_vidrst) funcs->disable_vidrst(mdev); @@ -735,6 +761,32 @@ void mgag200_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_st kfree(mgag200_crtc_state); } +int mgag200_crtc_enable_vblank(struct drm_crtc *crtc) +{ + struct mga_device *mdev = to_mga_device(crtc->dev); + u32 iclear, ien; + + iclear = RREG32(MGAREG_ICLEAR); + iclear |= MGAREG_ICLEAR_VLINEICLR; + WREG32(MGAREG_ICLEAR, iclear); + + ien = RREG32(MGAREG_IEN); + ien |= MGAREG_IEN_VLINEIEN; + WREG32(MGAREG_IEN, ien); + + return 0; +} + +void mgag200_crtc_disable_vblank(struct drm_crtc *crtc) +{ + struct mga_device *mdev = to_mga_device(crtc->dev); + u32 ien; + + ien = RREG32(MGAREG_IEN); + ien &= ~(MGAREG_IEN_VLINEIEN); + WREG32(MGAREG_IEN, ien); +} + /* * Mode config */ diff --git a/drivers/gpu/drm/mgag200/mgag200_reg.h b/drivers/gpu/drm/mgag200/mgag200_reg.h index aa73463674e4..d4fef8f25871 100644 --- a/drivers/gpu/drm/mgag200/mgag200_reg.h +++ b/drivers/gpu/drm/mgag200/mgag200_reg.h @@ -102,10 +102,17 @@ #define MGAREG_EXEC 0x0100 #define MGAREG_FIFOSTATUS 0x1e10 + #define MGAREG_STATUS 0x1e14 +#define MGAREG_STATUS_VLINEPEN BIT(5) + #define MGAREG_CACHEFLUSH 0x1fff + #define MGAREG_ICLEAR 0x1e18 +#define MGAREG_ICLEAR_VLINEICLR BIT(5) + #define MGAREG_IEN 0x1e1c +#define MGAREG_IEN_VLINEIEN BIT(5) #define MGAREG_VCOUNT 0x1e20 From patchwork Fri Jul 5 11:47:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13725022 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 202C5C30658 for ; Fri, 5 Jul 2024 11:49:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A952410EB8D; Fri, 5 Jul 2024 11:49:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="kEBS5oz0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="E6ypd51Q"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kEBS5oz0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="E6ypd51Q"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B15010EB78 for ; Fri, 5 Jul 2024 11:49:09 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1793921967; Fri, 5 Jul 2024 11:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5EUM3utw+hLLeabBiVBLexld4h7DI2LoWbycfuV8TdA=; b=kEBS5oz00dfe7d0VlXVZKMjtW4IhZeb3y41FUZ7z8LfxnQI7bZYIl5N+Yl4ayGlid+V/ax Hh2IHCQbxw5yc7dOJoxU/oBKvhmBRxD2jSehxr+Yzu0qaO4tsH7oGwSC1SJtxAfScegghe 19JggWE6Iz6+kt25q+PLxsMS/tNRlEI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5EUM3utw+hLLeabBiVBLexld4h7DI2LoWbycfuV8TdA=; b=E6ypd51Qs2STuH9hEwaBxXyu7xlx8011rt54NEefm5sagbAbpzJbyqJsuMbyERFM32bvjF xmvALOrsGOXH1MDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1720180148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5EUM3utw+hLLeabBiVBLexld4h7DI2LoWbycfuV8TdA=; b=kEBS5oz00dfe7d0VlXVZKMjtW4IhZeb3y41FUZ7z8LfxnQI7bZYIl5N+Yl4ayGlid+V/ax Hh2IHCQbxw5yc7dOJoxU/oBKvhmBRxD2jSehxr+Yzu0qaO4tsH7oGwSC1SJtxAfScegghe 19JggWE6Iz6+kt25q+PLxsMS/tNRlEI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1720180148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5EUM3utw+hLLeabBiVBLexld4h7DI2LoWbycfuV8TdA=; b=E6ypd51Qs2STuH9hEwaBxXyu7xlx8011rt54NEefm5sagbAbpzJbyqJsuMbyERFM32bvjF xmvALOrsGOXH1MDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CB4D213974; Fri, 5 Jul 2024 11:49:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KOZ1MLPdh2bUcQAAD6G6ig (envelope-from ); Fri, 05 Jul 2024 11:49:07 +0000 From: Thomas Zimmermann To: jfalempe@redhat.com, airlied@redhat.com, sam@ravnborg.org, emil.l.velikov@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v4 7/7] drm/mgag200: Implement struct drm_crtc_funcs.get_vblank_timestamp Date: Fri, 5 Jul 2024 13:47:50 +0200 Message-ID: <20240705114900.572-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705114900.572-1-tzimmermann@suse.de> References: <20240705114900.572-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-1.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ravnborg.org,gmail.com,linux.intel.com,kernel.org,ffwll.ch]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Implement struct drm_crtc_funcs.get_vblank_timestamp with the DRM helper drm_crtc_vblank_helper_get_vblank_timestamp() with its helper get_scanout_position. Read the scanout position from the MGAREG_VCOUNT register. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/mgag200_drv.h | 10 ++++++++-- drivers/gpu/drm/mgag200/mgag200_mode.c | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index f7b22b195016..acfa05335b09 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -410,13 +410,18 @@ int mgag200_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_st void mgag200_crtc_helper_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *old_state); void mgag200_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_state *old_state); void mgag200_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_atomic_state *old_state); +bool mgag200_crtc_helper_get_scanout_position(struct drm_crtc *crtc, bool in_vblank_irq, + int *vpos, int *hpos, + ktime_t *stime, ktime_t *etime, + const struct drm_display_mode *mode); #define MGAG200_CRTC_HELPER_FUNCS \ .mode_valid = mgag200_crtc_helper_mode_valid, \ .atomic_check = mgag200_crtc_helper_atomic_check, \ .atomic_flush = mgag200_crtc_helper_atomic_flush, \ .atomic_enable = mgag200_crtc_helper_atomic_enable, \ - .atomic_disable = mgag200_crtc_helper_atomic_disable + .atomic_disable = mgag200_crtc_helper_atomic_disable, \ + .get_scanout_position = mgag200_crtc_helper_get_scanout_position void mgag200_crtc_reset(struct drm_crtc *crtc); struct drm_crtc_state *mgag200_crtc_atomic_duplicate_state(struct drm_crtc *crtc); @@ -432,7 +437,8 @@ void mgag200_crtc_disable_vblank(struct drm_crtc *crtc); .atomic_duplicate_state = mgag200_crtc_atomic_duplicate_state, \ .atomic_destroy_state = mgag200_crtc_atomic_destroy_state, \ .enable_vblank = mgag200_crtc_enable_vblank, \ - .disable_vblank = mgag200_crtc_disable_vblank + .disable_vblank = mgag200_crtc_disable_vblank, \ + .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode); void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_info *format); diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index ec6fb1277d6e..fb03422c763b 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -718,6 +718,31 @@ void mgag200_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_atomic funcs->enable_vidrst(mdev); } +bool mgag200_crtc_helper_get_scanout_position(struct drm_crtc *crtc, bool in_vblank_irq, + int *vpos, int *hpos, + ktime_t *stime, ktime_t *etime, + const struct drm_display_mode *mode) +{ + struct mga_device *mdev = to_mga_device(crtc->dev); + u32 vcount; + + if (stime) + *stime = ktime_get(); + + if (vpos) { + vcount = RREG32(MGAREG_VCOUNT); + *vpos = vcount & GENMASK(11, 0); + } + + if (hpos) + *hpos = mode->htotal >> 1; // near middle of scanline on average + + if (etime) + *etime = ktime_get(); + + return true; +} + void mgag200_crtc_reset(struct drm_crtc *crtc) { struct mgag200_crtc_state *mgag200_crtc_state;