Enable Greybus Audio codec driver
Subsystems (3)
Vaibhav Agarwal
maintainercover Enable Greybus Audio codec driver
The existing GB Audio codec driver is dependent on MSM8994 Audio driver. During the development stage, this depdency was configured due to various changes involved in MSM Audio driver to enable addtional codec card and some of the changes proposed in mainline ASoC framework. However, these are not the real dependencies and some of them can be easily removed.
The folowing patch series includes the changes to resolve unnecessary depedencies and make the codec driver functional with the latest kernel.
Patch 1,2: Incudes jack framework related changes.
Patch 3,4,5: Resolves compilation error observed with the latest kernel and also provides helper APIs required to allow dynamic addition/removal of modules.
Patch 6: Finally provides config options and related Makefile changes to enable GB Codec driver.
Thanks to Alexandre for raising the headsup [1] and motivating me to provide the necessary changes.
[1] https://lore.kernel.org/lkml/[email protected]/
Vaibhav Agarwal (6):
staging: greybus: audio: Update snd_jack FW usage as per new APIs
staging: greybus: audio: Maintain jack list within GB Audio module
staging: greybus: audio: Resolve compilation errors for GB codec
module
staging: greybus: audio: Resolve compilation error in topology parser
staging: greybus: audio: Add helper APIs for dynamic audio modules
staging: greybus: audio: Enable GB codec, audio module compilation.
drivers/staging/greybus/Kconfig | 14 ++- drivers/staging/greybus/Makefile | 6 +- drivers/staging/greybus/audio_codec.c | 187 ++++++++++++++++++----------- drivers/staging/greybus/audio_codec.h | 12 +- drivers/staging/greybus/audio_helper.c | 197 +++++++++++++++++++++++++++++++ drivers/staging/greybus/audio_helper.h | 17 +++ drivers/staging/greybus/audio_module.c | 20 ++-- drivers/staging/greybus/audio_topology.c | 130 ++++++++++---------- 8 files changed, 427 insertions(+), 156 deletions(-) create mode 100644 drivers/staging/greybus/audio_helper.c create mode 100644 drivers/staging/greybus/audio_helper.h
Signature · 1 line
2.7.4
Vaibhav Agarwal
maintainerPATCH 1/6 staging: greybus: audio: Update snd_jack FW usage as per new APIs
snd_soc_jack APIs are modified in recent kernel versions. This patch updates the codec driver to resolve the compilation errors related to jack framework.
--- drivers/staging/greybus/audio_codec.c | 59 ++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 12 deletions(-)
drivers/staging/greybus/audio_codec.c +47 -12
@@ -709,17 +709,29 @@ static struct snd_soc_dai_driver gbaudio_dai[] = { };static int gbaudio_init_jack (struct gbaudio_module_info *module, -struct snd_soc_codec *codec) +struct snd_soc_card *card) {int ret; +struct snd_soc_jack *jack; +struct snd_soc_jack_pin *headset, *button; +if (!module->jack_mask)return 0 ;snprintf (module->jack_name,NAME_SIZE ,"GB %d Headset Jack" , module->dev_id); - ret =snd_soc_jack_new (codec, module->jack_name, module->jack_mask, - &module->headset_jack); + + headset =devm_kzalloc (module->dev,sizeof (*headset),GFP_KERNEL ); +if (!headset) +return -ENOMEM ; + + headset->pin = module->jack_name; + headset->mask = module->jack_mask; + jack = &module->headset_jack; + + ret =snd_soc_card_jack_new (card, module->jack_name, module->jack_mask, + jack, headset,1 );if (ret) {dev_err (module->dev,"Failed to create new jack\n" );return ret;
@@ -730,11 +742,21 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,snprintf (module->button_name,NAME_SIZE ,"GB %d Button Jack" , module->dev_id); - ret =snd_soc_jack_new (codec, module->button_name, module->button_mask, - &module->button_jack); + button =devm_kzalloc (module->dev,sizeof (*headset),GFP_KERNEL ); +if (!button) { + ret = -ENOMEM ; + goto free_headset; + } + + button->pin = module->button_name; + button->mask = module->button_mask; + jack = &module->button_jack; + + ret =snd_soc_card_jack_new (card, module->button_name, + module->button_mask, jack, button,1 );if (ret) {dev_err (module->dev,"Failed to create button jack\n" ); -return ret; + goto free_headset; }/*
@@ -750,7 +772,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, KEY_MEDIA);if (ret) {dev_err (module->dev,"Failed to set BTN_0\n" ); -return ret; + goto free_button; } }
@@ -759,7 +781,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, KEY_VOICECOMMAND);if (ret) {dev_err (module->dev,"Failed to set BTN_1\n" ); -return ret; + goto free_button; } }
@@ -768,7 +790,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, KEY_VOLUMEUP);if (ret) {dev_err (module->dev,"Failed to set BTN_2\n" ); -return ret; + goto free_button; } }
@@ -777,7 +799,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, KEY_VOLUMEDOWN);if (ret) {dev_err (module->dev,"Failed to set BTN_0\n" ); -return ret; + goto free_button; } }
@@ -788,6 +810,18 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,*/ return 0 ; + +free_button: + jack = &module->button_jack; +snd_device_free (card->snd_card, jack->jack); +list_del (&jack->list); + +free_headset: + jack = &module->headset_jack; +snd_device_free (card->snd_card, jack->jack); +list_del (&jack->list); + +return ret; }int gbaudio_register_module (struct gbaudio_module_info *module)
@@ -815,7 +849,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module)return -EINVAL ; } - ret =gbaudio_init_jack (module, codec); + ret =gbaudio_init_jack (module, component->card);if (ret) {up_write (&card->controls_rwsem);return ret;
@@ -942,7 +976,8 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)#ifdef CONFIG_SND_JACK /* free jack devices for this module from codec->jack_list */ -list_for_each_entry_safe (jack, next_j, &codec->jack_list, list) { +list_for_each_entry_safe (jack, next_j, &component->card->jack_list, + list) {if (jack == &module->headset_jack) mask =GBCODEC_JACK_MASK ;else if (jack == &module->button_jack)
Signature · 1 line
2.7.4
Vaibhav Agarwal
maintainerPATCH 2/6 staging: greybus: audio: Maintain jack list within GB Audio module
In reply to Vaibhav AgarwalAs per the current implementation for GB codec driver, a jack list is maintained for each module. And it expects the list to be populated by the snd_soc_jack structure which would require modifications in mainstream code.
However, this is not a necessary requirement and the list can be easily maintained within gbaudio_module_info as well. This patch provides the relevant changes for the same.
--- drivers/staging/greybus/audio_codec.c | 76 ++++++++++++++++++---------------- drivers/staging/greybus/audio_codec.h | 10 ++++- drivers/staging/greybus/audio_module.c | 20 +++++---- 3 files changed, 60 insertions(+), 46 deletions(-)
drivers/staging/greybus/audio_codec.c +41 -35
@@ -712,7 +712,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, struct snd_soc_card *card) {int ret; - +struct gbaudio_jack *gba_jack, *n;struct snd_soc_jack *jack;struct snd_soc_jack_pin *headset, *button;
@@ -728,7 +728,8 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, headset->pin = module->jack_name; headset->mask = module->jack_mask; - jack = &module->headset_jack; + gba_jack = &module->headset; + jack = &gba_jack->jack; ret =snd_soc_card_jack_new (card, module->jack_name, module->jack_mask, jack, headset,1 );
@@ -737,6 +738,9 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,return ret; } +/* Add to module's jack list */ +list_add (&gba_jack->list, &module->jack_list); +if (!module->button_mask)return 0 ;
@@ -745,20 +749,24 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, button =devm_kzalloc (module->dev,sizeof (*headset),GFP_KERNEL );if (!button) { ret = -ENOMEM ; - goto free_headset; + goto free_jack; } button->pin = module->button_name; button->mask = module->button_mask; - jack = &module->button_jack; + gba_jack = &module->button; + jack = &gba_jack->jack; ret =snd_soc_card_jack_new (card, module->button_name, module->button_mask, jack, button,1 );if (ret) {dev_err (module->dev,"Failed to create button jack\n" ); - goto free_headset; + goto free_jack; } +/* Add to module's jack list */ +list_add (&gba_jack->list, &module->jack_list); +/* * Currently, max 4 buttons are supported with following key mapping * BTN_0 = KEY_MEDIA
@@ -768,58 +776,55 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,*/ if (module->button_mask &SND_JACK_BTN_0 ) { - ret =snd_jack_set_key (module->button_jack.jack,SND_JACK_BTN_0 , + ret =snd_jack_set_key (jack->jack,SND_JACK_BTN_0 ,KEY_MEDIA );if (ret) {dev_err (module->dev,"Failed to set BTN_0\n" ); - goto free_button; + goto free_jack; } }if (module->button_mask &SND_JACK_BTN_1 ) { - ret =snd_jack_set_key (module->button_jack.jack,SND_JACK_BTN_1 , + ret =snd_jack_set_key (jack->jack,SND_JACK_BTN_1 ,KEY_VOICECOMMAND );if (ret) {dev_err (module->dev,"Failed to set BTN_1\n" ); - goto free_button; + goto free_jack; } }if (module->button_mask &SND_JACK_BTN_2 ) { - ret =snd_jack_set_key (module->button_jack.jack,SND_JACK_BTN_2 , + ret =snd_jack_set_key (jack->jack,SND_JACK_BTN_2 ,KEY_VOLUMEUP );if (ret) {dev_err (module->dev,"Failed to set BTN_2\n" ); - goto free_button; + goto free_jack; } }if (module->button_mask &SND_JACK_BTN_3 ) { - ret =snd_jack_set_key (module->button_jack.jack,SND_JACK_BTN_3 , + ret =snd_jack_set_key (jack->jack,SND_JACK_BTN_3 ,KEY_VOLUMEDOWN );if (ret) {dev_err (module->dev,"Failed to set BTN_0\n" ); - goto free_button; + goto free_jack; } }/* FIXME * verify if this is really required set_bit(INPUT_PROP_NO_DUMMY_RELEASE, -module->button_jack.jack->input_dev->propbit); +module->button->jack->jack->input_dev->propbit); */ return 0 ; -free_button: - jack = &module->button_jack; -snd_device_free (card->snd_card, jack->jack); -list_del (&jack->list); - -free_headset: - jack = &module->headset_jack; -snd_device_free (card->snd_card, jack->jack); -list_del (&jack->list); +free_jack: +list_for_each_entry_safe (gba_jack, n, &module->jack_list, list) { + jack = &gba_jack->jack; +snd_device_free (card->snd_card, jack->jack); +list_del (&gba_jack->list); + }return ret; }
@@ -829,6 +834,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module)int ret;struct snd_soc_codec *codec;struct snd_card *card; +struct gbaudio_jack *gba_jack =NULL ;struct snd_soc_jack *jack =NULL ;if (!gbcodec) {
@@ -874,11 +880,10 @@ int gbaudio_register_module(struct gbaudio_module_info *module)* register jack devices for this module * from codec->jack_list */ -list_for_each_entry (jack, &codec->jack_list, list) { -if ((jack == &module->headset_jack) || - (jack == &module->button_jack)) -snd_device_register (codec->card->snd_card, - jack->jack); +list_for_each_entry (gba_jack, &module->jack_list, list) { + jack = &gba_jack->jack; +snd_device_register (codec->card->snd_card, + jack->jack); }#endif }
@@ -962,7 +967,8 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module) {struct snd_soc_codec *codec = gbcodec->codec;struct snd_card *card = codec->card->snd_card; -struct snd_soc_jack *jack, *next_j; +struct gbaudio_jack *gba_jack, *n; +struct snd_soc_jack *jack;int mask;dev_dbg (codec->dev,"Unregister %s module\n" , module->name);
@@ -975,21 +981,21 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)mutex_unlock (&gbcodec->lock);#ifdef CONFIG_SND_JACK -/* free jack devices for this module from codec->jack_list */ -list_for_each_entry_safe (jack, next_j, &component->card->jack_list, - list) { -if (jack == &module->headset_jack) +/* free jack devices for this module jack_list */ +list_for_each_entry_safe (gba_jack, n, &module->jack_list, list) { +if (gba_jack == &module->headset) mask =GBCODEC_JACK_MASK ; -else if (jack == &module->button_jack) +else if (gba_jack == &module->button) mask =GBCODEC_JACK_BUTTON_MASK ;else mask =0 ;if (mask) { + jack = &gba_jack->jack;dev_dbg (module->dev,"Report %s removal\n" , jack->jack->id);snd_soc_jack_report (jack,0 , mask);snd_device_free (codec->card->snd_card, jack->jack); -list_del (&jack->list); +list_del (&gba_jack->list); } }#endif
drivers/staging/greybus/audio_codec.h +8 -2
@@ -106,6 +106,11 @@ enum gbaudio_module_state { GBAUDIO_MODULE_ON, }; +struct gbaudio_jack { +struct snd_soc_jack jack; +struct list_head list; +}; +struct gbaudio_module_info {/* module info */ struct device *dev;
@@ -130,8 +135,8 @@ struct gbaudio_module_info {int jack_mask;int button_mask;int button_status; -struct snd_soc_jack headset_jack; -struct snd_soc_jack button_jack; +struct gbaudio_jack headset; +struct gbaudio_jack button;/* connection info */ struct gb_connection *mgmt_connection;
@@ -155,6 +160,7 @@ struct gbaudio_module_info {struct list_head widget_list;struct list_head ctl_list;struct list_head widget_ctl_list; +struct list_head jack_list;struct gb_audio_topology *topology; };
drivers/staging/greybus/audio_module.c +11 -9
@@ -21,8 +21,10 @@ static int gbaudio_request_jack(struct gbaudio_module_info *module, struct gb_audio_jack_event_request *req) {int report; -struct snd_jack *jack = module->headset_jack.jack; -struct snd_jack *btn_jack = module->button_jack.jack; +struct snd_soc_jack *hs = &module->headset.jack; +struct snd_soc_jack *btn = &module->button.jack; +struct snd_jack *jack = hs->jack; +struct snd_jack *btn_jack = btn->jack;if (!jack) { dev_err_ratelimited(module->dev,
@@ -38,12 +40,10 @@ static int gbaudio_request_jack(struct gbaudio_module_info *module,if (req->event ==GB_AUDIO_JACK_EVENT_REMOVAL ) { module->jack_type =0 ;if (btn_jack && module->button_status) { -snd_soc_jack_report (&module->button_jack,0 , - module->button_mask); +snd_soc_jack_report (btn,0 , module->button_mask); module->button_status =0 ; } -snd_soc_jack_report (&module->headset_jack,0 , - module->jack_mask); +snd_soc_jack_report (hs,0 , module->jack_mask);return 0 ; }
@@ -61,7 +61,7 @@ static int gbaudio_request_jack(struct gbaudio_module_info *module, module->jack_type, report); module->jack_type = report; -snd_soc_jack_report (&module->headset_jack, report, module->jack_mask); +snd_soc_jack_report (hs, report, module->jack_mask);return 0 ; }
@@ -70,7 +70,8 @@ static int gbaudio_request_button(struct gbaudio_module_info *module, struct gb_audio_button_event_request *req) {int soc_button_id, report; -struct snd_jack *btn_jack = module->button_jack.jack; +struct snd_soc_jack *btn = &module->button.jack; +struct snd_jack *btn_jack = btn->jack;if (!btn_jack) { dev_err_ratelimited(module->dev,
@@ -124,7 +125,7 @@ static int gbaudio_request_button(struct gbaudio_module_info *module, module->button_status = report; -snd_soc_jack_report (&module->button_jack, report, module->button_mask); +snd_soc_jack_report (btn, report, module->button_mask);return 0 ; }
@@ -258,6 +259,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,INIT_LIST_HEAD (&gbmodule->widget_list);INIT_LIST_HEAD (&gbmodule->ctl_list);INIT_LIST_HEAD (&gbmodule->widget_ctl_list); +INIT_LIST_HEAD (&gbmodule->jack_list); gbmodule->dev = dev;snprintf (gbmodule->name,NAME_SIZE ,"%s.%s" , dev->driver->name,dev_name (dev));
Signature · 1 line
2.7.4
Vaibhav Agarwal
maintainerPATCH 3/6 staging: greybus: audio: Resolve compilation errors for GB codec module
In reply to Vaibhav AgarwalDue to dependencies on ASoC framework changes, GB dummy codec module compilation is currently disabled. This patch updates codec driver as per the latest ASoC APIs.
--- drivers/staging/greybus/audio_codec.c | 87 +++++++++++++++++------------------ drivers/staging/greybus/audio_codec.h | 2 +- 2 files changed, 44 insertions(+), 45 deletions(-)
drivers/staging/greybus/audio_codec.c +43 -44
@@ -832,7 +832,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,int gbaudio_register_module (struct gbaudio_module_info *module) {int ret; -struct snd_soc_codec *codec; +struct snd_soc_component *component;struct snd_card *card;struct gbaudio_jack *gba_jack =NULL ;struct snd_soc_jack *jack =NULL ;
@@ -842,8 +842,8 @@ int gbaudio_register_module(struct gbaudio_module_info *module)return -EAGAIN ; } - codec = gbcodec->codec; - card = codec->card->snd_card; + component = gbcodec->component; + card = component->card->snd_card;down_write (&card->controls_rwsem);
@@ -862,19 +862,20 @@ int gbaudio_register_module(struct gbaudio_module_info *module) }if (module->dapm_widgets) -snd_soc_dapm_new_controls (&codec->dapm, module->dapm_widgets, +snd_soc_dapm_new_controls (&component->dapm, + module->dapm_widgets, module->num_dapm_widgets);if (module->controls) -snd_soc_add_codec_controls (codec, module->controls, - module->num_controls); +snd_soc_add_component_controls (component, module->controls, + module->num_controls);if (module->dapm_routes) -snd_soc_dapm_add_routes (&codec->dapm, module->dapm_routes, +snd_soc_dapm_add_routes (&component->dapm, module->dapm_routes, module->num_dapm_routes);/* card already instantiated, create widgets here only */ -if (codec->card->instantiated) { -snd_soc_dapm_link_component_dai_widgets (codec->card, - &codec->dapm); +if (component->card->instantiated) { +snd_soc_dapm_link_component_dai_widgets (component->card, + &component->dapm);#ifdef CONFIG_SND_JACK /* * register jack devices for this module
@@ -882,7 +883,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module)*/ list_for_each_entry (gba_jack, &module->jack_list, list) { jack = &gba_jack->jack; -snd_device_register (codec->card->snd_card, +snd_device_register (component->card->snd_card, jack->jack); }#endif
@@ -892,9 +893,9 @@ int gbaudio_register_module(struct gbaudio_module_info *module)list_add (&module->list, &gbcodec->module_list);mutex_unlock (&gbcodec->lock); -if (codec->card->instantiated) - ret =snd_soc_dapm_new_widgets (&codec->dapm); -dev_dbg (codec->dev,"Registered %s module\n" , module->name); +if (component->card->instantiated) + ret =snd_soc_dapm_new_widgets (component->card); +dev_dbg (component->dev,"Registered %s module\n" , module->name);up_write (&card->controls_rwsem);return ret;
@@ -965,19 +966,19 @@ static void gbaudio_codec_cleanup(struct gbaudio_module_info *module)void gbaudio_unregister_module (struct gbaudio_module_info *module) { -struct snd_soc_codec *codec = gbcodec->codec; -struct snd_card *card = codec->card->snd_card; +struct snd_soc_component *component = gbcodec->component; +struct snd_card *card = component->card->snd_card;struct gbaudio_jack *gba_jack, *n;struct snd_soc_jack *jack;int mask; -dev_dbg (codec->dev,"Unregister %s module\n" , module->name); +dev_dbg (component->dev,"Unregister %s module\n" , module->name);down_write (&card->controls_rwsem);mutex_lock (&gbcodec->lock);gbaudio_codec_cleanup (module);list_del (&module->list); -dev_dbg (codec->dev,"Process Unregister %s module\n" , module->name); +dev_dbg (component->dev,"Process Unregister %s module\n" , module->name);mutex_unlock (&gbcodec->lock);#ifdef CONFIG_SND_JACK
@@ -994,99 +995,97 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)dev_dbg (module->dev,"Report %s removal\n" , jack->jack->id);snd_soc_jack_report (jack,0 , mask); -snd_device_free (codec->card->snd_card, jack->jack); +snd_device_free (component->card->snd_card, jack->jack); list_del(&gba_jack->list); } }#endif if (module->dapm_routes) { -dev_dbg (codec->dev,"Removing %d routes\n" , +dev_dbg (component->dev,"Removing %d routes\n" , module->num_dapm_routes); -snd_soc_dapm_del_routes (&codec->dapm, module->dapm_routes, +snd_soc_dapm_del_routes (&component->dapm, module->dapm_routes, module->num_dapm_routes); }if (module->controls) { -dev_dbg (codec->dev,"Removing %d controls\n" , +dev_dbg (component->dev,"Removing %d controls\n" , module->num_controls); -snd_soc_remove_codec_controls (codec, module->controls, +snd_soc_remove_codec_controls (component, module->controls, module->num_controls); }if (module->dapm_widgets) { -dev_dbg (codec->dev,"Removing %d widgets\n" , +dev_dbg (component->dev,"Removing %d widgets\n" , module->num_dapm_widgets); -snd_soc_dapm_free_controls (&codec->dapm, module->dapm_widgets, +snd_soc_dapm_free_controls (&component->dapm, + module->dapm_widgets, module->num_dapm_widgets); } -dev_dbg (codec->dev,"Unregistered %s module\n" , module->name); +dev_dbg (component->dev,"Unregistered %s module\n" , module->name);up_write (&card->controls_rwsem); }EXPORT_SYMBOL (gbaudio_unregister_module);/* -* codec driver ops +* component driver ops */ -static int gbcodec_probe (struct snd_soc_codec *codec) +static int gbcodec_probe (struct snd_soc_component *component) {int i;struct gbaudio_codec_info *info;struct gbaudio_codec_dai *dai; - info =devm_kzalloc (codec->dev,sizeof (*info),GFP_KERNEL ); + info =devm_kzalloc (component->dev,sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ; - info->dev = codec->dev; + info->dev = component->dev;INIT_LIST_HEAD (&info->module_list);mutex_init (&info->lock);INIT_LIST_HEAD (&info->dai_list);/* init dai_list used to maintain runtime stream info */ for (i =0 ; i <ARRAY_SIZE (gbaudio_dai); i++) { - dai =devm_kzalloc (codec->dev,sizeof (*dai),GFP_KERNEL ); + dai =devm_kzalloc (component->dev,sizeof (*dai),GFP_KERNEL );if (!dai)return -ENOMEM ; dai->id = gbaudio_dai[i].id;list_add (&dai->list, &info->dai_list); } - info->codec = codec; -snd_soc_codec_set_drvdata (codec, info); + info->component = component; +snd_soc_component_set_drvdata (component, info); gbcodec = info; -device_init_wakeup (codec->dev,1 ); +device_init_wakeup (component->dev,1 );return 0 ; } -static int gbcodec_remove (struct snd_soc_codec *codec) +static void gbcodec_remove (struct snd_soc_component *component) {/* Empty function for now */ -return 0 ; +return ; } -static int gbcodec_write (struct snd_soc_codec *codec,unsigned int reg, +static int gbcodec_write (struct snd_soc_component *component,unsigned int reg,unsigned int value) {return 0 ; } -static unsigned int gbcodec_read (struct snd_soc_codec *codec, +static unsigned int gbcodec_read (struct snd_soc_component *component,unsigned int reg) {return 0 ; } -static struct snd_soc_codec_driver soc_codec_dev_gbaudio = { +static const struct snd_soc_component_driver soc_codec_dev_gbaudio = { .probe = gbcodec_probe, .remove = gbcodec_remove, .read = gbcodec_read, .write = gbcodec_write, - - .idle_bias_off = true, - .ignore_pmdown_time =1 , };#ifdef CONFIG_PM
@@ -1110,13 +1109,13 @@ static const struct dev_pm_ops gbaudio_codec_pm_ops = {static int gbaudio_codec_probe (struct platform_device *pdev) { -return snd_soc_register_codec (&pdev->dev, &soc_codec_dev_gbaudio, +return devm_snd_soc_register_component (&pdev->dev, + &soc_codec_dev_gbaudio, gbaudio_dai,ARRAY_SIZE (gbaudio_dai)); }static int gbaudio_codec_remove (struct platform_device *pdev) { -snd_soc_unregister_codec (&pdev->dev);return 0 ; }
drivers/staging/greybus/audio_codec.h +1 -1
@@ -66,7 +66,7 @@ struct gbaudio_codec_dai {struct gbaudio_codec_info {struct device *dev; -struct snd_soc_codec *codec; +struct snd_soc_component *component;struct list_head module_list;/* to maintain runtime stream params for each DAI */ struct list_head dai_list;
Signature · 1 line
2.7.4
Vaibhav Agarwal
maintainerPATCH 4/6 staging: greybus: audio: Resolve compilation error in topology parser
In reply to Vaibhav AgarwalFix compilation errors for GB Audio topology parser code with recent kernel versions.
--- drivers/staging/greybus/audio_topology.c | 130 +++++++++++++++---------------- 1 file changed, 61 insertions(+), 69 deletions(-)
drivers/staging/greybus/audio_topology.c +61 -69
@@ -5,8 +5,8 @@* Copyright 2015-2016 Linaro Ltd. */ +#include <linux/greybus.h> #include "audio_codec.h" -#include "greybus_protocols.h" #define GBAUDIO_INVALID_ID 0xFF
@@ -165,15 +165,15 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,struct gbaudio_ctl_pvt *data;struct gb_audio_ctl_elem_info *info;struct gbaudio_module_info *module; -struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); -struct gbaudio_codec_info *gbcodec =snd_soc_codec_get_drvdata (codec); +struct snd_soc_component *comp =snd_soc_kcontrol_component (kcontrol); +struct gbaudio_codec_info *gb =snd_soc_component_get_drvdata (comp); -dev_dbg (codec->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); +dev_dbg (comp->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); data = (struct gbaudio_ctl_pvt *)kcontrol->private_value; info = (struct gb_audio_ctl_elem_info *)data->info;if (!info) { -dev_err (codec->dev,"NULL info for %s\n" , uinfo->id.name); +dev_err (comp->dev,"NULL info for %s\n" , uinfo->id.name);return -EINVAL ; }
@@ -193,7 +193,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol, uinfo->value.enumerated.items = max;if (uinfo->value.enumerated.item > max -1 ) uinfo->value.enumerated.item = max -1 ; - module =find_gb_module (gbcodec, kcontrol->id.name); + module =find_gb_module (gb, kcontrol->id.name);if (!module)return -EINVAL ; name = gbaudio_map_controlid(module, data->ctl_id,
@@ -201,7 +201,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,strlcpy (uinfo->value.enumerated.name, name,NAME_SIZE );break ;default : -dev_err (codec->dev,"Invalid type: %d for %s:kcontrol\n" , +dev_err (comp->dev,"Invalid type: %d for %s:kcontrol\n" , info->type, kcontrol->id.name);break ; }
@@ -216,11 +216,11 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol,struct gbaudio_ctl_pvt *data;struct gb_audio_ctl_elem_value gbvalue;struct gbaudio_module_info *module; -struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); -struct gbaudio_codec_info *gb =snd_soc_codec_get_drvdata (codec); +struct snd_soc_component *comp =snd_soc_kcontrol_component (kcontrol); +struct gbaudio_codec_info *gb =snd_soc_component_get_drvdata (comp);struct gb_bundle *bundle; -dev_dbg (codec->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); +dev_dbg (comp->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); module =find_gb_module (gb, kcontrol->id.name);if (!module)return -EINVAL ;
@@ -239,7 +239,7 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev,"%d:Error in %s for %s\n" , ret, +dev_err_ratelimited (comp->dev,"%d:Error in %s for %s\n" , ret, __func__, kcontrol->id.name);return ret; }
@@ -262,7 +262,7 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol,le32_to_cpu (gbvalue.value.enumerated_item[1 ]);break ;default : -dev_err (codec->dev,"Invalid type: %d for %s:kcontrol\n" , +dev_err (comp->dev,"Invalid type: %d for %s:kcontrol\n" , info->type, kcontrol->id.name); ret = -EINVAL ;break ;
@@ -278,11 +278,11 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol,struct gbaudio_ctl_pvt *data;struct gb_audio_ctl_elem_value gbvalue;struct gbaudio_module_info *module; -struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); -struct gbaudio_codec_info *gb =snd_soc_codec_get_drvdata (codec); +struct snd_soc_component *comp =snd_soc_kcontrol_component (kcontrol); +struct gbaudio_codec_info *gb =snd_soc_component_get_drvdata (comp);struct gb_bundle *bundle; -dev_dbg (codec->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); +dev_dbg (comp->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); module =find_gb_module (gb, kcontrol->id.name);if (!module)return -EINVAL ;
@@ -309,7 +309,7 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol,cpu_to_le32 (ucontrol->value.enumerated.item[1 ]);break ;default : -dev_err (codec->dev,"Invalid type: %d for %s:kcontrol\n" , +dev_err (comp->dev,"Invalid type: %d for %s:kcontrol\n" , info->type, kcontrol->id.name); ret = -EINVAL ;break ;
@@ -328,7 +328,7 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev,"%d:Error in %s for %s\n" , ret, +dev_err_ratelimited (comp->dev,"%d:Error in %s for %s\n" , ret, __func__, kcontrol->id.name); }
@@ -352,11 +352,7 @@ static int gbcodec_mixer_dapm_ctl_info(struct snd_kcontrol *kcontrol,int platform_max, platform_min;struct gbaudio_ctl_pvt *data;struct gb_audio_ctl_elem_info *info; -struct snd_soc_dapm_widget_list *wlist =snd_kcontrol_chip (kcontrol); -struct snd_soc_dapm_widget *widget = wlist->widgets[0 ]; -struct snd_soc_codec *codec = widget->codec; -dev_dbg (codec->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); data = (struct gbaudio_ctl_pvt *)kcontrol->private_value; info = (struct gb_audio_ctl_elem_info *)data->info;
@@ -387,11 +383,11 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol,struct gbaudio_module_info *module;struct snd_soc_dapm_widget_list *wlist =snd_kcontrol_chip (kcontrol);struct snd_soc_dapm_widget *widget = wlist->widgets[0 ]; -struct snd_soc_codec *codec = widget->codec; -struct gbaudio_codec_info *gb =snd_soc_codec_get_drvdata (codec); +struct device *codec_dev = widget->dapm->dev; +struct gbaudio_codec_info *gb =dev_get_drvdata (codec_dev);struct gb_bundle *bundle; -dev_dbg (codec->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); +dev_dbg (codec_dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); module =find_gb_module (gb, kcontrol->id.name);if (!module)return -EINVAL ;
@@ -415,7 +411,7 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev,"%d:Error in %s for %s\n" , ret, +dev_err_ratelimited (codec_dev,"%d:Error in %s for %s\n" , ret, __func__, kcontrol->id.name);return ret; }
@@ -429,7 +425,7 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol,static int gbcodec_mixer_dapm_ctl_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -int ret, wi, max, connect; +int ret, wi, max;unsigned int mask, val;struct gb_audio_ctl_elem_info *info;struct gbaudio_ctl_pvt *data;
@@ -437,11 +433,12 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,struct gbaudio_module_info *module;struct snd_soc_dapm_widget_list *wlist =snd_kcontrol_chip (kcontrol);struct snd_soc_dapm_widget *widget = wlist->widgets[0 ]; -struct snd_soc_codec *codec = widget->codec; -struct gbaudio_codec_info *gb =snd_soc_codec_get_drvdata (codec); +struct device *codec_dev = widget->dapm->dev; +struct gbaudio_codec_info *gb =dev_get_drvdata (codec_dev); +struct snd_soc_dapm_update *update =NULL ;struct gb_bundle *bundle; -dev_dbg (codec->dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); +dev_dbg (codec_dev,"Entered %s:%s\n" , __func__, kcontrol->id.name); module =find_gb_module (gb, kcontrol->id.name);if (!module)return -EINVAL ;
@@ -458,17 +455,13 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, max =le32_to_cpu (info->value.integer.max); mask = (1 <<fls (max)) -1 ; val = ucontrol->value.integer.value[0 ] & mask; - connect = !!val;/* update ucontrol */ if (gbvalue.value.integer_value[0 ] != val) {for (wi =0 ; wi < wlist->num_widgets; wi++) { widget = wlist->widgets[wi]; - - widget->value = val; - widget->dapm->update =NULL ; -snd_soc_dapm_mixer_update_power (widget, kcontrol, - connect); +snd_soc_dapm_mixer_update_power (widget->dapm, kcontrol, + val, update); } gbvalue.value.integer_value[0 ] =cpu_to_le32 (ucontrol->value.integer.value[0 ]);
@@ -484,7 +477,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev, +dev_err_ratelimited (codec_dev,"%d:Error in %s for %s\n" , ret, __func__, kcontrol->id.name);return ret;
@@ -553,11 +546,11 @@ static int gbcodec_enum_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {int ret, ctl_id; -struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); +struct snd_soc_component *comp =snd_soc_kcontrol_component (kcontrol); +struct gbaudio_codec_info *gb =snd_soc_component_get_drvdata (comp);struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;struct gb_audio_ctl_elem_value gbvalue;struct gbaudio_module_info *module; -struct gbaudio_codec_info *gb =snd_soc_codec_get_drvdata (codec);struct gb_bundle *bundle; module =find_gb_module (gb, kcontrol->id.name);
@@ -580,7 +573,7 @@ static int gbcodec_enum_ctl_get(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev,"%d:Error in %s for %s\n" , ret, +dev_err_ratelimited (comp->dev,"%d:Error in %s for %s\n" , ret, __func__, kcontrol->id.name);return ret; }
@@ -598,11 +591,11 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {int ret, ctl_id; -struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); +struct snd_soc_component *comp =snd_soc_kcontrol_component (kcontrol); +struct gbaudio_codec_info *gb =snd_soc_component_get_drvdata (comp);struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;struct gb_audio_ctl_elem_value gbvalue;struct gbaudio_module_info *module; -struct gbaudio_codec_info *gb =snd_soc_codec_get_drvdata (codec);struct gb_bundle *bundle; module =find_gb_module (gb, kcontrol->id.name);
@@ -613,13 +606,13 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol,if (ctl_id <0 )return -EINVAL ; -if (ucontrol->value.enumerated.item[0 ] > e->max -1 ) +if (ucontrol->value.enumerated.item[0 ] > e->items -1 )return -EINVAL ; gbvalue.value.enumerated_item[0 ] =cpu_to_le32 (ucontrol->value.enumerated.item[0 ]);if (e->shift_l != e->shift_r) { -if (ucontrol->value.enumerated.item[1 ] > e->max -1 ) +if (ucontrol->value.enumerated.item[1 ] > e->items -1 )return -EINVAL ; gbvalue.value.enumerated_item[1 ] =cpu_to_le32 (ucontrol->value.enumerated.item[1 ]);
@@ -637,8 +630,8 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev,"%d:Error in %s for %s\n" , ret, - __func__, kcontrol->id.name); +dev_err_ratelimited (comp->dev,"%d:Error in %s for %s\n" , + ret, __func__, kcontrol->id.name); }return ret;
@@ -659,13 +652,13 @@ static int gbaudio_tplg_create_enum_kctl(struct gbaudio_module_info *gb, gb_enum = &ctl->info.value.enumerated;/* since count=1, and reg is dummy */ - gbe->max =le32_to_cpu (gb_enum->items); + gbe->items =le32_to_cpu (gb_enum->items); gbe->texts =gb_generate_enum_strings (gb, gb_enum);/* debug enum info */ -dev_dbg (gb->dev,"Max:%d, name_length:%d\n" , gbe->max, +dev_dbg (gb->dev,"Max:%d, name_length:%d\n" , gbe->items,le16_to_cpu (gb_enum->names_length)); -for (i =0 ; i < gbe->max; i++) +for (i =0 ; i < gbe->items; i++)dev_dbg (gb->dev,"src[%d]: %s\n" , i, gbe->texts[i]); *kctl = (struct snd_kcontrol_new)
@@ -720,8 +713,8 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol,struct snd_soc_dapm_widget *widget = wlist->widgets[0 ];struct gbaudio_module_info *module;struct gb_audio_ctl_elem_value gbvalue; -struct snd_soc_codec *codec = widget->codec; -struct gbaudio_codec_info *gb =snd_soc_codec_get_drvdata (codec); +struct device *codec_dev = widget->dapm->dev; +struct gbaudio_codec_info *gb =dev_get_drvdata (codec_dev);struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;struct gb_bundle *bundle;
@@ -745,7 +738,7 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev,"%d:Error in %s for %s\n" , ret, +dev_err_ratelimited (codec_dev,"%d:Error in %s for %s\n" , ret, __func__, kcontrol->id.name);return ret; }
@@ -768,12 +761,13 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,struct snd_soc_dapm_widget *widget = wlist->widgets[0 ];struct gb_audio_ctl_elem_value gbvalue;struct gbaudio_module_info *module; -struct snd_soc_codec *codec = widget->codec; -struct gbaudio_codec_info *gb =snd_soc_codec_get_drvdata (codec); +struct device *codec_dev = widget->dapm->dev; +struct gbaudio_codec_info *gb =dev_get_drvdata (codec_dev);struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;struct gb_bundle *bundle; +struct snd_soc_dapm_update *update =NULL ; -if (ucontrol->value.enumerated.item[0 ] > e->max -1 ) +if (ucontrol->value.enumerated.item[0 ] > e->items -1 )return -EINVAL ; module =find_gb_module (gb, kcontrol->id.name);
@@ -797,7 +791,7 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev,"%d:Error in %s for %s\n" , ret, +dev_err_ratelimited (codec_dev,"%d:Error in %s for %s\n" , ret, __func__, kcontrol->id.name);return ret; }
@@ -814,7 +808,7 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, }if (e->shift_l != e->shift_r) { -if (ucontrol->value.enumerated.item[1 ] > e->max -1 ) +if (ucontrol->value.enumerated.item[1 ] > e->items -1 )return -EINVAL ; val |= ucontrol->value.enumerated.item[1 ] << e->shift_r; mask |= e->mask << e->shift_r;
@@ -837,16 +831,14 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,gb_pm_runtime_put_autosuspend (bundle);if (ret) { -dev_err_ratelimited (codec->dev, +dev_err_ratelimited (codec_dev,"%d:Error in %s for %s\n" , ret, __func__, kcontrol->id.name); }for (wi =0 ; wi < wlist->num_widgets; wi++) { widget = wlist->widgets[wi]; - - widget->value = val; - widget->dapm->update =NULL ; -snd_soc_dapm_mux_update_power (widget, kcontrol, mux, e); +snd_soc_dapm_mux_update_power (widget->dapm, kcontrol, + val, e, update); } }
@@ -868,13 +860,13 @@ static int gbaudio_tplg_create_enum_ctl(struct gbaudio_module_info *gb, gb_enum = &ctl->info.value.enumerated;/* since count=1, and reg is dummy */ - gbe->max =le32_to_cpu (gb_enum->items); + gbe->items =le32_to_cpu (gb_enum->items); gbe->texts =gb_generate_enum_strings (gb, gb_enum);/* debug enum info */ -dev_dbg (gb->dev,"Max:%d, name_length:%d\n" , gbe->max, +dev_dbg (gb->dev,"Max:%d, name_length:%d\n" , gbe->items,le16_to_cpu (gb_enum->names_length)); -for (i =0 ; i < gbe->max; i++) +for (i =0 ; i < gbe->items; i++)dev_dbg (gb->dev,"src[%d]: %s\n" , i, gbe->texts[i]); *kctl = (struct snd_kcontrol_new)
@@ -935,12 +927,12 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w, {int wid;int ret; -struct snd_soc_codec *codec = w->codec; -struct gbaudio_codec_info *gbcodec =snd_soc_codec_get_drvdata (codec); +struct device *codec_dev = w->dapm->dev; +struct gbaudio_codec_info *gbcodec =dev_get_drvdata (codec_dev);struct gbaudio_module_info *module;struct gb_bundle *bundle; -dev_dbg (codec->dev,"%s %s %d\n" , __func__, w->name, event); +dev_dbg (codec_dev,"%s %s %d\n" , __func__, w->name, event);/* Find relevant module */ module =find_gb_module (gbcodec, w->name);
@@ -950,7 +942,7 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w,/* map name to widget id */ wid =gbaudio_map_widgetname (module, w->name);if (wid <0 ) { -dev_err (codec->dev,"Invalid widget name:%s\n" , w->name); +dev_err (codec_dev,"Invalid widget name:%s\n" , w->name);return -EINVAL ; }
@@ -973,7 +965,7 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w,break ; }if (ret) -dev_err_ratelimited (codec->dev, +dev_err_ratelimited (codec_dev,"%d: widget, event:%d failed:%d\n" , wid, event, ret);
Signature · 1 line
2.7.4
Vaibhav Agarwal
maintainerPATCH 5/6 staging: greybus: audio: Add helper APIs for dynamic audio modules
In reply to Vaibhav AgarwalGreybus Codec driver allows modules to be dynamically added and removed, which further requires updating the DAPM configurations as well.
With current snd_soc architecture, dynamic audio modules is not yet supported. This patch provides helper APIs to update DAPM configurations in response to modules which are dynamically added or removed. The source is primarily based on snd_dapm.c
--- drivers/staging/greybus/Makefile | 2 +- drivers/staging/greybus/audio_codec.c | 13 ++- drivers/staging/greybus/audio_helper.c | 197 +++++++++++++++++++++++++++++++++ drivers/staging/greybus/audio_helper.h | 17 +++ 4 files changed, 224 insertions(+), 5 deletions(-) create mode 100644 drivers/staging/greybus/audio_helper.c create mode 100644 drivers/staging/greybus/audio_helper.h
drivers/staging/greybus/Makefile +1 -1
@@ -28,7 +28,7 @@ obj-$(CONFIG_GREYBUS_VIBRATOR) += gb-vibrator.o # Greybus Audio is a bunch of modules gb-audio-module-y := audio_module.o audio_topology.o -gb-audio-codec-y := audio_codec.o +gb-audio-codec-y := audio_codec.o audio_helper.o gb-audio-gb-y := audio_gb.o gb-audio-apbridgea-y := audio_apbridgea.o gb-audio-manager-y := audio_manager.o audio_manager_module.o
drivers/staging/greybus/audio_codec.c +9 -4
@@ -14,6 +14,7 @@#include "audio_codec.h" #include "audio_apbridgea.h" #include "audio_manager.h" +#include "audio_helper.h" static struct gbaudio_codec_info *gbcodec;
@@ -874,7 +875,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module)/* card already instantiated, create widgets here only */ if (component->card->instantiated) { -snd_soc_dapm_link_component_dai_widgets (component->card, +gbaudio_dapm_link_component_dai_widgets (component->card, &component->dapm);#ifdef CONFIG_SND_JACK /*
@@ -1004,19 +1005,23 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)if (module->dapm_routes) {dev_dbg (component->dev,"Removing %d routes\n" , module->num_dapm_routes); +/* verify routes with controls are removed */ snd_soc_dapm_del_routes (&component->dapm, module->dapm_routes, module->num_dapm_routes); }if (module->controls) {dev_dbg (component->dev,"Removing %d controls\n" , module->num_controls); -snd_soc_remove_codec_controls (component, module->controls, - module->num_controls); +/* release control semaphore */ +up_write (&card->controls_rwsem); +gbaudio_remove_component_controls (component, module->controls, + module->num_controls); +down_write (&card->controls_rwsem); }if (module->dapm_widgets) {dev_dbg (component->dev,"Removing %d widgets\n" , module->num_dapm_widgets); -snd_soc_dapm_free_controls (&component->dapm, +gbaudio_dapm_free_controls (&component->dapm, module->dapm_widgets, module->num_dapm_widgets); }
drivers/staging/greybus/audio_helper.c new file +197 -0
197 lines not on this page · raw message
drivers/staging/greybus/audio_helper.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Greybus Audio Sound SoC helper APIs +*/ + +#ifndef __LINUX_GBAUDIO_HELPER_H +#define __LINUX_GBAUDIO_HELPER_H + +int gbaudio_dapm_link_component_dai_widgets (struct snd_soc_card *card, +struct snd_soc_dapm_context *dapm); +int gbaudio_dapm_free_controls (struct snd_soc_dapm_context *dapm, +const struct snd_soc_dapm_widget *widget, +int num); +int gbaudio_remove_component_controls (struct snd_soc_component *component, +const struct snd_kcontrol_new *controls, +unsigned int num_controls); +#endif
Signature · 1 line
2.7.4
Vaibhav Agarwal
maintainerPATCH 6/6 staging: greybus: audio: Enable GB codec, audio module compilation.
In reply to Vaibhav AgarwalCurrently, GB codec and audio module is conditionally compiled based on GREYBUS_AUDIO_MSM8994. However, audio module is not dependent on MSM8994 platform and can be used generically with any platform that follows GB Audio class specification.
Also, GB codec driver corresponds to dummy codec represented by I2S port available on Toshiba AP Bridge. Added config option for the same in kconfig file and accordingly updated Makefile.
--- drivers/staging/greybus/Kconfig | 14 +++++++++++++- drivers/staging/greybus/Makefile | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/staging/greybus/Kconfig +13 -1
@@ -3,7 +3,7 @@ if GREYBUS config GREYBUS_AUDIO tristate "Greybus Audio Class driver" - depends on SOUND + depends on SOUND && SND_SOC ---help--- Select this option if you have a device that follows the Greybus Audio Class specification.
@@ -11,6 +11,18 @@ config GREYBUS_AUDIO To compile this code as a module, chose M here: the module will be called gb-audio.ko +config GREYBUS_AUDIO_APB_CODEC + tristate "Greybus APBridge Audio codec driver" + depends on SND_SOC && GREYBUS_AUDIO + help + Select this option if you have a Toshiba APB device that has I2S + ports and acts as a Greybus "Dummy codec". This device is a + bridge from an APB-I2S port to a Unipro network. + + To compile this code as a module, chose M here: the module + will be called gb-audio-codec.ko + + config GREYBUS_BOOTROM tristate "Greybus Bootrom Class driver" ---help---
drivers/staging/greybus/Makefile +2 -2
@@ -40,8 +40,8 @@ gb-audio-manager-y := audio_manager.o audio_manager_module.o #ccflags-y += -DGB_AUDIO_MANAGER_SYSFS #endif -obj-$(CONFIG_GREYBUS_AUDIO_MSM8994) += gb-audio-codec.o -obj-$(CONFIG_GREYBUS_AUDIO_MSM8994) += gb-audio-module.o +obj-$(CONFIG_GREYBUS_AUDIO_APB_CODEC) += gb-audio-codec.o +obj-$(CONFIG_GREYBUS_AUDIO_APB_CODEC) += gb-audio-module.o obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-gb.o obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-apbridgea.o obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-manager.o
Signature · 1 line
2.7.4
Re: [PATCH V1 5/6] staging: greybus: audio: Add helper APIs for dynamic audio modules
In reply to Vaibhav AgarwalHi,
Quoted 8 lines · Vaibhav Agarwal
Greybus Codec driver allows modules to be dynamically added and removed, which further requires updating the DAPM configurations as well.
With current
snd_socarchitecture, dynamic audio modules is not yet supported. This patch provides helper APIs to update DAPM configurations in response to modules which are dynamically added or removed. The source is primarily based onsnd_dapm.c
I really think you should send this patch series to the ASoC maintainers, especially this patch. The main goal shouldn't be to simply fix compilation issues but to try to get the driver out of staging else, the current situation will happen again.
Quoted 300 lines
Signed-off-by Vaibhav Agarwal <[email protected]>--- drivers/staging/greybus/Makefile | 2 +- drivers/staging/greybus/audio_codec.c | 13 ++- drivers/staging/greybus/audio_helper.c | 197 +++++++++++++++++++++++++++++++++ drivers/staging/greybus/audio_helper.h | 17 +++ 4 files changed, 224 insertions(+), 5 deletions(-) create mode 100644 drivers/staging/greybus/audio_helper.c create mode 100644 drivers/staging/greybus/audio_helper.hdrivers/staging/greybus/Makefile +1
-1@@ -28,7 +28,7 @@ obj-$(CONFIG_GREYBUS_VIBRATOR) += gb-vibrator.o # Greybus Audio is a bunch of modules gb-audio-module-y := audio_module.o audio_topology.o -gb-audio-codec-y := audio_codec.o +gb-audio-codec-y := audio_codec.o audio_helper.o gb-audio-gb-y := audio_gb.o gb-audio-apbridgea-y := audio_apbridgea.o gb-audio-manager-y := audio_manager.o audio_manager_module.odrivers/staging/greybus/audio_codec.c +9
-4@@ -14,6 +14,7 @@#include "audio_codec.h" #include "audio_apbridgea.h" #include "audio_manager.h" +#include "audio_helper.h" static struct gbaudio_codec_info *gbcodec;@@ -874,7 +875,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module)/* card already instantiated, create widgets here only */ if (component->card->instantiated) { -snd_soc_dapm_link_component_dai_widgets (component->card, +gbaudio_dapm_link_component_dai_widgets (component->card, &component->dapm);#ifdef CONFIG_SND_JACK /* @@ -1004,19 +1005,23 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)if (module->dapm_routes) {dev_dbg (component->dev,"Removing %d routes\n" , module->num_dapm_routes); +/* verify routes with controls are removed */ snd_soc_dapm_del_routes (&component->dapm, module->dapm_routes, module->num_dapm_routes); }if (module->controls) {dev_dbg (component->dev,"Removing %d controls\n" , module->num_controls); -snd_soc_remove_codec_controls (component, module->controls, - module->num_controls); +/* release control semaphore */ +up_write (&card->controls_rwsem); +gbaudio_remove_component_controls (component, module->controls, + module->num_controls); +down_write (&card->controls_rwsem); }if (module->dapm_widgets) {dev_dbg (component->dev,"Removing %d widgets\n" , module->num_dapm_widgets); -snd_soc_dapm_free_controls (&component->dapm, +gbaudio_dapm_free_controls (&component->dapm, module->dapm_widgets, module->num_dapm_widgets); }drivers/staging/greybus/audio_helper.c new file +197
-0@@ -0,0 +1,197 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Greybus Audio Sound SoC helper APIs +*/ + +#include <linux/debugfs.h> +#include <sound/core.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> + +#define gbaudio_dapm_for_each_direction (dir) \ + for ((dir) = SND_SOC_DAPM_DIR_IN; (dir) <= SND_SOC_DAPM_DIR_OUT; \ + (dir)++) + +static void gbaudio_dapm_link_dai_widget (struct snd_soc_dapm_widget *dai_w, +struct snd_soc_card *card) +{ +struct snd_soc_dapm_widget *w; +struct snd_soc_dapm_widget *src, *sink; +struct snd_soc_dai *dai = dai_w->priv; + +/* ...find all widgets with the same stream and link them */ +list_for_each_entry (w, &card->widgets, list) { +if (w->dapm != dai_w->dapm) +continue ; + +switch (w->id) { +case snd_soc_dapm_dai_in: +case snd_soc_dapm_dai_out: +continue ; +default : +break ; + } + +if (!w->sname || !strstr (w->sname, dai_w->sname)) +continue ; + +/* +* check if widget is already linked, +* if (w->linked) +* return; +*/ + +if (dai_w->id == snd_soc_dapm_dai_in) { + src = dai_w; + sink = w; + }else { + src = w; + sink = dai_w; + } +dev_dbg (dai->dev,"%s -> %s\n" , src->name, sink->name); +/* Add the DAPM path and set widget's linked status +* snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); +* w->linked = 1; +*/ + } +} + +int gbaudio_dapm_link_component_dai_widgets (struct snd_soc_card *card, +struct snd_soc_dapm_context *dapm) +{ +struct snd_soc_dapm_widget *dai_w; + +/* For each DAI widget... */ +list_for_each_entry (dai_w, &card->widgets, list) { +if (dai_w->dapm != dapm) +continue ; +switch (dai_w->id) { +case snd_soc_dapm_dai_in: +case snd_soc_dapm_dai_out: +break ; +default : +continue ; + } +gbaudio_dapm_link_dai_widget (dai_w, card); + } + +return 0 ; +} + +static void gbaudio_dapm_free_path (struct snd_soc_dapm_path *path) +{ +list_del (&path->list_node[SND_SOC_DAPM_DIR_IN ]); +list_del (&path->list_node[SND_SOC_DAPM_DIR_OUT ]); +list_del (&path->list_kcontrol); +list_del (&path->list); +kfree (path); +} + +static void gbaudio_dapm_free_widget (struct snd_soc_dapm_widget *w) +{ +struct snd_soc_dapm_path *p, *next_p; +enum snd_soc_dapm_direction dir; + +list_del (&w->list); +/* +* remove source and sink paths associated to this widget. +* While removing the path, remove reference to it from both +* source and sink widgets so that path is removed only once. +*/ +gbaudio_dapm_for_each_direction (dir) { +snd_soc_dapm_widget_for_each_path_safe (w, dir, p, next_p) +gbaudio_dapm_free_path (p); + } + +kfree (w->kcontrols); +kfree_const (w->name); +kfree_const (w->sname); +kfree (w); +} + +int gbaudio_dapm_free_controls (struct snd_soc_dapm_context *dapm, +const struct snd_soc_dapm_widget *widget, +int num) +{ +int i; +struct snd_soc_dapm_widget *w, *next_w; +#ifdef CONFIG_DEBUG_FS +struct dentry *parent = dapm->debugfs_dapm; +struct dentry *debugfs_w =NULL ; +#endif + +mutex_lock (&dapm->card->dapm_mutex); +for (i =0 ; i < num; i++) { +/* below logic can be optimized to identify widget pointer */ +list_for_each_entry_safe (w, next_w, &dapm->card->widgets, + list) { +if (w->dapm != dapm) +continue ; +if (!strcmp (w->name, widget->name)) +break ; + w =NULL ; + } +if (!w) { +dev_err (dapm->dev,"%s: widget not found\n" , + widget->name); +return -EINVAL ; + } + widget++; +#ifdef CONFIG_DEBUG_FS +if (!parent) + debugfs_w =debugfs_lookup (w->name, parent); +debugfs_remove (debugfs_w); + debugfs_w =NULL ; +#endif +gbaudio_dapm_free_widget (w); + } +mutex_unlock (&dapm->card->dapm_mutex); +return 0 ; +} + +static int gbaudio_remove_controls (struct snd_card *card,struct device *dev, +const struct snd_kcontrol_new *controls, +int num_controls,const char *prefix) +{ +int i, err; + +for (i =0 ; i < num_controls; i++) { +const struct snd_kcontrol_new *control = &controls[i]; +struct snd_ctl_elem_id id; +struct snd_kcontrol *kctl; + +if (prefix) +snprintf (id.name,sizeof (id.name),"%s %s" , prefix, + control->name); +else +strlcpy (id.name, control->name,sizeof (id.name)); + id.numid =0 ; + id.iface = control->iface; + id.device = control->device; + id.subdevice = control->subdevice; + id.index = control->index; + kctl =snd_ctl_find_id (card, &id); +if (!kctl) { +dev_err (dev,"%d: Failed to find %s\n" , err, + control->name); +return -ENOENT ; + } + err =snd_ctl_remove (card, kctl); +if (err <0 ) { +dev_err (dev,"%d: Failed to remove %s\n" , err, + control->name); +return err; + } + } +return 0 ; +} + +int gbaudio_remove_component_controls (struct snd_soc_component *component, +const struct snd_kcontrol_new *controls, +unsigned int num_controls) +{ +struct snd_card *card = component->card->snd_card; + +return gbaudio_remove_controls (card, component->dev, controls, + num_controls, component->name_prefix); +}drivers/staging/greybus/audio_helper.h new file +17
-0@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Greybus Audio Sound SoC helper APIs +*/ + +#ifndef __LINUX_GBAUDIO_HELPER_H +#define __LINUX_GBAUDIO_HELPER_H + +int gbaudio_dapm_link_component_dai_widgets (struct snd_soc_card *card, +struct snd_soc_dapm_context *dapm); +int gbaudio_dapm_free_controls (struct snd_soc_dapm_context *dapm, +const struct snd_soc_dapm_widget *widget, +int num); +int gbaudio_remove_component_controls (struct snd_soc_component *component, +const struct snd_kcontrol_new *controls, +unsigned int num_controls); +#endif Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
kbuild test robot
build botRe: [PATCH V1 6/6] staging: greybus: audio: Enable GB codec, audio module compilation.
In reply to Vaibhav AgarwalI love your patch! Perhaps something to improve:
Hi Vaibhav,
I love your patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v5.7-rc5 next-20200515]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Vaibhav-Agarwal/Enable-Greybus-Audio-codec-driver/20200518-012023 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git cef077e6aa4c7dbe2f23e1201cf705f9540ec467 config: i386-allyesconfig (attached as .config) reproduce: # apt-get install sparse # sparse version: v0.6.1-193-gb8fad4bc-dirty # save the attached .config to linux build tree make C=1 ARCH=i386 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> drivers/staging/greybus/audio_codec.c:691:36: sparse: sparse: incorrect type in initializer (different base types) @@ expected unsigned long long [usertype] formats @@ got restricteunsigned long long [usertype] formats @@ >> drivers/staging/greybus/audio_codec.c:691:36: sparse: expected unsigned long long [usertype] formats >> drivers/staging/greybus/audio_codec.c:691:36: sparse: got restricted snd_pcm_format_t [usertype]
drivers/staging/greybus/audio_codec.c:701:36: sparse: sparse: incorrect type in initializer (different base types) @@ expected unsigned long long [usertype] formats @@ got restricteunsigned long long [usertype] formats @@
drivers/staging/greybus/audio_codec.c:701:36: sparse: expected unsigned long long [usertype] formats
drivers/staging/greybus/audio_codec.c:701:36: sparse: got restricted snd_pcm_format_t [usertype]
--
>> drivers/staging/greybus/audio_module.c:223:25: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le16 [usertype] data_cport @@ got tricted __le16 [usertype] data_cport @@ >> drivers/staging/greybus/audio_module.c:223:25: sparse: expected restricted __le16 [usertype] data_cport >> drivers/staging/greybus/audio_module.c:223:25: sparse: got unsigned short [usertype] intf_cport_id -- >> drivers/staging/greybus/audio_topology.c:183:24: sparse: sparse: cast to restricted snd_ctl_elem_type_t >> drivers/staging/greybus/audio_topology.c:460:40: sparse: sparse: restricted __le32 degrades to integer >> drivers/staging/greybus/audio_topology.c:691:41: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int access @@ got restricted __le3unsigned int access @@ >> drivers/staging/greybus/audio_topology.c:691:41: sparse: expected unsigned int access >> drivers/staging/greybus/audio_topology.c:691:41: sparse: got restricted __le32 [usertype] access >> drivers/staging/greybus/audio_topology.c:678:14: sparse: sparse: restricted snd_ctl_elem_iface_t degrades to integer >> drivers/staging/greybus/audio_topology.c:746:44: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restrunsigned int @@ >> drivers/staging/greybus/audio_topology.c:746:44: sparse: expected unsigned int >> drivers/staging/greybus/audio_topology.c:746:44: sparse: got restricted __le32 drivers/staging/greybus/audio_topology.c:748:52: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restrunsigned int @@ drivers/staging/greybus/audio_topology.c:748:52: sparse: expected unsigned int drivers/staging/greybus/audio_topology.c:748:52: sparse: got restricted __le32 drivers/staging/greybus/audio_topology.c:803:42: sparse: sparse: restricted __le32 degrades to integer >> drivers/staging/greybus/audio_topology.c:806:50: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 @@ got icted __le32 @@ >> drivers/staging/greybus/audio_topology.c:806:50: sparse: expected restricted __le32 >> drivers/staging/greybus/audio_topology.c:806:50: sparse: got unsigned int
drivers/staging/greybus/audio_topology.c:815:50: sparse: sparse: restricted __le32 degrades to integer
drivers/staging/greybus/audio_topology.c:818:58: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 @@ got icted __le32 @@
drivers/staging/greybus/audio_topology.c:818:58: sparse: expected restricted __le32
drivers/staging/greybus/audio_topology.c:818:58: sparse: got unsigned int
drivers/staging/greybus/audio_topology.c:890:25: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int access @@ got restricted __le3unsigned int access @@
drivers/staging/greybus/audio_topology.c:890:25: sparse: expected unsigned int access
drivers/staging/greybus/audio_topology.c:890:25: sparse: got restricted __le32 [usertype] access
drivers/staging/greybus/audio_topology.c:906:14: sparse: sparse: restricted snd_ctl_elem_iface_t degrades to integer
vim +691 drivers/staging/greybus/audio_codec.c
d3d2af51f9c2f29 drivers/staging/greybus/audio-codec.c Vaibhav Agarwal 2015-11-23 683
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 684 static struct snd_soc_dai_driver gbaudio_dai[] = {
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 685 {
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 686 .name = "apb-i2s0",
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 687 .id = 0,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 688 .playback = {
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 689 .stream_name = "I2S 0 Playback",
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 690 .rates = SNDRV_PCM_RATE_48000,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 @691 .formats = SNDRV_PCM_FORMAT_S16_LE,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 692 .rate_max = 48000,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 693 .rate_min = 48000,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 694 .channels_min = 1,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 695 .channels_max = 2,
1023ab9c3800e58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2017-01-18 696 .sig_bits = 16,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 697 },
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 698 .capture = {
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 699 .stream_name = "I2S 0 Capture",
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 700 .rates = SNDRV_PCM_RATE_48000,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 701 .formats = SNDRV_PCM_FORMAT_S16_LE,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 702 .rate_max = 48000,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 703 .rate_min = 48000,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 704 .channels_min = 1,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 705 .channels_max = 2,
1023ab9c3800e58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2017-01-18 706 .sig_bits = 16,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 707 },
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 708 .ops = &gbcodec_dai_ops,
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 709 },
19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 710 };19866603be2ad58 drivers/staging/greybus/audio_codec.c Vaibhav Agarwal 2016-08-04 711
:::::: The code at line 691 was first introduced by commit
:::::: 19866603be2ad58735f82511f3d5f680e61479ea greybus: audio: Maintain runtime stream params for each DAI
:::::: TO: Vaibhav Agarwal <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Vaibhav Agarwal
maintainerRe: [PATCH V1 5/6] staging: greybus: audio: Add helper APIs for dynamic audio modules
In reply to Alexandre BelloniQuoted 12 lines · Alexandre Belloni
Hi,
Quoted 8 lines · Vaibhav Agarwal
Greybus Codec driver allows modules to be dynamically added and removed, which further requires updating the DAPM configurations as well.
With current
snd_socarchitecture, dynamic audio modules is not yet supported. This patch provides helper APIs to update DAPM configurations in response to modules which are dynamically added or removed. The source is primarily based onsnd_dapm.c
Quoted 4 lines
I really think you should send this patch series to the ASoC maintainers, especially this patch. The main goal shouldn't be to simply fix compilation issues but to try to get the driver out of staging else, the current situation will happen again.
Agree Alexandre. I'll share this with ASoC maintainers as well.
Also, I'm seeking opinion regarding the scope of pushing GB Audio out of staging tree. I'm keen to make the relevant changes and work actively for the same. However, I don't have a real device to test the latest code and thus not sure if the changes can be pushed to sound soc tree. GB maintainers, kindly share your opinion.
--
Regards,
Vaibhav
kbuild test robot
build botRe: [PATCH V1 6/6] staging: greybus: audio: Enable GB codec, audio module compilation.
In reply to Vaibhav AgarwalI love your patch! Perhaps something to improve:
Hi Vaibhav,
I love your patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v5.7-rc6 next-20200518]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Vaibhav-Agarwal/Enable-Greybus-Audio-codec-driver/20200518-012023 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git cef077e6aa4c7dbe2f23e1201cf705f9540ec467 config: nds32-allyesconfig (attached as .config) compiler: nds32le-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> drivers/staging/greybus/audio_helper.c:59:5: warning: no previous prototype for 'gbaudio_dapm_link_component_dai_widgets' [-Wmissing-prototypes] 59 | int gbaudio_dapm_link_component_dai_widgets(struct snd_soc_card *card, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/staging/greybus/audio_helper.c:112:5: warning: no previous prototype for 'gbaudio_dapm_free_controls' [-Wmissing-prototypes] 112 | int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, | ^~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/staging/greybus/audio_helper.c:189:5: warning: no previous prototype for 'gbaudio_remove_component_controls' [-Wmissing-prototypes]
189 | int gbaudio_remove_component_controls(struct snd_soc_component *component,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--drivers/staging/greybus/audio_topology.c: In function 'find_gb_module':
>> drivers/staging/greybus/audio_topology.c:31:14: warning: variable 'ret' set but not used [-Wunused-but-set-variable] 31 | int dev_id, ret; | ^~~ drivers/staging/greybus/audio_topology.c: In function 'gbcodec_mixer_dapm_ctl_get': >> drivers/staging/greybus/audio_topology.c:380:33: warning: variable 'info' set but not used [-Wunused-but-set-variable]
380 | struct gb_audio_ctl_elem_info *info;
| ^~~~
vim +/gbaudio_dapm_link_component_dai_widgets +59 drivers/staging/greybus/audio_helper.c
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 58
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 @59 int gbaudio_dapm_link_component_dai_widgets(struct snd_soc_card *card,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 60 struct snd_soc_dapm_context *dapm)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 61 {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 62 struct snd_soc_dapm_widget *dai_w;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 63
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 64 /* For each DAI widget... */
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 65 list_for_each_entry(dai_w, &card->widgets, list) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 66 if (dai_w->dapm != dapm)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 67 continue;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 68 switch (dai_w->id) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 69 case snd_soc_dapm_dai_in:
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 70 case snd_soc_dapm_dai_out:
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 71 break;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 72 default:
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 73 continue;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 74 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 75 gbaudio_dapm_link_dai_widget(dai_w, card);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 76 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 77
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 78 return 0;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 79 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 80
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 81 static void gbaudio_dapm_free_path(struct snd_soc_dapm_path *path)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 82 {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 83 list_del(&path->list_node[SND_SOC_DAPM_DIR_IN]);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 84 list_del(&path->list_node[SND_SOC_DAPM_DIR_OUT]);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 85 list_del(&path->list_kcontrol);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 86 list_del(&path->list);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 87 kfree(path);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 88 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 89
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 90 static void gbaudio_dapm_free_widget(struct snd_soc_dapm_widget *w)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 91 {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 92 struct snd_soc_dapm_path *p, *next_p;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 93 enum snd_soc_dapm_direction dir;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 94
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 95 list_del(&w->list);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 96 /*
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 97 * remove source and sink paths associated to this widget.
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 98 * While removing the path, remove reference to it from both
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 99 * source and sink widgets so that path is removed only once.
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 100 */
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 101 gbaudio_dapm_for_each_direction(dir) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 102 snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 103 gbaudio_dapm_free_path(p);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 104 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 105
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 106 kfree(w->kcontrols);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 107 kfree_const(w->name);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 108 kfree_const(w->sname);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 109 kfree(w);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 110 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 111
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 @112 int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 113 const struct snd_soc_dapm_widget *widget,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 114 int num)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 115 {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 116 int i;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 117 struct snd_soc_dapm_widget *w, *next_w;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 118 #ifdef CONFIG_DEBUG_FS
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 119 struct dentry *parent = dapm->debugfs_dapm;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 120 struct dentry *debugfs_w = NULL;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 121 #endif
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 122
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 123 mutex_lock(&dapm->card->dapm_mutex);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 124 for (i = 0; i < num; i++) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 125 /* below logic can be optimized to identify widget pointer */
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 126 list_for_each_entry_safe(w, next_w, &dapm->card->widgets,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 127 list) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 128 if (w->dapm != dapm)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 129 continue;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 130 if (!strcmp(w->name, widget->name))
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 131 break;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 132 w = NULL;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 133 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 134 if (!w) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 135 dev_err(dapm->dev, "%s: widget not found\n",
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 136 widget->name);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 137 return -EINVAL;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 138 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 139 widget++;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 140 #ifdef CONFIG_DEBUG_FS
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 141 if (!parent)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 142 debugfs_w = debugfs_lookup(w->name, parent);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 143 debugfs_remove(debugfs_w);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 144 debugfs_w = NULL;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 145 #endif
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 146 gbaudio_dapm_free_widget(w);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 147 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 148 mutex_unlock(&dapm->card->dapm_mutex);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 149 return 0;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 150 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 151
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 152 static int gbaudio_remove_controls(struct snd_card *card, struct device *dev,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 153 const struct snd_kcontrol_new *controls,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 154 int num_controls, const char *prefix)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 155 {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 156 int i, err;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 157
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 158 for (i = 0; i < num_controls; i++) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 159 const struct snd_kcontrol_new *control = &controls[i];
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 160 struct snd_ctl_elem_id id;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 161 struct snd_kcontrol *kctl;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 162
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 163 if (prefix)
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 164 snprintf(id.name, sizeof(id.name), "%s %s", prefix,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 165 control->name);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 166 else
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 167 strlcpy(id.name, control->name, sizeof(id.name));
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 168 id.numid = 0;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 169 id.iface = control->iface;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 170 id.device = control->device;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 171 id.subdevice = control->subdevice;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 172 id.index = control->index;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 173 kctl = snd_ctl_find_id(card, &id);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 174 if (!kctl) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 175 dev_err(dev, "%d: Failed to find %s\n", err,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 176 control->name);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 177 return -ENOENT;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 178 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 179 err = snd_ctl_remove(card, kctl);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 180 if (err < 0) {
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 181 dev_err(dev, "%d: Failed to remove %s\n", err,
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 182 control->name);
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 183 return err;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 184 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 185 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 186 return 0;
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 187 }
94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 188 94b08a33fd1bcaa Vaibhav Agarwal 2020-05-17 @189 int gbaudio_remove_component_controls(struct snd_soc_component *component,
:::::: The code at line 59 was first introduced by commit
:::::: 94b08a33fd1bcaa8660430f8107b5c7bbfbca3b4 staging: greybus: audio: Add helper APIs for dynamic audio modules
:::::: TO: Vaibhav Agarwal <[email protected]>
:::::: CC: 0day robot <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kbuild test robot
build botRe: [PATCH V1 6/6] staging: greybus: audio: Enable GB codec, audio module compilation.
In reply to Vaibhav AgarwalI love your patch! Perhaps something to improve:
Hi Vaibhav,
I love your patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v5.7-rc6 next-20200519]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Vaibhav-Agarwal/Enable-Greybus-Audio-codec-driver/20200518-012023 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git cef077e6aa4c7dbe2f23e1201cf705f9540ec467 config: x86_64-allyesconfig (attached as .config) compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 135b877874fae96b4372c8a3fbfaa8ff44ff86e3)
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> drivers/staging/greybus/audio_helper.c:59:5: warning: no previous prototype for function 'gbaudio_dapm_link_component_dai_widgets' [-Wmissing-prototypes]
int gbaudio_dapm_link_component_dai_widgets(struct snd_soc_card *card,
^drivers/staging/greybus/audio_helper.c:59:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int gbaudio_dapm_link_component_dai_widgets(struct snd_soc_card *card,
^
static
>> drivers/staging/greybus/audio_helper.c:112:5: warning: no previous prototype for function 'gbaudio_dapm_free_controls' [-Wmissing-prototypes]
int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
^drivers/staging/greybus/audio_helper.c:112:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
^
static
>> drivers/staging/greybus/audio_helper.c:189:5: warning: no previous prototype for function 'gbaudio_remove_component_controls' [-Wmissing-prototypes]
int gbaudio_remove_component_controls(struct snd_soc_component *component,
^drivers/staging/greybus/audio_helper.c:189:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int gbaudio_remove_component_controls(struct snd_soc_component *component,
^
static
3 warnings generated.
vim +/gbaudio_dapm_link_component_dai_widgets +59 drivers/staging/greybus/audio_helper.c
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 58
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 @59 int gbaudio_dapm_link_component_dai_widgets(struct snd_soc_card *card,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 60 struct snd_soc_dapm_context *dapm)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 61 {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 62 struct snd_soc_dapm_widget *dai_w;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 63
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 64 /* For each DAI widget... */
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 65 list_for_each_entry(dai_w, &card->widgets, list) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 66 if (dai_w->dapm != dapm)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 67 continue;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 68 switch (dai_w->id) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 69 case snd_soc_dapm_dai_in:
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 70 case snd_soc_dapm_dai_out:
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 71 break;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 72 default:
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 73 continue;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 74 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 75 gbaudio_dapm_link_dai_widget(dai_w, card);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 76 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 77
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 78 return 0;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 79 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 80
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 81 static void gbaudio_dapm_free_path(struct snd_soc_dapm_path *path)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 82 {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 83 list_del(&path->list_node[SND_SOC_DAPM_DIR_IN]);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 84 list_del(&path->list_node[SND_SOC_DAPM_DIR_OUT]);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 85 list_del(&path->list_kcontrol);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 86 list_del(&path->list);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 87 kfree(path);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 88 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 89
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 90 static void gbaudio_dapm_free_widget(struct snd_soc_dapm_widget *w)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 91 {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 92 struct snd_soc_dapm_path *p, *next_p;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 93 enum snd_soc_dapm_direction dir;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 94
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 95 list_del(&w->list);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 96 /*
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 97 * remove source and sink paths associated to this widget.
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 98 * While removing the path, remove reference to it from both
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 99 * source and sink widgets so that path is removed only once.
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 100 */
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 101 gbaudio_dapm_for_each_direction(dir) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 102 snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 103 gbaudio_dapm_free_path(p);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 104 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 105
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 106 kfree(w->kcontrols);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 107 kfree_const(w->name);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 108 kfree_const(w->sname);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 109 kfree(w);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 110 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 111
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 @112 int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 113 const struct snd_soc_dapm_widget *widget,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 114 int num)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 115 {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 116 int i;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 117 struct snd_soc_dapm_widget *w, *next_w;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 118 #ifdef CONFIG_DEBUG_FS
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 119 struct dentry *parent = dapm->debugfs_dapm;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 120 struct dentry *debugfs_w = NULL;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 121 #endif
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 122
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 123 mutex_lock(&dapm->card->dapm_mutex);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 124 for (i = 0; i < num; i++) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 125 /* below logic can be optimized to identify widget pointer */
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 126 list_for_each_entry_safe(w, next_w, &dapm->card->widgets,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 127 list) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 128 if (w->dapm != dapm)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 129 continue;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 130 if (!strcmp(w->name, widget->name))
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 131 break;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 132 w = NULL;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 133 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 134 if (!w) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 135 dev_err(dapm->dev, "%s: widget not found\n",
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 136 widget->name);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 137 return -EINVAL;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 138 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 139 widget++;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 140 #ifdef CONFIG_DEBUG_FS
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 141 if (!parent)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 142 debugfs_w = debugfs_lookup(w->name, parent);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 143 debugfs_remove(debugfs_w);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 144 debugfs_w = NULL;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 145 #endif
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 146 gbaudio_dapm_free_widget(w);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 147 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 148 mutex_unlock(&dapm->card->dapm_mutex);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 149 return 0;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 150 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 151
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 152 static int gbaudio_remove_controls(struct snd_card *card, struct device *dev,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 153 const struct snd_kcontrol_new *controls,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 154 int num_controls, const char *prefix)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 155 {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 156 int i, err;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 157
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 158 for (i = 0; i < num_controls; i++) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 159 const struct snd_kcontrol_new *control = &controls[i];
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 160 struct snd_ctl_elem_id id;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 161 struct snd_kcontrol *kctl;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 162
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 163 if (prefix)
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 164 snprintf(id.name, sizeof(id.name), "%s %s", prefix,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 165 control->name);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 166 else
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 167 strlcpy(id.name, control->name, sizeof(id.name));
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 168 id.numid = 0;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 169 id.iface = control->iface;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 170 id.device = control->device;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 171 id.subdevice = control->subdevice;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 172 id.index = control->index;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 173 kctl = snd_ctl_find_id(card, &id);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 174 if (!kctl) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 175 dev_err(dev, "%d: Failed to find %s\n", err,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 176 control->name);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 177 return -ENOENT;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 178 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 179 err = snd_ctl_remove(card, kctl);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 180 if (err < 0) {
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 181 dev_err(dev, "%d: Failed to remove %s\n", err,
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 182 control->name);
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 183 return err;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 184 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 185 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 186 return 0;
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 187 }
94b08a33fd1bca Vaibhav Agarwal 2020-05-17 188 94b08a33fd1bca Vaibhav Agarwal 2020-05-17 @189 int gbaudio_remove_component_controls(struct snd_soc_component *component,
:::::: The code at line 59 was first introduced by commit
:::::: 94b08a33fd1bcaa8660430f8107b5c7bbfbca3b4 staging: greybus: audio: Add helper APIs for dynamic audio modules
:::::: TO: Vaibhav Agarwal <[email protected]>
:::::: CC: 0day robot <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org