mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
ALSA: 6fire: add a playback channel map
The driver registers no "Playback Channel Map" control, so a program that needs the speaker position of each playback channel has to assume an order; speaker-test, for example, assumes FL FR RL RR FC LFE for 6 channels. Channel n of the PCM goes to Line Out n, and the manual of the card assigns Line Out 1 to 6 to front left and right, centre and subwoofer, and rear left and right. Add a playback channel map in the order of the manual, FL FR FC LFE RL RR. A stream with 2 to 5 channels gets the first positions of the list. A 1-channel stream gets MONO, as in every 1-channel entry of a channel map in sound/; the card plays it on Line Out 1 only. The map has an entry for every channel count from 1 to 6, because reading the control fails with -EINVAL for a count without an entry. Tested on a DMX 6Fire USB with kernel 7.2.10: during playback with 1, 3, 5 and 6 channels the control reads MONO, FL FR FC, FL FR FC LFE RL and FL FR FC LFE RL RR, and the "Front Center" test of speaker-test -c 6 played on Line Out 3. Assisted-by: LLM Signed-off-by: Piotr Gliźniewicz <p.glizniewicz@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20261016073132.109288-3-p.glizniewicz@gmail.com
This commit is contained in:
parent
d030561d53
commit
a050fabb16
|
|
@ -612,6 +612,28 @@ static void usb6fire_pcm_free(struct pcm_runtime *rt)
|
|||
kfree(rt);
|
||||
}
|
||||
|
||||
/*
|
||||
* playback channel map: channel n goes to analog output n, which the
|
||||
* manual of the card assigns to FL FR FC LFE RL RR for n = 1..6; a
|
||||
* 1-channel stream is MONO, as in snd_pcm_std_chmaps, and plays on
|
||||
* analog output 1 only
|
||||
*/
|
||||
static const struct snd_pcm_chmap_elem usb6fire_pcm_chmaps[] = {
|
||||
{ .channels = 1, .map = { SNDRV_CHMAP_MONO } },
|
||||
{ .channels = 2, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
|
||||
{ .channels = 3, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
|
||||
SNDRV_CHMAP_FC } },
|
||||
{ .channels = 4, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
|
||||
SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE } },
|
||||
{ .channels = 5, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
|
||||
SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE,
|
||||
SNDRV_CHMAP_RL } },
|
||||
{ .channels = 6, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
|
||||
SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE,
|
||||
SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } },
|
||||
{ }
|
||||
};
|
||||
|
||||
int usb6fire_pcm_init(struct sfire_chip *chip)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -665,6 +687,14 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
|
|||
rt->instance = pcm;
|
||||
|
||||
chip->pcm = rt;
|
||||
|
||||
/* on error, rt is freed with the card */
|
||||
ret = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
|
||||
usb6fire_pcm_chmaps, OUT_N_CHANNELS, 0, NULL);
|
||||
if (ret < 0) {
|
||||
dev_err(&chip->dev->dev, "cannot add channel map.\n");
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user