Commit 8079c5d5 authored by Takashi Iwai's avatar Takashi Iwai Committed by Mauro Carvalho Chehab
Browse files

media: usbtv: Use managed buffer allocation



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: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 5e625dd5
Loading
Loading
Loading
Loading
+1 −27
Original line number Diff line number Diff line
@@ -85,30 +85,6 @@ static int snd_usbtv_pcm_close(struct snd_pcm_substream *substream)
	return 0;
}

static int snd_usbtv_hw_params(struct snd_pcm_substream *substream,
		struct snd_pcm_hw_params *hw_params)
{
	int rv;
	struct usbtv *chip = snd_pcm_substream_chip(substream);

	rv = snd_pcm_lib_malloc_pages(substream,
		params_buffer_bytes(hw_params));

	if (rv < 0) {
		dev_warn(chip->dev, "pcm audio buffer allocation failure %i\n",
			rv);
		return rv;
	}

	return 0;
}

static int snd_usbtv_hw_free(struct snd_pcm_substream *substream)
{
	snd_pcm_lib_free_pages(substream);
	return 0;
}

static int snd_usbtv_prepare(struct snd_pcm_substream *substream)
{
	struct usbtv *chip = snd_pcm_substream_chip(substream);
@@ -337,8 +313,6 @@ static const struct snd_pcm_ops snd_usbtv_pcm_ops = {
	.open = snd_usbtv_pcm_open,
	.close = snd_usbtv_pcm_close,
	.ioctl = snd_pcm_lib_ioctl,
	.hw_params = snd_usbtv_hw_params,
	.hw_free = snd_usbtv_hw_free,
	.prepare = snd_usbtv_prepare,
	.trigger = snd_usbtv_card_trigger,
	.pointer = snd_usbtv_pointer,
@@ -377,7 +351,7 @@ int usbtv_audio_init(struct usbtv *usbtv)
	pcm->private_data = usbtv;

	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usbtv_pcm_ops);
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
	snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
		NULL, USBTV_AUDIO_BUFFER, USBTV_AUDIO_BUFFER);

	rv = snd_card_register(card);