From patchwork Tue Dec 19 17:00:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Bee X-Patchwork-Id: 181119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2085247dyi; Tue, 19 Dec 2023 09:09:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDVjbtHhmP0DEYLcZhTmsSKRtuP1rfRemHN5zYxa9VWXpcL/Rwz3j5S1Kj7SHWOr0+8j9B X-Received: by 2002:a17:90b:2415:b0:28b:4a9b:cf5c with SMTP id nr21-20020a17090b241500b0028b4a9bcf5cmr3240358pjb.67.1703005774877; Tue, 19 Dec 2023 09:09:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703005774; cv=none; d=google.com; s=arc-20160816; b=lsIotQnsrHHyeqhSl1Pet61ecF53HbMtzaQNsWJeIp+IQLTjLXkgY+3q675aJxmBZW kFG/FRh1vykUnFA75Kcm3e020DZE5ONpIuBD23MtjsX56DxnuBCU62MU5wZZpABxWMSS AR4Fzxu6F8Ik9T7l13IdrnqNfQnemqhzZBx2ht2Wub/lJVzeuR7R93cKEB/gi8xUqApn zNi1ps60rGIq+8EklORGjAYat9Z7ZiQSTLnds5oX76BpyGXVPOoa6fr9ZtftEW1uLXXC HTPMdvFvjVlnz514cOv9754rNNUMYzLWil7x2EFuXN6JhVdtmAv+q9b16ixy12gjDGKy 2+hg== 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=WLVOVeutPpE/o943uN9J0cWjrEPzXhsU4YUzCWYMJxA=; fh=k7ZhfSDxugAUNAX9PFQjqQnTRGZ+rgCl5CN8/TdzbyU=; b=nQmfFZ3SI7NzCLR36V05EtCAi5bkzYfaW1gGJPEoMDxF9o0b8m1QijsNFDVGc1tODD DtGVvXZk38W1ZhzOsL3C/IRMXmoJzUA1LFx7LR+SjR+xjRu0XFdGTwi6Yg+sL0uAkpPd nqc8RJPVj41qicLPCpUzg+ojgOMb/BPRa19CcM6IRXb1s8qGMyYrr3lrjqqxgC4ZE8DK qVMYNo9CuuEiVsoFcpKK3QZtZUipDvAUHHVpgcVmj/3qu3LRgigwYb0/8j8lnygoxBuz w53G3CvdWob7j2q3YdN5Vmh40yK5ux+DQ9T/wf4Hp5C+HGlhybzRE4ZpbNBy3Lh6Efpu PdRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ag++kioa; spf=pass (google.com: domain of linux-kernel+bounces-5633-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5633-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id nb18-20020a17090b35d200b0028bc7cefee2si383092pjb.34.2023.12.19.09.09.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:09:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5633-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ag++kioa; spf=pass (google.com: domain of linux-kernel+bounces-5633-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5633-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DBD53B259D8 for ; Tue, 19 Dec 2023 17:06:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC96C3DB8C; Tue, 19 Dec 2023 17:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ag++kioa" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 A14D839859; Tue, 19 Dec 2023 17:01:21 +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-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40c2308faedso56872875e9.1; Tue, 19 Dec 2023 09:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703005280; x=1703610080; 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=WLVOVeutPpE/o943uN9J0cWjrEPzXhsU4YUzCWYMJxA=; b=Ag++kioaLZBYMy6gi5yNznCDfCzXI5BLHTDlDjl+Hyq5w0pt3GKiBg9GZpT2NL0kgK WI0kvk7AEKiJVv91A2xLH2VPjC3Pv7dYZcqakz6G+dmp2aP0H0YLjUMdZk2P5nP9owLT AeHhDhttcz1XMy1GmzSEf87Ho6IrlhP8FWMd3ks4SikoQiXAqiNsDn4G4rcNAguOapvT HDQkzCOnsnemociZXIwliqbTWz26uOA7iC+zvBU8v4iKXh8ND/hrn+9gsJULV8uCrqU5 w7POzw71aoholSplG8coI+kEyAs6J5iBH22Hdyskr4YmG/k8ZjbWKU/7UY1mY0l58vmO LHBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703005280; x=1703610080; 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=WLVOVeutPpE/o943uN9J0cWjrEPzXhsU4YUzCWYMJxA=; b=o2gRRc9D3ANTTon72jWEMq7BGOZbZQKiuWAIxwihQWonyH0kWjRSSlBI8V0Qjz+5fW IgNlr4rEgYmRaxNr0al8ZU8eC1tNXL/CG3UAo0rhb+TqwEVBDgJncQ91LD0WyZEQQOiA oWQl5xr9o877+GNhUVwaJITIbYJtUk7EQMoEBg6xxDsB1wGMem1EbofEQMg891cexolI H0zI5MkHwHeP3/GAjme715OrFDew7x6gh/X94I4Gt0mD4jOSxUCJkg05I5rFAXNPjswD 6wAp5kWMoDq652Js6BLk0/ItzC8zb7ZWkvOpqVD8wqtM5ABHguBACXupTyUB8Pcbdjax kDTQ== X-Gm-Message-State: AOJu0Yyftt1GqhIt/D/GWVUs3B3s6zM1/C8qDguWwHNnyRW8P0HWsnxh cPYoKFJ4TfPzG8/AA66NnQ== X-Received: by 2002:a05:600c:808e:b0:40b:5e59:c581 with SMTP id ew14-20020a05600c808e00b0040b5e59c581mr9903834wmb.171.1703005279654; Tue, 19 Dec 2023 09:01:19 -0800 (PST) Received: from U4.lan ([2a02:810b:f40:4300:7ae5:3e:d1c6:a138]) by smtp.gmail.com with ESMTPSA id i7-20020a05600c354700b0040d2805d158sm3225878wmq.48.2023.12.19.09.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:01:19 -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 v3 14/29] drm/rockchip: inno_hdmi: Move infoframe disable to separate function Date: Tue, 19 Dec 2023 18:00:44 +0100 Message-ID: <20231219170100.188800-15-knaerzche@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219170100.188800-1-knaerzche@gmail.com> References: <20231219170100.188800-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: 1785730983656442217 X-GMAIL-MSGID: 1785730983656442217 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 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)