peterbay / uvc-gadget

uvc-gadget with resolution changing and video controls
GNU General Public License v2.0
81 stars 24 forks source link

How to use frambuffer devices? #13

Open tuyenld opened 3 years ago

tuyenld commented 3 years ago

I tried to use frambuffer instead of /dev/video0, but the webcam application show nothing. Here is what I did:

# ./gadget-framebuffer.sh 
INFO: --- Gadget framebuffer ---
INFO: Framebuffer width:  640
INFO: Framebuffer height: 480
INFO: Configfs path: /sys/kernel/config
INFO: Gadget config path: /sys/kernel/config/usb_gadget/fb_gadget
INFO: Initialize configs and functions
INFO: Enabling gadget
INFO: End

# ./uvc-gadget -u /dev/video1 -f /dev/fb0
[1] 404
root@raspberrypi:/home/pi/tuyenld/uvc-webcam# CONFIGFS: Initial path: /sys/kernel/config/usb_gadget
CONFIGFS: UVC: format: 0, frame: 0, resolution: 640x480, frame_interval: 1000000,  bitrate: [24576000, 49152000]
CONFIGFS: STREAMING maxburst:  0
CONFIGFS: STREAMING maxpacket: 2048
CONFIGFS: STREAMING interval:  1
SETTINGS: Number of buffers requested: 2
SETTINGS: Show FPS: DISABLED
SETTINGS: GPIO pin for streaming status: not set
SETTINGS: Onboard led0 used for streaming status: DISABLED
SETTINGS: Blink on startup: 0 times
SETTINGS: UVC device name: /dev/video1
SETTINGS: FB device name: /dev/fb0
SETTINGS: Framerate for frame buffer: 25
DEVICE_UVC: Opening /dev/video1 device
DEVICE_UVC: Device is 20980000.usb on bus gadget
FB: Opening /dev/fb0 device
FB: Resolution: 640x480
FB: Bits per pixel: 32
FB: Line length: 2560
FB: Memory size: 1228800
UVC: Streaming control: action: INIT
FRAME: format: 0, frame: 0, resolution: 640x480, frame_interval: 1000000,  bitrate: [24576000, 49152000]
DUMP: uvc_streaming_control: format: 0, frame: 0, frame interval: 1000000
UVC: Streaming control: action: INIT
FRAME: format: 0, frame: 0, resolution: 640x480, frame_interval: 1000000,  bitrate: [24576000, 49152000]
DUMP: uvc_streaming_control: format: 0, frame: 0, frame interval: 1000000
PROCESSING LOOP: FB -> UVC
DEVICE_UVC: UVC_EVENT_CONNECT
UVC: INPUT_TERMINAL - GET_INFO - UVC_CT_AE_MODE_CONTROL - DISABLED
UVC: PROCESSING_UNIT - GET_INFO - UVC_PU_BRIGHTNESS_CONTROL - DISABLED
UVC: Streaming request CS: PROBE, REQ: GET_DEF
UVC: Streaming control: action: GET MIN
FRAME: format: 0, frame: 0, resolution: 640x480, frame_interval: 1000000,  bitrate: [24576000, 49152000]
DUMP: uvc_streaming_control: format: 0, frame: 0, frame interval: 1000000
UVC: Streaming request CS: PROBE, REQ: SET_CUR
UVC: Control PROBE, length: 26
UVC: Streaming control: action: SET, format: 0, frame: 0
FRAME: format: 0, frame: 0, resolution: 640x480, frame_interval: 1000000,  bitrate: [24576000, 49152000]
DUMP: uvc_streaming_control: format: 0, frame: 0, frame interval: 1000000
UVC: Streaming request CS: PROBE, REQ: GET_CUR
UVC: PROCESSING_UNIT - GET_DEF - UVC_PU_BRIGHTNESS_CONTROL - DISABLED
UVC: PROCESSING_UNIT - GET_DEF - UVC_PU_BRIGHTNESS_CONTROL - DISABLED
UVC: PROCESSING_UNIT - GET_DEF - UVC_PU_BRIGHTNESS_CONTROL - DISABLED
UVC: PROCESSING_UNIT - GET_DEF - UVC_PU_BRIGHTNESS_CONTROL - DISABLED

I also tried to force HDMI output mode, but no luck.

# cat /boot/config.txt
[...]
hdmi_force_hotplug=1
hdmi_drive=2

Camera preview mode on RasPi is using GPU, so I think it is easy to overlay text or image with Camera video output. Could you give me more detail how to use framebuffer?

peterbay commented 3 years ago

If you set the framebuffer as an input device, then you must set uvc gadget as an output device.

v4l2-ctl --list-device 20980000.usb (gadget): /dev/video0

uvc-gadget -f /dev/fb0 -u /dev/video0

In your command you use /dev/video1 which is probably a camera module.