armada_drm.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 Russell King
  4. */
  5. #ifndef ARMADA_DRM_H
  6. #define ARMADA_DRM_H
  7. #include <linux/kfifo.h>
  8. #include <linux/io.h>
  9. #include <linux/workqueue.h>
  10. #include <drm/drm_device.h>
  11. #include <drm/drm_mm.h>
  12. struct armada_crtc;
  13. struct armada_gem_object;
  14. struct clk;
  15. struct drm_display_mode;
  16. static inline void
  17. armada_updatel(uint32_t val, uint32_t mask, void __iomem *ptr)
  18. {
  19. uint32_t ov, v;
  20. ov = v = readl_relaxed(ptr);
  21. v = (v & ~mask) | val;
  22. if (ov != v)
  23. writel_relaxed(v, ptr);
  24. }
  25. static inline uint32_t armada_pitch(uint32_t width, uint32_t bpp)
  26. {
  27. uint32_t pitch = bpp != 4 ? width * ((bpp + 7) / 8) : width / 2;
  28. /* 88AP510 spec recommends pitch be a multiple of 128 */
  29. return ALIGN(pitch, 128);
  30. }
  31. struct armada_private;
  32. struct armada_variant {
  33. bool has_spu_adv_reg;
  34. int (*init)(struct armada_crtc *, struct device *);
  35. int (*compute_clock)(struct armada_crtc *,
  36. const struct drm_display_mode *,
  37. uint32_t *);
  38. void (*disable)(struct armada_crtc *);
  39. void (*enable)(struct armada_crtc *, const struct drm_display_mode *);
  40. };
  41. /* Variant ops */
  42. extern const struct armada_variant armada510_ops;
  43. struct armada_private {
  44. struct drm_device drm;
  45. struct armada_crtc *dcrtc[2];
  46. struct drm_mm linear; /* protected by linear_lock */
  47. struct mutex linear_lock;
  48. struct drm_property *colorkey_prop;
  49. struct drm_property *colorkey_min_prop;
  50. struct drm_property *colorkey_max_prop;
  51. struct drm_property *colorkey_val_prop;
  52. struct drm_property *colorkey_alpha_prop;
  53. struct drm_property *colorkey_mode_prop;
  54. struct drm_property *brightness_prop;
  55. struct drm_property *contrast_prop;
  56. struct drm_property *saturation_prop;
  57. #ifdef CONFIG_DEBUG_FS
  58. struct dentry *de;
  59. #endif
  60. };
  61. #define drm_to_armada_dev(dev) container_of(dev, struct armada_private, drm)
  62. #if defined(CONFIG_DRM_FBDEV_EMULATION)
  63. void armada_fbdev_setup(struct drm_device *dev);
  64. #else
  65. static inline void armada_fbdev_setup(struct drm_device *dev)
  66. { }
  67. #endif
  68. int armada_overlay_plane_create(struct drm_device *, unsigned long);
  69. void armada_drm_crtc_debugfs_init(struct armada_crtc *dcrtc);
  70. int armada_drm_debugfs_init(struct drm_minor *);
  71. #endif