From 9534dea0dfc2a67f8f17b3155fe7aa0458b4e8d2 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 11 Jun 2024 15:08:10 +0200 Subject: [PATCH] cta: Return a block struct for video format preferences Signed-off-by: Sebastian Wick --- cta.c | 11 ++++++----- di-edid-decode/cta.c | 6 +++--- include/cta.h | 5 +++-- include/libdisplay-info/cta.h | 21 ++++++++++++++------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/cta.c b/cta.c index cc8df1e..223442f 100644 --- a/cta.c +++ b/cta.c @@ -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 * diff --git a/di-edid-decode/cta.c b/di-edid-decode/cta.c index 7aa6fa5..e52b8f2 100644 --- a/di-edid-decode/cta.c +++ b/di-edid-decode/cta.c @@ -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); diff --git a/include/cta.h b/include/cta.h index b257c8a..9350cc3 100644 --- a/include/cta.h +++ b/include/cta.h @@ -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; }; diff --git a/include/libdisplay-info/cta.h b/include/libdisplay-info/cta.h index c67d8c8..0466541 100644 --- a/include/libdisplay-info/cta.h +++ b/include/libdisplay-info/cta.h @@ -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