Skip to content

Commit

Permalink
Merge remote-tracking branch 'asoc/topic/dapm-pin' into asoc-next
Browse files Browse the repository at this point in the history
  • Loading branch information
broonie committed Dec 12, 2016
2 parents c0f2302 + 1b4d9c2 commit e6c6fd8
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1698,4 +1698,24 @@ static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
mutex_unlock(&dapm->card->dapm_mutex);
}

int snd_soc_component_enable_pin(struct snd_soc_component *component,
const char *pin);
int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
const char *pin);
int snd_soc_component_disable_pin(struct snd_soc_component *component,
const char *pin);
int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
const char *pin);
int snd_soc_component_nc_pin(struct snd_soc_component *component,
const char *pin);
int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
const char *pin);
int snd_soc_component_get_pin_status(struct snd_soc_component *component,
const char *pin);
int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
const char *pin);
int snd_soc_component_force_enable_pin_unlocked(
struct snd_soc_component *component,
const char *pin);

#endif
199 changes: 199 additions & 0 deletions sound/soc/soc-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,205 @@ int snd_soc_params_to_bclk(struct snd_pcm_hw_params *params)
}
EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk);

int snd_soc_component_enable_pin(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_enable_pin(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_enable_pin(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_enable_pin);

int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_enable_pin_unlocked(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_enable_pin_unlocked(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_enable_pin_unlocked);

int snd_soc_component_disable_pin(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_disable_pin(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_disable_pin(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_disable_pin);

int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_disable_pin_unlocked(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_disable_pin_unlocked(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_disable_pin_unlocked);

int snd_soc_component_nc_pin(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_nc_pin(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_nc_pin(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_nc_pin);

int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_nc_pin_unlocked(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_nc_pin_unlocked(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_nc_pin_unlocked);

int snd_soc_component_get_pin_status(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_get_pin_status(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_get_pin_status(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_get_pin_status);

int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_force_enable_pin(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_force_enable_pin(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin);

int snd_soc_component_force_enable_pin_unlocked(
struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;

if (!component->name_prefix)
return snd_soc_dapm_force_enable_pin_unlocked(dapm, pin);

full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;

ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, full_name);
kfree(full_name);

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);

static const struct snd_pcm_hardware dummy_dma_hardware = {
/* Random values to keep userspace happy when checking constraints */
.info = SNDRV_PCM_INFO_INTERLEAVED |
Expand Down

0 comments on commit e6c6fd8

Please sign in to comment.