Merge 5240584bbaa1055d610661ba5a1b84f8a64efa7d on remote branch

Change-Id: I77df238f6ed770672c4481103b4a6e4e6c25ac12
diff --git a/etc/init.qcom.usb.rc b/etc/init.qcom.usb.rc
index 8225ccc..c193dd2 100644
--- a/etc/init.qcom.usb.rc
+++ b/etc/init.qcom.usb.rc
@@ -85,6 +85,7 @@
     mkdir /config/usb_gadget/g1/functions/rmnet_bam.dpl_bam_dmux
     mkdir /config/usb_gadget/g1/functions/ncm.0
     mkdir /config/usb_gadget/g1/functions/ccid.ccid
+    mkdir /config/usb_gadget/g1/functions/uac1.uac1
     mkdir /config/usb_gadget/g1/functions/uac2.0
     mkdir /config/usb_gadget/g1/functions/uvc.0
     mkdir /config/usb_gadget/g1/configs/b.1 0770
@@ -1580,6 +1581,47 @@
     write /config/usb_gadget/g1/UDC ${sys.usb.controller}
     setprop sys.usb.state ${sys.usb.config}
 
+on property:sys.usb.config=diag,uac1,adb && property:sys.usb.configfs=1
+    start adbd
+
+on property:sys.usb.ffs.ready=1 && property:sys.usb.config=diag,uac1,adb && property:sys.usb.configfs=1
+    write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_uac1_adb"
+    rm /config/usb_gadget/g1/configs/b.1/f1
+    rm /config/usb_gadget/g1/configs/b.1/f2
+    rm /config/usb_gadget/g1/configs/b.1/f3
+    rm /config/usb_gadget/g1/configs/b.1/f4
+    rm /config/usb_gadget/g1/configs/b.1/f5
+    rm /config/usb_gadget/g1/configs/b.1/f6
+    rm /config/usb_gadget/g1/configs/b.1/f7
+    rm /config/usb_gadget/g1/configs/b.1/f8
+    rm /config/usb_gadget/g1/configs/b.1/f9
+    write /config/usb_gadget/g1/idVendor 0x05C6
+    write /config/usb_gadget/g1/idProduct 0x9108
+    write /config/usb_gadget/g1/functions/diag.diag/pid 0x9108
+    symlink /config/usb_gadget/g1/functions/${vendor.usb.diag.func.name}.diag /config/usb_gadget/g1/configs/b.1/f1
+    symlink /config/usb_gadget/g1/functions/uac1.uac1 /config/usb_gadget/g1/configs/b.1/f2
+    symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f3
+    write /config/usb_gadget/g1/UDC ${sys.usb.controller}
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=diag,uac1 && property:sys.usb.configfs=1
+    write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_uac1"
+    rm /config/usb_gadget/g1/configs/b.1/f1
+    rm /config/usb_gadget/g1/configs/b.1/f2
+    rm /config/usb_gadget/g1/configs/b.1/f3
+    rm /config/usb_gadget/g1/configs/b.1/f4
+    rm /config/usb_gadget/g1/configs/b.1/f5
+    rm /config/usb_gadget/g1/configs/b.1/f6
+    rm /config/usb_gadget/g1/configs/b.1/f7
+    rm /config/usb_gadget/g1/configs/b.1/f8
+    rm /config/usb_gadget/g1/configs/b.1/f9
+    write /config/usb_gadget/g1/idVendor 0x05C6
+    write /config/usb_gadget/g1/idProduct 0x9109
+    symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1
+    symlink /config/usb_gadget/g1/functions/uac1.uac1 /config/usb_gadget/g1/configs/b.1/f2
+    write /config/usb_gadget/g1/UDC ${sys.usb.controller}
+    setprop sys.usb.state ${sys.usb.config}
+
 on property:sys.usb.config=diag,diag_cnss,serial_cdev,rmnet,dpl,qdss,adb && property:sys.usb.configfs=1
     start adbd
 
@@ -1630,6 +1672,49 @@
     write /config/usb_gadget/g1/UDC ${sys.usb.controller}
     setprop sys.usb.state ${sys.usb.config}
 
+on property:sys.usb.config=diag,uac1,uvc,adb && property:sys.usb.configfs=1
+    start adbd
+
+on property:sys.usb.ffs.ready=1 && property:sys.usb.config=diag,uac1,uvc,adb && property:sys.usb.configfs=1
+    write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_uac1_uvc_adb"
+    rm /config/usb_gadget/g1/configs/b.1/f1
+    rm /config/usb_gadget/g1/configs/b.1/f2
+    rm /config/usb_gadget/g1/configs/b.1/f3
+    rm /config/usb_gadget/g1/configs/b.1/f4
+    rm /config/usb_gadget/g1/configs/b.1/f5
+    rm /config/usb_gadget/g1/configs/b.1/f6
+    rm /config/usb_gadget/g1/configs/b.1/f7
+    rm /config/usb_gadget/g1/configs/b.1/f8
+    rm /config/usb_gadget/g1/configs/b.1/f9
+    write /config/usb_gadget/g1/idVendor 0x05C6
+    write /config/usb_gadget/g1/idProduct 0x9113
+    write /config/usb_gadget/g1/functions/diag.diag/pid 0x9113
+    symlink /config/usb_gadget/g1/functions/${vendor.usb.diag.func.name}.diag /config/usb_gadget/g1/configs/b.1/f1
+    symlink /config/usb_gadget/g1/functions/uac1.uac1 /config/usb_gadget/g1/configs/b.1/f2
+    symlink /config/usb_gadget/g1/functions/uvc.0 /config/usb_gadget/g1/configs/b.1/f3
+    symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f4
+    write /config/usb_gadget/g1/UDC ${sys.usb.controller}
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=diag,uac1,uvc && property:sys.usb.configfs=1
+    write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_uac1_uvc"
+    rm /config/usb_gadget/g1/configs/b.1/f1
+    rm /config/usb_gadget/g1/configs/b.1/f2
+    rm /config/usb_gadget/g1/configs/b.1/f3
+    rm /config/usb_gadget/g1/configs/b.1/f4
+    rm /config/usb_gadget/g1/configs/b.1/f5
+    rm /config/usb_gadget/g1/configs/b.1/f6
+    rm /config/usb_gadget/g1/configs/b.1/f7
+    rm /config/usb_gadget/g1/configs/b.1/f8
+    rm /config/usb_gadget/g1/configs/b.1/f9
+    write /config/usb_gadget/g1/idVendor 0x05C6
+    write /config/usb_gadget/g1/idProduct 0x9114
+    symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1
+    symlink /config/usb_gadget/g1/functions/uac1.uac1 /config/usb_gadget/g1/configs/b.1/f2
+    symlink /config/usb_gadget/g1/functions/uvc.0 /config/usb_gadget/g1/configs/b.1/f3
+    write /config/usb_gadget/g1/UDC ${sys.usb.controller}
+    setprop sys.usb.state ${sys.usb.config}
+
 on property:sys.usb.config=adb && property:sys.usb.configfs=1
     write /config/usb_gadget/g1/idVendor 0x18d1
     write /config/usb_gadget/g1/idProduct 0x4ee7
diff --git a/etc/init.qcom.usb.sh b/etc/init.qcom.usb.sh
index 07ee843..31f1a66 100644
--- a/etc/init.qcom.usb.sh
+++ b/etc/init.qcom.usb.sh
@@ -194,40 +194,115 @@
 	cd /config/usb_gadget/g1/functions/uvc.0
 
 	echo 3072 > streaming_maxpacket
-	echo 1 > streaming_maxburst
+	echo 10 > streaming_maxburst
 	mkdir control/header/h
 	ln -s control/header/h control/class/fs/
 	ln -s control/header/h control/class/ss
 
 	mkdir -p streaming/uncompressed/u/360p
-	echo "666666\n1000000\n5000000\n" > streaming/uncompressed/u/360p/dwFrameInterval
+	echo -e "333333\n666666\n1000000\n5000000\n" > streaming/uncompressed/u/360p/dwFrameInterval
+	echo 333333 > streaming/uncompressed/u/360p/dwDefaultFrameInterval
 
 	mkdir -p streaming/uncompressed/u/720p
 	echo 1280 > streaming/uncompressed/u/720p/wWidth
-	echo 720 > streaming/uncompressed/u/720p/wWidth
+	echo 720 > streaming/uncompressed/u/720p/wHeight
 	echo 29491200 > streaming/uncompressed/u/720p/dwMinBitRate
 	echo 29491200 > streaming/uncompressed/u/720p/dwMaxBitRate
 	echo 1843200 > streaming/uncompressed/u/720p/dwMaxVideoFrameBufferSize
