armada_crtc.h 2.7 KB

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