staging: ALSA PCM API updates
Subsystems (4)
cover 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(-)
Signature · 1 line
2.16.4
PATCH 1/4 staging: most: Use managed buffer allocation
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.
--- drivers/staging/most/sound/sound.c | 44 +------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-)
drivers/staging/most/sound/sound.c +1 -43
@@ -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 ;
Signature · 1 line
2.16.4
PATCH 2/4 staging: bcm2835-audio: Use managed buffer allocation
In reply to Takashi IwaiClean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and dropped.
--- .../staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +1 -16
@@ -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)
Signature · 1 line
2.16.4
Re: [PATCH for-5.6 2/4] staging: bcm2835-audio: Use managed buffer allocation
Quoted 4 lines · Takashi Iwai
Clean up the driver with the new managed buffer allocation API. The
hw_paramsandhw_freecallbacks became superfluous and dropped.Signed-off-by Takashi Iwai <[email protected]>
Thanks!
PATCH 3/4 staging: most: Drop superfluous ioctl PCM ops
In reply to Takashi IwaiPCM core deals the empty ioctl field now as default. Let's kill the redundant lines.
--- drivers/staging/most/sound/sound.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/most/sound/sound.c +0 -1
@@ -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,
Signature · 1 line
2.16.4
PATCH 4/4 staging: bcm2835-audio: Drop superfluous ioctl PCM ops
In reply to Takashi IwaiPCM core deals the empty ioctl field now as default. Let's kill the redundant lines.
--- drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +0 -2
@@ -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,
Signature · 1 line
2.16.4
Re: [PATCH for-5.6 4/4] staging: bcm2835-audio: Drop superfluous ioctl PCM ops
Quoted 4 lines · Takashi Iwai
PCM core deals the empty ioctl field now as default. Let's kill the redundant lines.
Signed-off-by Takashi Iwai <[email protected]>
Thanks!
Greg Kroah-Hartman
maintainerQuoted 9 lines · Takashi Iwai
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