The preparation for configfs has been sent as a separate series: www.spinics.net/lists/linux-usb/msg110639.html like Laurent suggests. This series is rebased onto Felipe's testing/next with gadget directory cleanup series applied. I'm sending this series again basically in order for it to be easier to find. 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 and sourcesink. It contains everything that is required to provide the equivalent of g_webcam.ko with configfs. Some time ago I contributed a patch series which did the same thing: http://www.spinics.net/lists/linux-usb/msg98433.html but with a different approach. In webcam.c there is a bunch of statically defined descriptors. In the previous patch series I moved them to their only user - f_uvc.c, but Laurent pointed out: http://www.spinics.net/lists/linux-usb/msg98470.html they are only example values and should not be placed in the generic f_uvc.c. Later on I suggested how to create the said descriptors through configfs: http://www.spinics.net/lists/linux-usb/msg98493.html but there were no responses. So here I present an implementation of that idea so that there is something concrete to discuss. *** QUESTIONS *** ================= @Laurent in particular, @all in general I am kindly asking for a review and would also like to hear opinions on the following: 1. Is creating the descriptors with configfs the right way to go? If it is, then 2. What kinds of descriptors should be available through configfs? 3. Which fields of each descriptor should be available and in what mode (read-write, read-only) 4. The presented code might not be optimal and it could be over-engineered. What improvements do you think could be made to make the uvc-configfs.c code shorter? More efficient? Rebased onto Felipe's testing/next. 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 (and lengthy!) 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 echo 1 > functions/uvc.usb0/streaming/interval echo 1024 > functions/uvc.usb0/streaming/maxpacket mkdir strings/0x409 mkdir configs/c.1/strings/0x409 echo 0x3290 > idProduct echo 0x18ec > idVendor echo samsung123 > strings/0x409/serialnumber echo Samsung > strings/0x409/manufacturer echo EEM Gadget > strings/0x409/product echo "Conf 1" > configs/c.1/strings/0x409/configuration echo 120 > configs/c.1/MaxPower mkdir functions/uvc.usb0/control/header/webcam-hdr mkdir functions/uvc.usb0/control/processing/webcam-proc mkdir functions/uvc.usb0/control/terminal/camera/webcam-cam mkdir functions/uvc.usb0/control/terminal/output/webcam-out mkdir functions/uvc.usb0/control/class/fs/webcam-fs mkdir functions/uvc.usb0/streaming/input_header/webcam-ihdr mkdir functions/uvc.usb0/streaming/color_matching/webcam-cm mkdir functions/uvc.usb0/streaming/class/fs/streaming-fs mkdir functions/uvc.usb0/streaming/class/hs/streaming-hs mkdir functions/uvc.usb0/streaming/format/frame/yuv/360p mkdir functions/uvc.usb0/streaming/format/yuv/format-yuv ln -s functions/uvc.usb0/control/header/webcam-hdr functions/uvc.usb0/control/class/fs/webcam-fs ln -s functions/uvc.usb0/control/processing/webcam-proc functions/uvc.usb0/control/class/fs/webcam-fs ln -s functions/uvc.usb0/control/terminal/camera/webcam-cam functions/uvc.usb0/control/class/fs/webcam-fs ln -s functions/uvc.usb0/control/terminal/output/webcam-out functions/uvc.usb0/control/class/fs/webcam-fs ln -s functions/uvc.usb0/streaming/format/frame/yuv/360p functions/uvc.usb0/streaming/format/yuv/format-yuv ln -s functions/uvc.usb0/streaming/input_header/webcam-ihdr functions/uvc.usb0/streaming/class/fs/streaming-fs ln -s functions/uvc.usb0/streaming/color_matching/webcam-cm functions/uvc.usb0/streaming/class/fs/streaming-fs ln -s functions/uvc.usb0/streaming/format/yuv/format-yuv functions/uvc.usb0/streaming/class/fs/streaming-fs ln -s functions/uvc.usb0/streaming/input_header/webcam-ihdr functions/uvc.usb0/streaming/class/hs/streaming-hs ln -s functions/uvc.usb0/streaming/color_matching/webcam-cm functions/uvc.usb0/streaming/class/hs/streaming-hs ln -s functions/uvc.usb0/streaming/format/yuv/format-yuv functions/uvc.usb0/streaming/class/hs/streaming-hs ln -s functions/uvc.usb0/control/class/fs/webcam-fs functions/uvc.usb0/ ln -s functions/uvc.usb0/streaming/class/fs/streaming-fs functions/uvc.usb0/ ln -s functions/uvc.usb0/streaming/class/hs/streaming-hs functions/uvc.usb0/ ln -s functions/uvc.usb0 configs/c.1 echo s3c-hsotg > UDC After unbinding the gadget with echo "" > UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed and then the respective modules can be unloaded. TESTING THE FUNCTIONS (actually there is only one) ===================== uvc) device: connect the gadget, enable it, modprobe vivi, uvc-gadget -u /dev/video0 -v /dev/video1 I used 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 -- 1.7.9.5 and these patches http://comments.gmane.org/gmane.linux.usb.general/84813 host: luvcview -f yuv Andrzej Pietrasiewicz (3): usb: gadget: configfs: add missing #include usb: gadget: f_uvc: rename to_f_uvc_opts usb/gadget: f_uvc: add configfs support Documentation/ABI/testing/configfs-usb-gadget-uvc | 11 + drivers/usb/gadget/Kconfig | 11 + drivers/usb/gadget/configfs.h | 1 + drivers/usb/gadget/function/Makefile | 2 +- drivers/usb/gadget/function/f_uvc.c | 100 +- drivers/usb/gadget/function/u_uvc.h | 21 +- drivers/usb/gadget/function/uvc_configfs.c | 2928 +++++++++++++++++++++ drivers/usb/gadget/function/uvc_configfs.h | 283 ++ 8 files changed, 3352 insertions(+), 5 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-uvc create mode 100644 drivers/usb/gadget/function/uvc_configfs.c create mode 100644 drivers/usb/gadget/function/uvc_configfs.h -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html