USB/Linux USB Layers/Configfs Composite Gadget/Usage eq. to g webcam.ko

From Tizen Wiki
Jump to: navigation, search

Owner

  • Andrzej Pietrasiewicz <andrzej.p (at) samsung.com> (KERNEL)

Code change log

v1

Guide

This series aims at integrating configfs into uvc, the way it has been done for acm, ncm, ecm, eem, ecm subset, rndis, obex, phonet,

mass_storage, FunctionFS, loopback, sourcesink, uac1 and uac2.

The preparation series is already on Felipe's next, so this series in fact consists of a small preparation patch and the configfs support proper.


BACKWARD COMPATIBILITY

Please note that the old g_webcam.ko is still available and works.

USING THE NEW "GADGET"

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based gadgets (*).

With configfs the procedure is as follows, compared to the information mentioned above (*):

instead of mkdir functions/acm.ttyS1 do
mkdir functions/uvc.<instance name>
e.g. mkdir functions/uvc.usb0.

Here is an example script which sets up a minimal uvc gadget for operation with a high-speed udc:

$ modprobe libcomposite
$ mount none cfg -t configfs
$ mkdir cfg/usb_gadget/g1
$ cd cfg/usb_gadget/g1
$ mkdir configs/c.1
$ mkdir functions/uvc.usb0
$ mkdir strings/0x409
$ mkdir configs/c.1/strings/0x409
$ echo 0x3290 > idProduct
$ echo 0x18ec > idVendor
$ echo serial > strings/0x409/serialnumber
$ echo manufacturer > strings/0x409/manufacturer
$ echo UVC Gadget > strings/0x409/product
$ echo "Conf 1" > configs/c.1/strings/0x409/configuration
$ echo 120 > configs/c.1/MaxPower
$ mkdir -p functions/uvc.usb0/streaming/uncompressed/u/360p
$ cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/360p/dwFrameInterval
666666
1000000
5000000
EOF
$ mkdir functions/uvc.usb0/streaming/header/h
$ cd functions/uvc.usb0/streaming/header/h
$ ln -s ../../uncompressed/u
$ cd ../../class/fs
$ ln -s ../../header/h
$ cd ../../class/hs
$ ln -s ../../header/h
$ cd ../../../control
$ mkdir header/h
$ ln -s header/h class/fs
$ ln -s header/h class/ss
$ cd ../../../
$ echo 2048 > functions/uvc.usb0/streaming_maxpacket
$ ln -s functions/uvc.usb0 configs/c.1
$ echo 12480000.hsotg > UDC

TESTING THE FUNCTIONS

uvc)

device: connect the gadget, enable it, modprobe vivi,

$ ./uvc-gadget -u /dev/video<uvc video node #> -v /dev/video<vivi video node #>

Use Laurent's program:

http://git.ideasonboard.org/uvc-gadget.git

with this patch:

diff --git a/uvc-gadget.c b/uvc-gadget.c
index 9ef315c..f6263ba 100644
--- a/uvc-gadget.c
+++ b/uvc-gadget.c
@@ -387,7 +387,7 @@ uvc_events_process_standard(struct uvc_device *dev, struct usb_ctrlrequest *ctrl
 	printf("standard request\n");
 	(void)dev;
 	(void)ctrl;
-	(void)resp;
+	resp->length = 0;
 }
 
 static void
@@ -396,7 +396,7 @@ uvc_events_process_control(struct uvc_device *dev, uint8_t req, uint8_t cs,
 {
 	printf("control request (req %02x cs %02x)\n", req, cs);
 	(void)dev;
-	(void)resp;
+	resp->length = 0;
 }
 
 static void
--