Commit 105f1c28 authored by Mark Brown's avatar Mark Brown Committed by Jaroslav Kysela

[ALSA] soc - DAPM - Bulk route registration

ASoC codecs and machine drivers that use DAPM routes all cut'n'paste a
loop iterating over a null terminated array of routes.  Factor out this
into a bulk registration function, improving the error reporting for
most users, and deprecate the old API to help out of tree users pick up
the changes.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Graeme Gregory <graeme@openmoko.org>
Cc: Frank Mandarino <fmandarino@endrelia.com>
Cc: Jarkko Nikula <jarkko.nikula@nokia.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 4ba1327a
...@@ -193,6 +193,7 @@ struct snd_soc_dapm_widget; ...@@ -193,6 +193,7 @@ struct snd_soc_dapm_widget;
enum snd_soc_dapm_type; enum snd_soc_dapm_type;
struct snd_soc_dapm_path; struct snd_soc_dapm_path;
struct snd_soc_dapm_pin; struct snd_soc_dapm_pin;
struct snd_soc_dapm_route;
/* dapm controls */ /* dapm controls */
int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
...@@ -210,10 +211,12 @@ int snd_soc_dapm_new_controls(struct snd_soc_codec *codec, ...@@ -210,10 +211,12 @@ int snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
int num); int num);
/* dapm path setup */ /* dapm path setup */
int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, int __deprecated snd_soc_dapm_connect_input(struct snd_soc_codec *codec,
const char *sink_name, const char *control_name, const char *src_name); const char *sink_name, const char *control_name, const char *src_name);
int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec); int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec);
void snd_soc_dapm_free(struct snd_soc_device *socdev); void snd_soc_dapm_free(struct snd_soc_device *socdev);
int snd_soc_dapm_add_routes(struct snd_soc_codec *codec,
const struct snd_soc_dapm_route *route, int num);
/* dapm events */ /* dapm events */
int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream, int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream,
...@@ -250,6 +253,18 @@ enum snd_soc_dapm_type { ...@@ -250,6 +253,18 @@ enum snd_soc_dapm_type {
snd_soc_dapm_post, /* machine specific post widget - exec last */ snd_soc_dapm_post, /* machine specific post widget - exec last */
}; };
/*
* DAPM audio route definition.
*
* Defines an audio route originating at source via control and finishing
* at sink.
*/
struct snd_soc_dapm_route {
const char *sink;
const char *control;
const char *source;
};
/* dapm audio path between two widgets */ /* dapm audio path between two widgets */
struct snd_soc_dapm_path { struct snd_soc_dapm_path {
char *name; char *name;
......
...@@ -841,21 +841,8 @@ int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec) ...@@ -841,21 +841,8 @@ int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec)
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_endpoints); EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_endpoints);
/** static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
* snd_soc_dapm_connect_input - connect dapm widgets const char *sink, const char *control, const char *source)
* @codec: audio codec
* @sink: name of target widget
* @control: mixer control name
* @source: name of source name
*
* Connects 2 dapm widgets together via a named audio path. The sink is
* the widget receiving the audio signal, whilst the source is the sender
* of the audio signal.
*
* Returns 0 for success else error.
*/
int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink,
const char * control, const char *source)
{ {
struct snd_soc_dapm_path *path; struct snd_soc_dapm_path *path;
struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w; struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w;
...@@ -957,8 +944,63 @@ int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink, ...@@ -957,8 +944,63 @@ int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink,
kfree(path); kfree(path);
return ret; return ret;
} }
/**
* snd_soc_dapm_connect_input - connect dapm widgets
* @codec: audio codec
* @sink: name of target widget
* @control: mixer control name
* @source: name of source name
*
* Connects 2 dapm widgets together via a named audio path. The sink is
* the widget receiving the audio signal, whilst the source is the sender
* of the audio signal.
*
* This function has been deprecated in favour of snd_soc_dapm_add_routes().
*
* Returns 0 for success else error.
*/
int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink,
const char *control, const char *source)
{
return snd_soc_dapm_add_route(codec, sink, control, source);
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_connect_input); EXPORT_SYMBOL_GPL(snd_soc_dapm_connect_input);
/**
* snd_soc_dapm_add_routes - Add routes between DAPM widgets
* @codec: codec
* @route: audio routes
* @num: number of routes
*
* Connects 2 dapm widgets together via a named audio path. The sink is
* the widget receiving the audio signal, whilst the source is the sender
* of the audio signal.
*
* Returns 0 for success else error. On error all resources can be freed
* with a call to snd_soc_card_free().
*/
int snd_soc_dapm_add_routes(struct snd_soc_codec *codec,
const struct snd_soc_dapm_route *route, int num)
{
int i, ret;
for (i = 0; i < num; i++) {
ret = snd_soc_dapm_add_route(codec, route->sink,
route->control, route->source);
if (ret < 0) {
printk(KERN_ERR "Failed to add route %s->%s\n",
route->source,
route->sink);
return ret;
}
route++;
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
/** /**
* snd_soc_dapm_new_widgets - add new dapm widgets * snd_soc_dapm_new_widgets - add new dapm widgets
* @codec: audio codec * @codec: audio codec
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment