cta: Return a block struct for audio blocks

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
This commit is contained in:
Sebastian Wick 2023-01-19 04:41:55 +01:00 committed by Sebastian Wick
parent 8d04de834a
commit db6f0a86ce
4 changed files with 23 additions and 14 deletions

13
cta.c
View file

@ -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 *

View file

@ -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:

View file

@ -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 */

View file

@ -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