From patchwork Wed Sep 20 14:35:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 142449 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4196958vqi; Wed, 20 Sep 2023 07:51:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLCQ9zfInZ4XSlBEUYYUqKz6+xyLy/Lq1P8zxpMZZOdtjOdTyO9GjzyzjMgcEld6Gi7EDD X-Received: by 2002:a05:6e02:156a:b0:346:6d97:ffd1 with SMTP id k10-20020a056e02156a00b003466d97ffd1mr3781092ilu.18.1695221482876; Wed, 20 Sep 2023 07:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695221482; cv=none; d=google.com; s=arc-20160816; b=UyopcY4voCoppFIYNncdwtySmIyfaQD9tOGpIqnCWXLDc81+5nVbC2McE8KwsT8RbT JqjHKf4zJdGCL2fqSUk57ccKr+GrKiu/AheiHnntQkR8k/8Lw8vIYNqCTxB+PSPfHIAu pThL7ypoGedKvKIDBjRpDZMPOcea4mu5Y6qnnZSQxFzx7ebdZP6hgB5GKb1a5MHcPQTO OTNRHVBq2mlPKKnquZWnm0/b8xwgbL30S0l0Dn0d8/JRFT2TJfxd/kbKXpqrU4Z8oKkB NqpTb/OTdYd4pEniURLK+b0+Ol9Fx1RPQBIlav4FdpRhikkl3r56BUWLtgU755N3G8fN gbKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=4Yz8UMXUeg00+mRpfAl+QtEijB5hce9WPeNCGhPxCwU=; fh=e6/uyeFf2k7v8JUtB6fPyaAS5iN3eSA1hjtg35V2Rzw=; b=u6V0oWrJYYkbEy28qQ1w67EqjBvuZ2gEHuhtrK4PNb9tVOaiWz+nqZsWknW3eD0KWM BjEUv7bmuQfMw3YMANGUhQsSuWgBQ/bDoqeD2Yys0VmmEBHH0dTjxcscjhowoKRXo6R7 Spgpj+JJmDA7R7ogLaqmpMH9hz7dsr9mKjl2n9x2VDUrxnEeryMPct9/jE420xFS8dVk HOEI0twa2OWiVJH2RBHuOw4/jPm0iBbVrsVIh+cVoptq9JNwC3PmmVxdyc/gNVTRMtrO fmpFeMQW/pxbDbLcCT8bG+PluSzjMiPMzYhGr9IyDPvrIQS8jD37ZhVZARMKZ5flCstG oefA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xp+u+U23; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b00578faac74a4si119063pgb.577.2023.09.20.07.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 07:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xp+u+U23; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E7CB584865A3; Wed, 20 Sep 2023 07:38:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236791AbjITOiS (ORCPT + 27 others); Wed, 20 Sep 2023 10:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236828AbjITOhp (ORCPT ); Wed, 20 Sep 2023 10:37:45 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E3310E5; Wed, 20 Sep 2023 07:37:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 633C8C433B9; Wed, 20 Sep 2023 14:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695220621; bh=a4BpgPVlN4us8i8ZAKm55WYfRM8D4UzuiG9jC3POA78=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Xp+u+U23wcC1j0R0R0CgHMqWOB8I/CjrW/dfgbC4SMrxatx40K6DWlsnu8OtvQilE aAAuSe3M7gsyyQSAO5fMes44xaqdmWtMvVBSsqgq7VSO0Be+PjfRSRtJ0+ABaS5IQ0 2YDjfiChJ0rT0vAyC+NEajKtF3HIYbOmvkqJxonef2P3VEyazchjnpeNr8hVxoEVuE StIL2e5AapeocXN5iNDaiuuAN20S4JJbneRwCt2yc/YBCzI0k6OF2kdJi0SIIx8t2c 55b//lHAtnnO7k4R+V5Cb/uqth3BYpYEKlHv3wmMXjmDH+x3jFO5TR0kcPhQ/BSMe8 Q7ffJapvKs90w== From: Maxime Ripard Date: Wed, 20 Sep 2023 16:35:43 +0200 Subject: [PATCH RFC v2 28/37] drm/rockchip: inno_hdmi: Move infoframe disable to separate function MIME-Version: 1.0 Message-Id: <20230920-kms-hdmi-connector-state-v2-28-17932daddd7d@kernel.org> References: <20230920-kms-hdmi-connector-state-v2-0-17932daddd7d@kernel.org> In-Reply-To: <20230920-kms-hdmi-connector-state-v2-0-17932daddd7d@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=3525; i=mripard@kernel.org; h=from:subject:message-id; bh=a4BpgPVlN4us8i8ZAKm55WYfRM8D4UzuiG9jC3POA78=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKnczFZWXLVuG4wPiyjYmX7fJOn3N7Sh8khyX6/oqpqnW b6GttwdpSwMYlwMsmKKLDHC5kviTs163cnGNw9mDisTyBAGLk4BmEjPAkaGT698WDZ45G/s+/tN eMXXDUndMQ/lDp4XMeHU6/4zd4t7ASPDStN8mwerQsL/2dxJYfly4eGa5jVdcVrL//6zcObN4i9 mBgA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 20 Sep 2023 07:38:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777568561488830958 X-GMAIL-MSGID: 1777568561488830958 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 | 53 +++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c index 59b2b676b7b8..e3a421d98dd4 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -156,33 +156,38 @@ 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, - u32 mask, u32 disable, u32 enable) +static void inno_hdmi_disable_frame(struct inno_hdmi *hdmi, + u32 frame_index, + u32 mask, u32 disable) { if (mask) hdmi_modb(hdmi, HDMI_PACKET_SEND_AUTO, mask, disable); 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, + u32 mask, u32 disable, u32 enable) +{ + 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; + inno_hdmi_disable_frame(hdmi, frame_index, mask, disable); - for (i = 0; i < rc; i++) - hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_ADDR + i, - packed_frame[i]); + rc = hdmi_infoframe_pack(frame, packed_frame, + sizeof(packed_frame)); + if (rc < 0) + return rc; - if (mask) - hdmi_modb(hdmi, HDMI_PACKET_SEND_AUTO, mask, enable); - } + for (i = 0; i < rc; i++) + hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_ADDR + i, + packed_frame[i]); - return setup_rc; + if (mask) + hdmi_modb(hdmi, HDMI_PACKET_SEND_AUTO, mask, enable); + + return 0; } static int inno_hdmi_config_video_vsi(struct inno_hdmi *hdmi, @@ -194,8 +199,13 @@ static int inno_hdmi_config_video_vsi(struct inno_hdmi *hdmi, rc = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi, &hdmi->connector, mode); + if (rc) { + inno_hdmi_disable_frame(hdmi, INFOFRAME_VSI, + m_PACKET_VSI_EN, v_PACKET_VSI_EN(0)); + return rc; + } - return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_VSI, + return inno_hdmi_upload_frame(hdmi, &frame, INFOFRAME_VSI, m_PACKET_VSI_EN, v_PACKET_VSI_EN(0), v_PACKET_VSI_EN(1)); } @@ -208,9 +218,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, 0, 0); + return rc; + } + frame.avi.colorspace = HDMI_COLORSPACE_RGB; - return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); + return inno_hdmi_upload_frame(hdmi, &frame, INFOFRAME_AVI, 0, 0, 0); } static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi)