Commit 1482304d authored by Mark Brown's avatar Mark Brown

Merge series "ASoC: soc-component: add snd_soc_component_xxx()" from Kuninori...

Merge series "ASoC: soc-component: add snd_soc_component_xxx()" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Hi Mark

These are v2 of snd_soc_component_compr_xxx() function patches.
I think component related function should be implemented at
soc-component.c, otherwise it is confusable to read.
These are for it.

v1 -> v2
	- fixup function return timing on
		snd_soc_component_compr_get_params()
		snd_soc_component_compr_get_metadata()

	- use mutex at compr side on
		snd_soc_component_compr_get_caps()
		snd_soc_component_compr_get_codec_caps()
		snd_soc_component_compr_copy()

Link: https://lore.kernel.org/r/878sb78ac4.wl-kuninori.morimoto.gx@renesas.com

Kuninori Morimoto (12):
  ASoC: soc-component: add snd_soc_component_compr_open()
  ASoC: soc-component: add snd_soc_component_compr_free()
  ASoC: soc-component: add snd_soc_component_compr_trigger()
  ASoC: soc-component: add snd_soc_component_compr_set_params()
  ASoC: soc-component: add snd_soc_component_compr_get_params()
  ASoC: soc-component: add snd_soc_component_compr_get_caps()
  ASoC: soc-component: add snd_soc_component_compr_get_codec_caps()
  ASoC: soc-component: add snd_soc_component_compr_ack()
  ASoC: soc-component: add snd_soc_component_compr_pointer()
  ASoC: soc-component: add snd_soc_component_compr_copy()
  ASoC: soc-component: add snd_soc_component_compr_set_metadata()
  ASoC: soc-component: add snd_soc_component_compr_get_metadata()

 include/sound/soc-component.h |  22 +++
 sound/soc/soc-component.c     | 255 ++++++++++++++++++++++++++++++++
 sound/soc/soc-compress.c      | 263 ++++------------------------------
 3 files changed, 303 insertions(+), 237 deletions(-)

