init.qcom.usb.sh 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #!/vendor/bin/sh
  2. # Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are
  6. # met:
  7. # * Redistributions of source code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # * Redistributions in binary form must reproduce the above
  10. # copyright notice, this list of conditions and the following
  11. # disclaimer in the documentation and/or other materials provided
  12. # with the distribution.
  13. # * Neither the name of The Linux Foundation nor the names of its
  14. # contributors may be used to endorse or promote products derived
  15. # from this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  18. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  20. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  21. # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  24. # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  26. # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  27. # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. #
  29. #
  30. # Set platform variables
  31. soc_hwplatform=`cat /sys/devices/soc0/hw_platform 2> /dev/null`
  32. soc_machine=`cat /sys/devices/soc0/machine 2> /dev/null`
  33. soc_machine=${soc_machine:0:2}
  34. soc_id=`cat /sys/devices/soc0/soc_id 2> /dev/null`
  35. #
  36. # Check ESOC for external modem
  37. #
  38. # Note: currently only a single MDM/SDX is supported
  39. #
  40. esoc_name=`cat /sys/bus/esoc/devices/esoc0/esoc_name 2> /dev/null`
  41. target=`getprop ro.board.platform`
  42. if [ -f /sys/class/android_usb/f_mass_storage/lun/nofua ]; then
  43. echo 1 > /sys/class/android_usb/f_mass_storage/lun/nofua
  44. fi
  45. #
  46. # Override USB default composition
  47. #
  48. # If USB persist config not set, set default configuration
  49. if [ "$(getprop persist.vendor.usb.config)" == "" -a \
  50. "$(getprop init.svc.vendor.usb-gadget-hal-1-0)" != "running" ]; then
  51. if [ "$esoc_name" != "" ]; then
  52. setprop persist.vendor.usb.config diag,diag_mdm,qdss,qdss_mdm,serial_cdev,dpl,rmnet,adb
  53. else
  54. case "$(getprop ro.baseband)" in
  55. "apq")
  56. setprop persist.vendor.usb.config diag,adb
  57. ;;
  58. *)
  59. case "$soc_hwplatform" in
  60. "Dragon" | "SBC")
  61. setprop persist.vendor.usb.config diag,adb
  62. ;;
  63. *)
  64. case "$soc_machine" in
  65. "SA")
  66. setprop persist.vendor.usb.config diag,adb
  67. ;;
  68. *)
  69. case "$target" in
  70. "msm8909")
  71. setprop persist.vendor.usb.config diag,serial_smd,rmnet_qti_bam,adb
  72. ;;
  73. "msm8937")
  74. if [ -d /config/usb_gadget ]; then
  75. if [ "$(getprop ro.build.type)" != "user" ]; then
  76. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  77. fi
  78. else
  79. case "$soc_id" in
  80. "313" | "320")
  81. setprop persist.vendor.usb.config diag,serial_smd,rmnet_ipa,adb
  82. ;;
  83. *)
  84. setprop persist.vendor.usb.config diag,serial_smd,rmnet_qti_bam,adb
  85. ;;
  86. esac
  87. fi
  88. ;;
  89. "msm8953")
  90. if [ -d /config/usb_gadget ]; then
  91. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  92. else
  93. setprop persist.vendor.usb.config diag,serial_smd,rmnet_ipa,adb
  94. fi
  95. ;;
  96. "msm8996")
  97. if [ -d /config/usb_gadget ]; then
  98. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,adb
  99. else
  100. setprop persist.vendor.usb.config diag,serial_cdev,serial_tty,rmnet_ipa,mass_storage,adb
  101. fi
  102. ;;
  103. "msm8998" | "sdm660" | "apq8098_latv")
  104. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,adb
  105. ;;
  106. "sdm845" | "sdm710")
  107. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  108. ;;
  109. "msmnile" | "sm6150" | "trinket")
  110. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,qdss,adb
  111. ;;
  112. *)
  113. setprop persist.vendor.usb.config diag,adb
  114. ;;
  115. esac
  116. ;;
  117. esac
  118. ;;
  119. esac
  120. ;;
  121. esac
  122. fi
  123. fi
  124. # Start peripheral mode on primary USB controllers for Automotive platforms
  125. case "$soc_machine" in
  126. "SA")
  127. if [ -f /sys/bus/platform/devices/a600000.ssusb/mode ]; then
  128. default_mode=`cat /sys/bus/platform/devices/a600000.ssusb/mode`
  129. case "$default_mode" in
  130. "none")
  131. echo peripheral > /sys/bus/platform/devices/a600000.ssusb/mode
  132. ;;
  133. esac
  134. fi
  135. ;;
  136. esac
  137. # set rndis transport to BAM2BAM_IPA for 8920 and 8940
  138. if [ "$target" == "msm8937" ]; then
  139. if [ ! -d /config/usb_gadget ]; then
  140. case "$soc_id" in
  141. "313" | "320")
  142. echo BAM2BAM_IPA > /sys/class/android_usb/android0/f_rndis_qc/rndis_transports
  143. ;;
  144. *)
  145. ;;
  146. esac
  147. else
  148. case "$soc_id" in
  149. "313" | "320")
  150. setprop vendor.usb.rndis.func.name "rndis_bam"
  151. setprop vendor.usb.rmnet.func.name "rmnet_bam"
  152. setprop vendor.usb.rmnet.inst.name "rmnet"
  153. setprop vendor.usb.dpl.inst.name "dpl"
  154. ;;
  155. *)
  156. ;;
  157. esac
  158. fi
  159. fi
  160. if [ "$target" == "msm8996" ]; then
  161. if [ -d /config/usb_gadget ]; then
  162. setprop vendor.usb.rndis.func.name "rndis_bam"
  163. setprop vendor.usb.rmnet.func.name "rmnet_bam"
  164. setprop vendor.usb.rmnet.inst.name "rmnet"
  165. setprop vendor.usb.dpl.inst.name "dpl"
  166. fi
  167. fi
  168. # check configfs is mounted or not
  169. if [ -d /config/usb_gadget ]; then
  170. # Chip-serial is used for unique MSM identification in Product string
  171. msm_serial=`cat /sys/devices/soc0/serial_number`;
  172. msm_serial_hex=`printf %08X $msm_serial`
  173. machine_type=`cat /sys/devices/soc0/machine`
  174. product_string="$machine_type-$soc_hwplatform _SN:$msm_serial_hex"
  175. echo "$product_string" > /config/usb_gadget/g1/strings/0x409/product
  176. # ADB requires valid iSerialNumber; if ro.serialno is missing, use dummy
  177. serialnumber=`cat /config/usb_gadget/g1/strings/0x409/serialnumber 2> /dev/null`
  178. if [ "$serialnumber" == "" ]; then
  179. serialno=1234567
  180. echo $serialno > /config/usb_gadget/g1/strings/0x409/serialnumber
  181. fi
  182. fi
  183. #
  184. # Initialize RNDIS Diag option. If unset, set it to 'none'.
  185. #
  186. diag_extra=`getprop persist.vendor.usb.config.extra`
  187. if [ "$diag_extra" == "" ]; then
  188. setprop persist.vendor.usb.config.extra none
  189. fi
  190. # enable rps cpus on msm8937 target
  191. setprop vendor.usb.rps_mask 0
  192. case "$soc_id" in
  193. "294" | "295" | "353" | "354")
  194. setprop vendor.usb.rps_mask 40
  195. ;;
  196. esac
  197. #
  198. # Initialize UVC conifguration.
  199. #
  200. if [ -d /config/usb_gadget/g1/functions/uvc.0 ]; then
  201. cd /config/usb_gadget/g1/functions/uvc.0
  202. echo 3072 > streaming_maxpacket
  203. echo 1 > streaming_maxburst
  204. mkdir control/header/h
  205. ln -s control/header/h control/class/fs/
  206. ln -s control/header/h control/class/ss
  207. mkdir -p streaming/uncompressed/u/360p
  208. echo "666666\n1000000\n5000000\n" > streaming/uncompressed/u/360p/dwFrameInterval
  209. mkdir -p streaming/uncompressed/u/720p
  210. echo 1280 > streaming/uncompressed/u/720p/wWidth
  211. echo 720 > streaming/uncompressed/u/720p/wWidth
  212. echo 29491200 > streaming/uncompressed/u/720p/dwMinBitRate
  213. echo 29491200 > streaming/uncompressed/u/720p/dwMaxBitRate
  214. echo 1843200 > streaming/uncompressed/u/720p/dwMaxVideoFrameBufferSize
  215. echo 5000000 > streaming/uncompressed/u/720p/dwDefaultFrameInterval
  216. echo "5000000\n" > streaming/uncompressed/u/720p/dwFrameInterval
  217. mkdir -p streaming/mjpeg/m/360p
  218. echo "666666\n1000000\n5000000\n" > streaming/mjpeg/m/360p/dwFrameInterval
  219. mkdir -p streaming/mjpeg/m/720p
  220. echo 1280 > streaming/mjpeg/m/720p/wWidth
  221. echo 720 > streaming/mjpeg/m/720p/wWidth
  222. echo 29491200 > streaming/mjpeg/m/720p/dwMinBitRate
  223. echo 29491200 > streaming/mjpeg/m/720p/dwMaxBitRate
  224. echo 1843200 > streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize
  225. echo 5000000 > streaming/mjpeg/m/720p/dwDefaultFrameInterval
  226. echo "5000000\n" > streaming/mjpeg/m/720p/dwFrameInterval
  227. echo 0x04 > /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bmaControls
  228. mkdir -p streaming/h264/h/960p
  229. echo 1920 > streaming/h264/h/960p/wWidth
  230. echo 960 > streaming/h264/h/960p/wWidth
  231. echo 40 > streaming/h264/h/960p/bLevelIDC
  232. echo "333667\n" > streaming/h264/h/960p/dwFrameInterval
  233. mkdir -p streaming/h264/h/1920p
  234. echo "333667\n" > streaming/h264/h/1920p/dwFrameInterval
  235. mkdir streaming/header/h
  236. ln -s streaming/uncompressed/u streaming/header/h
  237. ln -s streaming/mjpeg/m streaming/header/h
  238. ln -s streaming/h264/h streaming/header/h
  239. ln -s streaming/header/h streaming/class/fs/
  240. ln -s streaming/header/h streaming/class/hs/
  241. ln -s streaming/header/h streaming/class/ss/
  242. fi