diff options
author | Mark Brown <broonie@kernel.org> | 2018-02-14 12:03:25 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-14 12:03:25 +0000 |
commit | 191db1ceb88264eea441648a63475538c5050461 (patch) | |
tree | 14cd917d53ae65d212523ef21307badfdf0a948f /sound | |
parent | ASoC: samsung: clean makefile about inexistant files (diff) | |
parent | ASoC: soc-utils: replace codec to component (diff) | |
download | linux-dev-191db1ceb88264eea441648a63475538c5050461.tar.xz linux-dev-191db1ceb88264eea441648a63475538c5050461.zip |
Merge branch 'topic/component-platform' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-samsung
Diffstat (limited to 'sound')
107 files changed, 1089 insertions, 878 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 4490a699030b..4563432badba 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -396,23 +396,23 @@ static int snd_compr_mmap(struct file *f, struct vm_area_struct *vma) return -ENXIO; } -static inline int snd_compr_get_poll(struct snd_compr_stream *stream) +static __poll_t snd_compr_get_poll(struct snd_compr_stream *stream) { if (stream->direction == SND_COMPRESS_PLAYBACK) - return POLLOUT | POLLWRNORM; + return EPOLLOUT | EPOLLWRNORM; else - return POLLIN | POLLRDNORM; + return EPOLLIN | EPOLLRDNORM; } -static unsigned int snd_compr_poll(struct file *f, poll_table *wait) +static __poll_t snd_compr_poll(struct file *f, poll_table *wait) { struct snd_compr_file *data = f->private_data; struct snd_compr_stream *stream; size_t avail; - int retval = 0; + __poll_t retval = 0; if (snd_BUG_ON(!data)) - return POLLERR; + return EPOLLERR; stream = &data->stream; @@ -421,7 +421,7 @@ static unsigned int snd_compr_poll(struct file *f, poll_table *wait) switch (stream->runtime->state) { case SNDRV_PCM_STATE_OPEN: case SNDRV_PCM_STATE_XRUN: - retval = snd_compr_get_poll(stream) | POLLERR; + retval = snd_compr_get_poll(stream) | EPOLLERR; goto out; default: break; @@ -447,7 +447,7 @@ static unsigned int snd_compr_poll(struct file *f, poll_table *wait) retval = snd_compr_get_poll(stream); break; default: - retval = snd_compr_get_poll(stream) | POLLERR; + retval = snd_compr_get_poll(stream) | EPOLLERR; break; } out: diff --git a/sound/core/control.c b/sound/core/control.c index 56b3e2d49c82..0b3026d937b1 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -25,6 +25,7 @@ #include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/time.h> +#include <linux/mm.h> #include <linux/sched/signal.h> #include <sound/core.h> #include <sound/minors.h> @@ -1129,7 +1130,7 @@ static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, if (size > 1024 * 128) /* sane value */ return -EINVAL; - container = memdup_user(buf, size); + container = vmemdup_user(buf, size); if (IS_ERR(container)) return PTR_ERR(container); @@ -1137,7 +1138,7 @@ static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, if (!change) change = memcmp(ue->tlv_data, container, size) != 0; if (!change) { - kfree(container); + kvfree(container); return 0; } @@ -1148,7 +1149,7 @@ static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, mask = SNDRV_CTL_EVENT_MASK_INFO; } - kfree(ue->tlv_data); + kvfree(ue->tlv_data); ue->tlv_data = container; ue->tlv_data_size = size; @@ -1197,7 +1198,7 @@ static int snd_ctl_elem_init_enum_names(struct user_element *ue) if (ue->info.value.enumerated.names_length > 64 * 1024) return -EINVAL; - names = memdup_user((const void __user *)user_ptrval, + names = vmemdup_user((const void __user *)user_ptrval, ue->info.value.enumerated.names_length); if (IS_ERR(names)) return PTR_ERR(names); @@ -1208,7 +1209,7 @@ static int snd_ctl_elem_init_enum_names(struct user_element *ue) for (i = 0; i < ue->info.value.enumerated.items; ++i) { name_len = strnlen(p, buf_len); if (name_len == 0 || name_len >= 64 || name_len == buf_len) { - kfree(names); + kvfree(names); return -EINVAL; } p += name_len + 1; @@ -1225,8 +1226,8 @@ static void snd_ctl_elem_user_free(struct snd_kcontrol *kcontrol) { struct user_element *ue = kcontrol->private_data; - kfree(ue->tlv_data); - kfree(ue->priv_data); + kvfree(ue->tlv_data); + kvfree(ue->priv_data); kfree(ue); } @@ -1666,9 +1667,9 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer, return result > 0 ? result : err; } -static unsigned int snd_ctl_poll(struct file *file, poll_table * wait) +static __poll_t snd_ctl_poll(struct file *file, poll_table * wait) { - unsigned int mask; + __poll_t mask; struct snd_ctl_file *ctl; ctl = file->private_data; @@ -1678,7 +1679,7 @@ static unsigned int snd_ctl_poll(struct file *file, poll_table * wait) mask = 0; if (!list_empty(&ctl->events)) - mask |= POLLIN | POLLRDNORM; + mask |= EPOLLIN | EPOLLRDNORM; return mask; } diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 8faae3d1455d..26e71cf05f1e 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -177,7 +177,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file) return err; } -static unsigned int snd_hwdep_poll(struct file * file, poll_table * wait) +static __poll_t snd_hwdep_poll(struct file * file, poll_table * wait) { struct snd_hwdep *hw = file->private_data; if (hw->ops.poll) @@ -233,8 +233,6 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw, /* check whether the dsp was already loaded */ if (hw->dsp_loaded & (1 << info.index)) return -EBUSY; - if (!access_ok(VERIFY_READ, info.image, info.length)) - return -EFAULT; err = hw->ops.dsp_load(hw, &info); if (err < 0) return err; diff --git a/sound/core/info.c b/sound/core/info.c index bcf6a48cc70d..4b36767af9e1 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -203,20 +203,20 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer return size; } -static unsigned int snd_info_entry_poll(struct file *file, poll_table *wait) +static __poll_t snd_info_entry_poll(struct file *file, poll_table *wait) { struct snd_info_private_data *data = file->private_data; struct snd_info_entry *entry = data->entry; - unsigned int mask = 0; + __poll_t mask = 0; if (entry->c.ops->poll) return entry->c.ops->poll(entry, data->file_private_data, file, wait); if (entry->c.ops->read) - mask |= POLLIN | POLLRDNORM; + mask |= EPOLLIN | EPOLLRDNORM; if (entry->c.ops->write) - mask |= POLLOUT | POLLWRNORM; + mask |= EPOLLOUT | EPOLLWRNORM; return mask; } diff --git a/sound/core/init.c b/sound/core/init.c index 168ae03d3a1c..4fa5dd955740 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -344,9 +344,9 @@ static int snd_disconnect_release(struct inode *inode, struct file *file) panic("%s(%p, %p) failed!", __func__, inode, file); } -static unsigned int snd_disconnect_poll(struct file * file, poll_table * wait) +static __poll_t snd_disconnect_poll(struct file * file, poll_table * wait) { - return POLLERR | POLLNVAL; + return EPOLLERR | EPOLLNVAL; } static long snd_disconnect_ioctl(struct file *file, diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index c2db7e905f7d..b044c0a5a674 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -186,7 +186,7 @@ static int _snd_pcm_hw_param_mask(struct snd_pcm_hw_params *params, { int changed; changed = snd_mask_refine(hw_param_mask(params, var), val); - if (changed) { + if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } @@ -233,7 +233,7 @@ static int _snd_pcm_hw_param_min(struct snd_pcm_hw_params *params, val, open); else return -EINVAL; - if (changed) { + if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } @@ -294,7 +294,7 @@ static int _snd_pcm_hw_param_max(struct snd_pcm_hw_params *params, val, open); else return -EINVAL; - if (changed) { + if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } @@ -499,7 +499,7 @@ static int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params, } } else return -EINVAL; - if (changed) { + if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } @@ -539,7 +539,7 @@ static int _snd_pcm_hw_param_setinteger(struct snd_pcm_hw_params *params, { int changed; changed = snd_interval_setinteger(hw_param_interval(params, var)); - if (changed) { + if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } @@ -842,7 +842,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream, if (!(mutex_trylock(&runtime->oss.params_lock))) return -EAGAIN; } else if (mutex_lock_interruptible(&runtime->oss.params_lock)) - return -EINTR; + return -ERESTARTSYS; sw_params = kzalloc(sizeof(*sw_params), GFP_KERNEL); params = kmalloc(sizeof(*params), GFP_KERNEL); sparams = kmalloc(sizeof(*sparams), GFP_KERNEL); @@ -2686,10 +2686,10 @@ static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream) runtime->oss.period_frames; } -static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) +static __poll_t snd_pcm_oss_poll(struct file *file, poll_table * wait) { struct snd_pcm_oss_file *pcm_oss_file; - unsigned int mask; + __poll_t mask; struct snd_pcm_substream *psubstream = NULL, *csubstream = NULL; pcm_oss_file = file->private_data; @@ -2705,7 +2705,7 @@ static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) if (runtime->status->state != SNDRV_PCM_STATE_DRAINING && (runtime->status->state != SNDRV_PCM_STATE_RUNNING || snd_pcm_oss_playback_ready(psubstream))) - mask |= POLLOUT | POLLWRNORM; + mask |= EPOLLOUT | EPOLLWRNORM; snd_pcm_stream_unlock_irq(psubstream); } if (csubstream != NULL) { @@ -2715,7 +2715,7 @@ static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) snd_pcm_stream_lock_irq(csubstream); if ((ostate = runtime->status->state) != SNDRV_PCM_STATE_RUNNING || snd_pcm_oss_capture_ready(csubstream)) - mask |= POLLIN | POLLRDNORM; + mask |= EPOLLIN | EPOLLRDNORM; snd_pcm_stream_unlock_irq(csubstream); if (ostate != SNDRV_PCM_STATE_RUNNING && runtime->oss.trigger) { struct snd_pcm_oss_file ofile; diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index faa67861cbc1..a83152e7d387 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1602,7 +1602,7 @@ static int _snd_pcm_hw_param_first(struct snd_pcm_hw_params *params, changed = snd_interval_refine_first(hw_param_interval(params, var)); else return -EINVAL; - if (changed) { + if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } @@ -1648,7 +1648,7 @@ static int _snd_pcm_hw_param_last(struct snd_pcm_hw_params *params, changed = snd_interval_refine_last(hw_param_interval(params, var)); else return -EINVAL; - if (changed) { + if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index f08772568c17..77ba50ddcf9e 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -3135,19 +3135,19 @@ static ssize_t snd_pcm_writev(struct kiocb *iocb, struct iov_iter *from) return result; } -static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) +static __poll_t snd_pcm_playback_poll(struct file *file, poll_table * wait) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; - unsigned int mask; + __poll_t mask; snd_pcm_uframes_t avail; pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) - return POLLOUT | POLLWRNORM | POLLERR; + return EPOLLOUT | EPOLLWRNORM | EPOLLERR; runtime = substream->runtime; poll_wait(file, &runtime->sleep, wait); @@ -3159,7 +3159,7 @@ static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) case SNDRV_PCM_STATE_PREPARED: case SNDRV_PCM_STATE_PAUSED: if (avail >= runtime->control->avail_min) { - mask = POLLOUT | POLLWRNORM; + mask = EPOLLOUT | EPOLLWRNORM; break; } /* Fall through */ @@ -3167,26 +3167,26 @@ static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) mask = 0; break; default: - mask = POLLOUT | POLLWRNORM | POLLERR; + mask = EPOLLOUT | EPOLLWRNORM | EPOLLERR; break; } snd_pcm_stream_unlock_irq(substream); return mask; } -static unsigned int snd_pcm_capture_poll(struct file *file, poll_table * wait) +static __poll_t snd_pcm_capture_poll(struct file *file, poll_table * wait) { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; - unsigned int mask; + __poll_t mask; snd_pcm_uframes_t avail; pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) - return POLLIN | POLLRDNORM | POLLERR; + return EPOLLIN | EPOLLRDNORM | EPOLLERR; runtime = substream->runtime; poll_wait(file, &runtime->sleep, wait); @@ -3198,19 +3198,19 @@ static unsigned int snd_pcm_capture_poll(struct file *file, poll_table * wait) case SNDRV_PCM_STATE_PREPARED: case SNDRV_PCM_STATE_PAUSED: if (avail >= runtime->control->avail_min) { - mask = POLLIN | POLLRDNORM; + mask = EPOLLIN | EPOLLRDNORM; break; } mask = 0; break; case SNDRV_PCM_STATE_DRAINING: if (avail > 0) { - mask = POLLIN | POLLRDNORM; + mask = EPOLLIN | EPOLLRDNORM; break; } /* Fall through */ default: - mask = POLLIN | POLLRDNORM | POLLERR; + mask = EPOLLIN | EPOLLRDNORM | EPOLLERR; break; } snd_pcm_stream_unlock_irq(substream); @@ -3446,7 +3446,7 @@ EXPORT_SYMBOL_GPL(snd_pcm_lib_default_mmap); int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_struct *area) { - struct snd_pcm_runtime *runtime = substream->runtime;; + struct snd_pcm_runtime *runtime = substream->runtime; area->vm_page_prot = pgprot_noncached(area->vm_page_prot); return vm_iomap_memory(area, runtime->dma_addr, runtime->dma_bytes); diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index f055ca10bbc1..69616d00481c 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1366,11 +1366,11 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, return result; } -static unsigned int snd_rawmidi_poll(struct file *file, poll_table * wait) +static __poll_t snd_rawmidi_poll(struct file *file, poll_table * wait) { struct snd_rawmidi_file *rfile; struct snd_rawmidi_runtime *runtime; - unsigned int mask; + __poll_t mask; rfile = file->private_data; if (rfile->input != NULL) { @@ -1385,11 +1385,11 @@ static unsigned int snd_rawmidi_poll(struct file *file, poll_table * wait) mask = 0; if (rfile->input != NULL) { if (snd_rawmidi_ready(rfile->input)) - mask |= POLLIN | POLLRDNORM; + mask |= EPOLLIN | EPOLLRDNORM; } if (rfile->output != NULL) { if (snd_rawmidi_ready(rfile->output)) - mask |= POLLOUT | POLLWRNORM; + mask |= EPOLLOUT | EPOLLWRNORM; } return mask; } diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 8cdf489df80e..5f64d0d88320 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c @@ -59,7 +59,7 @@ static int odev_release(struct inode *inode, struct file *file); static ssize_t odev_read(struct file *file, char __user *buf, size_t count, loff_t *offset); static ssize_t odev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset); static long odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -static unsigned int odev_poll(struct file *file, poll_table * wait); +static __poll_t odev_poll(struct file *file, poll_table * wait); /* @@ -197,7 +197,7 @@ static long odev_ioctl_compat(struct file *file, unsigned int cmd, #define odev_ioctl_compat NULL #endif -static unsigned int +static __poll_t odev_poll(struct file *file, poll_table * wait) { struct seq_oss_devinfo *dp; diff --git a/sound/core/seq/oss/seq_oss_device.h b/sound/core/seq/oss/seq_oss_device.h index afa007c0cc2d..2d0e9eaf13aa 100644 --- a/sound/core/seq/oss/seq_oss_device.h +++ b/sound/core/seq/oss/seq_oss_device.h @@ -124,7 +124,7 @@ void snd_seq_oss_release(struct seq_oss_devinfo *dp); int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg); int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count); int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt); -unsigned int snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait); +__poll_t snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait); void snd_seq_oss_reset(struct seq_oss_devinfo *dp); diff --git a/sound/core/seq/oss/seq_oss_rw.c b/sound/core/seq/oss/seq_oss_rw.c index 6a7b6aceeca9..30886f5fb100 100644 --- a/sound/core/seq/oss/seq_oss_rw.c +++ b/sound/core/seq/oss/seq_oss_rw.c @@ -196,21 +196,21 @@ insert_queue(struct seq_oss_devinfo *dp, union evrec *rec, struct file *opt) * select / poll */ -unsigned int +__poll_t snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait) { - unsigned int mask = 0; + __poll_t mask = 0; /* input */ if (dp->readq && is_read_mode(dp->file_mode)) { if (snd_seq_oss_readq_poll(dp->readq, file, wait)) - mask |= POLLIN | POLLRDNORM; + mask |= EPOLLIN | EPOLLRDNORM; } /* output */ if (dp->writeq && is_write_mode(dp->file_mode)) { if (snd_seq_kernel_client_write_poll(dp->cseq, file, wait)) - mask |= POLLOUT | POLLWRNORM; + mask |= EPOLLOUT | EPOLLWRNORM; } return mask; } diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index d01913404581..60db32785f62 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -1087,10 +1087,10 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, /* * handle polling */ -static unsigned int snd_seq_poll(struct file *file, poll_table * wait) +static __poll_t snd_seq_poll(struct file *file, poll_table * wait) { struct snd_seq_client *client = file->private_data; - unsigned int mask = 0; + __poll_t mask = 0; /* check client structures are in place */ if (snd_BUG_ON(!client)) @@ -1101,7 +1101,7 @@ static unsigned int snd_seq_poll(struct file *file, poll_table * wait) /* check if data is available in the outqueue */ if (snd_seq_fifo_poll_wait(client->data.user.fifo, file, wait)) - mask |= POLLIN | POLLRDNORM; + mask |= EPOLLIN | EPOLLRDNORM; } if (snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_OUTPUT) { @@ -1109,7 +1109,7 @@ static unsigned int snd_seq_poll(struct file *file, poll_table * wait) /* check if data is available in the pool */ if (!snd_seq_write_pool_allocated(client) || snd_seq_pool_poll_wait(client->pool, file, wait)) - mask |= POLLOUT | POLLWRNORM; + mask |= EPOLLOUT | EPOLLWRNORM; } return mask; diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index 79e0c5604ef8..0428e9061b47 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c @@ -497,9 +497,7 @@ int snd_seq_queue_timer_set_tempo(int queueid, int client, return -EPERM; } - result = snd_seq_timer_set_tempo(q->timer, info->tempo); - if (result >= 0) - result = snd_seq_timer_set_ppq(q->timer, info->ppq); + result = snd_seq_timer_set_tempo_ppq(q->timer, info->tempo, info->ppq); if (result >= 0 && info->skew_base > 0) result = snd_seq_timer_set_skew(q->timer, info->skew_value, info->skew_base); diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c index b80985fbc334..23167578231f 100644 --- a/sound/core/seq/seq_timer.c +++ b/sound/core/seq/seq_timer.c @@ -191,14 +191,15 @@ int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo) return 0; } -/* set current ppq */ -int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq) +/* set current tempo and ppq in a shot */ +int snd_seq_timer_set_tempo_ppq(struct snd_seq_timer *tmr, int tempo, int ppq) { + int changed; unsigned long flags; if (snd_BUG_ON(!tmr)) return -EINVAL; - if (ppq <= 0) + if (tempo <= 0 || ppq <= 0) return -EINVAL; spin_lock_irqsave(&tmr->lock, flags); if (tmr->running && (ppq != tmr->ppq)) { @@ -208,9 +209,11 @@ int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq) pr_debug("ALSA: seq: cannot change ppq of a running timer\n"); return -EBUSY; } - + changed = (tempo != tmr->tempo) || (ppq != tmr->ppq); + tmr->tempo = tempo; tmr->ppq = ppq; - snd_seq_timer_set_tick_resolution(tmr); + if (changed) + snd_seq_timer_set_tick_resolution(tmr); spin_unlock_irqrestore(&tmr->lock, flags); return 0; } diff --git a/sound/core/seq/seq_timer.h b/sound/core/seq/seq_timer.h index 9506b661fe5b..62f390671096 100644 --- a/sound/core/seq/seq_timer.h +++ b/sound/core/seq/seq_timer.h @@ -131,7 +131,7 @@ int snd_seq_timer_stop(struct snd_seq_timer *tmr); int snd_seq_timer_start(struct snd_seq_timer *tmr); int snd_seq_timer_continue(struct snd_seq_timer *tmr); int snd_seq_timer_set_tempo(struct snd_seq_timer *tmr, int tempo); -int snd_seq_timer_set_ppq(struct snd_seq_timer *tmr, int ppq); +int snd_seq_timer_set_tempo_ppq(struct snd_seq_timer *tmr, int tempo, int ppq); int snd_seq_timer_set_position_tick(struct snd_seq_timer *tmr, snd_seq_tick_time_t position); int snd_seq_timer_set_position_time(struct snd_seq_timer *tmr, snd_seq_real_time_t position); int snd_seq_timer_set_skew(struct snd_seq_timer *tmr, unsigned int skew, unsigned int base); diff --git a/sound/core/timer.c b/sound/core/timer.c index ee09dace8bb1..dc87728c5b74 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -2072,9 +2072,9 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, return result > 0 ? result : err; } -static unsigned int snd_timer_user_poll(struct file *file, poll_table * wait) +static __poll_t snd_timer_user_poll(struct file *file, poll_table * wait) { - unsigned int mask; + __poll_t mask; struct snd_timer_user *tu; tu = file->private_data; @@ -2084,9 +2084,9 @@ static unsigned int snd_timer_user_poll(struct file *file, poll_table * wait) mask = 0; spin_lock_irq(&tu->qlock); if (tu->qused) - mask |= POLLIN | POLLRDNORM; + mask |= EPOLLIN | EPOLLRDNORM; if (tu->disconnected) - mask |= POLLERR; + mask |= EPOLLERR; spin_unlock_irq(&tu->qlock); return mask; diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 7b2b1f766b00..8fb9a54fe8ba 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -375,17 +375,9 @@ struct dummy_hrtimer_pcm { ktime_t period_time; atomic_t running; struct hrtimer timer; - struct tasklet_struct tasklet; struct snd_pcm_substream *substream; }; -static void dummy_hrtimer_pcm_elapsed(unsigned long priv) -{ - struct dummy_hrtimer_pcm *dpcm = (struct dummy_hrtimer_pcm *)priv; - if (atomic_read(&dpcm->running)) - snd_pcm_period_elapsed(dpcm->substream); -} - static enum hrtimer_restart dummy_hrtimer_callback(struct hrtimer *timer) { struct dummy_hrtimer_pcm *dpcm; @@ -393,7 +385,14 @@ static enum hrtimer_restart dummy_hrtimer_callback(struct hrtimer *timer) dpcm = container_of(timer, struct dummy_hrtimer_pcm, timer); if (!atomic_read(&dpcm->running)) return HRTIMER_NORESTART; - tasklet_schedule(&dpcm->tasklet); + /* + * In cases of XRUN and draining, this calls .trigger to stop PCM + * substream. + */ + snd_pcm_period_elapsed(dpcm->substream); + if (!atomic_read(&dpcm->running)) + return HRTIMER_NORESTART; + hrtimer_forward_now(timer, dpcm->period_time); return HRTIMER_RESTART; } @@ -403,7 +402,7 @@ static int dummy_hrtimer_start(struct snd_pcm_substream *substream) struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; dpcm->base_time = hrtimer_cb_get_time(&dpcm->timer); - hrtimer_start(&dpcm->timer, dpcm->period_time, HRTIMER_MODE_REL); + hrtimer_start(&dpcm->timer, dpcm->period_time, HRTIMER_MODE_REL_SOFT); atomic_set(&dpcm->running, 1); return 0; } @@ -413,14 +412,14 @@ static int dummy_hrtimer_stop(struct snd_pcm_substream *substream) struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; atomic_set(&dpcm->running, 0); - hrtimer_cancel(&dpcm->timer); + if (!hrtimer_callback_running(&dpcm->timer)) + hrtimer_cancel(&dpcm->timer); return 0; } static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm) { hrtimer_cancel(&dpcm->timer); - tasklet_kill(&dpcm->tasklet); } static snd_pcm_uframes_t @@ -465,12 +464,10 @@ static int dummy_hrtimer_create(struct snd_pcm_substream *substream) if (!dpcm) return -ENOMEM; substream->runtime->private_data = dpcm; - hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT); dpcm->timer.function = dummy_hrtimer_callback; dpcm->substream = substream; atomic_set(&dpcm->running, 0); - tasklet_init(&dpcm->tasklet, dummy_hrtimer_pcm_elapsed, - (unsigned long)dpcm); return 0; } @@ -830,7 +827,7 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *info) { - const char *const names[] = { "None", "CD Player" }; + static const char *const names[] = { "None", "CD Player" }; return snd_ctl_enum_info(info, 1, 2, names); } diff --git a/sound/firewire/bebob/bebob_hwdep.c b/sound/firewire/bebob/bebob_hwdep.c index 2b367c21b80c..04c321e08c62 100644 --- a/sound/firewire/bebob/bebob_hwdep.c +++ b/sound/firewire/bebob/bebob_hwdep.c @@ -53,17 +53,17 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, return count; } -static unsigned int +static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) { struct snd_bebob *bebob = hwdep->private_data; - unsigned int events; + __poll_t events; poll_wait(file, &bebob->hwdep_wait, wait); spin_lock_irq(&bebob->lock); if (bebob->dev_lock_changed) - events = POLLIN | POLLRDNORM; + events = EPOLLIN | EPOLLRDNORM; else events = 0; spin_unlock_irq(&bebob->lock); diff --git a/sound/firewire/dice/dice-hwdep.c b/sound/firewire/dice/dice-hwdep.c index a4dc02a86f12..6498bf6909ba 100644 --- a/sound/firewire/dice/dice-hwdep.c +++ b/sound/firewire/dice/dice-hwdep.c @@ -52,17 +52,17 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, return count; } -static unsigned int hwdep_poll(struct snd_hwdep *hwdep, struct file *file, +static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) { struct snd_dice *dice = hwdep->private_data; - unsigned int events; + __poll_t events; poll_wait(file, &dice->hwdep_wait, wait); spin_lock_irq(&dice->lock); if (dice->dev_lock_changed || dice->notification_bits != 0) - events = POLLIN | POLLRDNORM; + events = EPOLLIN | EPOLLRDNORM; else events = 0; spin_unlock_irq(&dice->lock); diff --git a/sound/firewire/digi00x/digi00x-hwdep.c b/sound/firewire/digi00x/digi00x-hwdep.c index 463c6b8e864d..426cd39e0233 100644 --- a/sound/firewire/digi00x/digi00x-hwdep.c +++ b/sound/firewire/digi00x/digi00x-hwdep.c @@ -60,17 +60,17 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, return count; } -static unsigned int hwdep_poll(struct snd_hwdep *hwdep, struct file *file, +static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) { struct snd_dg00x *dg00x = hwdep->private_data; - unsigned int events; + __poll_t events; poll_wait(file, &dg00x->hwdep_wait, wait); spin_lock_irq(&dg00x->lock); if (dg00x->dev_lock_changed || dg00x->msg) - events = POLLIN | POLLRDNORM; + events = EPOLLIN | EPOLLRDNORM; else events = 0; spin_unlock_irq(&dg00x->lock); diff --git a/sound/firewire/fireface/ff-hwdep.c b/sound/firewire/fireface/ff-hwdep.c index 3ee04b054585..336c0076ec42 100644 --- a/sound/firewire/fireface/ff-hwdep.c +++ b/sound/firewire/fireface/ff-hwdep.c @@ -52,17 +52,17 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, return count; } -static unsigned int hwdep_poll(struct snd_hwdep *hwdep, struct file *file, +static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) { struct snd_ff *ff = hwdep->private_data; - unsigned int events; + __poll_t events; poll_wait(file, &ff->hwdep_wait, wait); spin_lock_irq(&ff->lock); if (ff->dev_lock_changed) - events = POLLIN | POLLRDNORM; + events = EPOLLIN | EPOLLRDNORM; else events = 0; spin_unlock_irq(&ff->lock); diff --git a/sound/firewire/fireworks/fireworks_hwdep.c b/sound/firewire/fireworks/fireworks_hwdep.c index a3a3a16f5e08..5cac26ab20b7 100644 --- a/sound/firewire/fireworks/fireworks_hwdep.c +++ b/sound/firewire/fireworks/fireworks_hwdep.c @@ -184,22 +184,22 @@ end: return count; } -static unsigned int +static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) { struct snd_efw *efw = hwdep->private_data; - unsigned int events; + __poll_t events; poll_wait(file, &efw->hwdep_wait, wait); spin_lock_irq(&efw->lock); if (efw->dev_lock_changed || efw->pull_ptr != efw->push_ptr) - events = POLLIN | POLLRDNORM; + events = EPOLLIN | EPOLLRDNORM; else events = 0; spin_unlock_irq(&efw->lock); - return events | POLLOUT; + return events | EPOLLOUT; } static int diff --git a/sound/firewire/motu/motu-hwdep.c b/sound/firewire/motu/motu-hwdep.c index b87ccb69d597..5f772eab588b 100644 --- a/sound/firewire/motu/motu-hwdep.c +++ b/sound/firewire/motu/motu-hwdep.c @@ -59,22 +59,22 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, return count; } -static unsigned int hwdep_poll(struct snd_hwdep *hwdep, struct file *file, +static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) { struct snd_motu *motu = hwdep->private_data; - unsigned int events; + __poll_t events; poll_wait(file, &motu->hwdep_wait, wait); spin_lock_irq(&motu->lock); if (motu->dev_lock_changed || motu->msg) - events = POLLIN | POLLRDNORM; + events = EPOLLIN | EPOLLRDNORM; else events = 0; spin_unlock_irq(&motu->lock); - return events | POLLOUT; + return events | EPOLLOUT; } static int hwdep_get_info(struct snd_motu *motu, void __user *arg) diff --git a/sound/firewire/oxfw/oxfw-hwdep.c b/sound/firewire/oxfw/oxfw-hwdep.c index ff2687ad0460..50a1c03b42b9 100644 --- a/sound/firewire/oxfw/oxfw-hwdep.c +++ b/sound/firewire/oxfw/oxfw-hwdep.c @@ -52,17 +52,17 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, return count; } -static unsigned int hwdep_poll(struct snd_hwdep *hwdep, struct file *file, +static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) { struct snd_oxfw *oxfw = hwdep->private_data; - unsigned int events; + __poll_t events; poll_wait(file, &oxfw->hwdep_wait, wait); spin_lock_irq(&oxfw->lock); if (oxfw->dev_lock_changed) - events = POLLIN | POLLRDNORM; + events = EPOLLIN | EPOLLRDNORM; else events = 0; spin_unlock_irq(&oxfw->lock); diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c index 8c4437d0051d..4e4c1e9020e8 100644 --- a/sound/firewire/tascam/tascam-hwdep.c +++ b/sound/firewire/tascam/tascam-hwdep.c @@ -50,17 +50,17 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, return count; } -static unsigned int hwdep_poll(struct snd_hwdep *hwdep, struct file *file, +static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) { struct snd_tscm *tscm = hwdep->private_data; - unsigned int events; + __poll_t events; poll_wait(file, &tscm->hwdep_wait, wait); spin_lock_irq(&tscm->lock); if (tscm->dev_lock_changed) - events = POLLIN | POLLRDNORM; + events = EPOLLIN | EPOLLRDNORM; else events = 0; spin_unlock_irq(&tscm->lock); diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c index 36c27c832360..7f95f452f106 100644 --- a/sound/isa/gus/gus_dma.c +++ b/sound/isa/gus/gus_dma.c @@ -201,10 +201,9 @@ int snd_gf1_dma_transfer_block(struct snd_gus_card * gus, struct snd_gf1_dma_block *block; block = kmalloc(sizeof(*block), atomic ? GFP_ATOMIC : GFP_KERNEL); - if (block == NULL) { - snd_printk(KERN_ERR "gf1: DMA transfer failure; not enough memory\n"); + if (!block) return -ENOMEM; - } + *block = *__block; block->next = NULL; diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index 37d378a26a50..c8904e732aaa 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -814,7 +814,7 @@ static int hal2_create(struct snd_card *card, struct snd_hal2 **rchip) struct hpc3_regs *hpc3 = hpc3c0; int err; - hal2 = kzalloc(sizeof(struct snd_hal2), GFP_KERNEL); + hal2 = kzalloc(sizeof(*hal2), GFP_KERNEL); if (!hal2) return -ENOMEM; diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 71c942162c25..9fb68b35de5a 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -840,7 +840,7 @@ static int snd_sgio2audio_create(struct snd_card *card, if (!(readq(&mace->perif.audio.control) & AUDIO_CONTROL_CODEC_PRESENT)) return -ENOENT; - chip = kzalloc(sizeof(struct snd_sgio2audio), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c index fb3bbceb1fef..8c0f8a9ee0ba 100644 --- a/sound/oss/dmasound/dmasound_core.c +++ b/sound/oss/dmasound/dmasound_core.c @@ -670,9 +670,9 @@ static ssize_t sq_write(struct file *file, const char __user *src, size_t uLeft, return uUsed < 0? uUsed: uWritten; } -static unsigned int sq_poll(struct file *file, struct poll_table_struct *wait) +static __poll_t sq_poll(struct file *file, struct poll_table_struct *wait) { - unsigned int mask = 0; + __poll_t mask = 0; int retVal; if (write_sq.locked == 0) { @@ -684,7 +684,7 @@ static unsigned int sq_poll(struct file *file, struct poll_table_struct *wait) poll_wait(file, &write_sq.action_queue, wait); if (file->f_mode & FMODE_WRITE) if (write_sq.count < write_sq.max_active || write_sq.block_size - write_sq.rear_size > 0) - mask |= POLLOUT | POLLWRNORM; + mask |= EPOLLOUT | EPOLLWRNORM; return mask; } diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 7f3b5ed81995..f7a492c382d9 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig @@ -88,7 +88,6 @@ config SND_HDA_PATCH_LOADER config SND_HDA_CODEC_REALTEK tristate "Build Realtek HD-audio codec support" select SND_HDA_GENERIC - select INPUT help Say Y or M here to include Realtek HD-audio codec support in snd-hda-intel driver, such as ALC880. diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 9aafc6c86132..23475888192b 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -3154,11 +3154,13 @@ static void alc256_shutup(struct hda_codec *codec) if (hp_pin_sense) msleep(85); + /* 3k pull low control for Headset jack. */ + /* NOTE: call this before clearing the pin, otherwise codec stalls */ + alc_update_coef_idx(codec, 0x46, 0, 3 << 12); + snd_hda_codec_write(codec, hp_pin, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); - alc_update_coef_idx(codec, 0x46, 0, 3 << 12); /* 3k pull low control for Headset jack. */ - if (hp_pin_sense) msleep(100); @@ -3166,6 +3168,93 @@ static void alc256_shutup(struct hda_codec *codec) snd_hda_shutup_pins(codec); } +static void alc225_init(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; + bool hp1_pin_sense, hp2_pin_sense; + + if (!hp_pin) + return; + + msleep(30); + + hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin); + hp2_pin_sense = snd_hda_jack_detect(codec, 0x16); + + if (hp1_pin_sense || hp2_pin_sense) + msleep(2); + + alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */ + + if (hp1_pin_sense) + snd_hda_codec_write(codec, hp_pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + if (hp2_pin_sense) + snd_hda_codec_write(codec, 0x16, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + + if (hp1_pin_sense || hp2_pin_sense) + msleep(85); + + if (hp1_pin_sense) + snd_hda_codec_write(codec, hp_pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + if (hp2_pin_sense) + snd_hda_codec_write(codec, 0x16, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + + if (hp1_pin_sense || hp2_pin_sense) + msleep(100); + + alc_update_coef_idx(codec, 0x4a, 3 << 10, 0); + alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */ +} + +static void alc225_shutup(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; + bool hp1_pin_sense, hp2_pin_sense; + + if (!hp_pin) { + alc269_shutup(codec); + return; + } + + /* 3k pull low control for Headset jack. */ + alc_update_coef_idx(codec, 0x4a, 0, 3 << 10); + + hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin); + hp2_pin_sense = snd_hda_jack_detect(codec, 0x16); + + if (hp1_pin_sense || hp2_pin_sense) + msleep(2); + + if (hp1_pin_sense) + snd_hda_codec_write(codec, hp_pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + if (hp2_pin_sense) + snd_hda_codec_write(codec, 0x16, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + + if (hp1_pin_sense || hp2_pin_sense) + msleep(85); + + if (hp1_pin_sense) + snd_hda_codec_write(codec, hp_pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); + if (hp2_pin_sense) + snd_hda_codec_write(codec, 0x16, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); + + if (hp1_pin_sense || hp2_pin_sense) + msleep(100); + + alc_auto_setup_eapd(codec, false); + snd_hda_shutup_pins(codec); +} + static void alc_default_init(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; @@ -3723,6 +3812,7 @@ static void alc280_fixup_hp_gpio4(struct hda_codec *codec, } } +#if IS_REACHABLE(INPUT) static void gpio2_mic_hotkey_event(struct hda_codec *codec, struct hda_jack_callback *event) { @@ -3855,6 +3945,10 @@ static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec, spec->kb_dev = NULL; } } +#else /* INPUT */ +#define alc280_fixup_hp_gpio2_mic_hotkey NULL +#define alc233_fixup_lenovo_line2_mic_hotkey NULL +#endif /* INPUT */ static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, const struct hda_fixup *fix, int action) @@ -3994,8 +4088,11 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) case 0x10ec0668: alc_process_coef_fw(codec, coef0668); break; + case 0x10ec0215: case 0x10ec0225: + case 0x10ec0285: case 0x10ec0295: + case 0x10ec0289: case 0x10ec0299: alc_process_coef_fw(codec, coef0225); break; @@ -4117,8 +4214,11 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, alc_process_coef_fw(codec, coef0688); snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); break; + case 0x10ec0215: case 0x10ec0225: + case 0x10ec0285: case 0x10ec0295: + case 0x10ec0289: case 0x10ec0299: alc_process_coef_fw(codec, alc225_pre_hsmode); alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10); @@ -4189,8 +4289,11 @@ static void alc_headset_mode_default(struct hda_codec *codec) }; switch (codec->core.vendor_id) { + case 0x10ec0215: case 0x10ec0225: + case 0x10ec0285: case 0x10ec0295: + case 0x10ec0289: case 0x10ec0299: alc_process_coef_fw(codec, alc225_pre_hsmode); alc_process_coef_fw(codec, coef0225); @@ -4332,8 +4435,11 @@ static void alc_headset_mode_ctia(struct hda_codec *codec) case 0x10ec0668: alc_process_coef_fw(codec, coef0688); break; + case 0x10ec0215: case 0x10ec0225: + case 0x10ec0285: case 0x10ec0295: + case 0x10ec0289: case 0x10ec0299: val = alc_read_coef_idx(codec, 0x45); if (val & (1 << 9)) @@ -4436,8 +4542,11 @@ static void alc_headset_mode_omtp(struct hda_codec *codec) case 0x10ec0668: alc_process_coef_fw(codec, coef0688); break; + case 0x10ec0215: case 0x10ec0225: + case 0x10ec0285: case 0x10ec0295: + case 0x10ec0289: case 0x10ec0299: alc_process_coef_fw(codec, coef0225); break; @@ -4566,9 +4675,18 @@ static void alc_determine_headset_type(struct hda_codec *codec) val = alc_read_coef_idx(codec, 0xbe); is_ctia = (val & 0x1c02) == 0x1c02; break; + case 0x10ec0215: case 0x10ec0225: + case 0x10ec0285: case 0x10ec0295: + case 0x10ec0289: case 0x10ec0299: + snd_hda_codec_write(codec, 0x21, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + msleep(80); + snd_hda_codec_write(codec, 0x21, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); + alc_process_coef_fw(codec, alc225_pre_hsmode); alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000); val = alc_read_coef_idx(codec, 0x45); @@ -4588,6 +4706,12 @@ static void alc_determine_headset_type(struct hda_codec *codec) alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6); alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4); alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000); + + snd_hda_codec_write(codec, 0x21, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + msleep(80); + snd_hda_codec_write(codec, 0x21, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); break; case 0x10ec0867: is_ctia = true; @@ -6920,16 +7044,17 @@ static int patch_alc269(struct hda_codec *codec) case 0x10ec0285: case 0x10ec0289: spec->codec_variant = ALC269_TYPE_ALC215; + spec->shutup = alc225_shutup; + spec->init_hook = alc225_init; spec->gen.mixer_nid = 0; break; case 0x10ec0225: case 0x10ec0295: - spec->codec_variant = ALC269_TYPE_ALC225; - spec->gen.mixer_nid = 0; /* no loopback on ALC225 ALC295 */ - break; case 0x10ec0299: spec->codec_variant = ALC269_TYPE_ALC225; - spec->gen.mixer_nid = 0; /* no loopback on ALC299 */ + spec->shutup = alc225_shutup; + spec->init_hook = alc225_init; + spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */ break; case 0x10ec0234: case 0x10ec0274: diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c index 2697402b5195..8dabd4d0211d 100644 --- a/sound/pci/ice1712/prodigy_hifi.c +++ b/sound/pci/ice1712/prodigy_hifi.c @@ -965,13 +965,32 @@ static int prodigy_hd2_add_controls(struct snd_ice1712 *ice) return 0; } +static void wm8766_init(struct snd_ice1712 *ice) +{ + static unsigned short wm8766_inits[] = { + WM8766_RESET, 0x0000, + WM8766_DAC_CTRL, 0x0120, + WM8766_INT_CTRL, 0x0022, /* I2S Normal Mode, 24 bit */ + WM8766_DAC_CTRL2, 0x0001, + WM8766_DAC_CTRL3, 0x0080, + WM8766_LDA1, 0x0100, + WM8766_LDA2, 0x0100, + WM8766_LDA3, 0x0100, + WM8766_RDA1, 0x0100, + WM8766_RDA2, 0x0100, + WM8766_RDA3, 0x0100, + WM8766_MUTE1, 0x0000, + WM8766_MUTE2, 0x0000, + }; + unsigned int i; -/* - * initialize the chip - */ -static int prodigy_hifi_init(struct snd_ice1712 *ice) + for (i = 0; i < ARRAY_SIZE(wm8766_inits); i += 2) + wm8766_spi_write(ice, wm8766_inits[i], wm8766_inits[i + 1]); +} + +static void wm8776_init(struct snd_ice1712 *ice) { - static unsigned short wm_inits[] = { + static unsigned short wm8776_inits[] = { /* These come first to reduce init pop noise */ WM_ADC_MUX, 0x0003, /* ADC mute */ /* 0x00c0 replaced by 0x0003 */ @@ -982,7 +1001,76 @@ static int prodigy_hifi_init(struct snd_ice1712 *ice) WM_POWERDOWN, 0x0008, /* All power-up except HP */ WM_RESET, 0x0000, /* reset */ }; - static unsigned short wm_inits2[] = { + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(wm8776_inits); i += 2) + wm_put(ice, wm8776_inits[i], wm8776_inits[i + 1]); +} + +#ifdef CONFIG_PM_SLEEP +static int prodigy_hifi_resume(struct snd_ice1712 *ice) +{ + static unsigned short wm8776_reinit_registers[] = { + WM_MASTER_CTRL, + WM_DAC_INT, + WM_ADC_INT, + WM_OUT_MUX, + WM_HP_ATTEN_L, + WM_HP_ATTEN_R, + WM_PHASE_SWAP, + WM_DAC_CTRL2, + WM_ADC_ATTEN_L, + WM_ADC_ATTEN_R, + WM_ALC_CTRL1, + WM_ALC_CTRL2, + WM_ALC_CTRL3, + WM_NOISE_GATE, + WM_ADC_MUX, + /* no DAC attenuation here */ + }; + struct prodigy_hifi_spec *spec = ice->spec; + int i, ch; + + mutex_lock(&ice->gpio_mutex); + + /* reinitialize WM8776 and re-apply old register values */ + wm8776_init(ice); + schedule_timeout_uninterruptible(1); + for (i = 0; i < ARRAY_SIZE(wm8776_reinit_registers); i++) + wm_put(ice, wm8776_reinit_registers[i], + wm_get(ice, wm8776_reinit_registers[i])); + + /* reinitialize WM8766 and re-apply volumes for all DACs */ + wm8766_init(ice); + for (ch = 0; ch < 2; ch++) { + wm_set_vol(ice, WM_DAC_ATTEN_L + ch, + spec->vol[2 + ch], spec->master[ch]); + + wm8766_set_vol(ice, WM8766_LDA1 + ch, + spec->vol[0 + ch], spec->master[ch]); + + wm8766_set_vol(ice, WM8766_LDA2 + ch, + spec->vol[4 + ch], spec->master[ch]); + + wm8766_set_vol(ice, WM8766_LDA3 + ch, + spec->vol[6 + ch], spec->master[ch]); + } + + /* unmute WM8776 DAC */ + wm_put(ice, WM_DAC_MUTE, 0x00); + wm_put(ice, WM_DAC_CTRL1, 0x90); + + mutex_unlock(&ice->gpio_mutex); + return 0; +} +#endif + +/* + * initialize the chip + */ +static int prodigy_hifi_init(struct snd_ice1712 *ice) +{ + static unsigned short wm8776_defaults[] = { WM_MASTER_CTRL, 0x0022, /* 256fs, slave mode */ WM_DAC_INT, 0x0022, /* I2S, normal polarity, 24bit */ WM_ADC_INT, 0x0022, /* I2S, normal polarity, 24bit */ @@ -1010,22 +1098,6 @@ static int prodigy_hifi_init(struct snd_ice1712 *ice) WM_DAC_MUTE, 0x0000, /* DAC unmute */ WM_ADC_MUX, 0x0003, /* ADC unmute, both CD/Line On */ }; - static unsigned short wm8766_inits[] = { - WM8766_RESET, 0x0000, - WM8766_DAC_CTRL, 0x0120, - WM8766_INT_CTRL, 0x0022, /* I2S Normal Mode, 24 bit */ - WM8766_DAC_CTRL2, 0x0001, - WM8766_DAC_CTRL3, 0x0080, - WM8766_LDA1, 0x0100, - WM8766_LDA2, 0x0100, - WM8766_LDA3, 0x0100, - WM8766_RDA1, 0x0100, - WM8766_RDA2, 0x0100, - WM8766_RDA3, 0x0100, - WM8766_MUTE1, 0x0000, - WM8766_MUTE2, 0x0000, - }; - struct prodigy_hifi_spec *spec; unsigned int i; @@ -1052,16 +1124,17 @@ static int prodigy_hifi_init(struct snd_ice1712 *ice) ice->spec = spec; /* initialize WM8776 codec */ - for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2) - wm_put(ice, wm_inits[i], wm_inits[i+1]); + wm8776_init(ice); schedule_timeout_uninterruptible(1); - for (i = 0; i < ARRAY_SIZE(wm_inits2); i += 2) - wm_put(ice, wm_inits2[i], wm_inits2[i+1]); + for (i = 0; i < ARRAY_SIZE(wm8776_defaults); i += 2) + wm_put(ice, wm8776_defaults[i], wm8776_defaults[i + 1]); - /* initialize WM8766 codec */ - for (i = 0; i < ARRAY_SIZE(wm8766_inits); i += 2) - wm8766_spi_write(ice, wm8766_inits[i], wm8766_inits[i+1]); + wm8766_init(ice); +#ifdef CONFIG_PM_SLEEP + ice->pm_resume = &prodigy_hifi_resume; + ice->pm_suspend_enabled = 1; +#endif return 0; } diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index c7b007164c99..4206ba44d8bb 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2348,7 +2348,6 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev); if (err < 0) { - release_firmware(dsp_code); snd_printk(KERN_ERR "firmware not available\n"); snd_korg1212_free(korg1212); return err; diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index c33a512283a4..78d7b6238376 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -23,6 +23,8 @@ #include <drm/amd_asic_type.h> #include "acp.h" +#define DRV_NAME "acp_audio_dma" + #define PLAYBACK_MIN_NUM_PERIODS 2 #define PLAYBACK_MAX_NUM_PERIODS 2 #define PLAYBACK_MAX_PERIOD_SIZE 16384 @@ -702,8 +704,8 @@ static int acp_dma_open(struct snd_pcm_substream *substream) int ret = 0; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *intr_data = dev_get_drvdata(prtd->platform->dev); - + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *intr_data = dev_get_drvdata(component->dev); struct audio_substream_data *adata = kzalloc(sizeof(struct audio_substream_data), GFP_KERNEL); if (adata == NULL) @@ -730,7 +732,7 @@ static int acp_dma_open(struct snd_pcm_substream *substream) ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) { - dev_err(prtd->platform->dev, "set integer constraint failed\n"); + dev_err(component->dev, "set integer constraint failed\n"); kfree(adata); return ret; } @@ -778,7 +780,8 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime; struct audio_substream_data *rtd; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *adata = dev_get_drvdata(prtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); runtime = substream->runtime; rtd = runtime->private_data; @@ -907,6 +910,7 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *prtd = substream->private_data; struct audio_substream_data *rtd = runtime->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); if (!rtd) return -EINVAL; @@ -924,7 +928,7 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & BIT(SYSRAM_TO_ACP_CH_NUM)) { if (!loops--) { - dev_err(prtd->platform->dev, + dev_err(component->dev, "acp dma start timeout\n"); return -ETIMEDOUT; } @@ -970,7 +974,8 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) { int ret; - struct audio_drv_data *adata = dev_get_drvdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); switch (adata->asic_type) { case CHIP_STONEY: @@ -987,7 +992,7 @@ static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) break; } if (ret < 0) - dev_err(rtd->platform->dev, + dev_err(component->dev, "buffer preallocation failer error:%d\n", ret); return ret; } @@ -998,7 +1003,8 @@ static int acp_dma_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *adata = dev_get_drvdata(prtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); kfree(rtd); @@ -1044,7 +1050,8 @@ static const struct snd_pcm_ops acp_dma_ops = { .prepare = acp_dma_prepare, }; -static struct snd_soc_platform_driver acp_asoc_platform = { +static struct snd_soc_component_driver acp_asoc_platform = { + .name = DRV_NAME, .ops = &acp_dma_ops, .pcm_new = acp_dma_new, }; @@ -1102,7 +1109,8 @@ static int acp_audio_probe(struct platform_device *pdev) return status; } - status = snd_soc_register_platform(&pdev->dev, &acp_asoc_platform); + status = devm_snd_soc_register_component(&pdev->dev, + &acp_asoc_platform, NULL, 0); if (status != 0) { dev_err(&pdev->dev, "Fail to register ALSA platform device\n"); return status; @@ -1123,7 +1131,6 @@ static int acp_audio_remove(struct platform_device *pdev) status = acp_deinit(adata->acp_mmio); if (status) dev_err(&pdev->dev, "ACP Deinit failed status:%d\n", status); - snd_soc_unregister_platform(&pdev->dev); pm_runtime_disable(&pdev->dev); return 0; diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index ebabed69f0e6..6bc2b729495c 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -32,6 +32,7 @@ struct atmel_classd { struct regmap *regmap; struct clk *pclk; struct clk *gclk; + struct device *dev; int irq; const struct atmel_classd_pdata *pdata; }; @@ -165,7 +166,7 @@ atmel_classd_platform_configure_dma(struct snd_pcm_substream *substream, struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); if (params_physical_width(params) != 16) { - dev_err(rtd->platform->dev, + dev_err(dd->dev, "only supports 16-bit audio data\n"); return -EINVAL; } @@ -587,6 +588,7 @@ static int atmel_classd_probe(struct platform_device *pdev) } dd->phy_base = res->start; + dd->dev = dev; dd->regmap = devm_regmap_init_mmio(dev, io_base, &atmel_classd_regmap_config); diff --git a/sound/soc/atmel/atmel-pcm-pdc.c b/sound/soc/atmel/atmel-pcm-pdc.c index 91b7069c3499..99ca23d527c9 100644 --- a/sound/soc/atmel/atmel-pcm-pdc.c +++ b/sound/soc/atmel/atmel-pcm-pdc.c @@ -393,7 +393,7 @@ static const struct snd_pcm_ops atmel_pcm_ops = { .mmap = atmel_pcm_mmap, }; -static struct snd_soc_platform_driver atmel_soc_platform = { +static struct snd_soc_component_driver atmel_soc_platform = { .ops = &atmel_pcm_ops, .pcm_new = atmel_pcm_new, .pcm_free = atmel_pcm_free, @@ -401,13 +401,13 @@ static struct snd_soc_platform_driver atmel_soc_platform = { int atmel_pcm_pdc_platform_register(struct device *dev) { - return snd_soc_register_platform(dev, &atmel_soc_platform); + return devm_snd_soc_register_component(dev, &atmel_soc_platform, + NULL, 0); } EXPORT_SYMBOL(atmel_pcm_pdc_platform_register); void atmel_pcm_pdc_platform_unregister(struct device *dev) { - snd_soc_unregister_platform(dev); } EXPORT_SYMBOL(atmel_pcm_pdc_platform_unregister); diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 8e3d34be9e69..4eea738c1047 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -32,6 +32,7 @@ struct atmel_pdmic { struct regmap *regmap; struct clk *pclk; struct clk *gclk; + struct device *dev; int irq; struct snd_pcm_substream *substream; const struct atmel_pdmic_pdata *pdata; @@ -206,7 +207,7 @@ atmel_pdmic_platform_configure_dma(struct snd_pcm_substream *substream, ret = snd_hwparams_to_dma_slave_config(substream, params, slave_config); if (ret) { - dev_err(rtd->platform->dev, + dev_err(dd->dev, "hw params to dma slave configure failed\n"); return ret; } @@ -596,6 +597,7 @@ static int atmel_pdmic_probe(struct platform_device *pdev) return -ENOMEM; dd->pdata = pdata; + dd->dev = dev; dd->irq = platform_get_irq(pdev, 0); if (dd->irq < 0) { diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 6a035ca0f521..fb650659c3a3 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -32,6 +32,8 @@ /*#define PCM_DEBUG*/ +#define DRV_NAME "dbdma2" + #define MSG(x...) printk(KERN_INFO "au1xpsc_pcm: " x) #ifdef PCM_DEBUG #define DBG MSG @@ -187,8 +189,8 @@ out: static inline struct au1xpsc_audio_dmadata *to_dmadata(struct snd_pcm_substream *ss) { struct snd_soc_pcm_runtime *rtd = ss->private_data; - struct au1xpsc_audio_dmadata *pcd = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct au1xpsc_audio_dmadata *pcd = snd_soc_component_get_drvdata(component); return &pcd[ss->stream]; } @@ -327,7 +329,8 @@ static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd) } /* au1xpsc audio platform */ -static struct snd_soc_platform_driver au1xpsc_soc_platform = { +static struct snd_soc_component_driver au1xpsc_soc_component = { + .name = DRV_NAME, .ops = &au1xpsc_pcm_ops, .pcm_new = au1xpsc_pcm_new, }; @@ -344,8 +347,8 @@ static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) platform_set_drvdata(pdev, dmadata); - return devm_snd_soc_register_platform(&pdev->dev, - &au1xpsc_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &au1xpsc_soc_component, NULL, 0); } static struct platform_driver au1xpsc_pcm_driver = { diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c index 19457e2b351e..efff1e293a1b 100644 --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c @@ -21,6 +21,8 @@ #include "psc.h" +#define DRV_NAME "au1x_dma" + struct pcm_period { u32 start; u32 relative_end; /* relative to start of buffer */ @@ -174,7 +176,8 @@ static const struct snd_pcm_hardware alchemy_pcm_hardware = { static inline struct alchemy_pcm_ctx *ss_to_ctx(struct snd_pcm_substream *ss) { struct snd_soc_pcm_runtime *rtd = ss->private_data; - return snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + return snd_soc_component_get_drvdata(component); } static inline struct audio_stream *ss_to_as(struct snd_pcm_substream *ss) @@ -297,7 +300,8 @@ static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_platform_driver alchemy_pcm_soc_platform = { +static struct snd_soc_component_driver alchemy_pcm_soc_component = { + .name = DRV_NAME, .ops = &alchemy_pcm_ops, .pcm_new = alchemy_pcm_new, }; @@ -312,8 +316,8 @@ static int alchemy_pcm_drvprobe(struct platform_device *pdev) platform_set_drvdata(pdev, ctx); - return devm_snd_soc_register_platform(&pdev->dev, - &alchemy_pcm_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &alchemy_pcm_soc_component, NULL, 0); } static struct platform_driver alchemy_pcmdma_driver = { diff --git a/sound/soc/bcm/cygnus-pcm.c b/sound/soc/bcm/cygnus-pcm.c index d616e096462e..123ecf5479d7 100644 --- a/sound/soc/bcm/cygnus-pcm.c +++ b/sound/soc/bcm/cygnus-pcm.c @@ -820,7 +820,7 @@ static int cygnus_dma_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_platform_driver cygnus_soc_platform = { +static struct snd_soc_component_driver cygnus_soc_platform = { .ops = &cygnus_pcm_ops, .pcm_new = cygnus_dma_new, .pcm_free = cygnus_dma_free_dma_buffers, @@ -840,7 +840,8 @@ int cygnus_soc_platform_register(struct device *dev, return rc; } - rc = snd_soc_register_platform(dev, &cygnus_soc_platform); + rc = devm_snd_soc_register_component(dev, &cygnus_soc_platform, + NULL, 0); if (rc) { dev_err(dev, "%s failed\n", __func__); return rc; @@ -851,8 +852,6 @@ int cygnus_soc_platform_register(struct device *dev, int cygnus_soc_platform_unregister(struct device *dev) { - snd_soc_unregister_platform(dev); - return 0; } diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c index 8c1d1983b8f9..08bceb519c29 100644 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c @@ -453,7 +453,7 @@ static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd) return ret; } -static struct snd_soc_platform_driver bf5xx_ac97_soc_platform = { +static struct snd_soc_component_driver bf5xx_ac97_soc_component = { .ops = &bf5xx_pcm_ac97_ops, .pcm_new = bf5xx_pcm_ac97_new, .pcm_free = bf5xx_pcm_free_dma_buffers, @@ -461,8 +461,8 @@ static struct snd_soc_platform_driver bf5xx_ac97_soc_platform = { static int bf5xx_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &bf5xx_ac97_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &bf5xx_ac97_soc_component, NULL, 0); } static struct platform_driver bf5xx_pcm_driver = { diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index 51cae76f14e6..6712b01dabd1 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c @@ -347,15 +347,15 @@ static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd) SNDRV_DMA_TYPE_DEV, card->dev, size, size); } -static struct snd_soc_platform_driver bf5xx_i2s_soc_platform = { +static struct snd_soc_component_driver bf5xx_i2s_soc_component = { .ops = &bf5xx_pcm_i2s_ops, .pcm_new = bf5xx_pcm_i2s_new, }; static int bfin_i2s_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &bf5xx_i2s_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &bf5xx_i2s_soc_component, NULL, 0); } static struct platform_driver bfin_i2s_pcm_driver = { diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index be2750680838..3f34de5f800e 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -33,6 +33,8 @@ #include "wm_adsp.h" #include "cs47l24.h" +#define DRV_NAME "cs47l24-codec" + struct cs47l24_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -1069,7 +1071,8 @@ static struct snd_soc_dai_driver cs47l24_dai[] = { static int cs47l24_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct cs47l24_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int n_adsp; @@ -1177,6 +1180,16 @@ static unsigned int cs47l24_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_4L, }; +static struct snd_compr_ops cs47l24_compr_ops = { + .open = cs47l24_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { .probe = cs47l24_codec_probe, .remove = cs47l24_codec_remove, @@ -1187,6 +1200,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { .set_pll = cs47l24_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &cs47l24_compr_ops, .controls = cs47l24_snd_controls, .num_controls = ARRAY_SIZE(cs47l24_snd_controls), .dapm_widgets = cs47l24_dapm_widgets, @@ -1196,20 +1211,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { }, }; -static const struct snd_compr_ops cs47l24_compr_ops = { - .open = cs47l24_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver cs47l24_compr_platform = { - .compr_ops = &cs47l24_compr_ops, -}; - static int cs47l24_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -1298,23 +1299,15 @@ static int cs47l24_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &cs47l24_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cs47l24, cs47l24_dai, ARRAY_SIZE(cs47l24_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -1328,7 +1321,6 @@ static int cs47l24_remove(struct platform_device *pdev) struct cs47l24_priv *cs47l24 = platform_get_drvdata(pdev); struct arizona *arizona = cs47l24->core.arizona; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 2144edca97b0..84184d90385b 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -35,6 +35,8 @@ #include "rt5514-spi.h" +#define DRV_NAME "rt5514-spi" + static struct spi_device *rt5514_spi; struct rt5514_dsp { @@ -211,8 +213,9 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); int ret; u8 buf[8]; @@ -235,8 +238,9 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, static int rt5514_spi_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); mutex_lock(&rt5514_dsp->dma_lock); rt5514_dsp->substream = NULL; @@ -252,8 +256,9 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer( { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); return bytes_to_frames(runtime, rt5514_dsp->dma_offset); } @@ -267,18 +272,18 @@ static const struct snd_pcm_ops rt5514_spi_pcm_ops = { .page = snd_pcm_lib_get_vmalloc_page, }; -static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) +static int rt5514_spi_pcm_probe(struct snd_soc_component *component) { struct rt5514_dsp *rt5514_dsp; int ret; - rt5514_dsp = devm_kzalloc(platform->dev, sizeof(*rt5514_dsp), + rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp), GFP_KERNEL); rt5514_dsp->dev = &rt5514_spi->dev; mutex_init(&rt5514_dsp->dma_lock); INIT_DELAYED_WORK(&rt5514_dsp->copy_work, rt5514_spi_copy_work); - snd_soc_platform_set_drvdata(platform, rt5514_dsp); + snd_soc_component_set_drvdata(component, rt5514_dsp); if (rt5514_spi->irq) { ret = devm_request_threaded_irq(&rt5514_spi->dev, @@ -296,15 +301,12 @@ static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) return 0; } -static const struct snd_soc_platform_driver rt5514_spi_platform = { +static const struct snd_soc_component_driver rt5514_spi_component = { + .name = DRV_NAME, .probe = rt5514_spi_pcm_probe, .ops = &rt5514_spi_pcm_ops, }; -static const struct snd_soc_component_driver rt5514_spi_dai_component = { - .name = "rt5514-spi-dai", -}; - /** * rt5514_spi_burst_read - Read data from SPI by rt5514 address. * @addr: Start address. @@ -445,14 +447,8 @@ static int rt5514_spi_probe(struct spi_device *spi) rt5514_spi = spi; - ret = devm_snd_soc_register_platform(&spi->dev, &rt5514_spi_platform); - if (ret < 0) { - dev_err(&spi->dev, "Failed to register platform.\n"); - return ret; - } - ret = devm_snd_soc_register_component(&spi->dev, - &rt5514_spi_dai_component, + &rt5514_spi_component, &rt5514_spi_dai, 1); if (ret < 0) { dev_err(&spi->dev, "Failed to register component.\n"); diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index fc066caa1918..a568050090ad 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -34,6 +34,8 @@ #include "wm5102.h" #include "wm_adsp.h" +#define DRV_NAME "wm5102-codec" + struct wm5102_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -1910,7 +1912,8 @@ static struct snd_soc_dai_driver wm5102_dai[] = { static int wm5102_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct wm5102_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct wm5102_priv *priv = snd_soc_component_get_drvdata(component); return wm_adsp_compr_open(&priv->core.adsp[0], stream); } @@ -1992,6 +1995,16 @@ static unsigned int wm5102_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; +static struct snd_compr_ops wm5102_compr_ops = { + .open = wm5102_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { .probe = wm5102_codec_probe, .remove = wm5102_codec_remove, @@ -2002,6 +2015,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { .set_pll = wm5102_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &wm5102_compr_ops, .controls = wm5102_snd_controls, .num_controls = ARRAY_SIZE(wm5102_snd_controls), .dapm_widgets = wm5102_dapm_widgets, @@ -2011,20 +2026,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { }, }; -static const struct snd_compr_ops wm5102_compr_ops = { - .open = wm5102_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver wm5102_compr_platform = { - .compr_ops = &wm5102_compr_ops, -}; - static int wm5102_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -2109,23 +2110,15 @@ static int wm5102_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &wm5102_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102, wm5102_dai, ARRAY_SIZE(wm5102_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -2139,7 +2132,6 @@ static int wm5102_remove(struct platform_device *pdev) struct wm5102_priv *wm5102 = platform_get_drvdata(pdev); struct arizona *arizona = wm5102->core.arizona; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index fb0cf9c61f48..d5ece6c6fcb6 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -35,6 +35,8 @@ #define WM5110_NUM_ADSP 4 +#define DRV_NAME "wm5110-codec" + struct wm5110_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -2229,7 +2231,8 @@ static struct snd_soc_dai_driver wm5110_dai[] = { static int wm5110_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct wm5110_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct wm5110_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int n_adsp; @@ -2346,6 +2349,16 @@ static unsigned int wm5110_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_6R, }; +static struct snd_compr_ops wm5110_compr_ops = { + .open = wm5110_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { .probe = wm5110_codec_probe, .remove = wm5110_codec_remove, @@ -2356,6 +2369,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { .set_pll = wm5110_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &wm5110_compr_ops, .controls = wm5110_snd_controls, .num_controls = ARRAY_SIZE(wm5110_snd_controls), .dapm_widgets = wm5110_dapm_widgets, @@ -2365,20 +2380,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { }, }; -static const struct snd_compr_ops wm5110_compr_ops = { - .open = wm5110_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver wm5110_compr_platform = { - .compr_ops = &wm5110_compr_ops, -}; - static int wm5110_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -2464,23 +2465,15 @@ static int wm5110_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &wm5110_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5110, wm5110_dai, ARRAY_SIZE(wm5110_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -2495,7 +2488,6 @@ static int wm5110_remove(struct platform_device *pdev) struct arizona *arizona = wm5110->core.arizona; int i; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 384961651904..807040bb3921 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -34,6 +34,7 @@ #include "edma-pcm.h" #include "davinci-i2s.h" +#define DRV_NAME "davinci-i2s" /* * NOTE: terminology here is confusing. @@ -190,7 +191,7 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); u32 spcr; u32 mask = playback ? DAVINCI_MCBSP_SPCR_XRST : DAVINCI_MCBSP_SPCR_RRST; @@ -211,8 +212,8 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, if (playback) { /* Stop the DMA to avoid data loss */ /* while the transmitter is out of reset to handle XSYNCERR */ - if (platform->driver->ops->trigger) { - int ret = platform->driver->ops->trigger(substream, + if (component->driver->ops->trigger) { + int ret = component->driver->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); if (ret < 0) printk(KERN_DEBUG "Playback DMA stop failed\n"); @@ -233,8 +234,8 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, toggle_clock(dev, playback); /* Restart the DMA */ - if (platform->driver->ops->trigger) { - int ret = platform->driver->ops->trigger(substream, + if (component->driver->ops->trigger) { + int ret = component->driver->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); if (ret < 0) printk(KERN_DEBUG "Playback DMA start failed\n"); @@ -651,7 +652,7 @@ static struct snd_soc_dai_driver davinci_i2s_dai = { }; static const struct snd_soc_component_driver davinci_i2s_component = { - .name = "davinci-i2s", + .name = DRV_NAME, }; static int davinci_i2s_probe(struct platform_device *pdev) diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c index 406fd867117b..2cc9632024fc 100644 --- a/sound/soc/dwc/dwc-pcm.c +++ b/sound/soc/dwc/dwc-pcm.c @@ -269,7 +269,7 @@ static const struct snd_pcm_ops dw_pcm_ops = { .pointer = dw_pcm_pointer, }; -static const struct snd_soc_platform_driver dw_pcm_platform = { +static const struct snd_soc_component_driver dw_pcm_component = { .pcm_new = dw_pcm_new, .pcm_free = dw_pcm_free, .ops = &dw_pcm_ops, @@ -277,5 +277,6 @@ static const struct snd_soc_platform_driver dw_pcm_platform = { int dw_pcm_register(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &dw_pcm_platform); + return devm_snd_soc_register_component(&pdev->dev, &dw_pcm_component, + NULL, 0); } diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 806d39927318..adfb8135d739 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -582,10 +582,6 @@ static struct snd_soc_dai_driver fsl_asrc_dai = { .ops = &fsl_asrc_dai_ops, }; -static const struct snd_soc_component_driver fsl_asrc_component = { - .name = "fsl-asrc-dai", -}; - static bool fsl_asrc_readable_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -927,12 +923,6 @@ static int fsl_asrc_probe(struct platform_device *pdev) return ret; } - ret = devm_snd_soc_register_platform(&pdev->dev, &fsl_asrc_platform); - if (ret) { - dev_err(&pdev->dev, "failed to register ASoC platform\n"); - return ret; - } - return 0; } diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h index 2c5856ac5bc3..d558dd5499a5 100644 --- a/sound/soc/fsl/fsl_asrc.h +++ b/sound/soc/fsl/fsl_asrc.h @@ -462,6 +462,7 @@ struct fsl_asrc { u32 regcache_cfg; }; -extern struct snd_soc_platform_driver fsl_asrc_platform; +#define DRV_NAME "fsl-asrc-dai" +extern struct snd_soc_component_driver fsl_asrc_component; struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir); #endif /* _FSL_ASRC_H */ diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index e1b97e59275a..565e16d8fe85 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -64,7 +64,8 @@ static int fsl_asrc_dma_prepare_and_submit(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_asrc_pair *pair = runtime->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; unsigned long flags = DMA_CTRL_ACK; /* Prepare and submit Front-End DMA channel */ @@ -137,12 +138,13 @@ static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream, bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct snd_dmaengine_dai_dma_data *dma_params_fe = NULL; struct snd_dmaengine_dai_dma_data *dma_params_be = NULL; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_asrc_pair *pair = runtime->private_data; struct fsl_asrc *asrc_priv = pair->asrc_priv; struct dma_slave_config config_fe, config_be; enum asrc_pair_index index = pair->index; - struct device *dev = rtd->platform->dev; + struct device *dev = component->dev; int stream = substream->stream; struct imx_dma_data *tmp_data; struct snd_soc_dpcm *dpcm; @@ -274,7 +276,8 @@ static int fsl_asrc_dma_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); struct fsl_asrc_pair *pair; @@ -381,9 +384,10 @@ static void fsl_asrc_dma_pcm_free(struct snd_pcm *pcm) } } -struct snd_soc_platform_driver fsl_asrc_platform = { +struct snd_soc_component_driver fsl_asrc_component = { + .name = DRV_NAME, .ops = &fsl_asrc_dma_pcm_ops, .pcm_new = fsl_asrc_dma_pcm_new, .pcm_free = fsl_asrc_dma_pcm_free, }; -EXPORT_SYMBOL_GPL(fsl_asrc_platform); +EXPORT_SYMBOL_GPL(fsl_asrc_component); diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index 8c2981b70f64..fce2010d3c53 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -37,6 +37,8 @@ #include "fsl_dma.h" #include "fsl_ssi.h" /* For the offset of stx0 and srx0 */ +#define DRV_NAME "fsl_dma" + /* * The formats that the DMA controller supports, which is anything * that is 8, 16, or 32 bits. @@ -56,7 +58,7 @@ SNDRV_PCM_FMTBIT_U32_LE | \ SNDRV_PCM_FMTBIT_U32_BE) struct dma_object { - struct snd_soc_platform_driver dai; + struct snd_soc_component_driver dai; dma_addr_t ssi_stx_phys; dma_addr_t ssi_srx_phys; unsigned int ssi_fifo_depth; @@ -203,7 +205,8 @@ static irqreturn_t fsl_dma_isr(int irq, void *dev_id) struct fsl_dma_private *dma_private = dev_id; struct snd_pcm_substream *substream = dma_private->substream; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; irqreturn_t ret = IRQ_NONE; u32 sr, sr2 = 0; @@ -385,9 +388,10 @@ static int fsl_dma_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct dma_object *dma = - container_of(rtd->platform->driver, struct dma_object, dai); + container_of(component->driver, struct dma_object, dai); struct fsl_dma_private *dma_private; struct ccsr_dma_channel __iomem *dma_channel; dma_addr_t ld_buf_phys; @@ -539,7 +543,8 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; /* Number of bits per sample */ unsigned int sample_bits = @@ -702,7 +707,8 @@ static snd_pcm_uframes_t fsl_dma_pointer(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; dma_addr_t position; snd_pcm_uframes_t frames; @@ -799,9 +805,10 @@ static int fsl_dma_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct dma_object *dma = - container_of(rtd->platform->driver, struct dma_object, dai); + container_of(component->driver, struct dma_object, dai); if (dma_private) { if (dma_private->irq) @@ -908,6 +915,7 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) return -ENOMEM; } + dma->dai.name = DRV_NAME; dma->dai.ops = &fsl_dma_ops; dma->dai.pcm_new = fsl_dma_new; dma->dai.pcm_free = fsl_dma_free_dma_buffers; @@ -925,7 +933,7 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) of_node_put(ssi_np); - ret = snd_soc_register_platform(&pdev->dev, &dma->dai); + ret = devm_snd_soc_register_component(&pdev->dev, &dma->dai, NULL, 0); if (ret) { dev_err(&pdev->dev, "could not register platform\n"); kfree(dma); @@ -944,7 +952,6 @@ static int fsl_soc_dma_remove(struct platform_device *pdev) { struct dma_object *dma = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); iounmap(dma->channel); irq_dispose_mapping(dma->irq); kfree(dma); diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 4e5fefee111e..0578f3486847 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -341,7 +341,7 @@ static void imx_pcm_fiq_free(struct snd_pcm *pcm) imx_pcm_free(pcm); } -static const struct snd_soc_platform_driver imx_soc_platform_fiq = { +static const struct snd_soc_component_driver imx_soc_component_fiq = { .ops = &imx_pcm_ops, .pcm_new = imx_pcm_fiq_new, .pcm_free = imx_pcm_fiq_free, @@ -368,7 +368,8 @@ int imx_pcm_fiq_init(struct platform_device *pdev, params->dma_params_tx->maxburst = 4; params->dma_params_rx->maxburst = 6; - ret = snd_soc_register_platform(&pdev->dev, &imx_soc_platform_fiq); + ret = devm_snd_soc_register_component(&pdev->dev, &imx_soc_component_fiq, + NULL, 0); if (ret) goto failed_register; @@ -384,7 +385,6 @@ EXPORT_SYMBOL_GPL(imx_pcm_fiq_init); void imx_pcm_fiq_exit(struct platform_device *pdev) { - snd_soc_unregister_platform(&pdev->dev); } EXPORT_SYMBOL_GPL(imx_pcm_fiq_exit); diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index e63029f1aabc..c1a4544eb16b 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -22,6 +22,8 @@ #include "mpc5200_dma.h" +#define DRV_NAME "mpc5200_dma" + /* * Interrupt handlers */ @@ -300,12 +302,13 @@ static const struct snd_pcm_ops psc_dma_ops = { static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_soc_dai *dai = rtd->cpu_dai; struct snd_pcm *pcm = rtd->pcm; size_t size = psc_dma_hardware.buffer_bytes_max; int rc; - dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", + dev_dbg(component->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", card, dai, pcm); rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); @@ -341,10 +344,11 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) static void psc_dma_free(struct snd_pcm *pcm) { struct snd_soc_pcm_runtime *rtd = pcm->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_pcm_substream *substream; int stream; - dev_dbg(rtd->platform->dev, "psc_dma_free(pcm=%p)\n", pcm); + dev_dbg(component->dev, "psc_dma_free(pcm=%p)\n", pcm); for (stream = 0; stream < 2; stream++) { substream = pcm->streams[stream].substream; @@ -356,7 +360,8 @@ static void psc_dma_free(struct snd_pcm *pcm) } } -static const struct snd_soc_platform_driver mpc5200_audio_dma_platform = { +static const struct snd_soc_component_driver mpc5200_audio_dma_component = { + .name = DRV_NAME, .ops = &psc_dma_ops, .pcm_new = &psc_dma_new, .pcm_free = &psc_dma_free, @@ -468,7 +473,8 @@ int mpc5200_audio_dma_create(struct platform_device *op) dev_set_drvdata(&op->dev, psc_dma); /* Tell the ASoC OF helpers about it */ - return snd_soc_register_platform(&op->dev, &mpc5200_audio_dma_platform); + return devm_snd_soc_register_component(&op->dev, + &mpc5200_audio_dma_component, NULL, 0); out_irq: free_irq(psc_dma->irq, psc_dma); free_irq(psc_dma->capture.irq, &psc_dma->capture); @@ -487,8 +493,6 @@ int mpc5200_audio_dma_destroy(struct platform_device *op) dev_dbg(&op->dev, "mpc5200_audio_dma_destroy()\n"); - snd_soc_unregister_platform(&op->dev); - bcom_gen_bd_rx_release(psc_dma->capture.bcom_task); bcom_gen_bd_tx_release(psc_dma->playback.bcom_task); diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c index 0f3604b55942..3672d36b4b66 100644 --- a/sound/soc/intel/atom/sst-atom-controls.c +++ b/sound/soc/intel/atom/sst-atom-controls.c @@ -1414,11 +1414,11 @@ static int sst_fill_module_list(struct snd_kcontrol *kctl, * name. First part of control name contains the pipe name (widget name). */ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, - struct snd_soc_platform *platform) + struct snd_soc_component *component) { struct snd_kcontrol *kctl; int index, ret = 0; - struct snd_card *card = platform->component.card->snd_card; + struct snd_card *card = component->card->snd_card; char *idx; down_read(&card->controls_rwsem); @@ -1468,13 +1468,13 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, /** * sst_fill_linked_widgets - fill the parent pointer for the linked widget */ -static void sst_fill_linked_widgets(struct snd_soc_platform *platform, +static void sst_fill_linked_widgets(struct snd_soc_component *component, struct sst_ids *ids) { struct snd_soc_dapm_widget *w; unsigned int len = strlen(ids->parent_wname); - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (!strncmp(ids->parent_wname, w->name, len)) { ids->parent_w = w; break; @@ -1485,41 +1485,41 @@ static void sst_fill_linked_widgets(struct snd_soc_platform *platform, /** * sst_map_modules_to_pipe - fill algo/gains list for all pipes */ -static int sst_map_modules_to_pipe(struct snd_soc_platform *platform) +static int sst_map_modules_to_pipe(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; int ret = 0; - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_sst_dapm_widget(w) && (w->priv)) { struct sst_ids *ids = w->priv; - dev_dbg(platform->dev, "widget type=%d name=%s\n", + dev_dbg(component->dev, "widget type=%d name=%s\n", w->id, w->name); INIT_LIST_HEAD(&ids->algo_list); INIT_LIST_HEAD(&ids->gain_list); - ret = sst_fill_widget_module_info(w, platform); + ret = sst_fill_widget_module_info(w, component); if (ret < 0) return ret; /* fill linked widgets */ if (ids->parent_wname != NULL) - sst_fill_linked_widgets(platform, ids); + sst_fill_linked_widgets(component, ids); } } return 0; } -int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component) { int i, ret = 0; struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(&platform->component); - struct sst_data *drv = snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_dapm(component); + struct sst_data *drv = snd_soc_component_get_drvdata(component); unsigned int gains = ARRAY_SIZE(sst_gain_controls)/3; - drv->byte_stream = devm_kzalloc(platform->dev, + drv->byte_stream = devm_kzalloc(component->dev, SST_MAX_BIN_BYTES, GFP_KERNEL); if (!drv->byte_stream) return -ENOMEM; @@ -1537,26 +1537,26 @@ int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) sst_gains[i].ramp_duration = SST_GAIN_RAMP_DURATION_DEFAULT; } - ret = snd_soc_add_platform_controls(platform, sst_gain_controls, + ret = snd_soc_add_component_controls(component, sst_gain_controls, ARRAY_SIZE(sst_gain_controls)); if (ret) return ret; /* Initialize algo control params */ - ret = sst_algo_control_init(platform->dev); + ret = sst_algo_control_init(component->dev); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_algo_controls, + ret = snd_soc_add_component_controls(component, sst_algo_controls, ARRAY_SIZE(sst_algo_controls)); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_slot_controls, + ret = snd_soc_add_component_controls(component, sst_slot_controls, ARRAY_SIZE(sst_slot_controls)); if (ret) return ret; - ret = sst_map_modules_to_pipe(platform); + ret = sst_map_modules_to_pipe(component); return ret; } diff --git a/sound/soc/intel/atom/sst-mfld-platform-compress.c b/sound/soc/intel/atom/sst-mfld-platform-compress.c index 1dbcab5a6ff0..6a44b19423cf 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-compress.c +++ b/sound/soc/intel/atom/sst-mfld-platform-compress.c @@ -107,8 +107,8 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, struct snd_sst_params str_params; struct sst_compress_cb cb; struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; - struct sst_data *ctx = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_data *ctx = snd_soc_component_get_drvdata(component); stream = cstream->runtime->private_data; /* construct fw structure for this*/ diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 43e7fdd19f29..6c36da560877 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -697,26 +697,22 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) return retval; } -static int sst_soc_probe(struct snd_soc_platform *platform) +static int sst_soc_probe(struct snd_soc_component *component) { - struct sst_data *drv = dev_get_drvdata(platform->dev); + struct sst_data *drv = dev_get_drvdata(component->dev); - drv->soc_card = platform->component.card; - return sst_dsp_init_v2_dpcm(platform); + drv->soc_card = component->card; + return sst_dsp_init_v2_dpcm(component); } -static const struct snd_soc_platform_driver sst_soc_platform_drv = { +static const struct snd_soc_component_driver sst_soc_platform_drv = { + .name = DRV_NAME, .probe = sst_soc_probe, .ops = &sst_platform_ops, .compr_ops = &sst_platform_compr_ops, .pcm_new = sst_pcm_new, }; -static const struct snd_soc_component_driver sst_component = { - .name = "sst", -}; - - static int sst_platform_probe(struct platform_device *pdev) { struct sst_data *drv; @@ -740,26 +736,16 @@ static int sst_platform_probe(struct platform_device *pdev) mutex_init(&drv->lock); dev_set_drvdata(&pdev->dev, drv); - ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv); - if (ret) { - dev_err(&pdev->dev, "registering soc platform failed\n"); - return ret; - } - - ret = snd_soc_register_component(&pdev->dev, &sst_component, + ret = devm_snd_soc_register_component(&pdev->dev, &sst_soc_platform_drv, sst_platform_dai, ARRAY_SIZE(sst_platform_dai)); - if (ret) { + if (ret) dev_err(&pdev->dev, "registering cpu dais failed\n"); - snd_soc_unregister_platform(&pdev->dev); - } + return ret; } static int sst_platform_remove(struct platform_device *pdev) { - - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); dev_dbg(&pdev->dev, "sst_platform_remove success\n"); return 0; } diff --git a/sound/soc/intel/atom/sst-mfld-platform.h b/sound/soc/intel/atom/sst-mfld-platform.h index 31a58c25472c..5f729df57bb5 100644 --- a/sound/soc/intel/atom/sst-mfld-platform.h +++ b/sound/soc/intel/atom/sst-mfld-platform.h @@ -27,6 +27,8 @@ extern struct sst_device *sst; extern const struct snd_compr_ops sst_platform_compr_ops; +#define DRV_NAME "sst" + #define SST_MONO 1 #define SST_STEREO 2 #define SST_MAX_CAP 5 @@ -155,7 +157,7 @@ struct sst_device { struct sst_data; -int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform); +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component); int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute); int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable); int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable); diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c index c54529320f07..aabb35bf6b96 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c @@ -23,6 +23,7 @@ #include "../common/sst-dsp-priv.h" #include "../common/sst-dsp.h" +#define DRV_NAME "byt-dai" #define BYT_PCM_COUNT 2 static const struct snd_pcm_hardware sst_byt_pcm_hardware = { @@ -69,8 +70,8 @@ static int sst_byt_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; u32 rate, bits; @@ -141,8 +142,8 @@ static int sst_byt_pcm_hw_free(struct snd_pcm_substream *substream) static int sst_byt_pcm_restore_stream_context(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; int ret; @@ -174,8 +175,8 @@ static void sst_byt_pcm_work(struct work_struct *work) static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; @@ -216,8 +217,8 @@ static u32 byt_notify_pointer(struct sst_byt_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt *byt = pdata->byt; u32 pos, hw_pos; @@ -238,8 +239,8 @@ static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; dev_dbg(rtd->dev, "PCM: DMA pointer %u bytes\n", pcm_data->hw_ptr); @@ -250,8 +251,8 @@ static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream static int sst_byt_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; @@ -278,8 +279,8 @@ static int sst_byt_pcm_open(struct snd_pcm_substream *substream) static int sst_byt_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; int ret; @@ -324,8 +325,8 @@ static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; size_t size; - struct snd_soc_platform *platform = rtd->platform; - struct sst_pdata *pdata = dev_get_platdata(platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); int ret = 0; if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || @@ -366,21 +367,21 @@ static struct snd_soc_dai_driver byt_dais[] = { }, }; -static int sst_byt_pcm_probe(struct snd_soc_platform *platform) +static int sst_byt_pcm_probe(struct snd_soc_component *component) { - struct sst_pdata *plat_data = dev_get_platdata(platform->dev); + struct sst_pdata *plat_data = dev_get_platdata(component->dev); struct sst_byt_priv_data *priv_data; int i; if (!plat_data) return -ENODEV; - priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), + priv_data = devm_kzalloc(component->dev, sizeof(*priv_data), GFP_KERNEL); if (!priv_data) return -ENOMEM; priv_data->byt = plat_data->dsp; - snd_soc_platform_set_drvdata(platform, priv_data); + snd_soc_component_set_drvdata(component, priv_data); for (i = 0; i < BYT_PCM_COUNT; i++) { mutex_init(&priv_data->pcm[i].mutex); @@ -390,22 +391,13 @@ static int sst_byt_pcm_probe(struct snd_soc_platform *platform) return 0; } -static int sst_byt_pcm_remove(struct snd_soc_platform *platform) -{ - return 0; -} - -static const struct snd_soc_platform_driver byt_soc_platform = { +static const struct snd_soc_component_driver byt_dai_component = { + .name = DRV_NAME, .probe = sst_byt_pcm_probe, - .remove = sst_byt_pcm_remove, .ops = &sst_byt_pcm_ops, .pcm_new = sst_byt_pcm_new, }; -static const struct snd_soc_component_driver byt_dai_component = { - .name = "byt-dai", -}; - #ifdef CONFIG_PM static int sst_byt_pcm_dev_suspend_late(struct device *dev) { @@ -461,19 +453,13 @@ static int sst_byt_pcm_dev_probe(struct platform_device *pdev) if (ret < 0) return -ENODEV; - ret = snd_soc_register_platform(&pdev->dev, &byt_soc_platform); - if (ret < 0) - goto err_plat; - - ret = snd_soc_register_component(&pdev->dev, &byt_dai_component, + ret = devm_snd_soc_register_component(&pdev->dev, &byt_dai_component, byt_dais, ARRAY_SIZE(byt_dais)); if (ret < 0) - goto err_comp; + goto err_plat; return 0; -err_comp: - snd_soc_unregister_platform(&pdev->dev); err_plat: sst_byt_dsp_free(&pdev->dev, sst_pdata); return ret; @@ -483,8 +469,6 @@ static int sst_byt_pcm_dev_remove(struct platform_device *pdev) { struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); sst_byt_dsp_free(&pdev->dev, sst_pdata); return 0; diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c index 058b8ccedf02..8999f8de119c 100644 --- a/sound/soc/intel/boards/bdw-rt5677.c +++ b/sound/soc/intel/boards/bdw-rt5677.c @@ -183,7 +183,8 @@ static const struct snd_soc_ops bdw_rt5677_ops = { static int bdw_rt5677_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c index 6dcbbcefc25b..249b8a3290b8 100644 --- a/sound/soc/intel/boards/broadwell.c +++ b/sound/soc/intel/boards/broadwell.c @@ -132,7 +132,8 @@ static const struct snd_soc_ops broadwell_rt286_ops = { static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; diff --git a/sound/soc/intel/boards/haswell.c b/sound/soc/intel/boards/haswell.c index 3c5160779204..eab1f439dd3f 100644 --- a/sound/soc/intel/boards/haswell.c +++ b/sound/soc/intel/boards/haswell.c @@ -87,7 +87,8 @@ static const struct snd_soc_ops haswell_rt5640_ops = { static int haswell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *haswell = pdata->dsp; int ret; diff --git a/sound/soc/intel/haswell/sst-haswell-ipc.h b/sound/soc/intel/haswell/sst-haswell-ipc.h index 06d71aefa1fe..fbc14df139e4 100644 --- a/sound/soc/intel/haswell/sst-haswell-ipc.h +++ b/sound/soc/intel/haswell/sst-haswell-ipc.h @@ -22,6 +22,8 @@ #include <linux/platform_device.h> #include <sound/asound.h> +#define DRV_NAME "haswell-dai" + #define SST_HSW_NO_CHANNELS 4 #define SST_HSW_MAX_DX_REGIONS 14 #define SST_HSW_DX_CONTEXT_SIZE (640 * 1024) diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c index c044400540ec..fe2c826e710c 100644 --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c @@ -181,11 +181,11 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value) static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -230,11 +230,11 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -273,8 +273,8 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, static int hsw_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -302,8 +302,8 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol, static int hsw_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; unsigned int volume = 0; @@ -322,8 +322,8 @@ static int hsw_volume_get(struct snd_kcontrol *kcontrol, static int hsw_waves_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -336,8 +336,8 @@ static int hsw_waves_switch_get(struct snd_kcontrol *kcontrol, static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; int ret = 0; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -370,8 +370,8 @@ static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol, static int hsw_waves_param_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; /* return a matching line from param buffer */ @@ -381,8 +381,8 @@ static int hsw_waves_param_get(struct snd_kcontrol *kcontrol, static int hsw_waves_param_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; int ret; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -472,8 +472,8 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; struct sst_module *module_data; @@ -674,8 +674,8 @@ static int hsw_pcm_hw_free(struct snd_pcm_substream *substream) static int hsw_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw_stream *sst_stream; struct sst_hsw *hsw = pdata->hsw; @@ -718,8 +718,8 @@ static u32 hsw_notify_pointer(struct sst_hsw_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; u32 pos; snd_pcm_uframes_t position = bytes_to_frames(runtime, @@ -783,8 +783,8 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; snd_pcm_uframes_t offset; @@ -807,8 +807,8 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) static int hsw_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; int dai; @@ -840,8 +840,8 @@ static int hsw_pcm_open(struct snd_pcm_substream *substream) static int hsw_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; int ret, dai; @@ -942,9 +942,9 @@ static void hsw_pcm_free_modules(struct hsw_priv_data *pdata) static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; - struct snd_soc_platform *platform = rtd->platform; - struct sst_pdata *pdata = dev_get_platdata(platform->dev); - struct hsw_priv_data *priv_data = dev_get_drvdata(platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); + struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev); struct device *dev = pdata->dma_dev; int ret = 0; @@ -1052,23 +1052,23 @@ static const struct snd_soc_dapm_route graph[] = { {"Analog Capture", NULL, "SSP0 CODEC IN"}, }; -static int hsw_pcm_probe(struct snd_soc_platform *platform) +static int hsw_pcm_probe(struct snd_soc_component *component) { - struct hsw_priv_data *priv_data = snd_soc_platform_get_drvdata(platform); - struct sst_pdata *pdata = dev_get_platdata(platform->dev); + struct hsw_priv_data *priv_data = snd_soc_component_get_drvdata(component); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct device *dma_dev, *dev; int i, ret = 0; if (!pdata) return -ENODEV; - dev = platform->dev; + dev = component->dev; dma_dev = pdata->dma_dev; priv_data->hsw = pdata->dsp; - priv_data->dev = platform->dev; + priv_data->dev = dev; priv_data->pm_state = HSW_PM_STATE_D0; - priv_data->soc_card = platform->component.card; + priv_data->soc_card = component->card; /* allocate DSP buffer page tables */ for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { @@ -1098,11 +1098,10 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform) goto err; /* enable runtime PM with auto suspend */ - pm_runtime_set_autosuspend_delay(platform->dev, - SST_RUNTIME_SUSPEND_DELAY); - pm_runtime_use_autosuspend(platform->dev); - pm_runtime_enable(platform->dev); - pm_runtime_idle(platform->dev); + pm_runtime_set_autosuspend_delay(dev, SST_RUNTIME_SUSPEND_DELAY); + pm_runtime_use_autosuspend(dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); return 0; @@ -1116,13 +1115,13 @@ err: return ret; } -static int hsw_pcm_remove(struct snd_soc_platform *platform) +static void hsw_pcm_remove(struct snd_soc_component *component) { struct hsw_priv_data *priv_data = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); int i; - pm_runtime_disable(platform->dev); + pm_runtime_disable(component->dev); hsw_pcm_free_modules(priv_data); for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { @@ -1131,24 +1130,19 @@ static int hsw_pcm_remove(struct snd_soc_platform *platform) if (hsw_dais[i].capture.channels_min) snd_dma_free_pages(&priv_data->dmab[i][1]); } - - return 0; } -static const struct snd_soc_platform_driver hsw_soc_platform = { +static const struct snd_soc_component_driver hsw_dai_component = { + .name = DRV_NAME, .probe = hsw_pcm_probe, .remove = hsw_pcm_remove, .ops = &hsw_pcm_ops, .pcm_new = hsw_pcm_new, -}; - -static const struct snd_soc_component_driver hsw_dai_component = { - .name = "haswell-dai", - .controls = hsw_volume_controls, - .num_controls = ARRAY_SIZE(hsw_volume_controls), - .dapm_widgets = widgets, + .controls = hsw_volume_controls, + .num_controls = ARRAY_SIZE(hsw_volume_controls), + .dapm_widgets = widgets, .num_dapm_widgets = ARRAY_SIZE(widgets), - .dapm_routes = graph, + .dapm_routes = graph, .num_dapm_routes = ARRAY_SIZE(graph), }; @@ -1172,19 +1166,13 @@ static int hsw_pcm_dev_probe(struct platform_device *pdev) priv_data->hsw = sst_pdata->dsp; platform_set_drvdata(pdev, priv_data); - ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform); - if (ret < 0) - goto err_plat; - - ret = snd_soc_register_component(&pdev->dev, &hsw_dai_component, + ret = devm_snd_soc_register_component(&pdev->dev, &hsw_dai_component, hsw_dais, ARRAY_SIZE(hsw_dais)); if (ret < 0) - goto err_comp; + goto err_plat; return 0; -err_comp: - snd_soc_unregister_platform(&pdev->dev); err_plat: sst_hsw_dsp_free(&pdev->dev, sst_pdata); return 0; @@ -1194,8 +1182,6 @@ static int hsw_pcm_dev_remove(struct platform_device *pdev) { struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); sst_hsw_dsp_free(&pdev->dev, sst_pdata); return 0; diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c index dc20d91f62e6..a016455a6ddb 100644 --- a/sound/soc/intel/skylake/skl-debug.c +++ b/sound/soc/intel/skylake/skl-debug.c @@ -231,7 +231,7 @@ struct skl_debug *skl_debugfs_init(struct skl *skl) /* create the debugfs dir with platform component's debugfs as parent */ d->fs = debugfs_create_dir("dsp", - skl->platform->component.debugfs_root); + skl->component->debugfs_root); if (IS_ERR(d->fs) || !d->fs) { dev_err(&skl->pci->dev, "debugfs root creation failed\n"); return NULL; diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index e46828533826..36a521562cf7 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1313,23 +1313,23 @@ static int skl_populate_modules(struct skl *skl) return ret; } -static int skl_platform_soc_probe(struct snd_soc_platform *platform) +static int skl_platform_soc_probe(struct snd_soc_component *component) { - struct hdac_ext_bus *ebus = dev_get_drvdata(platform->dev); + struct hdac_ext_bus *ebus = dev_get_drvdata(component->dev); struct skl *skl = ebus_to_skl(ebus); const struct skl_dsp_ops *ops; int ret; - pm_runtime_get_sync(platform->dev); + pm_runtime_get_sync(component->dev); if ((ebus_to_hbus(ebus))->ppcap) { - skl->platform = platform; + skl->component = component; /* init debugfs */ skl->debugfs = skl_debugfs_init(skl); - ret = skl_tplg_init(platform, ebus); + ret = skl_tplg_init(component, ebus); if (ret < 0) { - dev_err(platform->dev, "Failed to init topology!\n"); + dev_err(component->dev, "Failed to init topology!\n"); return ret; } @@ -1339,17 +1339,17 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) return -EIO; if (skl->skl_sst->is_first_boot == false) { - dev_err(platform->dev, "DSP reports first boot done!!!\n"); + dev_err(component->dev, "DSP reports first boot done!!!\n"); return -EIO; } /* disable dynamic clock gating during fw and lib download */ - skl->skl_sst->enable_miscbdcge(platform->dev, false); + skl->skl_sst->enable_miscbdcge(component->dev, false); - ret = ops->init_fw(platform->dev, skl->skl_sst); - skl->skl_sst->enable_miscbdcge(platform->dev, true); + ret = ops->init_fw(component->dev, skl->skl_sst); + skl->skl_sst->enable_miscbdcge(component->dev, true); if (ret < 0) { - dev_err(platform->dev, "Failed to boot first fw: %d\n", ret); + dev_err(component->dev, "Failed to boot first fw: %d\n", ret); return ret; } skl_populate_modules(skl); @@ -1362,22 +1362,20 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) skl->cfg.astate_cfg); } } - pm_runtime_mark_last_busy(platform->dev); - pm_runtime_put_autosuspend(platform->dev); + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); return 0; } -static const struct snd_soc_platform_driver skl_platform_drv = { + +static const struct snd_soc_component_driver skl_component = { + .name = "pcm", .probe = skl_platform_soc_probe, .ops = &skl_platform_ops, .pcm_new = skl_pcm_new, .pcm_free = skl_pcm_free, }; -static const struct snd_soc_component_driver skl_component = { - .name = "pcm", -}; - int skl_platform_register(struct device *dev) { int ret; @@ -1389,12 +1387,6 @@ int skl_platform_register(struct device *dev) INIT_LIST_HEAD(&skl->ppl_list); INIT_LIST_HEAD(&skl->bind_list); - ret = snd_soc_register_platform(dev, &skl_platform_drv); - if (ret) { - dev_err(dev, "soc platform registration failed %d\n", ret); - return ret; - } - skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai), GFP_KERNEL); if (!skl->dais) { @@ -1416,18 +1408,12 @@ int skl_platform_register(struct device *dev) num_dais += ARRAY_SIZE(skl_fe_dai); } - ret = snd_soc_register_component(dev, &skl_component, + ret = devm_snd_soc_register_component(dev, &skl_component, skl->dais, num_dais); - if (ret) { + if (ret) dev_err(dev, "soc component registration failed %d\n", ret); - goto err; - } - - return 0; err: - snd_soc_unregister_platform(dev); return ret; - } int skl_platform_unregister(struct device *dev) @@ -1443,8 +1429,6 @@ int skl_platform_unregister(struct device *dev) } } - snd_soc_unregister_component(dev); - snd_soc_unregister_platform(dev); kfree(skl->dais); return 0; diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 73af6e19ebbd..515e4b6d1950 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -2710,15 +2710,15 @@ static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w, return 0; } -static void skl_clear_pin_config(struct snd_soc_platform *platform, +static void skl_clear_pin_config(struct snd_soc_component *component, struct snd_soc_dapm_widget *w) { int i; struct skl_module_cfg *mconfig; struct skl_pipe *pipe; - if (!strncmp(w->dapm->component->name, platform->component.name, - strlen(platform->component.name))) { + if (!strncmp(w->dapm->component->name, component->name, + strlen(component->name))) { mconfig = w->priv; pipe = mconfig->pipe; for (i = 0; i < mconfig->module->max_input_pins; i++) { @@ -2737,14 +2737,14 @@ static void skl_clear_pin_config(struct snd_soc_platform *platform, void skl_cleanup_resources(struct skl *skl) { struct skl_sst *ctx = skl->skl_sst; - struct snd_soc_platform *soc_platform = skl->platform; + struct snd_soc_component *soc_component = skl->component; struct snd_soc_dapm_widget *w; struct snd_soc_card *card; - if (soc_platform == NULL) + if (soc_component == NULL) return; - card = soc_platform->component.card; + card = soc_component->card; if (!card || !card->instantiated) return; @@ -2753,7 +2753,7 @@ void skl_cleanup_resources(struct skl *skl) list_for_each_entry(w, &card->widgets, list) { if (is_skl_dsp_widget_type(w) && (w->priv != NULL)) - skl_clear_pin_config(soc_platform, w); + skl_clear_pin_config(soc_component, w); } skl_clear_module_cnt(ctx->dsp); @@ -3400,19 +3400,19 @@ static struct snd_soc_tplg_ops skl_tplg_ops = { * widgets in a pipelines, so this helper - skl_tplg_create_pipe_widget_list() * helps to get the SKL type widgets in that pipeline */ -static int skl_tplg_create_pipe_widget_list(struct snd_soc_platform *platform) +static int skl_tplg_create_pipe_widget_list(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; struct skl_module_cfg *mcfg = NULL; struct skl_pipe_module *p_module = NULL; struct skl_pipe *pipe; - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_skl_dsp_widget_type(w) && w->priv != NULL) { mcfg = w->priv; pipe = mcfg->pipe; - p_module = devm_kzalloc(platform->dev, + p_module = devm_kzalloc(component->dev, sizeof(*p_module), GFP_KERNEL); if (!p_module) return -ENOMEM; @@ -3455,7 +3455,7 @@ static void skl_tplg_set_pipe_type(struct skl *skl, struct skl_pipe *pipe) /* * SKL topology init routine */ -int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) +int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus) { int ret; const struct firmware *fw; @@ -3479,7 +3479,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) * The complete tplg for SKL is loaded as index 0, we don't use * any other index */ - ret = snd_soc_tplg_component_load(&platform->component, + ret = snd_soc_tplg_component_load(component, &skl_tplg_ops, fw, 0); if (ret < 0) { dev_err(bus->dev, "tplg component load failed%d\n", ret); @@ -3491,7 +3491,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) skl->resource.max_mem = SKL_FW_MAX_MEM; skl->tplg = fw; - ret = skl_tplg_create_pipe_widget_list(platform); + ret = skl_tplg_create_pipe_widget_list(component); if (ret < 0) return ret; diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index b6496513fe55..87c946835705 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -460,7 +460,7 @@ int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps, u32 caps_size, u32 node_id); void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai, struct skl_pipe_params *params, int stream); -int skl_tplg_init(struct snd_soc_platform *platform, +int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus); struct skl_module_cfg *skl_tplg_fe_get_cpr_module( struct snd_soc_dai *dai, int stream); diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 2d13f3fd988a..ca46ad1d0a08 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -74,7 +74,7 @@ struct skl { struct platform_device *dmic_dev; struct platform_device *i2s_dev; struct platform_device *clk_dev; - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct snd_soc_dai_driver *dais; struct nhlt_acpi_table *nhlt; /* nhlt ptr */ diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index 505b0ff03c3b..c6a58520d377 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -318,7 +318,8 @@ static void kirkwood_dma_free_dma_buffers(struct snd_pcm *pcm) } } -const struct snd_soc_platform_driver kirkwood_soc_platform = { +const struct snd_soc_component_driver kirkwood_soc_component = { + .name = DRV_NAME, .ops = &kirkwood_dma_ops, .pcm_new = kirkwood_dma_new, .pcm_free = kirkwood_dma_free_dma_buffers, diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 105a73cc5158..9a2777b72dcd 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -26,8 +26,6 @@ #include "kirkwood.h" -#define DRV_NAME "mvebu-audio" - #define KIRKWOOD_I2S_FORMATS \ (SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | \ @@ -524,10 +522,6 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { }, }; -static const struct snd_soc_component_driver kirkwood_i2s_component = { - .name = DRV_NAME, -}; - static int kirkwood_i2s_dev_probe(struct platform_device *pdev) { struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; @@ -601,24 +595,17 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128; } - err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, + err = devm_snd_soc_register_component(&pdev->dev, &kirkwood_soc_component, soc_dai, 2); if (err) { dev_err(&pdev->dev, "snd_soc_register_component failed\n"); goto err_component; } - err = snd_soc_register_platform(&pdev->dev, &kirkwood_soc_platform); - if (err) { - dev_err(&pdev->dev, "snd_soc_register_platform failed\n"); - goto err_platform; - } - kirkwood_i2s_init(priv); return 0; - err_platform: - snd_soc_unregister_component(&pdev->dev); + err_component: if (!IS_ERR(priv->extclk)) clk_disable_unprepare(priv->extclk); @@ -631,9 +618,6 @@ static int kirkwood_i2s_dev_remove(struct platform_device *pdev) { struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - if (!IS_ERR(priv->extclk)) clk_disable_unprepare(priv->extclk); clk_disable_unprepare(priv->clk); diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index 783cb1a4f30e..c13ee5f69446 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h @@ -12,6 +12,8 @@ #ifndef _KIRKWOOD_AUDIO_H #define _KIRKWOOD_AUDIO_H +#define DRV_NAME "mvebu-audio" + #define KIRKWOOD_RECORD_WIN 0 #define KIRKWOOD_PLAYBACK_WIN 1 #define KIRKWOOD_MAX_AUDIO_WIN 2 @@ -143,6 +145,6 @@ struct kirkwood_dma_data { int burst; }; -extern const struct snd_soc_platform_driver kirkwood_soc_platform; +extern const struct snd_soc_component_driver kirkwood_soc_component; #endif diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index ac231d33d8fe..c91e5f4cd902 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -18,6 +18,7 @@ #include <linux/pm_runtime.h> #include <linux/regmap.h> #include <sound/soc.h> +#include "mtk-afe-platform-driver.h" #include "mtk-afe-fe-dai.h" #include "mtk-base-afe.h" @@ -43,7 +44,8 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *runtime = substream->runtime; int memif_num = rtd->cpu_dai->id; struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; @@ -105,7 +107,8 @@ void mtk_afe_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int irq_id; @@ -128,7 +131,8 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int msb_at_bit33 = 0; int ret, fs = 0; @@ -192,7 +196,8 @@ int mtk_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage]; const struct mtk_base_irq_data *irq_data = irqs->irq_data; @@ -255,7 +260,8 @@ int mtk_afe_fe_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int hd_audio = 0; diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c index 82d439c15f4e..53215b52e4f2 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -25,7 +25,8 @@ static snd_pcm_uframes_t mtk_afe_pcm_pointer (struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; const struct mtk_base_memif_data *memif_data = memif->data; struct regmap *regmap = afe->regmap; @@ -65,7 +66,8 @@ static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd) size_t size; struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); size = afe->mtk_afe_hardware->buffer_bytes_max; return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, @@ -77,7 +79,8 @@ static void mtk_afe_pcm_free(struct snd_pcm *pcm) snd_pcm_lib_preallocate_free_for_all(pcm); } -const struct snd_soc_platform_driver mtk_afe_pcm_platform = { +const struct snd_soc_component_driver mtk_afe_pcm_platform = { + .name = AFE_PCM_NAME, .ops = &mtk_afe_pcm_ops, .pcm_new = mtk_afe_pcm_new, .pcm_free = mtk_afe_pcm_free, diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.h b/sound/soc/mediatek/common/mtk-afe-platform-driver.h index a973fc9253b4..8dcdbed959ea 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.h +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.h @@ -17,7 +17,8 @@ #ifndef _MTK_AFE_PLATFORM_DRIVER_H_ #define _MTK_AFE_PLATFORM_DRIVER_H_ -extern const struct snd_soc_platform_driver mtk_afe_pcm_platform; +#define AFE_PCM_NAME "mtk-afe-pcm" +extern const struct snd_soc_component_driver mtk_afe_pcm_platform; #endif diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index d68b53f7cefe..f7e0702d92f8 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -93,7 +93,8 @@ static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); if (i2s_num < 0) @@ -108,7 +109,8 @@ static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream, int dir_invert) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; const struct mt2701_i2s_data *i2s_data; @@ -144,7 +146,8 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); struct mt2701_i2s_path *i2s_path; @@ -176,7 +179,8 @@ static int mt2701_i2s_path_prepare_enable(struct snd_pcm_substream *substream, int dir_invert) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; const struct mt2701_i2s_data *i2s_data; @@ -247,7 +251,8 @@ static int mt2701_afe_i2s_prepare(struct snd_pcm_substream *substream, { int clk_domain; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); struct mt2701_i2s_path *i2s_path; @@ -312,7 +317,8 @@ static int mt2701_btmrg_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int ret; @@ -329,7 +335,8 @@ static int mt2701_btmrg_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_fs; u32 val, msk; @@ -372,7 +379,8 @@ static void mt2701_btmrg_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; /* if the other direction stream is not occupied */ @@ -392,7 +400,8 @@ static int mt2701_simple_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_dir = substream->stream; int memif_num = rtd->cpu_dai->id; struct mtk_base_afe_memif *memif_tmp; @@ -414,7 +423,8 @@ static int mt2701_simple_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_dir = substream->stream; /* single DL use PAIR_INTERLEAVE */ @@ -431,7 +441,8 @@ static int mt2701_dlm_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif_tmp; const struct mtk_base_memif_data *memif_data; int i; @@ -458,7 +469,8 @@ static void mt2701_dlm_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); const struct mtk_base_memif_data *memif_data; int i; @@ -477,7 +489,8 @@ static int mt2701_dlm_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int channels = params_channels(params); regmap_update_bits(afe->regmap, @@ -500,7 +513,8 @@ static int mt2701_dlm_fe_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif_tmp = &afe->memif[MT2701_MEMIF_DL1]; switch (cmd) { @@ -1517,7 +1531,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) } pm_runtime_get_sync(dev); - ret = snd_soc_register_platform(dev, &mtk_afe_pcm_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &mtk_afe_pcm_platform, + NULL, 0); if (ret) { dev_warn(dev, "err_platform\n"); goto err_platform; @@ -1526,13 +1541,11 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) ret = mt2701_afe_add_component(afe); if (ret) { dev_warn(dev, "err_dai_component\n"); - goto err_dai_component; + goto err_platform; } return 0; -err_dai_component: - snd_soc_unregister_platform(dev); err_platform: pm_runtime_put_sync(dev); err_pm_disable: @@ -1549,7 +1562,6 @@ static int mt2701_afe_pcm_dev_remove(struct platform_device *pdev) mt2701_afe_runtime_suspend(&pdev->dev); snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); return 0; } diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c index c7f7f8add5d9..65d1433a0944 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c @@ -304,7 +304,8 @@ static int mt8173_afe_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); if (dai->active) return 0; @@ -318,7 +319,8 @@ static void mt8173_afe_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); if (dai->active) return; @@ -334,7 +336,8 @@ static int mt8173_afe_i2s_prepare(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; int ret; @@ -356,7 +359,8 @@ static int mt8173_afe_hdmi_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; if (dai->active) @@ -371,7 +375,8 @@ static void mt8173_afe_hdmi_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; if (dai->active) @@ -386,7 +391,8 @@ static int mt8173_afe_hdmi_prepare(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; unsigned int val; @@ -449,7 +455,8 @@ static int mt8173_afe_hdmi_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); dev_info(afe->dev, "%s cmd=%d %s\n", __func__, cmd, dai->name); @@ -498,7 +505,8 @@ static int mt8173_memif_fs(struct snd_pcm_substream *substream, unsigned int rate) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int fs; @@ -1172,31 +1180,29 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) afe->runtime_resume = mt8173_afe_runtime_resume; afe->runtime_suspend = mt8173_afe_runtime_suspend; - ret = snd_soc_register_platform(&pdev->dev, &mtk_afe_pcm_platform); + ret = devm_snd_soc_register_component(&pdev->dev, + &mtk_afe_pcm_platform, + NULL, 0); if (ret) goto err_pm_disable; - ret = snd_soc_register_component(&pdev->dev, + ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_pcm_dai_component, mt8173_afe_pcm_dais, ARRAY_SIZE(mt8173_afe_pcm_dais)); if (ret) - goto err_platform; + goto err_pm_disable; - ret = snd_soc_register_component(&pdev->dev, + ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_hdmi_dai_component, mt8173_afe_hdmi_dais, ARRAY_SIZE(mt8173_afe_hdmi_dais)); if (ret) - goto err_comp; + goto err_pm_disable; dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n"); return 0; -err_comp: - snd_soc_unregister_component(&pdev->dev); -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_pm_disable: pm_runtime_disable(&pdev->dev); return ret; @@ -1207,8 +1213,6 @@ static int mt8173_afe_pcm_dev_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) mt8173_afe_runtime_suspend(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); return 0; } diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650.c b/sound/soc/mediatek/mt8173/mt8173-rt5650.c index 40ebefd625c1..679fc8bea0a3 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650.c @@ -272,15 +272,10 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev) } mt8173_rt5650_codecs[1].of_node = mt8173_rt5650_codecs[0].of_node; - if (of_find_node_by_name(platform_node, "codec-capture")) { - np = of_get_child_by_name(pdev->dev.of_node, "codec-capture"); - if (!np) { - dev_err(&pdev->dev, - "%s: Can't find codec-capture DT node\n", - __func__); - return -EINVAL; - } + np = of_get_child_by_name(pdev->dev.of_node, "codec-capture"); + if (np) { ret = snd_soc_of_get_dai_name(np, &codec_capture_dai); + of_node_put(np); if (ret < 0) { dev_err(&pdev->dev, "%s codec_capture_dai name fail %d\n", diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c index bd6dfa218d59..ad8392a87df9 100644 --- a/sound/soc/nuc900/nuc900-pcm.c +++ b/sound/soc/nuc900/nuc900-pcm.c @@ -299,14 +299,15 @@ static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static const struct snd_soc_platform_driver nuc900_soc_platform = { +static const struct snd_soc_component_driver nuc900_soc_component = { .ops = &nuc900_dma_ops, .pcm_new = nuc900_dma_new, }; static int nuc900_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &nuc900_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &nuc900_soc_component, + NULL, 0); } static struct platform_driver nuc900_pcm_driver = { diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index 7a54e3083203..79d4dc785e5c 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -854,7 +854,7 @@ unlock: return size; } -static DEVICE_ATTR(dma_op_mode, 0644, dma_op_mode_show, dma_op_mode_store); +static DEVICE_ATTR_RW(dma_op_mode); static const struct attribute *additional_attrs[] = { &dev_attr_max_tx_thres.attr, @@ -923,7 +923,7 @@ out: return size; } -static DEVICE_ATTR(st_taps, 0644, st_taps_show, st_taps_store); +static DEVICE_ATTR_RW(st_taps); static const struct attribute *sidetone_attrs[] = { &dev_attr_st_taps.attr, diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index aca2c43d0f03..778cc8f75b6a 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -243,7 +243,7 @@ out: return ret; } -static const struct snd_soc_platform_driver omap_soc_platform = { +static const struct snd_soc_component_driver omap_soc_component = { .ops = &omap_pcm_ops, .pcm_new = omap_pcm_new, .pcm_free = omap_pcm_free_dma_buffers, @@ -252,7 +252,8 @@ static const struct snd_soc_platform_driver omap_soc_platform = { int omap_pcm_platform_register(struct device *dev) { omap_pcm_limit_supported_formats(); - return devm_snd_soc_register_platform(dev, &omap_soc_platform); + return devm_snd_soc_register_component(dev, &omap_soc_component, + NULL, 0); } EXPORT_SYMBOL_GPL(omap_pcm_platform_register); diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 624d9bd5dadd..d2d4652de32c 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c @@ -25,6 +25,8 @@ #include <sound/soc.h> #include <sound/dmaengine_pcm.h> +#define DRV_NAME "mmp-pcm" + struct mmp_dma_data { int ssp_id; struct resource *dma_res; @@ -100,7 +102,8 @@ static bool filter(struct dma_chan *chan, void *param) static int mmp_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct platform_device *pdev = to_platform_device(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct platform_device *pdev = to_platform_device(component->dev); struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct mmp_dma_data dma_data; struct resource *r; @@ -211,7 +214,8 @@ err: return ret; } -static const struct snd_soc_platform_driver mmp_soc_platform = { +static const struct snd_soc_component_driver mmp_soc_component = { + .name = DRV_NAME, .ops = &mmp_pcm_ops, .pcm_new = mmp_pcm_new, .pcm_free = mmp_pcm_free_dma_buffers, @@ -231,7 +235,8 @@ static int mmp_pcm_probe(struct platform_device *pdev) mmp_pcm_hardware[SNDRV_PCM_STREAM_CAPTURE].period_bytes_max = pdata->period_max_capture; } - return devm_snd_soc_register_platform(&pdev->dev, &mmp_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &mmp_soc_component, + NULL, 0); } static struct platform_driver mmp_pcm_driver = { diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index e64958d8bff0..8b6a70e94c01 100644 --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c @@ -84,7 +84,7 @@ static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd) return ret; } -static const struct snd_soc_platform_driver pxa2xx_soc_platform = { +static const struct snd_soc_component_driver pxa2xx_soc_platform = { .ops = &pxa2xx_pcm_ops, .pcm_new = pxa2xx_soc_pcm_new, .pcm_free = pxa2xx_pcm_free_dma_buffers, @@ -92,7 +92,8 @@ static const struct snd_soc_platform_driver pxa2xx_soc_platform = { static int pxa2xx_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &pxa2xx_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &pxa2xx_soc_platform, + NULL, 0); } #ifdef CONFIG_OF diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index caf71aab8196..31fe78aa207f 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -24,6 +24,8 @@ #include "lpass-lpaif-reg.h" #include "lpass.h" +#define DRV_NAME "lpass-platform" + struct lpass_pcm_data { int dma_ch; int i2s_port; @@ -61,8 +63,8 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct lpass_variant *v = drvdata->variant; int ret, dma_ch, dir = substream->stream; struct lpass_pcm_data *data; @@ -115,8 +117,8 @@ static int lpass_platform_pcmops_close(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct lpass_variant *v = drvdata->variant; struct lpass_pcm_data *data; @@ -132,8 +134,8 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -225,8 +227,8 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, static int lpass_platform_pcmops_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -246,8 +248,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -298,8 +300,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -372,8 +374,8 @@ static snd_pcm_uframes_t lpass_platform_pcmops_pointer( struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -509,13 +511,14 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime) { struct snd_pcm *pcm = soc_runtime->pcm; struct snd_pcm_substream *psubstream, *csubstream; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); int ret = -EINVAL; size_t size = lpass_platform_pcm_hardware.buffer_bytes_max; psubstream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; if (psubstream) { ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - soc_runtime->platform->dev, + component->dev, size, &psubstream->dma_buffer); if (ret) { dev_err(soc_runtime->dev, "Cannot allocate buffer(s)\n"); @@ -526,7 +529,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime) csubstream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; if (csubstream) { ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - soc_runtime->platform->dev, + component->dev, size, &csubstream->dma_buffer); if (ret) { dev_err(soc_runtime->dev, "Cannot allocate buffer(s)\n"); @@ -555,7 +558,8 @@ static void lpass_platform_pcm_free(struct snd_pcm *pcm) } } -static const struct snd_soc_platform_driver lpass_platform_driver = { +static const struct snd_soc_component_driver lpass_component_driver = { + .name = DRV_NAME, .pcm_new = lpass_platform_pcm_new, .pcm_free = lpass_platform_pcm_free, .ops = &lpass_platform_pcm_ops, @@ -591,8 +595,8 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev) } - return devm_snd_soc_register_platform(&pdev->dev, - &lpass_platform_driver); + return devm_snd_soc_register_component(&pdev->dev, + &lpass_component_driver, NULL, 0); } EXPORT_SYMBOL_GPL(asoc_qcom_lpass_platform_register); diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index a635df61f928..b1f09b942410 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c @@ -399,7 +399,7 @@ void idma_reg_addr_init(void __iomem *regs, dma_addr_t addr) } EXPORT_SYMBOL_GPL(idma_reg_addr_init); -static const struct snd_soc_platform_driver asoc_idma_platform = { +static const struct snd_soc_component_driver asoc_idma_platform = { .ops = &idma_ops, .pcm_new = idma_new, .pcm_free = idma_free, @@ -411,7 +411,8 @@ static int asoc_idma_platform_probe(struct platform_device *pdev) if (idma_irq < 0) return idma_irq; - return devm_snd_soc_register_platform(&pdev->dev, &asoc_idma_platform); + return devm_snd_soc_register_component(&pdev->dev, &asoc_idma_platform, + NULL, 0); } static struct platform_driver asoc_idma_driver = { diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index 1e7d417b53ef..2dc3b762fdd9 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -320,14 +320,15 @@ static int camelot_pcm_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static const struct snd_soc_platform_driver sh7760_soc_platform = { +static const struct snd_soc_component_driver sh7760_soc_component = { .ops = &camelot_pcm_ops, .pcm_new = camelot_pcm_new, }; static int sh7760_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &sh7760_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &sh7760_soc_component, + NULL, 0); } static struct platform_driver sh7760_pcm_driver = { diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index c3aaf4788557..3bae06dd121f 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1764,7 +1764,7 @@ static const struct snd_pcm_ops fsi_pcm_ops = { }; /* - * snd_soc_platform + * snd_soc_component */ #define PREALLOC_BUFFER (32 * 1024) @@ -1818,13 +1818,10 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = { }, }; -static const struct snd_soc_platform_driver fsi_soc_platform = { - .ops = &fsi_pcm_ops, - .pcm_new = fsi_pcm_new, -}; - static const struct snd_soc_component_driver fsi_soc_component = { .name = "fsi", + .ops = &fsi_pcm_ops, + .pcm_new = fsi_pcm_new, }; /* @@ -2007,23 +2004,15 @@ static int fsi_probe(struct platform_device *pdev) goto exit_fsib; } - ret = snd_soc_register_platform(&pdev->dev, &fsi_soc_platform); - if (ret < 0) { - dev_err(&pdev->dev, "cannot snd soc register\n"); - goto exit_fsib; - } - - ret = snd_soc_register_component(&pdev->dev, &fsi_soc_component, + ret = devm_snd_soc_register_component(&pdev->dev, &fsi_soc_component, fsi_soc_dai, ARRAY_SIZE(fsi_soc_dai)); if (ret < 0) { dev_err(&pdev->dev, "cannot snd component register\n"); - goto exit_snd_soc; + goto exit_fsib; } return ret; -exit_snd_soc: - snd_soc_unregister_platform(&pdev->dev); exit_fsib: pm_runtime_disable(&pdev->dev); fsi_stream_remove(&master->fsib); @@ -2041,9 +2030,6 @@ static int fsi_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - fsi_stream_remove(&master->fsia); fsi_stream_remove(&master->fsib); diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 64d5ecb86528..b4007669c704 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1337,7 +1337,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, } /* - * snd_soc_platform + * snd_soc_component */ #define PREALLOC_BUFFER (32 * 1024) @@ -1364,12 +1364,9 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); } -static const struct snd_soc_platform_driver rsnd_soc_platform = { +static const struct snd_soc_component_driver rsnd_soc_component = { .ops = &rsnd_pcm_ops, .pcm_new = rsnd_pcm_new, -}; - -static const struct snd_soc_component_driver rsnd_soc_component = { .name = "rsnd", }; @@ -1478,17 +1475,11 @@ static int rsnd_probe(struct platform_device *pdev) /* * asoc register */ - ret = snd_soc_register_platform(dev, &rsnd_soc_platform); - if (ret < 0) { - dev_err(dev, "cannot snd soc register\n"); - return ret; - } - - ret = snd_soc_register_component(dev, &rsnd_soc_component, + ret = devm_snd_soc_register_component(dev, &rsnd_soc_component, priv->daidrv, rsnd_rdai_nr(priv)); if (ret < 0) { dev_err(dev, "cannot snd dai register\n"); - goto exit_snd_soc; + goto exit_snd_probe; } pm_runtime_enable(dev); @@ -1496,8 +1487,6 @@ static int rsnd_probe(struct platform_device *pdev) dev_info(dev, "probed\n"); return ret; -exit_snd_soc: - snd_soc_unregister_platform(dev); exit_snd_probe: for_each_rsnd_dai(rdai, priv, i) { rsnd_dai_call(remove, &rdai->playback, priv); @@ -1535,9 +1524,6 @@ static int rsnd_remove(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(remove_func); i++) remove_func[i](priv); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - return ret; } diff --git a/sound/soc/sh/siu.h b/sound/soc/sh/siu.h index 83c3430ad797..6088d627c0e4 100644 --- a/sound/soc/sh/siu.h +++ b/sound/soc/sh/siu.h @@ -183,7 +183,7 @@ static inline u32 siu_read32(u32 __iomem *addr) #define SIU_BRGBSEL (0x108 / sizeof(u32)) #define SIU_BRRB (0x10c / sizeof(u32)) -extern struct snd_soc_platform_driver siu_platform; +extern struct snd_soc_component_driver siu_component; extern struct siu_info *siu_i2s_data; int siu_init_port(int port, struct siu_port **port_info, struct snd_card *card); diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c index 160502947da2..ee2211635e92 100644 --- a/sound/soc/sh/siu_dai.c +++ b/sound/soc/sh/siu_dai.c @@ -727,10 +727,6 @@ static struct snd_soc_dai_driver siu_i2s_dai = { .ops = &siu_dai_ops, }; -static const struct snd_soc_component_driver siu_i2s_component = { - .name = "siu-i2s", -}; - static int siu_probe(struct platform_device *pdev) { const struct firmware *fw_entry; @@ -786,15 +782,11 @@ static int siu_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, info); /* register using ARRAY version so we can keep dai name */ - ret = devm_snd_soc_register_component(&pdev->dev, &siu_i2s_component, + ret = devm_snd_soc_register_component(&pdev->dev, &siu_component, &siu_i2s_dai, 1); if (ret < 0) return ret; - ret = devm_snd_soc_register_platform(&pdev->dev, &siu_platform); - if (ret < 0) - return ret; - pm_runtime_enable(&pdev->dev); return 0; diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index 3118cb0ee3f2..172909570ed5 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -35,6 +35,7 @@ #include "siu.h" +#define DRV_NAME "siu-i2s" #define GET_MAX_PERIODS(buf_bytes, period_bytes) \ ((buf_bytes) / (period_bytes)) #define PERIOD_OFFSET(buf_addr, period_num, period_bytes) \ @@ -340,7 +341,8 @@ static int siu_pcm_open(struct snd_pcm_substream *ss) { /* Playback / Capture */ struct snd_soc_pcm_runtime *rtd = ss->private_data; - struct siu_platform *pdata = rtd->platform->dev->platform_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct siu_platform *pdata = component->dev->platform_data; struct siu_info *info = siu_i2s_data; struct siu_port *port_info = siu_port_info(ss); struct siu_stream *siu_stream; @@ -604,9 +606,10 @@ static const struct snd_pcm_ops siu_pcm_ops = { .pointer = siu_pcm_pointer_dma, }; -struct snd_soc_platform_driver siu_platform = { +struct snd_soc_component_driver siu_component = { + .name = DRV_NAME, .ops = &siu_pcm_ops, .pcm_new = siu_pcm_new, .pcm_free = siu_pcm_free, }; -EXPORT_SYMBOL_GPL(siu_platform); +EXPORT_SYMBOL_GPL(siu_component); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9c7b78558979..9558125b448d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -173,7 +173,7 @@ static ssize_t codec_reg_show(struct device *dev, return soc_codec_reg_show(rtd->codec, buf, PAGE_SIZE, 0); } -static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL); +static DEVICE_ATTR_RO(codec_reg); static ssize_t pmdown_time_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -1162,11 +1162,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, rtd->platform = platform; } - if (!rtd->platform) { - dev_err(card->dev, "ASoC: platform %s not registered\n", - dai_link->platform_name); - goto _err_defer; - } soc_add_pcm_runtime(card, rtd); return 0; diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index a10b21cfc31e..92894d9cac19 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2026,7 +2026,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file, snd_soc_dapm_for_each_direction(dir) { rdir = SND_SOC_DAPM_DIR_REVERSE(dir); snd_soc_dapm_widget_for_each_path(w, dir, p) { - if (p->connected && !p->connected(w, p->node[rdir])) + if (p->connected && !p->connected(p->source, p->sink)) continue; if (!p->connect) @@ -2364,7 +2364,7 @@ static ssize_t dapm_widget_show(struct device *dev, return count; } -static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); +static DEVICE_ATTR_RO(dapm_widget); struct attribute *soc_dapm_dev_attrs[] = { &dev_attr_dapm_widget.attr, diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index d53786498b61..c07d5c79ca91 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -33,13 +33,13 @@ struct dmaengine_pcm { struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; const struct snd_dmaengine_pcm_config *config; - struct snd_soc_platform platform; + struct snd_soc_component component; unsigned int flags; }; -static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p) +static struct dmaengine_pcm *soc_component_to_pcm(struct snd_soc_component *p) { - return container_of(p, struct dmaengine_pcm, platform); + return container_of(p, struct dmaengine_pcm, component); } static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, @@ -88,7 +88,9 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); int (*prepare_slave_config)(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, @@ -119,7 +121,9 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct device *dma_dev = dmaengine_dma_dev(pcm, substream); struct dma_chan *chan = pcm->chan[substream->stream]; struct snd_dmaengine_dai_dma_data *dma_data; @@ -206,7 +210,9 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea static int dmaengine_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = pcm->chan[substream->stream]; int ret; @@ -221,7 +227,9 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( struct snd_soc_pcm_runtime *rtd, struct snd_pcm_substream *substream) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct snd_dmaengine_dai_dma_data *dma_data; dma_filter_fn fn = NULL; @@ -260,9 +268,11 @@ static bool dmaengine_pcm_can_report_residue(struct device *dev, static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); const struct snd_dmaengine_pcm_config *config = pcm->config; - struct device *dev = rtd->platform->dev; + struct device *dev = component->dev; struct snd_dmaengine_dai_dma_data *dma_data; struct snd_pcm_substream *substream; size_t prealloc_buffer_size; @@ -296,7 +306,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) } if (!pcm->chan[i]) { - dev_err(rtd->platform->dev, + dev_err(component->dev, "Missing dma channel for stream: %d\n", i); return -EINVAL; } @@ -320,7 +330,9 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) return snd_dmaengine_pcm_pointer_no_residue(substream); @@ -338,10 +350,9 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = { .pointer = dmaengine_pcm_pointer, }; -static const struct snd_soc_platform_driver dmaengine_pcm_platform = { - .component_driver = { - .probe_order = SND_SOC_COMP_ORDER_LATE, - }, +static const struct snd_soc_component_driver dmaengine_pcm_component = { + .name = SND_DMAENGINE_PCM_DRV_NAME, + .probe_order = SND_SOC_COMP_ORDER_LATE, .ops = &dmaengine_pcm_ops, .pcm_new = dmaengine_pcm_new, }; @@ -438,8 +449,8 @@ int snd_dmaengine_pcm_register(struct device *dev, if (ret) goto err_free_dma; - ret = snd_soc_add_platform(dev, &pcm->platform, - &dmaengine_pcm_platform); + ret = snd_soc_add_component(dev, &pcm->component, + &dmaengine_pcm_component, NULL, 0); if (ret) goto err_free_dma; @@ -461,16 +472,16 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_register); */ void snd_dmaengine_pcm_unregister(struct device *dev) { - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct dmaengine_pcm *pcm; - platform = snd_soc_lookup_platform(dev); - if (!platform) + component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME); + if (!component) return; - pcm = soc_platform_to_pcm(platform); + pcm = soc_component_to_pcm(component); - snd_soc_remove_platform(platform); + snd_soc_unregister_component(dev); dmaengine_pcm_release_chan(pcm); kfree(pcm); } diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index bcd3da2739e2..2d9e98bd1530 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -284,11 +284,16 @@ static const struct snd_pcm_ops dummy_dma_ops = { .ioctl = snd_pcm_lib_ioctl, }; -static const struct snd_soc_platform_driver dummy_platform = { +static const struct snd_soc_component_driver dummy_platform = { .ops = &dummy_dma_ops, }; -static const struct snd_soc_codec_driver dummy_codec; +static const struct snd_soc_component_driver dummy_codec = { + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; #define STUB_RATES SNDRV_PCM_RATE_8000_192000 #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ @@ -338,33 +343,22 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) { int ret; - ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &dummy_codec, &dummy_dai, 1); if (ret < 0) return ret; - ret = snd_soc_register_platform(&pdev->dev, &dummy_platform); - if (ret < 0) { - snd_soc_unregister_codec(&pdev->dev); - return ret; - } + ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, + NULL, 0); return ret; } -static int snd_soc_dummy_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_codec(&pdev->dev); - - return 0; -} - static struct platform_driver soc_dummy_driver = { .driver = { .name = "snd-soc-dummy", }, .probe = snd_soc_dummy_probe, - .remove = snd_soc_dummy_remove, }; static struct platform_device *soc_dummy_dev; diff --git a/sound/soc/stm/Kconfig b/sound/soc/stm/Kconfig index 3ad881fc40a1..48f9ddd94016 100644 --- a/sound/soc/stm/Kconfig +++ b/sound/soc/stm/Kconfig @@ -2,7 +2,7 @@ menu "STMicroelectronics STM32 SOC audio support" config SND_SOC_STM32_SAI tristate "STM32 SAI interface (Serial Audio Interface) support" - depends on ARCH_STM32 || COMPILE_TEST + depends on (ARCH_STM32 && OF) || COMPILE_TEST depends on SND_SOC select SND_SOC_GENERIC_DMAENGINE_PCM select REGMAP_MMIO @@ -11,7 +11,7 @@ config SND_SOC_STM32_SAI config SND_SOC_STM32_I2S tristate "STM32 I2S interface (SPI/I2S block) support" - depends on ARCH_STM32 || COMPILE_TEST + depends on (ARCH_STM32 && OF) || COMPILE_TEST depends on SND_SOC select SND_SOC_GENERIC_DMAENGINE_PCM select REGMAP_MMIO @@ -20,7 +20,7 @@ config SND_SOC_STM32_I2S config SND_SOC_STM32_SPDIFRX tristate "STM32 S/PDIF receiver (SPDIFRX) support" - depends on ARCH_STM32 || COMPILE_TEST + depends on (ARCH_STM32 && OF) || COMPILE_TEST depends on SND_SOC select SND_SOC_GENERIC_DMAENGINE_PCM select REGMAP_MMIO diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c index 7306e3eca9e1..db73fef3e500 100644 --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c @@ -281,7 +281,7 @@ static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm) } } -static struct snd_soc_platform_driver stm32_adfsdm_soc_platform = { +static struct snd_soc_component_driver stm32_adfsdm_soc_platform = { .ops = &stm32_adfsdm_pcm_ops, .pcm_new = stm32_adfsdm_pcm_new, .pcm_free = stm32_adfsdm_pcm_free, @@ -322,8 +322,9 @@ static int stm32_adfsdm_probe(struct platform_device *pdev) if (IS_ERR(priv->iio_cb)) return PTR_ERR(priv->iio_cb); - ret = devm_snd_soc_register_platform(&pdev->dev, - &stm32_adfsdm_soc_platform); + ret = devm_snd_soc_register_component(&pdev->dev, + &stm32_adfsdm_soc_platform, + NULL, 0); if (ret < 0) dev_err(&pdev->dev, "%s: Failed to register PCM platform\n", __func__); diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index a2bb68fea5a3..8d31fe628e2f 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -23,6 +23,8 @@ #include <sound/soc.h> #include "txx9aclc.h" +#define DRV_NAME "txx9aclc" + static struct txx9aclc_soc_device { struct txx9aclc_dmadata dmadata[2]; } txx9aclc_soc_device; @@ -53,6 +55,7 @@ static int txx9aclc_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct txx9aclc_dmadata *dmadata = runtime->private_data; int ret; @@ -60,13 +63,13 @@ static int txx9aclc_pcm_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - dev_dbg(rtd->platform->dev, + dev_dbg(component->dev, "runtime->dma_area = %#lx dma_addr = %#lx dma_bytes = %zd " "runtime->min_align %ld\n", (unsigned long)runtime->dma_area, (unsigned long)runtime->dma_addr, runtime->dma_bytes, runtime->min_align); - dev_dbg(rtd->platform->dev, + dev_dbg(component->dev, "periods %d period_bytes %d stream %d\n", params_periods(params), params_period_bytes(params), substream->stream); @@ -287,7 +290,8 @@ static int txx9aclc_pcm_new(struct snd_soc_pcm_runtime *rtd) struct snd_card *card = rtd->card->snd_card; struct snd_soc_dai *dai = rtd->cpu_dai; struct snd_pcm *pcm = rtd->pcm; - struct platform_device *pdev = to_platform_device(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct platform_device *pdev = to_platform_device(component->dev); struct txx9aclc_soc_device *dev; struct resource *r; int i; @@ -371,15 +375,15 @@ static int txx9aclc_dma_init(struct txx9aclc_soc_device *dev, return 0; } -static int txx9aclc_pcm_probe(struct snd_soc_platform *platform) +static int txx9aclc_pcm_probe(struct snd_soc_component *component) { - snd_soc_platform_set_drvdata(platform, &txx9aclc_soc_device); + snd_soc_component_set_drvdata(component, &txx9aclc_soc_device); return 0; } -static int txx9aclc_pcm_remove(struct snd_soc_platform *platform) +static void txx9aclc_pcm_remove(struct snd_soc_component *component) { - struct txx9aclc_soc_device *dev = snd_soc_platform_get_drvdata(platform); + struct txx9aclc_soc_device *dev = snd_soc_component_get_drvdata(component); struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; void __iomem *base = drvdata->base; int i; @@ -400,10 +404,10 @@ static int txx9aclc_pcm_remove(struct snd_soc_platform *platform) } dev->dmadata[i].dma_chan = NULL; } - return 0; } -static const struct snd_soc_platform_driver txx9aclc_soc_platform = { +static const struct snd_soc_component_driver txx9aclc_soc_component = { + .name = DRV_NAME, .probe = txx9aclc_pcm_probe, .remove = txx9aclc_pcm_remove, .ops = &txx9aclc_pcm_ops, @@ -412,8 +416,8 @@ static const struct snd_soc_platform_driver txx9aclc_soc_platform = { static int txx9aclc_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &txx9aclc_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &txx9aclc_soc_component, NULL, 0); } static struct platform_driver txx9aclc_pcm_driver = { diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c index 2472144b329e..503560916620 100644 --- a/sound/soc/xtensa/xtfpga-i2s.c +++ b/sound/soc/xtensa/xtfpga-i2s.c @@ -483,13 +483,10 @@ static const struct snd_pcm_ops xtfpga_pcm_ops = { .pointer = xtfpga_pcm_pointer, }; -static const struct snd_soc_platform_driver xtfpga_soc_platform = { - .pcm_new = xtfpga_pcm_new, - .ops = &xtfpga_pcm_ops, -}; - static const struct snd_soc_component_driver xtfpga_i2s_component = { .name = DRV_NAME, + .pcm_new = xtfpga_pcm_new, + .ops = &xtfpga_pcm_ops, }; static const struct snd_soc_dai_ops xtfpga_i2s_dai_ops = { @@ -591,18 +588,13 @@ static int xtfpga_i2s_probe(struct platform_device *pdev) goto err; } - err = snd_soc_register_platform(&pdev->dev, &xtfpga_soc_platform); - if (err < 0) { - dev_err(&pdev->dev, "couldn't register platform\n"); - goto err; - } err = devm_snd_soc_register_component(&pdev->dev, &xtfpga_i2s_component, xtfpga_i2s_dai, ARRAY_SIZE(xtfpga_i2s_dai)); if (err < 0) { dev_err(&pdev->dev, "couldn't register component\n"); - goto err_unregister_platform; + goto err; } pm_runtime_enable(&pdev->dev); @@ -615,8 +607,6 @@ static int xtfpga_i2s_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(&pdev->dev); -err_unregister_platform: - snd_soc_unregister_platform(&pdev->dev); err: dev_err(&pdev->dev, "%s: err = %d\n", __func__, err); return err; @@ -626,7 +616,6 @@ static int xtfpga_i2s_remove(struct platform_device *pdev) { struct xtfpga_i2s *i2s = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); if (i2s->regmap && !IS_ERR(i2s->regmap)) { regmap_write(i2s->regmap, XTFPGA_I2S_CONFIG, 0); regmap_write(i2s->regmap, XTFPGA_I2S_INT_MASK, 0); diff --git a/sound/sound_core.c b/sound/sound_core.c index 99b73c675743..b4efb22db561 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -119,13 +119,6 @@ struct sound_unit char name[32]; }; -#ifdef CONFIG_SOUND_MSNDCLAS -extern int msnd_classic_init(void); -#endif -#ifdef CONFIG_SOUND_MSNDPIN -extern int msnd_pinnacle_init(void); -#endif - /* * By default, OSS sound_core claims full legacy minor range (0-255) * of SOUND_MAJOR to trap open attempts to any sound minor and @@ -452,26 +445,6 @@ int register_sound_mixer(const struct file_operations *fops, int dev) EXPORT_SYMBOL(register_sound_mixer); -/** - * register_sound_midi - register a midi device - * @fops: File operations for the driver - * @dev: Unit number to allocate - * - * Allocate a midi device. Unit is the number of the midi device requested. - * Pass -1 to request the next free midi unit. - * - * Return: On success, the allocated number is returned. On failure, - * a negative error code is returned. - */ - -int register_sound_midi(const struct file_operations *fops, int dev) -{ - return sound_insert_unit(&chains[2], fops, dev, 2, 130, - "midi", S_IRUSR | S_IWUSR, NULL); -} - -EXPORT_SYMBOL(register_sound_midi); - /* * DSP's are registered as a triple. Register only one and cheat * in open - see below. @@ -533,21 +506,6 @@ void unregister_sound_mixer(int unit) EXPORT_SYMBOL(unregister_sound_mixer); /** - * unregister_sound_midi - unregister a midi device - * @unit: unit number to allocate - * - * Release a sound device that was allocated with register_sound_midi(). - * The unit passed is the return value from the register function. - */ - -void unregister_sound_midi(int unit) -{ - sound_remove_unit(&chains[2], unit); -} - -EXPORT_SYMBOL(unregister_sound_midi); - -/** * unregister_sound_dsp - unregister a DSP device * @unit: unit number to allocate * diff --git a/sound/usb/card.c b/sound/usb/card.c index 23d1d23aefec..8018d56cfecc 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -585,15 +585,24 @@ static int usb_audio_probe(struct usb_interface *intf, * now look for an empty slot and create a new card instance */ for (i = 0; i < SNDRV_CARDS; i++) - if (enable[i] && ! usb_chip[i] && + if (!usb_chip[i] && (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) && (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) { - err = snd_usb_audio_create(intf, dev, i, quirk, - id, &chip); - if (err < 0) + if (enable[i]) { + err = snd_usb_audio_create(intf, dev, i, quirk, + id, &chip); + if (err < 0) + goto __error; + chip->pm_intf = intf; + break; + } else if (vid[i] != -1 || pid[i] != -1) { + dev_info(&dev->dev, + "device (%04x:%04x) is disabled\n", + USB_ID_VENDOR(id), + USB_ID_PRODUCT(id)); + err = -ENOENT; goto __error; - chip->pm_intf = intf; - break; + } } if (!chip) { dev_err(&dev->dev, "no available usb audio device\n"); diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 2b4ceda36291..9afb8ab524c7 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -656,10 +656,14 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm unsigned char *name, int maxlen, int term_only) { struct iterm_name_combo *names; + int len; - if (iterm->name) - return snd_usb_copy_string_desc(state, iterm->name, + if (iterm->name) { + len = snd_usb_copy_string_desc(state, iterm->name, name, maxlen); + if (len) + return len; + } /* virtual type - not a real terminal */ if (iterm->type >> 16) { diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index e1e7ce9ab217..56537a156580 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -27,6 +27,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <linux/hid.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/usb.h> @@ -239,13 +240,13 @@ static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, return err < 0 ? err : count; } -static unsigned int snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file, +static __poll_t snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) { struct usb_mixer_interface *mixer = hw->private_data; poll_wait(file, &mixer->rc_waitq, wait); - return mixer->rc_code ? POLLIN | POLLRDNORM : 0; + return mixer->rc_code ? EPOLLIN | EPOLLRDNORM : 0; } static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) @@ -1721,6 +1722,83 @@ static int snd_microii_controls_create(struct usb_mixer_interface *mixer) return 0; } +/* Creative Sound Blaster E1 */ + +static int snd_soundblaster_e1_switch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = kcontrol->private_value; + return 0; +} + +static int snd_soundblaster_e1_switch_update(struct usb_mixer_interface *mixer, + unsigned char state) +{ + struct snd_usb_audio *chip = mixer->chip; + int err; + unsigned char buff[2]; + + buff[0] = 0x02; + buff[1] = state ? 0x02 : 0x00; + + err = snd_usb_lock_shutdown(chip); + if (err < 0) + return err; + err = snd_usb_ctl_msg(chip->dev, + usb_sndctrlpipe(chip->dev, 0), HID_REQ_SET_REPORT, + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, + 0x0202, 3, buff, 2); + snd_usb_unlock_shutdown(chip); + return err; +} + +static int snd_soundblaster_e1_switch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol); + unsigned char value = !!ucontrol->value.integer.value[0]; + int err; + + if (kcontrol->private_value == value) + return 0; + kcontrol->private_value = value; + err = snd_soundblaster_e1_switch_update(list->mixer, value); + return err < 0 ? err : 1; +} + +static int snd_soundblaster_e1_switch_resume(struct usb_mixer_elem_list *list) +{ + return snd_soundblaster_e1_switch_update(list->mixer, + list->kctl->private_value); +} + +static int snd_soundblaster_e1_switch_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static const char *const texts[2] = { + "Mic", "Aux" + }; + + return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts); +} + +static struct snd_kcontrol_new snd_soundblaster_e1_input_switch = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Input Source", + .info = snd_soundblaster_e1_switch_info, + .get = snd_soundblaster_e1_switch_get, + .put = snd_soundblaster_e1_switch_put, + .private_value = 0, +}; + +static int snd_soundblaster_e1_switch_create(struct usb_mixer_interface *mixer) +{ + return add_single_ctl_with_resume(mixer, 0, + snd_soundblaster_e1_switch_resume, + &snd_soundblaster_e1_input_switch, + NULL); +} + int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) { int err = 0; @@ -1802,6 +1880,10 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) case USB_ID(0x1235, 0x800c): /* Focusrite Scarlett 18i20 */ err = snd_scarlett_controls_create(mixer); break; + + case USB_ID(0x041e, 0x323b): /* Creative Sound Blaster E1 */ + err = snd_soundblaster_e1_switch_create(mixer); + break; } return err; diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index 8a59d4782a0f..50252046b01d 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -3277,4 +3277,52 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), } }, +{ + /* + * Nura's first gen headphones use Cambridge Silicon Radio's vendor + * ID, but it looks like the product ID actually is only for Nura. + * The capture interface does not work at all (even on Windows), + * and only the 48 kHz sample rate works for the playback interface. + */ + USB_DEVICE(0x0a12, 0x1243), + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { + .ifnum = QUIRK_ANY_INTERFACE, + .type = QUIRK_COMPOSITE, + .data = (const struct snd_usb_audio_quirk[]) { + { + .ifnum = 0, + .type = QUIRK_AUDIO_STANDARD_MIXER, + }, + /* Capture */ + { + .ifnum = 1, + .type = QUIRK_IGNORE_INTERFACE, + }, + /* Playback */ + { + .ifnum = 2, + .type = QUIRK_AUDIO_FIXED_ENDPOINT, + .data = &(const struct audioformat) { + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels = 2, + .iface = 2, + .altsetting = 1, + .altset_idx = 1, + .attributes = UAC_EP_CS_ATTR_FILL_MAX | + UAC_EP_CS_ATTR_SAMPLE_RATE, + .endpoint = 0x03, + .ep_attr = USB_ENDPOINT_XFER_ISOC, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .nr_rates = 1, + .rate_table = (unsigned int[]) { + 48000 + } + } + }, + } + } +}, + #undef USB_DEVICE_VENDOR_SPEC diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 159da1f3924e..ebcab5c5465d 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -271,16 +271,16 @@ out: return err; } -static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw, +static __poll_t usb_stream_hwdep_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) { struct us122l *us122l = hw->private_data; unsigned *polled; - unsigned int mask; + __poll_t mask; poll_wait(file, &us122l->sk.sleep, wait); - mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR; + mask = EPOLLIN | EPOLLOUT | EPOLLWRNORM | EPOLLERR; if (mutex_trylock(&us122l->mutex)) { struct usb_stream *s = us122l->sk.s; if (s && s->state == usb_stream_ready) { @@ -290,7 +290,7 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw, polled = &us122l->second_periods_polled; if (*polled != s->periods_done) { *polled = s->periods_done; - mask = POLLIN | POLLOUT | POLLWRNORM; + mask = EPOLLIN | EPOLLOUT | EPOLLWRNORM; } else mask = 0; } @@ -378,7 +378,7 @@ out: static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned cmd, unsigned long arg) { - struct usb_stream_config *cfg; + struct usb_stream_config cfg; struct us122l *us122l = hw->private_data; struct usb_stream *s; unsigned min_period_frames; @@ -388,24 +388,21 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) return -ENOTTY; - cfg = memdup_user((void *)arg, sizeof(*cfg)); - if (IS_ERR(cfg)) - return PTR_ERR(cfg); + if (copy_from_user(&cfg, (void __user *)arg, sizeof(cfg))) + return -EFAULT; + + if (cfg.version != USB_STREAM_INTERFACE_VERSION) + return -ENXIO; - if (cfg->version != USB_STREAM_INTERFACE_VERSION) { - err = -ENXIO; - goto free; - } high_speed = us122l->dev->speed == USB_SPEED_HIGH; - if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 && + if ((cfg.sample_rate != 44100 && cfg.sample_rate != 48000 && (!high_speed || - (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) || - cfg->frame_size != 6 || - cfg->period_frames > 0x3000) { - err = -EINVAL; - goto free; - } - switch (cfg->sample_rate) { + (cfg.sample_rate != 88200 && cfg.sample_rate != 96000))) || + cfg.frame_size != 6 || + cfg.period_frames > 0x3000) + return -EINVAL; + + switch (cfg.sample_rate) { case 44100: min_period_frames = 48; break; @@ -418,10 +415,8 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, } if (!high_speed) min_period_frames <<= 1; - if (cfg->period_frames < min_period_frames) { - err = -EINVAL; - goto free; - } + if (cfg.period_frames < min_period_frames) + return -EINVAL; snd_power_wait(hw->card, SNDRV_CTL_POWER_D0); @@ -430,24 +425,22 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, if (!us122l->master) us122l->master = file; else if (us122l->master != file) { - if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg))) { + if (!s || memcmp(&cfg, &s->cfg, sizeof(cfg))) { err = -EIO; goto unlock; } us122l->slave = file; } - if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg)) || + if (!s || memcmp(&cfg, &s->cfg, sizeof(cfg)) || s->state == usb_stream_xrun) { us122l_stop(us122l); - if (!us122l_start(us122l, cfg->sample_rate, cfg->period_frames)) + if (!us122l_start(us122l, cfg.sample_rate, cfg.period_frames)) err = -EIO; else err = 1; } unlock: mutex_unlock(&us122l->mutex); -free: - kfree(cfg); wake_up_all(&us122l->sk.sleep); return err; } diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index f4b3cda412fc..d8bd7c99b48c 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -86,18 +86,18 @@ static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct v return 0; } -static unsigned int snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) +static __poll_t snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) { - unsigned int mask = 0; + __poll_t mask = 0; struct usX2Ydev *us428 = hw->private_data; struct us428ctls_sharedmem *shm = us428->us428ctls_sharedmem; if (us428->chip_status & USX2Y_STAT_CHIP_HUP) - return POLLHUP; + return EPOLLHUP; poll_wait(file, &us428->us428ctls_wait_queue_head, wait); if (shm != NULL && shm->CtlSnapShotLast != shm->CtlSnapShotRed) - mask |= POLLIN; + mask |= EPOLLIN; return mask; } @@ -198,24 +198,22 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, struct snd_hwdep_dsp_image *dsp) { struct usX2Ydev *priv = hw->private_data; - int lret, err = -EINVAL; - snd_printdd( "dsp_load %s\n", dsp->name); + struct usb_device* dev = priv->dev; + int lret, err; + char *buf; - if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { - struct usb_device* dev = priv->dev; - char *buf; + snd_printdd( "dsp_load %s\n", dsp->name); - buf = memdup_user(dsp->image, dsp->length); - if (IS_ERR(buf)) - return PTR_ERR(buf); + buf = memdup_user(dsp->image, dsp->length); + if (IS_ERR(buf)) + return PTR_ERR(buf); - err = usb_set_interface(dev, 0, 1); - if (err) - snd_printk(KERN_ERR "usb_set_interface error \n"); - else - err = usb_bulk_msg(dev, usb_sndbulkpipe(dev, 2), buf, dsp->length, &lret, 6000); - kfree(buf); - } + err = usb_set_interface(dev, 0, 1); + if (err) + snd_printk(KERN_ERR "usb_set_interface error \n"); + else + err = usb_bulk_msg(dev, usb_sndbulkpipe(dev, 2), buf, dsp->length, &lret, 6000); + kfree(buf); if (err) return err; if (dsp->index == 1) { |