rcar_du_crtc.c 15 KB

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