summaryrefslogtreecommitdiff
path: root/scripts/uvc-gadget.sh
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2018-06-05 22:47:06 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-06-08 23:06:55 +0300
commit891e3120b41ae206002ba76e737d9b13bd327a29 (patch)
treea1af86c37f90bd64fb221f4c822b0fb9fd537867 /scripts/uvc-gadget.sh
parent1efb386db7afee91d21c952bfeca703e77930903 (diff)
uvc-gadget.sh: add function to create frame size
Currently there are a set of files that need to be written to in configfs to instantiate a single frame size of a UVC function. Add a function create_frame() to do this in one call. There is no delete_frame() since delete_uvc() will delete the frame settings. Previously delete_uvc() only deleted the single frame size, so this has been changed to a wildcard to catch all frame sizes. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'scripts/uvc-gadget.sh')
-rwxr-xr-xscripts/uvc-gadget.sh32
1 files changed, 25 insertions, 7 deletions
diff --git a/scripts/uvc-gadget.sh b/scripts/uvc-gadget.sh
index 46cc384..6c528f5 100755
--- a/scripts/uvc-gadget.sh
+++ b/scripts/uvc-gadget.sh
@@ -85,6 +85,27 @@ delete_msd() {
echo "OK"
}
+create_frame() {
+ # Example usage:
+ # create_frame <function name> <width> <height>
+
+ FUNCTION=$1
+ WIDTH=$2
+ HEIGHT=$3
+
+ wdir=functions/$FUNCTION/streaming/uncompressed/u/${HEIGHT}p
+
+ mkdir -p $wdir
+ echo $WIDTH > $wdir/wWidth
+ echo $HEIGHT > $wdir/wHeight
+ echo $(( $WIDTH * $HEIGHT * 2 )) > $wdir/dwMaxVideoFrameBufferSize
+ cat <<EOF > $wdir/dwFrameInterval
+666666
+100000
+5000000
+EOF
+}
+
create_uvc() {
# Example usage:
# create_uvc <target config> <function name>
@@ -94,12 +115,9 @@ create_uvc() {
echo " Creating UVC gadget functionality : $FUNCTION"
mkdir functions/$FUNCTION
- mkdir -p functions/$FUNCTION/streaming/uncompressed/u/360p
- cat <<EOF > functions/$FUNCTION/streaming/uncompressed/u/360p/dwFrameInterval
-666666
-1000000
-5000000
-EOF
+
+ create_frame $FUNCTION 640 360
+
mkdir functions/$FUNCTION/streaming/header/h
cd functions/$FUNCTION/streaming/header/h
ln -s ../../uncompressed/u
@@ -134,7 +152,7 @@ delete_uvc() {
rm functions/$FUNCTION/control/class/*/h
rm functions/$FUNCTION/streaming/class/*/h
rm functions/$FUNCTION/streaming/header/h/u
- rmdir functions/$FUNCTION/streaming/uncompressed/u/360p
+ rmdir functions/$FUNCTION/streaming/uncompressed/u/*/
rmdir functions/$FUNCTION/streaming/uncompressed/u
rmdir functions/$FUNCTION/streaming/header/h
rmdir functions/$FUNCTION/control/header/h