media-ctl-pipeline.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Copyright (C) 2021 StarFive Technology Co., Ltd.
  5. #
  6. USAGE="Usage: media-ctl-pipeline -d /dev/media0 -i interface_type -s sensor_type -a {start|stop}"
  7. devname="/dev/media0"
  8. while getopts "d:i:s:a:" arg
  9. do
  10. case $arg in
  11. d)
  12. devname=$OPTARG
  13. echo "select dev name: $devname"
  14. ;;
  15. i)
  16. interface_type=$OPTARG
  17. echo "select interface_type: $interface_type"
  18. ;;
  19. s)
  20. sensor_type=$OPTARG
  21. echo "select sensor_type: $sensor_type"
  22. ;;
  23. a)
  24. action=$OPTARG
  25. echo "select action: $action"
  26. ;;
  27. ?)
  28. echo "unknow argument"
  29. exit 1
  30. ;;
  31. esac
  32. done
  33. if [ -z $devname]; then
  34. echo "unknow media device"
  35. echo $USAGE
  36. exit 1
  37. fi
  38. if [ -z $interface_type ]; then
  39. echo "unknow interface type"
  40. echo $USAGE
  41. exit 1
  42. fi
  43. if [ -z $sensor_type ]; then
  44. echo "unknow sensor type"
  45. echo $USAGE
  46. exit 1
  47. fi
  48. if [ -z $action ]; then
  49. echo "unknow action type"
  50. echo $USAGE
  51. exit 1
  52. fi
  53. echo "Pipeline -d $devname -i $interface_type -s $sensor_type -a $action"
  54. case $interface_type in
  55. dvp)
  56. case $action in
  57. start)
  58. # media-ctl -d $devname -vl "'sc2235 1-0030':0 -> 'stf_dvp0':0 [1]"
  59. # media-ctl -d $devname -vl "'ov5640 1-003c':0 -> 'stf_dvp0':0 [1]"
  60. case $sensor_type in
  61. VIN)
  62. echo "DVP vin enable pipeline:"
  63. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_vin0_wr':0 [1]"
  64. # media-ctl -d $devname -vl "'stf_vin0_wr':1 -> 'stf_vin0_wr_video0':0 [1]"
  65. ;;
  66. ISP0)
  67. echo "DVP ISP0 enable pipeline:"
  68. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_isp0':0 [1]"
  69. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0':0 [1]"
  70. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [1]"
  71. ;;
  72. ISP0RAW)
  73. echo "DVP ISP0RAW enable pipeline:"
  74. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_isp0':0 [1]"
  75. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0_raw':0 [1]"
  76. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [1]"
  77. ;;
  78. ISP1)
  79. echo "DVP ISP1 enable pipeline:"
  80. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_isp1':0 [1]"
  81. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1':0 [1]"
  82. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [1]"
  83. ;;
  84. ISP1RAW)
  85. echo "DVP ISP1RAW enable pipeline:"
  86. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_isp1':0 [1]"
  87. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1_raw':0 [1]"
  88. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [1]"
  89. ;;
  90. *)
  91. echo $USAGE
  92. exit 1
  93. ;;
  94. esac
  95. ;;
  96. stop)
  97. # media-ctl -d $devname -vl "'sc2235 1-0030':0 -> 'stf_dvp0':0 [0]"
  98. # media-ctl -d $devname -vl "'ov5640 1-003c':0 -> 'stf_dvp0':0 [0]"
  99. case $sensor_type in
  100. VIN)
  101. echo "DVP vin disable pipeline:"
  102. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_vin0_wr':0 [0]"
  103. # media-ctl -d $devname -vl "'stf_vin0_wr':1 -> 'stf_vin0_wr_video0':0 [0]"
  104. ;;
  105. ISP0)
  106. echo "DVP ISP0 disable pipeline:"
  107. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_isp0':0 [0]"
  108. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0':0 [0]"
  109. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [0]"
  110. ;;
  111. ISP0RAW)
  112. echo "DVP ISP0RAW disable pipeline:"
  113. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_isp0':0 [0]"
  114. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0_raw':0 [0]"
  115. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [0]"
  116. ;;
  117. ISP1)
  118. echo "DVP ISP1 disable pipeline:"
  119. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_isp1':0 [0]"
  120. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1':0 [0]"
  121. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [0]"
  122. ;;
  123. ISP1RAW)
  124. echo "DVP ISP1RAW disable pipeline:"
  125. media-ctl -d $devname -vl "'stf_dvp0':1 -> 'stf_isp1':0 [0]"
  126. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1_raw':0 [0]"
  127. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [0]"
  128. ;;
  129. *)
  130. echo $USAGE
  131. exit 1
  132. ;;
  133. esac
  134. ;;
  135. *)
  136. echo $USAGE
  137. exit 1
  138. ;;
  139. esac
  140. ;;
  141. csiphy0)
  142. case $action in
  143. start)
  144. # media-ctl -d $devname -vl "'ov4689 0-0036':0 -> 'stf_csiphy0':0 [1]"
  145. case $sensor_type in
  146. VIN)
  147. echo "csiphy0 CSIRX0 vin enable pipeline:"
  148. ;;
  149. ISP0)
  150. echo "csiphy0 CSIRX0 ISP0 enable pipeline:"
  151. media-ctl -d $devname -vl "'stf_csiphy0':1 -> 'stf_csi0':0 [1]"
  152. media-ctl -d $devname -vl "'stf_csi0':1 -> 'stf_isp0':0 [1]"
  153. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0':0 [1]"
  154. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [1]"
  155. ;;
  156. ISP0RAW)
  157. echo "csiphy0 CSIRX0 ISP0RAW enable pipeline:"
  158. media-ctl -d $devname -vl "'stf_csiphy0':1 -> 'stf_csi0':0 [1]"
  159. media-ctl -d $devname -vl "'stf_csi0':1 -> 'stf_isp0':0 [1]"
  160. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0_raw':0 [1]"
  161. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [1]"
  162. ;;
  163. ISP1)
  164. echo "csiphy0 CSIRX0 ISP1 enable pipeline:"
  165. media-ctl -d $devname -vl "'stf_csiphy0':1 -> 'stf_csi0':0 [1]"
  166. media-ctl -d $devname -vl "'stf_csi0':1 -> 'stf_isp1':0 [1]"
  167. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1':0 [1]"
  168. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [1]"
  169. ;;
  170. ISP1RAW)
  171. echo "csiphy0 CSIRX0 ISP1RAW enable pipeline:"
  172. media-ctl -d $devname -vl "'stf_csiphy0':1 -> 'stf_csi0':0 [1]"
  173. media-ctl -d $devname -vl "'stf_csi0':1 -> 'stf_isp1':0 [1]"
  174. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1_raw':0 [1]"
  175. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [1]"
  176. ;;
  177. *)
  178. echo $USAGE
  179. exit 1
  180. ;;
  181. esac
  182. ;;
  183. stop)
  184. # media-ctl -d $devname -vl "'ov4689 0-0036':0 -> 'stf_csiphy0':0 [0]"
  185. case $sensor_type in
  186. VIN)
  187. echo "csiphy0 CSIRX0 vin disable pipeline:"
  188. ;;
  189. ISP0)
  190. echo "csiphy0 CSIRX0 ISP0 disable pipeline:"
  191. media-ctl -d $devname -vl "'stf_csiphy0':1 -> 'stf_csi0':0 [0]"
  192. media-ctl -d $devname -vl "'stf_csi0':1 -> 'stf_isp0':0 [0]"
  193. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0':0 [0]"
  194. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [0]"
  195. ;;
  196. ISP0RAW)
  197. echo "csiphy0 CSIRX0 ISP0RAW disable pipeline:"
  198. media-ctl -d $devname -vl "'stf_csiphy0':1 -> 'stf_csi0':0 [0]"
  199. media-ctl -d $devname -vl "'stf_csi0':1 -> 'stf_isp0':0 [0]"
  200. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0_raw':0 [0]"
  201. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [0]"
  202. ;;
  203. ISP1)
  204. echo "csiphy0 CSIRX0 ISP1 disable pipeline:"
  205. media-ctl -d $devname -vl "'stf_csiphy0':1 -> 'stf_csi0':0 [0]"
  206. media-ctl -d $devname -vl "'stf_csi0':1 -> 'stf_isp1':0 [0]"
  207. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1':0 [0]"
  208. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [0]"
  209. ;;
  210. ISP1RAW)
  211. echo "csiphy0 CSIRX0 ISP1RAW disable pipeline:"
  212. media-ctl -d $devname -vl "'stf_csiphy0':1 -> 'stf_csi0':0 [0]"
  213. media-ctl -d $devname -vl "'stf_csi0':1 -> 'stf_isp1':0 [0]"
  214. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1_raw':0 [0]"
  215. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [0]"
  216. ;;
  217. *)
  218. echo $USAGE
  219. exit 1
  220. ;;
  221. esac
  222. ;;
  223. *)
  224. echo $USAGE
  225. exit 1
  226. ;;
  227. esac
  228. ;;
  229. csiphy1)
  230. case $action in
  231. start)
  232. # media-ctl -d $devname -vl "'ov4689 2-0036':0 -> 'stf_csiphy1':0 [1]"
  233. case $sensor_type in
  234. VIN)
  235. echo "csiphy1 CSIRX0 vin enable pipeline:"
  236. ;;
  237. ISP0)
  238. echo "csiphy1 CSIRX1 ISP0 enable pipeline:"
  239. media-ctl -d $devname -vl "'stf_csiphy1':1 -> 'stf_csi1':0 [1]"
  240. media-ctl -d $devname -vl "'stf_csi1':1 -> 'stf_isp0':0 [1]"
  241. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0':0 [1]"
  242. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [1]"
  243. ;;
  244. ISP0RAW)
  245. echo "csiphy1 CSIRX1 ISP0RAW enable pipeline:"
  246. media-ctl -d $devname -vl "'stf_csiphy1':1 -> 'stf_csi1':0 [1]"
  247. media-ctl -d $devname -vl "'stf_csi1':1 -> 'stf_isp0':0 [1]"
  248. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0_raw':0 [1]"
  249. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [1]"
  250. ;;
  251. ISP1)
  252. echo "csiphy1 CSIRX1 ISP1 enable pipeline:"
  253. media-ctl -d $devname -vl "'stf_csiphy1':1 -> 'stf_csi1':0 [1]"
  254. media-ctl -d $devname -vl "'stf_csi1':1 -> 'stf_isp1':0 [1]"
  255. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1':0 [1]"
  256. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [1]"
  257. ;;
  258. ISP1RAW)
  259. echo "csiphy1 CSIRX1 ISP1RAW enable pipeline:"
  260. media-ctl -d $devname -vl "'stf_csiphy1':1 -> 'stf_csi1':0 [1]"
  261. media-ctl -d $devname -vl "'stf_csi1':1 -> 'stf_isp1':0 [1]"
  262. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1_raw':0 [1]"
  263. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [1]"
  264. ;;
  265. *)
  266. echo $USAGE
  267. exit 1
  268. ;;
  269. esac
  270. ;;
  271. stop)
  272. # media-ctl -d $devname -vl "'ov4689 0-0036':0 -> 'stf_csiphy0':0 [0]"
  273. case $sensor_type in
  274. VIN)
  275. echo "csiphy1 CSIRX0 vin disable pipeline:"
  276. ;;
  277. ISP0)
  278. echo "csiphy1 CSIRX1 ISP0 disable pipeline:"
  279. media-ctl -d $devname -vl "'stf_csiphy1':1 -> 'stf_csi1':0 [0]"
  280. media-ctl -d $devname -vl "'stf_csi1':1 -> 'stf_isp0':0 [0]"
  281. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0':0 [0]"
  282. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [0]"
  283. ;;
  284. ISP0RAW)
  285. echo "csiphy1 CSIRX1 ISP0RAW disable pipeline:"
  286. media-ctl -d $devname -vl "'stf_csiphy1':1 -> 'stf_csi1':0 [0]"
  287. media-ctl -d $devname -vl "'stf_csi1':1 -> 'stf_isp0':0 [0]"
  288. media-ctl -d $devname -vl "'stf_isp0':1 -> 'stf_vin0_isp0_raw':0 [0]"
  289. # media-ctl -d $devname -vl "'stf_vin0_isp0':1 -> 'stf_vin0_isp0_video1':0 [0]"
  290. ;;
  291. ISP1)
  292. echo "csiphy1 CSIRX1 ISP1 disable pipeline:"
  293. media-ctl -d $devname -vl "'stf_csiphy1':1 -> 'stf_csi1':0 [0]"
  294. media-ctl -d $devname -vl "'stf_csi1':1 -> 'stf_isp1':0 [0]"
  295. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1':0 [0]"
  296. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [0]"
  297. ;;
  298. ISP1RAW)
  299. echo "csiphy1 CSIRX1 ISP1RAW disable pipeline:"
  300. media-ctl -d $devname -vl "'stf_csiphy1':1 -> 'stf_csi1':0 [0]"
  301. media-ctl -d $devname -vl "'stf_csi1':1 -> 'stf_isp1':0 [0]"
  302. media-ctl -d $devname -vl "'stf_isp1':1 -> 'stf_vin0_isp1_raw':0 [0]"
  303. # media-ctl -d $devname -vl "'stf_vin0_isp1':1 -> 'stf_vin0_isp1_video2':0 [0]"
  304. ;;
  305. *)
  306. echo $USAGE
  307. exit 1
  308. ;;
  309. esac
  310. ;;
  311. *)
  312. echo $USAGE
  313. exit 1
  314. ;;
  315. esac
  316. ;;
  317. *)
  318. echo $USAGE
  319. exit 1
  320. ;;
  321. esac
  322. exit 0;