armada_drm.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 drm_device drm;
  46. struct work_struct fb_unref_work;
  47. DECLARE_KFIFO(fb_unref, struct drm_framebuffer *, 8);
  48. struct drm_fb_helper *fbdev;
  49. struct armada_crtc *dcrtc[2];
  50. struct drm_mm linear; /* protected by linear_lock */
  51. struct mutex linear_lock;
  52. struct drm_property *csc_yuv_prop;
  53. struct drm_property *csc_rgb_prop;
  54. struct drm_property *colorkey_prop;
  55. struct drm_property *colorkey_min_prop;
  56. struct drm_property *colorkey_max_prop;
  57. struct drm_property *colorkey_val_prop;
  58. struct drm_property *colorkey_alpha_prop;
  59. struct drm_property *colorkey_mode_prop;
  60. struct drm_property *brightness_prop;
  61. struct drm_property *contrast_prop;
  62. struct drm_property *saturation_prop;
  63. #ifdef CONFIG_DEBUG_FS
  64. struct dentry *de;
  65. #endif
  66. };
  67. void __armada_drm_queue_unref_work(struct drm_device *,
  68. struct drm_framebuffer *);
  69. void armada_drm_queue_unref_work(struct drm_device *,
  70. struct drm_framebuffer *);
  71. extern const struct drm_mode_config_funcs armada_drm_mode_config_funcs;
  72. int armada_fbdev_init(struct drm_device *);
  73. void armada_fbdev_lastclose(struct drm_device *);
  74. void armada_fbdev_fini(struct drm_device *);
  75. int armada_overlay_plane_create(struct drm_device *, unsigned long);
  76. int armada_drm_debugfs_init(struct drm_minor *);
  77. #endif