Skip to content

Commit 1bcbb88

Browse files
charleskeepaxbroonie
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2a4667f commit 1bcbb88

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

include/sound/sdca_function.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,25 @@ struct sdca_function_data {
11361136
unsigned int busy_max_delay;
11371137
};
11381138

1139+
static inline u32 sdca_range(struct sdca_control_range *range,
1140+
unsigned int col, unsigned int row)
1141+
{
1142+
return range->data[(row * range->cols) + col];
1143+
}
1144+
1145+
static inline u32 sdca_range_search(struct sdca_control_range *range,
1146+
int search_col, int value, int result_col)
1147+
{
1148+
int i;
1149+
1150+
for (i = 0; i < range->rows; i++) {
1151+
if (sdca_range(range, search_col, i) == value)
1152+
return sdca_range(range, result_col, i);
1153+
}
1154+
1155+
return 0;
1156+
}
1157+
11391158
int sdca_parse_function(struct device *dev,
11401159
struct sdca_function_desc *desc,
11411160
struct sdca_function_data *function);

0 commit comments

Comments
 (0)