From patchwork Tue Oct 31 16:48:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 160269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp375792vqg; Tue, 31 Oct 2023 09:54:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IES6R0o/+UvOVqktPwRgNU+bNwgG1islII5vxfccG6DxOusB0695QW0t6r8B0ZeJ/1lpGD7 X-Received: by 2002:a17:902:e549:b0:1cc:5aef:f2c3 with SMTP id n9-20020a170902e54900b001cc5aeff2c3mr181721plf.22.1698771295409; Tue, 31 Oct 2023 09:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698771295; cv=none; d=google.com; s=arc-20160816; b=G755WDgjBBNC0Vjv+pDVj2l7ykWhPS+8HRqmT39H83c4+68bKXWZja5QF8yrtycZy3 /pqyk4G1mLElGe7TWToQyPdMY9HDKeow0r/IQElo4IMOikjSt6TBa0fSdQ8xJFjx3s84 5qdnz256UKH/wGbBXjlw2yhkCmIFLthwg/AaMpX1O/0aDrdwR833QirC4XaMjPzf/cYD yLeLUs0comZx8HrGj5WD+9HKkNkEufHnb9QtzX/MiAWM5iyZQigKZGsPXj6vEX1WYzfF wX0ZnB6eo/Fzfs2Fu7qGGukfPJvtLHsVfneV7q6VMuXIj6LsW5j+p2kZKcQR1cEiTdNT JqBg== 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=UKXxOJvfCpzA8Fg9Wxwmho+51dEO5pBe1UkAGf+Z23gciw7YveEZKTCS8PteVQGnhK tsX26awqsQrX9eMYGDW0dFmFnSLRZdneFSnikIgi7aIgfMLpHdNXvr3TLNANJcFb6P/O Au7olY5Ko6IV6hd5ZxGZ5Q2H7PLhJv0eZ8CYY7agWYBbhPG86FRq0t4QphV9lh+yvAkh CtJSTsD2tFQ6zTuwAQPiop2x+CN5Zwx6GTuNDwR3+jJ6zBKnLVSE54knqNsz1RA+msSD KgDPBab8x9sQIWaYPnKDGc57KUIzIlzSVdYrLZ45ZpbMxSkss9qIi5pFWT6Rk1CWOX21 nqRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aiN72kjx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id s13-20020a170902ea0d00b001c9b5d2c3fasi1228228plg.523.2023.10.31.09.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aiN72kjx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 90D6D8029ADF; Tue, 31 Oct 2023 09:54:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347089AbjJaQxj (ORCPT + 33 others); Tue, 31 Oct 2023 12:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346793AbjJaQwV (ORCPT ); Tue, 31 Oct 2023 12:52:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA5AD69; Tue, 31 Oct 2023 09:49:54 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF742C433C8; Tue, 31 Oct 2023 16:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698770994; bh=a4BpgPVlN4us8i8ZAKm55WYfRM8D4UzuiG9jC3POA78=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aiN72kjxTIgwlSdP1Zseysb9S37svfxeQOijJA7ibJ6UyCQtF+TRHDtXe0+NDcZTJ yUk9k1Eqbl4ryka7NNjrFxJTINiwEN3CPNXL9C/u6HvYbv47tChXlF0to19Cv8R2XH txLVOlG/zDo2BPLiBe03o3uCEVkBCvSPUahlibuT7QlSrco3VaHy/viF5stetmvCS1 VQa9weYPiaOUdC/S9fliDupi/fafoPbHZfKdhlWHi0AK4Fhw291LM0ahl4QQ8ZkLRR jVeRq/U2tZvfUzTilLMh4OyQXxEb0iMfRFMadQ+Xf6GSlTN5RIOjvrYLiLctsVP4E0 RFUmHSn9bAkIw== From: Maxime Ripard Date: Tue, 31 Oct 2023 17:48:41 +0100 Subject: [PATCH RFC v3 28/37] drm/rockchip: inno_hdmi: Move infoframe disable to separate function MIME-Version: 1.0 Message-Id: <20231031-kms-hdmi-connector-state-v3-28-328b0fae43a7@kernel.org> References: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org> In-Reply-To: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@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+D1vfrpE4FHG02pJDKmO+vfXnXhjqpxsenDCwwptZptVS/4rFl85PW/xofzaM LXrZgd+dpSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAiNQsZGRY7dHb/3d/IsZJn h1LNQbP/949bfforrvHK57nM2wl68wMZfrP3B5tIfW675Kq5lWtP6V+3X0lcSnsOtfS3OQSUhAv sYgYA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:54:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781290810058692580 X-GMAIL-MSGID: 1781290810058692580 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)