wlhe / uvc-gadget

enhance uvc-gadget test application
GNU General Public License v2.0
140 stars 143 forks source link

100% cpu load when not streaming #1

Open raat1979 opened 5 years ago

raat1979 commented 5 years ago

not enough knowledge on this but looking at the source @line +/- 450

/* Return immediately if V4l2 streaming has not yet started. */
if (!dev->is_streaming){
    return 0;
}

guess we could sleep(2); instead of returning directly is no one is listening? not sure how the events work, will we miss them or are they queued?

raat1979 commented 5 years ago

500 ms seems to work

kbingham commented 5 years ago

You might also want to look at the upstream implementation of uvc-gadget. (http://git.ideasonboard.org/uvc-gadget.git)

It has just been updated with lots of work released. If this issue is present upstream, let us know and we'll fix it.

ikester commented 4 years ago

Hi Kieran. I see you guys moved to using select upstream. Unfortunately, I can't get that tree to work on a Raspberry Pi Zero (yet). Even after hardcoding values for bInterfaceNumber and bFormatIndex (which do not get populated in ConfigFS on the Pi, at least for Raspbian OS). I'll keep hacking at it.

kbingham commented 4 years ago

I really want to find time to try uvc-gadget on pi-zero, especially with our latest libcamera work - but I just never get time :-(

I'd be very interested to know what issues you hit to see if I can help you work through them.

jasonmnemonic commented 3 years ago

I really want to find time to try uvc-gadget on pi-zero, especially with our latest libcamera work - but I just never get time :-(

I'd be very interested to know what issues you hit to see if I can help you work through them.

Hi @kbingham and others. I have been looking at this uvc-gadget.c and been trying to setup to have a UVC USB webcam and also an ethernet gadget on the RPI0W and like @ikester, I have been having issues where ethernet works and Win10 device manager shows both UVC Camera and ethernet but UVC Camera does not stream with MediaCaptureFailedEvent. If I removed ethernet then UVC Camera works so a bit at a loss. I have been experimenting with Buster Lite Aug 2020 and Jessie Lite 2017-7 and see more or less the same thing.

I am not a pro at Linux but I find this entire setup interesting and want to explore further because it helps me understand more of Linux and Pi and also the work you guys are doing.

I know @wlhe repository is old and climberhunt's work, is what I can get working. I can clone http://git.ideasonboard.org/uvc-gadget.git but I see main.c and a lot of other C files but I failed to understand how this uvc-gadget.c has one file and that cloned git repository has main.c and other files but not uvc-gadget.c.

Could you give me pointers on how to "update" this uvc-gadget.c because http://git.ideasonboard.org/uvc-gadget.git has lots of new updates? I can understand C++ and C code so I just need some guidance to see where I can go towards.

Help please?

Thanks! :-)

kbingham commented 3 years ago

Looking around, this partciular bug appears to have been fixed in various forks, and is also fixed by rewriting all of this upstream as far as I can tell.

Unfortunately, I can't test any of this on my RPi4 as I can't get the gadget to function at all. Either it's crashing/hanging in the UDC kernel driver, or somethings not getting enough votls/power and it's causing the board to hang.

jasonmnemonic commented 3 years ago

Looking around, this partciular bug appears to have been fixed in various forks, and is also fixed by rewriting all of this upstream as far as I can tell.

Unfortunately, I can't test any of this on my RPi4 as I can't get the gadget to function at all. Either it's crashing/hanging in the UDC kernel driver, or somethings not getting enough votls/power and it's causing the board to hang.

Hi Kieran, thanks for the reply.

Just some questions if you have the time please? Ta.

Thanks for your time and contribution to the community :-)

kbingham commented 3 years ago

When you say rewriting all of this upstream, do you mean from https://git.ideasonboard.org/uvc-gadget.git ? Yes, upstream to me is Ideas on Board, (I am part of the Ideas on Board company).

Where do you get a segmentation fault? What have you built? Rather than discuss a multitude of different issues on this external repository - could you raise an issue on my github https://github.com/kbingham/uvc-gadget/, and we'll move the discussions there if you're working with the the upstream code.

jasonmnemonic commented 3 years ago

When you say rewriting all of this upstream, do you mean from https://git.ideasonboard.org/uvc-gadget.git ? Yes, upstream to me is Ideas on Board, (I am part of the Ideas on Board company).

Where do you get a segmentation fault? What have you built? Rather than discuss a multitude of different issues on this external repository - could you raise an issue on my github https://github.com/kbingham/uvc-gadget/, and we'll move the discussions there if you're working with the the upstream code.

Sure Kieran, I will do that. Thanks again for the fast reply! :-)

jcormier commented 3 years ago

bInterfaceNumber and bFormatIndex

Is there a kernel version where these entries were added to configfs? On my AM57x kernel 4.19.94, they aren't there.

jcormier commented 3 years ago

Is there a kernel version where these entries were added to configfs? On my AM57x kernel 4.19.94, they aren't there.

I guess this was added by 4.20. So close https://patchwork.kernel.org/project/linux-usb/patch/20180801215505.7658-6-laurent.pinchart@ideasonboard.com/

kbingham commented 3 years ago

If you're on an AM57x, I assume you are able to build your own kernel? If so - you can cherry pick the required kernel updates.

jcormier commented 3 years ago

Yeah, I will give it a shot, just had to chuckle when I found the kernel was almost close enough. I'm used to running platforms based on 3.2 xD