rcar_du_crtc.c 16 KB

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