malidp_drv.h 2.7 KB

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