[alsa-devel] [PATCH for-5.6 0/4] staging: ALSA PCM API updates
Hi,
this is a patch set to adapt the latest ALSA PCM API to staging drivers. Basically these are merely cleanups, as shown in diffstat, and there should be no functional changes.
As the corresponding ALSA PCM API change is found in 5.5-rc1, please apply these on 5.5-rc1 or later. Or if you prefer, I can merge them through sound tree, too. Let me know.
thanks,
Takashi
===
Takashi Iwai (4): staging: most: Use managed buffer allocation staging: bcm2835-audio: Use managed buffer allocation staging: most: Drop superfluous ioctl PCM ops staging: bcm2835-audio: Drop superfluous ioctl PCM ops
drivers/staging/most/sound/sound.c | 45 +--------------------- .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 19 +-------- 2 files changed, 2 insertions(+), 62 deletions(-)
Clean up the driver with the new managed buffer allocation API. Also remove the unnecessary checks of channels in hw_params callback as this is guaranteed by the hw constraints in anyway. After these cleanups, the hw_params and hw_free callbacks became empty, hence dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- drivers/staging/most/sound/sound.c | 44 +------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-)
diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 723d0bd1cc21..7c212c0db980 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -322,45 +322,6 @@ static int pcm_close(struct snd_pcm_substream *substream) return 0; }
-/** - * pcm_hw_params - implements hw_params callback function for PCM middle layer - * @substream: sub-stream pointer - * @hw_params: contains the hardware parameters set by the application - * - * This is called when the hardware parameters is set by the application, that - * is, once when the buffer size, the period size, the format, etc. are defined - * for the PCM substream. Many hardware setups should be done is this callback, - * including the allocation of buffers. - * - * Returns 0 on success or error code otherwise. - */ -static int pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - struct channel *channel = substream->private_data; - - if ((params_channels(hw_params) > channel->pcm_hardware.channels_max) || - (params_channels(hw_params) < channel->pcm_hardware.channels_min)) { - pr_err("Requested number of channels not supported.\n"); - return -EINVAL; - } - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -/** - * pcm_hw_free - implements hw_free callback function for PCM middle layer - * @substream: substream pointer - * - * This is called to release the resources allocated via hw_params. - * This function will be always called before the close callback is called. - * - * Returns 0 on success or error code otherwise. - */ -static int pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /** * pcm_prepare - implements prepare callback function for PCM middle layer * @substream: substream pointer @@ -463,8 +424,6 @@ static const struct snd_pcm_ops pcm_ops = { .open = pcm_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = pcm_hw_params, - .hw_free = pcm_hw_free, .prepare = pcm_prepare, .trigger = pcm_trigger, .pointer = pcm_pointer, @@ -661,8 +620,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, pcm->private_data = channel; strscpy(pcm->name, device_name, sizeof(pcm->name)); snd_pcm_set_ops(pcm, direction, &pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0;
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- .../staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c index 826016c3431a..97726b190bc5 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c @@ -193,17 +193,6 @@ static int snd_bcm2835_playback_close(struct snd_pcm_substream *substream) return 0; }
-static int snd_bcm2835_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); -} - -static int snd_bcm2835_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream) { struct bcm2835_chip *chip = snd_pcm_substream_chip(substream); @@ -317,8 +306,6 @@ static const struct snd_pcm_ops snd_bcm2835_playback_ops = { .open = snd_bcm2835_playback_open, .close = snd_bcm2835_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_bcm2835_pcm_hw_params, - .hw_free = snd_bcm2835_pcm_hw_free, .prepare = snd_bcm2835_pcm_prepare, .trigger = snd_bcm2835_pcm_trigger, .pointer = snd_bcm2835_pcm_pointer, @@ -329,8 +316,6 @@ static const struct snd_pcm_ops snd_bcm2835_playback_spdif_ops = { .open = snd_bcm2835_playback_spdif_open, .close = snd_bcm2835_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_bcm2835_pcm_hw_params, - .hw_free = snd_bcm2835_pcm_hw_free, .prepare = snd_bcm2835_pcm_prepare, .trigger = snd_bcm2835_pcm_trigger, .pointer = snd_bcm2835_pcm_pointer, @@ -362,7 +347,7 @@ int snd_bcm2835_new_pcm(struct bcm2835_chip *chip, const char *name, spdif ? &snd_bcm2835_playback_spdif_ops : &snd_bcm2835_playback_ops);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev, 128 * 1024, 128 * 1024);
if (spdif)
On Tue, 2019-12-10 at 15:13 +0100, Takashi Iwai wrote:
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de
Reviewed-by: Nicolas Saenz Julienne nsaenzjulienne@suse.de
Thanks!
PCM core deals the empty ioctl field now as default. Let's kill the redundant lines.
Signed-off-by: Takashi Iwai tiwai@suse.de --- drivers/staging/most/sound/sound.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 7c212c0db980..1ccfcb8f78b9 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -423,7 +423,6 @@ static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops pcm_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = pcm_prepare, .trigger = pcm_trigger, .pointer = pcm_pointer,
PCM core deals the empty ioctl field now as default. Let's kill the redundant lines.
Signed-off-by: Takashi Iwai tiwai@suse.de --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c index 97726b190bc5..33485184a98a 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c @@ -305,7 +305,6 @@ snd_bcm2835_pcm_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_bcm2835_playback_ops = { .open = snd_bcm2835_playback_open, .close = snd_bcm2835_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_bcm2835_pcm_prepare, .trigger = snd_bcm2835_pcm_trigger, .pointer = snd_bcm2835_pcm_pointer, @@ -315,7 +314,6 @@ static const struct snd_pcm_ops snd_bcm2835_playback_ops = { static const struct snd_pcm_ops snd_bcm2835_playback_spdif_ops = { .open = snd_bcm2835_playback_spdif_open, .close = snd_bcm2835_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_bcm2835_pcm_prepare, .trigger = snd_bcm2835_pcm_trigger, .pointer = snd_bcm2835_pcm_pointer,
On Tue, 2019-12-10 at 15:13 +0100, Takashi Iwai wrote:
PCM core deals the empty ioctl field now as default. Let's kill the redundant lines.
Signed-off-by: Takashi Iwai tiwai@suse.de
Reviewed-by: Nicolas Saenz Julienne nsaenzjulienne@suse.de
Thanks!
On Tue, Dec 10, 2019 at 03:13:52PM +0100, Takashi Iwai wrote:
Hi,
this is a patch set to adapt the latest ALSA PCM API to staging drivers. Basically these are merely cleanups, as shown in diffstat, and there should be no functional changes.
As the corresponding ALSA PCM API change is found in 5.5-rc1, please apply these on 5.5-rc1 or later. Or if you prefer, I can merge them through sound tree, too. Let me know.
Because of some future most driver changes that will be happening (hopefully soon), I'll just take all of these in the staging tree now, thanks!
greg k-h
participants (3)
-
Greg Kroah-Hartman
-
Nicolas Saenz Julienne
-
Takashi Iwai