From d013195750fe348c5a25a77f4e203f2f0baa1281 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 11 Jun 2024 14:50:15 +0200 Subject: [PATCH] cta: Return a block struct for speaker locations Signed-off-by: Sebastian Wick --- cta.c | 12 +++++++----- include/cta.h | 8 +++++--- include/libdisplay-info/cta.h | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/cta.c b/cta.c index 723b19c..456b625 100644 --- a/cta.c +++ b/cta.c @@ -1500,10 +1500,10 @@ parse_room_config_block(struct di_edid_cta *cta, static bool parse_speaker_location_block(struct di_edid_cta *cta, - struct di_cta_speaker_location_block *sldb, + struct di_cta_speaker_location_priv *sldb, const uint8_t *data, size_t size) { - struct di_cta_speaker_locations speaker_loc, *slp; + struct di_cta_speaker_location_descriptor speaker_loc, *slp; if (size < 2) { add_failure(cta, "Speaker Location Data Block: Empty Data Block with length %u.", @@ -1545,6 +1545,8 @@ parse_speaker_location_block(struct di_edid_cta *cta, sldb->locations[sldb->locations_len++] = slp; } + sldb->base.locations = + (const struct di_cta_speaker_location_descriptor *const *)sldb->locations; return true; } @@ -1602,7 +1604,7 @@ destroy_data_block(struct di_cta_data_block *data_block) 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_speaker_location_priv *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; @@ -2100,13 +2102,13 @@ di_cta_data_block_get_infoframe(const struct di_cta_data_block *block) return &block->infoframe.block; } -const struct di_cta_speaker_locations *const * +const struct di_cta_speaker_location_block * di_cta_data_block_get_speaker_locations(const struct di_cta_data_block *block) { if (block->tag != DI_CTA_DATA_BLOCK_SPEAKER_LOCATION) { return NULL; } - return (const struct di_cta_speaker_locations *const *) block->speaker_location.locations; + return &block->speaker_location.base; } const struct di_displayid_type_i_ii_vii_timing * diff --git a/include/cta.h b/include/cta.h index ca5eb5b..804954b 100644 --- a/include/cta.h +++ b/include/cta.h @@ -166,13 +166,15 @@ struct di_cta_hdmi_audio_block_priv { struct di_cta_infoframe_block_priv { struct di_cta_infoframe_block block; + /* NULL-terminated */ struct di_cta_infoframe_descriptor *infoframes[EDID_CTA_INFOFRAME_BLOCK_ENTRIES + 1]; size_t infoframes_len; }; -struct di_cta_speaker_location_block { +struct di_cta_speaker_location_priv { + struct di_cta_speaker_location_block base; /* NULL-terminated */ - struct di_cta_speaker_locations *locations[EDID_CTA_MAX_SPEAKER_LOCATION_BLOCK_ENTRIES + 1]; + struct di_cta_speaker_location_descriptor *locations[EDID_CTA_MAX_SPEAKER_LOCATION_BLOCK_ENTRIES + 1]; size_t locations_len; }; @@ -214,7 +216,7 @@ struct di_cta_data_block { /* Used for DI_CTA_DATA_BLOCK_ROOM_CONFIG */ struct di_cta_room_configuration_block room_config; /* Used for DI_CTA_DATA_BLOCK_SPEAKER_LOCATION */ - struct di_cta_speaker_location_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; /* Used for DI_CTA_DATA_BLOCK_DISPLAYID_VIDEO_TIMING_VII */ diff --git a/include/libdisplay-info/cta.h b/include/libdisplay-info/cta.h index 319531a..c67d8c8 100644 --- a/include/libdisplay-info/cta.h +++ b/include/libdisplay-info/cta.h @@ -1096,9 +1096,9 @@ enum di_cta_speaker_placement { }; /** - * Speaker Location Data Block, defined in section 7.5.16. + * Speaker Location Descriptor, defined in section 7.5.16. */ -struct di_cta_speaker_locations { +struct di_cta_speaker_location_descriptor { /* Index of the audio channel where the audio for the described speaker * is to be transmitted. */ int channel_index; @@ -1113,13 +1113,19 @@ struct di_cta_speaker_locations { }; /** - * Get an array of Speaker Locations. + * Speaker Location Data Block, defined in section 7.5.16. + */ +struct di_cta_speaker_location_block { + /* Speaker Location Descriptors. The array is NULL-terminated. */ + const struct di_cta_speaker_location_descriptor *const *locations; +}; + +/** + * Get the Speaker Locations from a CTA data block. * * Returns NULL if the data block tag is not DI_CTA_DATA_BLOCK_SPEAKER_LOCATION. - * - * The returned array is NULL-terminated. */ -const struct di_cta_speaker_locations *const * +const struct di_cta_speaker_location_block * di_cta_data_block_get_speaker_locations(const struct di_cta_data_block *block); /**