greybus: audio: topology: Add helper API to map controlid with widget name
This API is used by enumerated controls .get/.set callback functions to fetch control id associated with a widget. Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org> Reviewed-by: Mark Greer <mark.greer@animalcreek.com> Signed-off-by: Alex Elder <elder@linaro.org>
This commit is contained in:
Родитель
957ccca08a
Коммит
0c15a9e0f3
|
@ -123,6 +123,7 @@ struct gbaudio_widget {
|
||||||
struct gbaudio_control {
|
struct gbaudio_control {
|
||||||
__u8 id;
|
__u8 id;
|
||||||
char *name;
|
char *name;
|
||||||
|
char *wname;
|
||||||
const char * const *texts;
|
const char * const *texts;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,6 +77,20 @@ static const char *gbaudio_map_controlid(struct gbaudio_module_info *module,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int gbaudio_map_wcontrolname(struct gbaudio_module_info *module,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
struct gbaudio_control *control;
|
||||||
|
|
||||||
|
list_for_each_entry(control, &module->widget_ctl_list, list) {
|
||||||
|
if (!strncmp(control->wname, name, NAME_SIZE))
|
||||||
|
return control->id;
|
||||||
|
}
|
||||||
|
dev_warn(module->dev, "%s: missing in modules controls list\n", name);
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
static int gbaudio_map_widgetname(struct gbaudio_module_info *module,
|
static int gbaudio_map_widgetname(struct gbaudio_module_info *module,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
|
@ -652,6 +666,8 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
|
||||||
}
|
}
|
||||||
control->id = curr->id;
|
control->id = curr->id;
|
||||||
control->name = curr->name;
|
control->name = curr->name;
|
||||||
|
control->wname = w->name;
|
||||||
|
|
||||||
if (curr->info.type == GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED)
|
if (curr->info.type == GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED)
|
||||||
control->texts = (const char * const *)
|
control->texts = (const char * const *)
|
||||||
curr->info.value.enumerated.names;
|
curr->info.value.enumerated.names;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче