提交 f7acb369 编写于 作者: M Mark Brown

Merge remote-tracking branch 'asoc/topic/component' into asoc-multi

...@@ -257,7 +257,6 @@ struct snd_soc_dai { ...@@ -257,7 +257,6 @@ struct snd_soc_dai {
struct snd_soc_dapm_widget *playback_widget; struct snd_soc_dapm_widget *playback_widget;
struct snd_soc_dapm_widget *capture_widget; struct snd_soc_dapm_widget *capture_widget;
struct snd_soc_dapm_context dapm;
/* DAI DMA data */ /* DAI DMA data */
void *playback_dma_data; void *playback_dma_data;
......
...@@ -431,7 +431,7 @@ int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, ...@@ -431,7 +431,7 @@ int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
const char *pin); const char *pin);
int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
const char *pin); const char *pin);
void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec); void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card);
/* Mostly internal - should not normally be used */ /* Mostly internal - should not normally be used */
void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm); void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm);
...@@ -441,6 +441,8 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, ...@@ -441,6 +441,8 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,
struct snd_soc_dapm_widget_list **list); struct snd_soc_dapm_widget_list **list);
struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol); struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol);
struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm(
struct snd_kcontrol *kcontrol);
/* dapm widget types */ /* dapm widget types */
enum snd_soc_dapm_type { enum snd_soc_dapm_type {
...@@ -524,7 +526,6 @@ struct snd_soc_dapm_widget { ...@@ -524,7 +526,6 @@ struct snd_soc_dapm_widget {
const char *name; /* widget name */ const char *name; /* widget name */
const char *sname; /* stream name */ const char *sname; /* stream name */
struct snd_soc_codec *codec; struct snd_soc_codec *codec;
struct snd_soc_platform *platform;
struct list_head list; struct list_head list;
struct snd_soc_dapm_context *dapm; struct snd_soc_dapm_context *dapm;
...@@ -593,7 +594,6 @@ struct snd_soc_dapm_context { ...@@ -593,7 +594,6 @@ struct snd_soc_dapm_context {
struct device *dev; /* from parent - for debug */ struct device *dev; /* from parent - for debug */
struct snd_soc_component *component; /* parent component */ struct snd_soc_component *component; /* parent component */
struct snd_soc_codec *codec; /* parent codec */ struct snd_soc_codec *codec; /* parent codec */
struct snd_soc_platform *platform; /* parent platform */
struct snd_soc_card *card; /* parent card */ struct snd_soc_card *card; /* parent card */
/* used during DAPM updates */ /* used during DAPM updates */
...@@ -601,6 +601,8 @@ struct snd_soc_dapm_context { ...@@ -601,6 +601,8 @@ struct snd_soc_dapm_context {
struct list_head list; struct list_head list;
int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
int (*set_bias_level)(struct snd_soc_dapm_context *dapm,
enum snd_soc_bias_level level);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_dapm; struct dentry *debugfs_dapm;
......
...@@ -677,11 +677,15 @@ struct snd_soc_component_driver { ...@@ -677,11 +677,15 @@ struct snd_soc_component_driver {
int (*of_xlate_dai_name)(struct snd_soc_component *component, int (*of_xlate_dai_name)(struct snd_soc_component *component,
struct of_phandle_args *args, struct of_phandle_args *args,
const char **dai_name); const char **dai_name);
void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
int subseq);
int (*stream_event)(struct snd_soc_component *, int event);
}; };
struct snd_soc_component { struct snd_soc_component {
const char *name; const char *name;
int id; int id;
const char *name_prefix;
struct device *dev; struct device *dev;
unsigned int active; unsigned int active;
...@@ -705,13 +709,14 @@ struct snd_soc_component { ...@@ -705,13 +709,14 @@ struct snd_soc_component {
int val_bytes; int val_bytes;
struct mutex io_mutex; struct mutex io_mutex;
/* Don't use these, use snd_soc_component_get_dapm() */
struct snd_soc_dapm_context dapm;
struct snd_soc_dapm_context *dapm_ptr;
}; };
/* SoC Audio Codec device */ /* SoC Audio Codec device */
struct snd_soc_codec { struct snd_soc_codec {
const char *name;
const char *name_prefix;
int id;
struct device *dev; struct device *dev;
const struct snd_soc_codec_driver *driver; const struct snd_soc_codec_driver *driver;
...@@ -790,9 +795,6 @@ struct snd_soc_codec_driver { ...@@ -790,9 +795,6 @@ struct snd_soc_codec_driver {
void (*seq_notifier)(struct snd_soc_dapm_context *, void (*seq_notifier)(struct snd_soc_dapm_context *,
enum snd_soc_dapm_type, int); enum snd_soc_dapm_type, int);
/* codec stream completion event */
int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */
/* probe ordering - for components with runtime dependencies */ /* probe ordering - for components with runtime dependencies */
...@@ -834,9 +836,6 @@ struct snd_soc_platform_driver { ...@@ -834,9 +836,6 @@ struct snd_soc_platform_driver {
/* platform stream compress ops */ /* platform stream compress ops */
const struct snd_compr_ops *compr_ops; const struct snd_compr_ops *compr_ops;
/* platform stream completion event */
int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
/* probe ordering - for components with runtime dependencies */ /* probe ordering - for components with runtime dependencies */
int probe_order; int probe_order;
int remove_order; int remove_order;
...@@ -848,8 +847,6 @@ struct snd_soc_platform_driver { ...@@ -848,8 +847,6 @@ struct snd_soc_platform_driver {
}; };
struct snd_soc_platform { struct snd_soc_platform {
const char *name;
int id;
struct device *dev; struct device *dev;
const struct snd_soc_platform_driver *driver; const struct snd_soc_platform_driver *driver;
...@@ -862,8 +859,6 @@ struct snd_soc_platform { ...@@ -862,8 +859,6 @@ struct snd_soc_platform {
struct snd_soc_component component; struct snd_soc_component component;
struct snd_soc_dapm_context dapm;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_platform_root; struct dentry *debugfs_platform_root;
#endif #endif
...@@ -1164,6 +1159,21 @@ static inline struct snd_soc_platform *snd_soc_component_to_platform( ...@@ -1164,6 +1159,21 @@ static inline struct snd_soc_platform *snd_soc_component_to_platform(
return container_of(component, struct snd_soc_platform, component); return container_of(component, struct snd_soc_platform, component);
} }
/**
* snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
* embedded in
* @dapm: The DAPM context to cast to the component
*
* This function must only be used on DAPM contexts that are known to be part of
* a component (e.g. in a component driver). Otherwise the behavior is
* undefined.
*/
static inline struct snd_soc_component *snd_soc_dapm_to_component(
struct snd_soc_dapm_context *dapm)
{
return container_of(dapm, struct snd_soc_component, dapm);
}
/** /**
* snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in
* @dapm: The DAPM context to cast to the CODEC * @dapm: The DAPM context to cast to the CODEC
...@@ -1188,7 +1198,18 @@ static inline struct snd_soc_codec *snd_soc_dapm_to_codec( ...@@ -1188,7 +1198,18 @@ static inline struct snd_soc_codec *snd_soc_dapm_to_codec(
static inline struct snd_soc_platform *snd_soc_dapm_to_platform( static inline struct snd_soc_platform *snd_soc_dapm_to_platform(
struct snd_soc_dapm_context *dapm) struct snd_soc_dapm_context *dapm)
{ {
return container_of(dapm, struct snd_soc_platform, dapm); return snd_soc_component_to_platform(snd_soc_dapm_to_component(dapm));
}
/**
* snd_soc_component_get_dapm() - Returns the DAPM context associated with a
* component
* @component: The component for which to get the DAPM context
*/
static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
struct snd_soc_component *component)
{
return component->dapm_ptr;
} }
/* codec IO */ /* codec IO */
......
...@@ -296,17 +296,17 @@ TRACE_EVENT(snd_soc_cache_sync, ...@@ -296,17 +296,17 @@ TRACE_EVENT(snd_soc_cache_sync,
TP_ARGS(codec, type, status), TP_ARGS(codec, type, status),
TP_STRUCT__entry( TP_STRUCT__entry(
__string( name, codec->name ) __string( name, codec->component.name)
__string( status, status ) __string( status, status )
__string( type, type ) __string( type, type )
__field( int, id ) __field( int, id )
), ),
TP_fast_assign( TP_fast_assign(
__assign_str(name, codec->name); __assign_str(name, codec->component.name);
__assign_str(status, status); __assign_str(status, status);
__assign_str(type, type); __assign_str(type, type);
__entry->id = codec->id; __entry->id = codec->component.id;
), ),
TP_printk("codec=%s.%d type=%s status=%s", __get_str(name), TP_printk("codec=%s.%d type=%s status=%s", __get_str(name),
......
...@@ -1404,7 +1404,7 @@ static int dac33_soc_probe(struct snd_soc_codec *codec) ...@@ -1404,7 +1404,7 @@ static int dac33_soc_probe(struct snd_soc_codec *codec)
if (dac33->irq >= 0) { if (dac33->irq >= 0) {
ret = request_irq(dac33->irq, dac33_interrupt_handler, ret = request_irq(dac33->irq, dac33_interrupt_handler,
IRQF_TRIGGER_RISING, IRQF_TRIGGER_RISING,
codec->name, codec); codec->component.name, codec);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Could not request IRQ%d (%d)\n", dev_err(codec->dev, "Could not request IRQ%d (%d)\n",
dac33->irq, ret); dac33->irq, ret);
......
...@@ -78,7 +78,7 @@ int snd_soc_cache_init(struct snd_soc_codec *codec) ...@@ -78,7 +78,7 @@ int snd_soc_cache_init(struct snd_soc_codec *codec)
mutex_init(&codec->cache_rw_mutex); mutex_init(&codec->cache_rw_mutex);
dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n",
codec->name); codec->component.name);
if (codec_drv->reg_cache_default) if (codec_drv->reg_cache_default)
codec->reg_cache = kmemdup(codec_drv->reg_cache_default, codec->reg_cache = kmemdup(codec_drv->reg_cache_default,
...@@ -98,8 +98,7 @@ int snd_soc_cache_init(struct snd_soc_codec *codec) ...@@ -98,8 +98,7 @@ int snd_soc_cache_init(struct snd_soc_codec *codec)
int snd_soc_cache_exit(struct snd_soc_codec *codec) int snd_soc_cache_exit(struct snd_soc_codec *codec)
{ {
dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n", dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n",
codec->name); codec->component.name);
kfree(codec->reg_cache); kfree(codec->reg_cache);
codec->reg_cache = NULL; codec->reg_cache = NULL;
return 0; return 0;
...@@ -192,7 +191,7 @@ int snd_soc_cache_sync(struct snd_soc_codec *codec) ...@@ -192,7 +191,7 @@ int snd_soc_cache_sync(struct snd_soc_codec *codec)
return 0; return 0;
dev_dbg(codec->dev, "ASoC: Syncing cache for %s codec\n", dev_dbg(codec->dev, "ASoC: Syncing cache for %s codec\n",
codec->name); codec->component.name);
trace_snd_soc_cache_sync(codec, name, "start"); trace_snd_soc_cache_sync(codec, name, "start");
ret = snd_soc_flat_cache_sync(codec); ret = snd_soc_flat_cache_sync(codec);
if (!ret) if (!ret)
......
...@@ -37,7 +37,8 @@ static int soc_compr_open(struct snd_compr_stream *cstream) ...@@ -37,7 +37,8 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
if (platform->driver->compr_ops && platform->driver->compr_ops->open) { if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
ret = platform->driver->compr_ops->open(cstream); ret = platform->driver->compr_ops->open(cstream);
if (ret < 0) { if (ret < 0) {
pr_err("compress asoc: can't open platform %s\n", platform->name); pr_err("compress asoc: can't open platform %s\n",
platform->component.name);
goto out; goto out;
} }
} }
...@@ -84,7 +85,8 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) ...@@ -84,7 +85,8 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
if (platform->driver->compr_ops && platform->driver->compr_ops->open) { if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
ret = platform->driver->compr_ops->open(cstream); ret = platform->driver->compr_ops->open(cstream);
if (ret < 0) { if (ret < 0) {
pr_err("compress asoc: can't open platform %s\n", platform->name); pr_err("compress asoc: can't open platform %s\n",
platform->component.name);
goto out; goto out;
} }
} }
...@@ -680,7 +682,7 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -680,7 +682,7 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
ret = snd_compress_new(rtd->card->snd_card, num, direction, compr); ret = snd_compress_new(rtd->card->snd_card, num, direction, compr);
if (ret < 0) { if (ret < 0) {
pr_err("compress asoc: can't create compress for codec %s\n", pr_err("compress asoc: can't create compress for codec %s\n",
codec->name); codec->component.name);
goto compr_err; goto compr_err;
} }
......
此差异已折叠。
...@@ -349,13 +349,28 @@ static bool dapm_kcontrol_set_value(const struct snd_kcontrol *kcontrol, ...@@ -349,13 +349,28 @@ static bool dapm_kcontrol_set_value(const struct snd_kcontrol *kcontrol,
return true; return true;
} }
/**
* snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a
* kcontrol
* @kcontrol: The kcontrol
*
* Note: This function must only be used on kcontrols that are known to have
* been registered for a CODEC. Otherwise the behaviour is undefined.
*/
struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm(
struct snd_kcontrol *kcontrol)
{
return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->dapm;
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_kcontrol_dapm);
/** /**
* snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol
* @kcontrol: The kcontrol * @kcontrol: The kcontrol
*/ */
struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol) struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol)
{ {
return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->codec; return snd_soc_dapm_to_codec(snd_soc_dapm_kcontrol_dapm(kcontrol));
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_kcontrol_codec); EXPORT_SYMBOL_GPL(snd_soc_dapm_kcontrol_codec);
...@@ -375,23 +390,38 @@ static void dapm_reset(struct snd_soc_card *card) ...@@ -375,23 +390,38 @@ static void dapm_reset(struct snd_soc_card *card)
} }
} }
static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg, static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm)
{
if (!dapm->component)
return NULL;
return dapm->component->name_prefix;
}
static int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg,
unsigned int *value) unsigned int *value)
{ {
if (!w->dapm->component) if (!dapm->component)
return -EIO; return -EIO;
return snd_soc_component_read(w->dapm->component, reg, value); return snd_soc_component_read(dapm->component, reg, value);
} }
static int soc_widget_update_bits(struct snd_soc_dapm_widget *w, static int soc_dapm_update_bits(struct snd_soc_dapm_context *dapm,
int reg, unsigned int mask, unsigned int value) int reg, unsigned int mask, unsigned int value)
{ {
if (!w->dapm->component) if (!dapm->component)
return -EIO; return -EIO;
return snd_soc_component_update_bits_async(w->dapm->component, reg, return snd_soc_component_update_bits_async(dapm->component, reg,
mask, value); mask, value);
} }
static int soc_dapm_test_bits(struct snd_soc_dapm_context *dapm,
int reg, unsigned int mask, unsigned int value)
{
if (!dapm->component)
return -EIO;
return snd_soc_component_test_bits(dapm->component, reg, mask, value);
}
static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm)
{ {
if (dapm->component) if (dapm->component)
...@@ -420,15 +450,10 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm, ...@@ -420,15 +450,10 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
if (ret != 0) if (ret != 0)
goto out; goto out;
if (dapm->codec) { if (dapm->set_bias_level)
if (dapm->codec->driver->set_bias_level) ret = dapm->set_bias_level(dapm, level);
ret = dapm->codec->driver->set_bias_level(dapm->codec, else if (!card || dapm != &card->dapm)
level);
else
dapm->bias_level = level;
} else if (!card || dapm != &card->dapm) {
dapm->bias_level = level; dapm->bias_level = level;
}
if (ret != 0) if (ret != 0)
goto out; goto out;
...@@ -452,7 +477,7 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, ...@@ -452,7 +477,7 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
int i; int i;
if (e->reg != SND_SOC_NOPM) { if (e->reg != SND_SOC_NOPM) {
soc_widget_read(dest, e->reg, &val); soc_dapm_read(dapm, e->reg, &val);
val = (val >> e->shift_l) & e->mask; val = (val >> e->shift_l) & e->mask;
item = snd_soc_enum_val_to_item(e, val); item = snd_soc_enum_val_to_item(e, val);
} else { } else {
...@@ -496,7 +521,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_widget *w, ...@@ -496,7 +521,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_widget *w,
unsigned int val; unsigned int val;
if (reg != SND_SOC_NOPM) { if (reg != SND_SOC_NOPM) {
soc_widget_read(w, reg, &val); soc_dapm_read(w->dapm, reg, &val);
val = (val >> shift) & mask; val = (val >> shift) & mask;
if (invert) if (invert)
val = max - val; val = max - val;
...@@ -570,11 +595,7 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, ...@@ -570,11 +595,7 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w,
const char *name; const char *name;
int ret; int ret;
if (dapm->codec) prefix = soc_dapm_prefix(dapm);
prefix = dapm->codec->name_prefix;
else
prefix = NULL;
if (prefix) if (prefix)
prefix_len = strlen(prefix) + 1; prefix_len = strlen(prefix) + 1;
else else
...@@ -1308,16 +1329,18 @@ static void dapm_seq_check_event(struct snd_soc_card *card, ...@@ -1308,16 +1329,18 @@ static void dapm_seq_check_event(struct snd_soc_card *card,
static void dapm_seq_run_coalesced(struct snd_soc_card *card, static void dapm_seq_run_coalesced(struct snd_soc_card *card,
struct list_head *pending) struct list_head *pending)
{ {
struct snd_soc_dapm_context *dapm;
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
int reg; int reg;
unsigned int value = 0; unsigned int value = 0;
unsigned int mask = 0; unsigned int mask = 0;
reg = list_first_entry(pending, struct snd_soc_dapm_widget, w = list_first_entry(pending, struct snd_soc_dapm_widget, power_list);
power_list)->reg; reg = w->reg;
dapm = w->dapm;
list_for_each_entry(w, pending, power_list) { list_for_each_entry(w, pending, power_list) {
WARN_ON(reg != w->reg); WARN_ON(reg != w->reg || dapm != w->dapm);
w->power = w->new_power; w->power = w->new_power;
mask |= w->mask << w->shift; mask |= w->mask << w->shift;
...@@ -1326,7 +1349,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card, ...@@ -1326,7 +1349,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card,
else else
value |= w->off_val << w->shift; value |= w->off_val << w->shift;
pop_dbg(w->dapm->dev, card->pop_time, pop_dbg(dapm->dev, card->pop_time,
"pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n", "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n",
w->name, reg, value, mask); w->name, reg, value, mask);
...@@ -1339,14 +1362,12 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card, ...@@ -1339,14 +1362,12 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card,
/* Any widget will do, they should all be updating the /* Any widget will do, they should all be updating the
* same register. * same register.
*/ */
w = list_first_entry(pending, struct snd_soc_dapm_widget,
power_list);
pop_dbg(w->dapm->dev, card->pop_time, pop_dbg(dapm->dev, card->pop_time,
"pop test : Applying 0x%x/0x%x to %x in %dms\n", "pop test : Applying 0x%x/0x%x to %x in %dms\n",
value, mask, reg, card->pop_time); value, mask, reg, card->pop_time);
pop_wait(card->pop_time); pop_wait(card->pop_time);
soc_widget_update_bits(w, reg, mask, value); soc_dapm_update_bits(dapm, reg, mask, value);
} }
list_for_each_entry(w, pending, power_list) { list_for_each_entry(w, pending, power_list) {
...@@ -1492,7 +1513,8 @@ static void dapm_widget_update(struct snd_soc_card *card) ...@@ -1492,7 +1513,8 @@ static void dapm_widget_update(struct snd_soc_card *card)
if (!w) if (!w)
return; return;
ret = soc_widget_update_bits(w, update->reg, update->mask, update->val); ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask,
update->val);
if (ret < 0) if (ret < 0)
dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n",
w->name, ret); w->name, ret);
...@@ -2371,14 +2393,16 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, ...@@ -2371,14 +2393,16 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
const char *source; const char *source;
char prefixed_sink[80]; char prefixed_sink[80];
char prefixed_source[80]; char prefixed_source[80];
const char *prefix;
int ret; int ret;
if (dapm->codec && dapm->codec->name_prefix) { prefix = soc_dapm_prefix(dapm);
if (prefix) {
snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
dapm->codec->name_prefix, route->sink); prefix, route->sink);
sink = prefixed_sink; sink = prefixed_sink;
snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
dapm->codec->name_prefix, route->source); prefix, route->source);
source = prefixed_source; source = prefixed_source;
} else { } else {
sink = route->sink; sink = route->sink;
...@@ -2439,6 +2463,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, ...@@ -2439,6 +2463,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm,
const char *source; const char *source;
char prefixed_sink[80]; char prefixed_sink[80];
char prefixed_source[80]; char prefixed_source[80];
const char *prefix;
if (route->control) { if (route->control) {
dev_err(dapm->dev, dev_err(dapm->dev,
...@@ -2446,12 +2471,13 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, ...@@ -2446,12 +2471,13 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm,
return -EINVAL; return -EINVAL;
} }
if (dapm->codec && dapm->codec->name_prefix) { prefix = soc_dapm_prefix(dapm);
if (prefix) {
snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
dapm->codec->name_prefix, route->sink); prefix, route->sink);
sink = prefixed_sink; sink = prefixed_sink;
snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
dapm->codec->name_prefix, route->source); prefix, route->source);
source = prefixed_source; source = prefixed_source;
} else { } else {
sink = route->sink; sink = route->sink;
...@@ -2670,7 +2696,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) ...@@ -2670,7 +2696,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
/* Read the initial power state from the device */ /* Read the initial power state from the device */
if (w->reg >= 0) { if (w->reg >= 0) {
soc_widget_read(w, w->reg, &val); soc_dapm_read(w->dapm, w->reg, &val);
val = val >> w->shift; val = val >> w->shift;
val &= w->mask; val &= w->mask;
if (val == w->on_val) if (val == w->on_val)
...@@ -2701,8 +2727,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); ...@@ -2701,8 +2727,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_card *card = codec->card; struct snd_soc_card *card = dapm->card;
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
int reg = mc->reg; int reg = mc->reg;
...@@ -2711,17 +2737,20 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, ...@@ -2711,17 +2737,20 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
unsigned int mask = (1 << fls(max)) - 1; unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert; unsigned int invert = mc->invert;
unsigned int val; unsigned int val;
int ret = 0;
if (snd_soc_volsw_is_stereo(mc)) if (snd_soc_volsw_is_stereo(mc))
dev_warn(codec->dapm.dev, dev_warn(dapm->dev,
"ASoC: Control '%s' is stereo, which is not supported\n", "ASoC: Control '%s' is stereo, which is not supported\n",
kcontrol->id.name); kcontrol->id.name);
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) {
val = (snd_soc_read(codec, reg) >> shift) & mask; ret = soc_dapm_read(dapm, reg, &val);
else val = (val >> shift) & mask;
} else {
val = dapm_kcontrol_get_value(kcontrol); val = dapm_kcontrol_get_value(kcontrol);
}
mutex_unlock(&card->dapm_mutex); mutex_unlock(&card->dapm_mutex);
if (invert) if (invert)
...@@ -2729,7 +2758,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, ...@@ -2729,7 +2758,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
else else
ucontrol->value.integer.value[0] = val; ucontrol->value.integer.value[0] = val;
return 0; return ret;
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
...@@ -2745,8 +2774,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); ...@@ -2745,8 +2774,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_card *card = codec->card; struct snd_soc_card *card = dapm->card;
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
int reg = mc->reg; int reg = mc->reg;
...@@ -2755,12 +2784,12 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, ...@@ -2755,12 +2784,12 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
unsigned int mask = (1 << fls(max)) - 1; unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert; unsigned int invert = mc->invert;
unsigned int val; unsigned int val;
int connect, change; int connect, change, reg_change = 0;
struct snd_soc_dapm_update update; struct snd_soc_dapm_update update;
int ret = 0; int ret = 0;
if (snd_soc_volsw_is_stereo(mc)) if (snd_soc_volsw_is_stereo(mc))
dev_warn(codec->dapm.dev, dev_warn(dapm->dev,
"ASoC: Control '%s' is stereo, which is not supported\n", "ASoC: Control '%s' is stereo, which is not supported\n",
kcontrol->id.name); kcontrol->id.name);
...@@ -2773,20 +2802,23 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, ...@@ -2773,20 +2802,23 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
change = dapm_kcontrol_set_value(kcontrol, val); change = dapm_kcontrol_set_value(kcontrol, val);
if (change) {
if (reg != SND_SOC_NOPM) {
mask = mask << shift;
val = val << shift;
if (snd_soc_test_bits(codec, reg, mask, val)) {
update.kcontrol = kcontrol;
update.reg = reg;
update.mask = mask;
update.val = val;
card->update = &update;
}
if (reg != SND_SOC_NOPM) {
mask = mask << shift;
val = val << shift;
reg_change = soc_dapm_test_bits(dapm, reg, mask, val);
}
if (change || reg_change) {
if (reg_change) {
update.kcontrol = kcontrol;
update.reg = reg;
update.mask = mask;
update.val = val;
card->update = &update;
} }
change |= reg_change;
ret = soc_dapm_mixer_update_power(card, kcontrol, connect); ret = soc_dapm_mixer_update_power(card, kcontrol, connect);
...@@ -2814,12 +2846,13 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw); ...@@ -2814,12 +2846,13 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int reg_val, val; unsigned int reg_val, val;
int ret = 0;
if (e->reg != SND_SOC_NOPM) if (e->reg != SND_SOC_NOPM)
reg_val = snd_soc_read(codec, e->reg); ret = soc_dapm_read(dapm, e->reg, &reg_val);
else else
reg_val = dapm_kcontrol_get_value(kcontrol); reg_val = dapm_kcontrol_get_value(kcontrol);
...@@ -2831,7 +2864,7 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, ...@@ -2831,7 +2864,7 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
ucontrol->value.enumerated.item[1] = val; ucontrol->value.enumerated.item[1] = val;
} }
return 0; return ret;
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
...@@ -2847,8 +2880,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); ...@@ -2847,8 +2880,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_card *card = codec->card; struct snd_soc_card *card = dapm->card;
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int *item = ucontrol->value.enumerated.item; unsigned int *item = ucontrol->value.enumerated.item;
unsigned int val, change; unsigned int val, change;
...@@ -2871,7 +2904,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, ...@@ -2871,7 +2904,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
if (e->reg != SND_SOC_NOPM) if (e->reg != SND_SOC_NOPM)
change = snd_soc_test_bits(codec, e->reg, mask, val); change = soc_dapm_test_bits(dapm, e->reg, mask, val);
else else
change = dapm_kcontrol_set_value(kcontrol, val); change = dapm_kcontrol_set_value(kcontrol, val);
...@@ -2968,6 +3001,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, ...@@ -2968,6 +3001,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_widget *widget) const struct snd_soc_dapm_widget *widget)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
const char *prefix;
int ret; int ret;
if ((w = dapm_cnew_widget(widget)) == NULL) if ((w = dapm_cnew_widget(widget)) == NULL)
...@@ -3008,9 +3042,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, ...@@ -3008,9 +3042,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
break; break;
} }
if (dapm->codec && dapm->codec->name_prefix) prefix = soc_dapm_prefix(dapm);
w->name = kasprintf(GFP_KERNEL, "%s %s", if (prefix)
dapm->codec->name_prefix, widget->name); w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
else else
w->name = kasprintf(GFP_KERNEL, "%s", widget->name); w->name = kasprintf(GFP_KERNEL, "%s", widget->name);
...@@ -3063,7 +3097,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, ...@@ -3063,7 +3097,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
w->dapm = dapm; w->dapm = dapm;
w->codec = dapm->codec; w->codec = dapm->codec;
w->platform = dapm->platform;
INIT_LIST_HEAD(&w->sources); INIT_LIST_HEAD(&w->sources);
INIT_LIST_HEAD(&w->sinks); INIT_LIST_HEAD(&w->sinks);
INIT_LIST_HEAD(&w->list); INIT_LIST_HEAD(&w->list);
...@@ -3392,8 +3425,8 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) ...@@ -3392,8 +3425,8 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
source = cpu_dai->playback_widget; source = cpu_dai->playback_widget;
sink = codec_dai->playback_widget; sink = codec_dai->playback_widget;
dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n", dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
cpu_dai->codec->name, source->name, cpu_dai->component->name, source->name,
codec_dai->platform->name, sink->name); codec_dai->component->name, sink->name);
snd_soc_dapm_add_path(&card->dapm, source, sink, snd_soc_dapm_add_path(&card->dapm, source, sink,
NULL, NULL); NULL, NULL);
...@@ -3404,8 +3437,8 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) ...@@ -3404,8 +3437,8 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
source = codec_dai->capture_widget; source = codec_dai->capture_widget;
sink = cpu_dai->capture_widget; sink = cpu_dai->capture_widget;
dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n", dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
codec_dai->codec->name, source->name, codec_dai->component->name, source->name,
cpu_dai->platform->name, sink->name); cpu_dai->component->name, sink->name);
snd_soc_dapm_add_path(&card->dapm, source, sink, snd_soc_dapm_add_path(&card->dapm, source, sink,
NULL, NULL); NULL, NULL);
...@@ -3755,36 +3788,31 @@ static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card, ...@@ -3755,36 +3788,31 @@ static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card,
} }
/** /**
* snd_soc_dapm_auto_nc_codec_pins - call snd_soc_dapm_nc_pin for unused pins * snd_soc_dapm_auto_nc_pins - call snd_soc_dapm_nc_pin for unused pins
* @codec: The codec whose pins should be processed * @card: The card whose pins should be processed
* *
* Automatically call snd_soc_dapm_nc_pin() for any external pins in the codec * Automatically call snd_soc_dapm_nc_pin() for any external pins in the card
* which are unused. Pins are used if they are connected externally to the * which are unused. Pins are used if they are connected externally to a
* codec, whether that be to some other device, or a loop-back connection to * component, whether that be to some other device, or a loop-back connection to
* the codec itself. * the component itself.
*/ */
void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec) void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card)
{ {
struct snd_soc_card *card = codec->card;
struct snd_soc_dapm_context *dapm = &codec->dapm;
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
dev_dbg(codec->dev, "ASoC: Auto NC: DAPMs: card:%p codec:%p\n", dev_dbg(card->dev, "ASoC: Auto NC: DAPMs: card:%p\n", &card->dapm);
&card->dapm, &codec->dapm);
list_for_each_entry(w, &card->widgets, list) { list_for_each_entry(w, &card->widgets, list) {
if (w->dapm != dapm)
continue;
switch (w->id) { switch (w->id) {
case snd_soc_dapm_input: case snd_soc_dapm_input:
case snd_soc_dapm_output: case snd_soc_dapm_output:
case snd_soc_dapm_micbias: case snd_soc_dapm_micbias:
dev_dbg(codec->dev, "ASoC: Auto NC: Checking widget %s\n", dev_dbg(card->dev, "ASoC: Auto NC: Checking widget %s\n",
w->name); w->name);
if (!snd_soc_dapm_widget_in_card_paths(card, w)) { if (!snd_soc_dapm_widget_in_card_paths(card, w)) {
dev_dbg(codec->dev, dev_dbg(card->dev,
"... Not in map; disabling\n"); "... Not in map; disabling\n");
snd_soc_dapm_nc_pin(dapm, w->name); snd_soc_dapm_nc_pin(w->dapm, w->name);
} }
break; break;
default: default:
......
...@@ -390,7 +390,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) ...@@ -390,7 +390,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
ret = platform->driver->ops->open(substream); ret = platform->driver->ops->open(substream);
if (ret < 0) { if (ret < 0) {
dev_err(platform->dev, "ASoC: can't open platform" dev_err(platform->dev, "ASoC: can't open platform"
" %s: %d\n", platform->name, ret); " %s: %d\n", platform->component.name, ret);
goto platform_err; goto platform_err;
} }
} }
...@@ -720,7 +720,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -720,7 +720,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
ret = platform->driver->ops->hw_params(substream, params); ret = platform->driver->ops->hw_params(substream, params);
if (ret < 0) { if (ret < 0) {
dev_err(platform->dev, "ASoC: %s hw params failed: %d\n", dev_err(platform->dev, "ASoC: %s hw params failed: %d\n",
platform->name, ret); platform->component.name, ret);
goto platform_err; goto platform_err;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册