From a050fabb16a5529a83e9d461b99056ae48761f5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Gli=C5=BAniewicz?=
Date: Fri, 16 Oct 2026 09:31:31 +0200
Subject: [PATCH] ALSA: 6fire: add a playback channel map
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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
Signed-off-by: Takashi Iwai
Link: https://patch.msgid.link/20261016073132.109288-3-p.glizniewicz@gmail.com
---
sound/usb/6fire/pcm.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index 0285d79ace0f..d99395229eb2 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -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: