From 28ccb5f9dee4b7228751658185fb628d95a219bb Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Wed, 22 Jan 2020 14:50:17 -0800 Subject: [PATCH] disp: msm: add VSVDB parsing support to sde edid parser Add VSVDB parsing support to sde edid parser. This is required for HDR10+ support. Currently the parsing is done in the upstream edid parser. This shall be removed in a subsequent change. Change-Id: Ibd3a31e12bba68e14e278e0e478656453eb111ac Signed-off-by: Abhinav Kumar --- msm/sde/sde_connector.h | 1 + msm/sde_edid_parser.c | 74 ++++++++++++++++++++++++++++++++++++++++- msm/sde_edid_parser.h | 5 ++- 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/msm/sde/sde_connector.h b/msm/sde/sde_connector.h index c40a194220e9..02e9aa6ee2d2 100644 --- a/msm/sde/sde_connector.h +++ b/msm/sde/sde_connector.h @@ -471,6 +471,7 @@ struct sde_connector { u32 unset_bl_level; bool allow_bl_update; + u8 hdr_plus_app_ver; u32 qsync_mode; bool qsync_updated; diff --git a/msm/sde_edid_parser.c b/msm/sde_edid_parser.c index 0fc473da9f87..326fd7737b10 100644 --- a/msm/sde_edid_parser.c +++ b/msm/sde_edid_parser.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. */ #include @@ -8,6 +8,7 @@ #include "sde_kms.h" #include "sde_edid_parser.h" +#include "sde/sde_connector.h" #define DBC_START_OFFSET 4 #define EDID_DTD_LEN 18 @@ -464,6 +465,75 @@ static void _sde_edid_extract_audio_data_blocks( SDE_EDID_DEBUG("%s -", __func__); } +static void sde_edid_parse_hdr_plus_info(struct drm_connector *connector, + const u8 *db) +{ + struct sde_connector *c_conn; + + c_conn = to_sde_connector(connector); + c_conn->hdr_plus_app_ver = db[5] & VSVDB_HDR10_PLUS_APP_VER_MASK; +} + +static void sde_edid_parse_vsvdb_info(struct drm_connector *connector, + const u8 *db) +{ + u8 db_len = 0; + u32 ieee_code = 0; + + SDE_EDID_DEBUG("%s +\n", __func__); + + db_len = sde_cea_db_payload_len(db); + + if (db_len < 5) + return; + + /* Bytes 2-4: IEEE 24-bit code, LSB first */ + ieee_code = db[2] | (db[3] << 8) | (db[4] << 16); + + if (ieee_code == VSVDB_HDR10_PLUS_IEEE_CODE) + sde_edid_parse_hdr_plus_info(connector, db); + + SDE_EDID_DEBUG("%s -\n", __func__); +} + +/* + * sde_edid_parse_extended_blk_info - Parse the HDMI extended tag blocks + * @connector: connector corresponding to external sink + * @edid: handle to the EDID structure + * Parses the all extended tag blocks extract sink info for @connector. + */ +static void +sde_edid_parse_extended_blk_info(struct drm_connector *connector, + struct edid *edid) +{ + const u8 *cea = sde_find_cea_extension(edid); + const u8 *db = NULL; + + if (cea && sde_cea_revision(cea) >= 3) { + int i, start, end; + + if (sde_cea_db_offsets(cea, &start, &end)) + return; + + sde_for_each_cea_db(cea, i, start, end) { + db = &cea[i]; + + if (sde_cea_db_tag(db) == USE_EXTENDED_TAG) { + SDE_EDID_DEBUG("found ext tag block = %d\n", + db[1]); + switch (db[1]) { + case VENDOR_SPECIFIC_VIDEO_DATA_BLOCK: + sde_edid_parse_vsvdb_info(connector, + db); + break; + default: + break; + } + } + } + } +} + static void _sde_edid_extract_speaker_allocation_data( struct sde_edid_ctrl *edid_ctrl) { @@ -552,6 +622,8 @@ int _sde_edid_update_modes(struct drm_connector *connector, rc = drm_add_edid_modes(connector, edid_ctrl->edid); sde_edid_set_mode_format(connector, edid_ctrl); _sde_edid_update_dc_modes(connector, edid_ctrl); + sde_edid_parse_extended_blk_info(connector, + edid_ctrl->edid); SDE_EDID_DEBUG("%s -", __func__); return rc; } diff --git a/msm/sde_edid_parser.h b/msm/sde_edid_parser.h index 6501f329d57f..1429cce60aa8 100644 --- a/msm/sde_edid_parser.h +++ b/msm/sde_edid_parser.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. */ #ifndef _SDE_EDID_PARSER_H_ @@ -26,6 +26,9 @@ #define SDE_DRM_MODE_FLAG_FMT_MASK (0x3 << 20) +#define VSVDB_HDR10_PLUS_IEEE_CODE 0x90848b +#define VSVDB_HDR10_PLUS_APP_VER_MASK 0x3 + enum extended_data_block_types { VIDEO_CAPABILITY_DATA_BLOCK = 0x0, VENDOR_SPECIFIC_VIDEO_DATA_BLOCK = 0x01,