From patchwork Tue Dec 19 17:00:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Bee X-Patchwork-Id: 181115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2083958dyi; Tue, 19 Dec 2023 09:08:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQIZwwtYt+ivs+pCS0zzSyfLLynIecQhPVLLI3X5W1DcWAQ5rke7G5ZW/ghQrbv4UCu2zs X-Received: by 2002:a50:99da:0:b0:553:4841:9c3e with SMTP id n26-20020a5099da000000b0055348419c3emr2344655edb.55.1703005680999; Tue, 19 Dec 2023 09:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703005680; cv=none; d=google.com; s=arc-20160816; b=HCoKG7ej9Nv03N9Oz9QJAtwLIu+5zUUvq/k8R6JVGZHSrXxt2RTCbVpjZDHlWEjQ7o pJ/OHGYeAUlBgHJgbpzIqPT9z2dnu3GmYZ9tP4oAyzCChTiuFlVaIYIf7rtTXSnnjjHQ SKYZXafQToJtF6SFsJrKdGMzWRkE2DCOffhMyEoAzCfUn0KL8QNctYsKiQFG+6+T62bj IShyH+5QmP/M67Ro9ERoOLVMnUjQEMjR0uSOwnR941NAmziIgC/dEtvl8679V/SijwoU FkQ4zLQiByggk8BaSv7fvuDJzXfy/HmbaK/tMsWgPvCXRKn/fMDlgsBMcWGvQ6lhy3u2 fjBA== 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=XAqGTQIWGOGvPcvI30gGZkG+UcVd1X4ARFNZ3GdyHUM=; fh=k7ZhfSDxugAUNAX9PFQjqQnTRGZ+rgCl5CN8/TdzbyU=; b=UZI+hJZM3vKrAV8giEeHTNS3wqc7hQJ2BPPoCGGz7vf0tWBHuhiuDWaIpjpAzhTc3Z F59EpWXOUbZlz79UdOuiWjk2GfKp2iFpioGS3akCHFAf6/qxh0KSOmUN5BVfaDiRZa7Y tH5nMwyj9tzdWFx7vB1WHCaB5nF5p3SmMG7Rxlrn/H0RzmvxTHKMZyhg5GH9NsZrnKDW GX+vAfxTMb2U3iL6UsNgf/vZt5NYon8AS3ffkP0mJ3FsPqHWzj3W/G9SCFVK70A4/E9u 5Fr1byjPtOpC7rkeOEUPZ3GkZM3dJFg3sVnPeZbrIYj0qFj7QozsaDtCfbIoAI3wzgIf ZgDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VAM4IcSY; spf=pass (google.com: domain of linux-kernel+bounces-5639-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5639-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q21-20020a50cc95000000b00553429d5597si2196347edi.271.2023.12.19.09.08.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:08:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5639-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VAM4IcSY; spf=pass (google.com: domain of linux-kernel+bounces-5639-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5639-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7307A1F22CE4 for ; Tue, 19 Dec 2023 17:08:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33BA222331; Tue, 19 Dec 2023 17:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VAM4IcSY" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 7856D3B2A5; Tue, 19 Dec 2023 17:01:27 +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-f47.google.com with SMTP id 5b1f17b1804b1-40c48d7a7a7so45245385e9.3; Tue, 19 Dec 2023 09:01:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703005285; x=1703610085; 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=XAqGTQIWGOGvPcvI30gGZkG+UcVd1X4ARFNZ3GdyHUM=; b=VAM4IcSYWkyTcOjVaSfOt98LjymzjxhGteAPPd8uxijcs/v3S9k0f4TInY6aiOS8f+ TKbvZBVgB4oIoi9+7zS8Iq7OiESZWinp1WxuGI5ykhsmo9tRXW1uuX79721NMZSjGOuQ XEk4LzQNTjivkO/IP2WfZcBQwwA08IZVbdXygCglenUAPISTAvZ6T3HBhKuTs2mzPexP fttmQ7rN0rKbcY1Z5Z2e1uYU6xb09WKTtJfATqNtF7/eXawfF0ByHAwg51fZwm9MHhu8 A8DQjyPFfB8BWYa22zdZsPtU+V7UW+veAUPsQd0Awws2OSR3PTOrXwwZoAA5IJp7Edmp zXzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703005285; x=1703610085; 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=XAqGTQIWGOGvPcvI30gGZkG+UcVd1X4ARFNZ3GdyHUM=; b=Q4Uf5Bo1p2VWmEvzgWesohO/WN5QPGy+XoNwq9JXQNBVNCfrC2cMG51j+eU3Sx90EC bhWHaCwGMroMtVJvsGCnBDcxGf241MFG2b7mX4bPoh6hEW3nP3knDR/AUm5sOgYFCpCA dOyLoF6GTCY+XPedEg1TdrgC9D09dHdchDtZkNo6GyxMsgz4udn98d5IUQ7lw8arfdne 16B7whYsFsvZzHLAm0FygyEL/OO4xD5Wx7Q94Mt6mOd/cSWIIo83GJahSYOpW1yLwMdg jMl6tFCZKKln3HJ3eoWJSqBX26LyTg2nf2y7SLojKRp0Gd0Tsw6ngTPg5Wtd0OlBgr+Q NMeg== X-Gm-Message-State: AOJu0YwgyJCLkZGzTjc4HJxb+DM8QJtao6+vkE1s+1Z6niTwkdggzKh9 dX2EHF23GWQXg+biHunNTQ== X-Received: by 2002:a05:600c:3b06:b0:40c:3158:6467 with SMTP id m6-20020a05600c3b0600b0040c31586467mr10786965wms.1.1703005285545; Tue, 19 Dec 2023 09:01:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:01:25 -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 20/29] drm/rockchip: inno_hdmi: Correctly setup HDMI quantization range Date: Tue, 19 Dec 2023 18:00:50 +0100 Message-ID: <20231219170100.188800-21-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: 1785730884850048853 X-GMAIL-MSGID: 1785730884850048853 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. Signed-off-by: Alex Bee --- changes in v2: - made rgb_limited_range part of the new custom connector state changes in v3: - moved assignment of rgb_limited_range to atomic check drivers/gpu/drm/rockchip/inno_hdmi.c | 60 +++++++++++++++++++--------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c index 7ce5836fc80d..e6d37772500c 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -53,6 +53,7 @@ struct inno_hdmi_connector_state { struct drm_connector_state base; unsigned int enc_out_format; unsigned int colorimetry; + bool rgb_limited_range; }; static struct inno_hdmi *encoder_to_inno_hdmi(struct drm_encoder *encoder) @@ -270,6 +271,18 @@ static int inno_hdmi_config_video_avi(struct inno_hdmi *hdmi, else frame.avi.colorspace = HDMI_COLORSPACE_RGB; + if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_RGB) { + drm_hdmi_avi_infoframe_quant_range(&frame.avi, + connector, mode, + inno_conn_state->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, &frame, HDMI_INFOFRAME_TYPE_AVI); } @@ -297,29 +310,37 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL2, value); if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_RGB) { - 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 (inno_conn_state->colorimetry == HDMI_COLORIMETRY_ITU_601) { - if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_YUV444) { - csc_mode = CSC_RGB_0_255_TO_ITU601_16_235_8BIT; + if (inno_conn_state->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; } } else { - if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_YUV444) { - csc_mode = CSC_RGB_0_255_TO_ITU709_16_235_8BIT; - auto_csc = AUTO_CSC_DISABLE; - c0_c2_change = C0_C2_CHANGE_DISABLE; - csc_enable = v_CSC_ENABLE; + if (inno_conn_state->colorimetry == HDMI_COLORIMETRY_ITU_601) { + if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_YUV444) { + csc_mode = CSC_RGB_0_255_TO_ITU601_16_235_8BIT; + auto_csc = AUTO_CSC_DISABLE; + c0_c2_change = C0_C2_CHANGE_DISABLE; + csc_enable = v_CSC_ENABLE; + } + } else { + if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_YUV444) { + csc_mode = CSC_RGB_0_255_TO_ITU709_16_235_8BIT; + auto_csc = AUTO_CSC_DISABLE; + c0_c2_change = C0_C2_CHANGE_DISABLE; + csc_enable = v_CSC_ENABLE; + } } } @@ -473,6 +494,8 @@ inno_hdmi_encoder_atomic_check(struct drm_encoder *encoder, inno_conn_state->colorimetry = HDMI_COLORIMETRY_ITU_709; inno_conn_state->enc_out_format = HDMI_COLORSPACE_RGB; + inno_conn_state->rgb_limited_range = + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; return 0; } @@ -543,6 +566,7 @@ static void inno_hdmi_connector_reset(struct drm_connector *connector) inno_conn_state->colorimetry = HDMI_COLORIMETRY_ITU_709; inno_conn_state->enc_out_format = HDMI_COLORSPACE_RGB; + inno_conn_state->rgb_limited_range = false; } static struct drm_connector_state *