armada_drm.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. struct drm_fb_helper;
  17. struct drm_fb_helper_surface_size;
  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. int (*init)(struct armada_crtc *, struct device *);
  37. int (*compute_clock)(struct armada_crtc *,
  38. const struct drm_display_mode *,
  39. uint32_t *);
  40. void (*disable)(struct armada_crtc *);
  41. void (*enable)(struct armada_crtc *, const struct drm_display_mode *);
  42. };
  43. /* Variant ops */
  44. extern const struct armada_variant armada510_ops;
  45. struct armada_private {
  46. struct drm_device drm;
  47. struct armada_crtc *dcrtc[2];
  48. struct drm_mm linear; /* protected by linear_lock */
  49. struct mutex linear_lock;
  50. struct drm_property *colorkey_prop;
  51. struct drm_property *colorkey_min_prop;
  52. struct drm_property *colorkey_max_prop;
  53. struct drm_property *colorkey_val_prop;
  54. struct drm_property *colorkey_alpha_prop;
  55. struct drm_property *colorkey_mode_prop;
  56. struct drm_property *brightness_prop;
  57. struct drm_property *contrast_prop;
  58. struct drm_property *saturation_prop;
  59. #ifdef CONFIG_DEBUG_FS
  60. struct dentry *de;
  61. #endif
  62. };
  63. #define drm_to_armada_dev(dev) container_of(dev, struct armada_private, drm)
  64. #if defined(CONFIG_DRM_FBDEV_EMULATION)
  65. int armada_fbdev_driver_fbdev_probe(struct drm_fb_helper *fbh,
  66. struct drm_fb_helper_surface_size *sizes);
  67. #define ARMADA_FBDEV_DRIVER_OPS \
  68. .fbdev_probe = armada_fbdev_driver_fbdev_probe
  69. #else
  70. #define ARMADA_FBDEV_DRIVER_OPS \
  71. .fbdev_probe = NULL
  72. #endif
  73. int armada_overlay_plane_create(struct drm_device *, unsigned long);
  74. void armada_drm_crtc_debugfs_init(struct armada_crtc *dcrtc);
  75. int armada_drm_debugfs_init(struct drm_minor *);
  76. #endif