aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorUma Shankar <uma.shankar@intel.com>2019-05-16 10:10:09 -0400
committerVille Syrjälä <ville.syrjala@linux.intel.com>2019-05-22 15:46:35 -0400
commit2cdbfd66a82969770ce1a7032fb1e2155a08cee8 (patch)
treeaaa856471b49a8c9f3c5fd9565c17d58d4ea7f3b /drivers/gpu/drm
parente85959d6cbe08521942a6118568a38ac671e8d7f (diff)
drm: Enable HDR infoframe support
Enable Dynamic Range and Mastering Infoframe for HDR content, which is defined in CEA 861.3 spec. The metadata will be computed based on blending policy in userspace compositors and passed as a connector property blob to driver. The same will be sent as infoframe to panel which support HDR. Added the const version of infoframe for DRM metadata for HDR. v2: Rebase and added Ville's POC changes. v3: No Change v4: Addressed Shashank's review comments and merged the patch making drm infoframe function arguments as constant. v5: Rebase v6: Fixed checkpatch warnings with --strict option. Addressed Shashank's review comments and added his RB. v7: Addressed Brian Starkey's review comments. Merged 2 patches into one. v8: Addressed Jonas Karlman review comments. v9: Addressed Jonas Karlman review comments. v10: Addressed Ville's review comments. v11: Added BUILD_BUG_ON and sizeof instead of magic numbers as per Ville's comments. Signed-off-by: Uma Shankar <uma.shankar@intel.com> Reviewed-by: Shashank Sharma <shashank.sharma@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/1558015817-12025-5-git-send-email-uma.shankar@intel.com
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/drm_edid.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index a5ef9f45fee0..73560c9437cd 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4904,6 +4904,78 @@ static bool is_hdmi2_sink(struct drm_connector *connector)
4904 connector->display_info.color_formats & DRM_COLOR_FORMAT_YCRCB420; 4904 connector->display_info.color_formats & DRM_COLOR_FORMAT_YCRCB420;
4905} 4905}
4906 4906
4907static inline bool is_eotf_supported(u8 output_eotf, u8 sink_eotf)
4908{
4909 return sink_eotf & BIT(output_eotf);
4910}
4911
4912/**
4913 * drm_hdmi_infoframe_set_hdr_metadata() - fill an HDMI DRM infoframe with
4914 * HDR metadata from userspace
4915 * @frame: HDMI DRM infoframe
4916 * @hdr_metadata: hdr_source_metadata info from userspace
4917 *
4918 * Return: 0 on success or a negative error code on failure.
4919 */
4920int
4921drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
4922 const struct drm_connector_state *conn_state)
4923{
4924 struct drm_connector *connector;
4925 struct hdr_output_metadata *hdr_metadata;
4926 int err;
4927
4928 if (!frame || !conn_state)
4929 return -EINVAL;
4930
4931 connector = conn_state->connector;
4932
4933 if (!conn_state->hdr_output_metadata)
4934 return -EINVAL;
4935
4936 hdr_metadata = conn_state->hdr_output_metadata->data;
4937
4938 if (!hdr_metadata || !connector)
4939 return -EINVAL;
4940
4941 /* Sink EOTF is Bit map while infoframe is absolute values */
4942 if (!is_eotf_supported(hdr_metadata->hdmi_metadata_type1.eotf,
4943 connector->hdr_sink_metadata.hdmi_type1.eotf)) {
4944 DRM_DEBUG_KMS("EOTF Not Supported\n");
4945 return -EINVAL;
4946 }
4947
4948 err = hdmi_drm_infoframe_init(frame);
4949 if (err < 0)
4950 return err;
4951
4952 frame->eotf = hdr_metadata->hdmi_metadata_type1.eotf;
4953 frame->metadata_type = hdr_metadata->hdmi_metadata_type1.metadata_type;
4954
4955 BUILD_BUG_ON(sizeof(frame->display_primaries) !=
4956 sizeof(hdr_metadata->hdmi_metadata_type1.display_primaries));
4957 BUILD_BUG_ON(sizeof(frame->white_point) !=
4958 sizeof(hdr_metadata->hdmi_metadata_type1.white_point));
4959
4960 memcpy(&frame->display_primaries,
4961 &hdr_metadata->hdmi_metadata_type1.display_primaries,
4962 sizeof(frame->display_primaries));
4963
4964 memcpy(&frame->white_point,
4965 &hdr_metadata->hdmi_metadata_type1.white_point,
4966 sizeof(frame->white_point));
4967
4968 frame->max_display_mastering_luminance =
4969 hdr_metadata->hdmi_metadata_type1.max_display_mastering_luminance;
4970 frame->min_display_mastering_luminance =
4971 hdr_metadata->hdmi_metadata_type1.min_display_mastering_luminance;
4972 frame->max_fall = hdr_metadata->hdmi_metadata_type1.max_fall;
4973 frame->max_cll = hdr_metadata->hdmi_metadata_type1.max_cll;
4974
4975 return 0;
4976}
4977EXPORT_SYMBOL(drm_hdmi_infoframe_set_hdr_metadata);
4978
4907/** 4979/**
4908 * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with 4980 * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
4909 * data from a DRM display mode 4981 * data from a DRM display mode