[PATCH v6 4/9] ALSA: virtio: build PCM devices and substream hardware descriptors

Takashi Iwai tiwai at suse.de
Sun Feb 28 12:15:27 CET 2021


On Sat, 27 Feb 2021 09:59:51 +0100,
Anton Yakovlev wrote:
> +static int virtsnd_pcm_build_hw(struct virtio_pcm_substream *vss,
> +				struct virtio_snd_pcm_info *info)
> +{
....
> +	for (i = 0; i < ARRAY_SIZE(g_v2a_format_map); ++i)
> +		if (values & (1ULL << i)) {
> +			snd_pcm_format_t alsa_fmt = g_v2a_format_map[i];
> +			int bytes = snd_pcm_format_physical_width(alsa_fmt) / 8;
> +
> +			if (!sample_min || sample_min > bytes)
> +				sample_min = bytes;
> +
> +			if (sample_max < bytes)
> +				sample_max = bytes;
> +
> +			vss->hw.formats |= (1ULL << (__force int)alsa_fmt);

Please use pcm_format_to_bits().

> +	/* Align the buffer size to the page size */
> +	vss->hw.buffer_bytes_max =
> +		(vss->hw.buffer_bytes_max + PAGE_SIZE - 1) & -PAGE_SIZE;

You can use PAGE_ALIGN() macro.


thanks,

Takashi


More information about the Alsa-devel mailing list