Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74c34ca1 authored by Eldad Zack's avatar Eldad Zack Committed by Takashi Iwai
Browse files

ALSA: pcm_format_to_bits strong-typed conversion



Add a function to handle conversion from snd_pcm_format_t
to bitwise with proper typing.

Change such conversions to use this function and silence sparse
warnings.

Signed-off-by: default avatarEldad Zack <eldad@fogrefinery.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 75481347
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1133,4 +1133,10 @@ int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream,
			   unsigned long private_value,
			   struct snd_pcm_chmap **info_ret);

/* Strong-typed conversion of pcm_format to bitwise */
static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
{
	return 1ULL << (__force int) pcm_format;
}

#endif /* __SOUND_PCM_H */
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ static int i2sbus_pcm_open(struct i2sbus_dev *i2sdev, int in)
	 */
	if (other->active) {
		/* FIXME: is this guaranteed by the alsa api? */
		hw->formats &= (1ULL << i2sdev->format);
		hw->formats &= pcm_format_to_bits(i2sdev->format);
		/* see above, restrict rates to the one we already have */
		hw->rate_min = i2sdev->rate;
		hw->rate_max = i2sdev->rate;
+2 −2
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ static int atmel_ac97c_playback_open(struct snd_pcm_substream *substream)
		runtime->hw.rate_max = chip->cur_rate;
	}
	if (chip->cur_format)
		runtime->hw.formats = (1ULL << chip->cur_format);
		runtime->hw.formats = pcm_format_to_bits(chip->cur_format);
	mutex_unlock(&opened_mutex);
	chip->playback_substream = substream;
	return 0;
@@ -201,7 +201,7 @@ static int atmel_ac97c_capture_open(struct snd_pcm_substream *substream)
		runtime->hw.rate_max = chip->cur_rate;
	}
	if (chip->cur_format)
		runtime->hw.formats = (1ULL << chip->cur_format);
		runtime->hw.formats = pcm_format_to_bits(chip->cur_format);
	mutex_unlock(&opened_mutex);
	chip->capture_substream = substream;
	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ static void params_change(struct snd_pcm_substream *substream)
	struct loopback_pcm *dpcm = runtime->private_data;
	struct loopback_cable *cable = dpcm->cable;

	cable->hw.formats = (1ULL << runtime->format);
	cable->hw.formats = pcm_format_to_bits(runtime->format);
	cable->hw.rate_min = runtime->rate;
	cable->hw.rate_max = runtime->rate;
	cable->hw.channels_min = runtime->channels;
+2 −2
Original line number Diff line number Diff line
@@ -966,7 +966,7 @@ static u64 snd_card_asihpi_playback_formats(struct snd_card_asihpi *asihpi,
		if (!err)
			err = hpi_outstream_query_format(h_stream, &hpi_format);
		if (!err && (hpi_to_alsa_formats[format] != -1))
			formats |= (1ULL << hpi_to_alsa_formats[format]);
			formats |= pcm_format_to_bits(hpi_to_alsa_formats[format]);
	}
	return formats;
}
@@ -1142,7 +1142,7 @@ static u64 snd_card_asihpi_capture_formats(struct snd_card_asihpi *asihpi,
		if (!err)
			err = hpi_instream_query_format(h_stream, &hpi_format);
		if (!err)
			formats |= (1ULL << hpi_to_alsa_formats[format]);
			formats |= pcm_format_to_bits(hpi_to_alsa_formats[format]);
	}
	return formats;
}
Loading