From patchwork Thu Dec 7 15:49:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 751914 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7E13B3D0D4; Thu, 7 Dec 2023 15:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z8NI03N5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2AB1C4339A; Thu, 7 Dec 2023 15:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701964274; bh=Zhd2GuW7ERvi3M5zNeWUGu355TvNiDeR3lyKgQeqnAM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z8NI03N5JJNDdlkJxJyf1kVDiYnhsK/I/eHqW/YiTFOsokJJYpkKiCBYUtQ91E+Oy X7Olz2YwTqrzEhhWMLm9cfwYg5FMQb6+cPdb1O6m0+c4SVQrS2H5mGuY7wxNLazYK9 MwXYIZ8GZx5tquemx838IH7lI62cUUhFvFygio0QtWbLZsPVWgrP9LV4yIszWoRbVh 6q507gADm+XDo2h+GO0Nrq/z83ywoi2Ap3MQytndIl28DESDxflk+EGjzNy5IJSbgg dN2Lvh6XAiDENIKH5/P/zQ7pzeZsLiv2Sp1lFvnn2CSYBhluRhNNGLDdSoY+3SmpKN uaMZ+cxYTC3hw== From: Maxime Ripard Date: Thu, 07 Dec 2023 16:49:59 +0100 Subject: [PATCH v5 36/44] drm/rockchip: inno_hdmi: Move infoframe disable to separate function Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231207-kms-hdmi-connector-state-v5-36-6538e19d634d@kernel.org> References: <20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org> In-Reply-To: <20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Hans Verkuil , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3018; i=mripard@kernel.org; h=from:subject:message-id; bh=Zhd2GuW7ERvi3M5zNeWUGu355TvNiDeR3lyKgQeqnAM=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmFL9vkpkwSnnni26WDMzdOl0s7wKwULLPr+Mqly3yuP q1d8kztZUcpC4MYF4OsmCJLjLD5krhTs153svHNg5nDygQyhIGLUwAm8juR4a946Jd7nj6T3Bd/ b7/fPrVh2ozUaX3ZwsbWwl98jweE8goyMizaduGYiPLNLz90eQrDP3/ZzbloYX71xB/djDv7Lql oMjEDAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D The code to upload infoframes to the controller uses a weird construct which, based on the previous function call return code, will either disable or enable that infoframe. In order to get rid of that argument, let's split the function to disable the infoframe into a separate function and make it obvious what we are doing in the error path. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/rockchip/inno_hdmi.c | 47 ++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c index 9c64f94ede6f..b68cd3a6a0d1 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -156,34 +156,44 @@ static void inno_hdmi_reset(struct inno_hdmi *hdmi) inno_hdmi_set_pwr_mode(hdmi, NORMAL); } -static int inno_hdmi_upload_frame(struct inno_hdmi *hdmi, int setup_rc, - union hdmi_infoframe *frame, u32 frame_index) +static void inno_hdmi_disable_frame(struct inno_hdmi *hdmi, u32 frame_index) { struct drm_connector *connector = &hdmi->connector; if (frame_index != INFOFRAME_AVI) { drm_err(connector->dev, "Unsupported infoframe type: %u\n", frame_index); - return 0; + return; } hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_BUF_INDEX, frame_index); +} - if (setup_rc >= 0) { - u8 packed_frame[HDMI_MAXIMUM_INFO_FRAME_SIZE]; - ssize_t rc, i; +static int inno_hdmi_upload_frame(struct inno_hdmi *hdmi, + union hdmi_infoframe *frame, u32 frame_index) +{ + struct drm_connector *connector = &hdmi->connector; + u8 packed_frame[HDMI_MAXIMUM_INFO_FRAME_SIZE]; + ssize_t rc, i; - rc = hdmi_infoframe_pack(frame, packed_frame, - sizeof(packed_frame)); - if (rc < 0) - return rc; - - for (i = 0; i < rc; i++) - hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_ADDR + i, - packed_frame[i]); + if (frame_index != INFOFRAME_AVI) { + drm_err(connector->dev, + "Unsupported infoframe type: %u\n", frame_index); + return 0; } - return setup_rc; + inno_hdmi_disable_frame(hdmi, frame_index); + + rc = hdmi_infoframe_pack(frame, packed_frame, + sizeof(packed_frame)); + if (rc < 0) + return rc; + + for (i = 0; i < rc; i++) + hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_ADDR + i, + packed_frame[i]); + + return 0; } static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, @@ -195,9 +205,14 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, rc = drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, &hdmi->connector, mode); + if (rc) { + inno_hdmi_disable_frame(hdmi, INFOFRAME_AVI); + return rc; + } + frame.avi.colorspace = HDMI_COLORSPACE_RGB; - return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI); + return inno_hdmi_upload_frame(hdmi, &frame, INFOFRAME_AVI); } static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi)