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

100% cpu load when not streaming #1

Open
raat1979 opened this issue Feb 10, 2019 · 13 comments
Open

100% cpu load when not streaming #1

raat1979 opened this issue Feb 10, 2019 · 13 comments

Comments

@raat1979
Copy link

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
Copy link
Author

500 ms seems to work

@kbingham
Copy link

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
Copy link

ikester commented Jun 12, 2020

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
Copy link

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
Copy link

jasonmnemonic commented Nov 19, 2020

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
Copy link

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
Copy link

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.

  • When you say rewriting all of this upstream, do you mean from https://git.ideasonboard.org/uvc-gadget.git ?

  • I got the code from Laurent which I can build but I cannot seem to setup correctly on the Pi Zero W with Buster 2020 Aug where it captures camera video and redirects to UVC output using ConfigFS paths (I think that is what it is trying to do). I keep getting segmentation fault and also stuck since I am quite interested in learning all this but I cannot find a guide that makes it work out of the box. Is there a guide somewhere where it is easier to follow?

  • I have been looking at this code uvc-gadget.c and Laurent's repository where this has one C file and Laurent has a few C files and both code look a bit similar (common UVC interfaces) but different where this uvc-gadget.c takes V4L2 input and redirects to UVC to stream to a host PC. With Laurent's code, I am a bit at a loss; I am not sure if he is doing the same thing hence I am confused by both of these repositories. I know this is based on Laurent's code but why so different? I initially thought, this author took Laurent's code and put into one file but does not seem to be the case

  • How do I get myself learning this uvc-gadget.c and Laurent's repository? I can do the C/C++ but some of these UVC functions seem magical with the combination of V4L2 and UVC and hoping there is a guide somewhere that can help me.

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

@kbingham
Copy link

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
Copy link

jasonmnemonic commented Nov 24, 2020

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
Copy link

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
Copy link

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/[email protected]/

@kbingham
Copy link

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
Copy link

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

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

No branches or pull requests

5 participants