This is a cache of https://discuss.96boards.org/t/g-webcam-usb-gadget-not-working/181. It is a snapshot of the page at 2024-11-01T11:17:29.901+0000.
G_webcam USB gadget not working - DragonBoard410c - 96Boards Forum

G_webcam USB gadget not working

Anyone able to get the g_webcam gadget working on the DragonBoard 410c? When I run sudo modprobe g_webcam, the module appears to load but the host computer never recognizes that a USB device connected to it. Using g_audio works, though. BTW, neither module is part of the ubuntu 15.07 release, so I had to compile and install them myself.

Here’s the relevant part of the DragonBoard syslog:

Aug 26 21:52:40 linaro-alip kernel: [  105.446863] udc ci_hdrc.0: registering UDC driver [g_webcam]
Aug 26 21:52:40 linaro-alip kernel: [  105.447226] g_webcam gadget: adding config #1 'Video'/ffffffbffc055570
Aug 26 21:52:40 linaro-alip kernel: [  105.447505] g_webcam gadget: adding 'uvc'/ffffffc02ab07138 to config 'Video'/ffffffbffc055570
Aug 26 21:52:40 linaro-alip kernel: [  105.447516] g_webcam gadget: uvc_function_bind
Aug 26 21:52:40 linaro-alip kernel: [  105.456123] g_webcam gadget: cfg 1/ffffffbffc055570 speeds: high full
Aug 26 21:52:40 linaro-alip kernel: [  105.456140] g_webcam gadget:   interface 0 = uvc/ffffffc02ab07138
Aug 26 21:52:40 linaro-alip kernel: [  105.456151] g_webcam gadget:   interface 1 = uvc/ffffffc02ab07138
Aug 26 21:52:40 linaro-alip kernel: [  105.456162] g_webcam gadget: Webcam Video Gadget
Aug 26 21:52:40 linaro-alip kernel: [  105.456171] g_webcam gadget: g_webcam ready
Aug 26 21:52:40 linaro-alip kernel: [  105.466000] ------------[ cut here ]------------
Aug 26 21:52:40 linaro-alip kernel: [  105.466030] WARNING: CPU: 2 PID: 1053 at ../drivers/media/v4l2-core/v4l2-ioctl.c:1025 v4l_querycap+0x54/0x90()
Aug 26 21:52:40 linaro-alip kernel: [  105.466040] Modules linked in: g_webcam usb_f_uvc videobuf2_vmalloc libcomposite configfs wcn36xx wcn36xx_platform
Aug 26 21:52:40 linaro-alip kernel: [  105.466084] CPU: 2 PID: 1053 Comm: v4l_id Not tainted 4.0.0-linaro-lt-qcom #1
Aug 26 21:52:40 linaro-alip kernel: [  105.466092] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
Aug 26 21:52:40 linaro-alip kernel: [  105.466100] Call trace:
Aug 26 21:52:40 linaro-alip kernel: [  105.466136] [<ffffffc000089b00>] dump_backtrace+0x0/0x124
Aug 26 21:52:40 linaro-alip kernel: [  105.466148] [<ffffffc000089c34>] show_stack+0x10/0x1c
Aug 26 21:52:40 linaro-alip kernel: [  105.466160] [<ffffffc0007f04ec>] dump_stack+0x80/0xc4
Aug 26 21:52:40 linaro-alip kernel: [  105.466172] [<ffffffc0000b3910>] warn_slowpath_common+0x98/0xd0
Aug 26 21:52:40 linaro-alip kernel: [  105.466183] [<ffffffc0000b3a08>] warn_slowpath_null+0x14/0x20
Aug 26 21:52:40 linaro-alip kernel: [  105.466194] [<ffffffc000543e6c>] v4l_querycap+0x50/0x90
Aug 26 21:52:40 linaro-alip kernel: [  105.466206] [<ffffffc000544570>] __video_do_ioctl+0x23c/0x2b0
Aug 26 21:52:40 linaro-alip kernel: [  105.466217] [<ffffffc0005441d4>] video_usercopy+0x328/0x46c
Aug 26 21:52:40 linaro-alip kernel: [  105.466229] [<ffffffc000544328>] video_ioctl2+0x10/0x1c
Aug 26 21:52:40 linaro-alip kernel: [  105.466240] [<ffffffc000540970>] v4l2_ioctl+0xfc/0x174
Aug 26 21:52:40 linaro-alip kernel: [  105.466253] [<ffffffc0001bcbcc>] do_vfs_ioctl+0x37c/0x60c
Aug 26 21:52:40 linaro-alip kernel: [  105.466264] [<ffffffc0001bcedc>] SyS_ioctl+0x80/0x98
Aug 26 21:52:40 linaro-alip kernel: [  105.466272] ---[ end trace 5cba2816f2d34ea8 ]---

The warning message above is something I ran across a number of times searching the web. Consensus is that it can be ignored, but I’m not sure if it’s part of my problem or not. I was expecting the host computer to at least recognize a USB device, even if it couldn’t stream data properly at this point.

Any suggestions will be much appreciated.

I suppose you unplugged the micro usb connector before connecting the new usb device?
Not sure if I will be able to help on this one but could you also send the output of

$lsusb -t

Thanks for the reply.

I spent a while digging into this, and it turns out that what I described previously is by design. Most gadgets, like g_audio, show up on the host when the kernel module is loaded. But g_webcam is a special case in that it requires a user-space application as well. This application needs to respond to requests that the host will make when it tries to enumerate the device, which happens when the device enables a pullup resistor on one of the USB data lines.

Most gadgets enable the pullup resistor when the kernel module loads and binds to a UDC, but g_webcam waits until a user-space application opens the device. Then it enables the pullup, then the host detects a new UVC device, and then the host starts asking the device about its capabilities. You can see this happen if you monitor the dmesg output on the host and enter “less -f /dev/video0” on the DragonBoard. Of course “less” is not a very good user-space application for managing UVC, so don’t expect to see more than the device to be recognized on the host :wink:

I am not that familiar with how g_webcam operates; I took a quick look at the driver and couldn’t make it match to the behavior you are describing (I must be missing something important).

out of curiosity, how did you test this (what hardware do you have in the Dragon board to make it behave as a webcam when connected to your host computer)?

I’m not using any extra hardware other than the DragonBoard. I connect it to a host (my laptop) using the micro-USB connector on the board. I have found that the board needs to be connected to the host prior to reboot of the board. (See this thread.)

After reboot, enter “sudo modprobe g_webcam” to load the gadget module. At this point you should see something in the board’s syslog similar to what I posted, but nothing on the host side. You should also see a new video device in /dev; for me it was “/dev/video0” but I suppose it could be something else. Then you can open the device file descriptor, e.g., using “less” as mentioned previously, and see the device appear on the host.

If this doesn’t work, you might want to check the cable. Some are designed only for charging and not data transfer.

Hi,

I am trying to emulate beaglebone as webcam using g_webcam and using uvc-gadget test application. Since I dont have real camera I am trying to give mjpeg image using -i option and on host side I used luvcview but nothing appears on the window.
On device side:
insert g_webcam
./uvc-gadget -d -i image.mjpeg -u /dev/video0

On host side
luvcview -d /dev/video0

The luvcview window appears on host side but it is blank. Please help me to overcome this issue.
And also correct me if the application format is wrong.

Regards,
Preetha.