ASoC: component: Add sync_stop PCM ops
authorTakashi Iwai <tiwai@suse.de>
Thu, 21 Nov 2019 19:07:09 +0000 (20:07 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 22 Nov 2019 13:38:01 +0000 (14:38 +0100)
Add the support of the new PCM sync_stop ops in ASoC component.
It's optional and can be NULL unless you need the sync operation.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20191121190709.29121-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/soc-component.h
sound/soc/soc-component.c
sound/soc/soc-pcm.c

index 6aa3ecb7b6d3719e67f091f0b689667bdca0035c..d9dc8bcc96d00aef68b8ab1a8681b0b4d2f6faac 100644 (file)
@@ -88,6 +88,8 @@ struct snd_soc_component_driver {
                       struct snd_pcm_substream *substream);
        int (*trigger)(struct snd_soc_component *component,
                       struct snd_pcm_substream *substream, int cmd);
+       int (*sync_stop)(struct snd_soc_component *component,
+                        struct snd_pcm_substream *substream);
        snd_pcm_uframes_t (*pointer)(struct snd_soc_component *component,
                                     struct snd_pcm_substream *substream);
        int (*get_time_info)(struct snd_soc_component *component,
@@ -405,6 +407,7 @@ int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
                                unsigned int cmd, void *arg);
+int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream,
                                    int channel, unsigned long pos,
                                    void __user *buf, unsigned long bytes);
index 98ef0666add2afd4e7253849712e27f7ca88e5e1..58c1320a3521f8deb58b5b19b62b26f591aee2b1 100644 (file)
@@ -444,6 +444,25 @@ int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
        return snd_pcm_lib_ioctl(substream, cmd, arg);
 }
 
+int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_component *component;
+       struct snd_soc_rtdcom_list *rtdcom;
+       int ret;
+
+       for_each_rtd_components(rtd, rtdcom, component) {
+               if (component->driver->ioctl) {
+                       ret = component->driver->sync_stop(component,
+                                                          substream);
+                       if (ret < 0)
+                               return ret;
+               }
+       }
+
+       return 0;
+}
+
 int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream,
                                    int channel, unsigned long pos,
                                    void __user *buf, unsigned long bytes)
index 4dd13c9249abe15aa64067797f68154040f1c141..4457ac374a0ec77665587237bb9c285a5cf8e705 100644 (file)
@@ -3020,6 +3020,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 
                if (drv->ioctl)
                        rtd->ops.ioctl          = snd_soc_pcm_component_ioctl;
+               if (drv->sync_stop)
+                       rtd->ops.sync_stop      = snd_soc_pcm_component_sync_stop;
                if (drv->copy_user)
                        rtd->ops.copy_user      = snd_soc_pcm_component_copy_user;
                if (drv->page)