Skip to contentSkip to conversation

hdsp oss emulation and sync

DISCUSSION Peter Plessas 2 participants 7 messages Jun 28, 2005 – Jul 14, 2005

lore
Share & tools
lore
#0 lore raw

Dear List,

I posted this before but i think to the alsa-users list.

I have an HDSP (Pci or CardBus) with a Multiface, which shows the following behavior:

When the card works as a sync slave to other digital equipment, the OSS emulation does not work. I tested this on more than one machine. I can't give you any error messages by now, since i don't have the card with me (but do have time to write this).

There are simply some cases where i rely on the emulation.

Until today i just found one more posting about this problem in the alsa-list archives, but that remained unsolved till today.

Any ideas?

regards, Peter

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

#1 lore raw

At Tue, 28 Jun 2005 18:33:00 +0200,

Quoted 10 lines · Peter Plessas

Dear List,

I posted this before but i think to the alsa-users list.

I have an HDSP (Pci or CardBus) with a Multiface, which shows the following behavior:

When the card works as a sync slave to other digital equipment, the OSS emulation does not work.

How doesn't it work? More detailed explanation please?

Quoted 3 lines

I tested this on more than one machine.
I can't give you any error messages by now, since i don't have the card with me (but do have time to write this).

Well, it's hard to debug without error details...

Takashi

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

#2 lore raw

Hi Takashi, List,

Quoted 1 line · Takashi Iwai

How doesn't it work? More detailed explanation please?

I have the card synced as slave to my mixer.
I get the following error messages when starting f.e. pd or rezound:

(all software also tested as root)

pd -verbose -oss
device 1: tried /dev/midi READ/WRITE; returned 5 opened 1 MIDI input device(s) and 1 MIDI output device(s). input channels = 2, output channels = 2
opened /dev/dsp for reading and writing

error: OSS: SNDCTL_DSP_CHANNELS failed /dev/dsp
opened audio output on /dev/dsp; got 0 channels
opened /dev/dsp for reading only

error: OSS: SNDCTL_DSP_CHANNELS failed /dev/dsp opened audio input device /dev/dsp; got 0 channels

rezound
Error occurred while initializing audio output method 'oss' -- virtual void COSSSoundPlayer::initialize() -- error setting the format -- Operation not permitted

In both cases dmesg gives:

Jun 29 12:31:49 bigh kernel: No AutoSync source for requested rate

But my rate in pd and of the external source is both 44.1k

As i switch the card to sync master, these apps do fine.

Quoted 1 line

Well, it's hard to debug without error details...

Where else can i look for meaningful messages?

Thanks,

Peter

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

#3 lore raw

At Wed, 29 Jun 2005 12:30:02 +0200,

Quoted 31 lines · Peter Plessas

Hi Takashi, List,

Quoted 1 line · Takashi Iwai

How doesn't it work? More detailed explanation please?

I have the card synced as slave to my mixer.
I get the following error messages when starting f.e. pd or rezound:

(all software also tested as root)

pd -verbose -oss
device 1: tried /dev/midi READ/WRITE; returned 5 opened 1 MIDI input device(s) and 1 MIDI output device(s). input channels = 2, output channels = 2
opened /dev/dsp for reading and writing

error: OSS: SNDCTL_DSP_CHANNELS failed /dev/dsp
opened audio output on /dev/dsp; got 0 channels
opened /dev/dsp for reading only

error: OSS: SNDCTL_DSP_CHANNELS failed /dev/dsp opened audio input device /dev/dsp; got 0 channels

rezound
Error occurred while initializing audio output method 'oss' -- virtual void COSSSoundPlayer::initialize() -- error setting the format -- Operation not permitted

Quoted 5 lines

In both cases dmesg gives:

Jun 29 12:31:49 bigh kernel: No AutoSync source for requested rate

But my rate in pd and of the external source is both 44.1k

OSS always opens the device with the default sample rate 8000HZ. It looks like the hdsp driver doesn't accept this rate in the external sync mode.

Quoted 6 lines

As i switch the card to sync master, these apps do fine.

Quoted 1 line

Well, it's hard to debug without error details...

Where else can i look for meaningful messages?

So far, so good.

Could you try the patch below? This will add "Sample Clock Source Locking" mixer element. Enabling this switch may fix your problem above. You can turn this on via alsamixer or amixer.

Takashi

