vsp1_pipe.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. /*
  2. * vsp1_pipe.c -- R-Car VSP1 Pipeline
  3. *
  4. * Copyright (C) 2013-2015 Renesas Electronics Corporation
  5. *
  6. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/delay.h>
  14. #include <linux/list.h>
  15. #include <linux/sched.h>
  16. #include <linux/wait.h>
  17. #include <media/media-entity.h>
  18. #include <media/v4l2-subdev.h>
  19. #include "vsp1.h"
  20. #include "vsp1_bru.h"
  21. #include "vsp1_dl.h"
  22. #include "vsp1_entity.h"
  23. #include "vsp1_hgo.h"
  24. #include "vsp1_hgt.h"
  25. #include "vsp1_pipe.h"
  26. #include "vsp1_rwpf.h"
  27. #include "vsp1_uds.h"
  28. /* -----------------------------------------------------------------------------
  29. * Helper Functions
  30. */
  31. static const struct vsp1_format_info vsp1_video_formats[] = {
  32. { V4L2_PIX_FMT_RGB332, MEDIA_BUS_FMT_ARGB8888_1X32,
  33. VI6_FMT_RGB_332, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  34. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  35. 1, { 8, 0, 0 }, false, false, 1, 1, false },
  36. { V4L2_PIX_FMT_ARGB444, MEDIA_BUS_FMT_ARGB8888_1X32,
  37. VI6_FMT_ARGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  38. VI6_RPF_DSWAP_P_WDS,
  39. 1, { 16, 0, 0 }, false, false, 1, 1, true },
  40. { V4L2_PIX_FMT_XRGB444, MEDIA_BUS_FMT_ARGB8888_1X32,
  41. VI6_FMT_XRGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  42. VI6_RPF_DSWAP_P_WDS,
  43. 1, { 16, 0, 0 }, false, false, 1, 1, false },
  44. { V4L2_PIX_FMT_ARGB555, MEDIA_BUS_FMT_ARGB8888_1X32,
  45. VI6_FMT_ARGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  46. VI6_RPF_DSWAP_P_WDS,
  47. 1, { 16, 0, 0 }, false, false, 1, 1, true },
  48. { V4L2_PIX_FMT_XRGB555, MEDIA_BUS_FMT_ARGB8888_1X32,
  49. VI6_FMT_XRGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  50. VI6_RPF_DSWAP_P_WDS,
  51. 1, { 16, 0, 0 }, false, false, 1, 1, false },
  52. { V4L2_PIX_FMT_RGB565, MEDIA_BUS_FMT_ARGB8888_1X32,
  53. VI6_FMT_RGB_565, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  54. VI6_RPF_DSWAP_P_WDS,
  55. 1, { 16, 0, 0 }, false, false, 1, 1, false },
  56. { V4L2_PIX_FMT_BGR24, MEDIA_BUS_FMT_ARGB8888_1X32,
  57. VI6_FMT_BGR_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  58. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  59. 1, { 24, 0, 0 }, false, false, 1, 1, false },
  60. { V4L2_PIX_FMT_RGB24, MEDIA_BUS_FMT_ARGB8888_1X32,
  61. VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  62. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  63. 1, { 24, 0, 0 }, false, false, 1, 1, false },
  64. { V4L2_PIX_FMT_ABGR32, MEDIA_BUS_FMT_ARGB8888_1X32,
  65. VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS,
  66. 1, { 32, 0, 0 }, false, false, 1, 1, true },
  67. { V4L2_PIX_FMT_XBGR32, MEDIA_BUS_FMT_ARGB8888_1X32,
  68. VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS,
  69. 1, { 32, 0, 0 }, false, false, 1, 1, false },
  70. { V4L2_PIX_FMT_ARGB32, MEDIA_BUS_FMT_ARGB8888_1X32,
  71. VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  72. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  73. 1, { 32, 0, 0 }, false, false, 1, 1, true },
  74. { V4L2_PIX_FMT_XRGB32, MEDIA_BUS_FMT_ARGB8888_1X32,
  75. VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  76. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  77. 1, { 32, 0, 0 }, false, false, 1, 1, false },
  78. { V4L2_PIX_FMT_HSV24, MEDIA_BUS_FMT_AHSV8888_1X32,
  79. VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  80. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  81. 1, { 24, 0, 0 }, false, false, 1, 1, false },
  82. { V4L2_PIX_FMT_HSV32, MEDIA_BUS_FMT_AHSV8888_1X32,
  83. VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  84. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  85. 1, { 32, 0, 0 }, false, false, 1, 1, false },
  86. { V4L2_PIX_FMT_UYVY, MEDIA_BUS_FMT_AYUV8_1X32,
  87. VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  88. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  89. 1, { 16, 0, 0 }, false, false, 2, 1, false },
  90. { V4L2_PIX_FMT_VYUY, MEDIA_BUS_FMT_AYUV8_1X32,
  91. VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  92. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  93. 1, { 16, 0, 0 }, false, true, 2, 1, false },
  94. { V4L2_PIX_FMT_YUYV, MEDIA_BUS_FMT_AYUV8_1X32,
  95. VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  96. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  97. 1, { 16, 0, 0 }, true, false, 2, 1, false },
  98. { V4L2_PIX_FMT_YVYU, MEDIA_BUS_FMT_AYUV8_1X32,
  99. VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  100. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  101. 1, { 16, 0, 0 }, true, true, 2, 1, false },
  102. { V4L2_PIX_FMT_NV12M, MEDIA_BUS_FMT_AYUV8_1X32,
  103. VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  104. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  105. 2, { 8, 16, 0 }, false, false, 2, 2, false },
  106. { V4L2_PIX_FMT_NV21M, MEDIA_BUS_FMT_AYUV8_1X32,
  107. VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  108. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  109. 2, { 8, 16, 0 }, false, true, 2, 2, false },
  110. { V4L2_PIX_FMT_NV16M, MEDIA_BUS_FMT_AYUV8_1X32,
  111. VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  112. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  113. 2, { 8, 16, 0 }, false, false, 2, 1, false },
  114. { V4L2_PIX_FMT_NV61M, MEDIA_BUS_FMT_AYUV8_1X32,
  115. VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  116. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  117. 2, { 8, 16, 0 }, false, true, 2, 1, false },
  118. { V4L2_PIX_FMT_YUV420M, MEDIA_BUS_FMT_AYUV8_1X32,
  119. VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  120. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  121. 3, { 8, 8, 8 }, false, false, 2, 2, false },
  122. { V4L2_PIX_FMT_YVU420M, MEDIA_BUS_FMT_AYUV8_1X32,
  123. VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  124. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  125. 3, { 8, 8, 8 }, false, true, 2, 2, false },
  126. { V4L2_PIX_FMT_YUV422M, MEDIA_BUS_FMT_AYUV8_1X32,
  127. VI6_FMT_Y_U_V_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  128. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  129. 3, { 8, 8, 8 }, false, false, 2, 1, false },
  130. { V4L2_PIX_FMT_YVU422M, MEDIA_BUS_FMT_AYUV8_1X32,
  131. VI6_FMT_Y_U_V_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  132. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  133. 3, { 8, 8, 8 }, false, true, 2, 1, false },
  134. { V4L2_PIX_FMT_YUV444M, MEDIA_BUS_FMT_AYUV8_1X32,
  135. VI6_FMT_Y_U_V_444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  136. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  137. 3, { 8, 8, 8 }, false, false, 1, 1, false },
  138. { V4L2_PIX_FMT_YVU444M, MEDIA_BUS_FMT_AYUV8_1X32,
  139. VI6_FMT_Y_U_V_444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
  140. VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
  141. 3, { 8, 8, 8 }, false, true, 1, 1, false },
  142. };
  143. /**
  144. * vsp1_get_format_info - Retrieve format information for a 4CC
  145. * @vsp1: the VSP1 device
  146. * @fourcc: the format 4CC
  147. *
  148. * Return a pointer to the format information structure corresponding to the
  149. * given V4L2 format 4CC, or NULL if no corresponding format can be found.
  150. */
  151. const struct vsp1_format_info *vsp1_get_format_info(struct vsp1_device *vsp1,
  152. u32 fourcc)
  153. {
  154. unsigned int i;
  155. /* Special case, the VYUY and HSV formats are supported on Gen2 only. */
  156. if (vsp1->info->gen != 2) {
  157. switch (fourcc) {
  158. case V4L2_PIX_FMT_VYUY:
  159. case V4L2_PIX_FMT_HSV24:
  160. case V4L2_PIX_FMT_HSV32:
  161. return NULL;
  162. }
  163. }
  164. for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) {
  165. const struct vsp1_format_info *info = &vsp1_video_formats[i];
  166. if (info->fourcc == fourcc)
  167. return info;
  168. }
  169. return NULL;
  170. }
  171. /* -----------------------------------------------------------------------------
  172. * Pipeline Management
  173. */
  174. void vsp1_pipeline_reset(struct vsp1_pipeline *pipe)
  175. {
  176. unsigned int i;
  177. if (pipe->bru) {
  178. struct vsp1_bru *bru = to_bru(&pipe->bru->subdev);
  179. for (i = 0; i < ARRAY_SIZE(bru->inputs); ++i)
  180. bru->inputs[i].rpf = NULL;
  181. }
  182. for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) {
  183. if (pipe->inputs[i]) {
  184. pipe->inputs[i]->pipe = NULL;
  185. pipe->inputs[i] = NULL;
  186. }
  187. }
  188. if (pipe->output) {
  189. pipe->output->pipe = NULL;
  190. pipe->output = NULL;
  191. }
  192. if (pipe->hgo) {
  193. struct vsp1_hgo *hgo = to_hgo(&pipe->hgo->subdev);
  194. hgo->histo.pipe = NULL;
  195. }
  196. if (pipe->hgt) {
  197. struct vsp1_hgt *hgt = to_hgt(&pipe->hgt->subdev);
  198. hgt->histo.pipe = NULL;
  199. }
  200. INIT_LIST_HEAD(&pipe->entities);
  201. pipe->state = VSP1_PIPELINE_STOPPED;
  202. pipe->buffers_ready = 0;
  203. pipe->num_inputs = 0;
  204. pipe->bru = NULL;
  205. pipe->hgo = NULL;
  206. pipe->hgt = NULL;
  207. pipe->lif = NULL;
  208. pipe->uds = NULL;
  209. }
  210. void vsp1_pipeline_init(struct vsp1_pipeline *pipe)
  211. {
  212. mutex_init(&pipe->lock);
  213. spin_lock_init(&pipe->irqlock);
  214. init_waitqueue_head(&pipe->wq);
  215. kref_init(&pipe->kref);
  216. INIT_LIST_HEAD(&pipe->entities);
  217. pipe->state = VSP1_PIPELINE_STOPPED;
  218. }
  219. /* Must be called with the pipe irqlock held. */
  220. void vsp1_pipeline_run(struct vsp1_pipeline *pipe)
  221. {
  222. struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
  223. if (pipe->state == VSP1_PIPELINE_STOPPED) {
  224. vsp1_write(vsp1, VI6_CMD(pipe->output->entity.index),
  225. VI6_CMD_STRCMD);
  226. pipe->state = VSP1_PIPELINE_RUNNING;
  227. }
  228. pipe->buffers_ready = 0;
  229. }
  230. bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe)
  231. {
  232. unsigned long flags;
  233. bool stopped;
  234. spin_lock_irqsave(&pipe->irqlock, flags);
  235. stopped = pipe->state == VSP1_PIPELINE_STOPPED;
  236. spin_unlock_irqrestore(&pipe->irqlock, flags);
  237. return stopped;
  238. }
  239. int vsp1_pipeline_stop(struct vsp1_pipeline *pipe)
  240. {
  241. struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
  242. struct vsp1_entity *entity;
  243. unsigned long flags;
  244. int ret;
  245. if (pipe->lif) {
  246. /*
  247. * When using display lists in continuous frame mode the only
  248. * way to stop the pipeline is to reset the hardware.
  249. */
  250. ret = vsp1_reset_wpf(vsp1, pipe->output->entity.index);
  251. if (ret == 0) {
  252. spin_lock_irqsave(&pipe->irqlock, flags);
  253. pipe->state = VSP1_PIPELINE_STOPPED;
  254. spin_unlock_irqrestore(&pipe->irqlock, flags);
  255. }
  256. } else {
  257. /* Otherwise just request a stop and wait. */
  258. spin_lock_irqsave(&pipe->irqlock, flags);
  259. if (pipe->state == VSP1_PIPELINE_RUNNING)
  260. pipe->state = VSP1_PIPELINE_STOPPING;
  261. spin_unlock_irqrestore(&pipe->irqlock, flags);
  262. ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
  263. msecs_to_jiffies(500));
  264. ret = ret == 0 ? -ETIMEDOUT : 0;
  265. }
  266. list_for_each_entry(entity, &pipe->entities, list_pipe) {
  267. if (entity->route && entity->route->reg)
  268. vsp1_write(vsp1, entity->route->reg,
  269. VI6_DPR_NODE_UNUSED);
  270. }
  271. if (pipe->hgo)
  272. vsp1_write(vsp1, VI6_DPR_HGO_SMPPT,
  273. (7 << VI6_DPR_SMPPT_TGW_SHIFT) |
  274. (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT));
  275. if (pipe->hgt)
  276. vsp1_write(vsp1, VI6_DPR_HGT_SMPPT,
  277. (7 << VI6_DPR_SMPPT_TGW_SHIFT) |
  278. (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT));
  279. v4l2_subdev_call(&pipe->output->entity.subdev, video, s_stream, 0);
  280. return ret;
  281. }
  282. bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe)
  283. {
  284. unsigned int mask;
  285. mask = ((1 << pipe->num_inputs) - 1) << 1;
  286. if (!pipe->lif)
  287. mask |= 1 << 0;
  288. return pipe->buffers_ready == mask;
  289. }
  290. void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe)
  291. {
  292. bool completed;
  293. if (pipe == NULL)
  294. return;
  295. /*
  296. * If the DL commit raced with the frame end interrupt, the commit ends
  297. * up being postponed by one frame. @completed represents whether the
  298. * active frame was finished or postponed.
  299. */
  300. completed = vsp1_dlm_irq_frame_end(pipe->output->dlm);
  301. if (pipe->hgo)
  302. vsp1_hgo_frame_end(pipe->hgo);
  303. if (pipe->hgt)
  304. vsp1_hgt_frame_end(pipe->hgt);
  305. /*
  306. * Regardless of frame completion we still need to notify the pipe
  307. * frame_end to account for vblank events.
  308. */
  309. if (pipe->frame_end)
  310. pipe->frame_end(pipe, completed);
  311. pipe->sequence++;
  312. }
  313. /*
  314. * Propagate the alpha value through the pipeline.
  315. *
  316. * As the UDS has restricted scaling capabilities when the alpha component needs
  317. * to be scaled, we disable alpha scaling when the UDS input has a fixed alpha
  318. * value. The UDS then outputs a fixed alpha value which needs to be programmed
  319. * from the input RPF alpha.
  320. */
  321. void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
  322. struct vsp1_dl_list *dl, unsigned int alpha)
  323. {
  324. if (!pipe->uds)
  325. return;
  326. /*
  327. * The BRU and BRS background color has a fixed alpha value set to 255,
  328. * the output alpha value is thus always equal to 255.
  329. */
  330. if (pipe->uds_input->type == VSP1_ENTITY_BRU ||
  331. pipe->uds_input->type == VSP1_ENTITY_BRS)
  332. alpha = 255;
  333. vsp1_uds_set_alpha(pipe->uds, dl, alpha);
  334. }
  335. /*
  336. * Propagate the partition calculations through the pipeline
  337. *
  338. * Work backwards through the pipe, allowing each entity to update the partition
  339. * parameters based on its configuration, and the entity connected to its
  340. * source. Each entity must produce the partition required for the previous
  341. * entity in the pipeline.
  342. */
  343. void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe,
  344. struct vsp1_partition *partition,
  345. unsigned int index,
  346. struct vsp1_partition_window *window)
  347. {
  348. struct vsp1_entity *entity;
  349. list_for_each_entry_reverse(entity, &pipe->entities, list_pipe) {
  350. if (entity->ops->partition)
  351. entity->ops->partition(entity, pipe, partition, index,
  352. window);
  353. }
  354. }
  355. void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
  356. {
  357. unsigned long flags;
  358. unsigned int i;
  359. int ret;
  360. /*
  361. * To avoid increasing the system suspend time needlessly, loop over the
  362. * pipelines twice, first to set them all to the stopping state, and
  363. * then to wait for the stop to complete.
  364. */
  365. for (i = 0; i < vsp1->info->wpf_count; ++i) {
  366. struct vsp1_rwpf *wpf = vsp1->wpf[i];
  367. struct vsp1_pipeline *pipe;
  368. if (wpf == NULL)
  369. continue;
  370. pipe = wpf->pipe;
  371. if (pipe == NULL)
  372. continue;
  373. spin_lock_irqsave(&pipe->irqlock, flags);
  374. if (pipe->state == VSP1_PIPELINE_RUNNING)
  375. pipe->state = VSP1_PIPELINE_STOPPING;
  376. spin_unlock_irqrestore(&pipe->irqlock, flags);
  377. }
  378. for (i = 0; i < vsp1->info->wpf_count; ++i) {
  379. struct vsp1_rwpf *wpf = vsp1->wpf[i];
  380. struct vsp1_pipeline *pipe;
  381. if (wpf == NULL)
  382. continue;
  383. pipe = wpf->pipe;
  384. if (pipe == NULL)
  385. continue;
  386. ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
  387. msecs_to_jiffies(500));
  388. if (ret == 0)
  389. dev_warn(vsp1->dev, "pipeline %u stop timeout\n",
  390. wpf->entity.index);
  391. }
  392. }
  393. void vsp1_pipelines_resume(struct vsp1_device *vsp1)
  394. {
  395. unsigned long flags;
  396. unsigned int i;
  397. /* Resume all running pipelines. */
  398. for (i = 0; i < vsp1->info->wpf_count; ++i) {
  399. struct vsp1_rwpf *wpf = vsp1->wpf[i];
  400. struct vsp1_pipeline *pipe;
  401. if (wpf == NULL)
  402. continue;
  403. pipe = wpf->pipe;
  404. if (pipe == NULL)
  405. continue;
  406. spin_lock_irqsave(&pipe->irqlock, flags);
  407. if (vsp1_pipeline_ready(pipe))
  408. vsp1_pipeline_run(pipe);
  409. spin_unlock_irqrestore(&pipe->irqlock, flags);
  410. }
  411. }