--
2.25.1
parents de3de881 bab78c23
...@@ -444,6 +444,28 @@ int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component, ...@@ -444,6 +444,28 @@ int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component, int snd_soc_component_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);
int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
struct snd_soc_component **last);
void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
struct snd_soc_component *last);
int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd);
int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
struct snd_compr_params *params);
int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
struct snd_codec *params);
int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
struct snd_compr_caps *caps);
int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
struct snd_compr_codec_caps *codec);
int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes);
int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
struct snd_compr_tstamp *tstamp);
int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
char __user *buf, size_t count);
int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata);
int snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata);
int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream); int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream, int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
......
...@@ -421,6 +421,261 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap); ...@@ -421,6 +421,261 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
#endif #endif
int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
struct snd_soc_component **last)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->open) {
ret = component->driver->compress_ops->open(component, cstream);
if (ret < 0) {
*last = component;
return soc_component_ret(component, ret);
}
}
}
*last = NULL;
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_open);
void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
struct snd_soc_component *last)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i;
for_each_rtd_components(rtd, i, component) {
if (component == last)
break;
if (component->driver->compress_ops &&
component->driver->compress_ops->free)
component->driver->compress_ops->free(component, cstream);
}
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_free);
int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->trigger) {
ret = component->driver->compress_ops->trigger(
component, cstream, cmd);
if (ret < 0)
return soc_component_ret(component, ret);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_trigger);
int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
struct snd_compr_params *params)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->set_params) {
ret = component->driver->compress_ops->set_params(
component, cstream, params);
if (ret < 0)
return soc_component_ret(component, ret);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_params);
int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
struct snd_codec *params)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->get_params) {
ret = component->driver->compress_ops->get_params(
component, cstream, params);
return soc_component_ret(component, ret);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_params);
int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
struct snd_compr_caps *caps)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->get_caps) {
ret = component->driver->compress_ops->get_caps(
component, cstream, caps);
break;
}
}
mutex_unlock(&rtd->card->pcm_mutex);
return soc_component_ret(component, ret);
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_caps);
int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
struct snd_compr_codec_caps *codec)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->get_codec_caps) {
ret = component->driver->compress_ops->get_codec_caps(
component, cstream, codec);
break;
}
}
mutex_unlock(&rtd->card->pcm_mutex);
return soc_component_ret(component, ret);
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_codec_caps);
int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->ack) {
ret = component->driver->compress_ops->ack(
component, cstream, bytes);
if (ret < 0)
return soc_component_ret(component, ret);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_ack);
int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
struct snd_compr_tstamp *tstamp)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->pointer) {
ret = component->driver->compress_ops->pointer(
component, cstream, tstamp);
return soc_component_ret(component, ret);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_pointer);
int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
char __user *buf, size_t count)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->copy) {
ret = component->driver->compress_ops->copy(
component, cstream, buf, count);
break;
}
}
mutex_unlock(&rtd->card->pcm_mutex);
return soc_component_ret(component, ret);
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_copy);
int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->set_metadata) {
ret = component->driver->compress_ops->set_metadata(
component, cstream, metadata);
if (ret < 0)
return soc_component_ret(component, ret);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_metadata);
int snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops &&
component->driver->compress_ops->get_metadata) {
ret = component->driver->compress_ops->get_metadata(
component, cstream, metadata);
return soc_component_ret(component, ret);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_metadata);
static unsigned int soc_component_read_no_lock( static unsigned int soc_component_read_no_lock(
struct snd_soc_component *component, struct snd_soc_component *component,
unsigned int reg) unsigned int reg)
......
...@@ -22,54 +22,6 @@ ...@@ -22,54 +22,6 @@
#include <sound/soc-link.h> #include <sound/soc-link.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
static int soc_compr_components_open(struct snd_compr_stream *cstream,
struct snd_soc_component **last)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (!component->driver->compress_ops ||
!component->driver->compress_ops->open)
continue;
ret = component->driver->compress_ops->open(component, cstream);
if (ret < 0) {
dev_err(component->dev,
"Compress ASoC: can't open platform %s: %d\n",
component->name, ret);
*last = component;
return ret;
}
}
*last = NULL;
return 0;
}
static int soc_compr_components_free(struct snd_compr_stream *cstream,
struct snd_soc_component *last)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i;
for_each_rtd_components(rtd, i, component) {
if (component == last)
break;
if (!component->driver->compress_ops ||
!component->driver->compress_ops->free)
continue;
component->driver->compress_ops->free(component, cstream);
}
return 0;
}
static int soc_compr_open(struct snd_compr_stream *cstream) static int soc_compr_open(struct snd_compr_stream *cstream)
{ {
struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_pcm_runtime *rtd = cstream->private_data;
...@@ -88,7 +40,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) ...@@ -88,7 +40,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = soc_compr_components_open(cstream, &component); ret = snd_soc_component_compr_open(cstream, &component);
if (ret < 0) if (ret < 0)
goto machine_err; goto machine_err;
...@@ -103,7 +55,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) ...@@ -103,7 +55,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
return 0; return 0;
machine_err: machine_err:
soc_compr_components_free(cstream, component); snd_soc_component_compr_free(cstream, component);
snd_soc_dai_compr_shutdown(cpu_dai, cstream); snd_soc_dai_compr_shutdown(cpu_dai, cstream);
out: out:
...@@ -156,7 +108,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) ...@@ -156,7 +108,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = soc_compr_components_open(cstream, &component); ret = snd_soc_component_compr_open(cstream, &component);
if (ret < 0) if (ret < 0)
goto open_err; goto open_err;
...@@ -177,7 +129,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) ...@@ -177,7 +129,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
return 0; return 0;
machine_err: machine_err:
soc_compr_components_free(cstream, component); snd_soc_component_compr_free(cstream, component);
open_err: open_err:
snd_soc_dai_compr_shutdown(cpu_dai, cstream); snd_soc_dai_compr_shutdown(cpu_dai, cstream);
out: out:
...@@ -209,7 +161,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream) ...@@ -209,7 +161,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
snd_soc_link_compr_shutdown(cstream); snd_soc_link_compr_shutdown(cstream);
soc_compr_components_free(cstream, NULL); snd_soc_component_compr_free(cstream, NULL);
snd_soc_dai_compr_shutdown(cpu_dai, cstream); snd_soc_dai_compr_shutdown(cpu_dai, cstream);
...@@ -257,7 +209,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) ...@@ -257,7 +209,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
snd_soc_link_compr_shutdown(cstream); snd_soc_link_compr_shutdown(cstream);
soc_compr_components_free(cstream, NULL); snd_soc_component_compr_free(cstream, NULL);
snd_soc_dai_compr_shutdown(cpu_dai, cstream); snd_soc_dai_compr_shutdown(cpu_dai, cstream);
...@@ -265,27 +217,6 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) ...@@ -265,27 +217,6 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
return 0; return 0;
} }
static int soc_compr_components_trigger(struct snd_compr_stream *cstream,
int cmd)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (!component->driver->compress_ops ||
!component->driver->compress_ops->trigger)
continue;
ret = component->driver->compress_ops->trigger(
component, cstream, cmd);
if (ret < 0)
return ret;
}
return 0;
}
static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
{ {
struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_pcm_runtime *rtd = cstream->private_data;
...@@ -296,7 +227,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) ...@@ -296,7 +227,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
ret = soc_compr_components_trigger(cstream, cmd); ret = snd_soc_component_compr_trigger(cstream, cmd);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -327,7 +258,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) ...@@ -327,7 +258,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN || if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
cmd == SND_COMPR_TRIGGER_DRAIN) cmd == SND_COMPR_TRIGGER_DRAIN)
return soc_compr_components_trigger(cstream, cmd); return snd_soc_component_compr_trigger(cstream, cmd);
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
...@@ -335,7 +266,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) ...@@ -335,7 +266,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = soc_compr_components_trigger(cstream, cmd); ret = snd_soc_component_compr_trigger(cstream, cmd);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -364,27 +295,6 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) ...@@ -364,27 +295,6 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
return ret; return ret;
} }
static int soc_compr_components_set_params(struct snd_compr_stream *cstream,
struct snd_compr_params *params)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret;
for_each_rtd_components(rtd, i, component) {
if (!component->driver->compress_ops ||
!component->driver->compress_ops->set_params)
continue;
ret = component->driver->compress_ops->set_params(
component, cstream, params);
if (ret < 0)
return ret;
}
return 0;
}
static int soc_compr_set_params(struct snd_compr_stream *cstream, static int soc_compr_set_params(struct snd_compr_stream *cstream,
struct snd_compr_params *params) struct snd_compr_params *params)
{ {
...@@ -406,7 +316,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, ...@@ -406,7 +316,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
if (ret < 0) if (ret < 0)
goto err; goto err;
ret = soc_compr_components_set_params(cstream, params); ret = snd_soc_component_compr_set_params(cstream, params);
if (ret < 0) if (ret < 0)
goto err; goto err;
...@@ -463,7 +373,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, ...@@ -463,7 +373,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = soc_compr_components_set_params(cstream, params); ret = snd_soc_component_compr_set_params(cstream, params);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -484,9 +394,8 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, ...@@ -484,9 +394,8 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
struct snd_codec *params) struct snd_codec *params)
{ {
struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int i, ret = 0; int ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
...@@ -494,73 +403,17 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, ...@@ -494,73 +403,17 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
if (ret < 0) if (ret < 0)
goto err; goto err;
for_each_rtd_components(rtd, i, component) { ret = snd_soc_component_compr_get_params(cstream, params);
if (!component->driver->compress_ops ||
!component->driver->compress_ops->get_params)
continue;
ret = component->driver->compress_ops->get_params(
component, cstream, params);
break;
}
err: err:
mutex_unlock(&rtd->card->pcm_mutex); mutex_unlock(&rtd->card->pcm_mutex);
return ret; return ret;
} }
static int soc_compr_get_caps(struct snd_compr_stream *cstream,
struct snd_compr_caps *caps)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
for_each_rtd_components(rtd, i, component) {
if (!component->driver->compress_ops ||
!component->driver->compress_ops->get_caps)
continue;
ret = component->driver->compress_ops->get_caps(
component, cstream, caps);
break;
}
mutex_unlock(&rtd->card->pcm_mutex);
return ret;
}
static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
struct snd_compr_codec_caps *codec)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
for_each_rtd_components(rtd, i, component) {
if (!component->driver->compress_ops ||
!component->driver->compress_ops->get_codec_caps)
continue;
ret = component->driver->compress_ops->get_codec_caps(
component, cstream, codec);
break;
}
mutex_unlock(&rtd->card->pcm_mutex);
return ret;
}
static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
{ {
struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int i, ret = 0; int ret;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
...@@ -568,17 +421,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) ...@@ -568,17 +421,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
if (ret < 0) if (ret < 0)
goto err; goto err;
for_each_rtd_components(rtd, i, component) { ret = snd_soc_component_compr_ack(cstream, bytes);
if (!component->driver->compress_ops ||
!component->driver->compress_ops->ack)
continue;
ret = component->driver->compress_ops->ack(
component, cstream, bytes);
if (ret < 0)
goto err;
}
err: err:
mutex_unlock(&rtd->card->pcm_mutex); mutex_unlock(&rtd->card->pcm_mutex);
return ret; return ret;
...@@ -588,8 +431,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, ...@@ -588,8 +431,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
struct snd_compr_tstamp *tstamp) struct snd_compr_tstamp *tstamp)
{ {
struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component; int ret;
int i, ret = 0;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
...@@ -598,91 +440,38 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, ...@@ -598,91 +440,38 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
if (ret < 0) if (ret < 0)
goto out; goto out;
for_each_rtd_components(rtd, i, component) { ret = snd_soc_component_compr_pointer(cstream, tstamp);
if (!component->driver->compress_ops ||
!component->driver->compress_ops->pointer)
continue;
ret = component->driver->compress_ops->pointer(
component, cstream, tstamp);
break;
}
out: out:
mutex_unlock(&rtd->card->pcm_mutex); mutex_unlock(&rtd->card->pcm_mutex);
return ret; return ret;
} }
static int soc_compr_copy(struct snd_compr_stream *cstream,
char __user *buf, size_t count)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
for_each_rtd_components(rtd, i, component) {
if (!component->driver->compress_ops ||
!component->driver->compress_ops->copy)
continue;
ret = component->driver->compress_ops->copy(
component, cstream, buf, count);
break;
}
mutex_unlock(&rtd->card->pcm_mutex);
return ret;
}
static int soc_compr_set_metadata(struct snd_compr_stream *cstream, static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata) struct snd_compr_metadata *metadata)
{ {
struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int i, ret; int ret;
ret = snd_soc_dai_compr_set_metadata(cpu_dai, cstream, metadata); ret = snd_soc_dai_compr_set_metadata(cpu_dai, cstream, metadata);
if (ret < 0) if (ret < 0)
return ret; return ret;
for_each_rtd_components(rtd, i, component) { return snd_soc_component_compr_set_metadata(cstream, metadata);
if (!component->driver->compress_ops ||
!component->driver->compress_ops->set_metadata)
continue;
ret = component->driver->compress_ops->set_metadata(
component, cstream, metadata);
if (ret < 0)
return ret;
}
return 0;
} }
static int soc_compr_get_metadata(struct snd_compr_stream *cstream, static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata) struct snd_compr_metadata *metadata)
{ {
struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int i, ret; int ret;
ret = snd_soc_dai_compr_get_metadata(cpu_dai, cstream, metadata); ret = snd_soc_dai_compr_get_metadata(cpu_dai, cstream, metadata);
if (ret < 0) if (ret < 0)
return ret; return ret;
for_each_rtd_components(rtd, i, component) { return snd_soc_component_compr_get_metadata(cstream, metadata);
if (!component->driver->compress_ops ||
!component->driver->compress_ops->get_metadata)
continue;
return component->driver->compress_ops->get_metadata(
component, cstream, metadata);
}
return 0;
} }
/* ASoC Compress operations */ /* ASoC Compress operations */
...@@ -696,8 +485,8 @@ static struct snd_compr_ops soc_compr_ops = { ...@@ -696,8 +485,8 @@ static struct snd_compr_ops soc_compr_ops = {
.trigger = soc_compr_trigger, .trigger = soc_compr_trigger,
.pointer = soc_compr_pointer, .pointer = soc_compr_pointer,
.ack = soc_compr_ack, .ack = soc_compr_ack,
.get_caps = soc_compr_get_caps, .get_caps = snd_soc_component_compr_get_caps,
.get_codec_caps = soc_compr_get_codec_caps .get_codec_caps = snd_soc_component_compr_get_codec_caps,
}; };
/* ASoC Dynamic Compress operations */ /* ASoC Dynamic Compress operations */
...@@ -711,8 +500,8 @@ static struct snd_compr_ops soc_compr_dyn_ops = { ...@@ -711,8 +500,8 @@ static struct snd_compr_ops soc_compr_dyn_ops = {
.trigger = soc_compr_trigger_fe, .trigger = soc_compr_trigger_fe,
.pointer = soc_compr_pointer, .pointer = soc_compr_pointer,
.ack = soc_compr_ack, .ack = soc_compr_ack,
.get_caps = soc_compr_get_caps, .get_caps = snd_soc_component_compr_get_caps,
.get_codec_caps = soc_compr_get_codec_caps .get_codec_caps = snd_soc_component_compr_get_codec_caps,
}; };
/** /**
...@@ -815,7 +604,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -815,7 +604,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
!component->driver->compress_ops->copy) !component->driver->compress_ops->copy)
continue; continue;
compr->ops->copy = soc_compr_copy; compr->ops->copy = snd_soc_component_compr_copy;
break; break;
} }
......
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