armada_crtc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2012 Russell King
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef ARMADA_CRTC_H
  9. #define ARMADA_CRTC_H
  10. struct armada_gem_object;
  11. struct armada_regs {
  12. uint32_t offset;
  13. uint32_t mask;
  14. uint32_t val;
  15. };
  16. #define armada_reg_queue_mod(_r, _i, _v, _m, _o) \
  17. do { \
  18. struct armada_regs *__reg = _r; \
  19. __reg[_i].offset = _o; \
  20. __reg[_i].mask = ~(_m); \
  21. __reg[_i].val = _v; \
  22. _i++; \
  23. } while (0)
  24. #define armada_reg_queue_set(_r, _i, _v, _o) \
  25. armada_reg_queue_mod(_r, _i, _v, ~0, _o)
  26. #define armada_reg_queue_end(_r, _i) \
  27. armada_reg_queue_mod(_r, _i, 0, 0, ~0)
  28. struct armada_crtc;
  29. struct armada_plane;
  30. struct armada_variant;
  31. struct armada_plane_work {
  32. void (*fn)(struct armada_crtc *, struct armada_plane_work *);
  33. void (*cancel)(struct armada_crtc *, struct armada_plane_work *);
  34. bool need_kfree;
  35. struct drm_plane *plane;
  36. struct drm_framebuffer *old_fb;
  37. struct drm_pending_vblank_event *event;
  38. struct armada_regs regs[14];
  39. };
  40. struct armada_plane_state {
  41. u16 src_x;
  42. u16 src_y;
  43. u32 src_hw;
  44. u32 dst_hw;
  45. u32 dst_yx;
  46. u32 ctrl0;
  47. bool changed;
  48. bool vsync_update;
  49. };
  50. struct armada_plane {
  51. struct drm_plane base;
  52. wait_queue_head_t frame_wait;
  53. bool next_work;
  54. struct armada_plane_work works[2];
  55. struct armada_plane_work *work;
  56. struct armada_plane_state state;
  57. };
  58. #define drm_to_armada_plane(p) container_of(p, struct armada_plane, base)
  59. int armada_drm_plane_init(struct armada_plane *plane);
  60. int armada_drm_plane_work_queue(struct armada_crtc *dcrtc,
  61. struct armada_plane_work *work);
  62. int armada_drm_plane_work_wait(struct armada_plane *plane, long timeout);
  63. void armada_drm_plane_work_cancel(struct armada_crtc *dcrtc,
  64. struct armada_plane *plane);
  65. void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb,
  66. int x, int y);
  67. struct armada_crtc {
  68. struct drm_crtc crtc;
  69. const struct armada_variant *variant;
  70. unsigned num;
  71. void __iomem *base;
  72. struct clk *clk;
  73. struct clk *extclk[2];
  74. struct {
  75. uint32_t spu_v_h_total;
  76. uint32_t spu_v_porch;
  77. uint32_t spu_adv_reg;
  78. } v[2];
  79. bool interlaced;
  80. bool cursor_update;
  81. uint8_t csc_yuv_mode;
  82. uint8_t csc_rgb_mode;
  83. struct drm_plane *plane;
  84. struct armada_gem_object *cursor_obj;
  85. int cursor_x;
  86. int cursor_y;
  87. uint32_t cursor_hw_pos;
  88. uint32_t cursor_hw_sz;
  89. uint32_t cursor_w;
  90. uint32_t cursor_h;
  91. int dpms;
  92. uint32_t cfg_dumb_ctrl;
  93. uint32_t dumb_ctrl;
  94. uint32_t spu_iopad_ctrl;
  95. spinlock_t irq_lock;
  96. uint32_t irq_ena;
  97. };
  98. #define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc)
  99. void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
  100. int armada_drm_plane_disable(struct drm_plane *plane,
  101. struct drm_modeset_acquire_ctx *ctx);
  102. extern struct platform_driver armada_lcd_platform_driver;
  103. #endif