Dhaval Patel | 14d46ce | 2017-01-17 16:28:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2017 The Linux Foundation. All rights reserved. |
| 3 | * Copyright (C) 2013 Red Hat |
| 4 | * Author: Rob Clark <robdclark@gmail.com> |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 5 | * |
Dhaval Patel | 14d46ce | 2017-01-17 16:28:12 -0800 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published by |
| 8 | * the Free Software Foundation. |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 9 | * |
Dhaval Patel | 14d46ce | 2017-01-17 16:28:12 -0800 | [diff] [blame] | 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program. If not, see <http://www.gnu.org/licenses/>. |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #ifndef _SDE_CRTC_H_ |
| 20 | #define _SDE_CRTC_H_ |
| 21 | |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 22 | #include <linux/kthread.h> |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 23 | #include "drm_crtc.h" |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 24 | #include "msm_prop.h" |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 25 | #include "sde_fence.h" |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 26 | #include "sde_kms.h" |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 27 | #include "sde_core_perf.h" |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 28 | #include "sde_hw_blk.h" |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 29 | #include "sde_hw_ds.h" |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 30 | |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 31 | #define SDE_CRTC_NAME_SIZE 12 |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 32 | |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 33 | /* define the maximum number of in-flight frame events */ |
Veera Sundaram Sankaran | 675ff62 | 2017-06-21 21:44:46 -0700 | [diff] [blame] | 34 | #define SDE_CRTC_FRAME_EVENT_SIZE 4 |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 35 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 36 | /** |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 37 | * enum sde_crtc_client_type: crtc client type |
| 38 | * @RT_CLIENT: RealTime client like video/cmd mode display |
| 39 | * voting through apps rsc |
| 40 | * @NRT_CLIENT: Non-RealTime client like WB display |
| 41 | * voting through apps rsc |
| 42 | * @RT_RSC_CLIENT: Realtime display RSC voting client |
| 43 | */ |
| 44 | enum sde_crtc_client_type { |
| 45 | RT_CLIENT, |
| 46 | NRT_CLIENT, |
| 47 | RT_RSC_CLIENT, |
| 48 | }; |
| 49 | |
| 50 | /** |
Abhijit Kulkarni | 1b3340c | 2017-06-22 12:39:37 -0700 | [diff] [blame] | 51 | * enum sde_crtc_smmu_state: smmu state |
| 52 | * @ATTACHED: all the context banks are attached. |
| 53 | * @DETACHED: all the context banks are detached. |
| 54 | * @DETACHED_SEC: secure context bank is detached. |
| 55 | * @ATTACH_ALL_REQ: transient state of attaching context banks. |
| 56 | * @DETACH_ALL_REQ: transient state of detaching context banks. |
| 57 | * @DETACH_SEC_REQ: tranisent state of secure context bank is detached |
| 58 | * @ATTACH_SEC_REQ: transient state of attaching secure context bank. |
| 59 | */ |
| 60 | enum sde_crtc_smmu_state { |
| 61 | ATTACHED = 0, |
| 62 | DETACHED, |
| 63 | DETACHED_SEC, |
| 64 | ATTACH_ALL_REQ, |
| 65 | DETACH_ALL_REQ, |
| 66 | DETACH_SEC_REQ, |
| 67 | ATTACH_SEC_REQ, |
| 68 | }; |
| 69 | |
| 70 | /** |
| 71 | * enum sde_crtc_smmu_state_transition_type: state transition type |
| 72 | * @NONE: no pending state transitions |
| 73 | * @PRE_COMMIT: state transitions should be done before processing the commit |
| 74 | * @POST_COMMIT: state transitions to be done after processing the commit. |
| 75 | */ |
| 76 | enum sde_crtc_smmu_state_transition_type { |
| 77 | NONE, |
| 78 | PRE_COMMIT, |
| 79 | POST_COMMIT |
| 80 | }; |
| 81 | |
| 82 | /** |
| 83 | * struct sde_crtc_smmu_state_data: stores the smmu state and transition type |
| 84 | * @state: current state of smmu context banks |
| 85 | * @transition_type: transition request type |
| 86 | * @transition_error: whether there is error while transitioning the state |
| 87 | */ |
| 88 | struct sde_crtc_smmu_state_data { |
| 89 | uint32_t state; |
| 90 | uint32_t transition_type; |
| 91 | uint32_t transition_error; |
| 92 | }; |
| 93 | |
| 94 | /** |
Dhaval Patel | 5023c3c | 2017-08-22 12:40:11 -0700 | [diff] [blame] | 95 | * @connectors : Currently associated drm connectors for retire event |
| 96 | * @num_connectors: Number of associated drm connectors for retire event |
| 97 | * @list: event list |
| 98 | */ |
| 99 | struct sde_crtc_retire_event { |
| 100 | struct drm_connector *connectors[MAX_CONNECTORS]; |
| 101 | int num_connectors; |
| 102 | struct list_head list; |
| 103 | }; |
| 104 | |
| 105 | /** |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 106 | * struct sde_crtc_mixer: stores the map for each virtual pipeline in the CRTC |
| 107 | * @hw_lm: LM HW Driver context |
| 108 | * @hw_ctl: CTL Path HW driver context |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 109 | * @hw_dspp: DSPP HW driver context |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 110 | * @hw_ds: DS HW driver context |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 111 | * @encoder: Encoder attached to this lm & ctl |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 112 | * @mixer_op_mode: mixer blending operation mode |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 113 | * @flush_mask: mixer flush mask for ctl, mixer and pipe |
Clarence Ip | 662698e | 2017-09-12 18:34:16 -0400 | [diff] [blame] | 114 | * @pipe_mask: mixer flush mask for pipe |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 115 | */ |
| 116 | struct sde_crtc_mixer { |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 117 | struct sde_hw_mixer *hw_lm; |
Lloyd Atkinson | c44a52e | 2016-08-16 16:40:17 -0400 | [diff] [blame] | 118 | struct sde_hw_ctl *hw_ctl; |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 119 | struct sde_hw_dspp *hw_dspp; |
| 120 | struct sde_hw_ds *hw_ds; |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 121 | struct drm_encoder *encoder; |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 122 | u32 mixer_op_mode; |
| 123 | u32 flush_mask; |
Clarence Ip | 662698e | 2017-09-12 18:34:16 -0400 | [diff] [blame] | 124 | u32 pipe_mask; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | /** |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 128 | * struct sde_crtc_frame_event: stores crtc frame event for crtc processing |
| 129 | * @work: base work structure |
| 130 | * @crtc: Pointer to crtc handling this event |
| 131 | * @list: event list |
| 132 | * @ts: timestamp at queue entry |
| 133 | * @event: event identifier |
| 134 | */ |
| 135 | struct sde_crtc_frame_event { |
| 136 | struct kthread_work work; |
| 137 | struct drm_crtc *crtc; |
| 138 | struct list_head list; |
| 139 | ktime_t ts; |
| 140 | u32 event; |
| 141 | }; |
| 142 | |
| 143 | /** |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 144 | * struct sde_crtc_event - event callback tracking structure |
| 145 | * @list: Linked list tracking node |
| 146 | * @kt_work: Kthread worker structure |
| 147 | * @sde_crtc: Pointer to associated sde_crtc structure |
| 148 | * @cb_func: Pointer to callback function |
| 149 | * @usr: Pointer to user data to be provided to the callback |
| 150 | */ |
| 151 | struct sde_crtc_event { |
| 152 | struct list_head list; |
| 153 | struct kthread_work kt_work; |
| 154 | void *sde_crtc; |
| 155 | |
Gopikrishnaiah Anandan | b6b401f | 2017-03-14 16:39:49 -0700 | [diff] [blame] | 156 | void (*cb_func)(struct drm_crtc *crtc, void *usr); |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 157 | void *usr; |
| 158 | }; |
| 159 | |
| 160 | /* |
| 161 | * Maximum number of free event structures to cache |
| 162 | */ |
| 163 | #define SDE_CRTC_MAX_EVENT_COUNT 16 |
| 164 | |
| 165 | /** |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 166 | * struct sde_crtc - virtualized CRTC data structure |
| 167 | * @base : Base drm crtc structure |
| 168 | * @name : ASCII description of this crtc |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 169 | * @num_ctls : Number of ctl paths in use |
| 170 | * @num_mixers : Number of mixers in use |
Lloyd Atkinson | 094780d | 2017-04-24 17:25:08 -0400 | [diff] [blame] | 171 | * @mixers_swapped: Whether the mixers have been swapped for left/right update |
| 172 | * especially in the case of DSC Merge. |
Lloyd Atkinson | a9d7e75 | 2017-01-17 16:31:43 -0500 | [diff] [blame] | 173 | * @mixers : List of active mixers |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 174 | * @event : Pointer to last received drm vblank event. If there is a |
| 175 | * pending vblank event, this will be non-null. |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 176 | * @vsync_count : Running count of received vsync events |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 177 | * @drm_requested_vblank : Whether vblanks have been enabled in the encoder |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 178 | * @property_info : Opaque structure for generic property support |
| 179 | * @property_defaults : Array of default values for generic property support |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 180 | * @output_fence : output release fence context |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 181 | * @stage_cfg : H/w mixer stage configuration |
| 182 | * @debugfs_root : Parent of debugfs node |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 183 | * @vblank_cb_count : count of vblank callback since last reset |
Dhaval Patel | d67cf4a | 2017-06-14 18:08:32 -0700 | [diff] [blame] | 184 | * @play_count : frame count between crtc enable and disable |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 185 | * @vblank_cb_time : ktime at vblank count reset |
Lloyd Atkinson | dcb1c4a | 2017-07-27 10:52:09 -0400 | [diff] [blame] | 186 | * @vblank_requested : whether the user has requested vblank events |
Clarence Ip | 7f70ce4 | 2017-03-20 06:53:46 -0700 | [diff] [blame] | 187 | * @suspend : whether or not a suspend operation is in progress |
Lloyd Atkinson | dcb1c4a | 2017-07-27 10:52:09 -0400 | [diff] [blame] | 188 | * @enabled : whether the SDE CRTC is currently enabled. updated in the |
| 189 | * commit-thread, not state-swap time which is earlier, so |
| 190 | * safe to make decisions on during VBLANK on/off work |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 191 | * @feature_list : list of color processing features supported on a crtc |
| 192 | * @active_list : list of color processing features are active |
| 193 | * @dirty_list : list of color processing features are dirty |
Gopikrishnaiah Anandan | 9ba4378 | 2017-01-31 18:23:08 -0800 | [diff] [blame] | 194 | * @ad_dirty: list containing ad properties that are dirty |
| 195 | * @ad_active: list containing ad properties that are active |
Dhaval Patel | 3fbe6bf | 2016-10-20 20:00:41 -0700 | [diff] [blame] | 196 | * @crtc_lock : crtc lock around create, destroy and access. |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 197 | * @frame_pending : Whether or not an update is pending |
| 198 | * @frame_events : static allocation of in-flight frame events |
| 199 | * @frame_event_list : available frame event list |
| 200 | * @spin_lock : spin lock for frame event, transaction status, etc... |
Dhaval Patel | 5023c3c | 2017-08-22 12:40:11 -0700 | [diff] [blame] | 201 | * @retire_events : static allocation of retire fence connector |
| 202 | * @retire_event_list : available retire fence connector list |
Veera Sundaram Sankaran | 7ee9909 | 2017-06-13 11:19:36 -0700 | [diff] [blame] | 203 | * @frame_done_comp : for frame_event_done synchronization |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 204 | * @event_thread : Pointer to event handler thread |
| 205 | * @event_worker : Event worker queue |
| 206 | * @event_cache : Local cache of event worker structures |
| 207 | * @event_free_list : List of available event structures |
| 208 | * @event_lock : Spinlock around event handling code |
Dhaval Patel | f9245d6 | 2017-03-28 16:24:00 -0700 | [diff] [blame] | 209 | * @misr_enable : boolean entry indicates misr enable/disable status. |
Dhaval Patel | 010f517 | 2017-08-01 22:40:09 -0700 | [diff] [blame] | 210 | * @misr_frame_count : misr frame count provided by client |
| 211 | * @misr_data : store misr data before turning off the clocks. |
Clarence Ip | b776b53 | 2017-09-12 18:30:06 -0400 | [diff] [blame] | 212 | * @sbuf_flush_mask: flush mask for inline rotator |
| 213 | * @sbuf_flush_mask_old: inline rotator flush mask for previous commit |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 214 | * @power_event : registered power event handle |
Alan Kwong | 751cf46 | 2017-06-08 10:26:46 -0400 | [diff] [blame] | 215 | * @cur_perf : current performance committed to clock/bandwidth driver |
Alan Kwong | 310e9b0 | 2017-08-03 02:04:07 -0400 | [diff] [blame] | 216 | * @rp_lock : serialization lock for resource pool |
| 217 | * @rp_head : list of active resource pool |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 218 | * @scl3_cfg_lut : qseed3 lut config |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 219 | */ |
| 220 | struct sde_crtc { |
| 221 | struct drm_crtc base; |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 222 | char name[SDE_CRTC_NAME_SIZE]; |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 223 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 224 | /* HW Resources reserved for the crtc */ |
Lloyd Atkinson | c44a52e | 2016-08-16 16:40:17 -0400 | [diff] [blame] | 225 | u32 num_ctls; |
| 226 | u32 num_mixers; |
Lloyd Atkinson | 094780d | 2017-04-24 17:25:08 -0400 | [diff] [blame] | 227 | bool mixers_swapped; |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 228 | struct sde_crtc_mixer mixers[CRTC_DUAL_MIXERS]; |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 229 | struct sde_hw_scaler3_lut_cfg *scl3_lut_cfg; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 230 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 231 | struct drm_pending_vblank_event *event; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 232 | u32 vsync_count; |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 233 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 234 | struct msm_property_info property_info; |
| 235 | struct msm_property_data property_data[CRTC_PROP_COUNT]; |
Dhaval Patel | e4a5dda | 2016-10-13 19:29:30 -0700 | [diff] [blame] | 236 | struct drm_property_blob *blob_info; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 237 | |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 238 | /* output fence support */ |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 239 | struct sde_fence_context output_fence; |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 240 | |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 241 | struct sde_hw_stage_cfg stage_cfg; |
| 242 | struct dentry *debugfs_root; |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 243 | |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 244 | u32 vblank_cb_count; |
Dhaval Patel | d67cf4a | 2017-06-14 18:08:32 -0700 | [diff] [blame] | 245 | u64 play_count; |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 246 | ktime_t vblank_cb_time; |
Lloyd Atkinson | dcb1c4a | 2017-07-27 10:52:09 -0400 | [diff] [blame] | 247 | bool vblank_requested; |
Clarence Ip | 7f70ce4 | 2017-03-20 06:53:46 -0700 | [diff] [blame] | 248 | bool suspend; |
Lloyd Atkinson | dcb1c4a | 2017-07-27 10:52:09 -0400 | [diff] [blame] | 249 | bool enabled; |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 250 | |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 251 | struct list_head feature_list; |
| 252 | struct list_head active_list; |
| 253 | struct list_head dirty_list; |
Gopikrishnaiah Anandan | 9ba4378 | 2017-01-31 18:23:08 -0800 | [diff] [blame] | 254 | struct list_head ad_dirty; |
| 255 | struct list_head ad_active; |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 256 | struct list_head user_event_list; |
Dhaval Patel | 3fbe6bf | 2016-10-20 20:00:41 -0700 | [diff] [blame] | 257 | |
| 258 | struct mutex crtc_lock; |
Xu Yang | 1b3a5d9 | 2017-09-13 11:37:54 +0800 | [diff] [blame] | 259 | struct mutex crtc_cp_lock; |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 260 | |
| 261 | atomic_t frame_pending; |
| 262 | struct sde_crtc_frame_event frame_events[SDE_CRTC_FRAME_EVENT_SIZE]; |
| 263 | struct list_head frame_event_list; |
| 264 | spinlock_t spin_lock; |
Dhaval Patel | 5023c3c | 2017-08-22 12:40:11 -0700 | [diff] [blame] | 265 | struct sde_crtc_retire_event retire_events[SDE_CRTC_FRAME_EVENT_SIZE]; |
| 266 | struct list_head retire_event_list; |
Veera Sundaram Sankaran | 7ee9909 | 2017-06-13 11:19:36 -0700 | [diff] [blame] | 267 | struct completion frame_done_comp; |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 268 | |
| 269 | /* for handling internal event thread */ |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 270 | struct sde_crtc_event event_cache[SDE_CRTC_MAX_EVENT_COUNT]; |
| 271 | struct list_head event_free_list; |
| 272 | spinlock_t event_lock; |
Dhaval Patel | f9245d6 | 2017-03-28 16:24:00 -0700 | [diff] [blame] | 273 | bool misr_enable; |
Dhaval Patel | 010f517 | 2017-08-01 22:40:09 -0700 | [diff] [blame] | 274 | u32 misr_frame_count; |
| 275 | u32 misr_data[CRTC_DUAL_MIXERS]; |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 276 | |
Clarence Ip | b776b53 | 2017-09-12 18:30:06 -0400 | [diff] [blame] | 277 | u32 sbuf_flush_mask; |
| 278 | u32 sbuf_flush_mask_old; |
| 279 | |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 280 | struct sde_power_event *power_event; |
Alan Kwong | 751cf46 | 2017-06-08 10:26:46 -0400 | [diff] [blame] | 281 | |
| 282 | struct sde_core_perf_params cur_perf; |
Alan Kwong | 310e9b0 | 2017-08-03 02:04:07 -0400 | [diff] [blame] | 283 | |
| 284 | struct mutex rp_lock; |
| 285 | struct list_head rp_head; |
Abhijit Kulkarni | 1b3340c | 2017-06-22 12:39:37 -0700 | [diff] [blame] | 286 | |
| 287 | struct sde_crtc_smmu_state_data smmu_state; |
Xu Yang | 5e53c2e | 2017-07-11 16:46:28 +0800 | [diff] [blame] | 288 | |
| 289 | /* blob for histogram data */ |
| 290 | struct drm_property_blob *hist_blob; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | #define to_sde_crtc(x) container_of(x, struct sde_crtc, base) |
| 294 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 295 | /** |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 296 | * struct sde_crtc_res_ops - common operations for crtc resources |
| 297 | * @get: get given resource |
| 298 | * @put: put given resource |
| 299 | */ |
| 300 | struct sde_crtc_res_ops { |
| 301 | void *(*get)(void *val, u32 type, u64 tag); |
| 302 | void (*put)(void *val); |
| 303 | }; |
| 304 | |
| 305 | /* crtc resource type (0x0-0xffff reserved for hw block type */ |
| 306 | #define SDE_CRTC_RES_ROT_OUT_FBO 0x10000 |
| 307 | #define SDE_CRTC_RES_ROT_OUT_FB 0x10001 |
| 308 | #define SDE_CRTC_RES_ROT_PLANE 0x10002 |
| 309 | #define SDE_CRTC_RES_ROT_IN_FB 0x10003 |
| 310 | |
| 311 | #define SDE_CRTC_RES_FLAG_FREE BIT(0) |
| 312 | |
| 313 | /** |
| 314 | * struct sde_crtc_res - definition of crtc resources |
| 315 | * @list: list of crtc resource |
| 316 | * @type: crtc resource type |
| 317 | * @tag: unique identifier per type |
| 318 | * @refcount: reference/usage count |
| 319 | * @ops: callback operations |
| 320 | * @val: resource handle associated with type/tag |
| 321 | * @flags: customization flags |
| 322 | */ |
| 323 | struct sde_crtc_res { |
| 324 | struct list_head list; |
| 325 | u32 type; |
| 326 | u64 tag; |
| 327 | atomic_t refcount; |
| 328 | struct sde_crtc_res_ops ops; |
| 329 | void *val; |
| 330 | u32 flags; |
| 331 | }; |
| 332 | |
| 333 | /** |
| 334 | * sde_crtc_respool - crtc resource pool |
Alan Kwong | 310e9b0 | 2017-08-03 02:04:07 -0400 | [diff] [blame] | 335 | * @rp_lock: pointer to serialization lock |
| 336 | * @rp_head: pointer to head of active resource pools of this crtc |
| 337 | * @rp_list: list of crtc resource pool |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 338 | * @sequence_id: sequence identifier, incremented per state duplication |
| 339 | * @res_list: list of resource managed by this resource pool |
| 340 | * @ops: resource operations for parent resource pool |
| 341 | */ |
| 342 | struct sde_crtc_respool { |
Alan Kwong | 310e9b0 | 2017-08-03 02:04:07 -0400 | [diff] [blame] | 343 | struct mutex *rp_lock; |
| 344 | struct list_head *rp_head; |
| 345 | struct list_head rp_list; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 346 | u32 sequence_id; |
| 347 | struct list_head res_list; |
| 348 | struct sde_crtc_res_ops ops; |
| 349 | }; |
| 350 | |
| 351 | /** |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 352 | * struct sde_crtc_state - sde container for atomic crtc state |
| 353 | * @base: Base drm crtc state structure |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 354 | * @connectors : Currently associated drm connectors |
| 355 | * @num_connectors: Number of associated drm connectors |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 356 | * @rsc_client : sde rsc client when mode is valid |
Lloyd Atkinson | 66e7dde | 2017-02-08 15:52:53 -0500 | [diff] [blame] | 357 | * @is_ppsplit : Whether current topology requires PPSplit special handling |
Alan Kwong | 0230a10 | 2017-05-16 11:36:44 -0700 | [diff] [blame] | 358 | * @bw_control : true if bw/clk controlled by core bw/clk properties |
| 359 | * @bw_split_vote : true if bw controlled by llcc/dram bw properties |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 360 | * @crtc_roi : Current CRTC ROI. Possibly sub-rectangle of mode. |
| 361 | * Origin top left of CRTC. |
Lloyd Atkinson | 73fb809 | 2017-02-08 16:02:55 -0500 | [diff] [blame] | 362 | * @lm_bounds : LM boundaries based on current mode full resolution, no ROI. |
| 363 | * Origin top left of CRTC. |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 364 | * @lm_roi : Current LM ROI, possibly sub-rectangle of mode. |
| 365 | * Origin top left of CRTC. |
| 366 | * @user_roi_list : List of user's requested ROIs as from set property |
Clarence Ip | 4a2955d | 2017-07-04 18:04:33 -0400 | [diff] [blame] | 367 | * @property_state: Local storage for msm_prop properties |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 368 | * @property_values: Current crtc property values |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 369 | * @input_fence_timeout_ns : Cached input fence timeout, in ns |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 370 | * @num_dim_layers: Number of dim layers |
| 371 | * @dim_layer: Dim layer configs |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 372 | * @num_ds: Number of destination scalers to be configured |
| 373 | * @num_ds_enabled: Number of destination scalers enabled |
| 374 | * @ds_dirty: Boolean to indicate if dirty or not |
| 375 | * @ds_cfg: Destination scaler config |
Alan Kwong | 751cf46 | 2017-06-08 10:26:46 -0400 | [diff] [blame] | 376 | * @new_perf: new performance state being requested |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 377 | * @sbuf_cfg: stream buffer configuration |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 378 | * @sbuf_prefill_line: number of line for inline rotator prefetch |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 379 | */ |
| 380 | struct sde_crtc_state { |
| 381 | struct drm_crtc_state base; |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 382 | |
| 383 | struct drm_connector *connectors[MAX_CONNECTORS]; |
| 384 | int num_connectors; |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 385 | struct sde_rsc_client *rsc_client; |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 386 | bool rsc_update; |
Alan Kwong | ff30f4a | 2017-05-23 12:02:00 -0700 | [diff] [blame] | 387 | bool bw_control; |
Alan Kwong | 0230a10 | 2017-05-16 11:36:44 -0700 | [diff] [blame] | 388 | bool bw_split_vote; |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 389 | |
Lloyd Atkinson | 66e7dde | 2017-02-08 15:52:53 -0500 | [diff] [blame] | 390 | bool is_ppsplit; |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 391 | struct sde_rect crtc_roi; |
Lloyd Atkinson | 73fb809 | 2017-02-08 16:02:55 -0500 | [diff] [blame] | 392 | struct sde_rect lm_bounds[CRTC_DUAL_MIXERS]; |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 393 | struct sde_rect lm_roi[CRTC_DUAL_MIXERS]; |
| 394 | struct msm_roi_list user_roi_list; |
Lloyd Atkinson | a9d7e75 | 2017-01-17 16:31:43 -0500 | [diff] [blame] | 395 | |
Clarence Ip | 4a2955d | 2017-07-04 18:04:33 -0400 | [diff] [blame] | 396 | struct msm_property_state property_state; |
| 397 | struct msm_property_value property_values[CRTC_PROP_COUNT]; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 398 | uint64_t input_fence_timeout_ns; |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 399 | uint32_t num_dim_layers; |
| 400 | struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS]; |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 401 | uint32_t num_ds; |
| 402 | uint32_t num_ds_enabled; |
| 403 | bool ds_dirty; |
| 404 | struct sde_hw_ds_cfg ds_cfg[SDE_MAX_DS_COUNT]; |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 405 | |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 406 | struct sde_core_perf_params new_perf; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 407 | struct sde_ctl_sbuf_cfg sbuf_cfg; |
Clarence Ip | 7eb9045 | 2017-05-23 11:41:19 -0400 | [diff] [blame] | 408 | u32 sbuf_prefill_line; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 409 | |
| 410 | struct sde_crtc_respool rp; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 411 | }; |
| 412 | |
Xu Yang | 5e53c2e | 2017-07-11 16:46:28 +0800 | [diff] [blame] | 413 | enum sde_crtc_irq_state { |
| 414 | IRQ_NOINIT, |
| 415 | IRQ_ENABLED, |
| 416 | IRQ_DISABLED, |
| 417 | }; |
| 418 | |
| 419 | /** |
| 420 | * sde_crtc_irq_info - crtc interrupt info |
| 421 | * @irq: interrupt callback |
| 422 | * @event: event type of the interrupt |
| 423 | * @func: function pointer to enable/disable the interrupt |
| 424 | * @list: list of user customized event in crtc |
| 425 | * @ref_count: reference count for the interrupt |
| 426 | */ |
| 427 | struct sde_crtc_irq_info { |
| 428 | struct sde_irq_callback irq; |
| 429 | u32 event; |
| 430 | int (*func)(struct drm_crtc *crtc, bool en, |
| 431 | struct sde_irq_callback *irq); |
| 432 | struct list_head list; |
| 433 | enum sde_crtc_irq_state state; |
| 434 | }; |
| 435 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 436 | #define to_sde_crtc_state(x) \ |
| 437 | container_of(x, struct sde_crtc_state, base) |
| 438 | |
| 439 | /** |
| 440 | * sde_crtc_get_property - query integer value of crtc property |
| 441 | * @S: Pointer to crtc state |
| 442 | * @X: Property index, from enum msm_mdp_crtc_property |
| 443 | * Returns: Integer value of requested property |
| 444 | */ |
| 445 | #define sde_crtc_get_property(S, X) \ |
Clarence Ip | 4a2955d | 2017-07-04 18:04:33 -0400 | [diff] [blame] | 446 | ((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)].value) : 0) |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 447 | |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 448 | /** |
| 449 | * sde_crtc_get_mixer_width - get the mixer width |
| 450 | * Mixer width will be same as panel width(/2 for split) |
| 451 | * unless destination scaler feature is enabled |
| 452 | */ |
| 453 | static inline int sde_crtc_get_mixer_width(struct sde_crtc *sde_crtc, |
| 454 | struct sde_crtc_state *cstate, struct drm_display_mode *mode) |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 455 | { |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 456 | u32 mixer_width; |
| 457 | |
| 458 | if (!sde_crtc || !cstate || !mode) |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 459 | return 0; |
| 460 | |
Sravanthi Kollukuduru | c7bcde9 | 2017-06-16 12:44:39 +0530 | [diff] [blame] | 461 | if (cstate->num_ds_enabled) |
| 462 | mixer_width = cstate->ds_cfg[0].lm_width; |
| 463 | else |
| 464 | mixer_width = (sde_crtc->num_mixers == CRTC_DUAL_MIXERS ? |
| 465 | mode->hdisplay / CRTC_DUAL_MIXERS : mode->hdisplay); |
| 466 | |
| 467 | return mixer_width; |
| 468 | } |
| 469 | |
| 470 | /** |
| 471 | * sde_crtc_get_mixer_height - get the mixer height |
| 472 | * Mixer height will be same as panel height unless |
| 473 | * destination scaler feature is enabled |
| 474 | */ |
| 475 | static inline int sde_crtc_get_mixer_height(struct sde_crtc *sde_crtc, |
| 476 | struct sde_crtc_state *cstate, struct drm_display_mode *mode) |
| 477 | { |
| 478 | if (!sde_crtc || !cstate || !mode) |
| 479 | return 0; |
| 480 | |
| 481 | return (cstate->num_ds_enabled ? |
| 482 | cstate->ds_cfg[0].lm_height : mode->vdisplay); |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 483 | } |
| 484 | |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 485 | /** |
Veera Sundaram Sankaran | c9efbec | 2017-03-29 18:59:05 -0700 | [diff] [blame] | 486 | * sde_crtc_frame_pending - retun the number of pending frames |
| 487 | * @crtc: Pointer to drm crtc object |
| 488 | */ |
| 489 | static inline int sde_crtc_frame_pending(struct drm_crtc *crtc) |
| 490 | { |
| 491 | struct sde_crtc *sde_crtc; |
| 492 | |
| 493 | if (!crtc) |
| 494 | return -EINVAL; |
| 495 | |
| 496 | sde_crtc = to_sde_crtc(crtc); |
| 497 | return atomic_read(&sde_crtc->frame_pending); |
| 498 | } |
| 499 | |
| 500 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 501 | * sde_crtc_vblank - enable or disable vblanks for this crtc |
| 502 | * @crtc: Pointer to drm crtc object |
| 503 | * @en: true to enable vblanks, false to disable |
| 504 | */ |
| 505 | int sde_crtc_vblank(struct drm_crtc *crtc, bool en); |
| 506 | |
| 507 | /** |
| 508 | * sde_crtc_commit_kickoff - trigger kickoff of the commit for this crtc |
| 509 | * @crtc: Pointer to drm crtc object |
| 510 | */ |
| 511 | void sde_crtc_commit_kickoff(struct drm_crtc *crtc); |
| 512 | |
| 513 | /** |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 514 | * sde_crtc_prepare_commit - callback to prepare for output fences |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 515 | * @crtc: Pointer to drm crtc object |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 516 | * @old_state: Pointer to drm crtc old state object |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 517 | */ |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 518 | void sde_crtc_prepare_commit(struct drm_crtc *crtc, |
| 519 | struct drm_crtc_state *old_state); |
| 520 | |
| 521 | /** |
Abhijit Kulkarni | 1b3340c | 2017-06-22 12:39:37 -0700 | [diff] [blame] | 522 | * sde_crtc_complete_commit - callback signalling completion of current commit |
| 523 | * @crtc: Pointer to drm crtc object |
| 524 | * @old_state: Pointer to drm crtc old state object |
| 525 | */ |
| 526 | void sde_crtc_complete_commit(struct drm_crtc *crtc, |
| 527 | struct drm_crtc_state *old_state); |
| 528 | |
| 529 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 530 | * sde_crtc_init - create a new crtc object |
| 531 | * @dev: sde device |
| 532 | * @plane: base plane |
| 533 | * @Return: new crtc object or error |
| 534 | */ |
| 535 | struct drm_crtc *sde_crtc_init(struct drm_device *dev, struct drm_plane *plane); |
| 536 | |
| 537 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 538 | * sde_crtc_cancel_pending_flip - complete flip for clients on lastclose |
| 539 | * @crtc: Pointer to drm crtc object |
| 540 | * @file: client to cancel's file handle |
| 541 | */ |
| 542 | void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file); |
| 543 | |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 544 | /** |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 545 | * sde_crtc_register_custom_event - api for enabling/disabling crtc event |
| 546 | * @kms: Pointer to sde_kms |
| 547 | * @crtc_drm: Pointer to crtc object |
| 548 | * @event: Event that client is interested |
| 549 | * @en: Flag to enable/disable the event |
| 550 | */ |
| 551 | int sde_crtc_register_custom_event(struct sde_kms *kms, |
| 552 | struct drm_crtc *crtc_drm, u32 event, bool en); |
| 553 | |
| 554 | /** |
| 555 | * sde_crtc_get_intf_mode - get interface mode of the given crtc |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 556 | * @crtc: Pointert to crtc |
| 557 | */ |
Alan Kwong | 3e985f0 | 2017-02-12 15:08:44 -0800 | [diff] [blame] | 558 | enum sde_intf_mode sde_crtc_get_intf_mode(struct drm_crtc *crtc); |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 559 | |
| 560 | /** |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 561 | * sde_crtc_get_client_type - check the crtc type- rt, nrt, rsc, etc. |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 562 | * @crtc: Pointer to crtc |
| 563 | */ |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 564 | static inline enum sde_crtc_client_type sde_crtc_get_client_type( |
| 565 | struct drm_crtc *crtc) |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 566 | { |
| 567 | struct sde_crtc_state *cstate = |
| 568 | crtc ? to_sde_crtc_state(crtc->state) : NULL; |
| 569 | |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 570 | if (!cstate) |
| 571 | return NRT_CLIENT; |
| 572 | |
Alan Kwong | fcb5743 | 2017-09-14 17:48:11 -0400 | [diff] [blame] | 573 | return sde_crtc_get_intf_mode(crtc) == INTF_MODE_WB_LINE ? NRT_CLIENT : |
| 574 | (cstate->rsc_client ? RT_RSC_CLIENT : RT_CLIENT); |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | /** |
| 578 | * sde_crtc_is_enabled - check if sde crtc is enabled or not |
| 579 | * @crtc: Pointer to crtc |
| 580 | */ |
| 581 | static inline bool sde_crtc_is_enabled(struct drm_crtc *crtc) |
| 582 | { |
| 583 | return crtc ? crtc->enabled : false; |
| 584 | } |
| 585 | |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 586 | /** |
Alan Kwong | 56f1a94 | 2017-04-04 11:53:42 -0700 | [diff] [blame] | 587 | * sde_crtc_get_inline_prefill - get current inline rotation prefill |
| 588 | * @crtc: Pointer to crtc |
| 589 | * return: number of prefill lines |
| 590 | */ |
| 591 | static inline u32 sde_crtc_get_inline_prefill(struct drm_crtc *crtc) |
| 592 | { |
Clarence Ip | 7eb9045 | 2017-05-23 11:41:19 -0400 | [diff] [blame] | 593 | struct sde_crtc_state *cstate; |
| 594 | |
Alan Kwong | 56f1a94 | 2017-04-04 11:53:42 -0700 | [diff] [blame] | 595 | if (!crtc || !crtc->state) |
| 596 | return 0; |
| 597 | |
Clarence Ip | 7eb9045 | 2017-05-23 11:41:19 -0400 | [diff] [blame] | 598 | cstate = to_sde_crtc_state(crtc->state); |
| 599 | return cstate->sbuf_cfg.rot_op_mode != SDE_CTL_ROT_OP_MODE_OFFLINE ? |
| 600 | cstate->sbuf_prefill_line : 0; |
Alan Kwong | 56f1a94 | 2017-04-04 11:53:42 -0700 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | /** |
Veera Sundaram Sankaran | db43e28 | 2017-09-19 18:32:52 -0700 | [diff] [blame] | 604 | * sde_crtc_is_reset_required - validate the reset request based on the |
| 605 | * pm_suspend and crtc's active status. crtc's are left active |
| 606 | * on pm_suspend during LP1/LP2 states, as the display is still |
| 607 | * left ON. Avoid reset for the subsequent pm_resume in such cases. |
| 608 | * @crtc: Pointer to crtc |
| 609 | * return: false if in suspend state and crtc active, true otherwise |
| 610 | */ |
| 611 | static inline bool sde_crtc_is_reset_required(struct drm_crtc *crtc) |
| 612 | { |
| 613 | /* |
| 614 | * reset is required even when there is no crtc_state as it is required |
| 615 | * to create the initial state object |
| 616 | */ |
| 617 | if (!crtc || !crtc->state) |
| 618 | return true; |
| 619 | |
| 620 | /* reset not required if crtc is active during suspend state */ |
| 621 | if (sde_kms_is_suspend_state(crtc->dev) && crtc->state->active) |
| 622 | return false; |
| 623 | |
| 624 | return true; |
| 625 | } |
| 626 | |
| 627 | /** |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 628 | * sde_crtc_event_queue - request event callback |
| 629 | * @crtc: Pointer to drm crtc structure |
| 630 | * @func: Pointer to callback function |
| 631 | * @usr: Pointer to user data to be passed to callback |
| 632 | * Returns: Zero on success |
| 633 | */ |
| 634 | int sde_crtc_event_queue(struct drm_crtc *crtc, |
Gopikrishnaiah Anandan | b6b401f | 2017-03-14 16:39:49 -0700 | [diff] [blame] | 635 | void (*func)(struct drm_crtc *crtc, void *usr), void *usr); |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 636 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 637 | /** |
| 638 | * sde_crtc_res_add - add given resource to resource pool in crtc state |
| 639 | * @state: Pointer to drm crtc state |
| 640 | * @type: Resource type |
| 641 | * @tag: Search tag for given resource |
| 642 | * @val: Resource handle |
| 643 | * @ops: Resource callback operations |
| 644 | * return: 0 if success; error code otherwise |
| 645 | */ |
| 646 | int sde_crtc_res_add(struct drm_crtc_state *state, u32 type, u64 tag, |
| 647 | void *val, struct sde_crtc_res_ops *ops); |
| 648 | |
| 649 | /** |
| 650 | * sde_crtc_res_get - get given resource from resource pool in crtc state |
| 651 | * @state: Pointer to drm crtc state |
| 652 | * @type: Resource type |
| 653 | * @tag: Search tag for given resource |
| 654 | * return: Resource handle if success; pointer error or null otherwise |
| 655 | */ |
| 656 | void *sde_crtc_res_get(struct drm_crtc_state *state, u32 type, u64 tag); |
| 657 | |
| 658 | /** |
| 659 | * sde_crtc_res_put - return given resource to resource pool in crtc state |
| 660 | * @state: Pointer to drm crtc state |
| 661 | * @type: Resource type |
| 662 | * @tag: Search tag for given resource |
| 663 | * return: None |
| 664 | */ |
| 665 | void sde_crtc_res_put(struct drm_crtc_state *state, u32 type, u64 tag); |
| 666 | |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 667 | /** |
| 668 | * sde_crtc_get_crtc_roi - retrieve the crtc_roi from the given state object |
| 669 | * used to allow the planes to adjust their final lm out_xy value in the |
| 670 | * case of partial update |
| 671 | * @crtc_state: Pointer to crtc state |
| 672 | * @crtc_roi: Output pointer to crtc roi in the given state |
| 673 | */ |
| 674 | void sde_crtc_get_crtc_roi(struct drm_crtc_state *state, |
| 675 | const struct sde_rect **crtc_roi); |
| 676 | |
Abhijit Kulkarni | 7444a7d | 2017-06-21 18:53:36 -0700 | [diff] [blame] | 677 | /** sde_crt_get_secure_level - retrieve the secure level from the give state |
| 678 | * object, this is used to determine the secure state of the crtc |
| 679 | * @crtc : Pointer to drm crtc structure |
| 680 | * @usr: Pointer to drm crtc state |
| 681 | * return: secure_level |
| 682 | */ |
| 683 | static inline int sde_crtc_get_secure_level(struct drm_crtc *crtc, |
| 684 | struct drm_crtc_state *state) |
| 685 | { |
| 686 | if (!crtc || !state) |
| 687 | return -EINVAL; |
| 688 | |
| 689 | return sde_crtc_get_property(to_sde_crtc_state(state), |
| 690 | CRTC_PROP_SECURITY_LEVEL); |
| 691 | } |
| 692 | |
Abhijit Kulkarni | 1b3340c | 2017-06-22 12:39:37 -0700 | [diff] [blame] | 693 | /** |
| 694 | * sde_crtc_get_secure_transition - determines the operations to be |
| 695 | * performed before transitioning to secure state |
| 696 | * This function should be called after swapping the new state |
| 697 | * @crtc: Pointer to drm crtc structure |
| 698 | * @old_crtc_state: Poniter to previous CRTC state |
| 699 | * Returns the bitmask of operations need to be performed, -Error in |
| 700 | * case of error cases |
| 701 | */ |
| 702 | int sde_crtc_get_secure_transition_ops(struct drm_crtc *crtc, |
| 703 | struct drm_crtc_state *old_crtc_state, |
| 704 | bool old_valid_fb); |
| 705 | |
| 706 | /** |
| 707 | * sde_crtc_secure_ctrl - Initiates the transition between secure and |
| 708 | * non-secure world |
| 709 | * @crtc: Pointer to crtc |
| 710 | * @post_commit: if this operation is triggered after commit |
| 711 | */ |
| 712 | int sde_crtc_secure_ctrl(struct drm_crtc *crtc, bool post_commit); |
Abhijit Kulkarni | 7444a7d | 2017-06-21 18:53:36 -0700 | [diff] [blame] | 713 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 714 | #endif /* _SDE_CRTC_H_ */ |