From patchwork Wed Dec 13 19:51:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Bee X-Patchwork-Id: 178282 Return-Path: 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 + 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 ); 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 To: Sandy Huang , =?utf-8?q?Heiko_St=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 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 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: 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 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 --- 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; + /* 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));