From patchwork Fri Feb 8 18:24:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shankar, Uma" X-Patchwork-Id: 10803611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2B071390 for ; Fri, 8 Feb 2019 18:01:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4F412EBEB for ; Fri, 8 Feb 2019 18:01:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9B762EC83; Fri, 8 Feb 2019 18:01:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 625D32EBEB for ; Fri, 8 Feb 2019 18:01:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F14586EE54; Fri, 8 Feb 2019 18:01:31 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id C87956EE52; Fri, 8 Feb 2019 18:01:30 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2019 10:01:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,348,1544515200"; d="scan'208";a="113461133" Received: from linuxpresi1-desktop.iind.intel.com ([10.223.25.28]) by orsmga007.jf.intel.com with ESMTP; 08 Feb 2019 10:01:10 -0800 From: Uma Shankar To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Fri, 8 Feb 2019 23:54:55 +0530 Message-Id: <1549650296-28648-4-git-send-email-uma.shankar@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1549650296-28648-1-git-send-email-uma.shankar@intel.com> References: <1549650296-28648-1-git-send-email-uma.shankar@intel.com> Subject: [Intel-gfx] [v15 3/4] drm: Add colorspace info to AVI Infoframe X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ville.syrjala@intel.com, maarten.lankhorst@intel.com MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This adds colorspace information to HDMI AVI infoframe. A helper function is added to program the same. v2: Moved this to drm core instead of i915 driver. v3: Exported the helper function. v4: Added separate HDMI specific macro as per CTA spec. This is separate from user exposed enum values. This is as per Ville's suggestion. v5: Appended BT709 and SMPTE 170M with YCC information as per Ville's review comment to be clear and not to be confused with RGB. Signed-off-by: Uma Shankar --- drivers/gpu/drm/drm_edid.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 20 ++++++++++++++++ include/drm/drm_edid.h | 6 +++++ 3 files changed, 83 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 990b190..5202fea 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4925,6 +4925,63 @@ static bool is_hdmi2_sink(struct drm_connector *connector) EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode); /** + * drm_hdmi_avi_infoframe_colorspace() - fill the HDMI AVI infoframe + * colorspace information + * @frame: HDMI AVI infoframe + * @conn_state: connector state + */ +void +drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame, + const struct drm_connector_state *conn_state) +{ + u32 colorimetry_val = conn_state->colorspace & + FULL_COLORIMETRY_MASK; + + switch (colorimetry_val) { + case DRM_MODE_COLORIMETRY_NO_DATA: + colorimetry_val = HDMI_COLORIMETRY_NO_DATA; + break; + case HDMI_COLORIMETRY_SMPTE_170M_YCC: + colorimetry_val = HDMI_COLORIMETRY_SMPTE_170M_YCC; + break; + case DRM_MODE_COLORIMETRY_BT709_YCC: + colorimetry_val = HDMI_COLORIMETRY_BT709_YCC; + break; + case DRM_MODE_COLORIMETRY_XVYCC_601: + colorimetry_val = HDMI_COLORIMETRY_XVYCC_601; + break; + case DRM_MODE_COLORIMETRY_XVYCC_709: + colorimetry_val = HDMI_COLORIMETRY_XVYCC_709; + break; + case DRM_MODE_COLORIMETRY_SYCC_601: + colorimetry_val = HDMI_COLORIMETRY_SYCC_601; + break; + case DRM_MODE_COLORIMETRY_OPYCC_601: + colorimetry_val = HDMI_COLORIMETRY_OPYCC_601; + break; + case DRM_MODE_COLORIMETRY_OPRGB: + colorimetry_val = HDMI_COLORIMETRY_OPRGB; + break; + case DRM_MODE_COLORIMETRY_BT2020_RGB: + case DRM_MODE_COLORIMETRY_BT2020_YCC: + colorimetry_val = HDMI_COLORIMETRY_BT2020_RGB; + break; + case DRM_MODE_COLORIMETRY_BT2020_CYCC: + colorimetry_val = HDMI_COLORIMETRY_BT2020_CYCC; + break; + default: + /* ToDo: DCI-P3 will be handled as part of ACE enabling */ + colorimetry_val = HDMI_COLORIMETRY_NO_DATA; + break; + } + + frame->colorimetry = colorimetry_val & NORMAL_COLORIMETRY_MASK; + frame->extended_colorimetry = (colorimetry_val >> 2) & + EXTENDED_COLORIMETRY_MASK; +} +EXPORT_SYMBOL(drm_hdmi_avi_infoframe_colorspace); + +/** * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe * quantization range information * @frame: HDMI AVI infoframe diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 4d9aa2f..efacf29 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -288,6 +288,26 @@ enum drm_panel_orientation { #define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT 16 #define DRM_MODE_DP_COLORIMETRY_SCRGB 17 +/* HDMI Colorspace Spec Definitions */ +#define FULL_COLORIMETRY_MASK 0x1FF +#define NORMAL_COLORIMETRY_MASK 0x3 +#define EXTENDED_COLORIMETRY_MASK 0x7 +#define EXTENDED_ACE_COLORIMETRY_MASK 0xF + +#define HDMI_COLORIMETRY_NO_DATA 0x0 +#define HDMI_COLORIMETRY_SMPTE_170M_YCC 0x1 +#define HDMI_COLORIMETRY_BT709_YCC 0x2 +#define HDMI_COLORIMETRY_XVYCC_601 0x3 +#define HDMI_COLORIMETRY_XVYCC_709 0x7 +#define HDMI_COLORIMETRY_SYCC_601 0xB +#define HDMI_COLORIMETRY_OPYCC_601 0xF +#define HDMI_COLORIMETRY_OPRGB 0x13 +#define HDMI_COLORIMETRY_BT2020_CYCC 0x17 +#define HDMI_COLORIMETRY_BT2020_RGB 0x1C +#define HDMI_COLORIMETRY_BT2020_YCC 0x1C +#define HDMI_COLORIMETRY_DCI_P3_RGB_D65 0x1F +#define HDMI_COLORIMETRY_DCI_P3_RGB_THEATER 0x3F + /** * struct drm_display_info - runtime data about the connected sink * diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 8dc1a08..9d3b5b9 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -331,6 +331,7 @@ struct cea_sad { struct drm_encoder; struct drm_connector; +struct drm_connector_state; struct drm_display_mode; int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads); @@ -358,6 +359,11 @@ int drm_av_sync_delay(struct drm_connector *connector, drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame, struct drm_connector *connector, const struct drm_display_mode *mode); + +void +drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame, + const struct drm_connector_state *conn_state); + void drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame, struct drm_connector *connector,