diff options
author | Charles Keepax <ckeepax@opensource.cirrus.com> | 2025-03-12 17:22:04 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2025-03-16 23:27:57 +0000 |
commit | 1bcbb88bedb17804491e692a3f1a38223e09152c (patch) | |
tree | 9dda64cbd405b69695cddb39c5aec1e4666f7032 | |
parent | 2a4667f3d589524bd2fbfe4f7dc0e2f12b832e10 (diff) |
ASoC: SDCA: Add SDCA Control Range data access helper
SDCA Ranges are two dimensional arrays of data associated with controls,
add a helper to provide an x,y access mechanism to the data and a helper
to locate a specific value inside a range.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20250312172205.4152686-6-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | include/sound/sdca_function.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/sound/sdca_function.h b/include/sound/sdca_function.h index ca0376903e87..d7489e3c7e47 100644 --- a/include/sound/sdca_function.h +++ b/include/sound/sdca_function.h @@ -1136,6 +1136,25 @@ struct sdca_function_data { unsigned int busy_max_delay; }; +static inline u32 sdca_range(struct sdca_control_range *range, + unsigned int col, unsigned int row) +{ + return range->data[(row * range->cols) + col]; +} + +static inline u32 sdca_range_search(struct sdca_control_range *range, + int search_col, int value, int result_col) +{ + int i; + + for (i = 0; i < range->rows; i++) { + if (sdca_range(range, search_col, i) == value) + return sdca_range(range, result_col, i); + } + + return 0; +} + int sdca_parse_function(struct device *dev, struct sdca_function_desc *desc, struct sdca_function_data *function); |