Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Can't get surround sound working with optical output

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
grimripper
Posts: 4
Joined: 2019-04-04 16:51

Can't get surround sound working with optical output

#1 Post by grimripper »

Hi

I've installed Debian Stretch onto a new HTPC and then updated it to Buster. This helper a lot with audio issues but I still haven't been able to get surround sound working over optical output. I'm seeing two cards, one of which corresponds to HDMI and DP outputs. For the other one, there's a toslink and five 3.5mm jacks (7.1 channel output plus input) on the back of the computer and two 3.5mm jacks (output and input) on the front of the computer.

I've got audio working with HDMI and I've gotten stereo audio from front and back 3.5mm jacks as well as the toslink. I'm stumped on toslink surround though, especially since I read that it doesn't actually support surround and for 5.1 playback, the audio needs to be encoded, and I haven't figured out where and how this happens.

Here's aplay -l for the relevant card:

Code: Select all

card 1: Generic_1 [HD-Audio Generic], device 0: ALC1220 Analog [ALC1220 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 1: ALC1220 Digital [ALC1220 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


And aplay -L:

Code: Select all

sysdefault:CARD=Generic_1
    HD-Audio Generic, ALC1220 Analog
    Default Audio Device
front:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    Front speakers
surround21:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Digital
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    Direct sample mixing device
dmix:CARD=Generic_1,DEV=1
    HD-Audio Generic, ALC1220 Digital
    Direct sample mixing device
dsnoop:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    Direct sample snooping device
dsnoop:CARD=Generic_1,DEV=1
    HD-Audio Generic, ALC1220 Digital
    Direct sample snooping device
hw:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    Direct hardware device without any conversions
hw:CARD=Generic_1,DEV=1
    HD-Audio Generic, ALC1220 Digital
    Direct hardware device without any conversions
plughw:CARD=Generic_1,DEV=0
    HD-Audio Generic, ALC1220 Analog
    Hardware device with all software conversions
plughw:CARD=Generic_1,DEV=1
    HD-Audio Generic, ALC1220 Digital
    Hardware device with all software conversions
usbstream:CARD=Generic_1
    HD-Audio Generic
    USB Stream Output
alsamixer:
Image

I tried playing some noise with speaker-test:

Code: Select all

speaker-test -c 6 -l 1 -P 3 -D plughw:1,0
This "plays" all right, except that there's no sound. I assume this is the set of 3.5mm jacks which aren't currently connected. I also tried this:

Code: Select all

speaker-test -c 6 -l 1 -P 3 -D plughw:1,1


It plays noise on the front left and right speakers, with only the optical cable connected, and reports other channels as "Unused". I've tried playing some video files with SMPlayer + mpv over Pulseaudio and with VLC using its own sound device selection. I've also tried some AC3 and DTS settings on SMPlayer and pavucontrol.

Here's pacmd list-cards output for the relevant card:

Code: Select all

    index: 1
	name: <alsa_card.pci-0000_38_00.6>
	driver: <module-alsa-card.c>
	owner module: 7
	properties:
		alsa.card = "1"
		alsa.card_name = "HD-Audio Generic"
		alsa.long_card_name = "HD-Audio Generic at 0xfe480000 irq 88"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:38:00.6"
		sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:38:00.6/sound/card1"
		device.bus = "pci"
		device.vendor.id = "1022"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
		device.product.id = "15e3"
		device.product.name = "Family 17h (Models 10h-1fh) HD Audio Controller"
		device.string = "1"
		device.description = "Family 17h (Models 10h-1fh) HD Audio Controller"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	profiles:
		input:analog-stereo: Analoginen stereo Input (priority 65, available: no)
		output:analog-stereo: Analoginen stereo Output (priority 6500, available: no)
		output:analog-stereo+input:analog-stereo: Analoginen stereo, molemmat suunnat (priority 6565, available: no)
		output:analog-surround-21: Analoginen tilaääni 2.1 Output (priority 1300, available: no)
		output:analog-surround-21+input:analog-stereo: Analoginen tilaääni 2.1 Output + Analoginen stereo Input (priority 1365, available: no)
		output:analog-surround-40: Analoginen tilaääni 4.0 Output (priority 1200, available: no)
		output:analog-surround-40+input:analog-stereo: Analoginen tilaääni 4.0 Output + Analoginen stereo Input (priority 1265, available: no)
		output:analog-surround-41: Analoginen tilaääni 4.1 Output (priority 1300, available: no)
		output:analog-surround-41+input:analog-stereo: Analoginen tilaääni 4.1 Output + Analoginen stereo Input (priority 1365, available: no)
		output:analog-surround-50: Analoginen tilaääni 5.0 Output (priority 1200, available: no)
		output:analog-surround-50+input:analog-stereo: Analoginen tilaääni 5.0 Output + Analoginen stereo Input (priority 1265, available: no)
		output:analog-surround-51: Analoginen tilaääni 5.1 Output (priority 1300, available: no)
		output:analog-surround-51+input:analog-stereo: Analoginen tilaääni 5.1 Output + Analoginen stereo Input (priority 1365, available: no)
		output:iec958-stereo: Digitaalinen stereo (IEC958) Output (priority 5500, available: unknown)
		output:iec958-stereo+input:analog-stereo: Digitaalinen stereo (IEC958) Output + Analoginen stereo Input (priority 5565, available: unknown)
		output:iec958-ac3-surround-51: Digitaalinen tilaääni 5.1 (IEC958/AC3) Output (priority 300, available: no)
		output:iec958-ac3-surround-51+input:analog-stereo: Digitaalinen tilaääni 5.1 (IEC958/AC3) Output + Analoginen stereo Input (priority 365, available: no)
		off: Poissa (priority 0, available: unknown)
	active profile: <output:iec958-stereo+input:analog-stereo>
	sinks:
		alsa_output.pci-0000_38_00.6.iec958-stereo/#1: Family 17h (Models 10h-1fh) HD Audio Controller Digitaalinen stereo (IEC958)
	sources:
		alsa_output.pci-0000_38_00.6.iec958-stereo.monitor/#1: Monitor of Family 17h (Models 10h-1fh) HD Audio Controller Digitaalinen stereo (IEC958)
		alsa_input.pci-0000_38_00.6.analog-stereo/#2: Family 17h (Models 10h-1fh) HD Audio Controller Analoginen stereo
	ports:
		analog-input-front-mic: Front Microphone (priority 8500, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-rear-mic: Rear Microphone (priority 8200, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-linein: Linjasisääntulo (priority 8100, latency offset 0 usec, available: no)
			properties:
				
		analog-output-lineout: Line Out (priority 9900, latency offset 0 usec, available: no)
			properties:
				
		analog-output-headphones: Analoginen kuulokeliitäntä (priority 9000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"
		iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
I've tried setting the card's profile like this:

Code: Select all

pacmd set-card-profile 1 output:iec958-ac3-surround-51
There's no errors, but also it has no effect on anything as far as I can tell. In pavucontrol, I've got many "unplugged" options as well as IEC958 digital stereo (two options, with and without input) and IEC958/AC3 digital 5.1 surround output. If I select the 5.1 surround, pavucontrol switches back to stereo + input (I don't have any audio inputs connected). On some occasions, the profile hasn't immediately reverted to stereo, but then I get no sound from VLC, and SMPlayer plays videos at many times normal speed with only very short pieces of sound audible.

So I've got no idea what's going on here or what to do about it, and I'd appreciate some help.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Can't get surround sound working with optical output

#2 Post by Head_on_a_Stick »

deadbang

grimripper
Posts: 4
Joined: 2019-04-04 16:51

Re: Can't get surround sound working with optical output

#3 Post by grimripper »

Keeping pavucontrol on will (mostly) cause the 5.1 surround profile to revert to stereo + input.
I've seen before the Ubuntu wiki linked in that answer, but it's pretty old and for Ubuntu. Is it still relevant and also suitable for Debian?
It seems an a52 converter is included in the libasound2-plugins package. I have libasound_module_pcm_a52.so in /usr/lib/x86_64-linux-gnu/alsa-lib/ but no /usr/lib/alsa-lib/ directory or libasound_module_pcm_a52.la file anywhere. Also uname -i is "unknown".

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Can't get surround sound working with optical output

#4 Post by Head_on_a_Stick »

grimripper wrote:I've seen before the Ubuntu wiki linked in that answer, but it's pretty old and for Ubuntu. Is it still relevant and also suitable for Debian?
No idea, I don't use PulseAudio or surround sound. Why not try it and see for yourself?
deadbang

grimripper
Posts: 4
Joined: 2019-04-04 16:51

Re: Can't get surround sound working with optical output

#5 Post by grimripper »

I tried it, and now I no longer have any audio over the optical output. I'll try later to undo what I did now and see if it comes back. The configurations change seems to change something, since with it speaker-test plays six channels over the iec958 device (inaudibly).

EDIT: I got sound back and tried searching specifically for ALSA and a52. Turns out I already had an ALSA conf which seems to have a similar intent to the conf files I created based on that Ubuntu wiki:

cat /usr/share/alsa/alsa.conf.d/60-a52-encoder.conf

Code: Select all

pcm.a52 {
	@args [ CARD SLAVE RATE BITRATE CHANNELS ]
	@args.CARD {
		type integer
		default {
			@func refer
			name defaults.pcm.card
		}
	}
	@args.SLAVE {
		type string
	}
	@args.RATE {
		type integer
		default 48000
	}
	@args.BITRATE {
		type integer
		default 448
	}
	@args.CHANNELS {
		type string
		default 6
	}
	type a52
	card $CARD
	slavepcm $SLAVE
	rate $RATE
	bitrate $BITRATE
	channels $CHANNELS
	hint {
		show {
			@func refer
			name defaults.namehint.basic
		}
                description "Plugin to convert multichannel stream to A52 (AC3) bitstream"
	}
}
I didn't really find out what should be done with it. I tried some confs but only got "aplay: main:828: audio open error: No such file or directory". I tried editing the conf file cat /usr/share/alsa/pcm/iec958.conf:

Code: Select all

#
#  Hardware output from iec958
#

pcm.!iec958 {
	@args [ CARD DEV AES0 AES1 AES2 AES3 ]
	@args.CARD {
		type string
		default {
			@func getenv
			vars [
				ALSA_IEC958_CARD
				ALSA_PCM_CARD
				ALSA_CARD
			]
			default {
				@func refer
				name defaults.pcm.iec958.card
			}
		}
	}
	@args.DEV {
		type integer
		default {
			@func igetenv
			vars [
				ALSA_IEC958_DEVICE
			]
			default {
				@func refer
				name defaults.pcm.iec958.device
			}
		}
	}
	@args.AES0 {
		type integer
		# consumer, not-copyright, emphasis-none, mode=0
		default 0x04
	}
	@args.AES1 {
		type integer
		# original, PCM coder
		default 0x82
	}
	@args.AES2 {
		type integer
		# source and channel
		default 0x00
	}
	@args.AES3 {
		type integer
		# fs=48000Hz, clock accuracy=1000ppm
		default 0x02
	}
	type empty
	slave.pcm {
		@func refer
		name {
			@func concat
			strings [
				"cards."
				{
					@func card_driver
					card $CARD
				}
				".pcm.iec958." $DEV ":"
				"CARD=" $CARD ","
				"AES0=" $AES0 ","
				"AES1=" $AES1 ","
				"AES2=" $AES2 ","
				"AES3=" $AES3
			]
		}
	}
	hint {
		show {
			@func refer
			name defaults.namehint.basic
		}
		description "IEC958 (S/PDIF) Digital Audio Output"
		device $DEV
	}
}
I changed "type empty" to "type a52" like in some examples I've seen, but it only caused a different error:

Code: Select all

ALSA lib pcm_a52.c:912:(_snd_pcm_a52_open) Unknown field slave
I've still got no clue what's going on here or what should be done about it.

frazatto
Posts: 34
Joined: 2018-06-21 11:48
Has thanked: 3 times

Re: Can't get surround sound working with optical output

#6 Post by frazatto »

Hey man, sorry to resurrect your thread, but I'm on the same boat and I understood I should not create a new one.

Have you found a way to make it work???
For what I seen, I already went to all the links you did and ended up here hahahaha
But I think I ALMOST made it work!!!

This thread on Ubunto helped me a lot:
https://askubuntu.com/questions/483555/ ... untu-14-04

The last comment in particular, but module-switch-on-connect is not on the list in Debian 10 and I end up with crackling sound on all speakers and all videos have a hard time loading, lagging a lot.
I can see the receiver recognizing 5.1 input but it keeps blinking to stereo, so I believe something changed between that comment and today that reversed the solution.

This other thread took me a little further:
https://unix.stackexchange.com/question ... pulseaudio
linuxmarc comment uses a similar workaround but also uncomments the last two lines on the config file and it stopped trying to switch, receiver recognizes 5.1 all the time but the issues with sound and video continues.

Besides waiting for Bullseye next week, I'm out of ideas.......

grimripper
Posts: 4
Joined: 2019-04-04 16:51

Re: Can't get surround sound working with optical output

#7 Post by grimripper »

Nope, I never got anything except stereo out of the optical.

I found something about the (probably proprietary) encoding the surround output would use not being supported out of the box, and some instructions for compiling something with support for something that wasn't supported out of the box, but none of those instructions were applicable to the environment I had on my Debian Buster.

So eventually my "academic interest" ran out. I'm using HDMI for output anyway, and there's also a DisplayPort connector for backup, so surround sound over optical would only be really necessary if audio output broke for both HDMI and DisplayPort (or there was no matching input) but I'd still get video output over at least one of them.

frazatto
Posts: 34
Joined: 2018-06-21 11:48
Has thanked: 3 times

Re: Can't get surround sound working with optical output

#8 Post by frazatto »

Thanks to let me know anyway, maybe someone in the future will have more luck.
Just to document my efforts, I was able to pinpoint the changes that made most difference (Debian 10 and 11 in 2021).

Uncomment and change this fields at:

Code: Select all

/etc/pulse/daemon.conf
default-sample-rate = 48000
default-sample-channels = 6
Reboot and you will see two changes:
When you select the 5.1 Digital S/PDIF in Pavucontrol, it will create the behavior I previously mentioned (crackling sound on all speakers and all videos have a hard time loading).
BUT IT WILL ALSO! (if you have a Radeon graphic card) permit you yo select HDMI 5.1 Out on normal Sound Control!!!!!! And it works kind of ok, if you play stereo it will send the output to all the speakers and that sucks, but if you have a proper surround sound source on the browser it will play trough.

That is very strange, I have no idea how it comes to be, it only works on this motherboard.....but there it is.....

greg9
Posts: 34
Joined: 2021-09-14 06:29
Has thanked: 6 times

Re: Can't get surround sound working with optical output

#9 Post by greg9 »

just an idea, as most of the posters here seem to be using pulseaudio.
run

Code: Select all

alsamixer -c0
if it shows S/PFIF controls you are on the correct card. Otherwise change last command to -c1

Once spdif shows up, toggle on and then off then on ....one or more controls showing
or toggle off then on ----by pressing the m key for mute (or unmute)
Now go back into pavucontrol and see if you can see a difference.

Post Reply