Commit c3292ab5 authored by Jani Nikula's avatar Jani Nikula

drm/edid: parse VICs from CTA VDB early

A number of places need access to the VICs. Just parse them early for
easy access. Gracefully handle multiple CTA VDBs. It's unlikely to have
more than one, but the CTA-861 references "Video Data Block(s)", so err
on the safe side.

Start parsing them now, convert users in follow-up to have fewer moving
parts in one go.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/7989b2b37837be68953c5d20afd3e93762bfd626.1672826282.git.jani.nikula@intel.com
parent 72794d16
......@@ -565,6 +565,7 @@ void drm_connector_cleanup(struct drm_connector *connector)
ida_free(&dev->mode_config.connector_ida, connector->index);
kfree(connector->display_info.bus_formats);
kfree(connector->display_info.vics);
drm_mode_object_unregister(dev, &connector->base);
kfree(connector->name);
connector->name = NULL;
......
......@@ -5862,6 +5862,36 @@ drm_default_rgb_quant_range(const struct drm_display_mode *mode)
}
EXPORT_SYMBOL(drm_default_rgb_quant_range);
/* CTA-861 Video Data Block (CTA VDB) */
static void parse_cta_vdb(struct drm_connector *connector, const struct cea_db *db)
{
struct drm_display_info *info = &connector->display_info;
int i, vic_index, len = cea_db_payload_len(db);
const u8 *svds = cea_db_data(db);
u8 *vics;
if (!len)
return;
/* Gracefully handle multiple VDBs, however unlikely that is */
vics = krealloc(info->vics, info->vics_len + len, GFP_KERNEL);
if (!vics)
return;
vic_index = info->vics_len;
info->vics_len += len;
info->vics = vics;
for (i = 0; i < len; i++) {
u8 vic = svd_to_vic(svds[i]);
if (!drm_valid_cea_vic(vic))
vic = 0;
info->vics[vic_index++] = vic;
}
}
static void drm_parse_vcdb(struct drm_connector *connector, const u8 *db)
{
struct drm_display_info *info = &connector->display_info;
......@@ -6205,6 +6235,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
drm_parse_vcdb(connector, data);
else if (cea_db_is_hdmi_hdr_metadata_block(db))
drm_parse_hdr_metadata_block(connector, data);
else if (cea_db_tag(db) == CTA_DB_VIDEO)
parse_cta_vdb(connector, db);
}
cea_db_iter_end(&iter);
}
......@@ -6372,6 +6404,10 @@ static void drm_reset_display_info(struct drm_connector *connector)
info->mso_stream_count = 0;
info->mso_pixel_overlap = 0;
info->max_dsc_bpp = 0;
kfree(info->vics);
info->vics = NULL;
info->vics_len = 0;
}
static u32 update_display_info(struct drm_connector *connector,
......
......@@ -721,6 +721,16 @@ struct drm_display_info {
* monitor's default value is used instead.
*/
u32 max_dsc_bpp;
/**
* @vics: Array of vics_len VICs. Internal to EDID parsing.
*/
u8 *vics;
/**
* @vics_len: Number of elements in vics. Internal to EDID parsing.
*/
int vics_len;
};
int drm_display_info_set_bus_formats(struct drm_display_info *info,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment