omap_crtc.c 17 KB

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