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,
int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
struct of_phandle_args *args,
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_ioctl(struct snd_pcm_substream *substream,
......
......@@ -421,6 +421,261 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
#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(
struct snd_soc_component *component,
unsigned int reg)
......
This diff is collapsed.
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