amdgpu_dm.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef __AMDGPU_DM_H__
  26. #define __AMDGPU_DM_H__
  27. /*
  28. #include "linux/switch.h"
  29. */
  30. /*
  31. * This file contains the definition for amdgpu_display_manager
  32. * and its API for amdgpu driver's use.
  33. * This component provides all the display related functionality
  34. * and this is the only component that calls DAL API.
  35. * The API contained here intended for amdgpu driver use.
  36. * The API that is called directly from KMS framework is located
  37. * in amdgpu_dm_kms.h file
  38. */
  39. #define AMDGPU_DM_MAX_DISPLAY_INDEX 31
  40. /*
  41. #include "include/amdgpu_dal_power_if.h"
  42. #include "amdgpu_dm_irq.h"
  43. */
  44. #include "irq_types.h"
  45. #include "signal_types.h"
  46. /* Forward declarations */
  47. struct amdgpu_device;
  48. struct drm_device;
  49. struct amdgpu_dm_irq_handler_data;
  50. struct amdgpu_dm_prev_state {
  51. struct drm_framebuffer *fb;
  52. int32_t x;
  53. int32_t y;
  54. struct drm_display_mode mode;
  55. };
  56. struct common_irq_params {
  57. struct amdgpu_device *adev;
  58. enum dc_irq_source irq_src;
  59. };
  60. struct irq_list_head {
  61. struct list_head head;
  62. /* In case this interrupt needs post-processing, 'work' will be queued*/
  63. struct work_struct work;
  64. };
  65. struct amdgpu_display_manager {
  66. struct dal *dal;
  67. struct dc *dc;
  68. struct cgs_device *cgs_device;
  69. /* lock to be used when DAL is called from SYNC IRQ context */
  70. spinlock_t dal_lock;
  71. struct amdgpu_device *adev; /*AMD base driver*/
  72. struct drm_device *ddev; /*DRM base driver*/
  73. u16 display_indexes_num;
  74. struct amdgpu_dm_prev_state prev_state;
  75. /*
  76. * 'irq_source_handler_table' holds a list of handlers
  77. * per (DAL) IRQ source.
  78. *
  79. * Each IRQ source may need to be handled at different contexts.
  80. * By 'context' we mean, for example:
  81. * - The ISR context, which is the direct interrupt handler.
  82. * - The 'deferred' context - this is the post-processing of the
  83. * interrupt, but at a lower priority.
  84. *
  85. * Note that handlers are called in the same order as they were
  86. * registered (FIFO).
  87. */
  88. struct irq_list_head irq_handler_list_low_tab[DAL_IRQ_SOURCES_NUMBER];
  89. struct list_head irq_handler_list_high_tab[DAL_IRQ_SOURCES_NUMBER];
  90. struct common_irq_params
  91. pflip_params[DC_IRQ_SOURCE_PFLIP_LAST - DC_IRQ_SOURCE_PFLIP_FIRST + 1];
  92. struct common_irq_params
  93. vblank_params[DC_IRQ_SOURCE_VBLANK6 - DC_IRQ_SOURCE_VBLANK1 + 1];
  94. /* this spin lock synchronizes access to 'irq_handler_list_table' */
  95. spinlock_t irq_handler_list_table_lock;
  96. /* Timer-related data. */
  97. struct list_head timer_handler_list;
  98. struct workqueue_struct *timer_workqueue;
  99. /* Use dal_mutex for any activity which is NOT syncronized by
  100. * DRM mode setting locks.
  101. * For example: amdgpu_dm_hpd_low_irq() calls into DAL *without*
  102. * DRM mode setting locks being acquired. This is where dal_mutex
  103. * is acquired before calling into DAL. */
  104. struct mutex dal_mutex;
  105. struct backlight_device *backlight_dev;
  106. const struct dc_link *backlight_link;
  107. struct work_struct mst_hotplug_work;
  108. struct mod_freesync *freesync_module;
  109. /**
  110. * Caches device atomic state for suspend/resume
  111. */
  112. struct drm_atomic_state *cached_state;
  113. };
  114. /* basic init/fini API */
  115. int amdgpu_dm_init(struct amdgpu_device *adev);
  116. void amdgpu_dm_fini(struct amdgpu_device *adev);
  117. void amdgpu_dm_destroy(void);
  118. /* initializes drm_device display related structures, based on the information
  119. * provided by DAL. The drm strcutures are: drm_crtc, drm_connector,
  120. * drm_encoder, drm_mode_config
  121. *
  122. * Returns 0 on success
  123. */
  124. int amdgpu_dm_initialize_drm_device(
  125. struct amdgpu_device *adev);
  126. /* removes and deallocates the drm structures, created by the above function */
  127. void amdgpu_dm_destroy_drm_device(
  128. struct amdgpu_display_manager *dm);
  129. /* Locking/Mutex */
  130. bool amdgpu_dm_acquire_dal_lock(struct amdgpu_display_manager *dm);
  131. bool amdgpu_dm_release_dal_lock(struct amdgpu_display_manager *dm);
  132. /* Register "Backlight device" accessible by user-mode. */
  133. void amdgpu_dm_register_backlight_device(struct amdgpu_display_manager *dm);
  134. extern const struct amdgpu_ip_block_version dm_ip_block;
  135. void amdgpu_dm_update_connector_after_detect(
  136. struct amdgpu_connector *aconnector);
  137. struct amdgpu_connector *amdgpu_dm_find_first_crct_matching_connector(
  138. struct drm_atomic_state *state,
  139. struct drm_crtc *crtc,
  140. bool from_state_var);
  141. #endif /* __AMDGPU_DM_H__ */