From nobody Thu Oct 2 20:29:39 2025 Received: from mail-m1973197.qiye.163.com (mail-m1973197.qiye.163.com [220.197.31.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAA252E9EA1; Tue, 30 Sep 2025 09:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759223680; cv=none; b=TtT75thXRVUYL0yOIf35yZt3qD00fbE7n2kNtjcMhpAwpRrlgLPCPq2dnpZ4/gdSWujqbrDaFDTNKhHFl01djX3mDBt9zf4CXhqFoixvIRqz+TSZeECUaEOka3MP2rDta0GdvolW4TyfNHdXsDHpjO8pFePkC66jsXi7rTLQsmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759223680; c=relaxed/simple; bh=sPTlUhToY43C8ioFvZtb2Cs7YWuS8oSV2iovoKCxIuQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BATROZ5lTSJyYCq4xEbcVyz9QszULMgh5ZPEyag20FP6UwBcfC+FvI1biXfuIpj554FiLa0MdRD0PljdJ5rx8+EqSuKvQJ1mD4ETmgZqFpfG5zEi4AJdWqPjWgoP0ugg3Hl0xHqLkiIqB5YlfqLMgN2rYA6Hh4Gb7zzORegZoEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com; spf=pass smtp.mailfrom=rock-chips.com; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b=FWo8HMBf; arc=none smtp.client-ip=220.197.31.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b="FWo8HMBf" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 2493eb15f; Tue, 30 Sep 2025 17:14:27 +0800 (GMT+08:00) From: Damon Ding To: andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org Cc: Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, inki.dae@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, krzk@kernel.org, alim.akhtar@samsung.com, jingoohan1@gmail.com, p.zabel@pengutronix.de, hjc@rock-chips.com, heiko@sntech.de, andy.yan@rock-chips.com, dmitry.baryshkov@oss.qualcomm.com, dianders@chromium.org, m.szyprowski@samsung.com, luca.ceresoli@bootlin.com, jani.nikula@intel.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Damon Ding Subject: [PATCH v6 02/18] drm/bridge: analogix_dp: Move &drm_bridge_funcs.mode_set to &drm_bridge_funcs.atomic_enable Date: Tue, 30 Sep 2025 17:09:04 +0800 Message-Id: <20250930090920.131094-3-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250930090920.131094-1-damon.ding@rock-chips.com> References: <20250930090920.131094-1-damon.ding@rock-chips.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9999e6da8c03a3kunmd96de74a43bb5b X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQksdTVYeGEsdSBgeSEJLGUhWFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSEpKQk 1VSktLVUpCWQY+ DKIM-Signature: a=rsa-sha256; b=FWo8HMBfJfvqrIOYme7vHYHKoZFZSTLLjlfQ12vvflhrUom4Zi6wc0ZJk5NDPPtnU2xgfDZBqcjMai/kt4DJcAZ0bavdYpdxnHCLs+Fayq328aIW1JDSHc33fBUBe47QgoWC4iPen8HRdfRggzz94YQoHC7jC3OHxhsfCgzzaIs=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=LlUShgn0mdqY8jITI4+MoPclw1sVWOT2oJyVPP3wd5g=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" According to the include/drm/drm_bridge.h, the callback &drm_bridge_funcs.mode_set is deprecated and it should be better to include the mode setting in the &drm_bridge_funcs.atomic_enable instead. Signed-off-by: Damon Ding Reviewed-by: Dmitry Baryshkov Tested-by: Marek Szyprowski --- .../drm/bridge/analogix/analogix_dp_core.c | 161 +++++++++--------- 1 file changed, 82 insertions(+), 79 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/g= pu/drm/bridge/analogix/analogix_dp_core.c index 1e834d3656c1..3caa47d31649 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -1086,12 +1086,88 @@ static int analogix_dp_set_bridge(struct analogix_d= p_device *dp) return ret; } =20 +static void analogix_dp_bridge_mode_set(struct drm_bridge *bridge, + const struct drm_display_mode *mode) +{ + struct analogix_dp_device *dp =3D to_dp(bridge); + struct drm_display_info *display_info =3D &dp->connector.display_info; + struct video_info *video =3D &dp->video_info; + struct device_node *dp_node =3D dp->dev->of_node; + int vic; + + /* Input video interlaces & hsync pol & vsync pol */ + video->interlaced =3D !!(mode->flags & DRM_MODE_FLAG_INTERLACE); + video->v_sync_polarity =3D !!(mode->flags & DRM_MODE_FLAG_NVSYNC); + video->h_sync_polarity =3D !!(mode->flags & DRM_MODE_FLAG_NHSYNC); + + /* Input video dynamic_range & colorimetry */ + vic =3D drm_match_cea_mode(mode); + if ((vic =3D=3D 6) || (vic =3D=3D 7) || (vic =3D=3D 21) || (vic =3D=3D 22= ) || + (vic =3D=3D 2) || (vic =3D=3D 3) || (vic =3D=3D 17) || (vic =3D=3D 18= )) { + video->dynamic_range =3D CEA; + video->ycbcr_coeff =3D COLOR_YCBCR601; + } else if (vic) { + video->dynamic_range =3D CEA; + video->ycbcr_coeff =3D COLOR_YCBCR709; + } else { + video->dynamic_range =3D VESA; + video->ycbcr_coeff =3D COLOR_YCBCR709; + } + + /* Input vide bpc and color_formats */ + switch (display_info->bpc) { + case 12: + video->color_depth =3D COLOR_12; + break; + case 10: + video->color_depth =3D COLOR_10; + break; + case 8: + video->color_depth =3D COLOR_8; + break; + case 6: + video->color_depth =3D COLOR_6; + break; + default: + video->color_depth =3D COLOR_8; + break; + } + if (display_info->color_formats & DRM_COLOR_FORMAT_YCBCR444) + video->color_space =3D COLOR_YCBCR444; + else if (display_info->color_formats & DRM_COLOR_FORMAT_YCBCR422) + video->color_space =3D COLOR_YCBCR422; + else + video->color_space =3D COLOR_RGB; + + /* + * NOTE: those property parsing code is used for providing backward + * compatibility for samsung platform. + * Due to we used the "of_property_read_u32" interfaces, when this + * property isn't present, the "video_info" can keep the original + * values and wouldn't be modified. + */ + of_property_read_u32(dp_node, "samsung,color-space", + &video->color_space); + of_property_read_u32(dp_node, "samsung,dynamic-range", + &video->dynamic_range); + of_property_read_u32(dp_node, "samsung,ycbcr-coeff", + &video->ycbcr_coeff); + of_property_read_u32(dp_node, "samsung,color-depth", + &video->color_depth); + if (of_property_read_bool(dp_node, "hsync-active-high")) + video->h_sync_polarity =3D true; + if (of_property_read_bool(dp_node, "vsync-active-high")) + video->v_sync_polarity =3D true; + if (of_property_read_bool(dp_node, "interlaced")) + video->interlaced =3D true; +} + static void analogix_dp_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_atomic_state *old_state) { struct analogix_dp_device *dp =3D to_dp(bridge); struct drm_crtc *crtc; - struct drm_crtc_state *old_crtc_state; + struct drm_crtc_state *old_crtc_state, *new_crtc_state; int timeout_loop =3D 0; int ret; =20 @@ -1099,6 +1175,11 @@ static void analogix_dp_bridge_atomic_enable(struct = drm_bridge *bridge, if (!crtc) return; =20 + new_crtc_state =3D drm_atomic_get_new_crtc_state(old_state, crtc); + if (!new_crtc_state) + return; + analogix_dp_bridge_mode_set(bridge, &new_crtc_state->adjusted_mode); + old_crtc_state =3D drm_atomic_get_old_crtc_state(old_state, crtc); /* Not a full enable, just disable PSR and continue */ if (old_crtc_state && old_crtc_state->self_refresh_active) { @@ -1205,83 +1286,6 @@ static void analogix_dp_bridge_atomic_post_disable(s= truct drm_bridge *bridge, DRM_ERROR("Failed to enable psr (%d)\n", ret); } =20 -static void analogix_dp_bridge_mode_set(struct drm_bridge *bridge, - const struct drm_display_mode *orig_mode, - const struct drm_display_mode *mode) -{ - struct analogix_dp_device *dp =3D to_dp(bridge); - struct drm_display_info *display_info =3D &dp->connector.display_info; - struct video_info *video =3D &dp->video_info; - struct device_node *dp_node =3D dp->dev->of_node; - int vic; - - /* Input video interlaces & hsync pol & vsync pol */ - video->interlaced =3D !!(mode->flags & DRM_MODE_FLAG_INTERLACE); - video->v_sync_polarity =3D !!(mode->flags & DRM_MODE_FLAG_NVSYNC); - video->h_sync_polarity =3D !!(mode->flags & DRM_MODE_FLAG_NHSYNC); - - /* Input video dynamic_range & colorimetry */ - vic =3D drm_match_cea_mode(mode); - if ((vic =3D=3D 6) || (vic =3D=3D 7) || (vic =3D=3D 21) || (vic =3D=3D 22= ) || - (vic =3D=3D 2) || (vic =3D=3D 3) || (vic =3D=3D 17) || (vic =3D=3D 18= )) { - video->dynamic_range =3D CEA; - video->ycbcr_coeff =3D COLOR_YCBCR601; - } else if (vic) { - video->dynamic_range =3D CEA; - video->ycbcr_coeff =3D COLOR_YCBCR709; - } else { - video->dynamic_range =3D VESA; - video->ycbcr_coeff =3D COLOR_YCBCR709; - } - - /* Input vide bpc and color_formats */ - switch (display_info->bpc) { - case 12: - video->color_depth =3D COLOR_12; - break; - case 10: - video->color_depth =3D COLOR_10; - break; - case 8: - video->color_depth =3D COLOR_8; - break; - case 6: - video->color_depth =3D COLOR_6; - break; - default: - video->color_depth =3D COLOR_8; - break; - } - if (display_info->color_formats & DRM_COLOR_FORMAT_YCBCR444) - video->color_space =3D COLOR_YCBCR444; - else if (display_info->color_formats & DRM_COLOR_FORMAT_YCBCR422) - video->color_space =3D COLOR_YCBCR422; - else - video->color_space =3D COLOR_RGB; - - /* - * NOTE: those property parsing code is used for providing backward - * compatibility for samsung platform. - * Due to we used the "of_property_read_u32" interfaces, when this - * property isn't present, the "video_info" can keep the original - * values and wouldn't be modified. - */ - of_property_read_u32(dp_node, "samsung,color-space", - &video->color_space); - of_property_read_u32(dp_node, "samsung,dynamic-range", - &video->dynamic_range); - of_property_read_u32(dp_node, "samsung,ycbcr-coeff", - &video->ycbcr_coeff); - of_property_read_u32(dp_node, "samsung,color-depth", - &video->color_depth); - if (of_property_read_bool(dp_node, "hsync-active-high")) - video->h_sync_polarity =3D true; - if (of_property_read_bool(dp_node, "vsync-active-high")) - video->v_sync_polarity =3D true; - if (of_property_read_bool(dp_node, "interlaced")) - video->interlaced =3D true; -} - static const struct drm_bridge_funcs analogix_dp_bridge_funcs =3D { .atomic_duplicate_state =3D drm_atomic_helper_bridge_duplicate_state, .atomic_destroy_state =3D drm_atomic_helper_bridge_destroy_state, @@ -1290,7 +1294,6 @@ static const struct drm_bridge_funcs analogix_dp_brid= ge_funcs =3D { .atomic_enable =3D analogix_dp_bridge_atomic_enable, .atomic_disable =3D analogix_dp_bridge_atomic_disable, .atomic_post_disable =3D analogix_dp_bridge_atomic_post_disable, - .mode_set =3D analogix_dp_bridge_mode_set, .attach =3D analogix_dp_bridge_attach, }; =20 --=20 2.34.1