Universal HDMI Sound (...Plug n' Play 4 Porteus)

New features which should be implemented in Porteus; suggestions are welcome. All questions or problems with testing releases (alpha, beta, or rc) should go in their relevant thread here, rather than the Bug Reports section.
User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

Re: Static HDMI (...Out Of The Box Audio)

Post#16 by Tonio » 03 May 2015, 21:21

brokenman wrote:I'm attempting to tackle this common problem today.
Don't worry brokenman. It is not big problem. I am looking at installing Slackware on this machine, but am not sure when, openjdk is not working on slackware current at this time, some libgif* not working so iced-tea-web is not working and opening *.jnlp files. I'll have to tackle this first. But let me know if I can do something to help.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Static HDMI (...Out Of The Box Audio)

Post#17 by brokenman » 03 May 2015, 23:19

Well, it is kind of an important element of Porteus and we are seeing more and more people having problems due to dual sound setups. Today I sorted the whole Analog/HDMI thing on my laptop.
I now have some udev rules that automatically send video to HDMI when it is plugged. I also have a script that will ask which card you want to use and give you a test. Works fine for me on three machines tested.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Static HDMI (...Out Of The Box Audio)

Post#18 by brokenman » 04 May 2015, 15:54

If you are saving changes then it will persist. If not then it won't. The whole idea is that user needs to swap sound devices so persistence is not really appropriate. Also if you have a USB install that moves from machine to machine then a persistent asound.conf is no good.

For people that boot into fresh mode and want to select a sound card and keep it persistent, just copy the resulting alsa config file into the rootcopy folder and you're done.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Solved?:Static HDMI (...Out Of The Box Audio)

Post#19 by brokenman » 05 May 2015, 14:58

Yes, on my machine I have made it possible to send the video and sound to HDMI when HDMI is plugged in. I don't use it though. I prefer the video to go to the monitor but the sound to stay on the laptop (kickass Harman Kardon speakers). It is really not so difficult to script this, but there is some buginess when scripts are run via udev.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Solved?:Static HDMI (...Out Of The Box Audio)

Post#20 by brokenman » 07 May 2015, 01:08

Completely automated plug n play is just a matter of using xrandr to find the HDMI device.
xrandr | awk '/ connected/{print$1}'
And using aplay -l to find the HDMI sound device using the output of the above command (E.g HDMI1).
Then a file is created at /etc/asound.conf telling alsa which sound device to use. The problem I encountered was writing the asound.conf file from a udev script. Shouldn't be too hard to figure out once i get some more time. Remember I am creating a universal solution that will work on the majority of machines. If this solution is required just for YOUR machine it is much simpler. Just create two asound config files. One for the analog output and one for the HDMI output. When udev detects a HDMI plugin it creates a symlink at /etc/asound.conf pointing to the correct HDMI config file. If you need help with this just post the output of:

Code: Select all

xrandr && aplay -l
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

Re: Universal HDMI Sound (...Plug n' Play 4 Porteus)

Post#21 by Tonio » 09 May 2015, 00:47

@brokenman
Would you mind posting the script? I ran your commands sugested I get

Code: Select all

guest@porteus:~$ xrandr && aplay -l
Screen 0: minimum 320 x 200, current 1920 x 1200, maximum 16384 x 16384
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 1920x1200+0+0 (normal left inverted right x axis y axis) 593mm x 371mm
   1920x1200      60.0*+
   1920x1080      60.0     59.9  
   1920x1080i     60.1     60.0  
   1680x1050      59.9  
   1400x1050      59.9  
   1280x1024      75.0     60.0  
   1440x900       59.9  
   1280x960       60.0  
   1152x864       75.0  
   1280x720       60.0     59.9  
   1024x768       75.1     70.1     60.0  
   1440x480       60.0     59.9  
   1440x480i      60.1     60.1  
   832x624        74.6  
   800x600        72.2     75.0     60.3     56.2  
   720x480        60.0     59.9  
   640x480        75.0     72.8     66.7     60.0     59.9  
   720x400        70.1  
DVI-0 disconnected (normal left inverted right x axis y axis)
**** List of PLAYBACK Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: ALC887-VD Analog [ALC887-VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 1: ALC887-VD Digital [ALC887-VD Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
guest@porteus:~$ xrandr | awk '/ connected/{print$1}'
HDMI-0
guest@porteus:~$
I have checked the the aplay -l command also and contents of /etc/asound.conf I get

Code: Select all

.... /* removed to save space ********/ ........
state.HDMI {
	control {
	}
}
state.CX23885 {
	control {
	}
}
guest@porteus:~$ cat /etc/asound.conf
cat: /etc/asound.conf: No such file or directory
guest@porteus:~$ 

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Universal HDMI Sound (...Plug n' Play 4 Porteus)

Post#22 by brokenman » 11 May 2015, 15:57

Check if you have a config file at: $HOME/.asound.conf

If so move it elsewhere and run aplay -l again. The output should be something like:

Code: Select all

**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: 92HD99BXX Analog [92HD99BXX Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

Re: Universal HDMI Sound (...Plug n' Play 4 Porteus)

Post#23 by Tonio » 12 May 2015, 23:09

File $HOME/.asound.conf appears to not be found :(

Code: Select all

guest@porteus:~$ cat $HOME/.asound.conf
cat: /home/guest/.asound.conf: No such file or directory
guest@porteus:~$ ls .as*
/bin/ls: cannot access .as*: No such file or directory
guest@porteus:~$ pwd
/home/guest
guest@porteus:~$ find -iname "*.conf" > .allconffiles
guest@porteus:~$ cat .allconffiles 
guest@porteus:~$ su -c 'find -iname "*.conf" > /home/guest/.allconffiles'
Password: 
find: `./.gvfs': Permission denied
guest@porteus:~$ cat .allconffiles 
guest@porteus:~$ su -c 'find -iname "*.conf" > /home/guest/.allconffiles'
Password: 
find: `./.gvfs': Permission denied
guest@porteus:~$
root@porteus:/etc# ls *.conf
ca-certificates.conf  gpm-syn.conf       mtools.conf    smartd.conf
changes-exit.conf     gpm-twiddler.conf  nfsmount.conf  syslog.conf
dhcpcd.conf           host.conf          nscd.conf      updatedb.conf
dnsmasq.conf          ld.so.conf         nsswitch.conf  usb_modeswitch.conf
esd.conf              logrotate.conf     resolv.conf    wpa_supplicant.conf
ffserver.conf         mdadm.conf         sensors3.conf
gpm-root.conf         mke2fs.conf        serial.conf
root@porteus:/etc# cd /root/
root@porteus:~# ls
Desktop/  Documents/  Downloads/  Music/  Pictures/  Video/
root@porteus:~# cat $HOME/.asound.conf
cat: /root/.asound.conf: No such file or directory
root@porteus:~# echo $HOME
/root
root@porteus:~# exit
logout
guest@porteus:~$ echo $HOME
/home/guest
guest@porteus:~$ ls .allconffiles 
.allconffiles
guest@porteus:~$ cat .allconffiles 
Looking at
http://www.maketecheasier.com/setup-hd ... in-linux/
I have done suggested command, and get

Code: Select all

guest@porteus:~$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=SB
    HDA ATI SB, ALC887-VD Analog
    Default Audio Device
sysdefault:CARD=SB
    HDA ATI SB, ALC887-VD Analog
    Default Audio Device
front:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    Front speakers
surround21:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Digital
    IEC958 (S/PDIF) Digital Audio Output
guest@porteus:~$ 
EDIT*2 Created the suggested file .asoundrc with different values for hw 0,3, 0,2, etc and I get

Code: Select all

guest@porteus:~$ aplay -L
ALSA lib conf.c:1697:(snd_config_load1) _toplevel_:7:17:Unexpected char
ALSA lib conf.c:3417:(config_file_open) /home/guest/.asoundrc may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3339:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:3788:(snd_config_update_r) hooks failed, removing configuration
guest@porteus:~$ rm .asoundrc 
So I removed it to get sound again. Thanks for your help and sorry for not reporting back earlier. :(

Code: Select all

root@porteus:~# lspci -vv | grep 'HDMI'
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
I also have a correction, the file /etc/asound.conf does not exist, the one that does is /etc/asound.state

Code: Select all

state.HDMI {
	control {
	}
}
state.CX23885 {
	control {
	}
}
root@porteus:~#
root@porteus:~# lspci -v | grep -i audio
00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 Azalia (Intel HDA) (rev 40)
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
05:00.0 Multimedia video controller: Conexant Systems, Inc. CX23887/8 PCIe Broadcast Audio and Video Decoder with 3D Comb (rev 0f)
root@porteus:~# 

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Universal HDMI Sound (...Plug n' Play 4 Porteus)

Post#24 by brokenman » 14 May 2015, 01:23

I don't see any HDMI audio device in your output. Perhaps you need to try proprietary drivers for this card.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

Re: Universal HDMI Sound (...Plug n' Play 4 Porteus)

Post#25 by Tonio » 14 May 2015, 02:07

If it does not appear, it is there:

Code: Select all

guest@porteus:~/Downloads$ su -c 'lspci -v | grep -i audio'
Password: 
00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 Azalia (Intel HDA) (rev 40)
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
05:00.0 Multimedia video controller: Conexant Systems, Inc. CX23887/8 PCIe Broadcast Audio and Video Decoder with 3D Comb (rev 0f)
guest@porteus:~/Downloads$ su -c 'lspci -vv | grep 'HDMI' '
Password: 
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
guest@porteus:~/Downloads$ 
But the /etc/asound.state shows the same result and I loaded the boot parameter radeon.audio=1 and there is no sound from hdmi. I try the propietary driver(included in austrumi 3.1.7 and it has no sound either FYI). I have slackware64-current as of May 05 to install but have not done so yet. I like to run porteus without hardrive on this machine. I disconnected hard drive because if I leave it connected, it boots into windows 7 :( and does not give me a chance to boot cd/live usb. it has UEFI :(
Do not worry about it, but if you insist on fixing this, or finding a workaround, don't hesitate to post suggestions and I'll try them. Most of the solutions online are for *buntu and/or *buntu based distros which have pulseaudio installed. We don't want to work with that beast here, nor worry about a similar systemd stuff that may find its way :( :cry: over to Slackware which I hope never happens.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Universal HDMI Sound (...Plug n' Play 4 Porteus)

Post#26 by brokenman » 26 Sep 2015, 02:32

Help with what exactly?

If you are talking about getting sound over HDMI then this is what I can offer. Your /etc/asound.conf file should look like this for analog:
defaults.pcm.card 0
defaults.pcm.device 1
defaults.ctl.card 0


and this for HDMI
defaults.pcm.card 1
defaults.pcm.device 3
defaults.ctl.card 1


If the HDMI doesn't work then try replacing number 3 with 7
If this doesn't work I am out of ideas. Probably a driver for nVidia you need and don't have. Please try this in always fresh mode.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Universal HDMI Sound (...Plug n' Play 4 Porteus)

Post#27 by brokenman » 26 Sep 2015, 22:16

The script would do essentially what I just posted (based on your output). I still have the set of scripts here, but from memory the udev implementation was buggy. This is what makes it plug and play. In its current state I was not happy releasing it.

Here is the main script for providing HDMI audio (once you have plugged in):
---------------------------
#!/bin/bash

hdmin=$1

## Backup existing asound.conf
asnd="/etc/asound.conf"
[ -f $asnd ] && mv $asnd ${asnd}.bak

## Get HDMI sound card/device number
cardnum=`aplay -l | awk '/HDMI '$hdmin'/{print$2}' | sed 's/://'`
devnum=`aplay -l | awk '/HDMI '$hdmin'/{print$8}' | sed 's/://'`

## Generate asound.conf
echo "defaults.pcm.card $cardnum" > $asnd
echo "defaults.pcm.device $devnum" >> $asnd
echo "defaults.ctl.card $cardnum" >> $asnd
---------------------------

Then you can test your speakers:
speaker-test -t sin -l 1

WARNING: This sound is irritating so be ready to ctrl + c to exit.
How do i become super user?
Wear your underpants on the outside and put on a cape.

fullmoonremix

Re: Universal HDMI Sound (...Plug n' Play 4 Porteus)

Post#28 by fullmoonremix » 02 Dec 2015, 00:16

Salutations... :good:

Would this script work with OSS?
I now have some udev rules that automatically send video to HDMI when it is plugged.
I'm not really familiar with "udev" but exactly how would I configure these rules for OSS.
I'm not the brightest bulb in the pack... however I'm a quick study if things are broken down for me.

Best Regards... :beer:

Post Reply