Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

New Drivers Released - Might fix issue with latest firmware #2

Open
XertroV opened this issue Nov 26, 2020 · 20 comments
Open

New Drivers Released - Might fix issue with latest firmware #2

XertroV opened this issue Nov 26, 2020 · 20 comments

Comments

@XertroV
Copy link

XertroV commented Nov 26, 2020

New drivers: https://storage.avermedia.com/web_release_www/CL511HN/Generic_Ubuntu_CL511HN_Drv_2.0.1.zip

Note: the drivers were "published" on https://www.avermedia.com/professional/download/cl511hn#ans_part except that the link to download them is the same as 1.0.0031

I'm going to try and replicate your patches now. I flashed my gc573 with the latest firmware this evening and I can't get the current master to work (I'm using ubuntu 20.04). I noticed the latest firmware was released after the 1.0.0031 drivers were released.

@derrod
Copy link
Owner

derrod commented Nov 26, 2020

Thanks for the heads up, my main machine is on Windows so I haven't checked if this still works since originally publishing the repo. Also the AverMedia website currently doesn't work from Europe for some reason so I couldn't check for new drivers either...

Edit: also just for the record, there's no downgrade protection on the firmware. I might have to add a guide on how to downgrade it in case that's needed.

@derrod
Copy link
Owner

derrod commented Nov 26, 2020

Seems like the board/ code is now precompiled in the new drivers, rather than being editable. So that'll make it a bit more annoying. I will see to either provide a simple binary patch or check if simply reusing the old board code still works, possibly by diffing the old and new ones to see if they actually changed anything there.

@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

Hmm, that is annoying. I have a repo with the upstream changes merged in here: https://github.com/XertroV/lg4k-linux/tree/patched_20201104-merge

I've tested this and the device doesn't even show up for me anymore, so I might try with the old board code quickly to see if that works.

Edit: also just for the record, there's no downgrade protection on the firmware. I might have to add a guide on how to downgrade it in case that's needed.

Good to know!

If the old board code doesn't work I'll try downgrading (I guess there's an .exe in the drivers installer/unzipper-thing)

Update: not looking good on replacing AverMediaLib_64.a (and it6664_EDID.h) with the previous versions (at least not on my current firmware)

@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

I have it working! However, I think that the firmware update doesn't complete if you don't fully power down (a reboot isn't good enough). When I logged back into windows to downgrade the firmware, the avermedia program told me I was still on 2018 firmware. So none of my earlier results were valid.

I patched to 2019.12.xx (whatever it was) and powered down fully. Then powered up to confirm, rebooted to Ubuntu, and recompiled the drivers as they are in master -- they still work.

I'm going to test the new firmware now b/c if that works it should fix the pixel mode issues.

image

@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

Looks like the new firmware still works with the drivers in master:

❯ dmesg | grep chip_version
[   13.496280] chip_version:20200811

image
The video formats that work in OBS (using my switch as test input) are:

  • YUYV 4:2:2
  • YU12 (Emulated)
  • YV12 (Emulated)

BGR12 BGR3 (Emulated) does not work. The video is just frozen.

Setting the frame rate to other values seems to work too.

Audio works too:

image

@derrod
Copy link
Owner

derrod commented Nov 26, 2020

Yeah based on the changelog it appears that RGB was only fixed with the new driver. Try applying this patch (with bspatch) to the AverMediaLib_64.o file in the driver/ directory: https://we.tl/t-kNXH7JqjyM

That's still missing the stuff to load the driver automatically, but see if that works at least. The other parts of the driver haven't really been modified by me anyway.

@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

Cool, will do now.


dumping some useful commands here to make them easy to find later to update readme

  • echo -n "0000:03:00.0" | sudo tee /sys/bus/pci/drivers/CL511H/unbind -- replace with pci id/address/thing; can be found w/ lspci | grep -i aver

Firmware upgrade / downgrade - run the driver installer for the version respective firmware version, then run C:\Program Files (x86)\AVerMedia\AVerMedia GC573 PCIe Device\LiveGamer4KUpdate.exe with admin rights

@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

Should I be using https://github.com/delphidabbler/bdiff to apply the patch btw? I didn't find anything looking for an appropriate linux package (and patch doesn't work).

(Rebooting to windows now)

@derrod
Copy link
Owner

derrod commented Nov 26, 2020

At least on Debian/Ubuntu there should be the bsdiff package, which also includes bspatch.

@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

Thanks - bsdiff was the ticket (the package I linked didn't work)

I'm now running into some compiler errors with AverMediaLib_64.o

I tried applying the patch in a few ways. One thing I noticed just now, though, it looks like the cl511_20201104 drivers just work on their own. (Though BGR3 still isn't working -- note I typo'd it as BGR12 before)

Sample of some compiler errors:

  CC [M]  /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_alsa.o
  LD [M]  /home/xertrov/src/avermedia/lg4k-linux/driver//cx511h.o
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o):(.data+0x0): multiple definition of `BOARD_NAME'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:(.data+0x40): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o):(.data+0x20): multiple definition of `id_table'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:(.data+0x20): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o): in function `board_probe':
board_config.c:(.text+0x0): multiple definition of `board_probe'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:board_config.c:(.text+0x0): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o): in function `board_suspend':
board_config.c:(.text+0x596): multiple definition of `board_suspend'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:board_config.c:(.text+0x550): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o): in function `board_resume':
board_config.c:(.text+0x767): multiple definition of `board_resume'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:board_config.c:(.text+0x680): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o): in function `board_remove':
board_config.c:(.text+0xa3a): multiple definition of `board_remove'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:board_config.c:(.text+0x870): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o): in function `board_init':
board_config.c:(.text+0xb12): multiple definition of `board_init'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:board_config.c:(.text+0x920): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o): in function `board_exit':
board_config.c:(.text+0xb8a): multiple definition of `board_exit'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:board_config.c:(.text+0x9a0): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_i2c.o): in function `board_get_i2c_bus_name':
board_i2c.c:(.text+0x0): multiple definition of `board_get_i2c_bus_name'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_i2c.o:board_i2c.c:(.text+0x0): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_i2c.o): in function `board_i2c_init':
board_i2c.c:(.text+0x29): multiple definition of `board_i2c_init'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_i2c.o:board_i2c.c:(.text+0x20): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_i2c.o): in function `board_i2c_read':
board_i2c.c:(.text+0x3aa): multiple definition of `board_i2c_read'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_i2c.o:board_i2c.c:(.text+0x290): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_i2c.o): in function `board_i2c_write':
board_i2c.c:(.text+0x6d5): multiple definition of `board_i2c_write'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_i2c.o:board_i2c.c:(.text+0x500): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_gpio.o): in function `board_gpio_init':
board_gpio.c:(.text+0x0): multiple definition of `board_gpio_init'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_gpio.o:board_gpio.c:(.text+0x0): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_gpio.o): in function `board_set_gpio':
board_gpio.c:(.text+0xa3): multiple definition of `board_set_gpio'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_gpio.o:board_gpio.c:(.text+0x60): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_gpio.o): in function `board_get_gpio':
board_gpio.c:(.text+0x134): multiple definition of `board_get_gpio'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_gpio.o:board_gpio.c:(.text+0xd0): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_v4l2.o): in function `board_v4l2_init':
board_v4l2.c:(.text+0x206f): multiple definition of `board_v4l2_init'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_v4l2.o:board_v4l2.c:(.text+0x19b0): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_v4l2.o): in function `board_v4l2_suspend':
board_v4l2.c:(.text+0x256d): multiple definition of `board_v4l2_suspend'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_v4l2.o:board_v4l2.c:(.text+0x1d30): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_v4l2.o): in function `board_v4l2_resume':
board_v4l2.c:(.text+0x2754): multiple definition of `board_v4l2_resume'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_v4l2.o:board_v4l2.c:(.text+0x1e80): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_alsa.o): in function `board_alsa_recv_data':
board_alsa.c:(.text+0x4f6): multiple definition of `board_alsa_recv_data'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_alsa.o:board_alsa.c:(.text+0x120): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_alsa.o): in function `board_alsa_init':
board_alsa.c:(.text+0x1a7): multiple definition of `board_alsa_init'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_alsa.o:board_alsa.c:(.text+0x170): first defined here
ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o: member /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(pic_bmp.o) in archive is not an object
make[2]: *** [scripts/Makefile.build:446: /home/xertrov/src/avermedia/lg4k-linux/driver//cx511h.o] Error 1
make[1]: *** [Makefile:1757: /home/xertrov/src/avermedia/lg4k-linux/driver/] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-54-generic'
make: *** [Makefile:60: build] Error 2
make: Leaving directory '/home/xertrov/src/avermedia/lg4k-linux/driver'
cp: cannot stat 'driver/cx511h.ko': No such file or directory

@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

I'm not sure I'm applying the patch to the right files.

Going to dump some configurations here with details.


applying to vanilla 20201104 drivers

Error: ld: /home/xertrov/src/avermedia/cl511_20201104/driver//AverMediaLib_64.o: member /home/xertrov/src/avermedia/cl511_20201104/driver//AverMediaLib_64.o(pic_bmp.o) in archive is not an object

~/src/avermedia/cl511_20201104 
❯ sha256sum AverMediaLib_64* driver/AverMediaLib_64.o
a5141ab3254585e0778210e4a9685044cf57c72754e5d6f9f69a13b04202d32e  AverMediaLib_64.a
5b1b178aa1fd9243a2479a5316d98204d325a29fb2f3bff3a078908e983bc964  AverMediaLib_64.bpatch
db267163acf017ea8f3f6d5cdc9f1bc5d0d63bc85d4f31b421a82c32cfb31310  AverMediaLib_64-original.a
a5141ab3254585e0778210e4a9685044cf57c72754e5d6f9f69a13b04202d32e  driver/AverMediaLib_64.o

Applying patch to master: modprobe: ERROR: could not insert 'cx511h': Exec format error


Applying patch to patched_20201104-merged: ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o: member /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(pic_bmp.o) in archive is not an object


Applying patch to patched_20201104-merged w/ patched version of AverMediaLib_64.a copied from cl511_20201104

More of:

ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(board_config.o):(.data+0x0): multiple definition of `BOARD_NAME'; /home/xertrov/src/avermedia/lg4k-linux/driver//board//cx511h/board_config.o:(.data+0x40): first defined here

One thing I just thought of: I uncommented some lines in driver/Makefile about board sources b/c I had some errors about missing files before. That might be the source of multiple definitions.

Update: ahh, after fixing that I get ld: /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o: member /home/xertrov/src/avermedia/lg4k-linux/driver//AverMediaLib_64.o(pic_bmp.o) in archive is not an object

@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

So given that I have things working with the current master on the latest firmware (20200811) and I'm not getting anywhere with the above, I'm going to close this issue.

Thanks @derrod for being responsive. Hope the above notes help you or someone else down the road.

@XertroV XertroV closed this as completed Nov 26, 2020
@derrod
Copy link
Owner

derrod commented Nov 26, 2020

I'm going to keep this open since getting the new driver to work is still something I want.

I was able to make it work (turns out I had to patch AverMediaLib_64.a not the .o one...) However, it only works-ish. The new driver version keeps spamming dmesg and also does not work in OBS (ffplay works however, even with RGB24!).

Before properly updating to the new driver I'll have to figure out why it doesn't work in OBS, and maybe create another patch to silence the debug output a little bit.

@derrod derrod reopened this Nov 26, 2020
@XertroV
Copy link
Author

XertroV commented Nov 26, 2020

Cool, glad to hear you got it working!

I had some problems in OBS, particularly with outdated configs and needing to remove and re-add video capture devices. I think it always worked when ffplay or gst-launch-1.0 did.

@JustDevZero
Copy link

So... Any update on this so far?

@antpk
Copy link

antpk commented Apr 10, 2021

Hi, I've managed to get the latest driver compiled with the supplied board object files extracted from the a file. I modified the binary files to allow the gc573 card to be detected. (Used Ghidra to find the location in the file where the check was happening)

@ cdorn0's pull request was really helpful in getting the object files back in etc. So I used his branch as the base. Mine isn't good enough yet for a PR but here it is in case anyone else can have a look and see what's going on. https://github.com/antpk/lg4k-linux/tree/devwithlatestdriver

So the driver loads and I can get video to work from gst-launch. As far as I can tell RGB3, NV12 and YV12 are working. Weirdly YUYV is misbehaving. If you set these before starting OBS, it sometimes works in OBS.

Audio is not working at all at the moment. When the driver is loaded it actually kills all audio on my machine. I'm trying to figure out why that is but it seems to be something in the new supplied compiled files that is causing the issue.

This audio issue I think causes OBS to be particularity prone to crashing. I think changing the video settings in OBS isn't working as expected.

Finally, I'm running on Arch so I am using a fairly recent kernel. 5.11.12 to be exact. I am experiencing these issues:

  • Unable to unload the driver.
  • Poweroff/reboot hang possibly related to the lot of kernel messages being generated.
  • Lot of kernel messages:
    ** BUG: scheduling while atomic: kworker/3:3/1224/0x00000002
    ** BUG: workqueue leaked lock or atomic: kworker/3:3/0x7fffffff/1224 - last function: sys_work_func

Loads to investigate.

@Khyretos
Copy link

Hi, I've managed to get the latest driver compiled with the supplied board object files extracted from the a file. I modified the binary files to allow the gc573 card to be detected. (Used Ghidra to find the location in the file where the check was happening)

@ cdorn0's pull request was really helpful in getting the object files back in etc. So I used his branch as the base. Mine isn't good enough yet for a PR but here it is in case anyone else can have a look and see what's going on. https://github.com/antpk/lg4k-linux/tree/devwithlatestdriver

So the driver loads and I can get video to work from gst-launch. As far as I can tell RGB3, NV12 and YV12 are working. Weirdly YUYV is misbehaving. If you set these before starting OBS, it sometimes works in OBS.

Audio is not working at all at the moment. When the driver is loaded it actually kills all audio on my machine. I'm trying to figure out why that is but it seems to be something in the new supplied compiled files that is causing the issue.

This audio issue I think causes OBS to be particularity prone to crashing. I think changing the video settings in OBS isn't working as expected.

Finally, I'm running on Arch so I am using a fairly recent kernel. 5.11.12 to be exact. I am experiencing these issues:

* Unable to unload the driver.

* Poweroff/reboot hang possibly related to the lot of kernel messages being generated.

* Lot of kernel messages:
  ** BUG: scheduling while atomic: kworker/3:3/1224/0x00000002
  ** BUG: workqueue leaked lock or atomic: kworker/3:3/0x7fffffff/1224 - last function: sys_work_func

Loads to investigate.

your repository is the only one that compiles for me, but unfortunatly i cant get anything on my screen, its eeither black, green or grey/green gradient:
image
image
image
image

can anyone help me?

@Khyretos
Copy link

Khyretos commented May 30, 2021

So after making it work with @antpk repository o was able to compile it and run it with command line, but a couple of things to note are:

  • It only starts after I open and close obs
  • It completely freezes my system after a certain time
  • I don't know if this is normal but it does not pass through HDMI, at all
  • There is a slight difference when I compare the original screen with what comes out of the card
  • Freezing seems to only happen when
    VM is on
    when I try to change the display to where I connect the 'out' to
    the driver runs, its definitely just the driver that completely freezes my system.

This time it froze after min 3:
IMG_20210530_070006.jpg

@Khyretos
Copy link

i found the error that is causing my crashes:

BUG: scheduling while atomic: kworker/10:2/424/0x00000000
May 30 20:00:01 SOUCOUYANT kernel: BUG: scheduling while atomic: kworker/11:2/638/0x00000002
May 30 20:00:01 SOUCOUYANT kernel: BUG: workqueue leaked lock or atomic: kworker/11:2/0x7fffffff/638
                                        last function: sys_work_func [cx511h]
May 30 20:00:01 SOUCOUYANT kernel: BUG: scheduling while atomic: kworker/11:2/638/0x00000000
May 30 20:00:01 SOUCOUYANT kernel: BUG: scheduling while atomic: kworker/10:2/424/0x00000002
May 30 20:00:01 SOUCOUYANT kernel: BUG: workqueue leaked lock or atomic: kworker/10:2/0x7fffffff/424
                                        last function: sys_work_func [cx511h]

i just have no idea what i can do to fix this

@cdorn0
Copy link

cdorn0 commented Jan 9, 2022

i found the error that is causing my crashes:

BUG: scheduling while atomic: kworker/10:2/424/0x00000000
May 30 20:00:01 SOUCOUYANT kernel: BUG: scheduling while atomic: kworker/11:2/638/0x00000002
May 30 20:00:01 SOUCOUYANT kernel: BUG: workqueue leaked lock or atomic: kworker/11:2/0x7fffffff/638
                                        last function: sys_work_func [cx511h]
May 30 20:00:01 SOUCOUYANT kernel: BUG: scheduling while atomic: kworker/11:2/638/0x00000000
May 30 20:00:01 SOUCOUYANT kernel: BUG: scheduling while atomic: kworker/10:2/424/0x00000002
May 30 20:00:01 SOUCOUYANT kernel: BUG: workqueue leaked lock or atomic: kworker/10:2/0x7fffffff/424
                                        last function: sys_work_func [cx511h]

i just have no idea what i can do to fix this

Hi!
I am sorry, the problem with the crash originated from my patch. I used kzalloc for the debug print buffer, but I did not check, that the debug print is used in locked parts of the code, where sleeping is not allowed. Changing it to GFP_ATOMIC should fix the issue.

I did some work over Christmas and adapted the driver to the new version. I tried to get all pixelformats to work and OBS should work now, too. Unfortunately I could not stop the LEDs from blinking, as this uses custom software on the FPGA and the Windows driver is not easy to understand - at least for someone without any windows driver knowledge.

Check my repo or my pull request for the update ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants