media-ctl-pipeline.sh 12 KB

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