Index: uspace/drv/audio/sb16/mixer.c
===================================================================
--- uspace/drv/audio/sb16/mixer.c	(revision a68e5e23415d46f58fc8a62ef658897552e645e8)
+++ uspace/drv/audio/sb16/mixer.c	(revision 3df0f750d5542c7d884412d96aff44b1dca293ea)
@@ -35,4 +35,5 @@
 
 typedef struct channel {
+	const char *name;
 	uint8_t address;
 	unsigned shift;
@@ -49,47 +50,47 @@
 /* CT1335 channels */
 static const channel_t channels_table_ct1335[] = {
-	{ 0x02, 1, 8, false }, /* Master, Mono, 3bit volume level */
-	{ 0x06, 1, 8, false }, /* Midi, Mono, 3bit volume level */
-	{ 0x08, 1, 8, false }, /* CD, Mono, 3bit volume level */
-	{ 0x0a, 1, 4, false }, /* Voice, Mono, 2bit volume level */
+	{ "", 0x02, 1, 8, false }, /* Master, Mono, 3bit volume level */
+	{ "", 0x06, 1, 8, false }, /* Midi, Mono, 3bit volume level */
+	{ "", 0x08, 1, 8, false }, /* CD, Mono, 3bit volume level */
+	{ "", 0x0a, 1, 4, false }, /* Voice, Mono, 2bit volume level */
 };
 
 /* CT1345 channels */
 static const channel_t channels_table_ct1345[] = {
-	{ 0x22, 5, 8, true }, /* Master, Left, 3bit volume level */
-	{ 0x22, 1, 8, true }, /* Master, Right, 3bit volume level */
-	{ 0x26, 5, 8, true }, /* Midi, Left, 3bit volume level */
-	{ 0x26, 1, 8, true }, /* Midi, Right, 3bit volume level */
-	{ 0x28, 5, 8, true }, /* CD, Left, 3bit volume level */
-	{ 0x28, 1, 8, true }, /* CD, Right, 3bit volume level */
-	{ 0x2e, 5, 8, true }, /* Line, Left, 3bit volume level */
-	{ 0x2e, 1, 8, true }, /* Line, Right, 3bit volume level */
-	{ 0x04, 5, 8, true }, /* Voice, Left, 3bit volume level */
-	{ 0x04, 1, 8, true }, /* Voice, Right, 3bit volume level */
-	{ 0x0a, 1, 4, false }, /* Mic, Mono, 2bit volume level */
+	{ "Left", 0x22, 5, 8, true }, /* Master, Left, 3bit volume level */
+	{ "Right", 0x22, 1, 8, true }, /* Master, Right, 3bit volume level */
+	{ "Left", 0x26, 5, 8, true }, /* Midi, Left, 3bit volume level */
+	{ "Right", 0x26, 1, 8, true }, /* Midi, Right, 3bit volume level */
+	{ "Left", 0x28, 5, 8, true }, /* CD, Left, 3bit volume level */
+	{ "Right", 0x28, 1, 8, true }, /* CD, Right, 3bit volume level */
+	{ "Left", 0x2e, 5, 8, true }, /* Line, Left, 3bit volume level */
+	{ "Right", 0x2e, 1, 8, true }, /* Line, Right, 3bit volume level */
+	{ "Left", 0x04, 5, 8, true }, /* Voice, Left, 3bit volume level */
+	{ "Right", 0x04, 1, 8, true }, /* Voice, Right, 3bit volume level */
+	{ "", 0x0a, 1, 4, false }, /* Mic, Mono, 2bit volume level */
 };
 
 /* CT1745 channels */
 static const channel_t channels_table_ct1745[] = {
-	{ 0x30, 3, 32, false }, /* Master, Left, 5bit volume level */
-	{ 0x31, 3, 32, false }, /* Master, Right, 5bit volume level */
-	{ 0x32, 3, 32, false }, /* Voice, Left, 5bit volume level */
-	{ 0x33, 3, 32, false }, /* Voice, Right, 5bit volume level */
-	{ 0x34, 3, 32, false }, /* MIDI, Left, 5bit volume level */
-	{ 0x35, 3, 32, false }, /* MIDI, Right, 5bit volume level */
-	{ 0x36, 3, 32, false }, /* CD, Left, 5bit volume level */
-	{ 0x37, 3, 32, false }, /* CD, Right, 5bit volume level */
-	{ 0x38, 3, 32, false }, /* Line, Left, 5bit volume level */
-	{ 0x39, 3, 32, false }, /* Line, Right, 5bit volume level */
-	{ 0x3a, 3, 32, false }, /* Mic, Mono, 5bit volume level */
-	{ 0x3b, 6, 4, false }, /* PC speaker, Mono, 2bit volume level */
-	{ 0x3f, 6, 4, false }, /* Input Gain, Left, 2bit volume level */
-	{ 0x40, 6, 4, false }, /* Input Gain, Right, 2bit volume level */
-	{ 0x41, 6, 4, false }, /* Output Gain, Left, 2bit volume level */
-	{ 0x42, 6, 4, false }, /* Output Gain, Right, 2bit volume level */
-	{ 0x44, 4, 16, false }, /* Treble, Left, 4bit volume level */
-	{ 0x45, 4, 16, false }, /* Treble, Right, 4bit volume level */
-	{ 0x46, 4, 16, false }, /* Bass, Left, 4bit volume level */
-	{ 0x47, 4, 16, false }, /* Bass, Right, 4bit volume level */
+	{ "Left", 0x30, 3, 32, false },  /* Master, Left, 5bit volume level */
+	{ "Right", 0x31, 3, 32, false }, /* Master, Right, 5bit volume level */
+	{ "Left", 0x32, 3, 32, false },  /* Voice, Left, 5bit volume level */
+	{ "Right", 0x33, 3, 32, false }, /* Voice, Right, 5bit volume level */
+	{ "Left", 0x34, 3, 32, false }, /* MIDI, Left, 5bit volume level */
+	{ "Right", 0x35, 3, 32, false }, /* MIDI, Right, 5bit volume level */
+	{ "Left", 0x36, 3, 32, false }, /* CD, Left, 5bit volume level */
+	{ "Right", 0x37, 3, 32, false }, /* CD, Right, 5bit volume level */
+	{ "Left", 0x38, 3, 32, false }, /* Line, Left, 5bit volume level */
+	{ "Right", 0x39, 3, 32, false }, /* Line, Right, 5bit volume level */
+	{ "", 0x3a, 3, 32, false }, /* Mic, Mono, 5bit volume level */
+	{ "", 0x3b, 6, 4, false }, /* PC speaker, Mono, 2bit level */
+	{ "Left", 0x3f, 6, 4, false }, /* Input Gain, Left, 2bit level */
+	{ "Right", 0x40, 6, 4, false }, /* Input Gain, Right, 2bit level */
+	{ "Left", 0x41, 6, 4, false }, /* Output Gain, Left, 2bit level */
+	{ "Right", 0x42, 6, 4, false }, /* Output Gain, Right, 2bit level */
+	{ "Left", 0x44, 4, 16, false }, /* Treble, Left, 4bit volume level */
+	{ "Right", 0x45, 4, 16, false }, /* Treble, Right, 4bit volume level */
+	{ "Left", 0x46, 4, 16, false }, /* Bass, Left, 4bit volume level */
+	{ "Right", 0x47, 4, 16, false }, /* Bass, Right, 4bit volume level */
 };
 
@@ -145,10 +146,17 @@
 		return;
 	const unsigned item = 0; /* 0 is Master. */
-	unsigned levels = 0, channels = 0, level;
+	unsigned  channels = 0;
 	const char *name = NULL;
 
-	sb_mixer_get_control_item_info(mixer, item, &name, &channels, &levels);
+	sb_mixer_get_control_item_info(mixer, item, &name, &channels);
 	for (unsigned channel = 0; channel < channels; ++channel) {
-		level = sb_mixer_get_volume_level(mixer, item, channel);
+		unsigned levels = 0;
+		const int ret = sb_mixer_get_channel_info(mixer, item, channel,
+		    NULL, &levels);
+		if (ret != EOK)
+			continue;
+
+		unsigned level =
+		    sb_mixer_get_volume_level(mixer, item, channel);
 		ddf_log_note("Setting %s channel %d to %d (%d).\n",
 		    name, channel, levels - 1, level);
@@ -201,5 +209,5 @@
 /*----------------------------------------------------------------------------*/
 int sb_mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned index,
-    const char** name, unsigned *channels, unsigned *levels)
+    const char** name, unsigned *channels)
 {
 	assert(mixer);
@@ -207,11 +215,28 @@
 		return ENOENT;
 
-	const volume_item_t item = volume_table[mixer->type].table[index];
+	const volume_item_t *item = &volume_table[mixer->type].table[index];
 	if (name)
-		*name = item.description;
+		*name = item->description;
 	if (channels)
-		*channels = item.channels;
+		*channels = item->channels;
+	return EOK;
+}
+/*----------------------------------------------------------------------------*/
+int sb_mixer_get_channel_info(const sb_mixer_t *mixer, unsigned index,
+    unsigned channel, const char **name, unsigned *levels)
+{
+	assert(mixer);
+	if (index > volume_table[mixer->type].count)
+		return ENOENT;
+
+	const volume_item_t *item = &volume_table[mixer->type].table[index];
+	if (channel > item->channels)
+		return ENOENT;
+
+	const channel_t *chan = &item->channel_table[channel];
+	if (name)
+		*name = chan->name;
 	if (levels)
-		*levels = item.channel_table[0].volume_levels;
+		*levels = chan->volume_levels;
 	return EOK;
 }
