media-ctl-pipeline.sh 12 KB

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