Skip to contentSkip to conversation

Notes on 1.0.8-rc1 (and post-rc1)

DISCUSSION Takashi Iwai 3 participants 5 messages Dec 27, 2004 – Jan 12, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

as you might have already noticed, ALSA 1.0.8-rc1 was released recently. Some major changes are listed below...

Drivers:

- ioctl32 fixes
The broken ioctl32 on 2.6 kernels is fixed.

- Hotplug support
vxpocket, vx222 and mixart can use hotplug to load firmware. The old mechanism is activated only when the fw loader is disabled on kernel.
echoaudio drivers (added after rc1) _require_ the kernel fw loader.

- Audigy2 Value support

- audigyls driver was renamed to ca0106
It supports SB Live 24bit, too

- Hwdep-PCM support on usb-usx2y (for JACK)

- Resume/suspend fixes

- New drivers: pcxhr, sun-dbri

- Fix OOps on vxpocket

- Fix invalid HDSP pointers

- Lots of cleanups

Lib:

- Suppress (some of) non-fatal error messages
See NOTES for details.

Utils:

- Improvements on alsamixer
See manpage.

Tools & firmware:

- Hotplug support (for vx and mixart)

And, after rc1 release, many changes have been applied to CVS. The below are some of them.

- Fix PPC OOps on OSS emulation

- Fix control device creation with udev

- AC97 code cleanups (including new quirk support)

- Addition of echoaudio drivers
(The drivers need the firmware loader support on kernel.)

- Experimental softvol PCM plugin

The last one may need a bit more explanation.
This plugin is for the boards equipped with codecs which have no volume controls (e.g. some c-media codecs). The plugin can add a new user-defined control and apply the volume attenuation.

The typical usage is like below:

pcm.svol {
	type softvol
	slave.pcm hw:0
	control {
		name "PCM Playback Volume"
	}
}

After you put this to ~/.asoundrc, run "aplay -Dsvol foo.wav". Then the PCM volume is created (if not exists yet). Note that the volume element will appear first after you run this softvol PCM. Don't forget to raise the volume.

For the practical use, the combination with dmix would make your life often easier. You can override the "default" PCM like below:

pcm.!default {
	type plug
	slave.pcm {
		type softvol
		slave.pcm dmix
		control {
			card hw:0
			name "PCM Playback Volume"
		}
	}
}

Caveats: the new control is not restored correctly with alsactl after reboot. This will be fixed in future. Also, note that softvol supports only S16 format.

Takashi

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/

#1 lore raw
Quoted 5 lines · Takashi Iwai

Hi,

as you might have already noticed, ALSA 1.0.8-rc1 was released recently. Some major changes are listed below...

I guess this simple one below is however still missing.

Quoted 7 lines · Karsten Wiese

Rui Nuno Capela wrote:
Hi,

While testing the new snd-usb-usx2y 0.8.7 hwdep pcm interface on my Tascam US-224, and feeding it via aplay -D hw:N,2 samefile.wav, I've come to face a couple of issues I would like to report here.

Quoted 6 lines

The first one is about a repeatable kernel crash happening on my SUSE 9.2 Pro box (P4/HT), but also on my Mdk 10.1 laptop (P4/UP), everytime I try to aplay against the hw:N,2 device (N=soundcard index). See below for the whole data and the proper oops dumps. As every kernel crash, the system is left in a very dangerous and unstable state, so that this particular issue should be addressed ASAP.

OK, that one is fixed by attached patch.
Takashi: Please apply with

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Summary: return -EBUSY from snd_usX2Y_usbpcm_open(),
if the associated hwdep device is not opened.

It now works as originally intended. Had forgotten a pair of parenthesis.

<<<<<<

Index: alsa-kernel/usb/usx2y/usbusx2y.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/usb/usx2y/usbusx2y.c,v retrieving revision 1.7

