* [PATCH 1/1] ASoC: soc-component: add snd_soc_component_ack()
[not found] <CGME20200403021943epcas2p36334748d486a0d4703fb12d88fbc9ee8@epcas2p3.samsung.com>
@ 2020-04-03 2:19 ` Gyeongtaek Lee
0 siblings, 0 replies; 2+ messages in thread
From: Gyeongtaek Lee @ 2020-04-03 2:19 UTC (permalink / raw)
To: 'Mark Brown', kuninori.morimoto.gx
Cc: alsa-devel, lgirdwood, tiwai, hmseo, cpgs, tkjung, pilsun.jang
Current ALSA SoC is directly using component->driver->ops->xxx,
thus, it is deep nested, and makes code difficult to read,
and is not good for encapsulation.
This patch adds new snd_soc_component_ack() and use it.
Ack callback is revived because some ASoC driver is using it.
Change-Id: I85573cb43f3ca050c47ca9e3af3cfa9ec1fae3d0
Signed-off-by: Gyeongtaek Lee <gt82.lee@samsung.com>
---
include/sound/soc-component.h | 1 +
sound/soc/soc-component.c | 18 ++++++++++++++++++
sound/soc/soc-pcm.c | 2 ++
3 files changed, 21 insertions(+)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 5d80b2eef525..50b079272b47 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -381,6 +381,7 @@ struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
unsigned long offset);
int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
struct vm_area_struct *vma);
+int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
int snd_soc_pcm_component_new(struct snd_pcm *pcm);
void snd_soc_pcm_component_free(struct snd_pcm *pcm);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 79ffc2820ba9..b4be91cb9fa0 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -526,6 +526,24 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
return -EINVAL;
}
+int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_rtdcom_list *rtdcom;
+ struct snd_soc_component *component;
+
+ for_each_rtdcom(rtd, rtdcom) {
+ component = rtdcom->component;
+
+ /* FIXME. it returns 1st ack now */
+ if (component->driver->ops &&
+ component->driver->ops->ack)
+ return component->driver->ops->ack(substream);
+ }
+
+ return -EINVAL;
+}
+
int snd_soc_pcm_component_new(struct snd_pcm *pcm)
{
struct snd_soc_pcm_runtime *rtd = pcm->private_data;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index b600d3eaaf5c..c8a5a9a9d35f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2941,6 +2941,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
if (!ops)
continue;
+ if (ops->ack)
+ rtd->ops.ack = snd_soc_pcm_component_ack;
if (ops->copy_user)
rtd->ops.copy_user = snd_soc_pcm_component_copy_user;
if (ops->page)
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 1/1] ASoC: soc-component: add snd_soc_component_ack()
[not found] <CGME20200403022314epcas2p2f0626aacff2ad57890bf46d354c3b1c6@epcas2p2.samsung.com>
@ 2020-04-03 2:23 ` Gyeongtaek Lee
0 siblings, 0 replies; 2+ messages in thread
From: Gyeongtaek Lee @ 2020-04-03 2:23 UTC (permalink / raw)
To: 'Mark Brown', kuninori.morimoto.gx
Cc: alsa-devel, lgirdwood, tiwai, hmseo, cpgs, tkjung, pilsun.jang
Current ALSA SoC is directly using component->driver->ops->xxx,
thus, it is deep nested, and makes code difficult to read,
and is not good for encapsulation.
This patch adds new snd_soc_component_ack() and use it.
Ack callback is revived because some ASoC driver is using it.
Signed-off-by: Gyeongtaek Lee <gt82.lee@samsung.com>
---
include/sound/soc-component.h | 3 +++
sound/soc/soc-component.c | 14 ++++++++++++++
sound/soc/soc-pcm.c | 2 ++
3 files changed, 19 insertions(+)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 154d02fbbfed..a8c60efac8f7 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -104,6 +104,8 @@ struct snd_soc_component_driver {
struct page *(*page)(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
unsigned long offset);
+ int (*ack) (struct snd_soc_component *component,
+ struct snd_pcm_substream *substream);
int (*mmap)(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
struct vm_area_struct *vma);
@@ -415,6 +417,7 @@ struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
unsigned long offset);
int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
struct vm_area_struct *vma);
+int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 785a0385cc7f..b4b3245ef016 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -516,6 +516,20 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
return -EINVAL;
}
+int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_component *component;
+ int i;
+
+ /* FIXME. it returns 1st ack now */
+ for_each_rtd_components(rtd, i, component)
+ if (component->driver->ack)
+ return component->driver->ack(component, substream);
+
+ return -EINVAL;
+}
+
int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 289aebc15529..c6fddd1cb5aa 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -3027,6 +3027,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
rtd->ops.ioctl = snd_soc_pcm_component_ioctl;
if (drv->sync_stop)
rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop;
+ if (drv->ack)
+ rtd->ops.ack = snd_soc_pcm_component_ack;
if (drv->copy_user)
rtd->ops.copy_user = snd_soc_pcm_component_copy_user;
if (drv->page)
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-03 3:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20200403021943epcas2p36334748d486a0d4703fb12d88fbc9ee8@epcas2p3.samsung.com>
2020-04-03 2:19 ` [PATCH 1/1] ASoC: soc-component: add snd_soc_component_ack() Gyeongtaek Lee
[not found] <CGME20200403022314epcas2p2f0626aacff2ad57890bf46d354c3b1c6@epcas2p2.samsung.com>
2020-04-03 2:23 ` Gyeongtaek Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).