All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gyeongtaek Lee" <gt82.lee@samsung.com>
To: "'Mark Brown'" <broonie@kernel.org>, <kuninori.morimoto.gx@renesas.com>
Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, tiwai@suse.com,
	hmseo@samsung.com, cpgs@samsung.com, tkjung@samsung.com,
	pilsun.jang@samsung.com
Subject: [PATCH v2 1/1] ASoC: soc-component: add snd_soc_component_ack()
Date: Fri, 3 Apr 2020 13:17:23 +0900	[thread overview]
Message-ID: <1019298652.01585962901762.JavaMail.epsvc@epcpadp1> (raw)
In-Reply-To: CGME20200403041724epcas2p233810a68ae04a15427c33e5b82bc200a@epcas2p2.samsung.com

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 |  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)

base-commit: ef8e14794308a428b194f8b06ad9ae06b43466e4
-- 
2.21.0




           reply	other threads:[~2020-04-04  1:16 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CGME20200403041724epcas2p233810a68ae04a15427c33e5b82bc200a@epcas2p2.samsung.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1019298652.01585962901762.JavaMail.epsvc@epcpadp1 \
    --to=gt82.lee@samsung.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cpgs@samsung.com \
    --cc=hmseo@samsung.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=pilsun.jang@samsung.com \
    --cc=tiwai@suse.com \
    --cc=tkjung@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.