Skip to content

Commit

Permalink
tools: tplgtool2: Fix array size calculation for enum values
Browse files Browse the repository at this point in the history
Compute the max name length in terms of number of int32's and use that
set the values array size for parsing the enum controls properly.

Signed-off-by: Ranjani Sridharan <[email protected]>
  • Loading branch information
ranj063 authored and marc-hb committed Sep 9, 2024
1 parent 79a9634 commit 172d5a1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/tplgtool2.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def __init__(self):
self._hw_config_max = 8 # SND_SOC_TPLG_HW_CONFIG_MAX
self._tlv_size = 32 # SND_SOC_TPLG_TLV_SIZE
self._id_name_maxlen = 44 # SNDRV_CTL_ELEM_ID_NAME_MAXLEN
self._id_name_maxint32 = 44 // 4
self._num_texts = 16 # SND_SOC_TPLG_NUM_TEXTS

self._block_header = Struct( # snd_soc_tplg_hdr
Expand Down Expand Up @@ -472,7 +473,7 @@ def __init__(self):
"mask" / Int32ul,
"count" / Int32ul,
"texts" / Array(self._num_texts, String(self._id_name_maxlen, "ascii")),
"values" / Array(self._num_texts * self._id_name_maxlen / 4, Int32ul),
"values" / Array(self._num_texts * self._id_name_maxint32, Int32ul),
"priv" / self._private_raw,
)
self._bytes_control_body = Struct( # `snd_soc_tplg_bytes_control` without `hdr`
Expand Down

0 comments on commit 172d5a1

Please sign in to comment.