Git Product home page Git Product logo

nvhda's Introduction

nvhda

General info

should be obsolete for kernels >=5.4 as the HDA device is enabled per pci quirk. If not, use as a make-shift and report a bug to kernel bugzilla

Linux kernel module to turn on/off Nvidia HD audio device on notebooks. Blatantly copied from Lekensteyn's bbswitch module.

  • Due to a bug regarding re-reading the header type in kernels 4.9 - 4.13, this won't work on these series. Kernels 4.4, 4.14+ are known to work
  • This module will (hopefully) once being superseded by Lukas Wunner's patches https://bugs.freedesktop.org/show_bug.cgi?id=75985#c37

Install

# make
# sudo make install

Install using DKMS

# sudo make -f Makefile.dkms

Uninstall

# sudo make uninstall

or

# sudo make -f Makefile.dkms uninstall

Usage

Since its logic is copied from the bbswitch module, it works like that.

Load Module

# sudo modprobe nvhda

Get status:

# cat /proc/acpi/nvhda

Turn audio on/off:

# sudo tee /proc/acpi/nvhda <<<ON
# sudo tee /proc/acpi/nvhda <<<OFF

Check dmesg for messages.

How it works

See:

ToDo

  • lots of things

nvhda's People

Contributors

hhfeuer avatar kurt-von-laven avatar mibofra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvhda's Issues

nvhda + optimus-manager

Hello!

Could you give an advice about how to set up this module to work together with optimus-manager properly?

I have a laptop that supports Optimus technology.
I installed optimus-manager and use it to switch between Intel and Nvidia GPU.
I've installed your module as well.

The issue is that upon switching to Nvidia card, regardless of the nhvda enabled I still can't see my second audio card in the output of aplay -l
In order to enable it, I have to switch off an then switch on back.

I think about some sort of script (or systemd unit) that will check with which GPU system loaded and enable nvhda if required.

Is it good enough solution or could be better?

Fails to enable: Not multifunction, no audio

Dell Precision 5520 with Quadro M1200 4GB. In case it is relevant, I am using mvidia-xrun on Arch lInux (https://wiki.archlinux.org/index.php/nvidia-xrun).

Enabling nvhda fails here:

nvhda/nvhda.c

Line 150 in 9e9bba5

if (!(hdr_type & 0x80))

yet in my limited understanding the multifunction bit is set (see 0x80 at offset 0x0E at the very bottom).

$ dmesg
[Jan 2 10:53] bbswitch: enabling discrete graphics
[  +0.325967] nvidia-nvlink: Nvlink Core is being initialized, major device number 234
[  +0.100344] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  415.25  Wed Dec 12 10:22:08 CST 2018 (using threaded interrupts)
[  +0.013972] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  415.25  Wed Dec 12 10:02:42 CST 2018
[  +0.002218] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver
[  +0.000002] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:01:00.0 on minor 1
[  +0.010524] nvhda: version 0.01
[  +0.000007] nvhda: Found nv VGA device 0000:01:00.0
[  +0.000006] nvhda: enabling audio
[  +0.000001] nvhda: Not multifunction, no audio
[  +0.000004] nvhda: No audio device found, unsetting config bit.
[  +0.000001] nvhda: Succesfully loaded. Audio 0000:01:00.0 is off
$ lspci
...
01:00.0 3D controller: NVIDIA Corporation GM107GLM [Quadro M1200 Mobile] (rev a2)
...
$ sudo lspci -H1
...
01:00.0 3D controller: NVIDIA Corporation GM107GLM [Quadro M1200 Mobile] (rev a2)
01:00.1 Audio device: NVIDIA Corporation Device 0fbc (rev a1)
...
$ sudo lspci -d 10de:* -xxx
01:00.0 3D controller: NVIDIA Corporation GM107GLM [Quadro M1200 Mobile] (rev a2)
00: de 10 b6 13 07 00 10 00 a2 00 02 03 00 00 80 00
10: 00 00 00 ec 0c 00 00 c0 00 00 00 00 0c 00 00 d0
20: 00 00 00 00 01 e0 00 00 00 00 00 00 28 10 bf 07
30: 00 00 00 00 60 00 00 00 00 00 00 00 0b 01 00 00
40: 28 10 bf 07 00 00 00 00 00 00 00 00 00 00 00 00
50: 00 00 00 00 01 00 00 00 ce d6 23 00 00 00 00 00
60: 01 68 03 00 08 00 00 00 05 78 81 00 78 05 e0 fe
70: 00 00 00 00 00 00 00 00 10 00 02 00 e1 8d 2c 01
80: 30 21 00 00 03 bd 47 00 40 01 01 11 00 00 00 00
90: 00 00 00 00 00 00 00 00 00 00 00 00 13 08 04 00
a0: 00 04 00 00 0e 00 00 00 03 00 1f 00 00 00 00 00
b0: 00 00 00 00 09 00 14 01 00 00 10 80 00 00 00 00
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

HDMI Audio Success Ubuntu 16.04, Nvidia K1000M

To save some others some struggle (took me two days to figure out):

BIOS Display set to Nvidia Optimus
Install hhfeuer/nvhda (this github)
sudo apt purge nvidia*
sudo apt install nvidia-340 (later versions did not work for me)
reboot
configure pulseaudio to use HDMI output device

Error compiling with kernel 5.6

Hi there! I've tried to compile nvhda on Arch with kernel-5.6.3-zen, gcc-9.3.0 and make-4.3., but the following error occurred:

make -C /lib/modules/5.6.3-zen1-1-zen/build M="$(pwd)" modules make[1]: Entering directory '/usr/lib/modules/5.6.3-zen1-1-zen/build' CC [M] /home/smith/.cache/yay/nvhda-dkms-git/src/nvhda/nvhda.o /home/smith/.cache/yay/nvhda-dkms-git/src/nvhda/nvhda.c: In function ‘nvhda_init’: /home/smith/.cache/yay/nvhda-dkms-git/src/nvhda/nvhda.c:250:60: error: passing argument 4 of ‘proc_create’ from incompatible pointer type [-Werror=incompatible-pointer-types] 250 | acpi_entry = proc_create("nvhda", 0664, acpi_root_dir, &nvhda_fops); | ^~~~~~~~~~~ | | | struct file_operations * In file included from ./include/acpi/acpi_bus.h:83, from ./include/linux/acpi.h:32, from /home/smith/.cache/yay/nvhda-dkms-git/src/nvhda/nvhda.c:32: ./include/linux/proc_fs.h:64:24: note: expected ‘const struct proc_ops *’ but argument is of type ‘struct file_operations *’ 64 | struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops); | ^~~~~~~~~~~ cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:268: /home/smith/.cache/yay/nvhda-dkms-git/src/nvhda/nvhda.o] Error 1 make[1]: *** [Makefile:1683: /home/smith/.cache/yay/nvhda-dkms-git/src/nvhda] Error 2 make[1]: Leaving directory '/usr/lib/modules/5.6.3-zen1-1-zen/build' make: *** [Makefile:13: default] Error 2