usb/usx2y/usbusx2y.c +5 -1
diff -U3 -r1.7 usbusx2y.c
@@ -1,6 +1,10 @@
 /*
  * usbusy2y.c - ALSA USB US-428 Driver
  *
+2004-12-14 Karsten Wiese
+	Version 0.8.7.1:
+	snd_pcm_open for rawusb pcm-devices now returns -EBUSY if called without rawusb's hwdep device being open.
+
 2004-12-02 Karsten Wiese
 	Version 0.8.7:
 	Use macro usb_maxpacket() for portability.
@@ -139,7 +143,7 @@
 
 
 MODULE_AUTHOR("Karsten Wiese <[email protected]>");
-MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.8.7");
+MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.8.7.1");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{TASCAM(0x1604), "NAME_ALLCAPS"(0x8001)(0x8005)(0x8007) }}");
 

Index: alsa-kernel/usb/usx2y/usx2yhwdeppcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/usb/usx2y/usx2yhwdeppcm.c,v retrieving revision 1.1

usb/usx2y/usx2yhwdeppcm.c +2 -2
diff -U3 -r1.1 usx2yhwdeppcm.c
@@ -22,7 +22,7 @@
  It provides the alsa kernel half of the usx2y-alsa-jack driver pair.
  The pair uses a hardware dependant alsa-device for mmaped pcm transport.
  Advantage achieved:
-         The usb_hcd places reads/writes pcm data into dma-memory.
+         The usb_hc moves pcm data from/into memory via DMA.
          That memory is mmaped by jack's usx2y driver.
          Jack's usx2y driver is the first/last to read/write pcm data.
          Read/write is a combination of power of 2 period shaping and
@@ -568,7 +568,7 @@
 					 snd_pcm_substream_chip(substream))[substream->stream];
 	snd_pcm_runtime_t	*runtime = substream->runtime;
 
-	if (!subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)
+	if (!(subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS))
 		return -EBUSY;
 
 	runtime->hw = SNDRV_PCM_STREAM_PLAYBACK == substream->stream ? snd_usX2Y_2c :
#2 lore raw

At Mon, 27 Dec 2004 21:44:10 -0000 (WET),

Quoted 9 lines · Rui Nuno Capela
Quoted 5 lines · Takashi Iwai

Hi,

as you might have already noticed, ALSA 1.0.8-rc1 was released recently. Some major changes are listed below...

I guess this simple one below is however still missing.

Thanks, now applied.

Takashi

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/

#3 lore raw
In reply to Takashi Iwai

Hello.

Quoted 16 lines · Takashi Iwai

- Experimental softvol PCM plugin
The last one may need a bit more explanation.
This plugin is for the boards equipped with codecs which have no volume controls (e.g. some c-media codecs). The plugin can add a new user-defined control and apply the volume attenuation.

The typical usage is like below:

pcm.svol {
	type softvol
	slave.pcm hw:0
	control {
		name "PCM Playback Volume"
	}
}
Quoted 4 lines

After you put this to ~/.asoundrc, run "aplay -Dsvol foo.wav". Then the PCM volume is created (if not exists yet). Note that the volume element will appear first after you run this softvol PCM. Don't forget to raise the volume.

A while back ago I had written a message about this and thought it was plainly ignored :) And so I dared to write some code myself and already have working implementation (with exception of control emulation itself).

Here is description of what I've made:

1. Volume pcm which have volume coefficient as a parameter.
2. Mixer hook which can push volume coefficient from specified mixer control element into given value (It does it in a way similar to watching control changes in alsamixer). This hook can be attached to volume pcm.

Configuration example

pcm.vol {
	type volume
	slave.pcm hw:0
	coeff 0.9
	hook {
		card default
		control Master
		index 0
	}
}

Explicitly specified coefficient and one provided by hook are multiplied before applying to samples. Input and output PCM formats must match (as for copy plugin).

These things are usable alone. For example you can adjust amplitude of PCM or tell Master_volume_control of one card to affect output of another :) But to completely cheat applications all this lacks some emulated volume control like described in quoted post above.

So I wonder if this code could be useful for alsa-lib? Perhaps it can
supplement softvol code? I would like it to be reviewed by anyone
who interested. (I'll send the path in few days.)

/Petr.

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

#4 lore raw

At Wed, 12 Jan 2005 11:51:14 +0600,

Quoted 24 lines · Petr Gladkikh

1. Volume pcm which have volume coefficient as a parameter.
2. Mixer hook which can push volume coefficient from specified mixer control element into given value (It does it in a way similar to watching control changes in alsamixer). This hook can be attached to volume pcm.

Configuration example

pcm.vol {
	type volume
	slave.pcm hw:0
	coeff 0.9
	hook {
		card default
		control Master
		index 0
	}
}

Explicitly specified coefficient and one provided by hook are multiplied before applying to samples. Input and output PCM formats must match (as for copy plugin).

Quoted 8 lines

These things are usable alone. For example you can adjust amplitude of PCM or tell Master_volume_control of one card to affect output of another :) But to completely cheat applications all this lacks some emulated volume control like described in quoted post above.

So I wonder if this code could be useful for alsa-lib? Perhaps it can
supplement softvol code? I would like it to be reviewed by anyone
who interested. (I'll send the path in few days.)

Of course, it's interesting.

I think, however, the faeatures above can be easily merged to softvol, too. Only two changes would be needed in practice:

- When coeff != 1, update the dB table at initialization
- Accept hw volume control (maybe better to add a new option) instead of always bypassing it

An example patch is below (untested as usual).
The coeff is in dB on my code.

Or, any other functions in your proposal?

Takashi

Index: alsa-lib/src/pcm/pcm_softvol.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-lib/src/pcm/pcm_softvol.c,v retrieving revision 1.10

src/pcm/pcm_softvol.c +53 -19
diff -u -r1.10 pcm_softvol.c
@@ -48,6 +48,7 @@
 	unsigned int cur_vol[2];
 	unsigned int max_val;
 	double min_dB;
+	double coeff_dB;
 	unsigned short *dB_value;
 } snd_pcm_softvol_t;
 
@@ -453,6 +454,7 @@
 	snd_output_printf(out, "Soft volume PCM\n");
 	snd_output_printf(out, "Control: %s\n", svol->elem.id.name);
 	snd_output_printf(out, "min_dB: %g\n", svol->min_dB);
+	snd_output_printf(out, "coeff: %g\n", svol->coeff_dB);
 	snd_output_printf(out, "resolution: %d\n", svol->max_val + 1);
 	if (pcm->setup) {
 		snd_output_printf(out, "Its setup is:\n");
@@ -465,7 +467,7 @@
 static int add_user_ctl(snd_pcm_softvol_t *svol, snd_ctl_elem_info_t *cinfo, int count)
 {
 	int err;
-	unsigned int i;
+	int i;
 
 	err = snd_ctl_elem_add_integer(svol->ctl, &cinfo->id, count, 0, svol->max_val, 0);
 	if (err < 0)
@@ -484,7 +486,8 @@
  */
 static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol,
 				int ctl_card, snd_ctl_elem_id_t *ctl_id,
