[PATCHv3 0/3] Equivalent of g_webcam with configfs.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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, uac2, hid and midi.

v1..v2:
- sorted header fiels alphabetically
- applied style corrections
- factored out verifying uvc descriptors presence into a separate patch
- added mutex_destroy()
- added more comments for not-obvious parts
- eliminated copy-paste errors (assinment to opts->fs_control,
opts->ss_control
- actually used the refcnt member of struct f_uvc_opts

v2..v3:
- style corrections as suggested by Laurent
- improved documentation comments in u_uvc.h as suggested by Laurent

Below is an example listing of gadget's function directory. The attributes
whose access permissions are -r--r--r-- are there only for inspection
by the user but not for modifications. For color matching, camera
terminal, processing unit and output terminal only default descriptors
are provided, that is, creating user's own is not supported at this
moment.

drwxr-xr-x .  
drwxr-xr-x ./streaming  
drwxr-xr-x ./streaming/class  
drwxr-xr-x ./streaming/class/ss  
drwxr-xr-x ./streaming/class/hs  
lrwxrwxrwx ./streaming/class/hs/h -> \
../../../../../../../usb_gadget/g1/functions/uvc.usb0/streaming/header/h
drwxr-xr-x ./streaming/class/fs  
lrwxrwxrwx ./streaming/class/fs/h -> \
../../../../../../../usb_gadget/g1/functions/uvc.usb0/streaming/header/h
drwxr-xr-x ./streaming/color_matching  
drwxr-xr-x ./streaming/color_matching/default  
-r--r--r-- ./streaming/color_matching/default/bMatrixCoefficients  
-r--r--r-- ./streaming/color_matching/default/bTransferCharacteristics  
-r--r--r-- ./streaming/color_matching/default/bColorPrimaries  
drwxr-xr-x ./streaming/uncompressed  
drwxr-xr-x ./streaming/uncompressed/u  
drwxr-xr-x ./streaming/uncompressed/u/360p  
-rw-r--r-- ./streaming/uncompressed/u/360p/dwFrameInterval  
-rw-r--r-- ./streaming/uncompressed/u/360p/dwDefaultFrameInterval  
-rw-r--r-- ./streaming/uncompressed/u/360p/dwMaxVideoFrameBufferSize  
-rw-r--r-- ./streaming/uncompressed/u/360p/dwMaxBitRate  
-rw-r--r-- ./streaming/uncompressed/u/360p/dwMinBitRate  
-rw-r--r-- ./streaming/uncompressed/u/360p/wHeight  
-rw-r--r-- ./streaming/uncompressed/u/360p/wWidth  
-rw-r--r-- ./streaming/uncompressed/u/360p/bmCapabilities  
-rw-r--r-- ./streaming/uncompressed/u/bmaControls  
-r--r--r-- ./streaming/uncompressed/u/bmInterfaceFlags  
-r--r--r-- ./streaming/uncompressed/u/bAspectRatioY  
-r--r--r-- ./streaming/uncompressed/u/bAspectRatioX  
-rw-r--r-- ./streaming/uncompressed/u/bDefaultFrameIndex  
-rw-r--r-- ./streaming/uncompressed/u/bBitsPerPixel  
-rw-r--r-- ./streaming/uncompressed/u/guidFormat  
drwxr-xr-x ./streaming/header  
drwxr-xr-x ./streaming/header/h  
lrwxrwxrwx ./streaming/header/h/u -> \
../../../../../../../usb_gadget/g1/functions/uvc.usb0/streaming/uncompressed/u
-r--r--r-- ./streaming/header/h/bTriggerUsage  
-r--r--r-- ./streaming/header/h/bTriggerSupport  
-r--r--r-- ./streaming/header/h/bStillCaptureMethod  
-r--r--r-- ./streaming/header/h/bTerminalLink  
-r--r--r-- ./streaming/header/h/bmInfo  
drwxr-xr-x ./control  
drwxr-xr-x ./control/class  
drwxr-xr-x ./control/class/ss  
lrwxrwxrwx ./control/class/ss/h -> \
../../../../../../../usb_gadget/g1/functions/uvc.usb0/control/header/h
drwxr-xr-x ./control/class/fs  
lrwxrwxrwx ./control/class/fs/h -> \
../../../../../../../usb_gadget/g1/functions/uvc.usb0/control/header/h
drwxr-xr-x ./control/terminal  
drwxr-xr-x ./control/terminal/output  
drwxr-xr-x ./control/terminal/output/default  
-r--r--r-- ./control/terminal/output/default/iTerminal  
-r--r--r-- ./control/terminal/output/default/bSourceID  
-r--r--r-- ./control/terminal/output/default/bAssocTerminal  
-r--r--r-- ./control/terminal/output/default/wTerminalType  
-r--r--r-- ./control/terminal/output/default/bTerminalID  
drwxr-xr-x ./control/terminal/camera  
drwxr-xr-x ./control/terminal/camera/default  
-r--r--r-- ./control/terminal/camera/default/bmControls  
-r--r--r-- ./control/terminal/camera/default/wOcularFocalLength  
-r--r--r-- ./control/terminal/camera/default/wObjectiveFocalLengthMax  
-r--r--r-- ./control/terminal/camera/default/wObjectiveFocalLengthMin  
-r--r--r-- ./control/terminal/camera/default/iTerminal  
-r--r--r-- ./control/terminal/camera/default/bAssocTerminal  
-r--r--r-- ./control/terminal/camera/default/wTerminalType  
-r--r--r-- ./control/terminal/camera/default/bTerminalID  
drwxr-xr-x ./control/processing  
drwxr-xr-x ./control/processing/default  
-r--r--r-- ./control/processing/default/iProcessing  
-r--r--r-- ./control/processing/default/bmControls  
-r--r--r-- ./control/processing/default/wMaxMultiplier  
-r--r--r-- ./control/processing/default/bSourceID  
-r--r--r-- ./control/processing/default/bUnitID  
drwxr-xr-x ./control/header  
drwxr-xr-x ./control/header/h  
-rw-r--r-- ./control/header/h/dwClockFrequency  
-rw-r--r-- ./control/header/h/bcdUVC  
-rw-r--r-- ./streaming_maxburst  
-rw-r--r-- ./streaming_maxpacket  
-rw-r--r-- ./streaming_interval  

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 (actually there is only one)
=====================

uvc)

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

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

I used Laurent's program:
http://git.ideasonboard.org/uvc-gadget.git

with these patches:

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

host: luvcview -f yuv

Andrzej Pietrasiewicz (3):
  usb: gadget: f_uvc: rename a macro to avoid conflicts
  usb: gadget: uvc: verify descriptors presence
  usb: gadget: uvc: configfs support in uvc function

 Documentation/ABI/testing/configfs-usb-gadget-uvc |  265 +++
 drivers/usb/gadget/Kconfig                        |   11 +
 drivers/usb/gadget/function/Makefile              |    2 +-
 drivers/usb/gadget/function/f_uvc.c               |  136 +-
 drivers/usb/gadget/function/u_uvc.h               |   52 +-
 drivers/usb/gadget/function/uvc_configfs.c        | 2439 +++++++++++++++++++++
 drivers/usb/gadget/function/uvc_configfs.h        |   22 +
 7 files changed, 2917 insertions(+), 10 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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux