Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linuxPackages.gvusb2: init at 2020-07-27-unstable #109560

Closed
wants to merge 7 commits into from

Conversation

djanatyn
Copy link
Contributor

Motivation for this change

This is a new linux driver for the I-O DATA GV-USB2 capture card:

❯ find $(nix-build -A linuxPackages_latest.gvusb2) -type f
/nix/store/w77k64zb6v3x6sb9mwsf0n4qpjydkr6r-gvusb2-2020-07-27-unstable/lib/modules/5.10.7/extra/gvusb2-sound.ko
/nix/store/w77k64zb6v3x6sb9mwsf0n4qpjydkr6r-gvusb2-2020-07-27-unstable/lib/modules/5.10.7/extra/gvusb2-video.ko
❯ lsmod | grep gvusb2
gvusb2_video           32768  0
videobuf2_vmalloc      20480  1 gvusb2_video
videobuf2_v4l2         28672  1 gvusb2_video
videobuf2_common       53248  2 gvusb2_video,videobuf2_v4l2
videodev              253952  3 gvusb2_video,videobuf2_v4l2,videobuf2_common
gvusb2_sound           16384  0
snd_pcm               114688  6 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_pcm_oss,gvusb2_sound,snd_hda_core
snd                    90112  17 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm_oss,snd_pcm,gvusb2_sound,snd_mixer_oss
i2c_core               86016  7 videodev,drm_kms_helper,gvusb2_video,i2c_algo_bit,amdgpu,i2c_piix4,drm
usbcore               278528  6 xhci_hcd,gvusb2_video,usbhid,btusb,xhci_pci,gvusb2_sound

Using the driver, I was able to play Super Mario 64 on a CRT with simultaneous playback in VLC / OBS-Studio:

[  226.481672] usb 1-3: new high-speed USB device number 8 using xhci_hcd
[  226.683104] usb 1-3: config 1 interface 0 altsetting 0 endpoint 0x81 has invalid wMaxPacketSize 0
[  226.724103] usb 1-3: New USB device found, idVendor=04bb, idProduct=0532, bcdDevice= 0.05
[  226.724104] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=10
[  226.724105] usb 1-3: Product: I-O DATA GV-USB2
[  226.724106] usb 1-3: Manufacturer: I-O DATA
[  226.724107] usb 1-3: SerialNumber: 000000000000001
...
[  226.772110] usbcore: registered new interface driver gvusb2-snd
[  226.776674] mc: Linux media interface: v0.10
[  226.787110] videodev: Linux video capture interface: v2.00
[  226.792728] gvusb2-vid 1-3:1.0: found video at altsetting 5 endpoint 1
[  227.071151] usbcore: registered new interface driver gvusb2-vid

I tested with kernel 5.10.7:

    boot.extraModulePackages = with linuxPackages_latest; [
      gvusb2
    ];

vfl_type_grabber.patch addresses Isaac-Lozano/GV-USB2-Driver#2 on appropriate kernel versions.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@djanatyn
Copy link
Contributor Author

I saw that the upstream repository had two licenses in the tree:

I have the license set to GPL. Maybe it should be set to both? I'm not sure what should apply.

@SuperSandro2000
Copy link
Member

I saw that the upstream repository had two licenses in the tree:

I have the license set to GPL. Maybe it should be set to both? I'm not sure what should apply.

They apply both.

gvusb2-sound-y := gvusb2-snd.o gvusb2-core.o
gvusb2-video-y := gvusb2-vid.o gvusb2-v4l2.o gvusb2-core.o gvusb2-i2c.o

+KERNEL_SOURCE_DIR := /lib/modules/$(shell uname -r)/build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this patch? It looks like it changes nothing for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Makefile included with the project doesn't use any environment variables:

❯ git show 811fb0f6ee4ef62e0e346a293bb5e3b61ad10b7d:Makefile
obj-m += gvusb2-sound.o gvusb2-video.o

gvusb2-sound-y := gvusb2-snd.o gvusb2-core.o
gvusb2-video-y := gvusb2-vid.o gvusb2-v4l2.o gvusb2-core.o gvusb2-i2c.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Without this patch, the build is running the default make -C /lib/modules/5.10.7/build M=/build/source modules and failing:

❯ nix-build -A linuxPackages_latest.gvusb2
these derivations will be built:
  /nix/store/warcxpjpb5kknzkwrnbq21b50wavbz1k-gvusb2-2020-07-27-unstable.drv
