-
Notifications
You must be signed in to change notification settings - Fork 0
/
uvc_config.sh
126 lines (108 loc) · 3.86 KB
/
uvc_config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
USB_ROCKCHIP_DIR=/sys/kernel/config/usb_gadget/rockchip/
USB_FUNCTIONS_DIR=${USB_ROCKCHIP_DIR}/functions/
UVC_DIR=${USB_FUNCTIONS_DIR}/uvc.gs6/
UVC_STREAMING_DIR=${UVC_DIR}/streaming/
UVC_CONTROL_DIR=${UVC_DIR}/control/
UVC_U_DIR=${UVC_STREAMING_DIR}/uncompressed/u/
UVC_M_DIR=${UVC_STREAMING_DIR}/mjpeg/m/
UVC_F_DIR=${UVC_STREAMING_DIR}/framebased/f/
configure_uvc_resolution_yuyv()
{
W=$1
H=$2
DIR=${UVC_U_DIR}/${H}p/
mkdir ${DIR}
echo $W > ${DIR}/wWidth
echo $H > ${DIR}/wHeight
echo 333333 > ${DIR}/dwDefaultFrameInterval
echo $((W*H*20)) > ${DIR}/dwMinBitRate
echo $((W*H*20)) > ${DIR}/dwMaxBitRate
echo $((W*H*2)) > ${DIR}/dwMaxVideoFrameBufferSize
echo -e "333333\n666666\n1000000\n2000000" > ${DIR}/dwFrameInterval
}
configure_uvc_resolution_mjpeg()
{
W=$1
H=$2
DIR=${UVC_M_DIR}/${H}p/
mkdir ${DIR}
echo $W > ${DIR}/wWidth
echo $H > ${DIR}/wHeight
echo 333333 > ${DIR}/dwDefaultFrameInterval
echo $((W*H*20)) > ${DIR}/dwMinBitRate
echo $((W*H*20)) > ${DIR}/dwMaxBitRate
echo $((W*H*2)) > ${DIR}/dwMaxVideoFrameBufferSize
echo -e "333333\n666666\n1000000\n2000000" > ${DIR}/dwFrameInterval
}
configure_uvc_resolution_h264()
{
W=$1
H=$2
DIR=${UVC_F_DIR}/${H}p/
mkdir ${DIR}
echo $W > ${DIR}/wWidth
echo $H > ${DIR}/wHeight
echo 333333 > ${DIR}/dwDefaultFrameInterval
echo $((W*H*10)) > ${DIR}/dwMinBitRate
echo $((W*H*10)) > ${DIR}/dwMaxBitRate
#echo $((W*H*2)) > ${DIR}/dwMaxVideoFrameBufferSize
echo -e "333333\n666666\n1000000\n2000000" > ${DIR}/dwFrameInterval
}
/etc/init.d/S10udev stop
umount /sys/kernel/config
mount -t configfs none /sys/kernel/config
mkdir -p ${USB_ROCKCHIP_DIR}
mkdir -p ${USB_ROCKCHIP_DIR}/strings/0x409
mkdir -p ${USB_ROCKCHIP_DIR}/configs/b.1/strings/0x409
echo 0x2207 > ${USB_ROCKCHIP_DIR}/idVendor
echo 0x0310 > ${USB_ROCKCHIP_DIR}/bcdDevice
echo 0x0200 > ${USB_ROCKCHIP_DIR}/bcdUSB
echo "2020" > ${USB_ROCKCHIP_DIR}/strings/0x409/serialnumber
echo "Rockchip" > ${USB_ROCKCHIP_DIR}/strings/0x409/manufacturer
echo "UVC" > ${USB_ROCKCHIP_DIR}/strings/0x409/product
mkdir ${UVC_DIR}
#echo 3072 > ${UVC_DIR}/streaming_maxpacket
#echo 1 > ${UVC_DIR}/streaming_bulk
mkdir ${UVC_CONTROL_DIR}/header/h
ln -s ${UVC_CONTROL_DIR}/header/h ${UVC_CONTROL_DIR}/class/fs/h
ln -s ${UVC_CONTROL_DIR}/header/h ${UVC_CONTROL_DIR}/class/ss/h
##YUYV support config
mkdir ${UVC_U_DIR}
configure_uvc_resolution_yuyv 640 480
configure_uvc_resolution_yuyv 1280 720
##mjpeg support config
mkdir ${UVC_M_DIR}
configure_uvc_resolution_mjpeg 640 480
configure_uvc_resolution_mjpeg 1280 720
configure_uvc_resolution_mjpeg 1920 1080
configure_uvc_resolution_mjpeg 2560 1440
configure_uvc_resolution_mjpeg 2592 1944
## h.264 support config
mkdir ${UVC_F_DIR}
configure_uvc_resolution_h264 640 480
configure_uvc_resolution_h264 1280 720
configure_uvc_resolution_h264 1920 1080
mkdir ${UVC_STREAMING_DIR}/header/h
ln -s ${UVC_U_DIR} ${UVC_STREAMING_DIR}/header/h/u
ln -s ${UVC_M_DIR} ${UVC_STREAMING_DIR}/header/h/m
ln -s ${UVC_F_DIR} ${UVC_STREAMING_DIR}/header/h/f
ln -s ${UVC_STREAMING_DIR}/header/h ${UVC_STREAMING_DIR}/class/fs/h
ln -s ${UVC_STREAMING_DIR}/header/h ${UVC_STREAMING_DIR}/class/hs/h
ln -s ${UVC_STREAMING_DIR}/header/h ${UVC_STREAMING_DIR}/class/ss/h
echo 0x1 > ${USB_ROCKCHIP_DIR}/os_desc/b_vendor_code
echo "MSFT100" > ${USB_ROCKCHIP_DIR}/os_desc/qw_sign
echo 500 > ${USB_ROCKCHIP_DIR}/configs/b.1/MaxPower
ln -s ${USB_ROCKCHIP_DIR}/configs/b.1 ${USB_ROCKCHIP_DIR}/os_desc/b.1
echo 0x0005 > ${USB_ROCKCHIP_DIR}/idProduct
echo "uvc" > ${USB_ROCKCHIP_DIR}/configs/b.1/strings/0x409/configuration
USB_CONFIGS_DIR=${USB_ROCKCHIP_DIR}/configs/b.1
if [ -e ${USB_CONFIGS_DIR}/ffs.adb ]; then
#for rk1808 kernel 4.4
rm -f ${USB_CONFIGS_DIR}/ffs.adb
else
ls ${USB_CONFIGS_DIR} | grep f[0-9] | xargs -I {} rm ${USB_CONFIGS_DIR}/{}
fi
ln -s ${UVC_DIR} ${USB_ROCKCHIP_DIR}/configs/b.1/f1
UDC=`ls /sys/class/udc/| awk '{print $1}'`
echo $UDC > ${USB_ROCKCHIP_DIR}/UDC