Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2015-2020 Advanced Micro Devices, Inc. All rights reserved.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: AMD
0023  *
0024  */
0025 
0026 #ifndef __AMDGPU_DM_H__
0027 #define __AMDGPU_DM_H__
0028 
0029 #include <drm/display/drm_dp_mst_helper.h>
0030 #include <drm/drm_atomic.h>
0031 #include <drm/drm_connector.h>
0032 #include <drm/drm_crtc.h>
0033 #include <drm/drm_plane.h>
0034 
0035 /*
0036  * This file contains the definition for amdgpu_display_manager
0037  * and its API for amdgpu driver's use.
0038  * This component provides all the display related functionality
0039  * and this is the only component that calls DAL API.
0040  * The API contained here intended for amdgpu driver use.
0041  * The API that is called directly from KMS framework is located
0042  * in amdgpu_dm_kms.h file
0043  */
0044 
0045 #define AMDGPU_DM_MAX_DISPLAY_INDEX 31
0046 
0047 #define AMDGPU_DM_MAX_CRTC 6
0048 
0049 #define AMDGPU_DM_MAX_NUM_EDP 2
0050 
0051 #define AMDGPU_DMUB_NOTIFICATION_MAX 5
0052 
0053 /*
0054  * DMUB Async to Sync Mechanism Status
0055  */
0056 #define DMUB_ASYNC_TO_SYNC_ACCESS_FAIL 1
0057 #define DMUB_ASYNC_TO_SYNC_ACCESS_TIMEOUT 2
0058 #define DMUB_ASYNC_TO_SYNC_ACCESS_SUCCESS 3
0059 /*
0060 #include "include/amdgpu_dal_power_if.h"
0061 #include "amdgpu_dm_irq.h"
0062 */
0063 
0064 #include "irq_types.h"
0065 #include "signal_types.h"
0066 #include "amdgpu_dm_crc.h"
0067 struct aux_payload;
0068 enum aux_return_code_type;
0069 
0070 /* Forward declarations */
0071 struct amdgpu_device;
0072 struct amdgpu_crtc;
0073 struct drm_device;
0074 struct dc;
0075 struct amdgpu_bo;
0076 struct dmub_srv;
0077 struct dc_plane_state;
0078 struct dmub_notification;
0079 
0080 struct common_irq_params {
0081     struct amdgpu_device *adev;
0082     enum dc_irq_source irq_src;
0083     atomic64_t previous_timestamp;
0084 };
0085 
0086 /**
0087  * struct dm_compressor_info - Buffer info used by frame buffer compression
0088  * @cpu_addr: MMIO cpu addr
0089  * @bo_ptr: Pointer to the buffer object
0090  * @gpu_addr: MMIO gpu addr
0091  */
0092 struct dm_compressor_info {
0093     void *cpu_addr;
0094     struct amdgpu_bo *bo_ptr;
0095     uint64_t gpu_addr;
0096 };
0097 
0098 typedef void (*dmub_notify_interrupt_callback_t)(struct amdgpu_device *adev, struct dmub_notification *notify);
0099 
0100 /**
0101  * struct dmub_hpd_work - Handle time consuming work in low priority outbox IRQ
0102  *
0103  * @handle_hpd_work: Work to be executed in a separate thread to handle hpd_low_irq
0104  * @dmub_notify:  notification for callback function
0105  * @adev: amdgpu_device pointer
0106  */
0107 struct dmub_hpd_work {
0108     struct work_struct handle_hpd_work;
0109     struct dmub_notification *dmub_notify;
0110     struct amdgpu_device *adev;
0111 };
0112 
0113 /**
0114  * struct vblank_control_work - Work data for vblank control
0115  * @work: Kernel work data for the work event
0116  * @dm: amdgpu display manager device
0117  * @acrtc: amdgpu CRTC instance for which the event has occurred
0118  * @stream: DC stream for which the event has occurred
0119  * @enable: true if enabling vblank
0120  */
0121 struct vblank_control_work {
0122     struct work_struct work;
0123     struct amdgpu_display_manager *dm;
0124     struct amdgpu_crtc *acrtc;
0125     struct dc_stream_state *stream;
0126     bool enable;
0127 };
0128 
0129 /**
0130  * struct amdgpu_dm_backlight_caps - Information about backlight
0131  *
0132  * Describe the backlight support for ACPI or eDP AUX.
0133  */
0134 struct amdgpu_dm_backlight_caps {
0135     /**
0136      * @ext_caps: Keep the data struct with all the information about the
0137      * display support for HDR.
0138      */
0139     union dpcd_sink_ext_caps *ext_caps;
0140     /**
0141      * @aux_min_input_signal: Min brightness value supported by the display
0142      */
0143     u32 aux_min_input_signal;
0144     /**
0145      * @aux_max_input_signal: Max brightness value supported by the display
0146      * in nits.
0147      */
0148     u32 aux_max_input_signal;
0149     /**
0150      * @min_input_signal: minimum possible input in range 0-255.
0151      */
0152     int min_input_signal;
0153     /**
0154      * @max_input_signal: maximum possible input in range 0-255.
0155      */
0156     int max_input_signal;
0157     /**
0158      * @caps_valid: true if these values are from the ACPI interface.
0159      */
0160     bool caps_valid;
0161     /**
0162      * @aux_support: Describes if the display supports AUX backlight.
0163      */
0164     bool aux_support;
0165 };
0166 
0167 /**
0168  * struct dal_allocation - Tracks mapped FB memory for SMU communication
0169  * @list: list of dal allocations
0170  * @bo: GPU buffer object
0171  * @cpu_ptr: CPU virtual address of the GPU buffer object
0172  * @gpu_addr: GPU virtual address of the GPU buffer object
0173  */
0174 struct dal_allocation {
0175     struct list_head list;
0176     struct amdgpu_bo *bo;
0177     void *cpu_ptr;
0178     u64 gpu_addr;
0179 };
0180 
0181 /**
0182  * struct hpd_rx_irq_offload_work_queue - Work queue to handle hpd_rx_irq
0183  * offload work
0184  */
0185 struct hpd_rx_irq_offload_work_queue {
0186     /**
0187      * @wq: workqueue structure to queue offload work.
0188      */
0189     struct workqueue_struct *wq;
0190     /**
0191      * @offload_lock: To protect fields of offload work queue.
0192      */
0193     spinlock_t offload_lock;
0194     /**
0195      * @is_handling_link_loss: Used to prevent inserting link loss event when
0196      * we're handling link loss
0197      */
0198     bool is_handling_link_loss;
0199     /**
0200      * @aconnector: The aconnector that this work queue is attached to
0201      */
0202     struct amdgpu_dm_connector *aconnector;
0203 };
0204 
0205 /**
0206  * struct hpd_rx_irq_offload_work - hpd_rx_irq offload work structure
0207  */
0208 struct hpd_rx_irq_offload_work {
0209     /**
0210      * @work: offload work
0211      */
0212     struct work_struct work;
0213     /**
0214      * @data: reference irq data which is used while handling offload work
0215      */
0216     union hpd_irq_data data;
0217     /**
0218      * @offload_wq: offload work queue that this work is queued to
0219      */
0220     struct hpd_rx_irq_offload_work_queue *offload_wq;
0221 };
0222 
0223 /**
0224  * struct amdgpu_display_manager - Central amdgpu display manager device
0225  *
0226  * @dc: Display Core control structure
0227  * @adev: AMDGPU base driver structure
0228  * @ddev: DRM base driver structure
0229  * @display_indexes_num: Max number of display streams supported
0230  * @irq_handler_list_table_lock: Synchronizes access to IRQ tables
0231  * @backlight_dev: Backlight control device
0232  * @backlight_link: Link on which to control backlight
0233  * @backlight_caps: Capabilities of the backlight device
0234  * @freesync_module: Module handling freesync calculations
0235  * @hdcp_workqueue: AMDGPU content protection queue
0236  * @fw_dmcu: Reference to DMCU firmware
0237  * @dmcu_fw_version: Version of the DMCU firmware
0238  * @soc_bounding_box: SOC bounding box values provided by gpu_info FW
0239  * @cached_state: Caches device atomic state for suspend/resume
0240  * @cached_dc_state: Cached state of content streams
0241  * @compressor: Frame buffer compression buffer. See &struct dm_compressor_info
0242  * @force_timing_sync: set via debugfs. When set, indicates that all connected
0243  *             displays will be forced to synchronize.
0244  * @dmcub_trace_event_en: enable dmcub trace events
0245  * @dmub_outbox_params: DMUB Outbox parameters
0246  * @num_of_edps: number of backlight eDPs
0247  * @disable_hpd_irq: disables all HPD and HPD RX interrupt handling in the
0248  *           driver when true
0249  * @dmub_aux_transfer_done: struct completion used to indicate when DMUB
0250  *              transfers are done
0251  * @delayed_hpd_wq: work queue used to delay DMUB HPD work
0252  */
0253 struct amdgpu_display_manager {
0254 
0255     struct dc *dc;
0256 
0257     /**
0258      * @dmub_srv:
0259      *
0260      * DMUB service, used for controlling the DMUB on hardware
0261      * that supports it. The pointer to the dmub_srv will be
0262      * NULL on hardware that does not support it.
0263      */
0264     struct dmub_srv *dmub_srv;
0265 
0266     /**
0267      * @dmub_notify:
0268      *
0269      * Notification from DMUB.
0270      */
0271 
0272     struct dmub_notification *dmub_notify;
0273 
0274     /**
0275      * @dmub_callback:
0276      *
0277      * Callback functions to handle notification from DMUB.
0278      */
0279 
0280     dmub_notify_interrupt_callback_t dmub_callback[AMDGPU_DMUB_NOTIFICATION_MAX];
0281 
0282     /**
0283      * @dmub_thread_offload:
0284      *
0285      * Flag to indicate if callback is offload.
0286      */
0287 
0288     bool dmub_thread_offload[AMDGPU_DMUB_NOTIFICATION_MAX];
0289 
0290     /**
0291      * @dmub_fb_info:
0292      *
0293      * Framebuffer regions for the DMUB.
0294      */
0295     struct dmub_srv_fb_info *dmub_fb_info;
0296 
0297     /**
0298      * @dmub_fw:
0299      *
0300      * DMUB firmware, required on hardware that has DMUB support.
0301      */
0302     const struct firmware *dmub_fw;
0303 
0304     /**
0305      * @dmub_bo:
0306      *
0307      * Buffer object for the DMUB.
0308      */
0309     struct amdgpu_bo *dmub_bo;
0310 
0311     /**
0312      * @dmub_bo_gpu_addr:
0313      *
0314      * GPU virtual address for the DMUB buffer object.
0315      */
0316     u64 dmub_bo_gpu_addr;
0317 
0318     /**
0319      * @dmub_bo_cpu_addr:
0320      *
0321      * CPU address for the DMUB buffer object.
0322      */
0323     void *dmub_bo_cpu_addr;
0324 
0325     /**
0326      * @dmcub_fw_version:
0327      *
0328      * DMCUB firmware version.
0329      */
0330     uint32_t dmcub_fw_version;
0331 
0332     /**
0333      * @cgs_device:
0334      *
0335      * The Common Graphics Services device. It provides an interface for
0336      * accessing registers.
0337      */
0338     struct cgs_device *cgs_device;
0339 
0340     struct amdgpu_device *adev;
0341     struct drm_device *ddev;
0342     u16 display_indexes_num;
0343 
0344     /**
0345      * @atomic_obj:
0346      *
0347      * In combination with &dm_atomic_state it helps manage
0348      * global atomic state that doesn't map cleanly into existing
0349      * drm resources, like &dc_context.
0350      */
0351     struct drm_private_obj atomic_obj;
0352 
0353     /**
0354      * @dc_lock:
0355      *
0356      * Guards access to DC functions that can issue register write
0357      * sequences.
0358      */
0359     struct mutex dc_lock;
0360 
0361     /**
0362      * @audio_lock:
0363      *
0364      * Guards access to audio instance changes.
0365      */
0366     struct mutex audio_lock;
0367 
0368     /**
0369      * @vblank_lock:
0370      *
0371      * Guards access to deferred vblank work state.
0372      */
0373     spinlock_t vblank_lock;
0374 
0375     /**
0376      * @audio_component:
0377      *
0378      * Used to notify ELD changes to sound driver.
0379      */
0380     struct drm_audio_component *audio_component;
0381 
0382     /**
0383      * @audio_registered:
0384      *
0385      * True if the audio component has been registered
0386      * successfully, false otherwise.
0387      */
0388     bool audio_registered;
0389 
0390     /**
0391      * @irq_handler_list_low_tab:
0392      *
0393      * Low priority IRQ handler table.
0394      *
0395      * It is a n*m table consisting of n IRQ sources, and m handlers per IRQ
0396      * source. Low priority IRQ handlers are deferred to a workqueue to be
0397      * processed. Hence, they can sleep.
0398      *
0399      * Note that handlers are called in the same order as they were
0400      * registered (FIFO).
0401      */
0402     struct list_head irq_handler_list_low_tab[DAL_IRQ_SOURCES_NUMBER];
0403 
0404     /**
0405      * @irq_handler_list_high_tab:
0406      *
0407      * High priority IRQ handler table.
0408      *
0409      * It is a n*m table, same as &irq_handler_list_low_tab. However,
0410      * handlers in this table are not deferred and are called immediately.
0411      */
0412     struct list_head irq_handler_list_high_tab[DAL_IRQ_SOURCES_NUMBER];
0413 
0414     /**
0415      * @pflip_params:
0416      *
0417      * Page flip IRQ parameters, passed to registered handlers when
0418      * triggered.
0419      */
0420     struct common_irq_params
0421     pflip_params[DC_IRQ_SOURCE_PFLIP_LAST - DC_IRQ_SOURCE_PFLIP_FIRST + 1];
0422 
0423     /**
0424      * @vblank_params:
0425      *
0426      * Vertical blanking IRQ parameters, passed to registered handlers when
0427      * triggered.
0428      */
0429     struct common_irq_params
0430     vblank_params[DC_IRQ_SOURCE_VBLANK6 - DC_IRQ_SOURCE_VBLANK1 + 1];
0431 
0432     /**
0433      * @vline0_params:
0434      *
0435      * OTG vertical interrupt0 IRQ parameters, passed to registered
0436      * handlers when triggered.
0437      */
0438     struct common_irq_params
0439     vline0_params[DC_IRQ_SOURCE_DC6_VLINE0 - DC_IRQ_SOURCE_DC1_VLINE0 + 1];
0440 
0441     /**
0442      * @vupdate_params:
0443      *
0444      * Vertical update IRQ parameters, passed to registered handlers when
0445      * triggered.
0446      */
0447     struct common_irq_params
0448     vupdate_params[DC_IRQ_SOURCE_VUPDATE6 - DC_IRQ_SOURCE_VUPDATE1 + 1];
0449 
0450     /**
0451      * @dmub_trace_params:
0452      *
0453      * DMUB trace event IRQ parameters, passed to registered handlers when
0454      * triggered.
0455      */
0456     struct common_irq_params
0457     dmub_trace_params[1];
0458 
0459     struct common_irq_params
0460     dmub_outbox_params[1];
0461 
0462     spinlock_t irq_handler_list_table_lock;
0463 
0464     struct backlight_device *backlight_dev[AMDGPU_DM_MAX_NUM_EDP];
0465 
0466     const struct dc_link *backlight_link[AMDGPU_DM_MAX_NUM_EDP];
0467 
0468     uint8_t num_of_edps;
0469 
0470     struct amdgpu_dm_backlight_caps backlight_caps[AMDGPU_DM_MAX_NUM_EDP];
0471 
0472     struct mod_freesync *freesync_module;
0473 #ifdef CONFIG_DRM_AMD_DC_HDCP
0474     struct hdcp_workqueue *hdcp_workqueue;
0475 #endif
0476 
0477     /**
0478      * @vblank_control_workqueue:
0479      *
0480      * Deferred work for vblank control events.
0481      */
0482     struct workqueue_struct *vblank_control_workqueue;
0483 
0484     struct drm_atomic_state *cached_state;
0485     struct dc_state *cached_dc_state;
0486 
0487     struct dm_compressor_info compressor;
0488 
0489     const struct firmware *fw_dmcu;
0490     uint32_t dmcu_fw_version;
0491     /**
0492      * @soc_bounding_box:
0493      *
0494      * gpu_info FW provided soc bounding box struct or 0 if not
0495      * available in FW
0496      */
0497     const struct gpu_info_soc_bounding_box_v1_0 *soc_bounding_box;
0498 
0499     /**
0500      * @active_vblank_irq_count:
0501      *
0502      * number of currently active vblank irqs
0503      */
0504     uint32_t active_vblank_irq_count;
0505 
0506 #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
0507     /**
0508      * @crc_rd_wrk:
0509      *
0510      * Work to be executed in a separate thread to communicate with PSP.
0511      */
0512     struct crc_rd_work *crc_rd_wrk;
0513 #endif
0514     /**
0515      * @hpd_rx_offload_wq:
0516      *
0517      * Work queue to offload works of hpd_rx_irq
0518      */
0519     struct hpd_rx_irq_offload_work_queue *hpd_rx_offload_wq;
0520     /**
0521      * @mst_encoders:
0522      *
0523      * fake encoders used for DP MST.
0524      */
0525     struct amdgpu_encoder mst_encoders[AMDGPU_DM_MAX_CRTC];
0526     bool force_timing_sync;
0527     bool disable_hpd_irq;
0528     bool dmcub_trace_event_en;
0529     /**
0530      * @da_list:
0531      *
0532      * DAL fb memory allocation list, for communication with SMU.
0533      */
0534     struct list_head da_list;
0535     struct completion dmub_aux_transfer_done;
0536     struct workqueue_struct *delayed_hpd_wq;
0537 
0538     /**
0539      * @brightness:
0540      *
0541      * cached backlight values.
0542      */
0543     u32 brightness[AMDGPU_DM_MAX_NUM_EDP];
0544     /**
0545      * @actual_brightness:
0546      *
0547      * last successfully applied backlight values.
0548      */
0549     u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP];
0550 
0551     /**
0552      * @aux_hpd_discon_quirk:
0553      *
0554      * quirk for hpd discon while aux is on-going.
0555      * occurred on certain intel platform
0556      */
0557     bool aux_hpd_discon_quirk;
0558 };
0559 
0560 enum dsc_clock_force_state {
0561     DSC_CLK_FORCE_DEFAULT = 0,
0562     DSC_CLK_FORCE_ENABLE,
0563     DSC_CLK_FORCE_DISABLE,
0564 };
0565 
0566 struct dsc_preferred_settings {
0567     enum dsc_clock_force_state dsc_force_enable;
0568     uint32_t dsc_num_slices_v;
0569     uint32_t dsc_num_slices_h;
0570     uint32_t dsc_bits_per_pixel;
0571     bool dsc_force_disable_passthrough;
0572 };
0573 
0574 enum mst_progress_status {
0575     MST_STATUS_DEFAULT = 0,
0576     MST_PROBE = BIT(0),
0577     MST_REMOTE_EDID = BIT(1),
0578     MST_ALLOCATE_NEW_PAYLOAD = BIT(2),
0579     MST_CLEAR_ALLOCATED_PAYLOAD = BIT(3),
0580 };
0581 
0582 struct amdgpu_dm_connector {
0583 
0584     struct drm_connector base;
0585     uint32_t connector_id;
0586 
0587     /* we need to mind the EDID between detect
0588        and get modes due to analog/digital/tvencoder */
0589     struct edid *edid;
0590 
0591     /* shared with amdgpu */
0592     struct amdgpu_hpd hpd;
0593 
0594     /* number of modes generated from EDID at 'dc_sink' */
0595     int num_modes;
0596 
0597     /* The 'old' sink - before an HPD.
0598      * The 'current' sink is in dc_link->sink. */
0599     struct dc_sink *dc_sink;
0600     struct dc_link *dc_link;
0601     struct dc_sink *dc_em_sink;
0602 
0603     /* DM only */
0604     struct drm_dp_mst_topology_mgr mst_mgr;
0605     struct amdgpu_dm_dp_aux dm_dp_aux;
0606     struct drm_dp_mst_port *port;
0607     struct amdgpu_dm_connector *mst_port;
0608     struct drm_dp_aux *dsc_aux;
0609     /* TODO see if we can merge with ddc_bus or make a dm_connector */
0610     struct amdgpu_i2c_adapter *i2c;
0611 
0612     /* Monitor range limits */
0613     int min_vfreq ;
0614     int max_vfreq ;
0615     int pixel_clock_mhz;
0616 
0617     /* Audio instance - protected by audio_lock. */
0618     int audio_inst;
0619 
0620     struct mutex hpd_lock;
0621 
0622     bool fake_enable;
0623 #ifdef CONFIG_DEBUG_FS
0624     uint32_t debugfs_dpcd_address;
0625     uint32_t debugfs_dpcd_size;
0626 #endif
0627     bool force_yuv420_output;
0628     struct dsc_preferred_settings dsc_settings;
0629     union dp_downstream_port_present mst_downstream_port_present;
0630     /* Cached display modes */
0631     struct drm_display_mode freesync_vid_base;
0632 
0633     int psr_skip_count;
0634 
0635     /* Record progress status of mst*/
0636     uint8_t mst_status;
0637 };
0638 
0639 static inline void amdgpu_dm_set_mst_status(uint8_t *status,
0640         uint8_t flags, bool set)
0641 {
0642     if (set)
0643         *status |= flags;
0644     else
0645         *status &= ~flags;
0646 }
0647 
0648 #define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base)
0649 
0650 extern const struct amdgpu_ip_block_version dm_ip_block;
0651 
0652 struct dm_plane_state {
0653     struct drm_plane_state base;
0654     struct dc_plane_state *dc_state;
0655 };
0656 
0657 struct dm_crtc_state {
0658     struct drm_crtc_state base;
0659     struct dc_stream_state *stream;
0660 
0661     bool cm_has_degamma;
0662     bool cm_is_degamma_srgb;
0663 
0664     bool mpo_requested;
0665 
0666     int update_type;
0667     int active_planes;
0668 
0669     int crc_skip_count;
0670 
0671     bool freesync_timing_changed;
0672     bool freesync_vrr_info_changed;
0673 
0674     bool dsc_force_changed;
0675     bool vrr_supported;
0676     struct mod_freesync_config freesync_config;
0677     struct dc_info_packet vrr_infopacket;
0678 
0679     int abm_level;
0680 };
0681 
0682 #define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
0683 
0684 struct dm_atomic_state {
0685     struct drm_private_state base;
0686 
0687     struct dc_state *context;
0688 };
0689 
0690 #define to_dm_atomic_state(x) container_of(x, struct dm_atomic_state, base)
0691 
0692 struct dm_connector_state {
0693     struct drm_connector_state base;
0694 
0695     enum amdgpu_rmx_type scaling;
0696     uint8_t underscan_vborder;
0697     uint8_t underscan_hborder;
0698     bool underscan_enable;
0699     bool freesync_capable;
0700 #ifdef CONFIG_DRM_AMD_DC_HDCP
0701     bool update_hdcp;
0702 #endif
0703     uint8_t abm_level;
0704     int vcpi_slots;
0705     uint64_t pbn;
0706 };
0707 
0708 struct amdgpu_hdmi_vsdb_info {
0709     unsigned int amd_vsdb_version;      /* VSDB version, should be used to determine which VSIF to send */
0710     bool freesync_supported;        /* FreeSync Supported */
0711     unsigned int min_refresh_rate_hz;   /* FreeSync Minimum Refresh Rate in Hz */
0712     unsigned int max_refresh_rate_hz;   /* FreeSync Maximum Refresh Rate in Hz */
0713 };
0714 
0715 
0716 #define to_dm_connector_state(x)\
0717     container_of((x), struct dm_connector_state, base)
0718 
0719 void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector);
0720 struct drm_connector_state *
0721 amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector);
0722 int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
0723                         struct drm_connector_state *state,
0724                         struct drm_property *property,
0725                         uint64_t val);
0726 
0727 int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
0728                         const struct drm_connector_state *state,
0729                         struct drm_property *property,
0730                         uint64_t *val);
0731 
0732 int amdgpu_dm_get_encoder_crtc_mask(struct amdgpu_device *adev);
0733 
0734 void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
0735                      struct amdgpu_dm_connector *aconnector,
0736                      int connector_type,
0737                      struct dc_link *link,
0738                      int link_index);
0739 
0740 enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connector,
0741                    struct drm_display_mode *mode);
0742 
0743 void dm_restore_drm_connector_state(struct drm_device *dev,
0744                     struct drm_connector *connector);
0745 
0746 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
0747                     struct edid *edid);
0748 
0749 void amdgpu_dm_trigger_timing_sync(struct drm_device *dev);
0750 
0751 #define MAX_COLOR_LUT_ENTRIES 4096
0752 /* Legacy gamm LUT users such as X doesn't like large LUT sizes */
0753 #define MAX_COLOR_LEGACY_LUT_ENTRIES 256
0754 
0755 void amdgpu_dm_init_color_mod(void);
0756 int amdgpu_dm_verify_lut_sizes(const struct drm_crtc_state *crtc_state);
0757 int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc);
0758 int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
0759                       struct dc_plane_state *dc_plane_state);
0760 
0761 void amdgpu_dm_update_connector_after_detect(
0762         struct amdgpu_dm_connector *aconnector);
0763 
0764 extern const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs;
0765 
0766 int amdgpu_dm_process_dmub_aux_transfer_sync(bool is_cmd_aux,
0767                     struct dc_context *ctx, unsigned int link_index,
0768                     void *payload, void *operation_result);
0769 
0770 bool check_seamless_boot_capability(struct amdgpu_device *adev);
0771 
0772 struct dc_stream_state *
0773     create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
0774                     const struct drm_display_mode *drm_mode,
0775                     const struct dm_connector_state *dm_state,
0776                     const struct dc_stream_state *old_stream);
0777 
0778 int dm_atomic_get_state(struct drm_atomic_state *state,
0779             struct dm_atomic_state **dm_state);
0780 
0781 struct amdgpu_dm_connector *
0782 amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
0783                          struct drm_crtc *crtc);
0784 
0785 int convert_dc_color_depth_into_bpc(enum dc_color_depth display_color_depth);
0786 #endif /* __AMDGPU_DM_H__ */