I managed to compile successfully with the following patch.
nvhda.c.patch.txt

Automatically at boot?

Hi, great job, really appreciated. I am wondering how to modprobe the script automatically at every boot while setting the variable to ON by default. It would be much better than manually do it every time.

Many thanks again!

Bug with Nvidia-driver-460 (Maybe)

Used to work well on Ubuntu 16.04, 18.04 and 20.04 (with re-install), but when the drivers upgraded to 460, there comes bugs.

Basic conditions: Thinkpad P51, Ubuntu 20.04, with nvhda-start.service in /etc/systemd/system and nvhda in /etc/modules
After boot, journalctl -u nvhda-start.service shows that the service is started successfully. Terminal shows:
Input:
cat /proc/acpi/nvhda
Output:
0000:01:00.0 ON
Input:
aplay -l
Output:

card 0: PCH [HDA Intel PCH], device 0: ALC298 Analog [ALC298 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: AE5 [DELL PROFESSIONAL SOUND BAR AE5], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #11

It seems like the audio hasn't been real turned on. I tried to turn it on manually with sudo tee /proc/acpi/nvhda <<<ON, nothing happened.

Nevertheless, in the same condition after boot, if use sudo tee /proc/acpi/nvhda <<<OFF before sudo tee /proc/acpi/nvhda <<<ON, the audio can be turned on.

Therefore, I tried to add /bin/echo OFF >/proc/acpi/nvhda in the nvhda-start.service, but failed to fix this bug.

However, I'm not sure whether this bug comes with the latest driver or some other reasons. It's just a possible cause.

Kernel Update to 4.20.11 and reinstall of Nvidia Driver 418.43-2

Hello,

Together with the Kernel Update 4.20.11 I had to do a complete Reinstallation of the Nvidia Drivers to Version 418.43-2. (Nvidia seems to have decided out of the Blue to move my Graphics Card out of Legacy 390xx to the new Version, after moving it to Legacy just a few months ago...)

I have a Thinkpad W530 using a Nvidia Quadro K2000M. And Nvhda was working perfectly with Nvidia-390xx since October 2018.

  • I removed the Kernel Module from DKMS
  • Removed Nvhda with yay -Rs nvhda-dkms-git
  • Rebooted
  • Reinstalled Nvhda from AUR

'sudo modprobe nvhda' seems also to run through fine. No errors there.
Then to switch on Nvhda also seems to run with 'sudo tee /proc/acpi/nvhda <<<ON'

But even though anything looks fine, I cannot get Audio through Displayport anymore. Config of Bumblebee hasn't changed at all.

dmesg upon enabling nvhda gives me:
[ 2659.797670] nvhda: Found nv audio device 0000:01:00.1 [ 2659.912007] pci 0000:01:00.1: Dropping the link to 0000:01:00.0 [ 2659.912019] nvhda: disabling audio [ 2664.481122] nvhda: enabling audio [ 2664.481160] pci 0000:01:00.1: [10de:0e1b] type 00 class 0x040300 [ 2664.481195] pci 0000:01:00.1: reg 0x10: [mem 0xf1080000-0xf1083fff] [ 2664.481521] nvhda: Audio found, adding [ 2664.481532] pci 0000:01:00.1: BAR 0: assigned [mem 0xf1080000-0xf1083fff] [ 2664.481572] pci 0000:01:00.1: Linked as a consumer to 0000:01:00.0 [ 2664.481760] snd_hda_intel 0000:01:00.1: Disabling MSI [ 2664.481771] snd_hda_intel 0000:01:00.1: Handle vga_switcheroo audio client [ 2665.057288] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input44 [ 2665.057453] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input45 [ 2665.057662] input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input46

Are there any logs by Nvhda to Look up or anything else I can provide?

Edit: Noticed something else weird. If I use Alsamixer the Nvidia Card is detected after turning on Nvhda. But switching is impossible. Graphics card is not shown anywhere else. Gnome Settings just show Internal Speakers.

Needed on Dell Alienware 13R3 with Linux 5.10

Hi, I still need nvhda on
Linux 5.10.4-1-default #1 SMP Wed Dec 30 13:10:15 UTC 2020 (4169c1f) x86_64 x86_64 x86_64 GNU/Linux
for my Dell Alienware 13R3.

Could you please give me a hint how/whom to notify of the missing PCI quirk following your README remark?

Exec format error

For the past few weeks, I've been getting this error at boot:

somody@panda:~$ systemctl status systemd-modules-load.service
● systemd-modules-load.service - Load Kernel Modules
   Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-07-05 12:58:21 CEST; 3min 10s ago
     Docs: man:systemd-modules-load.service(8)
           man:modules-load.d(5)
  Process: 580 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, status=1/FAILURE)
 Main PID: 580 (code=exited, status=1/FAILURE)