-	echo 5000000 > streaming/uncompressed/u/720p/dwDefaultFrameInterval
-	echo "5000000\n" > streaming/uncompressed/u/720p/dwFrameInterval
+	echo 333333 > streaming/uncompressed/u/720p/dwDefaultFrameInterval
+	echo -e "333333\n666666\n1000000\n5000000\n" > streaming/uncompressed/u/720p/dwFrameInterval
+
+	mkdir -p streaming/uncompressed/u/1080p
+	echo 1920 > streaming/uncompressed/u/1080p/wWidth
+	echo 1080 > streaming/uncompressed/u/1080p/wHeight
+	echo 66355200 > streaming/uncompressed/u/1080p/dwMinBitRate
+	echo 995328000 > streaming/uncompressed/u/1080p/dwMaxBitRate
+	echo 4147200 > streaming/uncompressed/u/1080p/dwMaxVideoFrameBufferSize
+	echo 333333 > streaming/uncompressed/u/1080p/dwDefaultFrameInterval
+	echo -e "333333\n666666\n1000000\n5000000\n" > streaming/uncompressed/u/1080p/dwFrameInterval
+
+	mkdir -p streaming/uncompressed/u1/360p
+	echo -e "333333\n666666\n1000000\n5000000\n" > streaming/uncompressed/u1/360p/dwFrameInterval
+	echo 333333 > streaming/uncompressed/u1/360p/dwDefaultFrameInterval
+
+	mkdir -p streaming/mjpeg/m1/360p
+	echo 640 > streaming/mjpeg/m1/360p/wWidth
+	echo 360 > streaming/mjpeg/m1/360p/wHeight
+	echo 460800   > streaming/mjpeg/m1/360p/dwMaxVideoFrameBufferSize
+	echo 18432000  > streaming/mjpeg/m1/360p/dwMinBitRate
+	echo 55296000 > streaming/mjpeg/m1/360p/dwMaxBitRate
+	echo -e "333333\n666666\n1000000\n5000000\n" > streaming/mjpeg/m1/360p/dwFrameInterval
+	echo 333333 > streaming/mjpeg/m1/360p/dwDefaultFrameInterval
+
+	mkdir -p streaming/mjpeg/m1/720p
+	echo 1280 > streaming/mjpeg/m1/720p/wWidth
+	echo 720 > streaming/mjpeg/m1/720p/wHeight
+	echo 29491200 > streaming/mjpeg/m1/720p/dwMinBitRate
+	echo 29491200 > streaming/mjpeg/m1/720p/dwMaxBitRate
+	echo 1843200 > streaming/mjpeg/m1/720p/dwMaxVideoFrameBufferSize
+	echo 333333 > streaming/mjpeg/m1/720p/dwDefaultFrameInterval
+	echo -e "333333\n666666\n1000000\n5000000\n" > streaming/mjpeg/m1/720p/dwFrameInterval
+
+	mkdir -p streaming/mjpeg/m1/1080p
+	echo 1920 > streaming/mjpeg/m1/1080p/wWidth
+	echo 1080 > streaming/mjpeg/m1/1080p/wHeight
+	echo 66355200 > streaming/mjpeg/m1/1080p/dwMinBitRate
+	echo 995328000 > streaming/mjpeg/m1/1080p/dwMaxBitRate
+	echo 4147200 > streaming/mjpeg/m1/1080p/dwMaxVideoFrameBufferSize
+	echo 333333 > streaming/mjpeg/m1/1080p/dwDefaultFrameInterval
+	echo -e "333333\n666666\n1000000\n5000000\n" > streaming/mjpeg/m1/1080p/dwFrameInterval
 
 	mkdir -p streaming/mjpeg/m/360p
-	echo "666666\n1000000\n5000000\n" > streaming/mjpeg/m/360p/dwFrameInterval
+	echo 640 > streaming/mjpeg/m/360p/wWidth
+	echo 360 > streaming/mjpeg/m/360p/wHeight
+	echo 460800   > streaming/mjpeg/m/360p/dwMaxVideoFrameBufferSize
+	echo 18432000  > streaming/mjpeg/m/360p/dwMinBitRate
+	echo 55296000 > streaming/mjpeg/m/360p/dwMaxBitRate
+	echo "333333\n666666\n1000000\n5000000\n" > streaming/mjpeg/m/360p/dwFrameInterval
+	echo 333333 > streaming/mjpeg/m/360p/dwDefaultFrameInterval
 
 	mkdir -p streaming/mjpeg/m/720p
 	echo 1280 > streaming/mjpeg/m/720p/wWidth
