From patchwork Tue Feb 4 13:26:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13959235 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 5BDD5C02194 for ; Tue, 4 Feb 2025 13:32:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C7AC10E647; Tue, 4 Feb 2025 13:32:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="ykVEvxJx"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="L6vJH/DT"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="ykVEvxJx"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="L6vJH/DT"; 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 9CCCF10E33D for ; Tue, 4 Feb 2025 13:32:15 +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 6A1C621101; Tue, 4 Feb 2025 13:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738675934; 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=PRvbGDyOv23ynl8nZNiSkJNTuL/AYl/d/vYdF2QpfkM=; b=ykVEvxJxcxdNDoi2qI0oX7WTQjXT6KrFbgEHgn6hRPWFaiXvBx0+rw5Ik4bPZOZ7yc1Hou waSA3Jd4iqd+REAWmkkrtCpTuCNTTb8AAHB/E2a8MHKmNL06v1HBL261J1lvnYFRNL1U+e cV9WcvlEKd1SDqFd7+pFgwJ48CbuWTQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738675934; 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=PRvbGDyOv23ynl8nZNiSkJNTuL/AYl/d/vYdF2QpfkM=; b=L6vJH/DTUDx+MJDVMvcCXuW1gamT2/JpyVVMQOBdTC40y8ik93adhjbrnBiNZ66Jy4ovpu 3K40yAymVoyQOdDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738675934; 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=PRvbGDyOv23ynl8nZNiSkJNTuL/AYl/d/vYdF2QpfkM=; b=ykVEvxJxcxdNDoi2qI0oX7WTQjXT6KrFbgEHgn6hRPWFaiXvBx0+rw5Ik4bPZOZ7yc1Hou waSA3Jd4iqd+REAWmkkrtCpTuCNTTb8AAHB/E2a8MHKmNL06v1HBL261J1lvnYFRNL1U+e cV9WcvlEKd1SDqFd7+pFgwJ48CbuWTQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738675934; 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=PRvbGDyOv23ynl8nZNiSkJNTuL/AYl/d/vYdF2QpfkM=; b=L6vJH/DTUDx+MJDVMvcCXuW1gamT2/JpyVVMQOBdTC40y8ik93adhjbrnBiNZ66Jy4ovpu 3K40yAymVoyQOdDw== 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 3A1FD13A21; Tue, 4 Feb 2025 13:32:14 +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 8P/pDN4WomfsVAAAD6G6ig (envelope-from ); Tue, 04 Feb 2025 13:32:14 +0000 From: Thomas Zimmermann To: airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 1/4] drm/ast: astdp: Add connector state Date: Tue, 4 Feb 2025 14:26:37 +0100 Message-ID: <20250204133209.403327-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250204133209.403327-1-tzimmermann@suse.de> References: <20250204133209.403327-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; 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]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[] 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" Add dedicated connector state for ASTDP connectors. The state will store values for programming the transmitter chip. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/ast/ast_dp.c | 62 ++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index db3eb9ce1498..9c49b507a0d2 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -42,6 +42,16 @@ static const struct ast_astdp_mode_index_table_entry ast_astdp_mode_index_table[ { 0 } }; +struct ast_astdp_connector_state { + struct drm_connector_state base; +}; + +static struct ast_astdp_connector_state * +to_ast_astdp_connector_state(const struct drm_connector_state *state) +{ + return container_of(state, struct ast_astdp_connector_state, base); +} + static int __ast_astdp_get_mode_index(unsigned int hdisplay, unsigned int vdisplay) { const struct ast_astdp_mode_index_table_entry *entry = ast_astdp_mode_index_table; @@ -442,18 +452,58 @@ static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs .detect_ctx = ast_astdp_connector_helper_detect_ctx, }; -/* - * Output - */ +static void ast_astdp_connector_reset(struct drm_connector *connector) +{ + struct ast_astdp_connector_state *astdp_state = + kzalloc(sizeof(*astdp_state), GFP_KERNEL); + + if (connector->state) + connector->funcs->atomic_destroy_state(connector, connector->state); + + if (astdp_state) + __drm_atomic_helper_connector_reset(connector, &astdp_state->base); + else + __drm_atomic_helper_connector_reset(connector, NULL); +} + +static struct drm_connector_state * +ast_astdp_connector_atomic_duplicate_state(struct drm_connector *connector) +{ + struct ast_astdp_connector_state *new_astdp_state; + struct drm_device *dev = connector->dev; + + if (drm_WARN_ON(dev, !connector->state)) + return NULL; + + new_astdp_state = kmalloc(sizeof(*new_astdp_state), GFP_KERNEL); + if (!new_astdp_state) + return NULL; + __drm_atomic_helper_connector_duplicate_state(connector, &new_astdp_state->base); + + return &new_astdp_state->base; +} + +static void ast_astdp_connector_atomic_destroy_state(struct drm_connector *connector, + struct drm_connector_state *state) +{ + struct ast_astdp_connector_state *astdp_state = to_ast_astdp_connector_state(state); + + __drm_atomic_helper_connector_destroy_state(&astdp_state->base); + kfree(astdp_state); +} static const struct drm_connector_funcs ast_astdp_connector_funcs = { - .reset = drm_atomic_helper_connector_reset, + .reset = ast_astdp_connector_reset, .fill_modes = drm_helper_probe_single_connector_modes, .destroy = drm_connector_cleanup, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, + .atomic_duplicate_state = ast_astdp_connector_atomic_duplicate_state, + .atomic_destroy_state = ast_astdp_connector_atomic_destroy_state, }; +/* + * Output + */ + int ast_astdp_output_init(struct ast_device *ast) { struct drm_device *dev = &ast->base; From patchwork Tue Feb 4 13:26:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13959237 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 09D89C02197 for ; Tue, 4 Feb 2025 13:32:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD28910E64E; Tue, 4 Feb 2025 13:32:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="XIQIvyhW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="re45kvCK"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="XIQIvyhW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="re45kvCK"; 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 CB96410E647 for ; Tue, 4 Feb 2025 13:32:15 +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 8B7CD1F365; Tue, 4 Feb 2025 13:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738675934; 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=8FBpjecec7oC3UYjFoiQEw8dLg7UMFe8sR2HToIGuVo=; b=XIQIvyhWhMLdRfX6F7/NoxTWB3eb7zTYuR5UZzUHygf5oOpVXe4vonIVGtUYmSGuKNb0fq QhGQUo3kuH+0o3VZ5bxXQGhv4mr0o+WQ7pFhxUEPGLGVt2mmYxf7tWodIEafLaprGhlRd5 d/8mHDaevTS1n+qMi77ZmsU6/NPA/a4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738675934; 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=8FBpjecec7oC3UYjFoiQEw8dLg7UMFe8sR2HToIGuVo=; b=re45kvCKuGu2Bv3tR1ne9JF1Uq8WUmoKQJ0HQtTugvPptAatEM9mPr5lWkGiwBDBUYmOX3 ZyUOpWKnhW+H0vDQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738675934; 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=8FBpjecec7oC3UYjFoiQEw8dLg7UMFe8sR2HToIGuVo=; b=XIQIvyhWhMLdRfX6F7/NoxTWB3eb7zTYuR5UZzUHygf5oOpVXe4vonIVGtUYmSGuKNb0fq QhGQUo3kuH+0o3VZ5bxXQGhv4mr0o+WQ7pFhxUEPGLGVt2mmYxf7tWodIEafLaprGhlRd5 d/8mHDaevTS1n+qMi77ZmsU6/NPA/a4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738675934; 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=8FBpjecec7oC3UYjFoiQEw8dLg7UMFe8sR2HToIGuVo=; b=re45kvCKuGu2Bv3tR1ne9JF1Uq8WUmoKQJ0HQtTugvPptAatEM9mPr5lWkGiwBDBUYmOX3 ZyUOpWKnhW+H0vDQ== 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 65AB51393E; Tue, 4 Feb 2025 13:32:14 +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 aKudF94WomfsVAAAD6G6ig (envelope-from ); Tue, 04 Feb 2025 13:32:14 +0000 From: Thomas Zimmermann To: airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 2/4] drm/ast: astdp: Inline mode-index calculation Date: Tue, 4 Feb 2025 14:26:38 +0100 Message-ID: <20250204133209.403327-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250204133209.403327-1-tzimmermann@suse.de> References: <20250204133209.403327-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; 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]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[] 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" Programming the astdp transmitter chip requires a magic value for individual modes. Inline the helper for calculating the value into its only caller (i.e., the encoder's atomic_mode_set). With further refactoring, the atomic check will be able to detect invalid modes before attempting to program them. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/ast/ast_dp.c | 52 +++++++++++++++--------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index 9c49b507a0d2..e7b00153c37e 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -52,7 +52,7 @@ to_ast_astdp_connector_state(const struct drm_connector_state *state) return container_of(state, struct ast_astdp_connector_state, base); } -static int __ast_astdp_get_mode_index(unsigned int hdisplay, unsigned int vdisplay) +static int ast_astdp_get_mode_index(unsigned int hdisplay, unsigned int vdisplay) { const struct ast_astdp_mode_index_table_entry *entry = ast_astdp_mode_index_table; @@ -65,35 +65,6 @@ static int __ast_astdp_get_mode_index(unsigned int hdisplay, unsigned int vdispl return -EINVAL; } -static int ast_astdp_get_mode_index(const struct ast_vbios_enhtable *vmode) -{ - int mode_index; - u8 refresh_rate_index; - - mode_index = __ast_astdp_get_mode_index(vmode->hde, vmode->vde); - if (mode_index < 0) - return mode_index; - - if (vmode->refresh_rate_index < 1 || vmode->refresh_rate_index > 255) - return -EINVAL; - refresh_rate_index = vmode->refresh_rate_index - 1; - - /* FIXME: Why are we doing this? */ - switch (mode_index) { - case ASTDP_1280x800_60_RB: - case ASTDP_1440x900_60_RB: - case ASTDP_1600x900_60_RB: - case ASTDP_1680x1050_60_RB: - mode_index = (u8)(mode_index - (u8)refresh_rate_index); - break; - default: - mode_index = (u8)(mode_index + (u8)refresh_rate_index); - break; - } - - return mode_index; -} - static bool ast_astdp_is_connected(struct ast_device *ast) { if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF, AST_IO_VGACRDF_HPD)) @@ -333,13 +304,32 @@ static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoder struct drm_device *dev = encoder->dev; struct ast_device *ast = to_ast_device(dev); struct ast_crtc_state *ast_crtc_state = to_ast_crtc_state(crtc_state); + const struct ast_vbios_enhtable *vmode = ast_crtc_state->vmode; int mode_index; + u8 refresh_rate_index; u8 vgacre0, vgacre1, vgacre2; - mode_index = ast_astdp_get_mode_index(ast_crtc_state->vmode); + mode_index = ast_astdp_get_mode_index(vmode->hde, vmode->vde); if (drm_WARN_ON(dev, mode_index < 0)) return; + if (drm_WARN_ON(dev, vmode->refresh_rate_index < 1 || vmode->refresh_rate_index > 255)) + return; + refresh_rate_index = vmode->refresh_rate_index - 1; + + /* FIXME: Why are we doing this? */ + switch (mode_index) { + case ASTDP_1280x800_60_RB: + case ASTDP_1440x900_60_RB: + case ASTDP_1600x900_60_RB: + case ASTDP_1680x1050_60_RB: + mode_index = (u8)(mode_index - (u8)refresh_rate_index); + break; + default: + mode_index = (u8)(mode_index + (u8)refresh_rate_index); + break; + } + /* * CRE0[7:0]: MISC0 ((0x00: 18-bpp) or (0x20: 24-bpp) * CRE1[7:0]: MISC1 (default: 0x00) From patchwork Tue Feb 4 13:26:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13959234 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 99240C02196 for ; Tue, 4 Feb 2025 13:32:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 179FB10E32F; Tue, 4 Feb 2025 13:32:17 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id DFD3510E32F for ; Tue, 4 Feb 2025 13:32:15 +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 B8EA21F38C; Tue, 4 Feb 2025 13:32:14 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none 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 9362E13A21; Tue, 4 Feb 2025 13:32:14 +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 ODKvIt4WomfsVAAAD6G6ig (envelope-from ); Tue, 04 Feb 2025 13:32:14 +0000 From: Thomas Zimmermann To: airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 3/4] drm/ast: astdp: Store mode index in connector state Date: Tue, 4 Feb 2025 14:26:39 +0100 Message-ID: <20250204133209.403327-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250204133209.403327-1-tzimmermann@suse.de> References: <20250204133209.403327-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: B8EA21F38C X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.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" Look up the mode index for the astdp transmitter ship in the encoder's atomic check and report an error if the display mode is not supported. The lookup uses the DRM display mode instead of the driver's internal VBIOS mode. Both are be equivalent. The modesetting code later reads the calculated index from the connector state to avoid recalculating it. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/ast/ast_dp.c | 37 ++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index e7b00153c37e..056991afde7f 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,8 @@ static const struct ast_astdp_mode_index_table_entry ast_astdp_mode_index_table[ struct ast_astdp_connector_state { struct drm_connector_state base; + + int mode_index; }; static struct ast_astdp_connector_state * @@ -305,14 +308,12 @@ static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoder struct ast_device *ast = to_ast_device(dev); struct ast_crtc_state *ast_crtc_state = to_ast_crtc_state(crtc_state); const struct ast_vbios_enhtable *vmode = ast_crtc_state->vmode; - int mode_index; + struct ast_astdp_connector_state *astdp_conn_state = + to_ast_astdp_connector_state(conn_state); + int mode_index = astdp_conn_state->mode_index; u8 refresh_rate_index; u8 vgacre0, vgacre1, vgacre2; - mode_index = ast_astdp_get_mode_index(vmode->hde, vmode->vde); - if (drm_WARN_ON(dev, mode_index < 0)) - return; - if (drm_WARN_ON(dev, vmode->refresh_rate_index < 1 || vmode->refresh_rate_index > 255)) return; refresh_rate_index = vmode->refresh_rate_index - 1; @@ -368,10 +369,30 @@ static void ast_astdp_encoder_helper_atomic_disable(struct drm_encoder *encoder, ast_dp_set_phy_sleep(ast, true); } +static int ast_astdp_encoder_helper_atomic_check(struct drm_encoder *encoder, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + const struct drm_display_mode *mode = &crtc_state->mode; + struct ast_astdp_connector_state *astdp_conn_state = + to_ast_astdp_connector_state(conn_state); + int res; + + if (drm_atomic_crtc_needs_modeset(crtc_state)) { + res = ast_astdp_get_mode_index(mode->hdisplay, mode->vdisplay); + if (res < 0) + return res; + astdp_conn_state->mode_index = res; + } + + return 0; +} + static const struct drm_encoder_helper_funcs ast_astdp_encoder_helper_funcs = { .atomic_mode_set = ast_astdp_encoder_helper_atomic_mode_set, .atomic_enable = ast_astdp_encoder_helper_atomic_enable, .atomic_disable = ast_astdp_encoder_helper_atomic_disable, + .atomic_check = ast_astdp_encoder_helper_atomic_check, }; /* @@ -459,7 +480,7 @@ static void ast_astdp_connector_reset(struct drm_connector *connector) static struct drm_connector_state * ast_astdp_connector_atomic_duplicate_state(struct drm_connector *connector) { - struct ast_astdp_connector_state *new_astdp_state; + struct ast_astdp_connector_state *new_astdp_state, *astdp_state; struct drm_device *dev = connector->dev; if (drm_WARN_ON(dev, !connector->state)) @@ -470,6 +491,10 @@ ast_astdp_connector_atomic_duplicate_state(struct drm_connector *connector) return NULL; __drm_atomic_helper_connector_duplicate_state(connector, &new_astdp_state->base); + astdp_state = to_ast_astdp_connector_state(connector->state); + + new_astdp_state->mode_index = astdp_state->mode_index; + return &new_astdp_state->base; } From patchwork Tue Feb 4 13:26:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13959236 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 D643BC02196 for ; Tue, 4 Feb 2025 13:32:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E2A4C10E64D; Tue, 4 Feb 2025 13:32:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="P8Pezoy1"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="zmMmO149"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="H1vJUOS1"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="F1nNBX9M"; 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 3512C10E32F for ; Tue, 4 Feb 2025 13:32:16 +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 EF21C21111; Tue, 4 Feb 2025 13:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738675935; 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=Q3zRnawTAZf+7j5LhGzeklVfOHlsg2v3oT06CAXKXVs=; b=P8Pezoy1ef+82dB+nXk1NEBIgQvNa+tmrRyqQ6wvuEWF7WGhm/CHomGMWMHnddi6TTpA5z Tx2mf7y0/fj10uX8wBFXp1a5UCKjhyl49tnN3JO5S6um/Q7sUBtd4FYFJMLc4MHVGB6INz gBsav+z3Xta8h3aN2U/RUjREVIfbKPk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738675935; 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=Q3zRnawTAZf+7j5LhGzeklVfOHlsg2v3oT06CAXKXVs=; b=zmMmO14988vwsIVAG8BqWojvEkysu4COhu/LIB/W3wdvF0tlmlcGcEwDVjjLHwsyyXkxBn BiSG9oVPRFVmM+CQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738675934; 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=Q3zRnawTAZf+7j5LhGzeklVfOHlsg2v3oT06CAXKXVs=; b=H1vJUOS1R2CzfxXAzZMBgxAUt6RoKO7tl+OFaGxRMB9boSfPPlamNWikcFWeHwvPgMvaYT RH58Qnh3HL1YQR7VyJwn2pY15Y57j7k9LUfD1v0Xay5WsNyT28/Ojcv9F+3DJ5zezxswnf 5bi4X4yNXhDsdIQwHtp9W2qI2InELv4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738675934; 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=Q3zRnawTAZf+7j5LhGzeklVfOHlsg2v3oT06CAXKXVs=; b=F1nNBX9MLYvHTtgRuHacdg0hCm5jwdqZvzAUlZ7O7LzxGwdFWi2LUaq/stm13E0K6oGIOA FsAxRb65hvpmjxAg== 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 BEDCB1393E; Tue, 4 Feb 2025 13:32:14 +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 gOthLd4WomfsVAAAD6G6ig (envelope-from ); Tue, 04 Feb 2025 13:32:14 +0000 From: Thomas Zimmermann To: airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 4/4] drm/ast: astdp: Validate display modes Date: Tue, 4 Feb 2025 14:26:40 +0100 Message-ID: <20250204133209.403327-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250204133209.403327-1-tzimmermann@suse.de> References: <20250204133209.403327-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; 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]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[] 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" Validate each display mode against the astdp transmitter chips. Filters out modes that the chip does not support. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/ast/ast_dp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index 056991afde7f..19c04687b0fe 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -300,6 +300,19 @@ static const struct drm_encoder_funcs ast_astdp_encoder_funcs = { .destroy = drm_encoder_cleanup, }; +static enum drm_mode_status +ast_astdp_encoder_helper_mode_valid(struct drm_encoder *encoder, + const struct drm_display_mode *mode) +{ + int res; + + res = ast_astdp_get_mode_index(mode->hdisplay, mode->vdisplay); + if (res < 0) + return MODE_NOMODE; + + return MODE_OK; +} + static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) @@ -389,6 +402,7 @@ static int ast_astdp_encoder_helper_atomic_check(struct drm_encoder *encoder, } static const struct drm_encoder_helper_funcs ast_astdp_encoder_helper_funcs = { + .mode_valid = ast_astdp_encoder_helper_mode_valid, .atomic_mode_set = ast_astdp_encoder_helper_atomic_mode_set, .atomic_enable = ast_astdp_encoder_helper_atomic_enable, .atomic_disable = ast_astdp_encoder_helper_atomic_disable,