cta: Return block structs instead of SVDs directly

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
This commit is contained in:
Sebastian Wick 2023-01-30 16:29:48 +01:00 committed by Sebastian Wick
parent e4c750fab0
commit f48bd08f26
4 changed files with 54 additions and 31 deletions

27
cta.c
View file

@ -92,7 +92,7 @@ parse_svd(struct di_edid_cta *cta, uint8_t raw, const char *prefix)
}
static bool
parse_video_block(struct di_edid_cta *cta, struct di_cta_video_block *video,
parse_video_block(struct di_edid_cta *cta, struct di_cta_video_block_priv *video,
const uint8_t *data, size_t size)
{
size_t i;
@ -109,12 +109,13 @@ parse_video_block(struct di_edid_cta *cta, struct di_cta_video_block *video,
video->svds[video->svds_len++] = svd;
}
video->base.svds = (const struct di_cta_svd *const *)video->svds;
return true;
}
static bool
parse_ycbcr420_block(struct di_edid_cta *cta,
struct di_cta_video_block *ycbcr420,
struct di_cta_ycbcr420_video_block_priv *ycbcr420,
const uint8_t *data, size_t size)
{
size_t i;
@ -131,6 +132,7 @@ parse_ycbcr420_block(struct di_edid_cta *cta,
ycbcr420->svds[ycbcr420->svds_len++] = svd;
}
ycbcr420->base.svds = (const struct di_cta_svd *const *)ycbcr420->svds;
return true;
}
@ -1597,12 +1599,13 @@ static void
destroy_data_block(struct di_cta_data_block *data_block)
{
size_t i;
struct di_cta_video_block *video;
struct di_cta_video_block_priv *video;
struct di_cta_audio_block_priv *audio;
struct di_cta_infoframe_block_priv *infoframe;
struct di_cta_speaker_location_block *speaker_location;
struct di_cta_video_format_pref_block *vfpdb;
struct di_cta_hdmi_audio_block_priv *hdmi_audio;
struct di_cta_ycbcr420_video_block_priv *ycbcr420;
switch (data_block->tag) {
case DI_CTA_DATA_BLOCK_VIDEO:
@ -1611,9 +1614,9 @@ destroy_data_block(struct di_cta_data_block *data_block)
free(video->svds[i]);
break;
case DI_CTA_DATA_BLOCK_YCBCR420:
video = &data_block->ycbcr420;
for (i = 0; i < video->svds_len; i++)
free(video->svds[i]);
ycbcr420 = &data_block->ycbcr420;
for (i = 0; i < ycbcr420->svds_len; i++)
free(ycbcr420->svds[i]);
break;
case DI_CTA_DATA_BLOCK_AUDIO:
audio = &data_block->audio;
@ -1962,22 +1965,22 @@ di_cta_data_block_get_tag(const struct di_cta_data_block *block)
return block->tag;
}
const struct di_cta_svd *const *
di_cta_data_block_get_svds(const struct di_cta_data_block *block)
const struct di_cta_video_block *
di_cta_data_block_get_video(const struct di_cta_data_block *block)
{
if (block->tag != DI_CTA_DATA_BLOCK_VIDEO) {
return NULL;
}
return (const struct di_cta_svd *const *) block->video.svds;
return &block->video.base;
}
const struct di_cta_svd *const *
di_cta_data_block_get_ycbcr420_svds(const struct di_cta_data_block *block)
const struct di_cta_ycbcr420_video_block *
di_cta_data_block_get_ycbcr420_video(const struct di_cta_data_block *block)
{
if (block->tag != DI_CTA_DATA_BLOCK_YCBCR420) {
return NULL;
}
return (const struct di_cta_svd *const *) block->ycbcr420.svds;
return &block->ycbcr420.base;
}
const struct di_cta_svr *const *

View file

@ -659,7 +659,7 @@ print_ycbcr420_cap_map(const struct di_edid_cta *cta,
if (tag != DI_CTA_DATA_BLOCK_VIDEO)
continue;
svds = di_cta_data_block_get_svds(data_block);
svds = di_cta_data_block_get_video(data_block)->svds;
for (j = 0; svds[j] != NULL; j++) {
if (di_cta_ycbcr420_cap_map_supported(map, svd_index))
printf_cta_svd(svds[j]);
@ -937,11 +937,11 @@ print_cta(const struct di_edid_cta *cta)
switch (data_block_tag) {
case DI_CTA_DATA_BLOCK_VIDEO:
svds = di_cta_data_block_get_svds(data_block);
svds = di_cta_data_block_get_video(data_block)->svds;
printf_cta_svds(svds);
break;
case DI_CTA_DATA_BLOCK_YCBCR420:
svds = di_cta_data_block_get_ycbcr420_svds(data_block);
svds = di_cta_data_block_get_ycbcr420_video (data_block)->svds;
printf_cta_svds(svds);
break;
case DI_CTA_DATA_BLOCK_SPEAKER_ALLOC:

View file

@ -115,7 +115,15 @@ struct di_cta_hdr_dynamic_metadata_block_priv {
struct di_cta_hdr_dynamic_metadata_type256 type256;
};
struct di_cta_video_block {
struct di_cta_video_block_priv {
struct di_cta_video_block base;
/* NULL-terminated */
struct di_cta_svd *svds[EDID_CTA_MAX_VIDEO_BLOCK_ENTRIES + 1];
size_t svds_len;
};
struct di_cta_ycbcr420_video_block_priv {
struct di_cta_ycbcr420_video_block base;
/* NULL-terminated */
struct di_cta_svd *svds[EDID_CTA_MAX_VIDEO_BLOCK_ENTRIES + 1];
size_t svds_len;
@ -178,9 +186,9 @@ struct di_cta_data_block {
enum di_cta_data_block_tag tag;
/* Used for DI_CTA_DATA_BLOCK_VIDEO */
struct di_cta_video_block video;
struct di_cta_video_block_priv video;
/* Used for DI_CTA_DATA_BLOCK_YCBCR420 */
struct di_cta_video_block ycbcr420;
struct di_cta_ycbcr420_video_block_priv ycbcr420;
/* used for DI_CTA_DATA_BLOCK_AUDIO */
struct di_cta_audio_block_priv audio;
/* Used for DI_CTA_DATA_BLOCK_SPEAKER_ALLOC */

View file

@ -811,25 +811,37 @@ struct di_cta_svd {
};
/**
* Get an array of short video descriptors from a CTA data block.
*
* Returns NULL if the data block tag is not DI_CTA_DATA_BLOCK_VIDEO.
*
* The returned array is NULL-terminated.
* Video Data Block, defined in section 7.5.1.
*/
const struct di_cta_svd *const *
di_cta_data_block_get_svds(const struct di_cta_data_block *block);
struct di_cta_video_block {
/* Short video descriptors. The array is NULL-terminated. */
const struct di_cta_svd *const *svds;
};
/**
* Get an array of short video descriptors which only allow YCbCr 4:2:0 sampling
* mode from a CTA data block.
* Get the video from a CTA data block.
*
* Returns NULL if the data block tag is not DI_CTA_DATA_BLOCK_VIDEO.
*/
const struct di_cta_video_block *
di_cta_data_block_get_video(const struct di_cta_data_block *block);
/**
* Video Data Block, defined in section 7.5.1.
*/
struct di_cta_ycbcr420_video_block {
/* Short video descriptors which only allow YCbCr 4:2:0 sampling mode.
* The array is NULL-terminated. */
const struct di_cta_svd *const *svds;
};
/**
* Get the YCbCr video from a CTA data block.
*
* Returns NULL if the data block tag is not DI_CTA_DATA_BLOCK_YCBCR420.
*
* The returned array is NULL-terminated.
*/
const struct di_cta_svd *const *
di_cta_data_block_get_ycbcr420_svds(const struct di_cta_data_block *block);
const struct di_cta_ycbcr420_video_block *
di_cta_data_block_get_ycbcr420_video(const struct di_cta_data_block *block);
enum di_cta_vesa_transfer_characteristics_usage {
/* White transfer characteristic */