Index: alsa-kernel/pci/rme9652/hdsp.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/rme9652/hdsp.c,v retrieving revision 1.90

pci/rme9652/hdsp.c +54 -10
diff -u -r1.90 hdsp.c
@@ -445,6 +445,7 @@
 	u32                   control2_register;     /* cached value */
 	u32                   creg_spdif;
 	u32                   creg_spdif_stream;
+	int                   clock_source_locked;
 	char                 *card_name;	     /* digiface/multiface */
 	HDSP_IO_Type          io_type;               /* ditto, but for code use */
         unsigned short        firmware_rev;
@@ -2086,7 +2087,7 @@
 	    if (val > 6) val = 6;
 	}
 	spin_lock_irq(&hdsp->lock);
-	if (val != hdsp_clock_source(hdsp)) {
+	if (val != hdsp_clock_source(hdsp) && ! hdsp->clock_source_locked) {
 		change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0;
 	} else {
 		change = 0;
@@ -2095,6 +2096,34 @@
 	return change;
 }
 
+static int snd_hdsp_info_clock_source_lock(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = 1;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
+static int snd_hdsp_get_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+	
+	ucontrol->value.integer.value[0] = hdsp->clock_source_locked;
+	return 0;
+}
+
+static int snd_hdsp_put_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+	int change;
+
+	change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked;
+	if (change)
+		hdsp->clock_source_locked = ucontrol->value.integer.value[0];
+	return change;
+}
+
 #define HDSP_DA_GAIN(xname, xindex) \
 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
   .name = xname, \
@@ -3117,6 +3146,15 @@
 HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0),
 /* 'Sample Clock Source' complies with the alsa control naming scheme */ 
 HDSP_CLOCK_SOURCE("Sample Clock Source", 0),
+{
+	/* FIXME: should be PCM or MIXER? */
+	/* .iface = SNDRV_CTL_ELEM_IFACE_PCM, */
+	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+	.name = "Sample Clock Source Locking",
+	.info = snd_hdsp_info_clock_source_lock,
+	.get = snd_hdsp_get_clock_source_lock,
+	.put = snd_hdsp_put_clock_source_lock,
+},
 HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
 HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0),
 HDSP_AUTOSYNC_REF("AutoSync Reference", 0),
@@ -3349,6 +3387,7 @@
 	snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode);
 
 	snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate);
+	snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No");
 		
 	snd_iprintf(buffer, "\n");
 
@@ -3853,13 +3892,14 @@
 	 */
 
 	spin_lock_irq(&hdsp->lock);
-	if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
-		spin_unlock_irq(&hdsp->lock);
-		_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
-		return err;
-	} else {
-		spin_unlock_irq(&hdsp->lock);
+	if (! hdsp->clock_source_locked) {
+		if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
+			spin_unlock_irq(&hdsp->lock);
+			_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
+			return err;
+		}
 	}
+	spin_unlock_irq(&hdsp->lock);
 
 	if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) {
 		_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
@@ -4284,13 +4324,17 @@
 
 	snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes);
-	if (hdsp->io_type == H9632) {
-		runtime->hw.channels_min = hdsp->qs_out_channels;
-		runtime->hw.channels_max = hdsp->ss_out_channels;
+	if (hdsp->clock_source_locked) {
+		runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate;
+	} else if (hdsp->io_type == H9632) {
 		runtime->hw.rate_max = 192000;
 		runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
 		snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates);
 	}
+	if (hdsp->io_type == H9632) {
+		runtime->hw.channels_min = hdsp->qs_out_channels;
+		runtime->hw.channels_max = hdsp->ss_out_channels;
+	}	
 	
 	snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
 			     snd_hdsp_hw_rule_out_channels, hdsp,
#4 lore raw

Hi Takashi&List,

Yes, great! This works! What are the drawbacks of using the "Sample Clock Source Locking"? I can see that i can't change the hdsp from autosync to master after i enabled the locking. But the OSS emulation just works fine!!

Thanks again,

Peter

Quoted 5 lines · Takashi Iwai

Could you try the patch below? This will add "Sample Clock Source Locking" mixer element. Enabling this switch may fix your problem above. You can turn this on via alsamixer or amixer.

Quoted 8 lines

Takashi

------------------------------------------------------------------------

Index: alsa-kernel/pci/rme9652/hdsp.c
===================================================================
. . .

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