Jul 05 12:58:21 panda systemd[1]: Starting Load Kernel Modules...
Jul 05 12:58:21 panda systemd-modules-load[580]: Failed to insert module 'nvhda': Exec format error
Jul 05 12:58:21 panda systemd[1]: systemd-modules-load.service: Main process exited, code=exited, status=1/FAILURE
Jul 05 12:58:21 panda systemd[1]: systemd-modules-load.service: Failed with result 'exit-code'.
Jul 05 12:58:21 panda systemd[1]: Failed to start Load Kernel Modules.

and even manually:

somody@panda:~$ sudo modprobe nvhda
modprobe: ERROR: could not insert 'nvhda': Exec format error

Fedora 28

My notebook:
Dell Inspiron 15 7000 Gaming

01:00.0 3D controller: NVIDIA Corporation GP107M [GeForce GTX 1050 Ti Mobile] (rev a1)
00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04)

Linux berci7 4.17.3-200.fc28.x86_64 #1 SMP Tue Jun 26 14:17:07 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I installed the patch, but not work.

**** List of PLAYBACK Hardware Devices ****
card 0: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC3246 Analog [ALC3246 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
Subdevices: 1/1
Subdevice #0: subdevice #0

Need you any information?
Thank you!

After installation, hdmi dont work...?

Hi, man, how are you?
I discovered this week that my hdmi has no sound. I found your repo and installed this module in my ubuntu 16.04, kernel 4.15. After installing the problem is that even connected with hdmi now it does not display anything. What should I do?

Audio turned off after wake up

Kubuntu 18.04.02
nvidia 1050 TI (390.116)
Turn audio on by sudo tee /proc/acpi/nvhda <<<ON, set GP107GL as default output.
Suspend laptop, wakeup and OS has audio off.
If I execute again sudo tee /proc/acpi/nvhda <<<ON, back GP107GL as default output.
Can I fix it?

Can't switch to HDMI audio output

Hello,

I have a laptop with 2 GPU and use an optimus-manager to switch between inte/nvidia GPU.

For some reason after switching to NVIDIA and turning on nvhda, I can't switch the audio output to HDMI.
HDMI output appears in a list of audio devices, however after switching to HDMI nothing happens, and I can't see any errors and nothing suspicions in dmesg...

What could I do to debug this issue and find out what goes wrong?

Arch linux, kernel - 5.1.15

"invalid ELD data byte 5" when HDMI Cable is connected

..and hdmi audio is not enabled.

kernel 4.15.0 on Ubuntu 18.04 Developer release

$ tail -f /var/log/syslog
Mar 27 19:41:47 GL702VM kernel: [ 9906.147781] nvhda: version 0.01
Mar 27 19:41:47 GL702VM kernel: [ 9906.147788] nvhda: Found nv VGA device 0000:01:00.0
Mar 27 19:41:47 GL702VM kernel: [ 9906.147797] nvhda: Found nv audio device 0000:01:00.1
Mar 27 19:41:47 GL702VM kernel: [ 9906.147800] nvhda: Found nv audio device 0000:01:00.1
Mar 27 19:41:47 GL702VM kernel: [ 9906.147801] nvhda: Succesfully loaded. Audio 0000:01:00.0 is on

Mar 27 19:42:36 GL702VM kernel: [ 9955.125480] snd_hda_codec_hdmi hdaudioC1D0: HDMI: invalid ELD data byte 5
^C

jasmin@GL702VM:~/Downloads/nvhda$ cat /proc/acpi/nvhda 
0000:01:00.0 ON

jasmin@GL702VM:~/Downloads/nvhda$ uname -r
4.15.0-13-generic

jasmin@GL702VM:~/Downloads/nvhda$ apt policy nvidia-driver-390 
nvidia-driver-390:
  Installed: 390.42-0ubuntu1
  Candidate: 390.42-0ubuntu1
  Version table:
 *** 390.42-0ubuntu1 500
        500 http://de.archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages
        100 /var/lib/dpkg/status

sudo modprobe nvhda fails

After runnin sudo make -f Makefil.dkms and obtaining the following output:
image

Running sudo modprobe nvhda returns:
modprobe: ERROR: could not insert 'nvhda': Required key not available

The included systemd scripts are not working

Hello

ExecStart=/bin/echo "ON" >/proc/acpi/nvhda
ExecStart=/bin/echo "OFF" >/proc/acpi/nvhda

Just echos '>' and doesn't perform actual output redirection , this is in Arch Linux systemd 239, not sure if it used to work on earlier versions before

Please modify to the below and it should work

ExecStart=/bin/bash -c "/bin/echo ON >/proc/acpi/nvhda"
ExecStart=/bin/bash -c "/bin/echo OFF >/proc/acpi/nvhda"

Failed installation Kernel 5

Tried to install both using pacmac and dkms for Manjaro, however it fails and does not start.
Kernel 5.3 do install but nothing happens and neither the log is generated.

make.log for kernel 5.2
DKMS make.log for nvhda-0.01 for kernel 5.2.21-1-MANJARO (x86_64) qua nov 13 19:45:51 -03 2019 make[1]: Entering directory '/var/lib/dkms/nvhda/0.01/build' make -C /lib/modules/5.2.21-1-MANJARO/build M="$(pwd)" modules make[2]: Entering directory '/usr/lib/modules/5.2.21-1-MANJARO/build' CC [M] /var/lib/dkms/nvhda/0.01/build/nvhda.o cc1: error: incompatible gcc/plugin versions cc1: error: fail to initialize plugin ./scripts/gcc-plugins/structleak_plugin.so make[3]: *** [scripts/Makefile.build:285: /var/lib/dkms/nvhda/0.01/build/nvhda.o] Error 1 make[2]: *** [Makefile:1597: _module_/var/lib/dkms/nvhda/0.01/build] Error 2 make[2]: Leaving directory '/usr/lib/modules/5.2.21-1-MANJARO/build' make[1]: *** [Makefile:13: default] Error 2 make[1]: Leaving directory '/var/lib/dkms/nvhda/0.01/build'

nvhda: Not multifunction, no audio

Laptop GTX 1050 here, kernel 5.2.8-arch1-1-ARCH.
After sudo tee /proc/acpi/nvhda <<<ON, dmesg shows the following:

[  359.109481] nvhda: enabling audio
[  359.109483] nvhda: Not multifunction, no audio

How can I fix this? Thanks!

MOre important than you might know?

Hello!

I just wanted to report, that I am still using your module, despite having Kernel 5.7 on my Manjaro system
The reason is that after every suspend my system defaults to nvidia's hdmi audio output. I tried about 10(!) different methods for configuring this output as not default in pulse or disabling this output completely, as I don't need it at all - with no effect at all! The nvivida hdmi audio output inevitably takes priority once it's loaded!
So I created a systemd.service as a one shot, that uses your module for disabling the output automatically after every suspend or boot.
It's annoying having to do such workaround, because of the stuborn nvidia driver, but I am glad that the module is there and still working, and I hope it will continue to do so.
Thank you! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.