building '/nix/store/warcxpjpb5kknzkwrnbq21b50wavbz1k-gvusb2-2020-07-27-unstable.drv'...
unpacking sources
unpacking source archive /nix/store/iwc4l1vs3sqxmf99cq0839dl2zh2xnn1-source
source root is source
patching sources
configuring
no configure script, doing nothing
building
build flags: SHELL=/nix/store/kl6lr3czkbnr6m5crcy8ffwfzbj8a22i-bash-4.4-p23/bin/bash KERNEL_SOURCE_DIR=/nix/store/2kxfgzzdwi1nj6axsi43r05mcd6ncqg4-linux-5.10.7-dev/lib/modules/5.10.7/build INSTALL_MOD_PATH=\$\(out\)
make -C /lib/modules/5.10.7/build M=/build/source modules
make[1]: *** /lib/modules/5.10.7/build: No such file or directory.  Stop.
make: *** [Makefile:7: all] Error 2
builder for '/nix/store/warcxpjpb5kknzkwrnbq21b50wavbz1k-gvusb2-2020-07-27-unstable.drv' failed with exit code 2
error: build of '/nix/store/warcxpjpb5kknzkwrnbq21b50wavbz1k-gvusb2-2020-07-27-unstable.drv' failed

I'm using #105899 as a reference along with https://nixos.wiki/wiki/Linux_kernel#Packaging_out-of-tree_kernel_modules.

I'm adding an environment variable KERNEL_SOURCE_DIR to the Makefile to choose the right directory during the build, using ${kernel.dev}:
make -C /nix/store/2kxfgzzdwi1nj6axsi43r05mcd6ncqg4-linux-5.10.7-dev/lib/modules/5.10.7/build M=/build/source modules

build flags: SHELL=/nix/store/kl6lr3czkbnr6m5crcy8ffwfzbj8a22i-bash-4.4-p23/bin/bash KERNEL_SOURCE_DIR=/nix/store/2kxfgzzdwi1nj6axsi43r05mcd6ncqg4-linux-5.10.7-dev/lib/modules/5.10.7/build INSTALL_MOD_PATH=\$\(out\)
make -C /nix/store/2kxfgzzdwi1nj6axsi43r05mcd6ncqg4-linux-5.10.7-dev/lib/modules/5.10.7/build M=/build/source modules

I don't have much experience building kernel modules and may be missing some conventions here.

pkgs/os-specific/linux/gvusb2/default.nix Outdated Show resolved Hide resolved
pkgs/os-specific/linux/gvusb2/default.nix Outdated Show resolved Hide resolved
pkgs/os-specific/linux/gvusb2/default.nix Outdated Show resolved Hide resolved
@SuperSandro2000
Copy link
Member

  trying https://github.com/Isaac-Lozano/gvusb2/archive/811fb0f6ee4ef62e0e346a293bb5e3b61ad10b7d.tar.gz

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
error: cannot download source from any mirror

@djanatyn
Copy link
Contributor Author

  trying https://github.com/Isaac-Lozano/gvusb2/archive/811fb0f6ee4ef62e0e346a293bb5e3b61ad10b7d.tar.gz

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
error: cannot download source from any mirror

Sorry, I changed pname without rebuilding. I pushed the correct repo name: 657b7b8

@SuperSandro2000
Copy link
Member

This is a semi-automatic executed nixpkgs-review which is checked by a human on a best effort basis and does not build all packages (e.g. lumo, tensorflow or pytorch).
If you have any questions or problems please reach out to SuperSandro2000 on IRC.

Result of nixpkgs-review pr 109560 run on x86_64-linux 1

2 packages marked as broken and skipped:
  • linuxPackages_hardkernel_4_14.gvusb2
  • linuxPackages_hardkernel_latest.gvusb2
2 packages failed to build and are new build failures:
16 packages built:
  • linuxPackages.gvusb2 (linuxPackages_5_4.gvusb2)
  • linuxPackages_4_14.gvusb2
  • linuxPackages_4_19.gvusb2
  • linuxPackages_4_9.gvusb2
  • linuxPackages_5_10.gvusb2 (linuxPackages_latest.gvusb2)
  • linuxPackages_5_9.gvusb2
  • linuxPackages_hardened.gvusb2
  • linuxPackages_latest-libre.gvusb2
  • linuxPackages_latest_hardened.gvusb2
  • linuxPackages_latest_xen_dom0.gvusb2
  • linuxPackages_latest_xen_dom0_hardened.gvusb2
  • linuxPackages_lqx.gvusb2
  • linuxPackages_testing_bcachefs.gvusb2
  • linuxPackages_xen_dom0.gvusb2
  • linuxPackages_xen_dom0_hardened.gvusb2
  • linuxPackages_zen.gvusb2

@stale
Copy link

stale bot commented Jul 21, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 21, 2021
@Artturin
Copy link
Member

Artturin commented Feb 2, 2023

Reopen and rebase if you're still interested in this.

@Artturin Artturin closed this Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants