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

DisplayLink driver and module #18041

Merged
merged 2 commits into from Sep 12, 2016
Merged

DisplayLink driver and module #18041

merged 2 commits into from Sep 12, 2016

Conversation

abbradar
Copy link
Member

Motivation for this change

Fixes #18023

Things done
  • Tested using sandboxing
    (nix.useChroot on NixOS,
    or option build-use-chroot in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

cc @chris-martin for testing. I don't have the necessary hardware so I've just packaged the driver and made a module closely following Arch's AUR package. To enable this:

  services.xserver.videoDrivers = [ "displaylink" ];

@mention-bot
Copy link

@abbradar, thanks for your PR! By analyzing the annotation information on this pull request, we identified @edolstra, @bjornfor and @offlinehacker to be potential reviewers

@chris-martin
Copy link
Contributor

Tested by cherry-picking onto nixos-16.03. Gnome still isn't recognizing an external display.

Journalctl output when connecting a monitor:

Aug 27 14:48:31 renzo kernel: evdi: [D] evdi_painter_connect:433 (dev=-1) Connected with           (null)
Aug 27 14:48:31 renzo kernel: evdi: [D] evdi_detect:69 (dev=1) Painter is connected
Aug 27 14:48:31 renzo kernel: evdi: [D] evdi_detect:69 (dev=1) Painter is connected
Aug 27 14:48:31 renzo kernel: evdi: [D] evdi_painter_get_edid_copy:186 (dev=1) 00 ff ff

Then after unplugging:

Aug 27 14:49:38 renzo kernel: evdi: [D] evdi_painter_disconnect:483 (dev=1) Disconnected from ffff880037728a00
Aug 27 14:49:38 renzo kernel: evdi: [D] evdi_detect:72 Painter is disconnected
Aug 27 14:49:38 renzo kernel: evdi: [W] evdi_painter_disconnect:462 (dev=-1) An unknown connection to ffff880037728a00 tries to close us
Aug 27 14:49:38 renzo kernel: evdi: [W] evdi_painter_disconnect:463  - ignoring
Aug 27 14:49:38 renzo kernel: evdi: [D] evdi_detect:72 Painter is disconnected

@abbradar
Copy link
Member Author

Have you tried xrandr magic as described on ArchWiki?

@chris-martin
Copy link
Contributor

It doesn't seem that displaylink is being seen as a provider. The --listproviders output hasn't changed.

chris@renzo ~> xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x47 cap: 0x2, Sink Output crtcs: 3 outputs: 5 associated providers: 0 name:modesetting
Provider 1: id: 0x2b0 cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 0 name:modesetting
chris@renzo ~> xrandr --current
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
eDP-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 294mm x 165mm
   1920x1080     59.93*+
   1400x1050     59.98  
   1280x1024     60.02  
   1280x960      60.00  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   800x600       60.00    60.32    56.25  
   700x525       59.98  
   640x512       60.02  
   640x480       60.00    59.94  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
chris@renzo ~> xrandr --setprovideroutputsource 1 0
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  140 (RANDR)
  Minor opcode of failed request:  35 (RRSetProviderOutputSource)
  Value in failed request:  0x47
  Serial number of failed request:  16
  Current serial number in output stream:  17

@abbradar
Copy link
Member Author

Try it now. If it doesn't work, I'd be interested in this debug information:

$ systemctl status displaylink
(copy path to the binary)
$ systemctl stop displaylink
$ strace path/to/the/binary

@abbradar
Copy link
Member Author

Oh, and another possible fix: add modesetting to videoDrivers.

@chris-martin
Copy link
Contributor

chris-martin commented Aug 27, 2016

Changed nixos config to services.xserver.videoDrivers = [ "displaylink" "modesetting" ];

chris@renzo ~> systemctl status displaylink
● displaylink.service - DisplayLink Manager Service
   Loaded: loaded (/nix/store/zfircz0a4yvv9zgrgjz57cpmdrkhzcag-unit-displaylink.service/displaylink.service; bad; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sat 2016-08-27 16:31:22 EDT; 4s ago
  Process: 2396 ExecStart=/nix/store/i1sipyqyjd9flmsn181iqdpz6xh3wjpy-displaylink-1.1.62/bin/DisplayLinkManager (code=exited, status=127)
 Main PID: 2396 (code=exited, status=127)

Aug 27 16:31:22 renzo systemd[1]: displaylink.service: Unit entered failed state.
Aug 27 16:31:22 renzo systemd[1]: displaylink.service: Failed with result 'exit-code'.

And from journald:

Aug 27 16:32:36 renzo DisplayLinkManager[2979]: /nix/store/i1sipyqyjd9flmsn181iqdpz6xh3wjpy-displaylink-1.1.62/bin/DisplayLinkManager: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory

@abbradar
Copy link
Member Author

Fixed.

@chris-martin
Copy link
Contributor

chris-martin commented Aug 27, 2016

Service is up now

chris@renzo ~> systemctl status displaylink
● displaylink.service - DisplayLink Manager Service
   Loaded: loaded (/nix/store/09s6bxhim8d8hnwa7sd6xnfkcjmkqb70-unit-displaylink.service/displaylink.service; bad; vendor preset: enabled)
   Active: active (running) since Sat 2016-08-27 16:44:32 EDT; 2min 15s ago
 Main PID: 952 (.DisplayLinkMan)
   CGroup: /system.slice/displaylink.service
           └─952 /nix/store/4b8pl58v6619ns5il393ibiq7pf1gyls-displaylink-1.1.62/bin/DisplayLinkManager

Aug 27 16:44:32 renzo systemd[1]: Started DisplayLink Manager Service.

There's a lot of output from strace; anything in particular to grep for? Here's some:

strace /nix/store/4b8pl58v6619ns5il393ibiq7pf1gyls-displaylink-1.1.62/bin/DisplayLinkManager 2>&1 | head -n 1000

gist

@abbradar
Copy link
Member Author

Let's do it like this:

  • Start the service with strace from root, grep for "-1" (error) into a file;
  • With service up like this, plug in the device;
  • Observe that nothing has changed in XRandr;
  • Stop the service and upload the log somewhere.

Proprietary software can be difficult to debug D: BTW, have you tried adding modesetting?

@chris-martin
Copy link
Contributor

I've add modesetting added since I mentioned it here.

Nothing plugged in, no service running.

chris@renzo ~> xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x47 cap: 0x2, Sink Output crtcs: 3 outputs: 5 associated providers: 0 name:modesetting
Provider 1: id: 0x2ae cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 0 name:modesetting

strace /nix/store/4b8pl58v6619ns5il393ibiq7pf1gyls-displaylink-1.1.62/bin/DisplayLinkManager 2>&1 | grep "\-1" > /tmp/strace

Plugged in device.

chris@renzo ~> xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x47 cap: 0x2, Sink Output crtcs: 3 outputs: 5 associated providers: 0 name:modesetting
Provider 1: id: 0x2ae cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 0 name:modesetting

Stopped service.

Strace output

@abbradar
Copy link
Member Author

abbradar commented Aug 31, 2016

Hm, it looks trimmed (last string is stat("/dev/d). Nevertheless, I don't understand what happens -- first of all, try to create /var/log/displaylink (it tries to access this directory) and look for other log files (I think it left something in /tmp)...

@chris-martin
Copy link
Contributor

It writes to /tmp/DisplayLinkManager.log what appears to be a series of base64-encoded lines, but if that's what it is I can't make any sense out of what it decodes to.

The access("/var/log/displaylink/", W_OK) = -1 EACCES (Permission denied) line shows up in the output whether I've previously created a /var/log/displaylink directory or not.

@abbradar
Copy link
Member Author

I fear that they encrypt their logfiles.... Yuck!

OK, please do the same but this time upload full strace file somewhere. I'm not sure what else to try short of grepping it for random things...

@chris-martin
Copy link
Contributor

There's a support tool, though that itself will require some strace debugging to get it running.

The docs for the support tool do mention that some logs are encrypted.

I don't have an HDMI cable on me, will gather strace output when I get home later.

@chris-martin
Copy link
Contributor

I just realized in my last attempt I wasn't running DisplayLinkManager as root, so that accounts for some of the failure -_-

It does seem to require the /var/log/displaylink directory to pre-exist. If I create the directory first and then run DisplayLinkManager, I end up with this:

chris@renzo /v/l/displaylink> ll
total 84K
-rw-r--r-- 1 root root 3.5K Aug 31 21:37 DisplayLinkManager.log
-rw-r--r-- 1 root root  76K Aug 31 21:37 FirmwareTrace.log
-rw-r--r-- 1 root root  256 Aug 31 21:37 'LG TV_GSM0001-2013.1.01010101.edid'

Both log files are encrypted, but the good news is it seems to have at least detected the display (I do indeed have an LG television connected). Output from xrandr commands is unchanged, however.

Full strace: gist. All of that output is from before the displaylink adapter is connected. There is no further strace output produced when it is connected or disconnected.

@abbradar
Copy link
Member Author

abbradar commented Sep 1, 2016

Hm, I found this thread: http://displaylink.org/forum/showthread.php?t=64550

strace log shows that you do have [libevdi] ioctl: drop_master error=-1 in the output. Maybe that's the problem?

@abbradar
Copy link
Member Author

abbradar commented Sep 1, 2016

Also, check that your USB device vendor id is 17e9, and check dmesg (maybe something interesting is there).

chris-martin added a commit to chris-martin/home that referenced this pull request Sep 1, 2016
@chris-martin
Copy link
Contributor

I checked the connection of the dock and moved the USB cable in and out at the dock.
Suddently the screens are back!

I've tried two HDMI cables and displays and both USB ports. At this point I'd be surprised if I had a cabling issue.

strace log shows that you do have [libevdi] ioctl: drop_master error=-1 in the output. Maybe that's the problem?

I don't know, it doesn't mean anything to me.

check that your USB device vendor id is 17e9

> lsusb
Bus 002 Device 005: ID 17e9:436f DisplayLink

Looks right.

Kernel log when I plug the thing in:

Sep 12 16:26:20 renzo kernel: usb 2-2: new SuperSpeed USB device number 10 using xhci_hcd
Sep 12 16:26:20 renzo kernel: usb 2-2: New USB device found, idVendor=2109, idProduct=0210
Sep 12 16:26:20 renzo kernel: usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Sep 12 16:26:20 renzo kernel: usb 2-2: Product: USB3.0 Hub             
Sep 12 16:26:20 renzo kernel: usb 2-2: Manufacturer: VIA Labs, Inc.         
Sep 12 16:26:20 renzo kernel: hub 2-2:1.0: USB hub found
Sep 12 16:26:20 renzo kernel: hub 2-2:1.0: 1 port detected
Sep 12 16:26:20 renzo kernel: usb 1-2: new high-speed USB device number 11 using xhci_hcd
Sep 12 16:26:20 renzo kernel: usb 1-2: New USB device found, idVendor=2109, idProduct=2210
Sep 12 16:26:20 renzo kernel: usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Sep 12 16:26:20 renzo kernel: usb 1-2: Product: USB2.0 Hub             
Sep 12 16:26:20 renzo kernel: usb 1-2: Manufacturer: VIA Labs, Inc.         
Sep 12 16:26:20 renzo kernel: hub 1-2:1.0: USB hub found
Sep 12 16:26:20 renzo kernel: hub 1-2:1.0: 4 ports detected
Sep 12 16:26:22 renzo kernel: usb 2-2.1: new SuperSpeed USB device number 11 using xhci_hcd
Sep 12 16:26:22 renzo kernel: usb 2-2.1: New USB device found, idVendor=17e9, idProduct=436f
Sep 12 16:26:22 renzo kernel: usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 12 16:26:22 renzo kernel: usb 2-2.1: Product: Dell 4-in-1 Adapter
Sep 12 16:26:22 renzo kernel: usb 2-2.1: Manufacturer: DisplayLink
Sep 12 16:26:22 renzo kernel: usb 2-2.1: SerialNumber: 1507240231
Sep 12 16:26:22 renzo kernel: usb 2-2.1: Warning! Unlikely big volume range (=511), cval->res is probably wrong.
Sep 12 16:26:22 renzo kernel: usb 2-2.1: [14] FU [Dell USB Audio Playback Volume] ch = 6, val = -8176/0/16
Sep 12 16:26:22 renzo kernel: cdc_ncm 2-2.1:1.5: MAC-Address: 9c:eb:e8:24:a9:f6
Sep 12 16:26:22 renzo kernel: cdc_ncm 2-2.1:1.5: setting rx_max = 16384
Sep 12 16:26:22 renzo kernel: cdc_ncm 2-2.1:1.5: setting tx_max = 16384
Sep 12 16:26:22 renzo kernel: cdc_ncm 2-2.1:1.5 usb0: register 'cdc_ncm' at usb-0000:00:14.0-2.1, CDC NCM, 9c:eb:e8:24:a9:f6
Sep 12 16:26:22 renzo kernel: cdc_ncm 2-2.1:1.5 enp0s20f0u2u1i5: renamed from usb0
Sep 12 16:26:22 renzo kernel: IPv6: ADDRCONF(NETDEV_UP): enp0s20f0u2u1i5: link is not ready
Sep 12 16:26:22 renzo kernel: IPv6: ADDRCONF(NETDEV_UP): enp0s20f0u2u1i5: link is not ready
Sep 12 16:26:22 renzo kernel: evdi: [D] evdi_painter_connect:433 (dev=-1) Connected with           (null)
Sep 12 16:26:22 renzo kernel: evdi: [D] evdi_detect:69 (dev=1) Painter is connected
Sep 12 16:26:22 renzo kernel: evdi: [D] evdi_detect:69 (dev=1) Painter is connected
Sep 12 16:26:22 renzo kernel: evdi: [D] evdi_painter_get_edid_copy:186 (dev=1) 00 ff ff
Sep 12 16:26:25 renzo kernel: cdc_ncm 2-2.1:1.5 enp0s20f0u2u1i5: network connection: disconnected

@chris-martin
Copy link
Contributor

Oh! I just ran xrandr --setprovideroutputsource 1 0 and now it's working! 😄

Unfortunately I don't know exactly what the difference is between now and the last time I tried this. Possibilities are:

  • I'm currently using a different display and a different HDMI cable
  • This time I built the PR directly, whereas previously I was cherry-picking onto NixOS 16.03

@abbradar
Copy link
Member Author

Awesome!

It would be nice to have a cleanup now. First I'll add mkdir -p /var/log/displaylink to the service. Second, try:

  1. Removing modesetting from videoDrivers;
  2. Reverting "Try to fix things" commit;

and see if it works without one or both of them.

@chris-martin
Copy link
Contributor

I'm not sure what happened, but I can't build this anymore.

output: https://gist.github.com/chris-martin/6a269a9f6e510cd711f852b671d1295f

@abbradar
Copy link
Member Author

Okay, I've found an open-source code drop from DisplayLink here: https://github.com/DisplayLink/evdi. This brings us closer to have no binary blobs and also fixes build on newer kernels. Give it a try now!

@abbradar
Copy link
Member Author

Oops, small fix.

@chris-martin
Copy link
Contributor

Same result building bc493cc - /tmp/nix-build-displaylink-1.1.62.drv-0/src/evdi/evdi_drv.c:1:0: error: code model kernel does not support PIC mode

@abbradar
Copy link
Member Author

Hm, are you sure? This is a path from old version of my package (it should have been module/evdi_drv.c otherwise).

@chris-martin
Copy link
Contributor

Oh, whoops, I guess I don't know how to use git pr as well as I thought I did. Just a sec :)

@chris-martin
Copy link
Contributor

Looks okay, though one time X crashed when I plugged in the device.

kernel log: https://gist.github.com/chris-martin/7a700a77facc67fbddddee40fbdcc6ba

@chris-martin
Copy link
Contributor

I've removed modesetting from videoDrivers and it still works.

@abbradar
Copy link
Member Author

Well, I'm not sure what to do with an X crash. Was it one-time event (i.e. can you unplug/plug the device now without crashes)?

@chris-martin
Copy link
Contributor

chris-martin commented Sep 12, 2016

It seems to have been a one-time event.

Unfortunately the performance of this thing seems to be pretty awful. It'll be nice to have for the one-off presentation, but it's pretty much unusable as a full-time display. A really low frame rate, artifacting everywhere on both screens, repositioning the displays sometimes ends in disaster... I'm guessing this is just the device/driver and not much we can do about most of this?

@abbradar
Copy link
Member Author

Well, I'm not sure -- I think you can test it with e.g. Ubuntu and see if problems persist. We can investigate it more then.

Either way, let's merge this then now that it more or less works! I'll cherry-pick it to 16.09 too. Thank you for your testing!

@abbradar abbradar merged commit bc493cc into NixOS:master Sep 12, 2016
@chris-martin
Copy link
Contributor

Yeah, good thinking.

Thanks so much for all the work you've put into this!

abbradar added a commit that referenced this pull request Sep 12, 2016

powerManagement.powerDownCommands = ''
#flush any bytes in pipe
while read -n 1 -t 1 SUSPEND_RESULT < /tmp/PmMessagesPort_out; do : ; done;

Choose a reason for hiding this comment

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

This line prevents my laptop from going into suspend when there are no DisplayLink devices connected.

Choose a reason for hiding this comment

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

See #151706. Unfortunately I can't reproduce this any more. Strange.

chris-martin added a commit to chris-martin/home that referenced this pull request Mar 25, 2023
chris-martin added a commit to chris-martin/home that referenced this pull request Mar 27, 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.

DisplayLink support
4 participants