From patchwork Tue Oct 31 16:48:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 160241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp372988vqg; Tue, 31 Oct 2023 09:49:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcl8PYGD04okvFraOWBQ14DIz5FCpGVTVHz3BFxNZaHHKLba1TvptDzB/0AIJfHrJ8h+xs X-Received: by 2002:a05:6a21:27a4:b0:170:3e5b:bccd with SMTP id rn36-20020a056a2127a400b001703e5bbccdmr11589728pzb.30.1698770978052; Tue, 31 Oct 2023 09:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698770978; cv=none; d=google.com; s=arc-20160816; b=yJcSa0yA/fTSMSUPseyAnGs2ym7cORzmaLhVEWoM2P3oPSwW6YlZYwFJ8N2tU40mEG 8tIYNWjv+jgDFYkztxFrfwj0ZPmfJ013Ev2/oAJmPOdEidYOF/V1kxM55s71aGrTySsr 1AIAF27j7Jsr3fvD5rTwIzb87n7Q+nxCf4PMB1a6SkTg3QbgydxKNTcviiqpuuSqPZ2t Cc3m4Wp+IA8S0CFc8GjcWPFxweN/7opRqk04n/A/OWZgQlj3oa+dHI6NvJmlGEtZmP0U GgM9F2IpwAWsTiojmhZt6eijzBWW1kWvWu68wpVmU8y5llokwwU5VJD1UDiBVjOHtBux WQEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=PMaUfLhGn0MoCilM0mT3ZdH9cLLmtP+Is5G2vye4ZKU=; fh=e6/uyeFf2k7v8JUtB6fPyaAS5iN3eSA1hjtg35V2Rzw=; b=0/LEFFNXCoN9TcI2t9gdGhG4fk3iYzL0RnSzrB/l0AWoQFHRC+T/A+n3f4ZqJMjuf7 f7wKpsmhelMkjpLTnRkrr3+pEK+lUOQzCWJROBL8KYdZhSV1Azg8aZWkI7Nz3Cf1LtT3 fm7uEiqhWBlfOjWQjHl3sfV76PBpOcMFYIXh4kbAO6046i5vHNM1JACRipEBrFLAnJWf PArsQ4nW/3Im4TZ5o56SWXtwC14qYJaWDYN7m7L1jQxwijZn5RwXJreZ5+eK/zzQR+Og VI7TzgKT9O8vFBTbQuXE0CbeIcfcc0MkUMgUZZnYXwm8oErgD5V1URsalMqPfYnBDw2+ YNAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XDiUakTL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id g187-20020a636bc4000000b005abf640eec5si1267512pgc.171.2023.10.31.09.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:49:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XDiUakTL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0248B802B0CD; Tue, 31 Oct 2023 09:49:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346643AbjJaQtP (ORCPT + 33 others); Tue, 31 Oct 2023 12:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346518AbjJaQsw (ORCPT ); Tue, 31 Oct 2023 12:48:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D317D102; Tue, 31 Oct 2023 09:48:49 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E446FC433C8; Tue, 31 Oct 2023 16:48:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698770929; bh=NE9ZQi0quukkEFgUc0oJfWhNAR8pjL+9EmU2GJrMnDw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XDiUakTLpif9725+Vda0ONBIPTrOjSbkaSKI43oCZPRpyEg0gTEY47YatadFNSPZu 8zh8GOYPkB9bmHyoNqbVn1ZN7sxJQVtwZf6HLJN6sBvNsNACYSkUl5V8UByi7hKkOL 4LBPNr/zxOct1HoMOEzK+2KeGkgVN+cMOW4TCEk+WFE5NwpZK894AngVEpyTEee07F xHMCYJnb/BZPp5TpEqoECa1zd/PO6yzbAGHm0LSOOM3H/OYJzctwHw/V3551QVYT99 0HL3oHisbzZtYkaBaTDL5jhK0DgRB8/8oNWAcD1rZKtEEWvorEF6630kRlNd3pBite K76+Ocf2WaZ9Q== From: Maxime Ripard Date: Tue, 31 Oct 2023 17:48:18 +0100 Subject: [PATCH RFC v3 05/37] drm/connector: hdmi: Add output BPC to the connector state MIME-Version: 1.0 Message-Id: <20231031-kms-hdmi-connector-state-v3-5-328b0fae43a7@kernel.org> References: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org> In-Reply-To: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Hans Verkuil , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5152; i=mripard@kernel.org; h=from:subject:message-id; bh=NE9ZQi0quukkEFgUc0oJfWhNAR8pjL+9EmU2GJrMnDw=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmO+nf/L9EIj++dKN20a8/JzcLth77NXLTCvJNPdHb6u QVtV97JdpSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAim6oYGR5ZiG62sGK4EOet tzfRjfHfhbdn5k3xTuywL3vfaSFy+xPDP9UZysyKF1I8/mzoVmRe3sy+aD1H86d3kg15tYV/2Ds ZuAE= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:49:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781290476959425558 X-GMAIL-MSGID: 1781290476959425558 We'll add automatic selection of the output BPC in a following patch, but let's add it to the HDMI connector state already. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/drm_atomic.c | 1 + drivers/gpu/drm/drm_atomic_state_helper.c | 8 +++++++- drivers/gpu/drm/drm_connector.c | 20 +++++++++++++++++++- include/drm/drm_connector.h | 13 ++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 55cb117cd49a..51aac1b2aaaf 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1147,6 +1147,7 @@ static void drm_atomic_connector_print_state(struct drm_printer *p, drm_printf(p, "\tbroadcast_rgb=%s\n", drm_hdmi_connector_get_broadcast_rgb_name(state->hdmi.broadcast_rgb)); drm_printf(p, "\tis_full_range=%c\n", state->hdmi.is_full_range ? 'y' : 'n'); + drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc); } if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index c3f124af64dc..406ba358aa14 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -570,6 +570,11 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset); void __drm_atomic_helper_connector_hdmi_reset(struct drm_connector *connector, struct drm_connector_state *new_state) { + unsigned int max_bpc = connector->max_bpc; + + new_state->max_bpc = max_bpc; + new_state->max_requested_bpc = max_bpc; + new_state->hdmi.output_bpc = max_bpc; new_state->hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; } EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset); @@ -686,7 +691,8 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, new_state->hdmi.is_full_range = hdmi_is_full_range(connector, new_state); - if (old_state->hdmi.broadcast_rgb != new_state->hdmi.broadcast_rgb) { + if (old_state->hdmi.broadcast_rgb != new_state->hdmi.broadcast_rgb || + old_state->hdmi.output_bpc != new_state->hdmi.output_bpc) { struct drm_crtc *crtc = new_state->crtc; struct drm_crtc_state *crtc_state; diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 36d728e811ae..508d1c667732 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -459,6 +459,7 @@ EXPORT_SYMBOL(drmm_connector_init); * @funcs: callbacks for this connector * @connector_type: user visible type of the connector * @ddc: optional pointer to the associated ddc adapter + * @max_bpc: Maximum bits per char the HDMI connector supports * * Initialises a preallocated HDMI connector. Connectors can be * subclassed as part of driver connector objects. @@ -475,7 +476,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs, int connector_type, - struct i2c_adapter *ddc) + struct i2c_adapter *ddc, + unsigned int max_bpc) { int ret; @@ -487,6 +489,22 @@ int drmm_connector_hdmi_init(struct drm_device *dev, if (ret) return ret; + if (max_bpc) { + if (!(max_bpc == 8 || max_bpc == 10 || max_bpc == 12)) + return -EINVAL; + + /* + * drm_connector_attach_max_bpc_property() requires the + * connector to have a state. + */ + if (connector->funcs->reset) + connector->funcs->reset(connector); + + drm_connector_attach_hdr_output_metadata_property(connector); + drm_connector_attach_max_bpc_property(connector, 8, max_bpc); + connector->max_bpc = max_bpc; + } + return 0; } EXPORT_SYMBOL(drmm_connector_hdmi_init); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fc1fa754a40d..2d664b6ac0a6 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1059,6 +1059,11 @@ struct drm_connector_state { * RGB Quantization Range or not? */ bool is_full_range; + + /** + * @output_bpc: Bits per color channel to output. + */ + unsigned int output_bpc; } hdmi; }; @@ -1703,6 +1708,11 @@ struct drm_connector { */ struct drm_property_blob *path_blob_ptr; + /** + * @max_bpc: Maximum bits per color channel the connector supports. + */ + unsigned int max_bpc; + /** * @max_bpc_property: Default connector property for the max bpc to be * driven out of the connector. @@ -1942,7 +1952,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs, int connector_type, - struct i2c_adapter *ddc); + struct i2c_adapter *ddc, + unsigned int max_bpc); void drm_connector_attach_edid_property(struct drm_connector *connector); int drm_connector_register(struct drm_connector *connector); void drm_connector_unregister(struct drm_connector *connector);