From patchwork Fri Dec 22 17:42:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Bee X-Patchwork-Id: 182742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1224368dyi; Fri, 22 Dec 2023 09:46:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZHItWWcTJ3UvxO+8O6WQ49ZCSl1Vseqnm+zQw58Q9CERSaYutEuQ3SGKaWGNtz4Au3Mug X-Received: by 2002:a05:6a20:e116:b0:195:54ad:79fe with SMTP id kr22-20020a056a20e11600b0019554ad79femr321267pzb.120.1703267198317; Fri, 22 Dec 2023 09:46:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703267198; cv=none; d=google.com; s=arc-20160816; b=tKY0oQtsZD8IhGD1hW9LFiow9/N85+aWe+QkhngvkUP+3/s9Yk3TZhnTS5cJJ4wml4 2Tdjx0cVMUh/3I5KdG/bfnAs1WTHWpXZJiRsiu5k0geBM23AXScVZqbPaMO3MrNx0Z+f ilSBvEguto1Y+zbnzwbMj9Kb3wsmsUbWt0CPchxLdF/NdZE7Ebg2W/EEcqmng0/S8rvY YytORMHFJKzIl8PSQ34oO4UCeT61hswSpFim5YevaenUTJKNch+nDn1oU3cn9b8AiHZh CRQsl4kygZZNcuBxfbk5o9WiqEMIFeHkReEhTnhUZ3xfZnpqb2KOXiNzp/Z2wf7GqplX zd1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hxV163vg4WaEsUhoUGEXFBcX2Ll0vd6Pc97F0FYEm9Q=; fh=k7ZhfSDxugAUNAX9PFQjqQnTRGZ+rgCl5CN8/TdzbyU=; b=GqK+Yz8Yu3VYDpvQEQTiOK5H6D3fODWdl060RU91hiHfMlT5IDkcNpmT+ZAiOv6Yg3 /EKmrEludlb1bphwzykulHLB+pOJW7kVivfAciOYyx32HyaurPkpPHMg0GdkwoJIGzY/ iqjTkgv0H0oEO7de3EzynJTfx25DQYRFt7labjxEWs6apXjEo9wMV6kyf4Pf5JY798gF zQsDWF2TRrR1IQTF83CcMSfp81QiIrx+jAPj0/KHGDKFBHpQ+azJlM/4Bb5guudc/8LR 4iZwoDdrmjkyKiA+RIC+YRlpJF2ibOxZ1LkCH2jzTWUIPF1fSTx5UivqOPotXCmS+bkG rEow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fSeZit46; spf=pass (google.com: domain of linux-kernel+bounces-9963-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9963-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y14-20020a17090a134e00b0028bbdf5c434si3571164pjf.103.2023.12.22.09.46.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 09:46:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9963-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fSeZit46; spf=pass (google.com: domain of linux-kernel+bounces-9963-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9963-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1BE38282BB7 for ; Fri, 22 Dec 2023 17:46:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5562C31750; Fri, 22 Dec 2023 17:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fSeZit46" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C5B033060; Fri, 22 Dec 2023 17:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-336979a566aso574617f8f.1; Fri, 22 Dec 2023 09:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703266952; x=1703871752; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hxV163vg4WaEsUhoUGEXFBcX2Ll0vd6Pc97F0FYEm9Q=; b=fSeZit465fX7FzYQ8pKLFqekXEZnFXH3RNRFU2mMU5ZrHnz8h0tP4V+VD3yTXA10oC d2Bn7EbX+31XkAex8+39zKrHOp+szwZn8/v8diM9HOydt8du+YDk78lzzjnLbMgqxnEb EBAMM1VVFNV7X6V49GxkQ7axRDY9URCBxRva+qfVuikB3+VBMTf3HBoLnany5WpUAq5W aZcVjG17xObmTedR7CdFfjJMPqra4mA00u/WqjcZm2FkvNeGYx1+t6Fshd5oHtrXHK53 M/y4iwc1gKHPakCykaq1kiFGjHmO0HvCKui2O1d/H5O7HBaisWbAQ7c9J9/Dt/yhw5fr 1gvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703266952; x=1703871752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hxV163vg4WaEsUhoUGEXFBcX2Ll0vd6Pc97F0FYEm9Q=; b=fQBc1m+zKZitdJrqTCuyI+7YA8PpGRMDOMUUZQ2trtWMS0EZLCiROT3o+hHd3OR7AW M21OPAe5d+u0q9oxyl1ILHe5KI8//7vvaYGoBhwVCdtFIY3fUxZIV3tkEXODMBfz4+Pr 8ua/n6BX0eOwwltorRufWb7rbuzyfRLu3t0pZYW7tMIxb2pYxKUpRZeyCUEhwTg7pBia kFcAyxOK0ZFTG9WqmixsFprwLDRBgY4qgPWirFGl/A6vD/OT0E0S2LquBeh+695ln99A 0062o7LhZF/jqJaCJYQhqRF76PQBSFaco2N53ZZfenWggmORwXGWlK3yUXm1vD/dTThB rsLQ== X-Gm-Message-State: AOJu0Yzzm8uXhMyA2m/GT13T6hazJgpWYlLjcsKOMIWnKtBvIlSZ/UiT uE7uCZ3iapOfcyuuGbw4ew== X-Received: by 2002:adf:e4d1:0:b0:336:5fac:d845 with SMTP id v17-20020adfe4d1000000b003365facd845mr1065480wrm.34.1703266952323; Fri, 22 Dec 2023 09:42:32 -0800 (PST) Received: from U4.lan ([2a02:810b:f40:4300:f3ae:2788:7e03:f44]) by smtp.gmail.com with ESMTPSA id w10-20020adfec4a000000b00336670abdcasm4777116wrn.40.2023.12.22.09.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 09:42:32 -0800 (PST) From: Alex Bee To: Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Alex Bee Subject: [PATCH v4 14/29] drm/rockchip: inno_hdmi: Move infoframe disable to separate function Date: Fri, 22 Dec 2023 18:42:05 +0100 Message-ID: <20231222174220.55249-15-knaerzche@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231222174220.55249-1-knaerzche@gmail.com> References: <20231222174220.55249-1-knaerzche@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786005105391226660 X-GMAIL-MSGID: 1786005105391226660 From: Maxime Ripard 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 Tested-by: Alex Bee Signed-off-by: Alex Bee --- changes in v2: - imported patch changes in v3: - added my SoB changes in v4: - none drivers/gpu/drm/rockchip/inno_hdmi.c | 46 ++++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c index 5c9f1325441f..10466c2aa520 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -205,34 +205,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; - - rc = hdmi_infoframe_pack(frame, packed_frame, - sizeof(packed_frame)); - if (rc < 0) - return rc; +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; - 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, @@ -244,6 +254,10 @@ 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; + } if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_YUV444) frame.avi.colorspace = HDMI_COLORSPACE_YUV444; @@ -252,7 +266,7 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, else 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)