From db6f0a86cecc2e56b2a147e20e89a22126a5f1fc Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 19 Jan 2023 04:41:55 +0100 Subject: [PATCH] cta: Return a block struct for audio blocks Signed-off-by: Sebastian Wick --- cta.c | 13 +++++++------ di-edid-decode/cta.c | 2 +- include/cta.h | 5 +++-- include/libdisplay-info/cta.h | 17 ++++++++++++----- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/cta.c b/cta.c index 14d9b30..03a4b55 100644 --- a/cta.c +++ b/cta.c @@ -228,7 +228,7 @@ parse_sad_format(struct di_edid_cta *cta, uint8_t code, uint8_t code_ext, } static bool -parse_sad(struct di_edid_cta *cta, struct di_cta_audio_block *audio, +parse_sad(struct di_edid_cta *cta, struct di_cta_audio_block_priv *audio, const uint8_t data[static CTA_SAD_SIZE]) { enum di_cta_audio_format format; @@ -505,7 +505,7 @@ parse_sad(struct di_edid_cta *cta, struct di_cta_audio_block *audio, } static bool -parse_audio_block(struct di_edid_cta *cta, struct di_cta_audio_block *audio, +parse_audio_block(struct di_edid_cta *cta, struct di_cta_audio_block_priv *audio, const uint8_t *data, size_t size) { size_t i; @@ -518,6 +518,7 @@ parse_audio_block(struct di_edid_cta *cta, struct di_cta_audio_block *audio, return false; } + audio->audio.sads = (const struct di_cta_sad *const *) audio->sads; return true; } @@ -1597,7 +1598,7 @@ destroy_data_block(struct di_cta_data_block *data_block) { size_t i; struct di_cta_video_block *video; - struct di_cta_audio_block *audio; + 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; @@ -1988,13 +1989,13 @@ di_cta_data_block_get_svrs(const struct di_cta_data_block *block) return (const struct di_cta_svr *const *) block->video_format_pref.svrs; } -const struct di_cta_sad *const * -di_cta_data_block_get_sads(const struct di_cta_data_block *block) +const struct di_cta_audio_block * +di_cta_data_block_get_audio(const struct di_cta_data_block *block) { if (block->tag != DI_CTA_DATA_BLOCK_AUDIO) { return NULL; } - return (const struct di_cta_sad *const *) block->audio.sads; + return &block->audio.audio; } const struct di_cta_speaker_alloc_block * diff --git a/di-edid-decode/cta.c b/di-edid-decode/cta.c index 2871495..9d13138 100644 --- a/di-edid-decode/cta.c +++ b/di-edid-decode/cta.c @@ -1006,7 +1006,7 @@ print_cta(const struct di_edid_cta *cta) print_cta_vesa_transfer_characteristics(transfer_characteristics); break; case DI_CTA_DATA_BLOCK_AUDIO: - sads = di_cta_data_block_get_sads(data_block); + sads = di_cta_data_block_get_audio(data_block)->sads; print_cta_sads(sads); break; case DI_CTA_DATA_BLOCK_YCBCR420_CAP_MAP: diff --git a/include/cta.h b/include/cta.h index 0f08a15..61e750e 100644 --- a/include/cta.h +++ b/include/cta.h @@ -134,7 +134,8 @@ struct di_cta_sad_priv { struct di_cta_sad_wma_pro wma_pro; }; -struct di_cta_audio_block { +struct di_cta_audio_block_priv { + struct di_cta_audio_block audio; /* NULL-terminated */ struct di_cta_sad_priv *sads[EDID_CTA_MAX_AUDIO_BLOCK_ENTRIES + 1]; size_t sads_len; @@ -181,7 +182,7 @@ struct di_cta_data_block { /* Used for DI_CTA_DATA_BLOCK_YCBCR420 */ struct di_cta_video_block ycbcr420; /* used for DI_CTA_DATA_BLOCK_AUDIO */ - struct di_cta_audio_block audio; + struct di_cta_audio_block_priv audio; /* Used for DI_CTA_DATA_BLOCK_SPEAKER_ALLOC */ struct di_cta_speaker_alloc_block speaker_alloc; /* Used for DI_CTA_DATA_BLOCK_VIDEO_CAP */ diff --git a/include/libdisplay-info/cta.h b/include/libdisplay-info/cta.h index 4da484e..fd72881 100644 --- a/include/libdisplay-info/cta.h +++ b/include/libdisplay-info/cta.h @@ -343,15 +343,22 @@ struct di_cta_sad { const struct di_cta_sad_wma_pro *wma_pro; }; + /** - * Get an array of short audio descriptors from a CTA data block. + * Audio Data Block, defined in section 7.5.2. + */ +struct di_cta_audio_block { + /* Short audio descriptors. The array is NULL-terminated. */ + const struct di_cta_sad *const *sads; +}; + +/** + * Get the audio from a CTA data block. * * Returns NULL if the data block tag is not DI_CTA_DATA_BLOCK_AUDIO. - * - * The returned array is NULL-terminated. */ -const struct di_cta_sad *const * -di_cta_data_block_get_sads(const struct di_cta_data_block *data_block); +const struct di_cta_audio_block * +di_cta_data_block_get_audio(const struct di_cta_data_block *data_block); /** * Indicates which speakers are present. See figure 6 for the meaning of the