armada_drm.h 3.0 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_DRM_H
  9. #define ARMADA_DRM_H
  10. #include <linux/kfifo.h>
  11. #include <linux/io.h>
  12. #include <linux/workqueue.h>
  13. #include <drm/drmP.h>
  14. struct armada_crtc;
  15. struct armada_gem_object;
  16. struct clk;
  17. struct drm_fb_helper;
  18. static inline void
  19. armada_updatel(uint32_t val, uint32_t mask, void __iomem *ptr)
  20. {
  21. uint32_t ov, v;
  22. ov = v = readl_relaxed(ptr);
  23. v = (v & ~mask) | val;
  24. if (ov != v)
  25. writel_relaxed(v, ptr);
  26. }
  27. static inline uint32_t armada_pitch(uint32_t width, uint32_t bpp)
  28. {
  29. uint32_t pitch = bpp != 4 ? width * ((bpp + 7) / 8) : width / 2;
  30. /* 88AP510 spec recommends pitch be a multiple of 128 */
  31. return ALIGN(pitch, 128);
  32. }
  33. struct armada_vbl_event {
  34. struct list_head node;
  35. void *data;
  36. void (*fn)(struct armada_crtc *, void *);
  37. };
  38. void armada_drm_vbl_event_add(struct armada_crtc *,
  39. struct armada_vbl_event *);
  40. void armada_drm_vbl_event_remove(struct armada_crtc *,
  41. struct armada_vbl_event *);
  42. void armada_drm_vbl_event_remove_unlocked(struct armada_crtc *,
  43. struct armada_vbl_event *);
  44. #define armada_drm_vbl_event_init(_e, _f, _d) do { \
  45. struct armada_vbl_event *__e = _e; \
  46. INIT_LIST_HEAD(&__e->node); \
  47. __e->data = _d; \
  48. __e->fn = _f; \
  49. } while (0)
  50. struct armada_private;
  51. struct armada_variant {
  52. bool has_spu_adv_reg;
  53. uint32_t spu_adv_reg;
  54. int (*init)(struct armada_private *, struct device *);
  55. int (*crtc_init)(struct armada_crtc *);
  56. int (*crtc_compute_clock)(struct armada_crtc *,
  57. const struct drm_display_mode *,
  58. uint32_t *);
  59. };
  60. /* Variant ops */
  61. extern const struct armada_variant armada510_ops;
  62. struct armada_private {
  63. const struct armada_variant *variant;
  64. struct work_struct fb_unref_work;
  65. DECLARE_KFIFO(fb_unref, struct drm_framebuffer *, 8);
  66. struct drm_fb_helper *fbdev;
  67. struct armada_crtc *dcrtc[2];
  68. struct drm_mm linear;
  69. struct clk *extclk[2];
  70. struct drm_property *csc_yuv_prop;
  71. struct drm_property *csc_rgb_prop;
  72. struct drm_property *colorkey_prop;
  73. struct drm_property *colorkey_min_prop;
  74. struct drm_property *colorkey_max_prop;
  75. struct drm_property *colorkey_val_prop;
  76. struct drm_property *colorkey_alpha_prop;
  77. struct drm_property *colorkey_mode_prop;
  78. struct drm_property *brightness_prop;
  79. struct drm_property *contrast_prop;
  80. struct drm_property *saturation_prop;
  81. #ifdef CONFIG_DEBUG_FS
  82. struct dentry *de;
  83. #endif
  84. };
  85. void __armada_drm_queue_unref_work(struct drm_device *,
  86. struct drm_framebuffer *);
  87. void armada_drm_queue_unref_work(struct drm_device *,
  88. struct drm_framebuffer *);
  89. extern const struct drm_mode_config_funcs armada_drm_mode_config_funcs;
  90. int armada_fbdev_init(struct drm_device *);
  91. void armada_fbdev_fini(struct drm_device *);
  92. int armada_overlay_plane_create(struct drm_device *, unsigned long);
  93. int armada_drm_debugfs_init(struct drm_minor *);
  94. void armada_drm_debugfs_cleanup(struct drm_minor *);
  95. #endif