#include <sound/soc-dapm.h>
#include <sound/tlv.h>
-static struct sdca_control *selector_find_control(struct device *dev,
- struct sdca_entity *entity,
- const int sel)
-{
- int i;
-
- for (i = 0; i < entity->num_controls; i++) {
- struct sdca_control *control = &entity->controls[i];
-
- if (control->sel == sel)
- return control;
- }
-
- dev_err(dev, "%s: control %#x: missing\n", entity->label, sel);
- return NULL;
-}
-
-static struct sdca_control_range *control_find_range(struct device *dev,
- struct sdca_entity *entity,
- struct sdca_control *control,
- int cols, int rows)
-{
- struct sdca_control_range *range = &control->range;
-
- if ((cols && range->cols != cols) || (rows && range->rows != rows) ||
- !range->data) {
- dev_err(dev, "%s: control %#x: ranges invalid (%d,%d)\n",
- entity->label, control->sel, range->cols, range->rows);
- return NULL;
- }
-
- return range;
-}
-
-static struct sdca_control_range *selector_find_range(struct device *dev,
- struct sdca_entity *entity,
- int sel, int cols, int rows)
-{
- struct sdca_control *control;
-
- control = selector_find_control(dev, entity, sel);
- if (!control)
- return NULL;
-
- return control_find_range(dev, entity, control, cols, rows);
-}
-
static bool exported_control(struct sdca_entity *entity, struct sdca_control *control)
{
switch (SDCA_CTL_TYPE(entity->type, control->sel)) {
const char **texts;
int i;
- control = selector_find_control(dev, entity, SDCA_CTL_GE_SELECTED_MODE);
+ control = sdca_selector_find_control(dev, entity, SDCA_CTL_GE_SELECTED_MODE);
if (!control)
return -EINVAL;
dev_warn(dev, "%s: unexpected access layer: %x\n",
entity->label, control->layers);
- range = control_find_range(dev, entity, control, SDCA_SELECTED_MODE_NCOLS, 0);
+ range = sdca_control_find_range(dev, entity, control, SDCA_SELECTED_MODE_NCOLS, 0);
if (!range)
return -EINVAL;
unsigned int mask = 0;
int i;
- control = selector_find_control(dev, entity, SDCA_CTL_PDE_REQUESTED_PS);
+ control = sdca_selector_find_control(dev, entity, SDCA_CTL_PDE_REQUESTED_PS);
if (!control)
return -EINVAL;
dev_warn(dev, "%s: unexpected access layer: %x\n",
entity->label, control->layers);
- range = control_find_range(dev, entity, control, SDCA_REQUESTED_PS_NCOLS, 0);
+ range = sdca_control_find_range(dev, entity, control, SDCA_REQUESTED_PS_NCOLS, 0);
if (!range)
return -EINVAL;
return -EINVAL;
}
- range = selector_find_range(dev, entity->group, SDCA_CTL_GE_SELECTED_MODE,
- SDCA_SELECTED_MODE_NCOLS, 0);
+ range = sdca_selector_find_range(dev, entity->group, SDCA_CTL_GE_SELECTED_MODE,
+ SDCA_SELECTED_MODE_NCOLS, 0);
if (!range)
return -EINVAL;
return -EINVAL;
}
- control = selector_find_control(dev, entity, SDCA_CTL_SU_SELECTOR);
+ control = sdca_selector_find_control(dev, entity, SDCA_CTL_SU_SELECTOR);
if (!control)
return -EINVAL;
return -EINVAL;
}
- control = selector_find_control(dev, entity, SDCA_CTL_MU_MIXER);
+ control = sdca_selector_find_control(dev, entity, SDCA_CTL_MU_MIXER);
if (!control)
return -EINVAL;
/*
* FIXME: For now only handle the simple case of a single linear range
*/
- range = control_find_range(dev, entity, control, SDCA_VOLUME_LINEAR_NCOLS, 1);
+ range = sdca_control_find_range(dev, entity, control, SDCA_VOLUME_LINEAR_NCOLS, 1);
if (!range)
return -EINVAL;
}
if (entity->iot.clock) {
- range = selector_find_range(dev, entity->iot.clock,
- SDCA_CTL_CS_SAMPLERATEINDEX,
- SDCA_SAMPLERATEINDEX_NCOLS, 0);
+ range = sdca_selector_find_range(dev, entity->iot.clock,
+ SDCA_CTL_CS_SAMPLERATEINDEX,
+ SDCA_SAMPLERATEINDEX_NCOLS, 0);
if (!range)
return -EINVAL;
clock_rates = UINT_MAX;
}
- range = selector_find_range(dev, entity, sel, SDCA_USAGE_NCOLS, 0);
+ range = sdca_selector_find_range(dev, entity, sel, SDCA_USAGE_NCOLS, 0);
if (!range)
return -EINVAL;
}
EXPORT_SYMBOL_NS(sdca_parse_function, "SND_SOC_SDCA");
+struct sdca_control *sdca_selector_find_control(struct device *dev,
+ struct sdca_entity *entity,
+ const int sel)
+{
+ int i;
+
+ for (i = 0; i < entity->num_controls; i++) {
+ struct sdca_control *control = &entity->controls[i];
+
+ if (control->sel == sel)
+ return control;
+ }
+
+ dev_err(dev, "%s: control %#x: missing\n", entity->label, sel);
+ return NULL;
+}
+EXPORT_SYMBOL_NS(sdca_selector_find_control, "SND_SOC_SDCA");
+
+struct sdca_control_range *sdca_control_find_range(struct device *dev,
+ struct sdca_entity *entity,
+ struct sdca_control *control,
+ int cols, int rows)
+{
+ struct sdca_control_range *range = &control->range;
+
+ if ((cols && range->cols != cols) || (rows && range->rows != rows) ||
+ !range->data) {
+ dev_err(dev, "%s: control %#x: ranges invalid (%d,%d)\n",
+ entity->label, control->sel, range->cols, range->rows);
+ return NULL;
+ }
+
+ return range;
+}
+EXPORT_SYMBOL_NS(sdca_control_find_range, "SND_SOC_SDCA");
+
+struct sdca_control_range *sdca_selector_find_range(struct device *dev,
+ struct sdca_entity *entity,
+ int sel, int cols, int rows)
+{
+ struct sdca_control *control;
+
+ control = sdca_selector_find_control(dev, entity, sel);
+ if (!control)
+ return NULL;
+
+ return sdca_control_find_range(dev, entity, control, cols, rows);
+}
+EXPORT_SYMBOL_NS(sdca_selector_find_range, "SND_SOC_SDCA");
+
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("SDCA library");