Author Topic: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)  (Read 13056 times)

m3freak

  • Veteran
  • ***
  • Posts: 125
    • View Profile
HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« on: February 05, 2012, 05:34:25 am »
I'm a busy guy.  It's been very, very hard for me to find the time to learn enough about the innards of LinuxMCE to tackle the problem of the non-working HDMI sound on my Jetway Mini-top.  However, a week ago after several months of wimpy twiddling and random bashing of the keyboard, I finally figured out how to get HDMI sound working in the crappy 10.04 release (note: I do not like Ubuntu, but don't take that to mean I don't like LinuxMCE.  I will be randomly raging against Upoontu, so don't cry).

I have no idea if what I'm about to spell out will work on the current stable LinuxMCE release. I gave up on it while ago because of stupidness (e.g. my second NIC not working without manually building a new driver).  I also pieced together most of what needed to be done from several different sources. However, figuring out the order and the repeated testing, plus some key pieces to the final solution were all my doing.  If I wasn't already very well experienced with Linux systems, I would have been completely lost.  Overall it was not fun, but man was I happy when it all came together.

So...

PRO TIP: make sure the Mini-top's (or whatever it is you're using for your MD) HDMI port is actually plugged into something and that something is powered ON!

NOTE: All these steps were performed on the MD after I logged into it via SSH.  I did not do a "chroot" to the MD's directory on the core (i.e. /usr/pluto/diskless/XX).

1. In /etc/modprobe.conf/blacklist, add at the bottom the following:
Code: [Select]
blacklist snd-usb-audio
This was important.  I needed to blacklist this module to prevent it from breaking the MD's boot process and to ensure ONLY the nvidia HDMI audio was enabled.

2. In /etc/modprobe.conf/alsa-base.conf, add this, again at the bottom of the file:
Code: [Select]
alias snd-card-0 snd-hda-intel
options snd-hda-intel enable_msi=0 probe_mask=0xfff2

This alias bullshit I pulled from memory....from way, way back in the early days of Fedora when I had to battle with alsa to get sound working.  I'm not sure it's actually needed here, but I put the crap in anyway.  The second line came from the xbmc forums and the xbmc wiki - so awesome.

3. Upgrade alsa.  I used this page as a guide:

http://monespaceperso.org/blog-en/2010/05/02/upgrade-alsa-1-0-23-on-ubuntu-lucid-lynx-10-04/

I only upgraded alsa-driver and alsa-libs. There's no need to update alsa-utils.

4. Reboot

5, Upgrade the nvidia drivers.  Nothing special to note here.

6. Reboot

7. Install this package:
Code: [Select]
apt-get install linux-backports-modules-alsa-$(uname -r)
This was the biggest piece of the puzzle.  Without this package, the nvidia soundcard would not be detected by alsa.  I have no idea how the shit I figured this crap out.  I think I read about it somewhere on the net.  I know for sure it wasn't at all in reference to LinuxMCE, the ION2 or HDMI sound.  FUCK!

8. Reboot

9. Edit, /usr/pluto/bin/AVWizard_AudioConnector.sh, like so:
Code: [Select]
#!/bin/bash

. /usr/pluto/bin/AVWizard-Common.sh
. /usr/pluto/bin/Utils.sh

Param="$1"
case "$Param" in
        'Analog Stereo')
                XineConfSet audio.output.speaker_arrangement 'Stereo 2.0' "$XineConf"
                XineConfSet audio.device.alsa_front_device plughw:0 "$XineConf"
                XineConfSet audio.device.alsa_default_device plughw:0 "$XineConf"
        ;;
        'SPDIF Coaxial'|'SPDIF Optical')
                XineConfSet audio.output.speaker_arrangement 'Pass Through' "$XineConf"
                XineConfSet audio.device.alsa_front_device asym_spdif "$XineConf"
                XineConfSet audio.device.alsa_default_device asym_spdif "$XineConf"
                XineConfSet audio.device.alsa_passthrough_device "iec958:AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2" "$XineConf"
        ;;
        'HDMI')
                XineConfSet audio.output.speaker_arrangement 'Pass Through' "$XineConf"
                #XineConfSet audio.device.alsa_front_device asym_hdmi "$XineConf"
                XineConfSet audio.device.alsa_front_device nvidia_hdmi "$XineConf"
                #XineConfSet audio.device.alsa_default_device asym_hdmi "$XineConf"
                XineConfSet audio.device.alsa_default_device nvidia_hdmi "$XineConf"
                XineConfSet audio.device.alsa_passthrough_device "hdmi:AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2" "$XineConf"
        ;;
