CentOS 7 + Nvidia, HDMI and HD video + audio

I just went through the process of installing Cent7, and although the process is supposed to be simpler, there were still many tricks that needed completed for it to work properly. So as I went through the process, I updated my documentation from 4 years ago to reflect what needs done today.

The card

I purchased an Nvidia off-brand ASUS GeForce GT 430 Video Card (without fan) for around $70 new because I wanted it to be quiet.  However, there are many alternatives like the cheaper ASUS GeForce GT 430 low profile with fan or the ASUS GeForce GT 440 with fan, but the important thing is that you get one that is compatible with the VDPAU library – this library is what provides the best hardware acceleration for HD video playback.  MythTV maintains a good list of chipsets that VDPAU supports.

In addition, I wanted my Myth box to be out of sight for both visual appeal and to prevent machine noise around my entertainment center.  So, I purchased a long HDMI cable for this purpose.  CAUTION – I actually struggled with this.  At first I bought what looked like a really nice cable – name brand, CL3 rating and 3D supported.  I found out later that the gauge of the wires used in this cable are terribly small, which caused huge problems with reflection (the best way I can describe reflection is comparing the problem to the old analog term “ghosting”).

Thanks to Amazon’s fantastic return policy, they took the old cable back and I then purchased a Tartan 40 foot HDMI cable instead.  This one had larger 24 AWG wires in it and a lot more insulation – it is noticeably thicker.  This cable, although the same length and run the same way, presents a crystal clear picture.

Installing X / Gnome

EL7 has made things a lot simpler to get X installed, but there were still a few things I stumbled on along the way. So here’s a quick run-down of the steps I followed:

Install X and the driver:

sudo yum groupinstall 'GNOME Desktop'

Switch the system to boot into graphical mode:

sudo systemctl enable graphical.target
sudo systemctl set-default graphical.target

# confirm our new boot is into the graphical environment
systemctl get-default

Install the Nvidia driver:

The Nvidia driver is available via Elrepo, so we’ll install the repository:

sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
sudo rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

Now install the driver:

sudo yum install kmod-nvidia

Reboot

When complete, reboot. You will notice the high resolution boot screen may not appear since the nouveau module is no longer loaded. No worries, all will be well when X starts.

Once up and running, this time you should notice that the Nvidia driver actually loads instead of Nouveau:

$] lsmod | grep nvidia
nvidia               8536971  65
drm                   349210  3 nvidia
i2c_core               40582  3 drm,i2c_i801,nvidia

With all of that set, video should now working properly. One more note – if you have another display to hook up (in the closet, for example) this will likely affect the resolution (adversely) on your TV, whether the second display is hooked up via DVI or VGA, set to secondary, etc.  I suggest leaving your other monitor disconnected and have your TV be your only display device.

Getting audio to work through HDMI

With video behind us, there is still the issue of audio over HDMI and the configuration of Alsa.  At this point, we’re almost there.

You’ll need to install a few audio tools in order to perform the next few steps:

sudo yum install alsa-utils

Now we need to discover some information about your device:

$] sudo aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
	Subdevices: 1/1
	Subdevice #0: subdevice #0

From the above, you will notice that my Nvidia card is card 0.  The other important thing to note is that the input I’m connected to (HDMI) is device #3.

You can also gather this information / confirm this by:

$] cat /proc/asound/card0/eld#3.0
monitor_present         1
eld_valid               1
monitor_name            SAMSUNG

connection_type         HDMI
eld_version             [0x2] CEA-861D or below
edid_version            [0x3] CEA-861-B, C or D
manufacture_id          0x2d4c
product_id              0x3c7
port_id                 0x20000
support_hdcp            0
support_ai              0
audio_sync_delay        0
speakers                [0x1] FL/FR
sad_count               1
sad0_coding_type        [0x1] LPCM
sad0_channels           2
sad0_rates              [0xe0] 32000 44100 48000
sad0_bits               [0xe0000] 16 20 24

Change the card0 to match which card number your Nvidia device is, and eld#3.0 should match the device number (3).  Worst case, you can iterate through the different options until you find the one that shows your TV.

Now, with the information that we’ve gathered above, lets modify some configs.

asound.conf

The alsa configuration file (located in /etc/asound.conf or /etc/alsa/asound.conf) needs to be modified to reflect the information we’ve gathered.

  1. First, remove any other garbage in there
  2. Now add the following lines, using the card# and device# that you found earlier:
pcm.!default {
	type hw
	card 0
	device 3
}

ctl.!default {
	type hw
	card 0
	device 3
}

dist-alsa.conf

Next is the dist-alsa.conf found in /etc/modprobe.d/ folder.  Again with the information that you found above about your device# that is connected to your monitor, use one of these (where X in eld#X.0 corresponds to your device number):

  • eld#0.0 -> 0x101
  • eld#1.0 -> 0x102
  • eld#2.0 -> 0x104
  • eld#3.0 -> 0x108
  1. Comment out any other configuration in this file, especially a line performing:  install snd-pcm ….
  2. Add the following line, updating the probe_mask to match the hex number in the list above:
options snd-hda-intel enable_msi=0 probe_mask=0x108

Group permissions

Using the system-config-users script, or by editing /etc/group, make sure both the “audio” and “video” groups contain your user and/or the user that will be logged into the system when doing audio/video playback.

Reboot

Now that everything has been updated, you should be able to perform one last final reboot.

Fix some annoyances

There are a few really annoying parts of the new Gnome, especially when using it as a media center:

Auto-login to media center user

Gnome settings (System tools -> Settings) > Users > Unlock > Automatic Login > On

Disable screen lock

Gnome settings > Privacy > Screen Lock > Off

Disable screen shield

Clone the extension repo into the correct location:

git clone https://github.com/lgpasquale/gnome-shell-extension-disable-screenshield.git ~/.local/share/gnome-shell/extensions/disable-screenshield@lgpasquale.com

Reload GnomeShell:

Press ALT + F2 then enter r and press Enter.

Activate the extension:
Applications > Utilities > Tweak Tool > Extensions > On

Conclusion

You should now have HD video and audio.  One thing to remember – your TV will always report that it only supports 2 channels.  So if you want to support more than 2 channel audio, you’ll want to run your HDMI to your receiver first, then on to your TV.  This, however, may have an effect on the information returned about video resolution, I’ve not tested this connection method.