Asking for guidance on modifying / patching UVC driver

Hi all :slight_smile: this isn’t an actual support request, I’m just trying to get a webcam to work, so if you have important things to do, do those :wink:

But I’d appreciate help with the following:

I would like to replace the already by default installed UVC driver with a modified version that I want/need to build from source code.

Why? The webcam doesn’t work because the driver doesn’t recognize it as a cam. It’s a know problem, and there is already a rough “tutorial” about how to fix this on ubuntu, which i have tested on a live ubuntu and it seems to work - i could use the cam there. I don’t have exactly the same cam model, but it’s easy to adapt the patch.
However, the steps and commands of this tutorial won’t work with Rocky, obviously, and I’m at a total loss here.
Tried some things, you know, “learning by doing”, but nothing worked, and it seems pointless to try this myself (I’m a linux newbie, sorry… am probably not using the correct terminology either…).

Here is the shortened tutorial for ubuntu:

Enable source code repositories, then fetch the source code with:

apt-get source linux-modules-extra-$(uname -r)

In the source code folder, navigate to:
Replace the uvcdriver.c file with the patched version.
Open directory in terminal, then:

make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules
sudo cp uvcvideo.ko /lib/modules/$(uname -r)/kernel/drivers/media/usb/uvc/

LINK to original post

I already struggle with the rocky source code.
For example, I’ve tried downloading it with $ dnf download --source kernel (found the command here in the forums) which downloaded a ~135 Mb kernel-…src.rpm , but it seems i can do nothing with it, it won’t install.

I’ve read here that (maybe?) i need the rocky devtools, so I’ve downloaded the zip from github, extracted it but “make” won’t work with it and gives an error.

Now, I want to just ask:
What would be even the procedure here?
What (part of the) rocky source do I need, and how to get it?
About the last 2 commands for making the driver, I don’t know if those would generally work.
I noticed however, that on Rocky Linux, unlike ubuntu, the compiled driver is in a compressed .xz file. Don’t know if compressing it would be part of the make process…

Any hint or help is welcome :slight_smile: thank you!

Is your hardware ’ Quanta HD User Facing’ ? This device was added in the patch you referenced. If so the device ID is [0x0408:0x4035]. You can check this by running “lsusb”.

Learning is one thing, asking is another. :slight_smile: You may want to ask ELRepo to get the driver built as a kmod package. Otherwise you’d need to build the module upon every kernel update.


Thank you,
it’s “a” Quanta User Facing cam, but the number is just slightly different, it’s 0408:4033 , so the last number is a 3 instead of a 5 :roll_eyes:
So before building on ubuntu, I opened the uvcdriver.c file from the link and I swapped the numbers, and it worked - (maybe not with 100% functionality though, I haven’t tested it in detail…). Easy enough.

So doing what I described in the first posting is much more complicated on Rocky Linux?
It’s ok if it is, there will be reasons for that, but if not, could you or anyone tell me how to approach this? How to get a “usable” source code, for instance?

I wouldn’t mind rebuilding it after kernel updates when needed until this is somewhow officially added to the driver. Unless it’s really a hassle… (?)

I don’t know how that would work with ElRepo, but to be honest I’d feel silly to ask them as well, just so that I can use my webcam… Also I don’t see the point, when my cam is not officially part of the driver yet, and the fix only exists in a ubuntu forum. But I’ll try to find out more…

Ok, I extracted the source code .src.rpm (that matches my installed kernel) with
rpm -vv -Uvh kernel-5.14.0-162.22.2.el9_1.src.rpm
Among the extracted files was the compressed kernel which I then uncompressed. So far so good.
Now, in the extracted source code I navigate to the UVC-drivers source code folder, and run the command from the link:

make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules

it will create create many files, including the “uvcvideo.ko” file which I need.
The original driver, that came with the Rocky installation, is compressed to a “uvcvideo.ko.xz” file, so I compress my new compiled file as well.

Here comes the problem now:

The “old original” compressed driver has a size of ~73kb, whereas my new compiled (and also compressed) driver has a size of ~750kb, that’s like 10x as big.

edit: seems to be “debug-info” which i removed with

strip $(find ./ -name "*.ko") -d 

Now it’s much smaller, compressed it’s about 53 kb… a bit too small even.

However, it will not be loaded when I replace the old driver with my new compiled driver.
I restartet the PC, then ran
sudo modprobe uvcvideo
which resulted in
modprobe: ERROR: could not insert 'uvcvideo': Exec format error

I guess sth. went wrong, but what?

Thank you :slight_smile:

What would happen if you do not compress?

The strip command looks fine.


1 Like

Thank you!
that also doesn’t work, modprode says:

modprobe: ERROR: could not insert 'uvcvideo': Unknown symbol in module, or unknown parameter (see dmesg)

But I’ve just read, that for ubuntu, the UVC driver source is inside an extra source package. While the sourcecode also exists in the normal kernel-source, this is appearantly not the one that should be used, or else they get the same error message that I previously got with modprobe.
Instead the right source is in an “linux-modules-extra” source package.
This is the command to download it for ubuntu (or see my very first post) :
apt-get source linux-modules-extra-$(uname -r)

Now, does sth. like that exist for Rocky as well maybe?

I’ve found a “kernel-modules-extra” rpm here, which sounds similar enough for me to try it out, but sadly I don’t find a src.rpm for it.
but where is the source (?) :

But the UVC might just as well be a in a different package… looking for the needle in the haystack :wink:

“kernel-modules-extra” is built from the same source file as the “kernel” package.

1 Like

I JUST GOT IT WORKING, whoohoo. Totally unexpected, to be honest :smiley:

  • as you suggested I copied the new .ko file, NOT compressed as .xz
  • Then tried the “sudo modprobe uvcvideo” which gave the error. (Cheese also didn’t recognize the cam)
  • then tried sudo insmod uvcvideo.ko
    (sb was using that command in the ubuntu forum thread)
  • et voila! when starting Cheese, the webcam worked and I saw myself on the screen :wink:
  • it also wasn’t necessary to remove/strip the debug info. The 4mb file works just fine, as it seems.
  • that “insmod” command didn’t work with the compressed xz files though - so thank you VERY MUCH, I would have never tried to just use the uncompressed file :pray: :pray: :pray:

Will see how it actually works, or if there are follow up problems, after reboots etc… maybe I’ll create some “final” step-by-step instructions for myself, then I’ll post it here, although it’s not very likely sb else is having the same problem.


What I suspect has happened is that, when you used the modprobe command, it loaded the in-kernel driver, not the one you built.

Sadly it’s not persistent. After reboots I have to “insmod” it again :confused:
Not sure why that is.
I’ve also made an “.xz” again, with the same name in the same location etc. as the original file, but that also won’t be loaded after reboots.

For occasional webcam use that’s ok though, navigating to the UVC folder and use the insmod command isn’t that time consuming… So thanks again.

Still, I wonder why RL refuses to load the compressed module. If anyone has an idea, I’ll try it out… :slight_smile: but it’s probably not worth spending much more time for this, since it’s not a permanent solution anyway.

That is what I mentioned in my earlier post. kABI-tracking kmod packages [usually] survive kernel updates within a minor point release.