esac
/usr/pluto/bin/SetupAudioVideo.sh

Makes sure Xine uses the nvidia HDMI card (configured below).

10. At the bottom of /usr/pluto/templates/asound.conf, add this:
Code: [Select]
pcm.nvidia_hdmi {
        type hw
        card 0
        device 3
}

This configures the HDMI "card" for use with alsa.

8. Edit, the Setup_AsoundConf() function in /usr/pluto/bin/SetupAudioVideo.sh like so:
Code: [Select]
Setup_AsoundConf()
{
        local AudioSetting="$1"
        local SoundCard

        SoundCard=$(GetDeviceData "$PK_Device" "$DEVICEDATA_Sound_Card"|cut -f2 -d";")
        SoundCard=$(TranslateSoundCard "$SoundCard")
        if [[ -z "$SoundCard" ]]; then
                SoundCard=0
        fi
        sed -r "s,%MAIN_CARD%,$SoundCard,g" /usr/pluto/templates/asound.conf >/etc/asound.conf

        case "$AudioSetting" in
                *[CO]*)
                        # audio setting is Coaxial or Optical, i.e. S/PDIF
                        #echo 'pcm.!default asym_spdif' >>/etc/asound.conf
                        echo 'pcm.!default nvidia_hdmi' >> /etc/asound.conf
                        EnableDigitalOutputs
                ;;
                *H*)
                        # audio setting is HDMI
                        #echo 'pcm.!default asym_hdmi' >>/etc/asound.conf
                        echo 'pcm.!default nvidia_hdmi' >> /etc/asound.conf
                        EnableDigitalOutputs
                ;;
                *)
                        # audio setting is Stereo or something unknown
                        echo 'pcm.!default asym_analog' >>/etc/asound.conf
                ;;
        esac
}

That makes the nvidia HDMI card configured in the previous step the default output for sound.

9. Reboot

When the MD came back up, "aplay -L" correctly reported the NVidia HDMI sound card, and because of the mask (in alsa-base.conf), only one soundcard was shown.  You should see the same.

Now everything works.  mp3s, MKVs, AVIs, stereo sound, multichannel, dolby, DTS, LPCM...you name it.  Sound over HDMI works flawlessly.  Also, my changes to a couple of the scripts have assured reboots won't adversely affect sound over HDMI.

The only problem is I'm sure a future update will likely blow some of my changes away.  I hope the devs can incorporate what I've done into the setup scripts, thereby truly automating this particular MD's LinuxMCE setup.

Oh, one final note: I'll make sure the wiki article has a better flow for the steps (a couple are out of logical order, though the way I wrote the above how-to won't prevent HDMI sound from being correctly setup).

I hope this helps someone!

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #1 on: February 05, 2012, 11:05:03 am »
m3freak,

nice.

Could you amend your script changes in a way, that it detects the Jetway hardware and does the changes only for that hardware? A patch like that would be helpful, and could be incorporated into svn, so other people directly have a successful experience, without needing to modify scripts themselves.

m3freak

  • Veteran
  • ***
  • Posts: 125
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #2 on: February 05, 2012, 05:36:57 pm »
m3freak,

nice.

Could you amend your script changes in a way, that it detects the Jetway hardware and does the changes only for that hardware? A patch like that would be helpful, and could be incorporated into svn, so other people directly have a successful experience, without needing to modify scripts themselves.

The only problem is I don't know what to modify.  Where does the detection happen?

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #3 on: February 05, 2012, 06:00:02 pm »
I would do the detection in the scripts itself.

