mtk_drm_crtc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <asm/barrier.h>
  14. #include <drm/drmP.h>
  15. #include <drm/drm_atomic_helper.h>
  16. #include <drm/drm_crtc_helper.h>
  17. #include <drm/drm_plane_helper.h>
  18. #include <linux/clk.h>
  19. #include <linux/pm_runtime.h>
  20. #include <soc/mediatek/smi.h>
  21. #include "mtk_drm_drv.h"
  22. #include "mtk_drm_crtc.h"
  23. #include "mtk_drm_ddp.h"
  24. #include "mtk_drm_ddp_comp.h"
  25. #include "mtk_drm_gem.h"
  26. #include "mtk_drm_plane.h"
  27. /**
  28. * struct mtk_drm_crtc - MediaTek specific crtc structure.
  29. * @base: crtc object.
  30. * @enabled: records whether crtc_enable succeeded
  31. * @planes: array of 4 mtk_drm_plane structures, one for each overlay plane
  32. * @pending_planes: whether any plane has pending changes to be applied
  33. * @config_regs: memory mapped mmsys configuration register space
  34. * @mutex: handle to one of the ten disp_mutex streams
  35. * @ddp_comp_nr: number of components in ddp_comp
  36. * @ddp_comp: array of pointers the mtk_ddp_comp structures used by this crtc
  37. */
  38. struct mtk_drm_crtc {
  39. struct drm_crtc base;
  40. bool enabled;
  41. bool pending_needs_vblank;
  42. struct drm_pending_vblank_event *event;
  43. struct mtk_drm_plane planes[OVL_LAYER_NR];
  44. bool pending_planes;
  45. void __iomem *config_regs;
  46. struct mtk_disp_mutex *mutex;
  47. unsigned int ddp_comp_nr;
  48. struct mtk_ddp_comp **ddp_comp;
  49. };
  50. struct mtk_crtc_state {
  51. struct drm_crtc_state base;
  52. bool pending_config;
  53. unsigned int pending_width;
  54. unsigned int pending_height;
  55. unsigned int pending_vrefresh;
  56. };
  57. static inline struct mtk_drm_crtc *to_mtk_crtc(struct drm_crtc *c)
  58. {
  59. return container_of(c, struct mtk_drm_crtc, base);
  60. }
  61. static inline struct mtk_crtc_state *to_mtk_crtc_state(struct drm_crtc_state *s)
  62. {
  63. return container_of(s, struct mtk_crtc_state, base);
  64. }
  65. static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
  66. {
  67. struct drm_crtc *crtc = &mtk_crtc->base;
  68. unsigned long flags;
  69. spin_lock_irqsave(&crtc->dev->event_lock, flags);
  70. drm_crtc_send_vblank_event(crtc, mtk_crtc->event);
  71. drm_crtc_vblank_put(crtc);
  72. mtk_crtc->event = NULL;
  73. spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
  74. }
  75. static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
  76. {
  77. drm_crtc_handle_vblank(&mtk_crtc->base);
  78. if (mtk_crtc->pending_needs_vblank) {
  79. mtk_drm_crtc_finish_page_flip(mtk_crtc);
  80. mtk_crtc->pending_needs_vblank = false;
  81. }
  82. }
  83. static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
  84. {
  85. struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
  86. int i;
  87. for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
  88. clk_unprepare(mtk_crtc->ddp_comp[i]->clk);
  89. mtk_disp_mutex_put(mtk_crtc->mutex);
  90. drm_crtc_cleanup(crtc);
  91. }
  92. static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
  93. {
  94. struct mtk_crtc_state *state;
  95. if (crtc->state) {
  96. if (crtc->state->mode_blob)
  97. drm_property_unreference_blob(crtc->state->mode_blob);
  98. state = to_mtk_crtc_state(crtc->state);
  99. memset(state, 0, sizeof(*state));
  100. } else {
  101. state = kzalloc(sizeof(*state), GFP_KERNEL);
  102. if (!state)
  103. return;
  104. crtc->state = &state->base;
  105. }
  106. state->base.crtc = crtc;
  107. }
  108. static struct drm_crtc_state *mtk_drm_crtc_duplicate_state(struct drm_crtc *crtc)
  109. {
  110. struct mtk_crtc_state *state;
  111. state = kzalloc(sizeof(*state), GFP_KERNEL);
  112. if (!state)
  113. return NULL;
  114. __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
  115. WARN_ON(state->base.crtc != crtc);
  116. state->base.crtc = crtc;
  117. return &state->base;
  118. }
  119. static void mtk_drm_crtc_destroy_state(struct drm_crtc *crtc,
  120. struct drm_crtc_state *state)
  121. {
  122. __drm_atomic_helper_crtc_destroy_state(state);
  123. kfree(to_mtk_crtc_state(state));
  124. }
  125. static bool mtk_drm_crtc_mode_fixup(struct drm_crtc *crtc,
  126. const struct drm_display_mode *mode,
  127. struct drm_display_mode *adjusted_mode)
  128. {
  129. /* Nothing to do here, but this callback is mandatory. */
  130. return true;
  131. }
  132. static void mtk_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
  133. {
  134. struct mtk_crtc_state *state = to_mtk_crtc_state(crtc->state);
  135. state->pending_width = crtc->mode.hdisplay;
  136. state->pending_height = crtc->mode.vdisplay;
  137. state->pending_vrefresh = crtc->mode.vrefresh;
  138. wmb(); /* Make sure the above parameters are set before update */
  139. state->pending_config = true;
  140. }
  141. int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe)
  142. {
  143. struct mtk_drm_private *priv = drm->dev_private;
  144. struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(priv->crtc[pipe]);
  145. struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
  146. mtk_ddp_comp_enable_vblank(ovl, &mtk_crtc->base);
  147. return 0;
  148. }
  149. void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe)
  150. {
  151. struct mtk_drm_private *priv = drm->dev_private;
  152. struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(priv->crtc[pipe]);
  153. struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
  154. mtk_ddp_comp_disable_vblank(ovl);
  155. }
  156. static int mtk_crtc_ddp_clk_enable(struct mtk_drm_crtc *mtk_crtc)
  157. {
  158. int ret;
  159. int i;
  160. DRM_DEBUG_DRIVER("%s\n", __func__);
  161. for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
  162. ret = clk_enable(mtk_crtc->ddp_comp[i]->clk);
  163. if (ret) {
  164. DRM_ERROR("Failed to enable clock %d: %d\n", i, ret);
  165. goto err;
  166. }
  167. }
  168. return 0;
  169. err:
  170. while (--i >= 0)
  171. clk_disable(mtk_crtc->ddp_comp[i]->clk);
  172. return ret;
  173. }
  174. static void mtk_crtc_ddp_clk_disable(struct mtk_drm_crtc *mtk_crtc)
  175. {
  176. int i;
  177. DRM_DEBUG_DRIVER("%s\n", __func__);
  178. for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
  179. clk_disable(mtk_crtc->ddp_comp[i]->clk);
  180. }
  181. static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc)
  182. {
  183. struct drm_crtc *crtc = &mtk_crtc->base;
  184. unsigned int width, height, vrefresh;
  185. int ret;
  186. int i;
  187. DRM_DEBUG_DRIVER("%s\n", __func__);
  188. if (WARN_ON(!crtc->state))
  189. return -EINVAL;
  190. width = crtc->state->adjusted_mode.hdisplay;
  191. height = crtc->state->adjusted_mode.vdisplay;
  192. vrefresh = crtc->state->adjusted_mode.vrefresh;
  193. ret = pm_runtime_get_sync(crtc->dev->dev);
  194. if (ret < 0) {
  195. DRM_ERROR("Failed to enable power domain: %d\n", ret);
  196. return ret;
  197. }
  198. ret = mtk_disp_mutex_prepare(mtk_crtc->mutex);
  199. if (ret < 0) {
  200. DRM_ERROR("Failed to enable mutex clock: %d\n", ret);
  201. goto err_pm_runtime_put;
  202. }
  203. ret = mtk_crtc_ddp_clk_enable(mtk_crtc);
  204. if (ret < 0) {
  205. DRM_ERROR("Failed to enable component clocks: %d\n", ret);
  206. goto err_mutex_unprepare;
  207. }
  208. DRM_DEBUG_DRIVER("mediatek_ddp_ddp_path_setup\n");
  209. for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) {
  210. mtk_ddp_add_comp_to_path(mtk_crtc->config_regs,
  211. mtk_crtc->ddp_comp[i]->id,
  212. mtk_crtc->ddp_comp[i + 1]->id);
  213. mtk_disp_mutex_add_comp(mtk_crtc->mutex,
  214. mtk_crtc->ddp_comp[i]->id);
  215. }
  216. mtk_disp_mutex_add_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id);
  217. mtk_disp_mutex_enable(mtk_crtc->mutex);
  218. for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
  219. struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[i];
  220. mtk_ddp_comp_config(comp, width, height, vrefresh);
  221. mtk_ddp_comp_start(comp);
  222. }
  223. /* Initially configure all planes */
  224. for (i = 0; i < OVL_LAYER_NR; i++) {
  225. struct drm_plane *plane = &mtk_crtc->planes[i].base;
  226. struct mtk_plane_state *plane_state;
  227. plane_state = to_mtk_plane_state(plane->state);
  228. mtk_ddp_comp_layer_config(mtk_crtc->ddp_comp[0], i,
  229. plane_state);
  230. }
  231. return 0;
  232. err_mutex_unprepare:
  233. mtk_disp_mutex_unprepare(mtk_crtc->mutex);
  234. err_pm_runtime_put:
  235. pm_runtime_put(crtc->dev->dev);
  236. return ret;
  237. }
  238. static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc)
  239. {
  240. struct drm_device *drm = mtk_crtc->base.dev;
  241. int i;
  242. DRM_DEBUG_DRIVER("%s\n", __func__);
  243. for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
  244. mtk_ddp_comp_stop(mtk_crtc->ddp_comp[i]);
  245. for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
  246. mtk_disp_mutex_remove_comp(mtk_crtc->mutex,
  247. mtk_crtc->ddp_comp[i]->id);
  248. mtk_disp_mutex_disable(mtk_crtc->mutex);
  249. for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) {
  250. mtk_ddp_remove_comp_from_path(mtk_crtc->config_regs,
  251. mtk_crtc->ddp_comp[i]->id,
  252. mtk_crtc->ddp_comp[i + 1]->id);
  253. mtk_disp_mutex_remove_comp(mtk_crtc->mutex,
  254. mtk_crtc->ddp_comp[i]->id);
  255. }
  256. mtk_disp_mutex_remove_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id);
  257. mtk_crtc_ddp_clk_disable(mtk_crtc);
  258. mtk_disp_mutex_unprepare(mtk_crtc->mutex);
  259. pm_runtime_put(drm->dev);
  260. }
  261. static void mtk_drm_crtc_enable(struct drm_crtc *crtc)
  262. {
  263. struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
  264. struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
  265. int ret;
  266. DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id);
  267. ret = mtk_smi_larb_get(ovl->larb_dev);
  268. if (ret) {
  269. DRM_ERROR("Failed to get larb: %d\n", ret);
  270. return;
  271. }
  272. ret = mtk_crtc_ddp_hw_init(mtk_crtc);
  273. if (ret) {
  274. mtk_smi_larb_put(ovl->larb_dev);
  275. return;
  276. }
  277. drm_crtc_vblank_on(crtc);
  278. mtk_crtc->enabled = true;
  279. }
  280. static void mtk_drm_crtc_disable(struct drm_crtc *crtc)
  281. {
  282. struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
  283. struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
  284. int i;
  285. DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id);
  286. if (!mtk_crtc->enabled)
  287. return;
  288. /* Set all pending plane state to disabled */
  289. for (i = 0; i < OVL_LAYER_NR; i++) {
  290. struct drm_plane *plane = &mtk_crtc->planes[i].base;
  291. struct mtk_plane_state *plane_state;
  292. plane_state = to_mtk_plane_state(plane->state);
  293. plane_state->pending.enable = false;
  294. plane_state->pending.config = true;
  295. }
  296. mtk_crtc->pending_planes = true;
  297. /* Wait for planes to be disabled */
  298. drm_crtc_wait_one_vblank(crtc);
  299. drm_crtc_vblank_off(crtc);
  300. mtk_crtc_ddp_hw_fini(mtk_crtc);
  301. mtk_smi_larb_put(ovl->larb_dev);
  302. mtk_crtc->enabled = false;
  303. }
  304. static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc,
  305. struct drm_crtc_state *old_crtc_state)
  306. {
  307. struct mtk_crtc_state *state = to_mtk_crtc_state(crtc->state);
  308. struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
  309. if (mtk_crtc->event && state->base.event)
  310. DRM_ERROR("new event while there is still a pending event\n");
  311. if (state->base.event) {
  312. state->base.event->pipe = drm_crtc_index(crtc);
  313. WARN_ON(drm_crtc_vblank_get(crtc) != 0);
  314. mtk_crtc->event = state->base.event;
  315. state->base.event = NULL;
  316. }
  317. }
  318. static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
  319. struct drm_crtc_state *old_crtc_state)
  320. {
  321. struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
  322. unsigned int pending_planes = 0;
  323. int i;
  324. if (mtk_crtc->event)
  325. mtk_crtc->pending_needs_vblank = true;
  326. for (i = 0; i < OVL_LAYER_NR; i++) {
  327. struct drm_plane *plane = &mtk_crtc->planes[i].base;
  328. struct mtk_plane_state *plane_state;
  329. plane_state = to_mtk_plane_state(plane->state);
  330. if (plane_state->pending.dirty) {
  331. plane_state->pending.config = true;
  332. plane_state->pending.dirty = false;
  333. pending_planes |= BIT(i);
  334. }
  335. }
  336. if (pending_planes)
  337. mtk_crtc->pending_planes = true;
  338. }
  339. static const struct drm_crtc_funcs mtk_crtc_funcs = {
  340. .set_config = drm_atomic_helper_set_config,
  341. .page_flip = drm_atomic_helper_page_flip,
  342. .destroy = mtk_drm_crtc_destroy,
  343. .reset = mtk_drm_crtc_reset,
  344. .atomic_duplicate_state = mtk_drm_crtc_duplicate_state,
  345. .atomic_destroy_state = mtk_drm_crtc_destroy_state,
  346. };
  347. static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
  348. .mode_fixup = mtk_drm_crtc_mode_fixup,
  349. .mode_set_nofb = mtk_drm_crtc_mode_set_nofb,
  350. .enable = mtk_drm_crtc_enable,
  351. .disable = mtk_drm_crtc_disable,
  352. .atomic_begin = mtk_drm_crtc_atomic_begin,
  353. .atomic_flush = mtk_drm_crtc_atomic_flush,
  354. };
  355. static int mtk_drm_crtc_init(struct drm_device *drm,
  356. struct mtk_drm_crtc *mtk_crtc,
  357. struct drm_plane *primary,
  358. struct drm_plane *cursor, unsigned int pipe)
  359. {
  360. int ret;
  361. ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor,
  362. &mtk_crtc_funcs, NULL);
  363. if (ret)
  364. goto err_cleanup_crtc;
  365. drm_crtc_helper_add(&mtk_crtc->base, &mtk_crtc_helper_funcs);
  366. return 0;
  367. err_cleanup_crtc:
  368. drm_crtc_cleanup(&mtk_crtc->base);
  369. return ret;
  370. }
  371. void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *ovl)
  372. {
  373. struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
  374. struct mtk_crtc_state *state = to_mtk_crtc_state(mtk_crtc->base.state);
  375. unsigned int i;
  376. /*
  377. * TODO: instead of updating the registers here, we should prepare
  378. * working registers in atomic_commit and let the hardware command
  379. * queue update module registers on vblank.
  380. */
  381. if (state->pending_config) {
  382. mtk_ddp_comp_config(ovl, state->pending_width,
  383. state->pending_height,
  384. state->pending_vrefresh);
  385. state->pending_config = false;
  386. }
  387. if (mtk_crtc->pending_planes) {
  388. for (i = 0; i < OVL_LAYER_NR; i++) {
  389. struct drm_plane *plane = &mtk_crtc->planes[i].base;
  390. struct mtk_plane_state *plane_state;
  391. plane_state = to_mtk_plane_state(plane->state);
  392. if (plane_state->pending.config) {
  393. mtk_ddp_comp_layer_config(ovl, i, plane_state);
  394. plane_state->pending.config = false;
  395. }
  396. }
  397. mtk_crtc->pending_planes = false;
  398. }
  399. mtk_drm_finish_page_flip(mtk_crtc);
  400. }
  401. int mtk_drm_crtc_create(struct drm_device *drm_dev,
  402. const enum mtk_ddp_comp_id *path, unsigned int path_len)
  403. {
  404. struct mtk_drm_private *priv = drm_dev->dev_private;
  405. struct device *dev = drm_dev->dev;
  406. struct mtk_drm_crtc *mtk_crtc;
  407. enum drm_plane_type type;
  408. unsigned int zpos;
  409. int pipe = priv->num_pipes;
  410. int ret;
  411. int i;
  412. for (i = 0; i < path_len; i++) {
  413. enum mtk_ddp_comp_id comp_id = path[i];
  414. struct device_node *node;
  415. node = priv->comp_node[comp_id];
  416. if (!node) {
  417. dev_info(dev,
  418. "Not creating crtc %d because component %d is disabled or missing\n",
  419. pipe, comp_id);
  420. return 0;
  421. }
  422. }
  423. mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
  424. if (!mtk_crtc)
  425. return -ENOMEM;
  426. mtk_crtc->config_regs = priv->config_regs;
  427. mtk_crtc->ddp_comp_nr = path_len;
  428. mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr,
  429. sizeof(*mtk_crtc->ddp_comp),
  430. GFP_KERNEL);
  431. mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe);
  432. if (IS_ERR(mtk_crtc->mutex)) {
  433. ret = PTR_ERR(mtk_crtc->mutex);
  434. dev_err(dev, "Failed to get mutex: %d\n", ret);
  435. return ret;
  436. }
  437. for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
  438. enum mtk_ddp_comp_id comp_id = path[i];
  439. struct mtk_ddp_comp *comp;
  440. struct device_node *node;
  441. node = priv->comp_node[comp_id];
  442. comp = priv->ddp_comp[comp_id];
  443. if (!comp) {
  444. dev_err(dev, "Component %s not initialized\n",
  445. node->full_name);
  446. ret = -ENODEV;
  447. goto unprepare;
  448. }
  449. ret = clk_prepare(comp->clk);
  450. if (ret) {
  451. dev_err(dev,
  452. "Failed to prepare clock for component %s: %d\n",
  453. node->full_name, ret);
  454. goto unprepare;
  455. }
  456. mtk_crtc->ddp_comp[i] = comp;
  457. }
  458. for (zpos = 0; zpos < OVL_LAYER_NR; zpos++) {
  459. type = (zpos == 0) ? DRM_PLANE_TYPE_PRIMARY :
  460. (zpos == 1) ? DRM_PLANE_TYPE_CURSOR :
  461. DRM_PLANE_TYPE_OVERLAY;
  462. ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos],
  463. BIT(pipe), type, zpos);
  464. if (ret)
  465. goto unprepare;
  466. }
  467. ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0].base,
  468. &mtk_crtc->planes[1].base, pipe);
  469. if (ret < 0)
  470. goto unprepare;
  471. priv->crtc[pipe] = &mtk_crtc->base;
  472. priv->num_pipes++;
  473. return 0;
  474. unprepare:
  475. while (--i >= 0)
  476. clk_unprepare(mtk_crtc->ddp_comp[i]->clk);
  477. return ret;
  478. }