From patchwork Tue Jan 9 18:10:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andri Yngvason X-Patchwork-Id: 13520754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6DE0C47258 for ; Tue, 16 Jan 2024 12:28:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BDEA010E555; Tue, 16 Jan 2024 12:28:13 +0000 (UTC) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 65CC810E4C0 for ; Tue, 9 Jan 2024 18:11:23 +0000 (UTC) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40d6b4e2945so38967225e9.0 for ; Tue, 09 Jan 2024 10:11:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yngvason.is; s=google; t=1704823882; x=1705428682; darn=lists.freedesktop.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=j5TmlSqr2R0DSFOwP1jgxjjJC7p4LGOYCLeSujiTr2s=; b=NKCsu7OQaYqUVnTtK0YHAPYDu4Zx1rUDr03LvnGrqVfiWy0XI0IXRt3ilgiesLbrqs atlDRzuImJT0yj/l6kTfscl/DavmYRudG3qBy9aQoCGvuEzFPnSiC1JWuLXr6DB0LD1s t9DQEoYbTVA5tOGG2SO/8TP0uvL346AI9h2y0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704823882; x=1705428682; 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=j5TmlSqr2R0DSFOwP1jgxjjJC7p4LGOYCLeSujiTr2s=; b=Sz8LSV1STR92cV55/SWpqv+nDFZdJGRIkHOhKAywNrGHZdw7OhpeUrjU3hgcxBmUvB PioyiofmjMzR49B9icfLA73WuHEvoZcxt+5HKuHprbeGFqUczlKjQ8ooq1RfWoeHst9U kOBEgTPGa/YffHvsLxv1+nMAhpTl8CvTEBQrOtPwaeG5YDtW6lghfecBwBm0ZUh2yHdJ E2RjgwKHBQPr+RYBo5+WfsYx3HtVMdvzQiMksYkyIb1daXs8FHsNi1SNZnRvvUfD6ePe fMA+nJ+Vaa38B19L4EK86x5IBkl+2eZiO+DCneepTI80ITQvGn2XWBi8MbFj4FFEYHf0 39PQ== X-Gm-Message-State: AOJu0YypdV4RKrqqlb9rO6Y3HxgLY/5uupm3MRF5DD8AYs8po7IVB2NB 3UeHHOP1Mayvdp1ceNA6N4/lhbeWqNa2TQ== X-Google-Smtp-Source: AGHT+IE8mUwmBNyBZAX/TyOCIvUTmkvOp0uvsitYL/5KGkF2V5MZ5MAl58F6Q1VC6O24Tg7pMyScTA== X-Received: by 2002:a05:600c:468b:b0:40d:8909:b3a3 with SMTP id p11-20020a05600c468b00b0040d8909b3a3mr2205592wmo.20.1704823881662; Tue, 09 Jan 2024 10:11:21 -0800 (PST) Received: from andri-workstation.turninn.appdynamic.com ([2a01:8280:aa07:ad:7285:c2ff:fef0:4baf]) by smtp.gmail.com with ESMTPSA id n25-20020a05600c3b9900b0040e527602c8sm2104579wms.9.2024.01.09.10.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:11:21 -0800 (PST) From: Andri Yngvason To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Subject: [PATCH 1/7] drm/amd/display: Remove unnecessary SIGNAL_TYPE_HDMI_TYPE_A check Date: Tue, 9 Jan 2024 18:10:58 +0000 Message-ID: <20240109181104.1670304-2-andri@yngvason.is> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109181104.1670304-1-andri@yngvason.is> References: <20240109181104.1670304-1-andri@yngvason.is> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Jan 2024 12:28:11 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, Simon Ser , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andri Yngvason , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Werner Sembach Remove unnecessary SIGNAL_TYPE_HDMI_TYPE_A check that was performed in the drm_mode_is_420_only() case, but not in the drm_mode_is_420_also() && force_yuv420_output case. Without further knowledge if YCbCr 4:2:0 is supported outside of HDMI, there is no reason to use RGB when the display reports drm_mode_is_420_only() even on a non HDMI connection. This patch also moves both checks in the same if-case. This eliminates an extra else-if-case. Signed-off-by: Werner Sembach Signed-off-by: Andri Yngvason Tested-by: Andri Yngvason --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index c8c00c2a5224a..10e041a3b2545 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -5524,10 +5524,7 @@ static void fill_stream_properties_from_drm_display_mode( timing_out->v_border_bottom = 0; /* TODO: un-hardcode */ if (drm_mode_is_420_only(info, mode_in) - && stream->signal == SIGNAL_TYPE_HDMI_TYPE_A) - timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420; - else if (drm_mode_is_420_also(info, mode_in) - && aconnector->force_yuv420_output) + || (drm_mode_is_420_also(info, mode_in) && aconnector->force_yuv420_output)) timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420; else if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR444) && stream->signal == SIGNAL_TYPE_HDMI_TYPE_A) From patchwork Tue Jan 9 18:10:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andri Yngvason X-Patchwork-Id: 13520748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 519DAC47077 for ; Tue, 16 Jan 2024 12:28:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B46BE10E523; Tue, 16 Jan 2024 12:28:12 +0000 (UTC) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CB2710E4CA for ; Tue, 9 Jan 2024 18:11:30 +0000 (UTC) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40e490c2115so12886965e9.0 for ; Tue, 09 Jan 2024 10:11:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yngvason.is; s=google; t=1704823888; x=1705428688; darn=lists.freedesktop.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=iv1CfwfAn7ER1wsoqgpUMaFNsB1LA0XxFCM2c1c7OSw=; b=HLEdhawx9TLy78EIHTLt/ln1N8Nn5Ak/7DVVMBVFgB96qMgl5xIyjzDQ3PTkrzI2Hb KMp0A4gLwV1zAU04RFPSuBWIKE2EaQfhwSZFNtkTAtYbBo3i/LW8auhn4a7QEvqoRS5V xD24tVVVRZzUSsPriO7Uh0zGZJ5EEj/WZCXac= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704823888; x=1705428688; 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=iv1CfwfAn7ER1wsoqgpUMaFNsB1LA0XxFCM2c1c7OSw=; b=O53HCcABa7jDmBxTAkm2mkBM3ZHAuw82JZgFrCV7ljTsleZgeXp6iFZMmg/jnSclsJ vSuyEm1t6fpOml75j2hlu7/hzRSq/yIdz9kz/63B8iC7+yj+XS0yAUbsTMK/kCA1zDgg dhA9hqlwozFFZj9af38U1fWFYD3aLywRTNYxPP5s6rHijIf9VMPe1zIF++Ze7sRF9W5t RVyFfqTAHnpbU5rcb2QJME1ketKqzbeawZiU7ByqvKeTQ4ogrtRau+HfhpkjGi/fEe54 Hu27heY1AZGrIP4ykR0TcoxtrIGmShOMK3Ri7nr1shEZfaodYjjTcTvGV2MGQL+RIaQ3 C/CQ== X-Gm-Message-State: AOJu0YwQZYaDLufCh8pH/X9wePaCsWy7rc5cq0hKZSRlYI3j+VBexFMU XA9RhU3o0ErAjSfhy6UfNXOyG9lPPUlSfw== X-Google-Smtp-Source: AGHT+IHW+vnqtWq9qmMkX3cIDIbzoDHeml8A7NAyBIdCumvkqdPXyTH0vlksZ0ndiZHQzAVFE7zyJg== X-Received: by 2002:a05:600c:298c:b0:40d:5aea:c89b with SMTP id r12-20020a05600c298c00b0040d5aeac89bmr648932wmd.64.1704823888508; Tue, 09 Jan 2024 10:11:28 -0800 (PST) Received: from andri-workstation.turninn.appdynamic.com ([2a01:8280:aa07:ad:7285:c2ff:fef0:4baf]) by smtp.gmail.com with ESMTPSA id n25-20020a05600c3b9900b0040e527602c8sm2104579wms.9.2024.01.09.10.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:11:27 -0800 (PST) From: Andri Yngvason To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Subject: [PATCH 2/7] drm/uAPI: Add "active color format" drm property as feedback for userspace Date: Tue, 9 Jan 2024 18:10:59 +0000 Message-ID: <20240109181104.1670304-3-andri@yngvason.is> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109181104.1670304-1-andri@yngvason.is> References: <20240109181104.1670304-1-andri@yngvason.is> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Jan 2024 12:28:11 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, Simon Ser , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andri Yngvason , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Werner Sembach Add a new general drm property "active color format" which can be used by graphic drivers to report the used color format back to userspace. There was no way to check which color format got actually used on a given monitor. To surely predict this, one must know the exact capabilities of the monitor, the GPU, and the connection used and what the default behaviour of the used driver is (e.g. amdgpu prefers YCbCr 4:4:4 while i915 prefers RGB). This property helps eliminating the guessing on this point. In the future, automatic color calibration for screens might also depend on this information being available. Signed-off-by: Werner Sembach Signed-off-by: Andri Yngvason Tested-by: Andri Yngvason --- drivers/gpu/drm/drm_connector.c | 63 +++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 10 ++++++ 2 files changed, 73 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index c3725086f4132..30d62e505d188 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1061,6 +1061,14 @@ static const struct drm_prop_enum_list drm_dp_subconnector_enum_list[] = { { DRM_MODE_SUBCONNECTOR_Native, "Native" }, /* DP */ }; +static const struct drm_prop_enum_list drm_active_color_format_enum_list[] = { + { 0, "not applicable" }, + { DRM_COLOR_FORMAT_RGB444, "rgb" }, + { DRM_COLOR_FORMAT_YCBCR444, "ycbcr444" }, + { DRM_COLOR_FORMAT_YCBCR422, "ycbcr422" }, + { DRM_COLOR_FORMAT_YCBCR420, "ycbcr420" }, +}; + DRM_ENUM_NAME_FN(drm_get_dp_subconnector_name, drm_dp_subconnector_enum_list) @@ -1390,6 +1398,15 @@ static const u32 dp_colorspaces = * drm_connector_attach_max_bpc_property() to create and attach the * property to the connector during initialization. * + * active color format: + * This read-only property tells userspace the color format actually used + * by the hardware display engine "on the cable" on a connector. The chosen + * value depends on hardware capabilities, both display engine and + * connected monitor. Drivers shall use + * drm_connector_attach_active_color_format_property() to install this + * property. Possible values are "not applicable", "rgb", "ycbcr444", + * "ycbcr422", and "ycbcr420". + * * Connectors also have one standardized atomic property: * * CRTC_ID: @@ -2451,6 +2468,52 @@ int drm_connector_attach_max_bpc_property(struct drm_connector *connector, } EXPORT_SYMBOL(drm_connector_attach_max_bpc_property); +/** + * drm_connector_attach_active_color_format_property - attach "active color format" property + * @connector: connector to attach active color format property on. + * + * This is used to check the applied color format on a connector. + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_connector_attach_active_color_format_property(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_property *prop; + + if (!connector->active_color_format_property) { + prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, "active color format", + drm_active_color_format_enum_list, + ARRAY_SIZE(drm_active_color_format_enum_list)); + if (!prop) + return -ENOMEM; + + connector->active_color_format_property = prop; + } + + drm_object_attach_property(&connector->base, prop, 0); + + return 0; +} +EXPORT_SYMBOL(drm_connector_attach_active_color_format_property); + +/** + * drm_connector_set_active_color_format_property - sets the active color format property for a + * connector + * @connector: drm connector + * @active_color_format: color format for the connector currently active "on the cable" + * + * Should be used by atomic drivers to update the active color format over a connector. + */ +void drm_connector_set_active_color_format_property(struct drm_connector *connector, + u32 active_color_format) +{ + drm_object_property_set_value(&connector->base, connector->active_color_format_property, + active_color_format); +} +EXPORT_SYMBOL(drm_connector_set_active_color_format_property); + /** * drm_connector_attach_hdr_output_metadata_property - attach "HDR_OUTPUT_METADA" property * @connector: connector to attach the property on. diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fe88d7fc6b8f4..9ae73cfdceeb1 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1699,6 +1699,12 @@ struct drm_connector { */ struct drm_property *privacy_screen_hw_state_property; + /** + * @active_color_format_property: Default connector property for the + * active color format to be driven out of the connector. + */ + struct drm_property *active_color_format_property; + #define DRM_CONNECTOR_POLL_HPD (1 << 0) #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) @@ -2053,6 +2059,10 @@ void drm_connector_attach_privacy_screen_provider( struct drm_connector *connector, struct drm_privacy_screen *priv); void drm_connector_update_privacy_screen(const struct drm_connector_state *connector_state); +int drm_connector_attach_active_color_format_property(struct drm_connector *connector); +void drm_connector_set_active_color_format_property(struct drm_connector *connector, + u32 active_color_format); + /** * struct drm_tile_group - Tile group metadata * @refcount: reference count From patchwork Tue Jan 9 18:11:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andri Yngvason X-Patchwork-Id: 13520757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC3CAC4706C for ; Tue, 16 Jan 2024 12:28:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D34810E562; Tue, 16 Jan 2024 12:28:14 +0000 (UTC) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by gabe.freedesktop.org (Postfix) with ESMTPS id E179210E4B8 for ; Tue, 9 Jan 2024 18:11:34 +0000 (UTC) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40e5521db08so136915e9.2 for ; Tue, 09 Jan 2024 10:11:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yngvason.is; s=google; t=1704823893; x=1705428693; darn=lists.freedesktop.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=Ab6S82YVhL2fQWMl7n/iDflNvLFt/phlZFbHK/9RmUw=; b=K28g2QfdMDcMTjFibWYy4vS14Ld8cEvw/fXbFL/qO84S6D4C6gK4be2aKc9yx6yb13 vCNqvDTdjPGdhYEvo1BNg+PI2Rd1CBiawxCScDjsAsH5YpgYnPVs0BboQrtItbzsQ/E0 8lHHorWvzHM1Ymq1UuUvxpbp0vlaCSy+HbI8E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704823893; x=1705428693; 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=Ab6S82YVhL2fQWMl7n/iDflNvLFt/phlZFbHK/9RmUw=; b=R0XK1vRGCfifHlaDU7Lq2oRmidKxr/JAECVtSn3dTRNVs/wpiNPBsdjt+N644SJLJG AUEV4tMYImr08XsIkU2BpBXjSOD8bOgJQtPYKosZLw141BoZL+rSTVWRUviDM3rnNYEe 1TuQY5oThNKkn/vME6uM+klqf0AAZt28bq3kWBXRUb5SVQr2UGv61Kmtg87skemRtOiv TjSOzfE1oUPeIoJDBLefulbnSD46Kuex1HmwPp31f5MCY+/3prKCryXGeOSW5d76V1ov JcuRbRLqDF4UJ2tc+XJMqlSzM2gkYu7hhSatJUqPqJ+cg4EHnV/+wZ5oki4a8togdzA6 GXTA== X-Gm-Message-State: AOJu0YxCvND+PN10oK6F9rcMOUY9x2ETKcLJEqxdvAGWRAyZLVtDXnlW pWUQnYB+Sfp0OQtg7Hsa/5KMSLa6ebIkGA== X-Google-Smtp-Source: AGHT+IECX0laRRtfF4jvavSEkKwLcA9a4P5MCiLvTCxN6JaHCGAk1yoL0mgxvPQHa7eWzawwSwZVFQ== X-Received: by 2002:a05:600c:1c20:b0:40e:53f8:5242 with SMTP id j32-20020a05600c1c2000b0040e53f85242mr186194wms.72.1704823893245; Tue, 09 Jan 2024 10:11:33 -0800 (PST) Received: from andri-workstation.turninn.appdynamic.com ([2a01:8280:aa07:ad:7285:c2ff:fef0:4baf]) by smtp.gmail.com with ESMTPSA id n25-20020a05600c3b9900b0040e527602c8sm2104579wms.9.2024.01.09.10.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:11:32 -0800 (PST) From: Andri Yngvason To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Subject: [PATCH 3/7] drm/amd/display: Add handling for new "active color format" property Date: Tue, 9 Jan 2024 18:11:00 +0000 Message-ID: <20240109181104.1670304-4-andri@yngvason.is> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109181104.1670304-1-andri@yngvason.is> References: <20240109181104.1670304-1-andri@yngvason.is> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Jan 2024 12:28:11 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, Simon Ser , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andri Yngvason , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Werner Sembach This commit implements the "active color format" drm property for the AMD GPU driver. Signed-off-by: Werner Sembach Signed-off-by: Andri Yngvason Tested-by: Andri Yngvason --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 42 ++++++++++++++++++- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 4 ++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 10e041a3b2545..b44d06c3b1706 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6882,6 +6882,24 @@ int convert_dc_color_depth_into_bpc(enum dc_color_depth display_color_depth) return 0; } +static int convert_dc_pixel_encoding_into_drm_color_format( + enum dc_pixel_encoding display_pixel_encoding) +{ + switch (display_pixel_encoding) { + case PIXEL_ENCODING_RGB: + return DRM_COLOR_FORMAT_RGB444; + case PIXEL_ENCODING_YCBCR422: + return DRM_COLOR_FORMAT_YCBCR422; + case PIXEL_ENCODING_YCBCR444: + return DRM_COLOR_FORMAT_YCBCR444; + case PIXEL_ENCODING_YCBCR420: + return DRM_COLOR_FORMAT_YCBCR420; + default: + break; + } + return 0; +} + static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) @@ -7436,8 +7454,10 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm, adev->mode_info.underscan_vborder_property, 0); - if (!aconnector->mst_root) + if (!aconnector->mst_root) { drm_connector_attach_max_bpc_property(&aconnector->base, 8, 16); + drm_connector_attach_active_color_format_property(&aconnector->base); + } aconnector->base.state->max_bpc = 16; aconnector->base.state->max_requested_bpc = aconnector->base.state->max_bpc; @@ -8969,6 +8989,26 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) kfree(dummy_updates); } + /* Extract information from crtc to communicate it to userspace as connector properties */ + for_each_new_connector_in_state(state, connector, new_con_state, i) { + struct drm_crtc *crtc = new_con_state->crtc; + struct dc_stream_state *stream; + + if (crtc) { + new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc); + dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); + stream = dm_new_crtc_state->stream; + + if (stream) { + drm_connector_set_active_color_format_property(connector, + convert_dc_pixel_encoding_into_drm_color_format( + dm_new_crtc_state->stream->timing.pixel_encoding)); + } + } else { + drm_connector_set_active_color_format_property(connector, 0); + } + } + /** * Enable interrupts for CRTCs that are newly enabled or went through * a modeset. It was intentionally deferred until after the front end diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c index 11da0eebee6c4..a4d1b3ea8f81c 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c @@ -600,6 +600,10 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, if (connector->max_bpc_property) drm_connector_attach_max_bpc_property(connector, 8, 16); + connector->active_color_format_property = master->base.active_color_format_property; + if (connector->active_color_format_property) + drm_connector_attach_active_color_format_property(&aconnector->base); + connector->vrr_capable_property = master->base.vrr_capable_property; if (connector->vrr_capable_property) drm_connector_attach_vrr_capable_property(connector); From patchwork Tue Jan 9 18:11:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andri Yngvason X-Patchwork-Id: 13520751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DC28C47DA6 for ; Tue, 16 Jan 2024 12:28:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C77C010E530; Tue, 16 Jan 2024 12:28:12 +0000 (UTC) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A56210E4CA for ; Tue, 9 Jan 2024 18:11:39 +0000 (UTC) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40e4d1e0e5eso12117745e9.3 for ; Tue, 09 Jan 2024 10:11:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yngvason.is; s=google; t=1704823897; x=1705428697; darn=lists.freedesktop.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=xEKXGZp6/dSPIf69wGEjjsLtzr50iEJJm//VReGTJdM=; b=e7dVL4/9X3KP6AOHyICkULy/Vrx+951G8CI5+K1pg280zwgVt+VRSVg214a29EEATp AGSiEjzySUQlodBdHmGLS68Oxwga52epfKxNHNPvXrGk4s7mBhuCb5gueUNWQmhCUESY GTcVkjaWuMBV3kRMwPLoz3dJPNBpAn6WvXrGg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704823897; x=1705428697; 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=xEKXGZp6/dSPIf69wGEjjsLtzr50iEJJm//VReGTJdM=; b=uZnTkRco6omKq8QkHcxRw/hbj/vMEDOCRcr3HCn4GEVmA2n00XPJnmyCr6s0CssrSB e2kQVyLr7CpqD0JLshO8FaqoPVl9/tRugig1S6unrbpYPsihHceg4hRXoY5tka9946tH nbs8oguB5lfAnRp1kTj721b6+mW8OoXfeXSrz1X7imks5Usd/UiCigVXAggb08Ky8VSQ 0d+PmSjh50wAt1EjJsU78ulnrjf7r+Km+urNeG6eqLgqYbqb0XtItRC9NHcuqWrV+E6I E1lKZirJ+8xE8bV6M1fIewP2H5wK+kZzwUaGWoihpfDObIMqhjdFSqa0ls3ZYeCo96MX A43g== X-Gm-Message-State: AOJu0Yy/SZOHO9H9id2tA795w0cYHSyU7VHJ9f3i0g+uxxFPW9BZi5zR 9Rfmk2lBj8CFUm52gZvNNJZdYSMeFbh7gQ== X-Google-Smtp-Source: AGHT+IGPmvdUO8SXjXgKV/aQCxeStLpIIPvoeykWdqZkiW7Qc5Us/N/1WUFwWDhYHwAEHPNbOA3kGg== X-Received: by 2002:a05:600c:228d:b0:40e:4579:9eb1 with SMTP id 13-20020a05600c228d00b0040e45799eb1mr2208339wmf.1.1704823897680; Tue, 09 Jan 2024 10:11:37 -0800 (PST) Received: from andri-workstation.turninn.appdynamic.com ([2a01:8280:aa07:ad:7285:c2ff:fef0:4baf]) by smtp.gmail.com with ESMTPSA id n25-20020a05600c3b9900b0040e527602c8sm2104579wms.9.2024.01.09.10.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:11:37 -0800 (PST) From: Andri Yngvason To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Subject: [PATCH 4/7] drm/i915/display: Add handling for new "active color format" property Date: Tue, 9 Jan 2024 18:11:01 +0000 Message-ID: <20240109181104.1670304-5-andri@yngvason.is> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109181104.1670304-1-andri@yngvason.is> References: <20240109181104.1670304-1-andri@yngvason.is> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Jan 2024 12:28:11 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, Simon Ser , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andri Yngvason , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Werner Sembach This commit implements the "active color format" drm property for the Intel GPU driver. Signed-off-by: Werner Sembach Signed-off-by: Andri Yngvason Tested-by: Andri Yngvason --- drivers/gpu/drm/i915/display/intel_display.c | 33 ++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_dp.c | 7 +++-- drivers/gpu/drm/i915/display/intel_dp_mst.c | 5 +++ drivers/gpu/drm/i915/display/intel_hdmi.c | 4 ++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index df582ff81b45f..79cc258db8f09 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -7167,6 +7167,21 @@ static void intel_atomic_prepare_plane_clear_colors(struct intel_atomic_state *s } } +static int convert_intel_output_format_into_drm_color_format(enum intel_output_format output_format) +{ + switch (output_format) { + case INTEL_OUTPUT_FORMAT_RGB: + return DRM_COLOR_FORMAT_RGB444; + case INTEL_OUTPUT_FORMAT_YCBCR420: + return DRM_COLOR_FORMAT_YCBCR420; + case INTEL_OUTPUT_FORMAT_YCBCR444: + return DRM_COLOR_FORMAT_YCBCR444; + default: + break; + } + return 0; +} + static void intel_atomic_commit_tail(struct intel_atomic_state *state) { struct drm_device *dev = state->base.dev; @@ -7438,6 +7453,9 @@ int intel_atomic_commit(struct drm_device *dev, struct drm_atomic_state *_state, { struct intel_atomic_state *state = to_intel_atomic_state(_state); struct drm_i915_private *dev_priv = to_i915(dev); + struct drm_connector *connector; + struct drm_connector_state *new_conn_state; + int i; int ret = 0; state->wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm); @@ -7506,6 +7524,21 @@ int intel_atomic_commit(struct drm_device *dev, struct drm_atomic_state *_state, intel_shared_dpll_swap_state(state); intel_atomic_track_fbs(state); + /* Extract information from crtc to communicate it to userspace as connector properties */ + for_each_new_connector_in_state(&state->base, connector, new_conn_state, i) { + struct intel_crtc *crtc = to_intel_crtc(new_conn_state->crtc); + + if (crtc) { + struct intel_crtc_state *new_crtc_state = + intel_atomic_get_new_crtc_state(state, crtc); + + drm_connector_set_active_color_format_property(connector, + convert_intel_output_format_into_drm_color_format( + new_crtc_state->output_format)); + } else + drm_connector_set_active_color_format_property(connector, 0); + } + drm_atomic_state_get(&state->base); INIT_WORK(&state->base.commit_work, intel_atomic_commit_work); diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 62ce92772367f..c40fe8a847614 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -5910,10 +5910,13 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect intel_attach_force_audio_property(connector); intel_attach_broadcast_rgb_property(connector); - if (HAS_GMCH(dev_priv)) + if (HAS_GMCH(dev_priv)) { drm_connector_attach_max_bpc_property(connector, 6, 10); - else if (DISPLAY_VER(dev_priv) >= 5) + drm_connector_attach_active_color_format_property(connector); + } else if (DISPLAY_VER(dev_priv) >= 5) { drm_connector_attach_max_bpc_property(connector, 6, 12); + drm_connector_attach_active_color_format_property(connector); + } /* Register HDMI colorspace for case of lspcon */ if (intel_bios_encoder_is_lspcon(dp_to_dig_port(intel_dp)->base.devdata)) { diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c index aa10612626136..e7574ca0604e6 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c @@ -1210,6 +1210,11 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo drm_dbg_kms(&dev_priv->drm, "[%s:%d] HDCP MST init failed, skipping.\n", connector->name, connector->base.id); + connector->active_color_format_property = + intel_dp->attached_connector->base.active_color_format_property; + if (connector->active_color_format_property) + drm_connector_attach_active_color_format_property(connector); + return connector; err: diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index bfa456fa7d25c..ce0221f90de92 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -2611,8 +2611,10 @@ intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *c if (DISPLAY_VER(dev_priv) >= 10) drm_connector_attach_hdr_output_metadata_property(connector); - if (!HAS_GMCH(dev_priv)) + if (!HAS_GMCH(dev_priv)) { drm_connector_attach_max_bpc_property(connector, 8, 12); + drm_connector_attach_active_color_format_property(connector); + } } /* From patchwork Tue Jan 9 18:11:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andri Yngvason X-Patchwork-Id: 13520752 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F114C47DA2 for ; Tue, 16 Jan 2024 12:28:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1126210E537; Tue, 16 Jan 2024 12:28:12 +0000 (UTC) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F63310E4CB for ; Tue, 9 Jan 2024 18:11:46 +0000 (UTC) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40e43fb2659so26946365e9.1 for ; Tue, 09 Jan 2024 10:11:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yngvason.is; s=google; t=1704823904; x=1705428704; darn=lists.freedesktop.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=0FOig009jjEjeh+vnprQEku+JrOLkbdtfCg1b2Ndzfw=; b=SajxNQ7ZNRj5I9VQ5oVQS9It+MdpNNPWP0NuW3G7OVPT26YzGc2i7g6mHPztEj98so VB6Sdjavyu0NzupdqyrkGvRsD7bT7JNEJDu6y8UQkXTfIDucILcC1suVFI0cnfmIkVAq bSvYVUzEnZt1h85azeR+tCLu1jh7CQBd3DL0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704823904; x=1705428704; 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=0FOig009jjEjeh+vnprQEku+JrOLkbdtfCg1b2Ndzfw=; b=FCcXbOH0HcbezU2Yrz/sO0ESDeO2MTREFZg6nCXm/df+viS6bP6B36jz4rDsrkgdaL bseCvYpY+CmJN3gX/Agp2KIZU9Lt8PbC3wEHs1nQaLZzSGlmarx1UfzuspY0rfUoavI7 jDKS6wRK5IXaZyjzPjWnQSotQ0+rVf5B1Nm5Q78y27Hq4fASEX+uPTeLJvRH6iTB/ge9 Rs33wkOEzNq+YO+xnJPiO43DHjSwN/4L2KQSOvoLlkd6DYKb+XHiB6j0BsaYADGY4KNK DavCtpIV0EJcKj+72gkvFcNHfCfTuThKo2LdDMikXGPb3CNqg0VFGbdU4vrnW2q+q1Cw ToSA== X-Gm-Message-State: AOJu0YyTHBmhUHYDv59hYBXIVIRHby8Pb7IcCAUJNnFPtb5lMO7TVZYW sK8ayv42/uhfY58UowjLbW9DvphmdotgPw== X-Google-Smtp-Source: AGHT+IFzA8uBOAMbRxLaFNUGf0cxS9vZD5/6R/qJ13W5c3i448PbrK2IbE7snX+W95EFhYkD/m0DGA== X-Received: by 2002:a7b:ce10:0:b0:40e:4572:57ea with SMTP id m16-20020a7bce10000000b0040e457257eamr1973874wmc.65.1704823904568; Tue, 09 Jan 2024 10:11:44 -0800 (PST) Received: from andri-workstation.turninn.appdynamic.com ([2a01:8280:aa07:ad:7285:c2ff:fef0:4baf]) by smtp.gmail.com with ESMTPSA id n25-20020a05600c3b9900b0040e527602c8sm2104579wms.9.2024.01.09.10.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:11:44 -0800 (PST) From: Andri Yngvason To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Subject: [PATCH 5/7] drm/uAPI: Add "preferred color format" drm property as setting for userspace Date: Tue, 9 Jan 2024 18:11:02 +0000 Message-ID: <20240109181104.1670304-6-andri@yngvason.is> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109181104.1670304-1-andri@yngvason.is> References: <20240109181104.1670304-1-andri@yngvason.is> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Jan 2024 12:28:11 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, Simon Ser , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andri Yngvason , dri-devel@lists.freedesktop.org, Dan Carpenter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Werner Sembach Add a new general drm property "preferred color format" which can be used by userspace to tell the graphic drivers to which color format to use. Possible options are: - auto (default/current behaviour) - rgb - ycbcr444 - ycbcr422 (not supported by both amdgpu and i915) - ycbcr420 In theory the auto option should choose the best available option for the current setup, but because of bad internal conversion some monitors look better with rgb and some with ycbcr444. Also, because of bad shielded connectors and/or cables, it might be preferable to use the less bandwidth heavy ycbcr422 and ycbcr420 formats for a signal that is less deceptible to interference. In the future, automatic color calibration for screens might also depend on this option being available. Signed-off-by: Werner Sembach Reported-by: Dan Carpenter Signed-off-by: Andri Yngvason Tested-by: Andri Yngvason --- drivers/gpu/drm/drm_atomic_helper.c | 4 +++ drivers/gpu/drm/drm_atomic_uapi.c | 4 +++ drivers/gpu/drm/drm_connector.c | 50 ++++++++++++++++++++++++++++- include/drm/drm_connector.h | 17 ++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 68ffcc0b00dca..745a43d9c5da3 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -707,6 +707,10 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, if (old_connector_state->max_requested_bpc != new_connector_state->max_requested_bpc) new_crtc_state->connectors_changed = true; + + if (old_connector_state->preferred_color_format != + new_connector_state->preferred_color_format) + new_crtc_state->connectors_changed = true; } if (funcs->atomic_check) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 98d3b10c08ae1..eba5dea1249e5 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -798,6 +798,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, state->max_requested_bpc = val; } else if (property == connector->privacy_screen_sw_state_property) { state->privacy_screen_sw_state = val; + } else if (property == connector->preferred_color_format_property) { + state->preferred_color_format = val; } else if (connector->funcs->atomic_set_property) { return connector->funcs->atomic_set_property(connector, state, property, val); @@ -881,6 +883,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->max_requested_bpc; } else if (property == connector->privacy_screen_sw_state_property) { *val = state->privacy_screen_sw_state; + } else if (property == connector->preferred_color_format_property) { + *val = state->preferred_color_format; } else if (connector->funcs->atomic_get_property) { return connector->funcs->atomic_get_property(connector, state, property, val); diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 30d62e505d188..4de48a38792cf 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1061,6 +1061,14 @@ static const struct drm_prop_enum_list drm_dp_subconnector_enum_list[] = { { DRM_MODE_SUBCONNECTOR_Native, "Native" }, /* DP */ }; +static const struct drm_prop_enum_list drm_preferred_color_format_enum_list[] = { + { 0, "auto" }, + { DRM_COLOR_FORMAT_RGB444, "rgb" }, + { DRM_COLOR_FORMAT_YCBCR444, "ycbcr444" }, + { DRM_COLOR_FORMAT_YCBCR422, "ycbcr422" }, + { DRM_COLOR_FORMAT_YCBCR420, "ycbcr420" }, +}; + static const struct drm_prop_enum_list drm_active_color_format_enum_list[] = { { 0, "not applicable" }, { DRM_COLOR_FORMAT_RGB444, "rgb" }, @@ -1398,11 +1406,20 @@ static const u32 dp_colorspaces = * drm_connector_attach_max_bpc_property() to create and attach the * property to the connector during initialization. * + * preferred color format: + * This property is used by userspace to change the used color format. When + * used the driver will use the selected format if valid for the hardware, + * sink, and current resolution and refresh rate combination. Drivers to + * use the function drm_connector_attach_preferred_color_format_property() + * to create and attach the property to the connector during + * initialization. Possible values are "auto", "rgb", "ycbcr444", + * "ycbcr422", and "ycbcr420". + * * active color format: * This read-only property tells userspace the color format actually used * by the hardware display engine "on the cable" on a connector. The chosen * value depends on hardware capabilities, both display engine and - * connected monitor. Drivers shall use + * connected monitor, and the "preferred color format". Drivers shall use * drm_connector_attach_active_color_format_property() to install this * property. Possible values are "not applicable", "rgb", "ycbcr444", * "ycbcr422", and "ycbcr420". @@ -2468,6 +2485,37 @@ int drm_connector_attach_max_bpc_property(struct drm_connector *connector, } EXPORT_SYMBOL(drm_connector_attach_max_bpc_property); +/** + * drm_connector_attach_preferred_color_format_property - attach "preferred color format" property + * @connector: connector to attach preferred color format property on. + * + * This is used to add support for selecting a color format on a connector. + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_connector_attach_preferred_color_format_property(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_property *prop; + + if (!connector->preferred_color_format_property) { + prop = drm_property_create_enum(dev, 0, "preferred color format", + drm_preferred_color_format_enum_list, + ARRAY_SIZE(drm_preferred_color_format_enum_list)); + if (!prop) + return -ENOMEM; + + connector->preferred_color_format_property = prop; + } + + drm_object_attach_property(&connector->base, prop, 0); + connector->state->preferred_color_format = 0; + + return 0; +} +EXPORT_SYMBOL(drm_connector_attach_preferred_color_format_property); + /** * drm_connector_attach_active_color_format_property - attach "active color format" property * @connector: connector to attach active color format property on. diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 9ae73cfdceeb1..d7bc54c8b42cb 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1026,6 +1026,16 @@ struct drm_connector_state { */ enum drm_privacy_screen_status privacy_screen_sw_state; + /** + * preferred_color_format: Property set by userspace to tell the GPU + * driver which color format to use. It only gets applied if hardware, + * meaning both the computer and the monitor, and the driver support the + * given format at the current resolution and refresh rate. Userspace + * can check for (un-)successful application via the "active color + * format" property. + */ + u32 preferred_color_format; + /** * @hdr_output_metadata: * DRM blob property for HDR output metadata @@ -1699,6 +1709,12 @@ struct drm_connector { */ struct drm_property *privacy_screen_hw_state_property; + /** + * @preferred_color_format_property: Default connector property for the + * preferred color format to be driven out of the connector. + */ + struct drm_property *preferred_color_format_property; + /** * @active_color_format_property: Default connector property for the * active color format to be driven out of the connector. @@ -2059,6 +2075,7 @@ void drm_connector_attach_privacy_screen_provider( struct drm_connector *connector, struct drm_privacy_screen *priv); void drm_connector_update_privacy_screen(const struct drm_connector_state *connector_state); +int drm_connector_attach_preferred_color_format_property(struct drm_connector *connector); int drm_connector_attach_active_color_format_property(struct drm_connector *connector); void drm_connector_set_active_color_format_property(struct drm_connector *connector, u32 active_color_format); From patchwork Tue Jan 9 18:11:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andri Yngvason X-Patchwork-Id: 13520759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7D74C47077 for ; Tue, 16 Jan 2024 12:28:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D752D10E556; Tue, 16 Jan 2024 12:28:13 +0000 (UTC) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by gabe.freedesktop.org (Postfix) with ESMTPS id EBF2810E4D3 for ; Tue, 9 Jan 2024 18:11:49 +0000 (UTC) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40e5508ecb9so619675e9.3 for ; Tue, 09 Jan 2024 10:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yngvason.is; s=google; t=1704823908; x=1705428708; darn=lists.freedesktop.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=Qt0c3XMcNoO4kFPW/v1FdVP0dkTx8zEwl7ZVK3nsems=; b=NipQWASxioXg8Q8HGbWZNKI/vY8YdFKpCBUiD36LjUSktw8lykrd/N9p1LhurAjk/+ U1o1sgqWgJaovC3PRLl/i80Fnufy+zgmTnlK+ePo24kQCFNlrexFYmmvNC1Aqbr1WZCp aIbGZ46fvbafraaub1wdtqMkwVlxrQsyPi9fk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704823908; x=1705428708; 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=Qt0c3XMcNoO4kFPW/v1FdVP0dkTx8zEwl7ZVK3nsems=; b=hzKEOZr1PE9xPPYeVg+u39q9GMf1JltbTiftKNDr9ocsp9GybJLr/lhwN7RJ7JH4OX ySm599c26jAG52ZdfT0YPyYQt9l3/omueP6MV6JfCWOpaJM/6kxAo7H1cP5g3p3bRJnB 7WFvrZMHEPvQnn2pISgVF+bdZ8MOD21qn2qyJQOlhAcX1/17mbW6Y0jiMq1TXwTFYiyu fy+crf4iX/W954Q33raXFuwRd3YHqZFwxLBBgtR3sUbF/SMWzmIN6tnj2On1A7DwI67K TfvIuZ10VN/WlfCbgn6KhHvn+mbKluqks+T+KuIwkWTlS8C4b5EoPfm8hhgj0R+5+FlO I2Iw== X-Gm-Message-State: AOJu0Yz+CfCPIVeO2BLFtTYd4ixZeSL8AHmqMU1gGOFTn8Y4CLstIlT5 yByc+Jit3K0hg8tT/CIhPWQwrqe+qqOHPQ== X-Google-Smtp-Source: AGHT+IFgwClqgXbf2UT4umhrLU7jfpYqaURbrVxuW4v/iRn1SN3rphz7JKJNAvzao7RlEeWaArDvaQ== X-Received: by 2002:a7b:ca45:0:b0:40e:482d:e718 with SMTP id m5-20020a7bca45000000b0040e482de718mr1724173wml.33.1704823908518; Tue, 09 Jan 2024 10:11:48 -0800 (PST) Received: from andri-workstation.turninn.appdynamic.com ([2a01:8280:aa07:ad:7285:c2ff:fef0:4baf]) by smtp.gmail.com with ESMTPSA id n25-20020a05600c3b9900b0040e527602c8sm2104579wms.9.2024.01.09.10.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:11:48 -0800 (PST) From: Andri Yngvason To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Subject: [PATCH 6/7] drm/amd/display: Add handling for new "preferred color format" property Date: Tue, 9 Jan 2024 18:11:03 +0000 Message-ID: <20240109181104.1670304-7-andri@yngvason.is> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109181104.1670304-1-andri@yngvason.is> References: <20240109181104.1670304-1-andri@yngvason.is> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Jan 2024 12:28:11 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, Simon Ser , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andri Yngvason , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Werner Sembach This commit implements the "preferred color format" drm property for the AMD GPU driver. Signed-off-by: Werner Sembach Signed-off-by: Andri Yngvason Tested-by: Andri Yngvason --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 30 +++++++++++++++---- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 4 +++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index b44d06c3b1706..262d420877c91 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -5522,15 +5522,32 @@ static void fill_stream_properties_from_drm_display_mode( timing_out->h_border_right = 0; timing_out->v_border_top = 0; timing_out->v_border_bottom = 0; - /* TODO: un-hardcode */ - if (drm_mode_is_420_only(info, mode_in) - || (drm_mode_is_420_also(info, mode_in) && aconnector->force_yuv420_output)) + + if (connector_state + && (connector_state->preferred_color_format == DRM_COLOR_FORMAT_YCBCR420 + || aconnector->force_yuv420_output) && drm_mode_is_420(info, mode_in)) timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420; - else if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR444) - && stream->signal == SIGNAL_TYPE_HDMI_TYPE_A) + else if (connector_state + && connector_state->preferred_color_format == DRM_COLOR_FORMAT_YCBCR444 + && connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR444) timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR444; - else + else if (connector_state + && connector_state->preferred_color_format == DRM_COLOR_FORMAT_RGB444 + && !drm_mode_is_420_only(info, mode_in)) timing_out->pixel_encoding = PIXEL_ENCODING_RGB; + else + /* + * connector_state->preferred_color_format not possible + * || connector_state->preferred_color_format == 0 (auto) + * || connector_state->preferred_color_format == DRM_COLOR_FORMAT_YCBCR422 + */ + if (drm_mode_is_420_only(info, mode_in)) + timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420; + else if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR444) + && stream->signal == SIGNAL_TYPE_HDMI_TYPE_A) + timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR444; + else + timing_out->pixel_encoding = PIXEL_ENCODING_RGB; timing_out->timing_3d_format = TIMING_3D_FORMAT_NONE; timing_out->display_color_depth = convert_color_depth_from_display_info( @@ -7456,6 +7473,7 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm, if (!aconnector->mst_root) { drm_connector_attach_max_bpc_property(&aconnector->base, 8, 16); + drm_connector_attach_preferred_color_format_property(&aconnector->base); drm_connector_attach_active_color_format_property(&aconnector->base); } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c index a4d1b3ea8f81c..dc8cea0ac2c11 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c @@ -600,6 +600,10 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, if (connector->max_bpc_property) drm_connector_attach_max_bpc_property(connector, 8, 16); + connector->preferred_color_format_property = master->base.preferred_color_format_property; + if (connector->preferred_color_format_property) + drm_connector_attach_preferred_color_format_property(&aconnector->base); + connector->active_color_format_property = master->base.active_color_format_property; if (connector->active_color_format_property) drm_connector_attach_active_color_format_property(&aconnector->base); From patchwork Tue Jan 9 18:11:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andri Yngvason X-Patchwork-Id: 13520749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE14DC4706C for ; Tue, 16 Jan 2024 12:28:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C127B10E52C; Tue, 16 Jan 2024 12:28:12 +0000 (UTC) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by gabe.freedesktop.org (Postfix) with ESMTPS id 524D710E4D5 for ; Tue, 9 Jan 2024 18:11:55 +0000 (UTC) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40e47d74824so21199165e9.2 for ; Tue, 09 Jan 2024 10:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yngvason.is; s=google; t=1704823914; x=1705428714; darn=lists.freedesktop.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=1K35iyXrIjP9JEaVNwNgowQ2gmFwtnlNnPCP001WTzs=; b=T9ErnVxmP3A7CbGfOx5/rcrNiR+1zok+b70FkTq3omeJifjvUx0Rs4zrHR33DY2WG8 0P0DNB84PsNW206wNkrHelewbYD7rrI5dfAFydVOHUaLtezZAioGd6uCOfFcXnvjNFEn cUXVy82V+yRWCeSjYcbIuk7SXGEq4yFUZbLdY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704823914; x=1705428714; 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=1K35iyXrIjP9JEaVNwNgowQ2gmFwtnlNnPCP001WTzs=; b=r5tDwlX7k0sXkxvRD1Fkku/FiE+4RCVwUllLy2qKOqf1sej1E1NvsTqY9vz0hvk2gA l0aUXFCsvAhVE835fbz1spGSe5XjIzNLJUeF6q0tUbPvwr+g5yx/g9J3HQzTm/+G1SOK 2LjdVLbQDXZ44fxVyO2obNsvsUGSa88HV7KfzRh3W5rN6foz4sHzIdk61qWKj61TAIG3 qLFoElSMpet7zzpcHJrlZ+clFqFjnrkw9oesiDI89XEN8K/3BLVErXeZUc/JijUn2Lix M2xetoogGXlNzdBW6d2HaZfL4FPCsf+ocE6RyNye/fHfOFfu3zv7p4srabUszNAPpbqI i3xw== X-Gm-Message-State: AOJu0YxD8BVe92VqVFDrXsA0Mfl97pS4eHpL4F9SvfDxrBCZNhOlSqSL 9PJ+fzXMAwxkfUcammqFZ3wXFWReSigkow== X-Google-Smtp-Source: AGHT+IHCvkhLBDjMnPPg6VS4Uza9HPKoHPU28wAqqAGezxMnCAYYxMWKNpbjFIpaRNQwjFu2XbHG4A== X-Received: by 2002:a05:600c:5251:b0:40c:24b1:8d07 with SMTP id fc17-20020a05600c525100b0040c24b18d07mr1582485wmb.192.1704823913857; Tue, 09 Jan 2024 10:11:53 -0800 (PST) Received: from andri-workstation.turninn.appdynamic.com ([2a01:8280:aa07:ad:7285:c2ff:fef0:4baf]) by smtp.gmail.com with ESMTPSA id n25-20020a05600c3b9900b0040e527602c8sm2104579wms.9.2024.01.09.10.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:11:53 -0800 (PST) From: Andri Yngvason To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Subject: [PATCH 7/7] drm/i915/display: Add handling for new "preferred color format" property Date: Tue, 9 Jan 2024 18:11:04 +0000 Message-ID: <20240109181104.1670304-8-andri@yngvason.is> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109181104.1670304-1-andri@yngvason.is> References: <20240109181104.1670304-1-andri@yngvason.is> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Jan 2024 12:28:11 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, Simon Ser , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andri Yngvason , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Werner Sembach This commit implements the "preferred color format" drm property for the Intel GPU driver. Signed-off-by: Werner Sembach Co-developed-by: Andri Yngvason Signed-off-by: Andri Yngvason Tested-by: Andri Yngvason --- drivers/gpu/drm/i915/display/intel_dp.c | 16 ++++++++++------ drivers/gpu/drm/i915/display/intel_dp_mst.c | 5 +++++ drivers/gpu/drm/i915/display/intel_hdmi.c | 12 +++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index c40fe8a847614..f241798660d0b 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -2698,21 +2698,23 @@ intel_dp_compute_output_format(struct intel_encoder *encoder, struct intel_connector *connector = intel_dp->attached_connector; const struct drm_display_info *info = &connector->base.display_info; const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; - bool ycbcr_420_only; + bool ycbcr_420_output; int ret; - ycbcr_420_only = drm_mode_is_420_only(info, adjusted_mode); + ycbcr_420_output = drm_mode_is_420_only(info, adjusted_mode) || + (conn_state->preferred_color_format == DRM_COLOR_FORMAT_YCBCR420 && + drm_mode_is_420_also(&connector->base.display_info, adjusted_mode)); - if (ycbcr_420_only && !connector->base.ycbcr_420_allowed) { + crtc_state->sink_format = ycbcr_420_output ? INTEL_OUTPUT_FORMAT_YCBCR420 : + INTEL_OUTPUT_FORMAT_RGB; + + if (ycbcr_420_output && !connector->base.ycbcr_420_allowed) { drm_dbg_kms(&i915->drm, "YCbCr 4:2:0 mode but YCbCr 4:2:0 output not possible. Falling back to RGB.\n"); crtc_state->sink_format = INTEL_OUTPUT_FORMAT_RGB; - } else { - crtc_state->sink_format = intel_dp_sink_format(connector, adjusted_mode); } crtc_state->output_format = intel_dp_output_format(connector, crtc_state->sink_format); - ret = intel_dp_compute_link_config(encoder, crtc_state, conn_state, respect_downstream_limits); if (ret) { @@ -5912,9 +5914,11 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect intel_attach_broadcast_rgb_property(connector); if (HAS_GMCH(dev_priv)) { drm_connector_attach_max_bpc_property(connector, 6, 10); + drm_connector_attach_preferred_color_format_property(connector); drm_connector_attach_active_color_format_property(connector); } else if (DISPLAY_VER(dev_priv) >= 5) { drm_connector_attach_max_bpc_property(connector, 6, 12); + drm_connector_attach_preferred_color_format_property(connector); drm_connector_attach_active_color_format_property(connector); } diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c index e7574ca0604e6..4a850eb9b8d4d 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c @@ -1210,6 +1210,11 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo drm_dbg_kms(&dev_priv->drm, "[%s:%d] HDCP MST init failed, skipping.\n", connector->name, connector->base.id); + connector->preferred_color_format_property = + intel_dp->attached_connector->base.preferred_color_format_property; + if (connector->preferred_color_format_property) + drm_connector_attach_preferred_color_format_property(connector); + connector->active_color_format_property = intel_dp->attached_connector->base.active_color_format_property; if (connector->active_color_format_property) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index ce0221f90de92..3030589d245d7 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -2214,19 +2214,24 @@ static int intel_hdmi_compute_output_format(struct intel_encoder *encoder, const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; const struct drm_display_info *info = &connector->base.display_info; struct drm_i915_private *i915 = to_i915(connector->base.dev); - bool ycbcr_420_only = drm_mode_is_420_only(info, adjusted_mode); + bool ycbcr_420_output; int ret; + ycbcr_420_output = drm_mode_is_420_only(info, adjusted_mode) || + (conn_state->preferred_color_format == DRM_COLOR_FORMAT_YCBCR420 && + drm_mode_is_420_also(&connector->base.display_info, adjusted_mode)); + crtc_state->sink_format = - intel_hdmi_sink_format(crtc_state, connector, ycbcr_420_only); + intel_hdmi_sink_format(crtc_state, connector, ycbcr_420_output); - if (ycbcr_420_only && crtc_state->sink_format != INTEL_OUTPUT_FORMAT_YCBCR420) { + if (ycbcr_420_output && crtc_state->sink_format != INTEL_OUTPUT_FORMAT_YCBCR420) { drm_dbg_kms(&i915->drm, "YCbCr 4:2:0 mode but YCbCr 4:2:0 output not possible. Falling back to RGB.\n"); crtc_state->sink_format = INTEL_OUTPUT_FORMAT_RGB; } crtc_state->output_format = intel_hdmi_output_format(crtc_state); + ret = intel_hdmi_compute_clock(encoder, crtc_state, respect_downstream_limits); if (ret) { if (crtc_state->sink_format == INTEL_OUTPUT_FORMAT_YCBCR420 || @@ -2613,6 +2618,7 @@ intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *c if (!HAS_GMCH(dev_priv)) { drm_connector_attach_max_bpc_property(connector, 8, 12); + drm_connector_attach_preferred_color_format_property(connector); drm_connector_attach_active_color_format_property(connector); } }