Murdock

  • Guru
  • ****
  • Posts: 229
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #4 on: May 05, 2012, 05:04:35 pm »
I'll take this on, i've opened ticket http://svn.linuxmce.org/trac.cgi/ticket/1461 to track the integration work and testing

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #5 on: May 05, 2012, 05:13:38 pm »
Make sure to confer with l3mce, as he is working on everything install related atm.

l3mce

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1084
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #6 on: May 06, 2012, 02:59:36 am »
Ticket updated
I never quit... I just ping out.

Murdock

  • Guru
  • ****
  • Posts: 229
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #7 on: May 06, 2012, 03:09:31 am »
Sounds good, I've reassigned the ticket to L3mce - if i can help please let me know!

l3mce

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1084
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #8 on: May 06, 2012, 05:34:51 am »
It occurs now after looking over this that an alsa upgrade AND and nvidia upgrade is occurring.

In 1004 this will not be automated. Alsa is pegged there for reasons which apply to other areas of the system as I understand it. I cannot break parts of the system automatically for this.

However, I would be interested in working to make this happen in 1004 with the native nvidia-glx-260 and alsa .23. It appears that the video driver upgrade doesn't really make any difference. While working with someone in IRC they were able to get their audio going with the alsa upgrade on nvidia-glx-195, having forgotten to add the ppa before forcing the nvidia-current install.

So... I am given to believe it is just an alsa thing, and as alsa upgrade is required for the nvidia 295 driver from swat (the .40 edition has regression issues btw), I am not sure if anyone has tried to get alsa .23 going, as people presume it is the graphics driver which is failing to even run avwizard, or play movies in MD... when in truth it is the same busted alsa config causing this behavior.

The only possible reason to upgrade to the new driver is for the 5 chipsets which have the new VDPAU rev D.

Anyway... until I get my hands on the hardware, or an ssh hole to it, I can only guess at what might work. If you don't mind investing the time, I would be curious if you could similarly make this HW work with our native drivers.
I never quit... I just ping out.

Murdock

  • Guru
  • ****
  • Posts: 229
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #9 on: May 06, 2012, 02:45:14 pm »
Unfortunately it does require an update from nvidia 265 (so the ion2 architecture may be recognized) AND an update to alsa (to recognize and understand how to work with the updated nvidia hardware), in terms what revision they need to be at or what the cutoff is I don't know and that's pretty much where my investigation died off a couple of months back.

Considering the fundamental nature of these updates, when will 12.04 go into alpha testing? It may be worthy to test the updates we need to recognize this hardware there.

l3mce

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1084
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #10 on: May 06, 2012, 05:54:23 pm »
I got tekoholic through avwizard on a zotac ID41 on the nvidia-glx-195 driver sans hdmi audio. http://reviews.cnet.com/barebones-pcs/zotac-zbox-id41-u/4507-11485_7-34666140.html

I was unable to get esperegu through avwizard on a gt520 (rev D) on the nvidia-glx-260

So... I need to test more. I was also able to get at least one other chipset that is only identified as covered by 295 going on 260 (see http://svn.linuxmce.org/trac.cgi/browser/branches/LinuxMCE-1004/src/BootScripts/nvidia-install.sh for my preparation to switch over to x-swat ppa before encountering the alsa reqs)

So, at least SOME chipsets WILL fire under 260. There are only 5 rev D chipsets.
Big ups to esperegu for giving me access to his.
I never quit... I just ping out.

Murdock

  • Guru
  • ****
  • Posts: 229
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #11 on: May 06, 2012, 05:57:01 pm »
Good job!

l3mce

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1084
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #12 on: May 06, 2012, 06:48:28 pm »
Good job!

I have totally hosed Xconfigure.sh however, and could really use some help when you have some time. I know you are busy. I have hacked it up to work, but I am not convinced that is enough. Drop into IRC when you have time and I will explain/show you what I have done.
I never quit... I just ping out.

Murdock

  • Guru
  • ****
  • Posts: 229
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #13 on: May 06, 2012, 06:59:47 pm »
Will do

l3mce

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1084
    • View Profile
Re: HOW-TO: HDMI sound on a Jetway Mini-top (ION 2)
« Reply #14 on: May 07, 2012, 07:19:06 am »
Noodled it.

Still be cool to chat... drop in sometime :)
I never quit... I just ping out.