-	echo 720 > streaming/mjpeg/m/720p/wWidth
+	echo 720 > streaming/mjpeg/m/720p/wHeight
 	echo 29491200 > streaming/mjpeg/m/720p/dwMinBitRate
 	echo 29491200 > streaming/mjpeg/m/720p/dwMaxBitRate
 	echo 1843200 > streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize
-	echo 5000000 > streaming/mjpeg/m/720p/dwDefaultFrameInterval
-	echo "5000000\n" > streaming/mjpeg/m/720p/dwFrameInterval
+	echo 333333 > streaming/mjpeg/m/720p/dwDefaultFrameInterval
+	echo "333333\n666666\n1000000\n5000000\n" > streaming/mjpeg/m/720p/dwFrameInterval
+
+	mkdir -p streaming/mjpeg/m/1080p
+	echo 1920 > streaming/mjpeg/m/1080p/wWidth
+	echo 1080 > streaming/mjpeg/m/1080p/wHeight
+	echo 66355200 > streaming/mjpeg/m/1080p/dwMinBitRate
+	echo 995328000 > streaming/mjpeg/m/1080p/dwMaxBitRate
+	echo 4147200 > streaming/mjpeg/m/1080p/dwMaxVideoFrameBufferSize
+	echo 333333 > streaming/mjpeg/m/1080p/dwDefaultFrameInterval
+	echo "333333\n666666\n1000000\n5000000\n" > streaming/mjpeg/m/1080p/dwFrameInterval
+
+	mkdir -p streaming/mjpeg/m/1440p
+	echo 2560 > streaming/mjpeg/m/1440p/wWidth
+	echo 1440 > streaming/mjpeg/m/1440p/wHeight
+	echo 117964800 > streaming/mjpeg/m/1440p/dwMinBitRate
+	echo 1769472000 > streaming/mjpeg/m/1440p/dwMaxBitRate
+	echo 7372800 > streaming/mjpeg/m/1440p/dwMaxVideoFrameBufferSize
+	echo 333333 > streaming/mjpeg/m/1440p/dwDefaultFrameInterval
+	echo "333333\n666666\n1000000\n5000000\n" > streaming/mjpeg/m/1440p/dwFrameInterval
+
+	mkdir -p streaming/mjpeg/m/2160p
+	echo 3840 > streaming/mjpeg/m/2160p/wWidth
+	echo 2160 > streaming/mjpeg/m/2160p/wHeight
+	echo 265420800 > streaming/mjpeg/m/2160p/dwMinBitRate
+	echo 3981312000 > streaming/mjpeg/m/2160p/dwMaxBitRate
+	echo 16588800 > streaming/mjpeg/m/2160p/dwMaxVideoFrameBufferSize
+	echo 333333 > streaming/mjpeg/m/2160p/dwDefaultFrameInterval
+	echo "333333\n666666\n1000000\n5000000\n" > streaming/mjpeg/m/2160p/dwFrameInterval
 
 	echo 0x04 > /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bmaControls
+	echo 0x04 > /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m1/bmaControls
 
 	mkdir -p streaming/h264/h/960p
 	echo 1920 > streaming/h264/h/960p/wWidth
-	echo 960 > streaming/h264/h/960p/wWidth
+	echo 960 > streaming/h264/h/960p/wHeight
 	echo 40 > streaming/h264/h/960p/bLevelIDC
 	echo "333667\n" > streaming/h264/h/960p/dwFrameInterval
 
@@ -235,10 +310,13 @@
 	echo "333667\n" > streaming/h264/h/1920p/dwFrameInterval
 
 	mkdir streaming/header/h
+	mkdir streaming/header/h1
+	ln -s streaming/uncompressed/u1 streaming/header/h1
+	ln -s streaming/mjpeg/m1 streaming/header/h1
 	ln -s streaming/uncompressed/u streaming/header/h
 	ln -s streaming/mjpeg/m streaming/header/h
 	ln -s streaming/h264/h streaming/header/h
-	ln -s streaming/header/h streaming/class/fs/
-	ln -s streaming/header/h streaming/class/hs/
+	ln -s streaming/header/h1 streaming/class/fs/
+	ln -s streaming/header/h1 streaming/class/hs/
 	ln -s streaming/header/h streaming/class/ss/
 fi