omap_crtc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. * drivers/gpu/drm/omapdrm/omap_crtc.c
  3. *
  4. * Copyright (C) 2011 Texas Instruments
  5. * Author: Rob Clark <rob@ti.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <linux/completion.h>
  20. #include <drm/drm_atomic.h>
  21. #include <drm/drm_atomic_helper.h>
  22. #include <drm/drm_crtc.h>
  23. #include <drm/drm_crtc_helper.h>
  24. #include <drm/drm_mode.h>
  25. #include <drm/drm_plane_helper.h>
  26. #include "omap_drv.h"
  27. #define to_omap_crtc(x) container_of(x, struct omap_crtc, base)
  28. struct omap_crtc {
  29. struct drm_crtc base;
  30. const char *name;
  31. enum omap_channel channel;
  32. struct drm_encoder *current_encoder;
  33. /*
  34. * Temporary: eventually this will go away, but it is needed
  35. * for now to keep the output's happy. (They only need
  36. * mgr->id.) Eventually this will be replaced w/ something
  37. * more common-panel-framework-y
  38. */
  39. struct omap_overlay_manager *mgr;
  40. struct omap_video_timings timings;
  41. struct omap_drm_irq vblank_irq;
  42. struct omap_drm_irq error_irq;
  43. /* pending event */
  44. struct drm_pending_vblank_event *event;
  45. wait_queue_head_t flip_wait;
  46. struct completion completion;
  47. bool ignore_digit_sync_lost;
  48. };
  49. /* -----------------------------------------------------------------------------
  50. * Helper Functions
  51. */
  52. uint32_t pipe2vbl(struct drm_crtc *crtc)
  53. {
  54. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  55. return dispc_mgr_get_vsync_irq(omap_crtc->channel);
  56. }
  57. const struct omap_video_timings *omap_crtc_timings(struct drm_crtc *crtc)
  58. {
  59. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  60. return &omap_crtc->timings;
  61. }
  62. enum omap_channel omap_crtc_channel(struct drm_crtc *crtc)
  63. {
  64. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  65. return omap_crtc->channel;
  66. }
  67. /* -----------------------------------------------------------------------------
  68. * DSS Manager Functions
  69. */
  70. /*
  71. * Manager-ops, callbacks from output when they need to configure
  72. * the upstream part of the video pipe.
  73. *
  74. * Most of these we can ignore until we add support for command-mode
  75. * panels.. for video-mode the crtc-helpers already do an adequate
  76. * job of sequencing the setup of the video pipe in the proper order
  77. */
  78. /* ovl-mgr-id -> crtc */
  79. static struct omap_crtc *omap_crtcs[8];
  80. /* we can probably ignore these until we support command-mode panels: */
  81. static int omap_crtc_dss_connect(struct omap_overlay_manager *mgr,
  82. struct omap_dss_device *dst)
  83. {
  84. if (mgr->output)
  85. return -EINVAL;
  86. if ((mgr->supported_outputs & dst->id) == 0)
  87. return -EINVAL;
  88. dst->manager = mgr;
  89. mgr->output = dst;
  90. return 0;
  91. }
  92. static void omap_crtc_dss_disconnect(struct omap_overlay_manager *mgr,
  93. struct omap_dss_device *dst)
  94. {
  95. mgr->output->manager = NULL;
  96. mgr->output = NULL;
  97. }
  98. static void omap_crtc_dss_start_update(struct omap_overlay_manager *mgr)
  99. {
  100. }
  101. /* Called only from omap_crtc_encoder_setup and suspend/resume handlers. */
  102. static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
  103. {
  104. struct drm_device *dev = crtc->dev;
  105. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  106. enum omap_channel channel = omap_crtc->channel;
  107. struct omap_irq_wait *wait;
  108. u32 framedone_irq, vsync_irq;
  109. int ret;
  110. if (dispc_mgr_is_enabled(channel) == enable)
  111. return;
  112. if (omap_crtc->channel == OMAP_DSS_CHANNEL_DIGIT) {
  113. /*
  114. * Digit output produces some sync lost interrupts during the
  115. * first frame when enabling, so we need to ignore those.
  116. */
  117. omap_crtc->ignore_digit_sync_lost = true;
  118. }
  119. framedone_irq = dispc_mgr_get_framedone_irq(channel);
  120. vsync_irq = dispc_mgr_get_vsync_irq(channel);
  121. if (enable) {
  122. wait = omap_irq_wait_init(dev, vsync_irq, 1);
  123. } else {
  124. /*
  125. * When we disable the digit output, we need to wait for
  126. * FRAMEDONE to know that DISPC has finished with the output.
  127. *
  128. * OMAP2/3 does not have FRAMEDONE irq for digit output, and in
  129. * that case we need to use vsync interrupt, and wait for both
  130. * even and odd frames.
  131. */
  132. if (framedone_irq)
  133. wait = omap_irq_wait_init(dev, framedone_irq, 1);
  134. else
  135. wait = omap_irq_wait_init(dev, vsync_irq, 2);
  136. }
  137. dispc_mgr_enable(channel, enable);
  138. ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100));
  139. if (ret) {
  140. dev_err(dev->dev, "%s: timeout waiting for %s\n",
  141. omap_crtc->name, enable ? "enable" : "disable");
  142. }
  143. if (omap_crtc->channel == OMAP_DSS_CHANNEL_DIGIT) {
  144. omap_crtc->ignore_digit_sync_lost = false;
  145. /* make sure the irq handler sees the value above */
  146. mb();
  147. }
  148. }
  149. static int omap_crtc_dss_enable(struct omap_overlay_manager *mgr)
  150. {
  151. struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
  152. struct omap_overlay_manager_info info;
  153. memset(&info, 0, sizeof(info));
  154. info.default_color = 0x00000000;
  155. info.trans_key = 0x00000000;
  156. info.trans_key_type = OMAP_DSS_COLOR_KEY_GFX_DST;
  157. info.trans_enabled = false;
  158. dispc_mgr_setup(omap_crtc->channel, &info);
  159. dispc_mgr_set_timings(omap_crtc->channel,
  160. &omap_crtc->timings);
  161. omap_crtc_set_enabled(&omap_crtc->base, true);
  162. return 0;
  163. }
  164. static void omap_crtc_dss_disable(struct omap_overlay_manager *mgr)
  165. {
  166. struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
  167. omap_crtc_set_enabled(&omap_crtc->base, false);
  168. }
  169. static void omap_crtc_dss_set_timings(struct omap_overlay_manager *mgr,
  170. const struct omap_video_timings *timings)
  171. {
  172. struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
  173. DBG("%s", omap_crtc->name);
  174. omap_crtc->timings = *timings;
  175. }
  176. static void omap_crtc_dss_set_lcd_config(struct omap_overlay_manager *mgr,
  177. const struct dss_lcd_mgr_config *config)
  178. {
  179. struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
  180. DBG("%s", omap_crtc->name);
  181. dispc_mgr_set_lcd_config(omap_crtc->channel, config);
  182. }
  183. static int omap_crtc_dss_register_framedone(
  184. struct omap_overlay_manager *mgr,
  185. void (*handler)(void *), void *data)
  186. {
  187. return 0;
  188. }
  189. static void omap_crtc_dss_unregister_framedone(
  190. struct omap_overlay_manager *mgr,
  191. void (*handler)(void *), void *data)
  192. {
  193. }
  194. static const struct dss_mgr_ops mgr_ops = {
  195. .connect = omap_crtc_dss_connect,
  196. .disconnect = omap_crtc_dss_disconnect,
  197. .start_update = omap_crtc_dss_start_update,
  198. .enable = omap_crtc_dss_enable,
  199. .disable = omap_crtc_dss_disable,
  200. .set_timings = omap_crtc_dss_set_timings,
  201. .set_lcd_config = omap_crtc_dss_set_lcd_config,
  202. .register_framedone_handler = omap_crtc_dss_register_framedone,
  203. .unregister_framedone_handler = omap_crtc_dss_unregister_framedone,
  204. };
  205. /* -----------------------------------------------------------------------------
  206. * Setup, Flush and Page Flip
  207. */
  208. void omap_crtc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file)
  209. {
  210. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  211. struct drm_pending_vblank_event *event;
  212. struct drm_device *dev = crtc->dev;
  213. unsigned long flags;
  214. /* Destroy the pending vertical blanking event associated with the
  215. * pending page flip, if any, and disable vertical blanking interrupts.
  216. */
  217. spin_lock_irqsave(&dev->event_lock, flags);
  218. event = omap_crtc->event;
  219. omap_crtc->event = NULL;
  220. if (event && event->base.file_priv == file) {
  221. event->base.destroy(&event->base);
  222. drm_crtc_vblank_put(crtc);
  223. }
  224. spin_unlock_irqrestore(&dev->event_lock, flags);
  225. }
  226. static void omap_crtc_complete_page_flip(struct drm_crtc *crtc)
  227. {
  228. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  229. struct drm_pending_vblank_event *event;
  230. struct drm_device *dev = crtc->dev;
  231. unsigned long flags;
  232. spin_lock_irqsave(&dev->event_lock, flags);
  233. event = omap_crtc->event;
  234. omap_crtc->event = NULL;
  235. if (event) {
  236. drm_crtc_send_vblank_event(crtc, event);
  237. wake_up(&omap_crtc->flip_wait);
  238. drm_crtc_vblank_put(crtc);
  239. }
  240. spin_unlock_irqrestore(&dev->event_lock, flags);
  241. }
  242. static bool omap_crtc_page_flip_pending(struct drm_crtc *crtc)
  243. {
  244. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  245. struct drm_device *dev = crtc->dev;
  246. unsigned long flags;
  247. bool pending;
  248. spin_lock_irqsave(&dev->event_lock, flags);
  249. pending = omap_crtc->event != NULL;
  250. spin_unlock_irqrestore(&dev->event_lock, flags);
  251. return pending;
  252. }
  253. static void omap_crtc_wait_page_flip(struct drm_crtc *crtc)
  254. {
  255. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  256. if (wait_event_timeout(omap_crtc->flip_wait,
  257. !omap_crtc_page_flip_pending(crtc),
  258. msecs_to_jiffies(50)))
  259. return;
  260. dev_warn(crtc->dev->dev, "page flip timeout!\n");
  261. omap_crtc_complete_page_flip(crtc);
  262. }
  263. static void omap_crtc_error_irq(struct omap_drm_irq *irq, uint32_t irqstatus)
  264. {
  265. struct omap_crtc *omap_crtc =
  266. container_of(irq, struct omap_crtc, error_irq);
  267. if (omap_crtc->ignore_digit_sync_lost) {
  268. irqstatus &= ~DISPC_IRQ_SYNC_LOST_DIGIT;
  269. if (!irqstatus)
  270. return;
  271. }
  272. DRM_ERROR_RATELIMITED("%s: errors: %08x\n", omap_crtc->name, irqstatus);
  273. }
  274. static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus)
  275. {
  276. struct omap_crtc *omap_crtc =
  277. container_of(irq, struct omap_crtc, vblank_irq);
  278. struct drm_device *dev = omap_crtc->base.dev;
  279. if (dispc_mgr_go_busy(omap_crtc->channel))
  280. return;
  281. DBG("%s: apply done", omap_crtc->name);
  282. __omap_irq_unregister(dev, &omap_crtc->vblank_irq);
  283. /* wakeup userspace */
  284. omap_crtc_complete_page_flip(&omap_crtc->base);
  285. complete(&omap_crtc->completion);
  286. }
  287. int omap_crtc_flush(struct drm_crtc *crtc)
  288. {
  289. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  290. DBG("%s: GO", omap_crtc->name);
  291. WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
  292. WARN_ON(omap_crtc->vblank_irq.registered);
  293. dispc_runtime_get();
  294. if (dispc_mgr_is_enabled(omap_crtc->channel)) {
  295. dispc_mgr_go(omap_crtc->channel);
  296. omap_irq_register(crtc->dev, &omap_crtc->vblank_irq);
  297. WARN_ON(!wait_for_completion_timeout(&omap_crtc->completion,
  298. msecs_to_jiffies(100)));
  299. reinit_completion(&omap_crtc->completion);
  300. }
  301. dispc_runtime_put();
  302. return 0;
  303. }
  304. static void omap_crtc_encoder_setup(struct drm_crtc *crtc, bool enable)
  305. {
  306. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  307. struct omap_drm_private *priv = crtc->dev->dev_private;
  308. struct drm_encoder *encoder = NULL;
  309. unsigned int i;
  310. DBG("%s: enable=%d", omap_crtc->name, enable);
  311. dispc_runtime_get();
  312. for (i = 0; i < priv->num_encoders; i++) {
  313. if (priv->encoders[i]->crtc == crtc) {
  314. encoder = priv->encoders[i];
  315. break;
  316. }
  317. }
  318. if (omap_crtc->current_encoder && encoder != omap_crtc->current_encoder)
  319. omap_encoder_set_enabled(omap_crtc->current_encoder, false);
  320. omap_crtc->current_encoder = encoder;
  321. if (encoder) {
  322. omap_encoder_set_enabled(encoder, false);
  323. if (enable) {
  324. omap_encoder_update(encoder, omap_crtc->mgr,
  325. &omap_crtc->timings);
  326. omap_encoder_set_enabled(encoder, true);
  327. }
  328. }
  329. dispc_runtime_put();
  330. }
  331. /* -----------------------------------------------------------------------------
  332. * CRTC Functions
  333. */
  334. static void omap_crtc_destroy(struct drm_crtc *crtc)
  335. {
  336. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  337. DBG("%s", omap_crtc->name);
  338. WARN_ON(omap_crtc->vblank_irq.registered);
  339. omap_irq_unregister(crtc->dev, &omap_crtc->error_irq);
  340. drm_crtc_cleanup(crtc);
  341. kfree(omap_crtc);
  342. }
  343. static bool omap_crtc_mode_fixup(struct drm_crtc *crtc,
  344. const struct drm_display_mode *mode,
  345. struct drm_display_mode *adjusted_mode)
  346. {
  347. return true;
  348. }
  349. static void omap_crtc_enable(struct drm_crtc *crtc)
  350. {
  351. struct omap_drm_private *priv = crtc->dev->dev_private;
  352. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  353. unsigned int i;
  354. DBG("%s", omap_crtc->name);
  355. dispc_runtime_get();
  356. /* Enable all planes associated with the CRTC. */
  357. for (i = 0; i < priv->num_planes; i++) {
  358. struct drm_plane *plane = priv->planes[i];
  359. if (plane->crtc == crtc)
  360. WARN_ON(omap_plane_setup(plane));
  361. }
  362. omap_crtc_encoder_setup(crtc, true);
  363. omap_crtc_flush(crtc);
  364. drm_crtc_vblank_on(crtc);
  365. dispc_runtime_put();
  366. }
  367. static void omap_crtc_disable(struct drm_crtc *crtc)
  368. {
  369. struct omap_drm_private *priv = crtc->dev->dev_private;
  370. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  371. unsigned int i;
  372. DBG("%s", omap_crtc->name);
  373. omap_crtc_wait_page_flip(crtc);
  374. dispc_runtime_get();
  375. drm_crtc_vblank_off(crtc);
  376. /* Disable all planes associated with the CRTC. */
  377. for (i = 0; i < priv->num_planes; i++) {
  378. struct drm_plane *plane = priv->planes[i];
  379. if (plane->crtc == crtc)
  380. WARN_ON(omap_plane_setup(plane));
  381. }
  382. omap_crtc_encoder_setup(crtc, false);
  383. omap_crtc_flush(crtc);
  384. dispc_runtime_put();
  385. }
  386. static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc)
  387. {
  388. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  389. struct drm_display_mode *mode = &crtc->state->adjusted_mode;
  390. DBG("%s: set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
  391. omap_crtc->name, mode->base.id, mode->name,
  392. mode->vrefresh, mode->clock,
  393. mode->hdisplay, mode->hsync_start, mode->hsync_end, mode->htotal,
  394. mode->vdisplay, mode->vsync_start, mode->vsync_end, mode->vtotal,
  395. mode->type, mode->flags);
  396. copy_timings_drm_to_omap(&omap_crtc->timings, mode);
  397. }
  398. static void omap_crtc_atomic_begin(struct drm_crtc *crtc)
  399. {
  400. struct drm_pending_vblank_event *event = crtc->state->event;
  401. struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
  402. struct drm_device *dev = crtc->dev;
  403. unsigned long flags;
  404. dispc_runtime_get();
  405. if (event) {
  406. WARN_ON(omap_crtc->event);
  407. WARN_ON(drm_crtc_vblank_get(crtc) != 0);
  408. spin_lock_irqsave(&dev->event_lock, flags);
  409. omap_crtc->event = event;
  410. spin_unlock_irqrestore(&dev->event_lock, flags);
  411. }
  412. }
  413. static void omap_crtc_atomic_flush(struct drm_crtc *crtc)
  414. {
  415. omap_crtc_flush(crtc);
  416. dispc_runtime_put();
  417. crtc->invert_dimensions = !!(crtc->primary->state->rotation &
  418. (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)));
  419. }
  420. static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
  421. struct drm_crtc_state *state,
  422. struct drm_property *property,
  423. uint64_t val)
  424. {
  425. struct drm_plane_state *plane_state;
  426. struct drm_plane *plane = crtc->primary;
  427. /*
  428. * Delegate property set to the primary plane. Get the plane state and
  429. * set the property directly.
  430. */
  431. plane_state = drm_atomic_get_plane_state(state->state, plane);
  432. if (!plane_state)
  433. return -EINVAL;
  434. return drm_atomic_plane_set_property(plane, plane_state, property, val);
  435. }
  436. static int omap_crtc_atomic_get_property(struct drm_crtc *crtc,
  437. const struct drm_crtc_state *state,
  438. struct drm_property *property,
  439. uint64_t *val)
  440. {
  441. /*
  442. * Delegate property get to the primary plane. The
  443. * drm_atomic_plane_get_property() function isn't exported, but can be
  444. * called through drm_object_property_get_value() as that will call
  445. * drm_atomic_get_property() for atomic drivers.
  446. */
  447. return drm_object_property_get_value(&crtc->primary->base, property,
  448. val);
  449. }
  450. static const struct drm_crtc_funcs omap_crtc_funcs = {
  451. .reset = drm_atomic_helper_crtc_reset,
  452. .set_config = drm_atomic_helper_set_config,
  453. .destroy = omap_crtc_destroy,
  454. .page_flip = drm_atomic_helper_page_flip,
  455. .set_property = drm_atomic_helper_crtc_set_property,
  456. .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
  457. .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
  458. .atomic_set_property = omap_crtc_atomic_set_property,
  459. .atomic_get_property = omap_crtc_atomic_get_property,
  460. };
  461. static const struct drm_crtc_helper_funcs omap_crtc_helper_funcs = {
  462. .mode_fixup = omap_crtc_mode_fixup,
  463. .mode_set_nofb = omap_crtc_mode_set_nofb,
  464. .disable = omap_crtc_disable,
  465. .enable = omap_crtc_enable,
  466. .atomic_begin = omap_crtc_atomic_begin,
  467. .atomic_flush = omap_crtc_atomic_flush,
  468. };
  469. /* -----------------------------------------------------------------------------
  470. * Init and Cleanup
  471. */
  472. static const char *channel_names[] = {
  473. [OMAP_DSS_CHANNEL_LCD] = "lcd",
  474. [OMAP_DSS_CHANNEL_DIGIT] = "tv",
  475. [OMAP_DSS_CHANNEL_LCD2] = "lcd2",
  476. [OMAP_DSS_CHANNEL_LCD3] = "lcd3",
  477. };
  478. void omap_crtc_pre_init(void)
  479. {
  480. dss_install_mgr_ops(&mgr_ops);
  481. }
  482. void omap_crtc_pre_uninit(void)
  483. {
  484. dss_uninstall_mgr_ops();
  485. }
  486. /* initialize crtc */
  487. struct drm_crtc *omap_crtc_init(struct drm_device *dev,
  488. struct drm_plane *plane, enum omap_channel channel, int id)
  489. {
  490. struct drm_crtc *crtc = NULL;
  491. struct omap_crtc *omap_crtc;
  492. int ret;
  493. DBG("%s", channel_names[channel]);
  494. omap_crtc = kzalloc(sizeof(*omap_crtc), GFP_KERNEL);
  495. if (!omap_crtc)
  496. return NULL;
  497. crtc = &omap_crtc->base;
  498. init_waitqueue_head(&omap_crtc->flip_wait);
  499. init_completion(&omap_crtc->completion);
  500. omap_crtc->channel = channel;
  501. omap_crtc->name = channel_names[channel];
  502. omap_crtc->vblank_irq.irqmask = pipe2vbl(crtc);
  503. omap_crtc->vblank_irq.irq = omap_crtc_vblank_irq;
  504. omap_crtc->error_irq.irqmask =
  505. dispc_mgr_get_sync_lost_irq(channel);
  506. omap_crtc->error_irq.irq = omap_crtc_error_irq;
  507. omap_irq_register(dev, &omap_crtc->error_irq);
  508. /* temporary: */
  509. omap_crtc->mgr = omap_dss_get_overlay_manager(channel);
  510. ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL,
  511. &omap_crtc_funcs);
  512. if (ret < 0) {
  513. kfree(omap_crtc);
  514. return NULL;
  515. }
  516. drm_crtc_helper_add(crtc, &omap_crtc_helper_funcs);
  517. omap_plane_install_properties(crtc->primary, &crtc->base);
  518. omap_crtcs[channel] = omap_crtc;
  519. return crtc;
  520. }