diff options
Diffstat (limited to 'sound/soc/soc-component.c')
-rw-r--r-- | sound/soc/soc-component.c | 125 |
1 files changed, 45 insertions, 80 deletions
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 79ffc2820ba9..1590e805d016 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -314,30 +314,24 @@ void snd_soc_component_module_put(struct snd_soc_component *component, int snd_soc_component_open(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - if (component->driver->ops && - component->driver->ops->open) - return component->driver->ops->open(substream); - + if (component->driver->open) + return component->driver->open(component, substream); return 0; } int snd_soc_component_close(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - if (component->driver->ops && - component->driver->ops->close) - return component->driver->ops->close(substream); - + if (component->driver->close) + return component->driver->close(component, substream); return 0; } int snd_soc_component_prepare(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - if (component->driver->ops && - component->driver->ops->prepare) - return component->driver->ops->prepare(substream); - + if (component->driver->prepare) + return component->driver->prepare(component, substream); return 0; } @@ -345,20 +339,17 @@ int snd_soc_component_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - if (component->driver->ops && - component->driver->ops->hw_params) - return component->driver->ops->hw_params(substream, params); - + if (component->driver->hw_params) + return component->driver->hw_params(component, + substream, params); return 0; } int snd_soc_component_hw_free(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - if (component->driver->ops && - component->driver->ops->hw_free) - return component->driver->ops->hw_free(substream); - + if (component->driver->hw_free) + return component->driver->hw_free(component, substream); return 0; } @@ -366,10 +357,8 @@ int snd_soc_component_trigger(struct snd_soc_component *component, struct snd_pcm_substream *substream, int cmd) { - if (component->driver->ops && - component->driver->ops->trigger) - return component->driver->ops->trigger(substream, cmd); - + if (component->driver->trigger) + return component->driver->trigger(component, substream, cmd); return 0; } @@ -431,14 +420,10 @@ int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream) struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; - for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; - - /* FIXME: use 1st pointer */ - if (component->driver->ops && - component->driver->ops->pointer) - return component->driver->ops->pointer(substream); - } + /* FIXME: use 1st pointer */ + for_each_rtd_components(rtd, rtdcom, component) + if (component->driver->pointer) + return component->driver->pointer(component, substream); return 0; } @@ -450,15 +435,11 @@ int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream, struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; - for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; - - /* FIXME: use 1st ioctl */ - if (component->driver->ops && - component->driver->ops->ioctl) - return component->driver->ops->ioctl(substream, - cmd, arg); - } + /* FIXME: use 1st ioctl */ + for_each_rtd_components(rtd, rtdcom, component) + if (component->driver->ioctl) + return component->driver->ioctl(component, substream, + cmd, arg); return snd_pcm_lib_ioctl(substream, cmd, arg); } @@ -471,15 +452,11 @@ int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream, struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; - for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; - - /* FIXME. it returns 1st copy now */ - if (component->driver->ops && - component->driver->ops->copy_user) - return component->driver->ops->copy_user( - substream, channel, pos, buf, bytes); - } + /* FIXME. it returns 1st copy now */ + for_each_rtd_components(rtd, rtdcom, component) + if (component->driver->copy_user) + return component->driver->copy_user( + component, substream, channel, pos, buf, bytes); return -EINVAL; } @@ -492,13 +469,11 @@ struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream, struct snd_soc_component *component; struct page *page; - for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; - - /* FIXME. it returns 1st page now */ - if (component->driver->ops && - component->driver->ops->page) { - page = component->driver->ops->page(substream, offset); + /* FIXME. it returns 1st page now */ + for_each_rtd_components(rtd, rtdcom, component) { + if (component->driver->page) { + page = component->driver->page(component, + substream, offset); if (page) return page; } @@ -514,30 +489,24 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream, struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; - for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; - - /* FIXME. it returns 1st mmap now */ - if (component->driver->ops && - component->driver->ops->mmap) - return component->driver->ops->mmap(substream, vma); - } + /* FIXME. it returns 1st mmap now */ + for_each_rtd_components(rtd, rtdcom, component) + if (component->driver->mmap) + return component->driver->mmap(component, + substream, vma); return -EINVAL; } -int snd_soc_pcm_component_new(struct snd_pcm *pcm) +int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_pcm_runtime *rtd = pcm->private_data; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; int ret; - for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; - - if (component->driver->pcm_new) { - ret = component->driver->pcm_new(rtd); + for_each_rtd_components(rtd, rtdcom, component) { + if (component->driver->pcm_construct) { + ret = component->driver->pcm_construct(component, rtd); if (ret < 0) return ret; } @@ -546,16 +515,12 @@ int snd_soc_pcm_component_new(struct snd_pcm *pcm) return 0; } -void snd_soc_pcm_component_free(struct snd_pcm *pcm) +void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_pcm_runtime *rtd = pcm->private_data; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; - for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; - - if (component->driver->pcm_free) - component->driver->pcm_free(pcm); - } + for_each_rtd_components(rtd, rtdcom, component) + if (component->driver->pcm_destruct) + component->driver->pcm_destruct(component, rtd->pcm); } |