malidp_drv.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * (C) COPYRIGHT 2016 ARM Limited. All rights reserved.
  4. * Author: Liviu Dudau <Liviu.Dudau@arm.com>
  5. *
  6. * ARM Mali DP500/DP550/DP650 KMS/DRM driver structures
  7. */
  8. #ifndef __MALIDP_DRV_H__
  9. #define __MALIDP_DRV_H__
  10. #include <linux/mutex.h>
  11. #include <linux/wait.h>
  12. #include <linux/spinlock.h>
  13. #include <drm/drm_writeback.h>
  14. #include <drm/drm_encoder.h>
  15. #include "malidp_hw.h"
  16. #define MALIDP_CONFIG_VALID_INIT 0
  17. #define MALIDP_CONFIG_VALID_DONE 1
  18. #define MALIDP_CONFIG_START 0xd0
  19. struct malidp_error_stats {
  20. s32 num_errors;
  21. u32 last_error_status;
  22. s64 last_error_vblank;
  23. };
  24. struct malidp_drm {
  25. struct drm_device base;
  26. struct malidp_hw_device *dev;
  27. struct drm_crtc crtc;
  28. struct drm_writeback_connector mw_connector;
  29. wait_queue_head_t wq;
  30. struct drm_pending_vblank_event *event;
  31. atomic_t config_valid;
  32. u32 core_id;
  33. #ifdef CONFIG_DEBUG_FS
  34. struct malidp_error_stats de_errors;
  35. struct malidp_error_stats se_errors;
  36. /* Protects errors stats */
  37. spinlock_t errors_lock;
  38. #endif
  39. };
  40. #define drm_to_malidp(x) container_of(x, struct malidp_drm, base)
  41. #define crtc_to_malidp_device(x) container_of(x, struct malidp_drm, crtc)
  42. struct malidp_plane {
  43. struct drm_plane base;
  44. struct malidp_hw_device *hwdev;
  45. const struct malidp_layer *layer;
  46. };
  47. enum mmu_prefetch_mode {
  48. MALIDP_PREFETCH_MODE_NONE,
  49. MALIDP_PREFETCH_MODE_PARTIAL,
  50. MALIDP_PREFETCH_MODE_FULL,
  51. };
  52. struct malidp_plane_state {
  53. struct drm_plane_state base;
  54. /* size of the required rotation memory if plane is rotated */
  55. u32 rotmem_size;
  56. /* internal format ID */
  57. u8 format;
  58. u8 n_planes;
  59. enum mmu_prefetch_mode mmu_prefetch_mode;
  60. u32 mmu_prefetch_pgsize;
  61. };
  62. #define to_malidp_plane(x) container_of(x, struct malidp_plane, base)
  63. #define to_malidp_plane_state(x) container_of(x, struct malidp_plane_state, base)
  64. struct malidp_crtc_state {
  65. struct drm_crtc_state base;
  66. u32 gamma_coeffs[MALIDP_COEFFTAB_NUM_COEFFS];
  67. u32 coloradj_coeffs[MALIDP_COLORADJ_NUM_COEFFS];
  68. struct malidp_se_config scaler_config;
  69. /* Bitfield of all the planes that have requested a scaled output. */
  70. u8 scaled_planes_mask;
  71. };
  72. #define to_malidp_crtc_state(x) container_of(x, struct malidp_crtc_state, base)
  73. int malidp_de_planes_init(struct drm_device *drm);
  74. int malidp_crtc_init(struct drm_device *drm);
  75. bool malidp_hw_format_is_linear_only(u32 format);
  76. bool malidp_hw_format_is_afbc_only(u32 format);
  77. bool malidp_format_mod_supported(struct drm_device *drm,
  78. u32 format, u64 modifier);
  79. #ifdef CONFIG_DEBUG_FS
  80. void malidp_error(struct malidp_drm *malidp,
  81. struct malidp_error_stats *error_stats, u32 status,
  82. u64 vblank);
  83. #endif
  84. /* often used combination of rotational bits */
  85. #define MALIDP_ROTATED_MASK (DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_270)
  86. #endif /* __MALIDP_DRV_H__ */