-				int cchannels, double min_dB, int resolution)
+				int cchannels, int hwctl,
+				double min_dB, int resolution, double coeff)
 {
 	char tmp_name[32];
 	snd_pcm_info_t *info;
@@ -513,6 +516,7 @@
 	svol->elem.id = *ctl_id;
 	svol->max_val = resolution - 1;
 	svol->min_dB = min_dB;
+	svol->coeff_dB = coeff;
 
 	snd_ctl_elem_info_alloca(&cinfo);
 	snd_ctl_elem_info_set_id(cinfo, ctl_id);
@@ -529,9 +533,10 @@
 	} else {
 		if (! (cinfo->access & SNDRV_CTL_ELEM_ACCESS_USER)) {
 			/* hardware control exists */
-			return 1; /* notify */
-
-		} else if (cinfo->type != SND_CTL_ELEM_TYPE_INTEGER ||
+			if (! hwctl)
+				return 1; /* notify */
+		}
+		if (cinfo->type != SND_CTL_ELEM_TYPE_INTEGER ||
 			   cinfo->count != (unsigned int)cchannels ||
 			   cinfo->value.integer.min != 0 ||
 			   cinfo->value.integer.max != resolution - 1) {
@@ -547,7 +552,7 @@
 		}
 	}
 
-	if (min_dB == PRESET_MIN_DB && resolution == PRESET_RESOLUTION)
+	if (min_dB == PRESET_MIN_DB && resolution == PRESET_RESOLUTION && coeff == 0)
 		svol->dB_value = preset_dB_value;
 	else {
 #ifndef HAVE_SOFT_FLOAT
@@ -556,13 +561,15 @@
 			SNDERR("cannot allocate dB table");
 			return -ENOMEM;
 		}
-		svol->min_dB = min_dB;
-		for (i = 1; i < svol->max_val; i++) {
-			double db = svol->min_dB - ((i - 1) * svol->min_dB) / (svol->max_val - 1);
+		for (i = 1; i <= svol->max_val; i++) {
+			double db = svol->coeff_dB + svol->min_dB - ((i - 1) * svol->min_dB) / (svol->max_val - 1);
 			double v = (pow(10.0, db / 20.0) * (double)(1 << VOL_SCALE_SHIFT));
+			if (v >= 65535)
+				v = 65535;
 			svol->dB_value[i] = (unsigned short)v;
 		}
-		svol->dB_value[svol->max_val] = 65535;
+		if (coeff == 0)
+			svol->dB_value[svol->max_val] = 65535;
 #else
 		SNDERR("Cannot handle the given min_dB and resolution");
 		return -EINVAL;
@@ -605,8 +612,8 @@
 int snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name,
 			 snd_pcm_format_t sformat,
 			 int ctl_card, snd_ctl_elem_id_t *ctl_id,
-			 int cchannels,
-			 double min_dB, int resolution,
+			 int cchannels, int hwctl,
+			 double min_dB, int resolution, double coeff,
 			 snd_pcm_t *slave, int close_slave)
 {
 	snd_pcm_t *pcm;
@@ -620,8 +627,8 @@
 	svol = calloc(1, sizeof(*svol));
 	if (! svol)
 		return -ENOMEM;
-	err = softvol_load_control(slave, svol, ctl_card, ctl_id, cchannels,
-				   min_dB, resolution);
+	err = softvol_load_control(slave, svol, ctl_card, ctl_id, cchannels, hwctl,
+				   min_dB, resolution, coeff);
 	if (err < 0) {
 		softvol_free(svol);
 		return err;
@@ -664,7 +671,7 @@
  * parse card index and id for the softvol control
  */
 static int parse_control_id(snd_config_t *conf, snd_ctl_elem_id_t *ctl_id, int *cardp,
-			    int *cchannelsp)
+			    int *cchannelsp, int *hwctl)
 {
 	snd_config_iterator_t i, next;
 	int iface = SND_CTL_ELEM_IFACE_MIXER;
@@ -676,6 +683,7 @@
 
 	*cardp = -1;
 	*cchannelsp = 2;
+	*hwctl = 0;
 	snd_config_for_each(i, next, conf) {
 		snd_config_t *n = snd_config_iterator_entry(i);
 		const char *id;
@@ -746,6 +754,19 @@
 			*cchannelsp = v;
 			continue;
 		}
+		if (strcmp(id, "hwctl") == 0) {
+			char *tmp;
+			if ((err = snd_config_get_ascii(n, &tmp)) < 0) {
+				SNDERR("field %s has an invalid type", id);
+				goto _err;
+			}
+			if ((err = snd_config_get_bool_ascii(tmp)) < 0) {
+				SNDERR("field %s is not a boolean", id);
+				goto _err;
+			}
+			*hwctl = err;
+			continue;
+		}
 		SNDERR("Unknown field %s", id);
 		return -EINVAL;
 	}
@@ -804,9 +825,11 @@
 		[device INT]    # device number of the element
 		[subdevice INT] # subdevice number of the element
 		[count INT]     # control channels 1 or 2 (default: 2)
+		[hwctl BOOL]	# accept h/w control
 	}
 	[min_dB REAL]           # minimal dB value (default: -48.0)
 	[resolution INT]        # resolution (default: 256)
+	[coeff REAL]		# coefficient in dB
 }
 \endcode
 
@@ -845,7 +868,8 @@
 	snd_ctl_elem_id_t *ctl_id;
 	int resolution = PRESET_RESOLUTION;
 	double min_dB = PRESET_MIN_DB;
-	int card = -1, cchannels = 2;
+	double coeff = 0;
+	int card = -1, cchannels = 2, hwctl = 0;
 
 	snd_config_for_each(i, next, conf) {
 		snd_config_t *n = snd_config_iterator_entry(i);
@@ -880,6 +904,16 @@
 			}
 			continue;
 		}
+#ifndef HAVE_SOFT_FLOAT
+		if (strcmp(id, "coeff") == 0) {
+			err = snd_config_get_real(n, &coeff);
+			if (err < 0) {
+				SNDERR("Invalid coeff value");
+				return err;
+			}
+			continue;
+		}
+#endif
 		SNDERR("Unknown field %s", id);
 		return -EINVAL;
 	}
@@ -915,12 +949,12 @@
 	if (err < 0)
 		return err;
 	snd_ctl_elem_id_alloca(&ctl_id);
-	if ((err = parse_control_id(control, ctl_id, &card, &cchannels)) < 0) {
+	if ((err = parse_control_id(control, ctl_id, &card, &cchannels, &hwctl)) < 0) {
 		snd_pcm_close(spcm);
 		return err;
 	}
-	err = snd_pcm_softvol_open(pcmp, name, sformat, card, ctl_id, cchannels,
-				   min_dB, resolution, spcm, 1);
+	err = snd_pcm_softvol_open(pcmp, name, sformat, card, ctl_id, cchannels, hwctl,
+				   min_dB, resolution, coeff, spcm, 1);
 	if (err < 0)
 		snd_pcm_close(spcm);
 	return err;