Received: by 2002:a05:7412:8d23:b0:f7:29d7:fb05 with SMTP id bj35csp294900rdb; Sat, 16 Dec 2023 08:31:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKceRdtDSHEdtis8RV5yvkP2G6b8T+c3kVcyKUK56zHvKOnKctzOjtne02eP/wTHjtu5eE X-Received: by 2002:a6b:5a03:0:b0:7b4:3bd0:243e with SMTP id o3-20020a6b5a03000000b007b43bd0243emr16477004iob.22.1702744269062; Sat, 16 Dec 2023 08:31:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702744269; cv=none; d=google.com; s=arc-20160816; b=T7JeY6YfIT0Qphqu7W5dlhH8BhNUII9dajoiWpdEXkACmfUMRg19bHCdV8Yc1gi/Vw Ctctx60vpuCqqNi0YWhcB6CQ7zqVnmrYRhOIWAvf9JGIG69NbEsxVcoX8CvtGdlLiL2x GUFZDI1JklJiTkCP5Q0/Qy3Mn4DQv6pZhDAOWo7cia1tVEWE5CPXAD+WhmiRwkmeosMF pPA+Skx64aOtJzHMeoKuCeaO7yPKQ2Z82/y/64QyN8I97pyAeeukSYCidC/qX8BCG2k3 75uihUU2uE7qHMXUAKfymUNIjQ3h27K6/yg2Y1r4vgzRvj1hGBGJ//RHW2IZVf4zkaJ9 2eyg== 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=i9QZuywAC4EI3NrqImc1jlnBGMQF6PpPHDhHez7fyFw=; fh=nzMX5Jolb3GculGR3f1Z1ReHOqdNjcdazDY5R3X+7M0=; b=tdGnEaQX/WlW6/PGxlkbQhj4AJtD1MIlAbfPsEPpNkNzDyJwS6zSZRRwHp8Z75bKtn 9ZQs+sbH/TDo1QNKgooOafFqU6n8BFLuENo75OMSCUsNwsbJqxRocoNjHoVUZa50TzO/ Od0P6awrl0nb0DvS+2G5q0+smfBP2dGZWEeEOEAVUhUHr2uuNVl01o5lA19c19NoU7mJ Hea/slABpoZlUUSRbAnCUWuXNhVBsuszkyDL1ZN0S3n4Pfl9pBhkf/fPR5+4tDVY1zft kODENeklrk418FKDR132pTFUPK/jUMA42I+HdZqFH+o5/SNPnpNZ6OiNPdr1Hxts3s28 WDdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lC6ELqZ6; spf=pass (google.com: domain of linux-kernel+bounces-2261-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2261-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z10-20020a17090ad78a00b0028b08990987si4787514pju.168.2023.12.16.08.31.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 08:31:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2261-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lC6ELqZ6; spf=pass (google.com: domain of linux-kernel+bounces-2261-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2261-linux.lists.archive=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 AC68B2857AF for ; Sat, 16 Dec 2023 16:31:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5723236AF8; Sat, 16 Dec 2023 16:27:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lC6ELqZ6" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 0D89334CF1; Sat, 16 Dec 2023 16:27:16 +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-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-552d39ac3ccso2601012a12.0; Sat, 16 Dec 2023 08:27:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702744035; x=1703348835; 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=i9QZuywAC4EI3NrqImc1jlnBGMQF6PpPHDhHez7fyFw=; b=lC6ELqZ66HTWeSk1fO0gBvzesZIupydZdhYexTiF+MkbiTU5N/qM7wSmLB5pHdpTkS TjEtvBs9cF+Y8aAnIspe6BvXUxA0n2IFXhgAdZyA0kIGQ25adKkRD9l7PXAtuYIzYpnZ PqrT54vqL90GuU3BpIKvksbJUWFoHPZ4MjL1C8hsNDrPzEB2nel52fRdMjjcmjT5JN4z FeWilNCsbghNXjR6LZlWkcJua5jETJ0T/S4l9Ubmxa8h4Azn23WrxF+pt+Ul+CsgRiwV gXCdP1K4dZvuH0TBn4AIM9K33F+Z14Ym7++tj3xph6JuV1UBWjOfg0inKo5D1nErkBM5 Tmqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702744035; x=1703348835; 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=i9QZuywAC4EI3NrqImc1jlnBGMQF6PpPHDhHez7fyFw=; b=syoHOsqdoK0Ofx0XWULxmx/Lv5d4HJgUUunuJHBSZeRk1eDbq2BCp9xddSezmitd3u DPtueQthTV2vZx0L/8VqdOz5VdTlDRcRDVpzelM/Bc4MOUBXftYL2V3SIsfPfEd0NvfQ iVulnx/FGNL9uS7TMaxDx35UA4IbLQotM6LmLvsFo/0omLY8l6etUo0MSH4sjWVYGjRq VW9x0AHCL6u5drOiOIJvqGdp8OV6nUg5W0s7Pm83Oqg+qw5BaGdQZ2kjRpwIp4G2pOWM FzADyGeIprYHIX2lZvJKGOjxpm4MuUjXKkpxYytu9H+fbVXZE/dWyTOFTTh2vyvf7gBs BoSA== X-Gm-Message-State: AOJu0YzaGLQoxMwzuu+rXghMdNFPU2Ea0+z00Uh+mqi5CHE/DnsKy8au uYMPrBDglQOFYyvty5P83sumhHz9KA== X-Received: by 2002:a17:906:610:b0:a19:a409:37dc with SMTP id s16-20020a170906061000b00a19a40937dcmr14010099ejb.53.1702744035357; Sat, 16 Dec 2023 08:27:15 -0800 (PST) Received: from U4.lan ([2a02:810b:f40:4300:e807:d345:6f47:1db9]) by smtp.gmail.com with ESMTPSA id st10-20020a170907c08a00b00a1cd0794696sm11990362ejc.53.2023.12.16.08.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 08:27:15 -0800 (PST) From: Alex Bee To: Sandy Huang , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Andy Yan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: David Airlie , Daniel Vetter , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Alex Bee Subject: [PATCH v2 13/27] drm/rockchip: inno_hdmi: Move infoframe disable to separate function Date: Sat, 16 Dec 2023 17:26:24 +0100 Message-ID: <20231216162639.125215-14-knaerzche@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231216162639.125215-1-knaerzche@gmail.com> References: <20231216162639.125215-1-knaerzche@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- changes in v2: - imported patch 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 1dd757845547..6354949bfd8e 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -207,34 +207,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, @@ -246,6 +256,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; @@ -254,7 +268,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) -- 2.43.0