armada_drm.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_private;
  34. struct armada_variant {
  35. bool has_spu_adv_reg;
  36. uint32_t spu_adv_reg;
  37. int (*init)(struct armada_crtc *, struct device *);
  38. int (*compute_clock)(struct armada_crtc *,
  39. const struct drm_display_mode *,
  40. uint32_t *);
  41. };
  42. /* Variant ops */
  43. extern const struct armada_variant armada510_ops;
  44. struct armada_private {
  45. struct work_struct fb_unref_work;
  46. DECLARE_KFIFO(fb_unref, struct drm_framebuffer *, 8);
  47. struct drm_fb_helper *fbdev;
  48. struct armada_crtc *dcrtc[2];
  49. struct drm_mm linear;
  50. struct drm_property *csc_yuv_prop;
  51. struct drm_property *csc_rgb_prop;
  52. struct drm_property *colorkey_prop;
  53. struct drm_property *colorkey_min_prop;
  54. struct drm_property *colorkey_max_prop;
  55. struct drm_property *colorkey_val_prop;
  56. struct drm_property *colorkey_alpha_prop;
  57. struct drm_property *colorkey_mode_prop;
  58. struct drm_property *brightness_prop;
  59. struct drm_property *contrast_prop;
  60. struct drm_property *saturation_prop;
  61. #ifdef CONFIG_DEBUG_FS
  62. struct dentry *de;
  63. #endif
  64. };
  65. void __armada_drm_queue_unref_work(struct drm_device *,
  66. struct drm_framebuffer *);
  67. void armada_drm_queue_unref_work(struct drm_device *,
  68. struct drm_framebuffer *);
  69. extern const struct drm_mode_config_funcs armada_drm_mode_config_funcs;
  70. int armada_fbdev_init(struct drm_device *);
  71. void armada_fbdev_lastclose(struct drm_device *);
  72. void armada_fbdev_fini(struct drm_device *);
  73. int armada_overlay_plane_create(struct drm_device *, unsigned long);
  74. int armada_drm_debugfs_init(struct drm_minor *);
  75. void armada_drm_debugfs_cleanup(struct drm_minor *);
  76. #endif