malidp_drv.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. struct malidp_plane_state {
  51. struct drm_plane_state base;
  52. /* size of the required rotation memory if plane is rotated */
  53. u32 rotmem_size;
  54. /* internal format ID */
  55. u8 format;
  56. u8 n_planes;
  57. };
  58. #define to_malidp_plane(x) container_of(x, struct malidp_plane, base)
  59. #define to_malidp_plane_state(x) container_of(x, struct malidp_plane_state, base)
  60. struct malidp_crtc_state {
  61. struct drm_crtc_state base;
  62. u32 gamma_coeffs[MALIDP_COEFFTAB_NUM_COEFFS];
  63. u32 coloradj_coeffs[MALIDP_COLORADJ_NUM_COEFFS];
  64. struct malidp_se_config scaler_config;
  65. /* Bitfield of all the planes that have requested a scaled output. */
  66. u8 scaled_planes_mask;
  67. };
  68. #define to_malidp_crtc_state(x) container_of(x, struct malidp_crtc_state, base)
  69. int malidp_de_planes_init(struct drm_device *drm);
  70. int malidp_crtc_init(struct drm_device *drm);
  71. #ifdef CONFIG_DEBUG_FS
  72. void malidp_error(struct malidp_drm *malidp,
  73. struct malidp_error_stats *error_stats, u32 status,
  74. u64 vblank);
  75. #endif
  76. /* often used combination of rotational bits */
  77. #define MALIDP_ROTATED_MASK (DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_270)
  78. #endif /* __MALIDP_DRV_H__ */