[alsa-devel] [PATCH] ASoC: core - Add platform IO tracing
Trace platform IO just like CODEC IO.
Signed-off-by: Liam Girdwood lrg@ti.com --- include/trace/events/asoc.h | 45 +++++++++++++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 2 + 2 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/include/trace/events/asoc.h b/include/trace/events/asoc.h index ae973d2..603f5a0 100644 --- a/include/trace/events/asoc.h +++ b/include/trace/events/asoc.h @@ -9,6 +9,7 @@
struct snd_soc_jack; struct snd_soc_codec; +struct snd_soc_platform; struct snd_soc_card; struct snd_soc_dapm_widget;
@@ -59,6 +60,50 @@ DEFINE_EVENT(snd_soc_reg, snd_soc_reg_read,
);
+DECLARE_EVENT_CLASS(snd_soc_preg, + + TP_PROTO(struct snd_soc_platform *platform, unsigned int reg, + unsigned int val), + + TP_ARGS(platform, reg, val), + + TP_STRUCT__entry( + __string( name, platform->name ) + __field( int, id ) + __field( unsigned int, reg ) + __field( unsigned int, val ) + ), + + TP_fast_assign( + __assign_str(name, platform->name); + __entry->id = platform->id; + __entry->reg = reg; + __entry->val = val; + ), + + TP_printk("platform=%s.%d reg=%x val=%x", __get_str(name), + (int)__entry->id, (unsigned int)__entry->reg, + (unsigned int)__entry->val) +); + +DEFINE_EVENT(snd_soc_preg, snd_soc_preg_write, + + TP_PROTO(struct snd_soc_platform *platform, unsigned int reg, + unsigned int val), + + TP_ARGS(platform, reg, val) + +); + +DEFINE_EVENT(snd_soc_preg, snd_soc_preg_read, + + TP_PROTO(struct snd_soc_platform *platform, unsigned int reg, + unsigned int val), + + TP_ARGS(platform, reg, val) + +); + DECLARE_EVENT_CLASS(snd_soc_card,
TP_PROTO(struct snd_soc_card *card, int val), diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d08abf4..06c9b14 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1652,6 +1652,7 @@ int snd_soc_platform_read(struct snd_soc_platform *platform,
ret = platform->driver->read(platform, reg); dev_dbg(platform->dev, "read %x => %x\n", reg, ret); + trace_snd_soc_preg_read(platform, reg, ret);
return ret; } @@ -1666,6 +1667,7 @@ int snd_soc_platform_write(struct snd_soc_platform *platform, }
dev_dbg(platform->dev, "write %x = %x\n", reg, val); + trace_snd_soc_preg_write(platform, reg, val); return platform->driver->write(platform, reg, val); } EXPORT_SYMBOL_GPL(snd_soc_platform_write);
In preparation for Dynamic PCM (AKA DSP) support.
Allow platform drivers to register kcontrols.
Signed-off-by: Liam Girdwood lrg@ti.com --- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index f30f3fe..c421501 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -368,6 +368,8 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, const char *prefix); int snd_soc_add_controls(struct snd_soc_codec *codec, const struct snd_kcontrol_new *controls, int num_controls); +int snd_soc_add_platform_controls(struct snd_soc_platform *platform, + const struct snd_kcontrol_new *controls, int num_controls); int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 06c9b14..a69b87a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1951,6 +1951,36 @@ int snd_soc_add_controls(struct snd_soc_codec *codec, EXPORT_SYMBOL_GPL(snd_soc_add_controls);
/** + * snd_soc_add_platform_controls - add an array of controls to a platform. + * Convienience function to add a list of controls. + * + * @platform: platform to add controls to + * @controls: array of controls to add + * @num_controls: number of elements in the array + * + * Return 0 for success, else error. + */ +int snd_soc_add_platform_controls(struct snd_soc_platform *platform, + const struct snd_kcontrol_new *controls, int num_controls) +{ + struct snd_card *card = platform->card->snd_card; + int err, i; + + for (i = 0; i < num_controls; i++) { + const struct snd_kcontrol_new *control = &controls[i]; + err = snd_ctl_add(card, snd_soc_cnew(control, platform, + control->name, NULL)); + if (err < 0) { + dev_err(platform->dev, "Failed to add %s %d\n",control->name, err); + return err; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); + +/** * snd_soc_info_enum_double - enumerated double mixer info callback * @kcontrol: mixer control * @uinfo: control element information
Allow platform driver widgets to perform any IO required for DAPM.
Signed-off-by: Liam Girdwood lrg@ti.com --- include/sound/soc-dapm.h | 2 ++ include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 4 ++++ sound/soc/soc-dapm.c | 13 +++++++++++-- 4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 602024d..e09505c 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -447,6 +447,7 @@ struct snd_soc_dapm_widget { char *name; /* widget name */ char *sname; /* stream name */ struct snd_soc_codec *codec; + struct snd_soc_platform *platform; struct list_head list; struct snd_soc_dapm_context *dapm;
@@ -510,6 +511,7 @@ struct snd_soc_dapm_context {
struct device *dev; /* from parent - for debug */ struct snd_soc_codec *codec; /* parent codec */ + struct snd_soc_platform *platform; /* parent platform */ struct snd_soc_card *card; /* parent card */
/* used during DAPM updates */ diff --git a/include/sound/soc.h b/include/sound/soc.h index c421501..6ce8dc3 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -682,6 +682,8 @@ struct snd_soc_platform { struct snd_soc_card *card; struct list_head list; struct list_head card_list; + + struct snd_soc_dapm_context dapm; };
struct snd_soc_dai_link { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a69b87a..36e71e9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -993,6 +993,7 @@ static int soc_probe_platform(struct snd_soc_card *card, const struct snd_soc_platform_driver *driver = platform->driver;
platform->card = card; + platform->dapm.card = card;
if (!try_module_get(platform->dev->driver->owner)) return -ENODEV; @@ -1010,6 +1011,7 @@ static int soc_probe_platform(struct snd_soc_card *card, /* mark platform as probed and add to card platform list */ platform->probed = 1; list_add(&platform->card_list, &card->platform_dev_list); + list_add(&platform->dapm.list, &card->dapm_list);
return 0;
@@ -3124,6 +3126,8 @@ int snd_soc_register_platform(struct device *dev,
platform->dev = dev; platform->driver = platform_drv; + platform->dapm.dev = dev; + platform->dapm.platform = platform;
mutex_lock(&client_mutex); list_add(&platform->list, &platform_list); diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 605c225..0a78482 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -128,14 +128,22 @@ static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg) { if (w->codec) return snd_soc_read(w->codec, reg); - return 0; + else if (w->platform) + return snd_soc_platform_read(w->platform, reg); + + dev_err(w->dapm->dev, "no valid widget read method\n"); + return -1; }
static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg, int val) { if (w->codec) return snd_soc_write(w->codec, reg, val); - return 0; + else if (w->platform) + return snd_soc_platform_write(w->platform, reg, val); + + dev_err(w->dapm->dev, "no valid widget write method\n"); + return -1; }
static int soc_widget_update_bits(struct snd_soc_dapm_widget *w, @@ -2489,6 +2497,7 @@ int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, dapm->n_widgets++; w->dapm = dapm; w->codec = dapm->codec; + w->platform = dapm->platform; INIT_LIST_HEAD(&w->sources); INIT_LIST_HEAD(&w->sinks); INIT_LIST_HEAD(&w->list);
Allow platform probe to register platform kcontrols and DAPM just like the CODEC probe().
Signed-off-by: Liam Girdwood lrg@ti.com --- include/sound/soc.h | 8 ++++++++ sound/soc/soc-core.c | 11 +++++++++++ 2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 6ce8dc3..aa19f5a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -651,6 +651,14 @@ struct snd_soc_platform_driver { int (*pcm_new)(struct snd_soc_pcm_runtime *); void (*pcm_free)(struct snd_pcm *);
+ /* Default control and setup, added after probe() is run */ + const struct snd_kcontrol_new *controls; + int num_controls; + const struct snd_soc_dapm_widget *dapm_widgets; + int num_dapm_widgets; + const struct snd_soc_dapm_route *dapm_routes; + int num_dapm_routes; + /* * For platform caused delay reporting. * Optional. diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 36e71e9..70f4779 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -998,6 +998,10 @@ static int soc_probe_platform(struct snd_soc_card *card, if (!try_module_get(platform->dev->driver->owner)) return -ENODEV;
+ if (driver->dapm_widgets) + snd_soc_dapm_new_controls(&platform->dapm, + driver->dapm_widgets, driver->num_dapm_widgets); + if (driver->probe) { ret = driver->probe(platform); if (ret < 0) { @@ -1008,6 +1012,13 @@ static int soc_probe_platform(struct snd_soc_card *card, } }
+ if (driver->controls) + snd_soc_add_platform_controls(platform, driver->controls, + driver->num_controls); + if (driver->dapm_routes) + snd_soc_dapm_add_routes(&platform->dapm, driver->dapm_routes, + driver->num_dapm_routes); + /* mark platform as probed and add to card platform list */ platform->probed = 1; list_add(&platform->card_list, &card->platform_dev_list);
On Mon, Jul 04, 2011 at 10:10:50PM +0100, Liam Girdwood wrote:
Trace platform IO just like CODEC IO.
Signed-off-by: Liam Girdwood lrg@ti.com
Applied all, thanks.
participants (2)
-
Liam Girdwood
-
Mark Brown