1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. 5 * Copyright (C) 2013 Red Hat 6 * Author: Rob Clark <robdclark@gmail.com> 7 */ 8 9 #ifndef __DPU_ENCODER_H__ 10 #define __DPU_ENCODER_H__ 11 12 #include <drm/drm_crtc.h> 13 #include "dpu_hw_mdss.h" 14 15 #define DPU_ENCODER_FRAME_EVENT_DONE BIT(0) 16 #define DPU_ENCODER_FRAME_EVENT_ERROR BIT(1) 17 #define DPU_ENCODER_FRAME_EVENT_PANEL_DEAD BIT(2) 18 #define DPU_ENCODER_FRAME_EVENT_IDLE BIT(3) 19 20 #define IDLE_TIMEOUT (66 - 16/2) 21 22 /** 23 * struct msm_display_info - defines display properties 24 * @intf_type: INTF_ type 25 * @num_of_h_tiles: Number of horizontal tiles in case of split interface 26 * @h_tile_instance: Controller instance used per tile. Number of elements is 27 * based on num_of_h_tiles 28 * @is_cmd_mode Boolean to indicate if the CMD mode is requested 29 * @vsync_source: Source of the TE signal for DSI CMD devices 30 */ 31 struct msm_display_info { 32 enum dpu_intf_type intf_type; 33 uint32_t num_of_h_tiles; 34 uint32_t h_tile_instance[MAX_H_TILES_PER_DISPLAY]; 35 bool is_cmd_mode; 36 enum dpu_vsync_source vsync_source; 37 }; 38 39 /** 40 * dpu_encoder_assign_crtc - Link the encoder to the crtc it's assigned to 41 * @encoder: encoder pointer 42 * @crtc: crtc pointer 43 */ 44 void dpu_encoder_assign_crtc(struct drm_encoder *encoder, 45 struct drm_crtc *crtc); 46 47 /** 48 * dpu_encoder_toggle_vblank_for_crtc - Toggles vblank interrupts on or off if 49 * the encoder is assigned to the given crtc 50 * @encoder: encoder pointer 51 * @crtc: crtc pointer 52 * @enable: true if vblank should be enabled 53 */ 54 void dpu_encoder_toggle_vblank_for_crtc(struct drm_encoder *encoder, 55 struct drm_crtc *crtc, bool enable); 56 57 /** 58 * dpu_encoder_prepare_for_kickoff - schedule double buffer flip of the ctl 59 * path (i.e. ctl flush and start) at next appropriate time. 60 * Immediately: if no previous commit is outstanding. 61 * Delayed: Block until next trigger can be issued. 62 * @encoder: encoder pointer 63 */ 64 void dpu_encoder_prepare_for_kickoff(struct drm_encoder *encoder); 65 66 /** 67 * dpu_encoder_trigger_kickoff_pending - Clear the flush bits from previous 68 * kickoff and trigger the ctl prepare progress for command mode display. 69 * @encoder: encoder pointer 70 */ 71 void dpu_encoder_trigger_kickoff_pending(struct drm_encoder *encoder); 72 73 /** 74 * dpu_encoder_kickoff - trigger a double buffer flip of the ctl path 75 * (i.e. ctl flush and start) immediately. 76 * @encoder: encoder pointer 77 */ 78 void dpu_encoder_kickoff(struct drm_encoder *encoder); 79 80 /** 81 * dpu_encoder_wakeup_time - get the time of the next vsync 82 */ 83 int dpu_encoder_vsync_time(struct drm_encoder *drm_enc, ktime_t *wakeup_time); 84 85 int dpu_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder); 86 87 int dpu_encoder_wait_for_tx_complete(struct drm_encoder *drm_encoder); 88 89 /* 90 * dpu_encoder_get_intf_mode - get interface mode of the given encoder 91 * @encoder: Pointer to drm encoder object 92 */ 93 enum dpu_intf_mode dpu_encoder_get_intf_mode(struct drm_encoder *encoder); 94 95 /** 96 * dpu_encoder_virt_runtime_resume - pm runtime resume the encoder configs 97 * @encoder: encoder pointer 98 */ 99 void dpu_encoder_virt_runtime_resume(struct drm_encoder *encoder); 100 101 /** 102 * dpu_encoder_init - initialize virtual encoder object 103 * @dev: Pointer to drm device structure 104 * @drm_enc_mode: corresponding DRM_MODE_ENCODER_* constant 105 * @disp_info: Pointer to display information structure 106 * Returns: Pointer to newly created drm encoder 107 */ 108 struct drm_encoder *dpu_encoder_init(struct drm_device *dev, 109 int drm_enc_mode, 110 struct msm_display_info *disp_info); 111 112 /** 113 * dpu_encoder_set_idle_timeout - set the idle timeout for video 114 * and command mode encoders. 115 * @drm_enc: Pointer to previously created drm encoder structure 116 * @idle_timeout: idle timeout duration in milliseconds 117 */ 118 void dpu_encoder_set_idle_timeout(struct drm_encoder *drm_enc, 119 u32 idle_timeout); 120 /** 121 * dpu_encoder_get_linecount - get interface line count for the encoder. 122 * @drm_enc: Pointer to previously created drm encoder structure 123 */ 124 int dpu_encoder_get_linecount(struct drm_encoder *drm_enc); 125 126 /** 127 * dpu_encoder_get_vsync_count - get vsync count for the encoder. 128 * @drm_enc: Pointer to previously created drm encoder structure 129 */ 130 int dpu_encoder_get_vsync_count(struct drm_encoder *drm_enc); 131 132 /** 133 * dpu_encoder_is_widebus_enabled - return bool value if widebus is enabled 134 * @drm_enc: Pointer to previously created drm encoder structure 135 */ 136 bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc); 137 138 /** 139 * dpu_encoder_is_dsc_enabled - indicate whether dsc is enabled 140 * for the encoder. 141 * @drm_enc: Pointer to previously created drm encoder structure 142 */ 143 bool dpu_encoder_is_dsc_enabled(const struct drm_encoder *drm_enc); 144 145 /** 146 * dpu_encoder_get_crc_values_cnt - get number of physical encoders contained 147 * in virtual encoder that can collect CRC values 148 * @drm_enc: Pointer to previously created drm encoder structure 149 * Returns: Number of physical encoders for given drm encoder 150 */ 151 int dpu_encoder_get_crc_values_cnt(const struct drm_encoder *drm_enc); 152 153 /** 154 * dpu_encoder_setup_misr - enable misr calculations 155 * @drm_enc: Pointer to previously created drm encoder structure 156 */ 157 void dpu_encoder_setup_misr(const struct drm_encoder *drm_encoder); 158 159 /** 160 * dpu_encoder_get_crc - get the crc value from interface blocks 161 * @drm_enc: Pointer to previously created drm encoder structure 162 * Returns: 0 on success, error otherwise 163 */ 164 int dpu_encoder_get_crc(const struct drm_encoder *drm_enc, u32 *crcs, int pos); 165 166 /** 167 * dpu_encoder_use_dsc_merge - returns true if the encoder uses DSC merge topology. 168 * @drm_enc: Pointer to previously created drm encoder structure 169 */ 170 bool dpu_encoder_use_dsc_merge(struct drm_encoder *drm_enc); 171 172 /** 173 * dpu_encoder_prepare_wb_job - prepare writeback job for the encoder. 174 * @drm_enc: Pointer to previously created drm encoder structure 175 * @job: Pointer to the current drm writeback job 176 */ 177 void dpu_encoder_prepare_wb_job(struct drm_encoder *drm_enc, 178 struct drm_writeback_job *job); 179 180 /** 181 * dpu_encoder_cleanup_wb_job - cleanup writeback job for the encoder. 182 * @drm_enc: Pointer to previously created drm encoder structure 183 * @job: Pointer to the current drm writeback job 184 */ 185 void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc, 186 struct drm_writeback_job *job); 187 188 /** 189 * dpu_encoder_is_valid_for_commit - check if encode has valid parameters for commit. 190 * @drm_enc: Pointer to drm encoder structure 191 */ 192 bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc); 193 194 #endif /* __DPU_ENCODER_H__ */ 195