armada_crtc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 *,
  33. struct armada_plane *,
  34. struct armada_plane_work *);
  35. };
  36. struct armada_plane_state {
  37. u32 src_hw;
  38. u32 dst_hw;
  39. u32 dst_yx;
  40. u32 ctrl0;
  41. };
  42. struct armada_plane {
  43. struct drm_plane base;
  44. wait_queue_head_t frame_wait;
  45. struct armada_plane_work *work;
  46. struct armada_plane_state state;
  47. };
  48. #define drm_to_armada_plane(p) container_of(p, struct armada_plane, base)
  49. int armada_drm_plane_init(struct armada_plane *plane);
  50. int armada_drm_plane_work_queue(struct armada_crtc *dcrtc,
  51. struct armada_plane *plane, struct armada_plane_work *work);
  52. int armada_drm_plane_work_wait(struct armada_plane *plane, long timeout);
  53. struct armada_plane_work *armada_drm_plane_work_cancel(
  54. struct armada_crtc *dcrtc, struct armada_plane *plane);
  55. void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb,
  56. int x, int y);
  57. struct armada_crtc {
  58. struct drm_crtc crtc;
  59. const struct armada_variant *variant;
  60. unsigned num;
  61. void __iomem *base;
  62. struct clk *clk;
  63. struct clk *extclk[2];
  64. struct {
  65. uint32_t spu_v_h_total;
  66. uint32_t spu_v_porch;
  67. uint32_t spu_adv_reg;
  68. } v[2];
  69. bool interlaced;
  70. bool cursor_update;
  71. uint8_t csc_yuv_mode;
  72. uint8_t csc_rgb_mode;
  73. struct drm_plane *plane;
  74. struct armada_gem_object *cursor_obj;
  75. int cursor_x;
  76. int cursor_y;
  77. uint32_t cursor_hw_pos;
  78. uint32_t cursor_hw_sz;
  79. uint32_t cursor_w;
  80. uint32_t cursor_h;
  81. int dpms;
  82. uint32_t cfg_dumb_ctrl;
  83. uint32_t dumb_ctrl;
  84. uint32_t spu_iopad_ctrl;
  85. spinlock_t irq_lock;
  86. uint32_t irq_ena;
  87. };
  88. #define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc)
  89. void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
  90. void armada_drm_crtc_plane_disable(struct armada_crtc *dcrtc,
  91. struct drm_plane *plane);
  92. extern struct platform_driver armada_lcd_platform_driver;
  93. #endif