@@ -226,19 +251,20 @@
 	if (channel >= volume_table[mixer->type].table[index].channels)
 		return ENOENT;
-	const channel_t chan =
-	    volume_table[mixer->type].table[index].channel_table[channel];
-
-	if (level > chan.volume_levels)
-		level = chan.volume_levels;
-
-	pio_write_8(&mixer->regs->mixer_address, chan.address);
+
+	const channel_t *chan =
+	    &volume_table[mixer->type].table[index].channel_table[channel];
+
+	if (level > chan->volume_levels)
+		level = chan->volume_levels;
+
+	pio_write_8(&mixer->regs->mixer_address, chan->address);
+
 	uint8_t value = 0;
-
-	if (chan.preserve_bits) {
+	if (chan->preserve_bits) {
 		value = pio_read_8(&mixer->regs->mixer_data);
-		value &= ~(uint8_t)((chan.volume_levels - 1) << chan.shift);
+		value &= ~(uint8_t)((chan->volume_levels - 1) << chan->shift);
 	}
 
-	value |= level << chan.shift;
+	value |= level << chan->shift;
 	pio_write_8(&mixer->regs->mixer_data, value);
 	return EOK;
@@ -255,8 +281,9 @@
 		return 0;
 
-	const channel_t chan =
-	    volume_table[mixer->type].table[index].channel_table[channel];
-	pio_write_8(&mixer->regs->mixer_address, chan.address);
-	return (pio_read_8(&mixer->regs->mixer_data) >> chan.shift)
-	    & (chan.volume_levels - 1);
-}
+	const channel_t *chan =
+	    &volume_table[mixer->type].table[index].channel_table[channel];
+
+	pio_write_8(&mixer->regs->mixer_address, chan->address);
+	return (pio_read_8(&mixer->regs->mixer_data) >> chan->shift)
+	    & (chan->volume_levels - 1);
+}
