Message ID | 20231213195125.212923-5-knaerzche@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8030562dys; Wed, 13 Dec 2023 11:52:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqI/RauuhoJf54/Bh8RP3B0sjepxGgyOEdpxFN02xF+hBaqzIv6wLGNm6q12QGAoFUG/Zs X-Received: by 2002:a05:6a20:5656:b0:18f:97c:4f6c with SMTP id is22-20020a056a20565600b0018f097c4f6cmr4514290pzc.120.1702497138773; Wed, 13 Dec 2023 11:52:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702497138; cv=none; d=google.com; s=arc-20160816; b=Zd5JkwYtr5xmHDPC3RyteWq6qXR1nnVi0sehTYjZ7nFFqjIFQPSN4sZo1NPxZV6foK a+xAZ7byNxbvtxt25RgJoFjUVaKTdkOH7TRoA3ETz1l+WeRXc9nm14sEyK8tUdXiq3FC OfPZosQOCoTMI+zor96mwr924Yqqw9FXS/HG59DySI0nvXouSa/NnwyxzLOt4uZ9A0Dz 98uHijhkXP9fIOY0/v5/upiCrwbcq/mzPM7xmFYNitYVde4gG6INl0vyZsqd8TNWT8ef 74yHnFquWeKq6ANlFxe/pD2UP4zg01RiY0HQC6WxD5Nlny1TRxIUCYQdmouwqlwdtoWj 8evA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sSS4lcTIGbMXkzXHnajhTMjU7KSYMMCUlsf0C4cS0VI=; fh=nzMX5Jolb3GculGR3f1Z1ReHOqdNjcdazDY5R3X+7M0=; b=xWgIhJuJIKxBFiXAwWsW+YYOumFRDhJtwjVuZhx+Df/EKyG57lJerFWdWzBzNWTeu2 i0CHr5O3j9KEFQriQS6Gl2u7UQvnwmVEn7ThGtZTE3sH97QtW6Ry0Moa7IzPPTAAIluu i6EiISH+qrIw0f+k1GbZ0WP2RuJW0Tr/ei5ggZ4d467GIN5DciMSdnHQRp8l0ejb8CE+ kr8H19NFvvdoNC/LetAJ8W5zN5M9GTWiSWrVduN0Dyu6lHayQv80b/3yKDegKvIbpkFh a8wbeHQJUgb1VLuWZa3EJ+McvzGxeBEe++bZUfGPtTEgZVX47cK1U+EnN4Mpu8q6dxzJ 9NEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DA42hTmN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g9-20020a636b09000000b005c6ef013573si9305480pgc.446.2023.12.13.11.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 11:52:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DA42hTmN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CF49D802D520; Wed, 13 Dec 2023 11:51:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442256AbjLMTvg (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 14:51:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377931AbjLMTvY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 14:51:24 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 224F2DC; Wed, 13 Dec 2023 11:51:31 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40c46d6784eso34793475e9.3; Wed, 13 Dec 2023 11:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702497089; x=1703101889; 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=sSS4lcTIGbMXkzXHnajhTMjU7KSYMMCUlsf0C4cS0VI=; b=DA42hTmNzdYhM6vWCT9grgW3ch5sEOkwVO1S8FSagUYe8/k9Aa9WmhvNf6+DjBXdyh HgylTwC/8sQrvu3jIVnF9EgFShmflcxWtb5YJRzgCyfvsl7AA/C0vHsUmbuRnLi4VYto irewCGYKJUIE2/mQKAN8H1Y11bazIsjjZuXNilp7Z33OxJ4rGC7KZ6s6evK9CUiXLOlq UThDYz8PcDJwOFabk1GS0ncwshfGm2Kp3vO1CCP4yXKCzKjanxnkbOdDL8oZluZawjTc kVdlUd7LOlRzlqQZbOx7tBgL6Jdok3RsMb91zrJVlU6ZevxbuvjP7kInUPJudEIaj84g k07w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702497089; x=1703101889; 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=sSS4lcTIGbMXkzXHnajhTMjU7KSYMMCUlsf0C4cS0VI=; b=pAkYRsV4GSbMZ2BK+eG3V6hAqDndufqxC259LQ1NMV5GTp2iNmbk3D+bvCfp4zZVwB kAuW+mZkCs3860cqmy9d/CjGPvwbkuiNM7mmNm8je2NLPX3RP/3Vkg61SQwpdUciAFQb FNjBSgcGyOF+H0kYz467kKi4NjtM2SheVmf5WXG4GJ8Ez1ofpnWXpUMX1AMKiiaagwRt HrgLz27viUxP3DvxYAgJ9mkmnXNhs7W4zBkUvu5GLoMdhXkv2zdsCdZAL9nSSVLZXT8+ 1Hc6/CzdUP68c2zBhcs8Ot2oGG0gd1a/Agfc071GvAj7oQxBY2DluoKV4axN5jBhJCyt slww== X-Gm-Message-State: AOJu0YxI2zBO65DE/4kBiuYigW0GQTt6giMkT+/bln8Rco0fdc7u7Jly tTlNpOKXrz72EDMr4dQi7g== X-Received: by 2002:a05:600c:3657:b0:40c:2d85:3a13 with SMTP id y23-20020a05600c365700b0040c2d853a13mr4530961wmq.185.1702497089612; Wed, 13 Dec 2023 11:51:29 -0800 (PST) Received: from U4.lan ([2a02:810b:f40:4300:92dc:8b1c:e01c:b93c]) by smtp.gmail.com with ESMTPSA id fm14-20020a05600c0c0e00b00407b93d8085sm24050698wmb.27.2023.12.13.11.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 11:51:29 -0800 (PST) From: Alex Bee <knaerzche@gmail.com> To: Sandy Huang <hjc@rock-chips.com>, =?utf-8?q?Heiko_St=C3=BCbner?= <heiko@sntech.de>, Andy Yan <andyshrk@163.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de> Cc: David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Alex Bee <knaerzche@gmail.com> Subject: [PATCH 04/11] drm/rockchip: inno_hdmi: Correctly setup HDMI quantization range Date: Wed, 13 Dec 2023 20:51:18 +0100 Message-ID: <20231213195125.212923-5-knaerzche@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213195125.212923-1-knaerzche@gmail.com> References: <20231213195125.212923-1-knaerzche@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Dec 2023 11:51:59 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785197639871063350 X-GMAIL-MSGID: 1785197639871063350 |
Series |
Add HDMI support for RK3128
|
|
Commit Message
Alex Bee
Dec. 13, 2023, 7:51 p.m. UTC
The display controller will always give full range RGB regardless of the
mode set, but HDMI requires certain modes to be transmitted in limited
range RGB. This is especially required for HDMI sinks which do not support
non-standard quantization ranges.
This enables color space conversion for those modes and sets the
quantization range accordingly in the AVI infoframe.
Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support")
Signed-off-by: Alex Bee <knaerzche@gmail.com>
---
drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------
1 file changed, 32 insertions(+), 8 deletions(-)
Comments
Hi Alex, Thanks for working on this! On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: > The display controller will always give full range RGB regardless of the > mode set, but HDMI requires certain modes to be transmitted in limited > range RGB. This is especially required for HDMI sinks which do not support > non-standard quantization ranges. > > This enables color space conversion for those modes and sets the > quantization range accordingly in the AVI infoframe. > > Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") > Signed-off-by: Alex Bee <knaerzche@gmail.com> > --- > drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ > 1 file changed, 32 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c > index 345253e033c5..32626a75723c 100644 > --- a/drivers/gpu/drm/rockchip/inno_hdmi.c > +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c > @@ -33,6 +33,7 @@ struct hdmi_data_info { > unsigned int enc_in_format; > unsigned int enc_out_format; > unsigned int colorimetry; > + bool rgb_limited_range; > }; > > struct inno_hdmi_i2c { > @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, > else > frame.avi.colorspace = HDMI_COLORSPACE_RGB; > > + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { > + drm_hdmi_avi_infoframe_quant_range(&frame.avi, > + &hdmi->connector, mode, > + hdmi->hdmi_data.rgb_limited_range ? > + HDMI_QUANTIZATION_RANGE_LIMITED : > + HDMI_QUANTIZATION_RANGE_FULL); > + } else { > + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; > + frame.avi.ycc_quantization_range = > + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; > + } > + > return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); > } > > @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) > if (data->enc_in_format == data->enc_out_format) { > if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || > (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { > - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > - > - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > - return 0; > + if (data->enc_in_format == HDMI_COLORSPACE_RGB && > + data->enc_out_format == HDMI_COLORSPACE_RGB && > + hdmi->hdmi_data.rgb_limited_range) { > + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; > + auto_csc = AUTO_CSC_DISABLE; > + c0_c2_change = C0_C2_CHANGE_DISABLE; > + csc_enable = v_CSC_ENABLE; > + } else { > + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > + return 0; > + } > } > } > > @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, > else > hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; > > + hdmi->hdmi_data.rgb_limited_range = > + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; > + This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ I would appreciate if you could test and merge them into your series. In particular, there's no need to store the range here: enc_out_format is always RGB, so you'll always end up calling drm_hdmi_avi_infoframe_quant_range(), and you'll always have the same csc values. Maxime
Hi Maxime Am 14.12.23 um 08:56 schrieb Maxime Ripard: > Hi Alex, > > Thanks for working on this! > > On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: >> The display controller will always give full range RGB regardless of the >> mode set, but HDMI requires certain modes to be transmitted in limited >> range RGB. This is especially required for HDMI sinks which do not support >> non-standard quantization ranges. >> >> This enables color space conversion for those modes and sets the >> quantization range accordingly in the AVI infoframe. >> >> Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") >> Signed-off-by: Alex Bee <knaerzche@gmail.com> >> --- >> drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ >> 1 file changed, 32 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c >> index 345253e033c5..32626a75723c 100644 >> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c >> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c >> @@ -33,6 +33,7 @@ struct hdmi_data_info { >> unsigned int enc_in_format; >> unsigned int enc_out_format; >> unsigned int colorimetry; >> + bool rgb_limited_range; >> }; >> >> struct inno_hdmi_i2c { >> @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, >> else >> frame.avi.colorspace = HDMI_COLORSPACE_RGB; >> >> + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { >> + drm_hdmi_avi_infoframe_quant_range(&frame.avi, >> + &hdmi->connector, mode, >> + hdmi->hdmi_data.rgb_limited_range ? >> + HDMI_QUANTIZATION_RANGE_LIMITED : >> + HDMI_QUANTIZATION_RANGE_FULL); >> + } else { >> + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; >> + frame.avi.ycc_quantization_range = >> + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; >> + } >> + >> return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); >> } >> >> @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) >> if (data->enc_in_format == data->enc_out_format) { >> if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || >> (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { >> - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); >> - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); >> - >> - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, >> - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, >> - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | >> - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); >> - return 0; >> + if (data->enc_in_format == HDMI_COLORSPACE_RGB && >> + data->enc_out_format == HDMI_COLORSPACE_RGB && >> + hdmi->hdmi_data.rgb_limited_range) { >> + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; >> + auto_csc = AUTO_CSC_DISABLE; >> + c0_c2_change = C0_C2_CHANGE_DISABLE; >> + csc_enable = v_CSC_ENABLE; >> + } else { >> + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); >> + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); >> + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, >> + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, >> + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | >> + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); >> + return 0; >> + } >> } >> } >> >> @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, >> else >> hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; >> >> + hdmi->hdmi_data.rgb_limited_range = >> + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; >> + > This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): > https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ I'm aware of that and I mentioned it in the cover letter. Your series is not merged yet and it didn't get much feedback so far. What is the status there? Especially because you are removing things from inno-hdmi driver (which aren't really required to remove there) which will I have to reintroduce. > I would appreciate if you could test and merge them into your series. > > In particular, there's no need to store the range here: enc_out_format rgb_limited_range is currently not only used for csc, but also for for infoframe creation. So it makes sense to have this stored to avoid calling drm_default_rgb_quant_range twice. > is always RGB, so you'll always end up calling > drm_hdmi_avi_infoframe_quant_range(), and you'll always have the same csc values. I don't think that's true. Non-VIC modes like 800x600 or 1024x764 want full range RGB and csc must not be done in those cases. Alex > > Maxime
Am Donnerstag, 14. Dezember 2023, 12:12:08 CET schrieb Alex Bee: > Hi Maxime > > Am 14.12.23 um 08:56 schrieb Maxime Ripard: > > Hi Alex, > > > > Thanks for working on this! > > > > On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: > >> The display controller will always give full range RGB regardless of the > >> mode set, but HDMI requires certain modes to be transmitted in limited > >> range RGB. This is especially required for HDMI sinks which do not support > >> non-standard quantization ranges. > >> > >> This enables color space conversion for those modes and sets the > >> quantization range accordingly in the AVI infoframe. > >> > >> Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") > >> Signed-off-by: Alex Bee <knaerzche@gmail.com> > >> --- > >> drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ > >> 1 file changed, 32 insertions(+), 8 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c > >> index 345253e033c5..32626a75723c 100644 > >> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c > >> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c > >> @@ -33,6 +33,7 @@ struct hdmi_data_info { > >> unsigned int enc_in_format; > >> unsigned int enc_out_format; > >> unsigned int colorimetry; > >> + bool rgb_limited_range; > >> }; > >> > >> struct inno_hdmi_i2c { > >> @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, > >> else > >> frame.avi.colorspace = HDMI_COLORSPACE_RGB; > >> > >> + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { > >> + drm_hdmi_avi_infoframe_quant_range(&frame.avi, > >> + &hdmi->connector, mode, > >> + hdmi->hdmi_data.rgb_limited_range ? > >> + HDMI_QUANTIZATION_RANGE_LIMITED : > >> + HDMI_QUANTIZATION_RANGE_FULL); > >> + } else { > >> + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; > >> + frame.avi.ycc_quantization_range = > >> + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; > >> + } > >> + > >> return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); > >> } > >> > >> @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) > >> if (data->enc_in_format == data->enc_out_format) { > >> if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || > >> (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { > >> - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > >> - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > >> - > >> - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > >> - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > >> - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > >> - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > >> - return 0; > >> + if (data->enc_in_format == HDMI_COLORSPACE_RGB && > >> + data->enc_out_format == HDMI_COLORSPACE_RGB && > >> + hdmi->hdmi_data.rgb_limited_range) { > >> + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; > >> + auto_csc = AUTO_CSC_DISABLE; > >> + c0_c2_change = C0_C2_CHANGE_DISABLE; > >> + csc_enable = v_CSC_ENABLE; > >> + } else { > >> + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > >> + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > >> + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > >> + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > >> + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > >> + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > >> + return 0; > >> + } > >> } > >> } > >> > >> @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, > >> else > >> hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; > >> > >> + hdmi->hdmi_data.rgb_limited_range = > >> + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; > >> + > > This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): > > https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ > I'm aware of that and I mentioned it in the cover letter. Your series is > not merged yet and it didn't get much feedback so far. What is the > status there? Especially because you are removing things from inno-hdmi > driver (which aren't really required to remove there) which will I have > to reintroduce. Sadly I haven't found the time to look closer at Maxime's series so far, but I got the impression that it separates into multiple cleanup steps for a number of controllers. So the sentence below suggests that Maxime wanted you to pick the appropriate patches from there and incorporate them into your series (as it looks like you developed a nice working knowledge of the inno-hdmi driver). So there is no need to first drop and then reintroduce stuff, but there may be other interesting cleanups there. > > I would appreciate if you could test and merge them into your series. Heiko > > In particular, there's no need to store the range here: enc_out_format > rgb_limited_range is currently not only used for csc, but also for for > infoframe creation. So it makes sense to have this stored to avoid > calling drm_default_rgb_quant_range twice. > > > is always RGB, so you'll always end up calling > > drm_hdmi_avi_infoframe_quant_range(), and you'll always have the same csc values. > > I don't think that's true. Non-VIC modes like 800x600 or 1024x764 want > full range RGB and csc must not be done in those cases.
On Thu, Dec 14, 2023 at 12:12:08PM +0100, Alex Bee wrote: > Hi Maxime > > Am 14.12.23 um 08:56 schrieb Maxime Ripard: > > Hi Alex, > > > > Thanks for working on this! > > > > On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: > > > The display controller will always give full range RGB regardless of the > > > mode set, but HDMI requires certain modes to be transmitted in limited > > > range RGB. This is especially required for HDMI sinks which do not support > > > non-standard quantization ranges. > > > > > > This enables color space conversion for those modes and sets the > > > quantization range accordingly in the AVI infoframe. > > > > > > Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") > > > Signed-off-by: Alex Bee <knaerzche@gmail.com> > > > --- > > > drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ > > > 1 file changed, 32 insertions(+), 8 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c > > > index 345253e033c5..32626a75723c 100644 > > > --- a/drivers/gpu/drm/rockchip/inno_hdmi.c > > > +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c > > > @@ -33,6 +33,7 @@ struct hdmi_data_info { > > > unsigned int enc_in_format; > > > unsigned int enc_out_format; > > > unsigned int colorimetry; > > > + bool rgb_limited_range; > > > }; > > > struct inno_hdmi_i2c { > > > @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, > > > else > > > frame.avi.colorspace = HDMI_COLORSPACE_RGB; > > > + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { > > > + drm_hdmi_avi_infoframe_quant_range(&frame.avi, > > > + &hdmi->connector, mode, > > > + hdmi->hdmi_data.rgb_limited_range ? > > > + HDMI_QUANTIZATION_RANGE_LIMITED : > > > + HDMI_QUANTIZATION_RANGE_FULL); > > > + } else { > > > + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; > > > + frame.avi.ycc_quantization_range = > > > + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; > > > + } > > > + > > > return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); > > > } > > > @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) > > > if (data->enc_in_format == data->enc_out_format) { > > > if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || > > > (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { > > > - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > > > - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > > > - > > > - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > > > - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > > > - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > > > - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > > > - return 0; > > > + if (data->enc_in_format == HDMI_COLORSPACE_RGB && > > > + data->enc_out_format == HDMI_COLORSPACE_RGB && > > > + hdmi->hdmi_data.rgb_limited_range) { > > > + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; > > > + auto_csc = AUTO_CSC_DISABLE; > > > + c0_c2_change = C0_C2_CHANGE_DISABLE; > > > + csc_enable = v_CSC_ENABLE; > > > + } else { > > > + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > > > + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > > > + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > > > + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > > > + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > > > + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > > > + return 0; > > > + } > > > } > > > } > > > @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, > > > else > > > hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; > > > + hdmi->hdmi_data.rgb_limited_range = > > > + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; > > > + > > This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): > > https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ > > I'm aware of that and I mentioned it in the cover letter. Sorry, I missed that part. > Your series is not merged yet and it didn't get much feedback so far. > What is the status there? It didn't have much reviews, but I'll hope to change that. For the patches 22 to 38 though, it doesn't really matter. Those changes are self-contained and can be applied as is outside of the series. > Especially because you are removing things from inno-hdmi driver (which > aren't really required to remove there) which will I have to reintroduce. I'm not entirely sure which part I remove that are actually going to be used here. > > I would appreciate if you could test and merge them into your series. > > > > In particular, there's no need to store the range here: enc_out_format > > rgb_limited_range is currently not only used for csc, but also for for > infoframe creation. So it makes sense to have this stored to avoid calling > drm_default_rgb_quant_range twice. You're right, I missed one. Still, it shouldn't be stored in the hdmi_data_info structure, it's tied to the mode, and the mode is part of the state, so it's not a property to a given device, but it's tied to the connector state. So if you want to do so, you should really create a custom state structure and store the range there, just like vc4 is doing for example. Maxime
On Thu, Dec 14, 2023 at 12:17:34PM +0100, Heiko Stübner wrote: > Am Donnerstag, 14. Dezember 2023, 12:12:08 CET schrieb Alex Bee: > > Hi Maxime > > > > Am 14.12.23 um 08:56 schrieb Maxime Ripard: > > > Hi Alex, > > > > > > Thanks for working on this! > > > > > > On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: > > >> The display controller will always give full range RGB regardless of the > > >> mode set, but HDMI requires certain modes to be transmitted in limited > > >> range RGB. This is especially required for HDMI sinks which do not support > > >> non-standard quantization ranges. > > >> > > >> This enables color space conversion for those modes and sets the > > >> quantization range accordingly in the AVI infoframe. > > >> > > >> Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") > > >> Signed-off-by: Alex Bee <knaerzche@gmail.com> > > >> --- > > >> drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ > > >> 1 file changed, 32 insertions(+), 8 deletions(-) > > >> > > >> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c > > >> index 345253e033c5..32626a75723c 100644 > > >> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c > > >> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c > > >> @@ -33,6 +33,7 @@ struct hdmi_data_info { > > >> unsigned int enc_in_format; > > >> unsigned int enc_out_format; > > >> unsigned int colorimetry; > > >> + bool rgb_limited_range; > > >> }; > > >> > > >> struct inno_hdmi_i2c { > > >> @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, > > >> else > > >> frame.avi.colorspace = HDMI_COLORSPACE_RGB; > > >> > > >> + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { > > >> + drm_hdmi_avi_infoframe_quant_range(&frame.avi, > > >> + &hdmi->connector, mode, > > >> + hdmi->hdmi_data.rgb_limited_range ? > > >> + HDMI_QUANTIZATION_RANGE_LIMITED : > > >> + HDMI_QUANTIZATION_RANGE_FULL); > > >> + } else { > > >> + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; > > >> + frame.avi.ycc_quantization_range = > > >> + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; > > >> + } > > >> + > > >> return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); > > >> } > > >> > > >> @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) > > >> if (data->enc_in_format == data->enc_out_format) { > > >> if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || > > >> (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { > > >> - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > > >> - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > > >> - > > >> - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > > >> - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > > >> - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > > >> - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > > >> - return 0; > > >> + if (data->enc_in_format == HDMI_COLORSPACE_RGB && > > >> + data->enc_out_format == HDMI_COLORSPACE_RGB && > > >> + hdmi->hdmi_data.rgb_limited_range) { > > >> + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; > > >> + auto_csc = AUTO_CSC_DISABLE; > > >> + c0_c2_change = C0_C2_CHANGE_DISABLE; > > >> + csc_enable = v_CSC_ENABLE; > > >> + } else { > > >> + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > > >> + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > > >> + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > > >> + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > > >> + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > > >> + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > > >> + return 0; > > >> + } > > >> } > > >> } > > >> > > >> @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, > > >> else > > >> hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; > > >> > > >> + hdmi->hdmi_data.rgb_limited_range = > > >> + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; > > >> + > > > This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): > > > https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ > > I'm aware of that and I mentioned it in the cover letter. Your series is > > not merged yet and it didn't get much feedback so far. What is the > > status there? Especially because you are removing things from inno-hdmi > > driver (which aren't really required to remove there) which will I have > > to reintroduce. > > Sadly I haven't found the time to look closer at Maxime's series so far, > but I got the impression that it separates into multiple cleanup steps > for a number of controllers. Yeah, one of the previous version comment was to support more controllers than vc4, which is fair. So I ended up reworking and converting multiple controllers, but most of the clean up changes can be applied outside of that series just fine. I just didn't find someone to test / review them yet :) Maxime
Hi: 在 2023-12-14 19:36:05,"Maxime Ripard" <mripard@kernel.org> 写道: >On Thu, Dec 14, 2023 at 12:17:34PM +0100, Heiko Stübner wrote: >> Am Donnerstag, 14. Dezember 2023, 12:12:08 CET schrieb Alex Bee: >> > Hi Maxime >> > >> > Am 14.12.23 um 08:56 schrieb Maxime Ripard: >> > > Hi Alex, >> > > >> > > Thanks for working on this! >> > > >> > > On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: >> > >> The display controller will always give full range RGB regardless of the >> > >> mode set, but HDMI requires certain modes to be transmitted in limited >> > >> range RGB. This is especially required for HDMI sinks which do not support >> > >> non-standard quantization ranges. >> > >> >> > >> This enables color space conversion for those modes and sets the >> > >> quantization range accordingly in the AVI infoframe. >> > >> >> > >> Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") >> > >> Signed-off-by: Alex Bee <knaerzche@gmail.com> >> > >> --- >> > >> drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ >> > >> 1 file changed, 32 insertions(+), 8 deletions(-) >> > >> >> > >> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c >> > >> index 345253e033c5..32626a75723c 100644 >> > >> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c >> > >> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c >> > >> @@ -33,6 +33,7 @@ struct hdmi_data_info { >> > >> unsigned int enc_in_format; >> > >> unsigned int enc_out_format; >> > >> unsigned int colorimetry; >> > >> + bool rgb_limited_range; >> > >> }; >> > >> >> > >> struct inno_hdmi_i2c { >> > >> @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, >> > >> else >> > >> frame.avi.colorspace = HDMI_COLORSPACE_RGB; >> > >> >> > >> + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { >> > >> + drm_hdmi_avi_infoframe_quant_range(&frame.avi, >> > >> + &hdmi->connector, mode, >> > >> + hdmi->hdmi_data.rgb_limited_range ? >> > >> + HDMI_QUANTIZATION_RANGE_LIMITED : >> > >> + HDMI_QUANTIZATION_RANGE_FULL); >> > >> + } else { >> > >> + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; >> > >> + frame.avi.ycc_quantization_range = >> > >> + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; >> > >> + } >> > >> + >> > >> return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); >> > >> } >> > >> >> > >> @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) >> > >> if (data->enc_in_format == data->enc_out_format) { >> > >> if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || >> > >> (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { >> > >> - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); >> > >> - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); >> > >> - >> > >> - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, >> > >> - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, >> > >> - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | >> > >> - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); >> > >> - return 0; >> > >> + if (data->enc_in_format == HDMI_COLORSPACE_RGB && >> > >> + data->enc_out_format == HDMI_COLORSPACE_RGB && >> > >> + hdmi->hdmi_data.rgb_limited_range) { >> > >> + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; >> > >> + auto_csc = AUTO_CSC_DISABLE; >> > >> + c0_c2_change = C0_C2_CHANGE_DISABLE; >> > >> + csc_enable = v_CSC_ENABLE; >> > >> + } else { >> > >> + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); >> > >> + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); >> > >> + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, >> > >> + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, >> > >> + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | >> > >> + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); >> > >> + return 0; >> > >> + } >> > >> } >> > >> } >> > >> >> > >> @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, >> > >> else >> > >> hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; >> > >> >> > >> + hdmi->hdmi_data.rgb_limited_range = >> > >> + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; >> > >> + >> > > This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): >> > > https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ >> > I'm aware of that and I mentioned it in the cover letter. Your series is >> > not merged yet and it didn't get much feedback so far. What is the >> > status there? Especially because you are removing things from inno-hdmi >> > driver (which aren't really required to remove there) which will I have >> > to reintroduce. >> >> Sadly I haven't found the time to look closer at Maxime's series so far, >> but I got the impression that it separates into multiple cleanup steps >> for a number of controllers. > >Yeah, one of the previous version comment was to support more >controllers than vc4, which is fair. So I ended up reworking and >converting multiple controllers, but most of the clean up changes can be >applied outside of that series just fine. > >I just didn't find someone to test / review them yet :) I will try to bring up my rk3036 kylin board whith mainline kernel this weekend, then I can do some tests. > >Maxime
Am 14.12.23 um 12:33 schrieb Maxime Ripard: > On Thu, Dec 14, 2023 at 12:12:08PM +0100, Alex Bee wrote: >> Hi Maxime >> >> Am 14.12.23 um 08:56 schrieb Maxime Ripard: >>> Hi Alex, >>> >>> Thanks for working on this! >>> >>> On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: >>>> The display controller will always give full range RGB regardless of the >>>> mode set, but HDMI requires certain modes to be transmitted in limited >>>> range RGB. This is especially required for HDMI sinks which do not support >>>> non-standard quantization ranges. >>>> >>>> This enables color space conversion for those modes and sets the >>>> quantization range accordingly in the AVI infoframe. >>>> >>>> Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") >>>> Signed-off-by: Alex Bee <knaerzche@gmail.com> >>>> --- >>>> drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ >>>> 1 file changed, 32 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c >>>> index 345253e033c5..32626a75723c 100644 >>>> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c >>>> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c >>>> @@ -33,6 +33,7 @@ struct hdmi_data_info { >>>> unsigned int enc_in_format; >>>> unsigned int enc_out_format; >>>> unsigned int colorimetry; >>>> + bool rgb_limited_range; >>>> }; >>>> struct inno_hdmi_i2c { >>>> @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, >>>> else >>>> frame.avi.colorspace = HDMI_COLORSPACE_RGB; >>>> + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { >>>> + drm_hdmi_avi_infoframe_quant_range(&frame.avi, >>>> + &hdmi->connector, mode, >>>> + hdmi->hdmi_data.rgb_limited_range ? >>>> + HDMI_QUANTIZATION_RANGE_LIMITED : >>>> + HDMI_QUANTIZATION_RANGE_FULL); >>>> + } else { >>>> + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; >>>> + frame.avi.ycc_quantization_range = >>>> + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; >>>> + } >>>> + >>>> return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); >>>> } >>>> @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) >>>> if (data->enc_in_format == data->enc_out_format) { >>>> if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || >>>> (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { >>>> - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); >>>> - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); >>>> - >>>> - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, >>>> - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, >>>> - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | >>>> - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); >>>> - return 0; >>>> + if (data->enc_in_format == HDMI_COLORSPACE_RGB && >>>> + data->enc_out_format == HDMI_COLORSPACE_RGB && >>>> + hdmi->hdmi_data.rgb_limited_range) { >>>> + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; >>>> + auto_csc = AUTO_CSC_DISABLE; >>>> + c0_c2_change = C0_C2_CHANGE_DISABLE; >>>> + csc_enable = v_CSC_ENABLE; >>>> + } else { >>>> + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); >>>> + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); >>>> + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, >>>> + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, >>>> + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | >>>> + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); >>>> + return 0; >>>> + } >>>> } >>>> } >>>> @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, >>>> else >>>> hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; >>>> + hdmi->hdmi_data.rgb_limited_range = >>>> + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; >>>> + >>> This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): >>> https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ >> I'm aware of that and I mentioned it in the cover letter. > Sorry, I missed that part. > >> Your series is not merged yet and it didn't get much feedback so far. >> What is the status there? > It didn't have much reviews, but I'll hope to change that. For the > patches 22 to 38 though, it doesn't really matter. Those changes are > self-contained and can be applied as is outside of the series. > >> Especially because you are removing things from inno-hdmi driver (which >> aren't really required to remove there) which will I have to reintroduce. > I'm not entirely sure which part I remove that are actually going to be > used here. I'm refering to [PATCH v5 33/44] which completly removes csc coeffs but this series needs the CSC_RGB_0_255_TO_RGB_16_235_8BIT coeffs and [PATCH v5 29/44] which removes writing csc_coeffs to the hardware. > >>> I would appreciate if you could test and merge them into your series. >>> >>> In particular, there's no need to store the range here: enc_out_format >> rgb_limited_range is currently not only used for csc, but also for for >> infoframe creation. So it makes sense to have this stored to avoid calling >> drm_default_rgb_quant_range twice. > You're right, I missed one. Still, it shouldn't be stored in the > hdmi_data_info structure, it's tied to the mode, and the mode is part of > the state, so it's not a property to a given device, but it's tied to > the connector state. > > So if you want to do so, you should really create a custom state > structure and store the range there, just like vc4 is doing for example. OK - I'll check. Alex > > Maxime
Hi Heiko, Hi Maxime, Am 14.12.23 um 12:36 schrieb Maxime Ripard: > On Thu, Dec 14, 2023 at 12:17:34PM +0100, Heiko Stübner wrote: >> Am Donnerstag, 14. Dezember 2023, 12:12:08 CET schrieb Alex Bee: >>> Hi Maxime >>> >>> Am 14.12.23 um 08:56 schrieb Maxime Ripard: >>>> Hi Alex, >>>> >>>> Thanks for working on this! >>>> >>>> On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: >>>>> The display controller will always give full range RGB regardless of the >>>>> mode set, but HDMI requires certain modes to be transmitted in limited >>>>> range RGB. This is especially required for HDMI sinks which do not support >>>>> non-standard quantization ranges. >>>>> >>>>> This enables color space conversion for those modes and sets the >>>>> quantization range accordingly in the AVI infoframe. >>>>> >>>>> Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") >>>>> Signed-off-by: Alex Bee <knaerzche@gmail.com> >>>>> --- >>>>> drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ >>>>> 1 file changed, 32 insertions(+), 8 deletions(-) >>>>> >>>>> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c >>>>> index 345253e033c5..32626a75723c 100644 >>>>> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c >>>>> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c >>>>> @@ -33,6 +33,7 @@ struct hdmi_data_info { >>>>> unsigned int enc_in_format; >>>>> unsigned int enc_out_format; >>>>> unsigned int colorimetry; >>>>> + bool rgb_limited_range; >>>>> }; >>>>> >>>>> struct inno_hdmi_i2c { >>>>> @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, >>>>> else >>>>> frame.avi.colorspace = HDMI_COLORSPACE_RGB; >>>>> >>>>> + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { >>>>> + drm_hdmi_avi_infoframe_quant_range(&frame.avi, >>>>> + &hdmi->connector, mode, >>>>> + hdmi->hdmi_data.rgb_limited_range ? >>>>> + HDMI_QUANTIZATION_RANGE_LIMITED : >>>>> + HDMI_QUANTIZATION_RANGE_FULL); >>>>> + } else { >>>>> + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; >>>>> + frame.avi.ycc_quantization_range = >>>>> + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; >>>>> + } >>>>> + >>>>> return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); >>>>> } >>>>> >>>>> @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) >>>>> if (data->enc_in_format == data->enc_out_format) { >>>>> if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || >>>>> (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { >>>>> - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); >>>>> - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); >>>>> - >>>>> - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, >>>>> - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, >>>>> - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | >>>>> - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); >>>>> - return 0; >>>>> + if (data->enc_in_format == HDMI_COLORSPACE_RGB && >>>>> + data->enc_out_format == HDMI_COLORSPACE_RGB && >>>>> + hdmi->hdmi_data.rgb_limited_range) { >>>>> + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; >>>>> + auto_csc = AUTO_CSC_DISABLE; >>>>> + c0_c2_change = C0_C2_CHANGE_DISABLE; >>>>> + csc_enable = v_CSC_ENABLE; >>>>> + } else { >>>>> + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); >>>>> + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); >>>>> + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, >>>>> + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, >>>>> + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | >>>>> + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); >>>>> + return 0; >>>>> + } >>>>> } >>>>> } >>>>> >>>>> @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, >>>>> else >>>>> hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; >>>>> >>>>> + hdmi->hdmi_data.rgb_limited_range = >>>>> + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; >>>>> + >>>> This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): >>>> https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ >>> I'm aware of that and I mentioned it in the cover letter. Your series is >>> not merged yet and it didn't get much feedback so far. What is the >>> status there? Especially because you are removing things from inno-hdmi >>> driver (which aren't really required to remove there) which will I have >>> to reintroduce. >> Sadly I haven't found the time to look closer at Maxime's series so far, >> but I got the impression that it separates into multiple cleanup steps >> for a number of controllers. > Yeah, one of the previous version comment was to support more > controllers than vc4, which is fair. So I ended up reworking and > converting multiple controllers, but most of the clean up changes can be > applied outside of that series just fine. > > I just didn't find someone to test / review them yet :) I'm not exactly sure how to proceed here. Do you want me to: - base my patches on top of Maxime's series and reintroduce csc things (of course only those which touch inno-hdmi w/o the framwork changes) - only apply the patches that do not touch csc things and base my series on top of that - adapt Maxime's patches so that RGB full to RGB limited stays in there - wait with resend until Maxime's series is merged and reintroduce csc after that - something else ? Please advise. Thanks, Alex > Maxime
On Thu, Dec 14, 2023 at 03:05:59PM +0100, Alex Bee wrote: > > Am 14.12.23 um 12:33 schrieb Maxime Ripard: > > On Thu, Dec 14, 2023 at 12:12:08PM +0100, Alex Bee wrote: > > > Hi Maxime > > > > > > Am 14.12.23 um 08:56 schrieb Maxime Ripard: > > > > Hi Alex, > > > > > > > > Thanks for working on this! > > > > > > > > On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: > > > > > The display controller will always give full range RGB regardless of the > > > > > mode set, but HDMI requires certain modes to be transmitted in limited > > > > > range RGB. This is especially required for HDMI sinks which do not support > > > > > non-standard quantization ranges. > > > > > > > > > > This enables color space conversion for those modes and sets the > > > > > quantization range accordingly in the AVI infoframe. > > > > > > > > > > Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") > > > > > Signed-off-by: Alex Bee <knaerzche@gmail.com> > > > > > --- > > > > > drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ > > > > > 1 file changed, 32 insertions(+), 8 deletions(-) > > > > > > > > > > diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c > > > > > index 345253e033c5..32626a75723c 100644 > > > > > --- a/drivers/gpu/drm/rockchip/inno_hdmi.c > > > > > +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c > > > > > @@ -33,6 +33,7 @@ struct hdmi_data_info { > > > > > unsigned int enc_in_format; > > > > > unsigned int enc_out_format; > > > > > unsigned int colorimetry; > > > > > + bool rgb_limited_range; > > > > > }; > > > > > struct inno_hdmi_i2c { > > > > > @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, > > > > > else > > > > > frame.avi.colorspace = HDMI_COLORSPACE_RGB; > > > > > + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { > > > > > + drm_hdmi_avi_infoframe_quant_range(&frame.avi, > > > > > + &hdmi->connector, mode, > > > > > + hdmi->hdmi_data.rgb_limited_range ? > > > > > + HDMI_QUANTIZATION_RANGE_LIMITED : > > > > > + HDMI_QUANTIZATION_RANGE_FULL); > > > > > + } else { > > > > > + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; > > > > > + frame.avi.ycc_quantization_range = > > > > > + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; > > > > > + } > > > > > + > > > > > return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); > > > > > } > > > > > @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) > > > > > if (data->enc_in_format == data->enc_out_format) { > > > > > if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || > > > > > (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { > > > > > - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > > > > > - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > > > > > - > > > > > - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > > > > > - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > > > > > - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > > > > > - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > > > > > - return 0; > > > > > + if (data->enc_in_format == HDMI_COLORSPACE_RGB && > > > > > + data->enc_out_format == HDMI_COLORSPACE_RGB && > > > > > + hdmi->hdmi_data.rgb_limited_range) { > > > > > + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; > > > > > + auto_csc = AUTO_CSC_DISABLE; > > > > > + c0_c2_change = C0_C2_CHANGE_DISABLE; > > > > > + csc_enable = v_CSC_ENABLE; > > > > > + } else { > > > > > + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > > > > > + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > > > > > + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > > > > > + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > > > > > + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > > > > > + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > > > > > + return 0; > > > > > + } > > > > > } > > > > > } > > > > > @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, > > > > > else > > > > > hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; > > > > > + hdmi->hdmi_data.rgb_limited_range = > > > > > + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; > > > > > + > > > > This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): > > > > https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ > > > I'm aware of that and I mentioned it in the cover letter. > > Sorry, I missed that part. > > > > > Your series is not merged yet and it didn't get much feedback so far. > > > What is the status there? > > It didn't have much reviews, but I'll hope to change that. For the > > patches 22 to 38 though, it doesn't really matter. Those changes are > > self-contained and can be applied as is outside of the series. > > > > > Especially because you are removing things from inno-hdmi driver (which > > > aren't really required to remove there) which will I have to reintroduce. > > I'm not entirely sure which part I remove that are actually going to be > > used here. > > I'm refering to [PATCH v5 33/44] which completly removes csc coeffs but this > series needs the CSC_RGB_0_255_TO_RGB_16_235_8BIT coeffs and [PATCH v5 > 29/44] which removes writing csc_coeffs to the hardware. Oh, right, feel free to drop those Maxime
On Thu, Dec 14, 2023 at 05:34:59PM +0100, Alex Bee wrote: > Hi Heiko, Hi Maxime, > > Am 14.12.23 um 12:36 schrieb Maxime Ripard: > > On Thu, Dec 14, 2023 at 12:17:34PM +0100, Heiko Stübner wrote: > > > Am Donnerstag, 14. Dezember 2023, 12:12:08 CET schrieb Alex Bee: > > > > Hi Maxime > > > > > > > > Am 14.12.23 um 08:56 schrieb Maxime Ripard: > > > > > Hi Alex, > > > > > > > > > > Thanks for working on this! > > > > > > > > > > On Wed, Dec 13, 2023 at 08:51:18PM +0100, Alex Bee wrote: > > > > > > The display controller will always give full range RGB regardless of the > > > > > > mode set, but HDMI requires certain modes to be transmitted in limited > > > > > > range RGB. This is especially required for HDMI sinks which do not support > > > > > > non-standard quantization ranges. > > > > > > > > > > > > This enables color space conversion for those modes and sets the > > > > > > quantization range accordingly in the AVI infoframe. > > > > > > > > > > > > Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support") > > > > > > Signed-off-by: Alex Bee <knaerzche@gmail.com> > > > > > > --- > > > > > > drivers/gpu/drm/rockchip/inno_hdmi.c | 40 ++++++++++++++++++++++------ > > > > > > 1 file changed, 32 insertions(+), 8 deletions(-) > > > > > > > > > > > > diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c > > > > > > index 345253e033c5..32626a75723c 100644 > > > > > > --- a/drivers/gpu/drm/rockchip/inno_hdmi.c > > > > > > +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c > > > > > > @@ -33,6 +33,7 @@ struct hdmi_data_info { > > > > > > unsigned int enc_in_format; > > > > > > unsigned int enc_out_format; > > > > > > unsigned int colorimetry; > > > > > > + bool rgb_limited_range; > > > > > > }; > > > > > > struct inno_hdmi_i2c { > > > > > > @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, > > > > > > else > > > > > > frame.avi.colorspace = HDMI_COLORSPACE_RGB; > > > > > > + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { > > > > > > + drm_hdmi_avi_infoframe_quant_range(&frame.avi, > > > > > > + &hdmi->connector, mode, > > > > > > + hdmi->hdmi_data.rgb_limited_range ? > > > > > > + HDMI_QUANTIZATION_RANGE_LIMITED : > > > > > > + HDMI_QUANTIZATION_RANGE_FULL); > > > > > > + } else { > > > > > > + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; > > > > > > + frame.avi.ycc_quantization_range = > > > > > > + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; > > > > > > + } > > > > > > + > > > > > > return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); > > > > > > } > > > > > > @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) > > > > > > if (data->enc_in_format == data->enc_out_format) { > > > > > > if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || > > > > > > (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { > > > > > > - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > > > > > > - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > > > > > > - > > > > > > - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > > > > > > - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > > > > > > - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > > > > > > - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > > > > > > - return 0; > > > > > > + if (data->enc_in_format == HDMI_COLORSPACE_RGB && > > > > > > + data->enc_out_format == HDMI_COLORSPACE_RGB && > > > > > > + hdmi->hdmi_data.rgb_limited_range) { > > > > > > + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; > > > > > > + auto_csc = AUTO_CSC_DISABLE; > > > > > > + c0_c2_change = C0_C2_CHANGE_DISABLE; > > > > > > + csc_enable = v_CSC_ENABLE; > > > > > > + } else { > > > > > > + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); > > > > > > + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); > > > > > > + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, > > > > > > + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, > > > > > > + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | > > > > > > + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); > > > > > > + return 0; > > > > > > + } > > > > > > } > > > > > > } > > > > > > @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, > > > > > > else > > > > > > hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; > > > > > > + hdmi->hdmi_data.rgb_limited_range = > > > > > > + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; > > > > > > + > > > > > This patch conflicts heavily with my inno_hdmi patches here (patches 22 to 38): > > > > > https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ > > > > I'm aware of that and I mentioned it in the cover letter. Your series is > > > > not merged yet and it didn't get much feedback so far. What is the > > > > status there? Especially because you are removing things from inno-hdmi > > > > driver (which aren't really required to remove there) which will I have > > > > to reintroduce. > > > Sadly I haven't found the time to look closer at Maxime's series so far, > > > but I got the impression that it separates into multiple cleanup steps > > > for a number of controllers. > > Yeah, one of the previous version comment was to support more > > controllers than vc4, which is fair. So I ended up reworking and > > converting multiple controllers, but most of the clean up changes can be > > applied outside of that series just fine. > > > > I just didn't find someone to test / review them yet :) > > I'm not exactly sure how to proceed here. Do you want me to: > > - base my patches on top of Maxime's series and reintroduce csc things (of > course only those which touch inno-hdmi w/o the framwork changes) > > - only apply the patches that do not touch csc things and base my series on > top of that > > - adapt Maxime's patches so that RGB full to RGB limited stays in there > > - wait with resend until Maxime's series is merged and reintroduce csc after > that > > - something else > > ? 2 or 3, at your discretion Maxime
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c index 345253e033c5..32626a75723c 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -33,6 +33,7 @@ struct hdmi_data_info { unsigned int enc_in_format; unsigned int enc_out_format; unsigned int colorimetry; + bool rgb_limited_range; }; struct inno_hdmi_i2c { @@ -308,6 +309,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, else frame.avi.colorspace = HDMI_COLORSPACE_RGB; + if (hdmi->hdmi_data.enc_out_format == HDMI_COLORSPACE_RGB) { + drm_hdmi_avi_infoframe_quant_range(&frame.avi, + &hdmi->connector, mode, + hdmi->hdmi_data.rgb_limited_range ? + HDMI_QUANTIZATION_RANGE_LIMITED : + HDMI_QUANTIZATION_RANGE_FULL); + } else { + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; + frame.avi.ycc_quantization_range = + HDMI_YCC_QUANTIZATION_RANGE_LIMITED; + } + return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_AVI, 0, 0, 0); } @@ -334,14 +347,22 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) if (data->enc_in_format == data->enc_out_format) { if ((data->enc_in_format == HDMI_COLORSPACE_RGB) || (data->enc_in_format >= HDMI_COLORSPACE_YUV444)) { - value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); - hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); - - hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, - m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, - v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | - v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); - return 0; + if (data->enc_in_format == HDMI_COLORSPACE_RGB && + data->enc_out_format == HDMI_COLORSPACE_RGB && + hdmi->hdmi_data.rgb_limited_range) { + csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT; + auto_csc = AUTO_CSC_DISABLE; + c0_c2_change = C0_C2_CHANGE_DISABLE; + csc_enable = v_CSC_ENABLE; + } else { + value = v_SOF_DISABLE | v_COLOR_DEPTH_NOT_INDICATED(1); + hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); + hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, + m_VIDEO_AUTO_CSC | m_VIDEO_C0_C2_SWAP, + v_VIDEO_AUTO_CSC(AUTO_CSC_DISABLE) | + v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE)); + return 0; + } } } @@ -458,6 +479,9 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, else hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; + hdmi->hdmi_data.rgb_limited_range = + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; + /* Mute video and audio output */ hdmi_modb(hdmi, HDMI_AV_MUTE, m_AUDIO_MUTE | m_VIDEO_BLACK, v_AUDIO_MUTE(1) | v_VIDEO_MUTE(1));