rcar_du_crtc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /*
  2. * rcar_du_crtc.c -- R-Car Display Unit CRTCs
  3. *
  4. * Copyright (C) 2013 Renesas 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/clk.h>
  14. #include <linux/mutex.h>
  15. #include <drm/drmP.h>
  16. #include <drm/drm_crtc.h>
  17. #include <drm/drm_crtc_helper.h>
  18. #include <drm/drm_fb_cma_helper.h>
  19. #include <drm/drm_gem_cma_helper.h>
  20. #include "rcar_du_crtc.h"
  21. #include "rcar_du_drv.h"
  22. #include "rcar_du_kms.h"
  23. #include "rcar_du_plane.h"
  24. #include "rcar_du_regs.h"
  25. #define to_rcar_crtc(c) container_of(c, struct rcar_du_crtc, crtc)
  26. static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg)
  27. {
  28. struct rcar_du_device *rcdu = rcrtc->group->dev;
  29. return rcar_du_read(rcdu, rcrtc->mmio_offset + reg);
  30. }
  31. static void rcar_du_crtc_write(struct rcar_du_crtc *rcrtc, u32 reg, u32 data)
  32. {
  33. struct rcar_du_device *rcdu = rcrtc->group->dev;
  34. rcar_du_write(rcdu, rcrtc->mmio_offset + reg, data);
  35. }
  36. static void rcar_du_crtc_clr(struct rcar_du_crtc *rcrtc, u32 reg, u32 clr)
  37. {
  38. struct rcar_du_device *rcdu = rcrtc->group->dev;
  39. rcar_du_write(rcdu, rcrtc->mmio_offset + reg,
  40. rcar_du_read(rcdu, rcrtc->mmio_offset + reg) & ~clr);
  41. }
  42. static void rcar_du_crtc_set(struct rcar_du_crtc *rcrtc, u32 reg, u32 set)
  43. {
  44. struct rcar_du_device *rcdu = rcrtc->group->dev;
  45. rcar_du_write(rcdu, rcrtc->mmio_offset + reg,
  46. rcar_du_read(rcdu, rcrtc->mmio_offset + reg) | set);
  47. }
  48. static void rcar_du_crtc_clr_set(struct rcar_du_crtc *rcrtc, u32 reg,
  49. u32 clr, u32 set)
  50. {
  51. struct rcar_du_device *rcdu = rcrtc->group->dev;
  52. u32 value = rcar_du_read(rcdu, rcrtc->mmio_offset + reg);
  53. rcar_du_write(rcdu, rcrtc->mmio_offset + reg, (value & ~clr) | set);
  54. }
  55. static int rcar_du_crtc_get(struct rcar_du_crtc *rcrtc)
  56. {
  57. int ret;
  58. ret = clk_prepare_enable(rcrtc->clock);
  59. if (ret < 0)
  60. return ret;
  61. ret = rcar_du_group_get(rcrtc->group);
  62. if (ret < 0)
  63. clk_disable_unprepare(rcrtc->clock);
  64. return ret;
  65. }
  66. static void rcar_du_crtc_put(struct rcar_du_crtc *rcrtc)
  67. {
  68. rcar_du_group_put(rcrtc->group);
  69. clk_disable_unprepare(rcrtc->clock);
  70. }
  71. static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc)
  72. {
  73. const struct drm_display_mode *mode = &rcrtc->crtc.mode;
  74. unsigned long clk;
  75. u32 value;
  76. u32 div;
  77. /* Dot clock */
  78. clk = clk_get_rate(rcrtc->clock);
  79. div = DIV_ROUND_CLOSEST(clk, mode->clock * 1000);
  80. div = clamp(div, 1U, 64U) - 1;
  81. rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? ESCR2 : ESCR,
  82. ESCR_DCLKSEL_CLKS | div);
  83. rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? OTAR2 : OTAR, 0);
  84. /* Signal polarities */
  85. value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL)
  86. | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? 0 : DSMR_HSL)
  87. | DSMR_DIPM_DE;
  88. rcar_du_crtc_write(rcrtc, DSMR, value);
  89. /* Display timings */
  90. rcar_du_crtc_write(rcrtc, HDSR, mode->htotal - mode->hsync_start - 19);
  91. rcar_du_crtc_write(rcrtc, HDER, mode->htotal - mode->hsync_start +
  92. mode->hdisplay - 19);
  93. rcar_du_crtc_write(rcrtc, HSWR, mode->hsync_end -
  94. mode->hsync_start - 1);
  95. rcar_du_crtc_write(rcrtc, HCR, mode->htotal - 1);
  96. rcar_du_crtc_write(rcrtc, VDSR, mode->vtotal - mode->vsync_end - 2);
  97. rcar_du_crtc_write(rcrtc, VDER, mode->vtotal - mode->vsync_end +
  98. mode->vdisplay - 2);
  99. rcar_du_crtc_write(rcrtc, VSPR, mode->vtotal - mode->vsync_end +
  100. mode->vsync_start - 1);
  101. rcar_du_crtc_write(rcrtc, VCR, mode->vtotal - 1);
  102. rcar_du_crtc_write(rcrtc, DESR, mode->htotal - mode->hsync_start);
  103. rcar_du_crtc_write(rcrtc, DEWR, mode->hdisplay);
  104. }
  105. void rcar_du_crtc_route_output(struct drm_crtc *crtc,
  106. enum rcar_du_output output)
  107. {
  108. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  109. struct rcar_du_device *rcdu = rcrtc->group->dev;
  110. /* Store the route from the CRTC output to the DU output. The DU will be
  111. * configured when starting the CRTC.
  112. */
  113. rcrtc->outputs |= BIT(output);
  114. }
  115. void rcar_du_crtc_update_planes(struct drm_crtc *crtc)
  116. {
  117. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  118. struct rcar_du_plane *planes[RCAR_DU_NUM_HW_PLANES];
  119. unsigned int num_planes = 0;
  120. unsigned int prio = 0;
  121. unsigned int i;
  122. u32 dptsr = 0;
  123. u32 dspr = 0;
  124. for (i = 0; i < ARRAY_SIZE(rcrtc->group->planes.planes); ++i) {
  125. struct rcar_du_plane *plane = &rcrtc->group->planes.planes[i];
  126. unsigned int j;
  127. if (plane->crtc != &rcrtc->crtc || !plane->enabled)
  128. continue;
  129. /* Insert the plane in the sorted planes array. */
  130. for (j = num_planes++; j > 0; --j) {
  131. if (planes[j-1]->zpos <= plane->zpos)
  132. break;
  133. planes[j] = planes[j-1];
  134. }
  135. planes[j] = plane;
  136. prio += plane->format->planes * 4;
  137. }
  138. for (i = 0; i < num_planes; ++i) {
  139. struct rcar_du_plane *plane = planes[i];
  140. unsigned int index = plane->hwindex;
  141. prio -= 4;
  142. dspr |= (index + 1) << prio;
  143. dptsr |= DPTSR_PnDK(index) | DPTSR_PnTS(index);
  144. if (plane->format->planes == 2) {
  145. index = (index + 1) % 8;
  146. prio -= 4;
  147. dspr |= (index + 1) << prio;
  148. dptsr |= DPTSR_PnDK(index) | DPTSR_PnTS(index);
  149. }
  150. }
  151. /* Select display timing and dot clock generator 2 for planes associated
  152. * with superposition controller 2.
  153. */
  154. if (rcrtc->index % 2) {
  155. u32 value = rcar_du_group_read(rcrtc->group, DPTSR);
  156. /* The DPTSR register is updated when the display controller is
  157. * stopped. We thus need to restart the DU. Once again, sorry
  158. * for the flicker. One way to mitigate the issue would be to
  159. * pre-associate planes with CRTCs (either with a fixed 4/4
  160. * split, or through a module parameter). Flicker would then
  161. * occur only if we need to break the pre-association.
  162. */
  163. if (value != dptsr) {
  164. rcar_du_group_write(rcrtc->group, DPTSR, dptsr);
  165. if (rcrtc->group->used_crtcs)
  166. rcar_du_group_restart(rcrtc->group);
  167. }
  168. }
  169. rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR,
  170. dspr);
  171. }
  172. static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc)
  173. {
  174. struct drm_crtc *crtc = &rcrtc->crtc;
  175. unsigned int i;
  176. if (rcrtc->started)
  177. return;
  178. if (WARN_ON(rcrtc->plane->format == NULL))
  179. return;
  180. /* Set display off and background to black */
  181. rcar_du_crtc_write(rcrtc, DOOR, DOOR_RGB(0, 0, 0));
  182. rcar_du_crtc_write(rcrtc, BPOR, BPOR_RGB(0, 0, 0));
  183. /* Configure display timings and output routing */
  184. rcar_du_crtc_set_display_timing(rcrtc);
  185. rcar_du_group_set_routing(rcrtc->group);
  186. mutex_lock(&rcrtc->group->planes.lock);
  187. rcrtc->plane->enabled = true;
  188. rcar_du_crtc_update_planes(crtc);
  189. mutex_unlock(&rcrtc->group->planes.lock);
  190. /* Setup planes. */
  191. for (i = 0; i < ARRAY_SIZE(rcrtc->group->planes.planes); ++i) {
  192. struct rcar_du_plane *plane = &rcrtc->group->planes.planes[i];
  193. if (plane->crtc != crtc || !plane->enabled)
  194. continue;
  195. rcar_du_plane_setup(plane);
  196. }
  197. /* Select master sync mode. This enables display operation in master
  198. * sync mode (with the HSYNC and VSYNC signals configured as outputs and
  199. * actively driven).
  200. */
  201. rcar_du_crtc_clr_set(rcrtc, DSYSR, DSYSR_TVM_MASK, DSYSR_TVM_MASTER);
  202. rcar_du_group_start_stop(rcrtc->group, true);
  203. rcrtc->started = true;
  204. }
  205. static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)
  206. {
  207. struct drm_crtc *crtc = &rcrtc->crtc;
  208. if (!rcrtc->started)
  209. return;
  210. mutex_lock(&rcrtc->group->planes.lock);
  211. rcrtc->plane->enabled = false;
  212. rcar_du_crtc_update_planes(crtc);
  213. mutex_unlock(&rcrtc->group->planes.lock);
  214. /* Select switch sync mode. This stops display operation and configures
  215. * the HSYNC and VSYNC signals as inputs.
  216. */
  217. rcar_du_crtc_clr_set(rcrtc, DSYSR, DSYSR_TVM_MASK, DSYSR_TVM_SWITCH);
  218. rcar_du_group_start_stop(rcrtc->group, false);
  219. rcrtc->started = false;
  220. }
  221. void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc)
  222. {
  223. rcar_du_crtc_stop(rcrtc);
  224. rcar_du_crtc_put(rcrtc);
  225. }
  226. void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc)
  227. {
  228. if (rcrtc->dpms != DRM_MODE_DPMS_ON)
  229. return;
  230. rcar_du_crtc_get(rcrtc);
  231. rcar_du_crtc_start(rcrtc);
  232. }
  233. static void rcar_du_crtc_update_base(struct rcar_du_crtc *rcrtc)
  234. {
  235. struct drm_crtc *crtc = &rcrtc->crtc;
  236. rcar_du_plane_compute_base(rcrtc->plane, crtc->fb);
  237. rcar_du_plane_update_base(rcrtc->plane);
  238. }
  239. static void rcar_du_crtc_dpms(struct drm_crtc *crtc, int mode)
  240. {
  241. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  242. if (rcrtc->dpms == mode)
  243. return;
  244. if (mode == DRM_MODE_DPMS_ON) {
  245. rcar_du_crtc_get(rcrtc);
  246. rcar_du_crtc_start(rcrtc);
  247. } else {
  248. rcar_du_crtc_stop(rcrtc);
  249. rcar_du_crtc_put(rcrtc);
  250. }
  251. rcrtc->dpms = mode;
  252. }
  253. static bool rcar_du_crtc_mode_fixup(struct drm_crtc *crtc,
  254. const struct drm_display_mode *mode,
  255. struct drm_display_mode *adjusted_mode)
  256. {
  257. /* TODO Fixup modes */
  258. return true;
  259. }
  260. static void rcar_du_crtc_mode_prepare(struct drm_crtc *crtc)
  261. {
  262. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  263. /* We need to access the hardware during mode set, acquire a reference
  264. * to the CRTC.
  265. */
  266. rcar_du_crtc_get(rcrtc);
  267. /* Stop the CRTC and release the plane. Force the DPMS mode to off as a
  268. * result.
  269. */
  270. rcar_du_crtc_stop(rcrtc);
  271. rcar_du_plane_release(rcrtc->plane);
  272. rcrtc->dpms = DRM_MODE_DPMS_OFF;
  273. }
  274. static int rcar_du_crtc_mode_set(struct drm_crtc *crtc,
  275. struct drm_display_mode *mode,
  276. struct drm_display_mode *adjusted_mode,
  277. int x, int y,
  278. struct drm_framebuffer *old_fb)
  279. {
  280. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  281. struct rcar_du_device *rcdu = rcrtc->group->dev;
  282. const struct rcar_du_format_info *format;
  283. int ret;
  284. format = rcar_du_format_info(crtc->fb->pixel_format);
  285. if (format == NULL) {
  286. dev_dbg(rcdu->dev, "mode_set: unsupported format %08x\n",
  287. crtc->fb->pixel_format);
  288. ret = -EINVAL;
  289. goto error;
  290. }
  291. ret = rcar_du_plane_reserve(rcrtc->plane, format);
  292. if (ret < 0)
  293. goto error;
  294. rcrtc->plane->format = format;
  295. rcrtc->plane->pitch = crtc->fb->pitches[0];
  296. rcrtc->plane->src_x = x;
  297. rcrtc->plane->src_y = y;
  298. rcrtc->plane->width = mode->hdisplay;
  299. rcrtc->plane->height = mode->vdisplay;
  300. rcar_du_plane_compute_base(rcrtc->plane, crtc->fb);
  301. rcrtc->outputs = 0;
  302. return 0;
  303. error:
  304. /* There's no rollback/abort operation to clean up in case of error. We
  305. * thus need to release the reference to the CRTC acquired in prepare()
  306. * here.
  307. */
  308. rcar_du_crtc_put(rcrtc);
  309. return ret;
  310. }
  311. static void rcar_du_crtc_mode_commit(struct drm_crtc *crtc)
  312. {
  313. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  314. /* We're done, restart the CRTC and set the DPMS mode to on. The
  315. * reference to the DU acquired at prepare() time will thus be released
  316. * by the DPMS handler (possibly called by the disable() handler).
  317. */
  318. rcar_du_crtc_start(rcrtc);
  319. rcrtc->dpms = DRM_MODE_DPMS_ON;
  320. }
  321. static int rcar_du_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
  322. struct drm_framebuffer *old_fb)
  323. {
  324. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  325. rcrtc->plane->src_x = x;
  326. rcrtc->plane->src_y = y;
  327. rcar_du_crtc_update_base(to_rcar_crtc(crtc));
  328. return 0;
  329. }
  330. static void rcar_du_crtc_disable(struct drm_crtc *crtc)
  331. {
  332. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  333. rcar_du_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
  334. rcar_du_plane_release(rcrtc->plane);
  335. }
  336. static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
  337. .dpms = rcar_du_crtc_dpms,
  338. .mode_fixup = rcar_du_crtc_mode_fixup,
  339. .prepare = rcar_du_crtc_mode_prepare,
  340. .commit = rcar_du_crtc_mode_commit,
  341. .mode_set = rcar_du_crtc_mode_set,
  342. .mode_set_base = rcar_du_crtc_mode_set_base,
  343. .disable = rcar_du_crtc_disable,
  344. };
  345. void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc,
  346. struct drm_file *file)
  347. {
  348. struct drm_pending_vblank_event *event;
  349. struct drm_device *dev = rcrtc->crtc.dev;
  350. unsigned long flags;
  351. /* Destroy the pending vertical blanking event associated with the
  352. * pending page flip, if any, and disable vertical blanking interrupts.
  353. */
  354. spin_lock_irqsave(&dev->event_lock, flags);
  355. event = rcrtc->event;
  356. if (event && event->base.file_priv == file) {
  357. rcrtc->event = NULL;
  358. event->base.destroy(&event->base);
  359. drm_vblank_put(dev, rcrtc->index);
  360. }
  361. spin_unlock_irqrestore(&dev->event_lock, flags);
  362. }
  363. static void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc)
  364. {
  365. struct drm_pending_vblank_event *event;
  366. struct drm_device *dev = rcrtc->crtc.dev;
  367. unsigned long flags;
  368. spin_lock_irqsave(&dev->event_lock, flags);
  369. event = rcrtc->event;
  370. rcrtc->event = NULL;
  371. spin_unlock_irqrestore(&dev->event_lock, flags);
  372. if (event == NULL)
  373. return;
  374. spin_lock_irqsave(&dev->event_lock, flags);
  375. drm_send_vblank_event(dev, rcrtc->index, event);
  376. spin_unlock_irqrestore(&dev->event_lock, flags);
  377. drm_vblank_put(dev, rcrtc->index);
  378. }
  379. static irqreturn_t rcar_du_crtc_irq(int irq, void *arg)
  380. {
  381. struct rcar_du_crtc *rcrtc = arg;
  382. irqreturn_t ret = IRQ_NONE;
  383. u32 status;
  384. status = rcar_du_crtc_read(rcrtc, DSSR);
  385. rcar_du_crtc_write(rcrtc, DSRCR, status & DSRCR_MASK);
  386. if (status & DSSR_VBK) {
  387. drm_handle_vblank(rcrtc->crtc.dev, rcrtc->index);
  388. rcar_du_crtc_finish_page_flip(rcrtc);
  389. ret = IRQ_HANDLED;
  390. }
  391. return ret;
  392. }
  393. static int rcar_du_crtc_page_flip(struct drm_crtc *crtc,
  394. struct drm_framebuffer *fb,
  395. struct drm_pending_vblank_event *event)
  396. {
  397. struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
  398. struct drm_device *dev = rcrtc->crtc.dev;
  399. unsigned long flags;
  400. spin_lock_irqsave(&dev->event_lock, flags);
  401. if (rcrtc->event != NULL) {
  402. spin_unlock_irqrestore(&dev->event_lock, flags);
  403. return -EBUSY;
  404. }
  405. spin_unlock_irqrestore(&dev->event_lock, flags);
  406. crtc->fb = fb;
  407. rcar_du_crtc_update_base(rcrtc);
  408. if (event) {
  409. event->pipe = rcrtc->index;
  410. drm_vblank_get(dev, rcrtc->index);
  411. spin_lock_irqsave(&dev->event_lock, flags);
  412. rcrtc->event = event;
  413. spin_unlock_irqrestore(&dev->event_lock, flags);
  414. }
  415. return 0;
  416. }
  417. static const struct drm_crtc_funcs crtc_funcs = {
  418. .destroy = drm_crtc_cleanup,
  419. .set_config = drm_crtc_helper_set_config,
  420. .page_flip = rcar_du_crtc_page_flip,
  421. };
  422. int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index)
  423. {
  424. static const unsigned int mmio_offsets[] = {
  425. DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET
  426. };
  427. struct rcar_du_device *rcdu = rgrp->dev;
  428. struct platform_device *pdev = to_platform_device(rcdu->dev);
  429. struct rcar_du_crtc *rcrtc = &rcdu->crtcs[index];
  430. struct drm_crtc *crtc = &rcrtc->crtc;
  431. unsigned int irqflags;
  432. char clk_name[5];
  433. char *name;
  434. int irq;
  435. int ret;
  436. /* Get the CRTC clock. */
  437. if (rcar_du_has(rcdu, RCAR_DU_FEATURE_CRTC_IRQ_CLOCK)) {
  438. sprintf(clk_name, "du.%u", index);
  439. name = clk_name;
  440. } else {
  441. name = NULL;
  442. }
  443. rcrtc->clock = devm_clk_get(rcdu->dev, name);
  444. if (IS_ERR(rcrtc->clock)) {
  445. dev_err(rcdu->dev, "no clock for CRTC %u\n", index);
  446. return PTR_ERR(rcrtc->clock);
  447. }
  448. rcrtc->group = rgrp;
  449. rcrtc->mmio_offset = mmio_offsets[index];
  450. rcrtc->index = index;
  451. rcrtc->dpms = DRM_MODE_DPMS_OFF;
  452. rcrtc->plane = &rgrp->planes.planes[index % 2];
  453. rcrtc->plane->crtc = crtc;
  454. ret = drm_crtc_init(rcdu->ddev, crtc, &crtc_funcs);
  455. if (ret < 0)
  456. return ret;
  457. drm_crtc_helper_add(crtc, &crtc_helper_funcs);
  458. /* Register the interrupt handler. */
  459. if (rcar_du_has(rcdu, RCAR_DU_FEATURE_CRTC_IRQ_CLOCK)) {
  460. irq = platform_get_irq(pdev, index);
  461. irqflags = 0;
  462. } else {
  463. irq = platform_get_irq(pdev, 0);
  464. irqflags = IRQF_SHARED;
  465. }
  466. if (irq < 0) {
  467. dev_err(rcdu->dev, "no IRQ for CRTC %u\n", index);
  468. return ret;
  469. }
  470. ret = devm_request_irq(rcdu->dev, irq, rcar_du_crtc_irq, irqflags,
  471. dev_name(rcdu->dev), rcrtc);
  472. if (ret < 0) {
  473. dev_err(rcdu->dev,
  474. "failed to register IRQ for CRTC %u\n", index);
  475. return ret;
  476. }
  477. return 0;
  478. }
  479. void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable)
  480. {
  481. if (enable) {
  482. rcar_du_crtc_write(rcrtc, DSRCR, DSRCR_VBCL);
  483. rcar_du_crtc_set(rcrtc, DIER, DIER_VBE);
  484. } else {
  485. rcar_du_crtc_clr(rcrtc, DIER, DIER_VBE);
  486. }
  487. }