Bug 92690 - Regression: No right channel sound on Creative Xtreme Audio (CA0106)
Summary: Regression: No right channel sound on Creative Xtreme Audio (CA0106)
Status: RESOLVED WORKSFORME
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: alsa (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-27 11:06 UTC by Luke
Modified: 2016-09-24 19:17 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
PulseAudio verbose log (280.61 KB, text/plain)
2015-10-27 11:06 UTC, Luke
Details
New PulseAudio Verbose Log with updated analog-output.conf + default.conf (814.45 KB, text/plain)
2016-05-07 04:13 UTC, Luke
Details

Description Luke 2015-10-27 11:06:29 UTC
Created attachment 119222 [details]
PulseAudio verbose log

After a fresh install of Ubuntu 14.04, 15.04, 15.10 and on the liveCD, There is no sound on right channel. But it works perfectly in Win 7/10. It also worked perfectly on Ubuntu 12.04 My sound card is Creative Xtreme Audio (PCI CA0106).

In the forum, many users also have experienced this bug with the incorrect default alsamixer settings.

http://ubuntuforums.org/showthread.php?t=2217724
http://askubuntu.com/questions/496607/no-sound-from-right-speakers#

Here are my alsa-info.sh results.

http://www.alsa-project.org/db/?f=e3ae99437c3d283b35cac7c33ace996bedf43a16

Also attached the result of:
# echo autospawn = no >> ~/.config/pulse/client.conf
# sudo killall pulseaudio
# LANG=C pulseaudio -vvvv --log-time=1 > ~/pulseverbose.log 2>&1

Raymond has some analysis here:
https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1497666
Comment 1 Raymond 2015-10-27 14:49:09 UTC
how about aad the following elements to http://cgit.freedesktop.org/pulseaudio/pulseaudio/plain/src/modules/alsa/mixer/paths/analog-output.conf


[Element Analog Front]
switch = mute
volume = merge
override-map.1 = all-front
override-map.2 = front-left,front-right


[Element Analog Surround]
switch = mute
volume = merge
override-map.1 = all-rear
override-map.2 = rear-left,rear-right

[Element Analog Side]
switch = mute
volume = merge
override-map.1 = all-side
override-map.2 = side-left,side-right

[Element Analog Center/LFE]
switch = mute
volume = merge
override-map.1 = all-center
override-map.2 = all-center,lfe
Comment 2 David Henningsson 2015-10-29 03:22:54 UTC
Hi Luke,

Can you try the suggestion by Raymond in the previous comment?

I e, edit /usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf and add these lines:

;;; cut here ;;;

[Element Analog Front]
switch = mute
volume = merge
override-map.1 = all-front
override-map.2 = front-left,front-right

[Element Analog Surround]
switch = mute
volume = merge
override-map.1 = all-rear
override-map.2 = rear-left,rear-right

[Element Analog Side]
switch = mute
volume = merge
override-map.1 = all-side
override-map.2 = side-left,side-right

[Element Analog Center/LFE]
switch = mute
volume = merge
override-map.1 = all-center
override-map.2 = all-center,lfe

;;; cut here ;;;

Then reboot your computer for changes to take effect.

Do you now have the possibility to change balance on the different outputs correctly, so that PulseAudio controls these alsamixer sliders when you use the normal GUI (e g unity-control-center)? If not, please also attach the output of "pactl list".
Comment 3 Raymond 2015-10-29 05:49:55 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/ca0106/ca0106_mixer.c?id=49c88b85b53767f97eb8c9171cb0b976c62a0114


the virtual master control both analog and digital volume

000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
(   0.355|   0.000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
(   0.355|   0.000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
(   0.355|   0.000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
(   0.355|   0.000) D: [pulseaudio] alsa-util.c: Set neither period nor buffer size.
(   0.356|   0.000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
(   0.356|   0.000) I: [pulseaudio] alsa-util.c: snd_pcm_hw_params failed: Device or resource busy
(   0.356|   0.000) I: [pulseaudio] alsa-util.c: Failed to set hardware parameters on plug:iec958:0: Device or resource busy



there are locks associated with iec958 playback

you need to use type asym for ca0106 iec958 to prevent  lock when pulseaudio open iec958 capture
Comment 4 Raymond 2015-10-29 10:10:03 UTC
http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths


why pulseaudio only has iec958-stereo-output.conf but no iec958-stereo-input.conf when 


http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/profile-sets/default.conf

[Mapping iec958-stereo]
device-strings = iec958:%f
channel-map = left,right
paths-input = iec958-stereo-input
paths-output = iec958-stereo-output
priority = 5
Comment 5 Raymond 2015-10-29 10:13:45 UTC
you need ice958-stereo-input.conf for selecting digital source

Simple mixer control 'Digital Source',0
  Capabilities: cenum
  Items: 'IEC958 out' 'i2s mixer out' 'IEC958 in' 'i2s in' 'AC97 in' 'SRC out'
  Item0: 'i2s in'
Comment 6 Luke 2015-11-24 07:25:49 UTC
After editing edit /usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf, 
The Unity sound control panel showed the balance as "Left" (it was at the "Center" position before the edit). After moving the slider from "Left" to "Center", sound played out of the Right speaker.

Would you like any more information?
Comment 7 Luke 2015-12-13 06:38:21 UTC
@Raymond
This is still marked NEEDINFO. What else do you need?
Comment 8 Raymond 2015-12-13 17:12:09 UTC
[Mapping iec958-stereo] 
device-strings = iec958:%f 
channel-map = left,right 
paths-input = iec958-stereo-input 
paths-output = iec958-stereo-output 
priority = 5

You can remove the iec958-stereo-input from pulseaudio default.conf 

http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/profile-sets/default.conf


You need to provide pulseaudio verbose log after you added those analog elements and force pulseaudio not probe iec958 input
Comment 9 Raymond 2015-12-15 01:37:19 UTC
0.304| 0.000) D: [pulseaudio] alsa-mixer.c: Available mixer paths (after tidying): 
( 0.304| 0.000) D: [pulseaudio] alsa-mixer.c: Path Set 0x8628a98, direction=1 
( 0.304| 0.000) D: [pulseaudio] alsa-mixer.c: Path analog-output (Analog Output), direction=1, priority=99, probed=yes, supported=yes, has_mute=yes, has_volume=yes, has_dB=yes, min_volume=0, max_volume=255, min_dB=-100000, max_dB=0 
( 0.304| 0.000) D: [pulseaudio] alsa-mixer.c: Element Master, direction=1, switch=1, volume=1, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x7ffffffffffff, n_channels=1, override_map=yes 
( 0.304| 0.000) D: [pulseaudio] alsa-mixer.c: Element IEC958, direction=1, switch=2, volume=0, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x0, n_channels=0, override_map=no


It seem ignore those ca0106 analog playback volume control and just found the mono virtual master playback volume
Comment 10 Luke 2016-05-07 04:13:19 UTC
Created attachment 123531 [details]
New PulseAudio Verbose Log with updated analog-output.conf + default.conf

Sorry for the delay, I was away from my desktop for a few months.

I have done the following:
* Followed the instructions here: http://ubuntuforums.org/showthread.php?t=2210602 to build from source
* Removed the 1 line with iec958-stereo-input from src/modules/alsa/mixer/profile-sets/default.conf
* Added the elements to src/modules/alsa/mixer/paths/analog-output.conf
* sudo make install
* Rebooted
* Created PulseAudio verbose log

As I said earlier, with the new analog-output.conf elements, this issue is fixed.
Comment 11 Raymond 2016-05-08 14:57:30 UTC
you still have locking problem when pulseaudio try to open ice958 playback and ice958 capture

  0.374|   0.000) D: [pulseaudio] alsa-mixer.c: Looking at profile output:iec958-stereo+input:iec958-stereo
(   0.374|   0.000) D: [pulseaudio] alsa-mixer.c: Checking for recording on Digital Stereo (IEC958) (iec958-stereo)
(   0.374|   0.000) D: [pulseaudio] alsa-util.c: Trying iec958:0 with SND_PCM_NO_AUTO_FORMAT ...
(   0.374|   0.000) D: [pulseaudio] alsa-util.c: Managed to open iec958:0
(   0.375|   0.000) D: [pulseaudio] alsa-util.c: Maximum hw buffer size is 340 ms
(   0.375|   0.000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
(   0.375|   0.000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
(   0.375|   0.000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
(   0.375|   0.000) I: [pulseaudio] (alsa-lib)setup.c: Cannot lock ctl elem
Comment 12 Raymond 2016-05-08 15:03:13 UTC
you need an asym plugin for ice958 playback and capture so that it only lock playback ctl 



http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/conf/cards/CA0106.conf;hb=HEAD#l223
Comment 13 Luke 2016-05-08 15:07:31 UTC
Raymond,
I'
Comment 14 Luke 2016-05-08 15:11:43 UTC
Raymond,
I'm not a developer. Could you please give me detailed instructions on what you want me to do? Thank you for all your help on this issue.
Comment 15 Raymond 2016-05-09 01:42:54 UTC
http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html


just make sure that when application open iec958 capture won't lock those playback ctl elems



Plugin: asym

This plugin is a combination of playback and capture PCM streams. Slave PCMs can be defined asymmetrically for both directions.

pcm.name {
        type asym               # Asym PCM
        playback STR            # Playback slave name
        # or
        playback {              # Playback slave definition
                pcm STR         # Slave PCM name
                # or
                pcm { }         # Slave PCM definition
        }
        capture STR             # Capture slave name
        # or
        capture {               # Capture slave definition
                pcm STR         # Slave PCM name
                # or
                pcm { }         # Slave PCM definition
        }
}
Comment 16 Luke 2016-05-09 20:46:55 UTC
I still don't quite follow what you want. I tried adding your Plugin: asym code to a new file, $HOME/.asoundrc . After a reboot, no sound would play. Do you want a PulseAudio verbose log of this?
Comment 17 Raymond 2016-05-09 23:16:28 UTC
(   0.327|   0.000) D: [pulseaudio] alsa-mixer.c: Path analog-output (Analog Output), direction=1, priority=99, probed=yes, supported=yes, has_mute=yes, has_volume=yes, has_dB=yes, min_volume=0, max_volume=255, min_dB=-200000, max_dB=12
(   0.327|   0.000) D: [pulseaudio] alsa-mixer.c: Element Master, direction=1, switch=1, volume=1, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x7ffffffffffff, n_channels=1, override_map=yes
(   0.327|   0.000) D: [pulseaudio] alsa-mixer.c: Element Analog Front, direction=1, switch=1, volume=1, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x6, n_channels=2, override_map=yes
(   0.327|   0.000) D: [pulseaudio] alsa-mixer.c: Element Analog Side, direction=1, switch=1, volume=1, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0xc00, n_channels=2, override_map=yes
(   0.327|   0.000) D: [pulseaudio] alsa-mixer.c: Element Analog Center/LFE, direction=1, switch=1, volume=1, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x4900000000098, n_channels=2, override_map=yes
(   0.327|   0.000) D: [pulseaudio] alsa-mixer.c: Element IEC958, direction=1, switch=2, volume=0, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x0, n_channels=0, override_map=no


why iec958 switch in analog path ?

as 99999.99 represent infinite dB , how can mindB equal to -20000dB

	control.5 {
		iface MIXER
		name 'Analog Front Playback Volume'
		value.0 207
		value.1 207
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 255'
			dbmin -9999999
			dbmax 1200
			dbvalue.0 0
			dbvalue.1 0
		}
	}


control.38 {
		iface MIXER
		name 'Master Playback Volume'
		value 202
		comment {
			access 'read write'
			type INTEGER
			count 1
			range '0 - 255'
			dbmin -9999999
			dbmax 0
			dbvalue.0 -1325
		}
	}
Comment 18 Raymond 2016-05-10 00:49:05 UTC
if the master playback volume control is virtual master, it is strange that dB max is different from slaves


https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/ca0106?id=601e1cc5df940b59e71c947726640811897d30df
Comment 19 Raymond 2016-05-10 11:52:36 UTC
CA0106.pcm.iec958.0 {
	@args [ CARD AES0 AES1 AES2 AES3 ]
	@args.CARD {
		type string
	}
	@args.AES0 {
		type integer
	}
	@args.AES1 {
		type integer
	}
	@args.AES2 {
		type integer
	}
	@args.AES3 {
		type integer
	}
type asym
playback {


	type hooks
	slave.pcm {
		type hw
		card $CARD
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{
				name "IEC958 Front Playback Volume"
				index 0
				lock true
				preserve true
				value [ 207 207 ]   # Puts 0x30303030 in the Volume register. 0xff - 0x30 = 0xcf = 207
			}
			{
				name "IEC958 Playback Switch"
				lock true
				preserve true
				value 1
			}
			{
				interface PCM
				name "IEC958 Playback Default"
				index 1
				lock true
				preserve true
				optional true
				value [ $AES0 $AES1 $AES2 $AES3 ]
			}
			{
				# for compatibility with older drivers
				name "IEC958 Playback Default"
				index 1
				lock true
				preserve true
				optional true
				value [ $AES0 $AES1 $AES2 $AES3 ]
			}
		]
	}
}
capture {
	slave.pcm {
		type hw
		card $CARD
	}
}
}
Comment 20 Luke 2016-05-13 02:15:30 UTC
Raymond,
Again, I'm not sure what you need me to do. Please give me clear instructions and I'll do my best to follow them.
Comment 21 Raymond 2016-05-13 02:53:51 UTC
you have to change CA0106.pcm.iec958.0 in  /usr/share/alsa/cards/CA0106.conf to use asym plugin so that open iec958 capture won't lock those iec958 playback controls


seem syntax of capture should be 

      capture {

		type hw
		card $CARD
	
      }

instead of 

capture {
	slave.pcm {
		type hw
		card $CARD
	}
}
Comment 22 Raymond 2016-05-13 03:20:05 UTC
for the max dB bug. you have to ask the author of this patch 

+static int slave_tlv_cmd(struct snd_kcontrol *kcontrol,
+			 int op_flag, unsigned int size,
+			 unsigned int __user *tlv)
+{
+	struct link_slave *slave = snd_kcontrol_chip(kcontrol);
+	/* FIXME: this assumes that the max volume is 0 dB */
+	return slave->slave.tlv.c(&slave->slave, op_flag, size, tlv);



+}ound.git/commit/sound/core/vmaster.c?id=e922b0028fad87de0d262f9fa51f98595d2df258
Comment 24 Raymond 2016-05-13 08:59:10 UTC
the modified ca0106.conf should allow you to run arecord and aplay with ice958 of your ca0106 at the same time without "Cannot lock ctl elem" error
Comment 25 Luke 2016-05-14 00:55:13 UTC
Raymond,
Since you understand this issue far better than I do, could you please ask him for me? I opened a new issue over here:

https://bugzilla.kernel.org/show_bug.cgi?id=118161

After I modify A0106.pcm.iec958.0 in  /usr/share/alsa/cards/CA0106.conf, what next? Another PulseAudio verbose log?
Comment 26 Raymond 2016-05-14 11:49:02 UTC
how do you test ?

speaker-test -c 2  -t wav -D hw:CARD=CA0106


do you get the correct sound if the application use alsa hw device ?



speaker-test -c2 -t wav -D pulse
Comment 27 Luke 2016-07-25 20:42:56 UTC
From 
https://bugzilla.kernel.org/show_bug.cgi?id=118161

> I installed Lubuntu 12.04, 3.2.0-102-generic-pae. Both channels played. I
> upgraded the kernel to 3.10.101-0310101-generic from here:
> http://kernel.ubuntu.com/~kernel-ppa/mainline/

> Unlike the bootable iso image, once installed it had a /var/lib/alsa/asound.state

> I removed this and did a $ alsa force-reload and $ alsactl init, but 
> asound.state wasn't recreated. Also the old alsamixer settings seemed to 
> remain.  How do I reset ALL the alsa settings to reproduce this bug with newer 
> kernels?

Since upgrading the kernel didn't trigger this bug, does it mean that it's an also configuration issue? I can reproduce this issue on Lubuntu (no PA), so should I close this bug?
Comment 28 Raymond 2016-07-26 16:15:07 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/log/sound/pci/ca0106


only a few change in ca0106 driver, so it is unlikely driver bug if speaker-test with hw devuce still work
Comment 29 Luke 2016-09-24 19:17:58 UTC
Verified fixed with a clean install of Ubuntu 16.10.

$ uname -a
Linux luke-PowerEdge-T105 4.4.0-9136-generic #55-Ubuntu SMP Fri Aug 26 05:58:34 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Raymond,
Thank you so much for all your help on this issue!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.