#5 lore raw

At Thu, 30 Jun 2005 22:22:28 +0200,

Quoted 5 lines · Peter Plessas

Hi Takashi&List,

Yes, great! This works! What are the drawbacks of using the "Sample Clock Source Locking"?

If the locking is set, only the current sample rate is available for the PCMs opened later on. But this restriction doesn't matter since the oss-emulation does the sample rate conversion by itself. Also, setting this switch to off is exactly the same behavior as before.

Quoted 2 lines

I can see that i can't change the hdsp from
autosync to master after i enabled the locking.

It's intentional in the last patch. I got rid of this behavior from the patch below, a newer version. I'll commit this to CVS.

Takashi

Index: alsa-kernel/pci/rme9652/hdsp.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/rme9652/hdsp.c,v retrieving revision 1.90

pci/rme9652/hdsp.c +53 -9
diff -u -r1.90 hdsp.c
@@ -445,6 +445,7 @@
 	u32                   control2_register;     /* cached value */
 	u32                   creg_spdif;
 	u32                   creg_spdif_stream;
+	int                   clock_source_locked;
 	char                 *card_name;	     /* digiface/multiface */
 	HDSP_IO_Type          io_type;               /* ditto, but for code use */
         unsigned short        firmware_rev;
@@ -2095,6 +2096,34 @@
 	return change;
 }
 
+static int snd_hdsp_info_clock_source_lock(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = 1;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
+static int snd_hdsp_get_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+	
+	ucontrol->value.integer.value[0] = hdsp->clock_source_locked;
+	return 0;
+}
+
+static int snd_hdsp_put_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+	int change;
+
+	change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked;
+	if (change)
+		hdsp->clock_source_locked = ucontrol->value.integer.value[0];
+	return change;
+}
+
 #define HDSP_DA_GAIN(xname, xindex) \
 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
   .name = xname, \
@@ -3117,6 +3146,15 @@
 HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0),
 /* 'Sample Clock Source' complies with the alsa control naming scheme */ 
 HDSP_CLOCK_SOURCE("Sample Clock Source", 0),
+{
+	/* FIXME: should be PCM or MIXER? */
+	/* .iface = SNDRV_CTL_ELEM_IFACE_PCM, */
+	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+	.name = "Sample Clock Source Locking",
+	.info = snd_hdsp_info_clock_source_lock,
+	.get = snd_hdsp_get_clock_source_lock,
+	.put = snd_hdsp_put_clock_source_lock,
+},
 HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
 HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0),
 HDSP_AUTOSYNC_REF("AutoSync Reference", 0),
@@ -3349,6 +3387,7 @@
 	snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode);
 
 	snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate);
+	snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No");
 		
 	snd_iprintf(buffer, "\n");
 
@@ -3853,13 +3892,14 @@
 	 */
 
 	spin_lock_irq(&hdsp->lock);
-	if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
-		spin_unlock_irq(&hdsp->lock);
-		_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
-		return err;
-	} else {
-		spin_unlock_irq(&hdsp->lock);
+	if (! hdsp->clock_source_locked) {
+		if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
+			spin_unlock_irq(&hdsp->lock);
+			_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
+			return err;
+		}
 	}
+	spin_unlock_irq(&hdsp->lock);
 
 	if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) {
 		_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
@@ -4284,13 +4324,17 @@
 
 	snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes);
-	if (hdsp->io_type == H9632) {
-		runtime->hw.channels_min = hdsp->qs_out_channels;
-		runtime->hw.channels_max = hdsp->ss_out_channels;
+	if (hdsp->clock_source_locked) {
+		runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate;
+	} else if (hdsp->io_type == H9632) {
 		runtime->hw.rate_max = 192000;
 		runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
 		snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates);
 	}
+	if (hdsp->io_type == H9632) {
+		runtime->hw.channels_min = hdsp->qs_out_channels;
+		runtime->hw.channels_max = hdsp->ss_out_channels;
+	}	
 	
 	snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
 			     snd_hdsp_hw_rule_out_channels, hdsp,
#6 lore raw
In reply to Takashi Iwai

Hi, Takashi, List,

Thanks for the second patch,
i have no hdsp with me for another 6 weeks, but i'll be happy to try it once i return home.

Thanks!

Peter P.

-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar