cta: Return a block struct for video format preferences

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
This commit is contained in:
Sebastian Wick 2024-06-11 15:08:10 +02:00 committed by Sebastian Wick
parent 9ed2eeedee
commit 9534dea0df
4 changed files with 26 additions and 17 deletions

11
cta.c
View file

@ -1103,7 +1103,7 @@ parse_vesa_transfer_characteristics_block(struct di_edid_cta *cta,
static bool
parse_video_format_pref_block(struct di_edid_cta *cta,
struct di_cta_video_format_pref_block *vfpdb,
struct di_cta_video_format_pref_priv *vfpdb,
const uint8_t *data, size_t size)
{
struct di_cta_svr *svr;
@ -1147,6 +1147,7 @@ parse_video_format_pref_block(struct di_edid_cta *cta,
vfpdb->svrs[vfpdb->svrs_len++] = svr;
}
vfpdb->base.svrs = (const struct di_cta_svr *const *)vfpdb->svrs;
return true;
}
@ -1605,7 +1606,7 @@ destroy_data_block(struct di_cta_data_block *data_block)
struct di_cta_audio_block_priv *audio;
struct di_cta_infoframe_block_priv *infoframe;
struct di_cta_speaker_location_priv *speaker_location;
struct di_cta_video_format_pref_block *vfpdb;
struct di_cta_video_format_pref_priv *vfpdb;
struct di_cta_hdmi_audio_block_priv *hdmi_audio;
struct di_cta_ycbcr420_video_block_priv *ycbcr420;
@ -1985,13 +1986,13 @@ di_cta_data_block_get_ycbcr420_video(const struct di_cta_data_block *block)
return &block->ycbcr420.base;
}
const struct di_cta_svr *const *
di_cta_data_block_get_svrs(const struct di_cta_data_block *block)
const struct di_cta_video_format_pref_block *
di_cta_data_block_get_video_format_pref(const struct di_cta_data_block *block)
{
if (block->tag != DI_CTA_DATA_BLOCK_VIDEO_FORMAT_PREF) {
return NULL;
}
return (const struct di_cta_svr *const *) block->video_format_pref.svrs;
return &block->video_format_pref.base;
}
const struct di_cta_audio_block *

View file

@ -904,7 +904,7 @@ print_cta(const struct di_edid_cta *cta)
const struct di_cta_sad *const *sads;
const struct di_cta_ycbcr420_cap_map_block *ycbcr420_cap_map;
const struct di_cta_infoframe_block *infoframe;
const struct di_cta_svr *const *svrs;
const struct di_cta_video_format_pref_block *video_format_pref;
const struct di_edid_detailed_timing_def *const *detailed_timing_defs;
const struct di_displayid_type_i_ii_vii_timing *type_vii_timing;
const struct di_cta_hdmi_audio_block *hdmi_audio;
@ -1019,8 +1019,8 @@ print_cta(const struct di_edid_cta *cta)
print_infoframes(infoframe->infoframes);
break;
case DI_CTA_DATA_BLOCK_VIDEO_FORMAT_PREF:
svrs = di_cta_data_block_get_svrs(data_block);
printf_cta_svrs(svrs);
video_format_pref = di_cta_data_block_get_video_format_pref(data_block);
printf_cta_svrs(video_format_pref->svrs);
break;
case DI_CTA_DATA_BLOCK_DISPLAYID_VIDEO_TIMING_VII:
type_vii_timing = di_cta_data_block_get_did_type_vii_timing(data_block);

View file

@ -178,7 +178,8 @@ struct di_cta_speaker_location_priv {
size_t locations_len;
};
struct di_cta_video_format_pref_block {
struct di_cta_video_format_pref_priv {
struct di_cta_video_format_pref_block base;
/* NULL-terminated */
struct di_cta_svr *svrs[EDID_CTA_MAX_VIDEO_FORMAT_PREF_BLOCK_ENTRIES + 1];
size_t svrs_len;
@ -218,7 +219,7 @@ struct di_cta_data_block {
/* Used for DI_CTA_DATA_BLOCK_SPEAKER_LOCATION */
struct di_cta_speaker_location_priv speaker_location;
/* Used for DI_CTA_DATA_BLOCK_VIDEO_FORMAT_PREF */
struct di_cta_video_format_pref_block video_format_pref;
struct di_cta_video_format_pref_priv video_format_pref;
/* Used for DI_CTA_DATA_BLOCK_DISPLAYID_VIDEO_TIMING_VII */
struct di_displayid_type_i_ii_vii_timing did_vii_timing;
};

View file

@ -1166,17 +1166,24 @@ struct di_cta_svr {
uint8_t t7_t10_vtdb_index;
};
/**
* Get an array of Short Video References (SVRs) from a CTA data block. The
* first SVR refers to the most-preferred Video Format, while the next SVRs
* are listed in order of decreasing preference.
* Video Format Preference Data Block, defined in section 7.5.12.
*/
struct di_cta_video_format_pref_block {
/* Short Video References (SVRs). The array is NULL-terminated.
* The first SVR refers to the most-preferred Video Format, while the
* next SVRs are listed in order of decreasing preference. */
const struct di_cta_svr *const *svrs;
};
/**
* Get the Video Format Preference information from a CTA data block.
*
* Returns NULL if the data block tag is not
* DI_CTA_DATA_BLOCK_VIDEO_FORMAT_PREF.
*
* The returned array is NULL-terminated.
*/
const struct di_cta_svr *const *
di_cta_data_block_get_svrs(const struct di_cta_data_block *block);
const struct di_cta_video_format_pref_block *
di_cta_data_block_get_video_format_pref(const struct di_cta_data_block *block);
#endif