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" |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 29 | |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 30 | #define SDE_CRTC_NAME_SIZE 12 |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 31 | |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 32 | /* define the maximum number of in-flight frame events */ |
Veera Sundaram Sankaran | 675ff62 | 2017-06-21 21:44:46 -0700 | [diff] [blame] | 33 | #define SDE_CRTC_FRAME_EVENT_SIZE 4 |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 34 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 35 | /** |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 36 | * enum sde_crtc_client_type: crtc client type |
| 37 | * @RT_CLIENT: RealTime client like video/cmd mode display |
| 38 | * voting through apps rsc |
| 39 | * @NRT_CLIENT: Non-RealTime client like WB display |
| 40 | * voting through apps rsc |
| 41 | * @RT_RSC_CLIENT: Realtime display RSC voting client |
| 42 | */ |
| 43 | enum sde_crtc_client_type { |
| 44 | RT_CLIENT, |
| 45 | NRT_CLIENT, |
| 46 | RT_RSC_CLIENT, |
| 47 | }; |
| 48 | |
| 49 | /** |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 50 | * struct sde_crtc_mixer: stores the map for each virtual pipeline in the CRTC |
| 51 | * @hw_lm: LM HW Driver context |
| 52 | * @hw_ctl: CTL Path HW driver context |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 53 | * @hw_dspp: DSPP HW driver context |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 54 | * @encoder: Encoder attached to this lm & ctl |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 55 | * @mixer_op_mode: mixer blending operation mode |
| 56 | * @flush_mask: mixer flush mask for ctl, mixer and pipe |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 57 | */ |
| 58 | struct sde_crtc_mixer { |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 59 | struct sde_hw_mixer *hw_lm; |
Lloyd Atkinson | c44a52e | 2016-08-16 16:40:17 -0400 | [diff] [blame] | 60 | struct sde_hw_ctl *hw_ctl; |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 61 | struct sde_hw_dspp *hw_dspp; |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 62 | struct drm_encoder *encoder; |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 63 | u32 mixer_op_mode; |
| 64 | u32 flush_mask; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | /** |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 68 | * struct sde_crtc_frame_event: stores crtc frame event for crtc processing |
| 69 | * @work: base work structure |
| 70 | * @crtc: Pointer to crtc handling this event |
| 71 | * @list: event list |
| 72 | * @ts: timestamp at queue entry |
| 73 | * @event: event identifier |
| 74 | */ |
| 75 | struct sde_crtc_frame_event { |
| 76 | struct kthread_work work; |
| 77 | struct drm_crtc *crtc; |
| 78 | struct list_head list; |
| 79 | ktime_t ts; |
| 80 | u32 event; |
| 81 | }; |
| 82 | |
| 83 | /** |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 84 | * struct sde_crtc_event - event callback tracking structure |
| 85 | * @list: Linked list tracking node |
| 86 | * @kt_work: Kthread worker structure |
| 87 | * @sde_crtc: Pointer to associated sde_crtc structure |
| 88 | * @cb_func: Pointer to callback function |
| 89 | * @usr: Pointer to user data to be provided to the callback |
| 90 | */ |
| 91 | struct sde_crtc_event { |
| 92 | struct list_head list; |
| 93 | struct kthread_work kt_work; |
| 94 | void *sde_crtc; |
| 95 | |
Gopikrishnaiah Anandan | b6b401f | 2017-03-14 16:39:49 -0700 | [diff] [blame] | 96 | void (*cb_func)(struct drm_crtc *crtc, void *usr); |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 97 | void *usr; |
| 98 | }; |
| 99 | |
| 100 | /* |
| 101 | * Maximum number of free event structures to cache |
| 102 | */ |
| 103 | #define SDE_CRTC_MAX_EVENT_COUNT 16 |
| 104 | |
| 105 | /** |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 106 | * struct sde_crtc - virtualized CRTC data structure |
| 107 | * @base : Base drm crtc structure |
| 108 | * @name : ASCII description of this crtc |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 109 | * @num_ctls : Number of ctl paths in use |
| 110 | * @num_mixers : Number of mixers in use |
Lloyd Atkinson | 094780d | 2017-04-24 17:25:08 -0400 | [diff] [blame] | 111 | * @mixers_swapped: Whether the mixers have been swapped for left/right update |
| 112 | * especially in the case of DSC Merge. |
Lloyd Atkinson | a9d7e75 | 2017-01-17 16:31:43 -0500 | [diff] [blame] | 113 | * @mixers : List of active mixers |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 114 | * @event : Pointer to last received drm vblank event. If there is a |
| 115 | * pending vblank event, this will be non-null. |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 116 | * @vsync_count : Running count of received vsync events |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 117 | * @drm_requested_vblank : Whether vblanks have been enabled in the encoder |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 118 | * @property_info : Opaque structure for generic property support |
| 119 | * @property_defaults : Array of default values for generic property support |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 120 | * @output_fence : output release fence context |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 121 | * @stage_cfg : H/w mixer stage configuration |
| 122 | * @debugfs_root : Parent of debugfs node |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 123 | * @vblank_cb_count : count of vblank callback since last reset |
Dhaval Patel | d67cf4a | 2017-06-14 18:08:32 -0700 | [diff] [blame] | 124 | * @play_count : frame count between crtc enable and disable |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 125 | * @vblank_cb_time : ktime at vblank count reset |
Lloyd Atkinson | dcb1c4a | 2017-07-27 10:52:09 -0400 | [diff] [blame] | 126 | * @vblank_requested : whether the user has requested vblank events |
Clarence Ip | 7f70ce4 | 2017-03-20 06:53:46 -0700 | [diff] [blame] | 127 | * @suspend : whether or not a suspend operation is in progress |
Lloyd Atkinson | dcb1c4a | 2017-07-27 10:52:09 -0400 | [diff] [blame] | 128 | * @enabled : whether the SDE CRTC is currently enabled. updated in the |
| 129 | * commit-thread, not state-swap time which is earlier, so |
| 130 | * safe to make decisions on during VBLANK on/off work |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 131 | * @feature_list : list of color processing features supported on a crtc |
| 132 | * @active_list : list of color processing features are active |
| 133 | * @dirty_list : list of color processing features are dirty |
Gopikrishnaiah Anandan | 9ba4378 | 2017-01-31 18:23:08 -0800 | [diff] [blame] | 134 | * @ad_dirty: list containing ad properties that are dirty |
| 135 | * @ad_active: list containing ad properties that are active |
Dhaval Patel | 3fbe6bf | 2016-10-20 20:00:41 -0700 | [diff] [blame] | 136 | * @crtc_lock : crtc lock around create, destroy and access. |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 137 | * @frame_pending : Whether or not an update is pending |
| 138 | * @frame_events : static allocation of in-flight frame events |
| 139 | * @frame_event_list : available frame event list |
| 140 | * @spin_lock : spin lock for frame event, transaction status, etc... |
Veera Sundaram Sankaran | 7ee9909 | 2017-06-13 11:19:36 -0700 | [diff] [blame] | 141 | * @frame_done_comp : for frame_event_done synchronization |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 142 | * @event_thread : Pointer to event handler thread |
| 143 | * @event_worker : Event worker queue |
| 144 | * @event_cache : Local cache of event worker structures |
| 145 | * @event_free_list : List of available event structures |
| 146 | * @event_lock : Spinlock around event handling code |
Dhaval Patel | f9245d6 | 2017-03-28 16:24:00 -0700 | [diff] [blame] | 147 | * @misr_enable : boolean entry indicates misr enable/disable status. |
Dhaval Patel | 010f517 | 2017-08-01 22:40:09 -0700 | [diff] [blame] | 148 | * @misr_frame_count : misr frame count provided by client |
| 149 | * @misr_data : store misr data before turning off the clocks. |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 150 | * @power_event : registered power event handle |
Alan Kwong | 751cf46 | 2017-06-08 10:26:46 -0400 | [diff] [blame] | 151 | * @cur_perf : current performance committed to clock/bandwidth driver |
Alan Kwong | 310e9b0 | 2017-08-03 02:04:07 -0400 | [diff] [blame] | 152 | * @rp_lock : serialization lock for resource pool |
| 153 | * @rp_head : list of active resource pool |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 154 | */ |
| 155 | struct sde_crtc { |
| 156 | struct drm_crtc base; |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 157 | char name[SDE_CRTC_NAME_SIZE]; |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 158 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 159 | /* HW Resources reserved for the crtc */ |
Lloyd Atkinson | c44a52e | 2016-08-16 16:40:17 -0400 | [diff] [blame] | 160 | u32 num_ctls; |
| 161 | u32 num_mixers; |
Lloyd Atkinson | 094780d | 2017-04-24 17:25:08 -0400 | [diff] [blame] | 162 | bool mixers_swapped; |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 163 | struct sde_crtc_mixer mixers[CRTC_DUAL_MIXERS]; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 164 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 165 | struct drm_pending_vblank_event *event; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 166 | u32 vsync_count; |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 167 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 168 | struct msm_property_info property_info; |
| 169 | struct msm_property_data property_data[CRTC_PROP_COUNT]; |
Dhaval Patel | e4a5dda | 2016-10-13 19:29:30 -0700 | [diff] [blame] | 170 | struct drm_property_blob *blob_info; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 171 | |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 172 | /* output fence support */ |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 173 | struct sde_fence_context output_fence; |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 174 | |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 175 | struct sde_hw_stage_cfg stage_cfg; |
| 176 | struct dentry *debugfs_root; |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 177 | |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 178 | u32 vblank_cb_count; |
Dhaval Patel | d67cf4a | 2017-06-14 18:08:32 -0700 | [diff] [blame] | 179 | u64 play_count; |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 180 | ktime_t vblank_cb_time; |
Lloyd Atkinson | dcb1c4a | 2017-07-27 10:52:09 -0400 | [diff] [blame] | 181 | bool vblank_requested; |
Clarence Ip | 7f70ce4 | 2017-03-20 06:53:46 -0700 | [diff] [blame] | 182 | bool suspend; |
Lloyd Atkinson | dcb1c4a | 2017-07-27 10:52:09 -0400 | [diff] [blame] | 183 | bool enabled; |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 184 | |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 185 | struct list_head feature_list; |
| 186 | struct list_head active_list; |
| 187 | struct list_head dirty_list; |
Gopikrishnaiah Anandan | 9ba4378 | 2017-01-31 18:23:08 -0800 | [diff] [blame] | 188 | struct list_head ad_dirty; |
| 189 | struct list_head ad_active; |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 190 | struct list_head user_event_list; |
Dhaval Patel | 3fbe6bf | 2016-10-20 20:00:41 -0700 | [diff] [blame] | 191 | |
| 192 | struct mutex crtc_lock; |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 193 | |
| 194 | atomic_t frame_pending; |
| 195 | struct sde_crtc_frame_event frame_events[SDE_CRTC_FRAME_EVENT_SIZE]; |
| 196 | struct list_head frame_event_list; |
| 197 | spinlock_t spin_lock; |
Veera Sundaram Sankaran | 7ee9909 | 2017-06-13 11:19:36 -0700 | [diff] [blame] | 198 | struct completion frame_done_comp; |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 199 | |
| 200 | /* for handling internal event thread */ |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 201 | struct sde_crtc_event event_cache[SDE_CRTC_MAX_EVENT_COUNT]; |
| 202 | struct list_head event_free_list; |
| 203 | spinlock_t event_lock; |
Dhaval Patel | f9245d6 | 2017-03-28 16:24:00 -0700 | [diff] [blame] | 204 | bool misr_enable; |
Dhaval Patel | 010f517 | 2017-08-01 22:40:09 -0700 | [diff] [blame] | 205 | u32 misr_frame_count; |
| 206 | u32 misr_data[CRTC_DUAL_MIXERS]; |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 207 | |
| 208 | struct sde_power_event *power_event; |
Alan Kwong | 751cf46 | 2017-06-08 10:26:46 -0400 | [diff] [blame] | 209 | |
| 210 | struct sde_core_perf_params cur_perf; |
Alan Kwong | 310e9b0 | 2017-08-03 02:04:07 -0400 | [diff] [blame] | 211 | |
| 212 | struct mutex rp_lock; |
| 213 | struct list_head rp_head; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 214 | }; |
| 215 | |
| 216 | #define to_sde_crtc(x) container_of(x, struct sde_crtc, base) |
| 217 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 218 | /** |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 219 | * struct sde_crtc_res_ops - common operations for crtc resources |
| 220 | * @get: get given resource |
| 221 | * @put: put given resource |
| 222 | */ |
| 223 | struct sde_crtc_res_ops { |
| 224 | void *(*get)(void *val, u32 type, u64 tag); |
| 225 | void (*put)(void *val); |
| 226 | }; |
| 227 | |
| 228 | /* crtc resource type (0x0-0xffff reserved for hw block type */ |
| 229 | #define SDE_CRTC_RES_ROT_OUT_FBO 0x10000 |
| 230 | #define SDE_CRTC_RES_ROT_OUT_FB 0x10001 |
| 231 | #define SDE_CRTC_RES_ROT_PLANE 0x10002 |
| 232 | #define SDE_CRTC_RES_ROT_IN_FB 0x10003 |
| 233 | |
| 234 | #define SDE_CRTC_RES_FLAG_FREE BIT(0) |
| 235 | |
| 236 | /** |
| 237 | * struct sde_crtc_res - definition of crtc resources |
| 238 | * @list: list of crtc resource |
| 239 | * @type: crtc resource type |
| 240 | * @tag: unique identifier per type |
| 241 | * @refcount: reference/usage count |
| 242 | * @ops: callback operations |
| 243 | * @val: resource handle associated with type/tag |
| 244 | * @flags: customization flags |
| 245 | */ |
| 246 | struct sde_crtc_res { |
| 247 | struct list_head list; |
| 248 | u32 type; |
| 249 | u64 tag; |
| 250 | atomic_t refcount; |
| 251 | struct sde_crtc_res_ops ops; |
| 252 | void *val; |
| 253 | u32 flags; |
| 254 | }; |
| 255 | |
| 256 | /** |
| 257 | * sde_crtc_respool - crtc resource pool |
Alan Kwong | 310e9b0 | 2017-08-03 02:04:07 -0400 | [diff] [blame] | 258 | * @rp_lock: pointer to serialization lock |
| 259 | * @rp_head: pointer to head of active resource pools of this crtc |
| 260 | * @rp_list: list of crtc resource pool |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 261 | * @sequence_id: sequence identifier, incremented per state duplication |
| 262 | * @res_list: list of resource managed by this resource pool |
| 263 | * @ops: resource operations for parent resource pool |
| 264 | */ |
| 265 | struct sde_crtc_respool { |
Alan Kwong | 310e9b0 | 2017-08-03 02:04:07 -0400 | [diff] [blame] | 266 | struct mutex *rp_lock; |
| 267 | struct list_head *rp_head; |
| 268 | struct list_head rp_list; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 269 | u32 sequence_id; |
| 270 | struct list_head res_list; |
| 271 | struct sde_crtc_res_ops ops; |
| 272 | }; |
| 273 | |
| 274 | /** |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 275 | * struct sde_crtc_state - sde container for atomic crtc state |
| 276 | * @base: Base drm crtc state structure |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 277 | * @connectors : Currently associated drm connectors |
| 278 | * @num_connectors: Number of associated drm connectors |
Alan Kwong | 67a3f79 | 2016-11-01 23:16:53 -0400 | [diff] [blame] | 279 | * @intf_mode : Interface mode of the primary connector |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 280 | * @rsc_client : sde rsc client when mode is valid |
Lloyd Atkinson | 66e7dde | 2017-02-08 15:52:53 -0500 | [diff] [blame] | 281 | * @is_ppsplit : Whether current topology requires PPSplit special handling |
Alan Kwong | 0230a10 | 2017-05-16 11:36:44 -0700 | [diff] [blame] | 282 | * @bw_control : true if bw/clk controlled by core bw/clk properties |
| 283 | * @bw_split_vote : true if bw controlled by llcc/dram bw properties |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 284 | * @crtc_roi : Current CRTC ROI. Possibly sub-rectangle of mode. |
| 285 | * Origin top left of CRTC. |
Lloyd Atkinson | 73fb809 | 2017-02-08 16:02:55 -0500 | [diff] [blame] | 286 | * @lm_bounds : LM boundaries based on current mode full resolution, no ROI. |
| 287 | * Origin top left of CRTC. |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 288 | * @lm_roi : Current LM ROI, possibly sub-rectangle of mode. |
| 289 | * Origin top left of CRTC. |
| 290 | * @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] | 291 | * @property_state: Local storage for msm_prop properties |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 292 | * @property_values: Current crtc property values |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 293 | * @input_fence_timeout_ns : Cached input fence timeout, in ns |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 294 | * @num_dim_layers: Number of dim layers |
| 295 | * @dim_layer: Dim layer configs |
Alan Kwong | 751cf46 | 2017-06-08 10:26:46 -0400 | [diff] [blame] | 296 | * @new_perf: new performance state being requested |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 297 | * @sbuf_cfg: stream buffer configuration |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 298 | * @sbuf_prefill_line: number of line for inline rotator prefetch |
Clarence Ip | 7e5f000 | 2017-05-29 18:46:56 -0400 | [diff] [blame] | 299 | * @sbuf_flush_mask: flush mask for inline rotator |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 300 | */ |
| 301 | struct sde_crtc_state { |
| 302 | struct drm_crtc_state base; |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 303 | |
| 304 | struct drm_connector *connectors[MAX_CONNECTORS]; |
| 305 | int num_connectors; |
Alan Kwong | 67a3f79 | 2016-11-01 23:16:53 -0400 | [diff] [blame] | 306 | enum sde_intf_mode intf_mode; |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 307 | struct sde_rsc_client *rsc_client; |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 308 | bool rsc_update; |
Alan Kwong | ff30f4a | 2017-05-23 12:02:00 -0700 | [diff] [blame] | 309 | bool bw_control; |
Alan Kwong | 0230a10 | 2017-05-16 11:36:44 -0700 | [diff] [blame] | 310 | bool bw_split_vote; |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 311 | |
Lloyd Atkinson | 66e7dde | 2017-02-08 15:52:53 -0500 | [diff] [blame] | 312 | bool is_ppsplit; |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 313 | struct sde_rect crtc_roi; |
Lloyd Atkinson | 73fb809 | 2017-02-08 16:02:55 -0500 | [diff] [blame] | 314 | struct sde_rect lm_bounds[CRTC_DUAL_MIXERS]; |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 315 | struct sde_rect lm_roi[CRTC_DUAL_MIXERS]; |
| 316 | struct msm_roi_list user_roi_list; |
Lloyd Atkinson | a9d7e75 | 2017-01-17 16:31:43 -0500 | [diff] [blame] | 317 | |
Clarence Ip | 4a2955d | 2017-07-04 18:04:33 -0400 | [diff] [blame] | 318 | struct msm_property_state property_state; |
| 319 | struct msm_property_value property_values[CRTC_PROP_COUNT]; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 320 | uint64_t input_fence_timeout_ns; |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 321 | uint32_t num_dim_layers; |
| 322 | struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS]; |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 323 | |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 324 | struct sde_core_perf_params new_perf; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 325 | struct sde_ctl_sbuf_cfg sbuf_cfg; |
Clarence Ip | 7eb9045 | 2017-05-23 11:41:19 -0400 | [diff] [blame] | 326 | u32 sbuf_prefill_line; |
Clarence Ip | 7e5f000 | 2017-05-29 18:46:56 -0400 | [diff] [blame] | 327 | u32 sbuf_flush_mask; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 328 | |
| 329 | struct sde_crtc_respool rp; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 330 | }; |
| 331 | |
| 332 | #define to_sde_crtc_state(x) \ |
| 333 | container_of(x, struct sde_crtc_state, base) |
| 334 | |
| 335 | /** |
| 336 | * sde_crtc_get_property - query integer value of crtc property |
| 337 | * @S: Pointer to crtc state |
| 338 | * @X: Property index, from enum msm_mdp_crtc_property |
| 339 | * Returns: Integer value of requested property |
| 340 | */ |
| 341 | #define sde_crtc_get_property(S, X) \ |
Clarence Ip | 4a2955d | 2017-07-04 18:04:33 -0400 | [diff] [blame] | 342 | ((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)].value) : 0) |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 343 | |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 344 | static inline int sde_crtc_mixer_width(struct sde_crtc *sde_crtc, |
| 345 | struct drm_display_mode *mode) |
| 346 | { |
| 347 | if (!sde_crtc || !mode) |
| 348 | return 0; |
| 349 | |
| 350 | return sde_crtc->num_mixers == CRTC_DUAL_MIXERS ? |
| 351 | mode->hdisplay / CRTC_DUAL_MIXERS : mode->hdisplay; |
| 352 | } |
| 353 | |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 354 | /** |
Veera Sundaram Sankaran | c9efbec | 2017-03-29 18:59:05 -0700 | [diff] [blame] | 355 | * sde_crtc_frame_pending - retun the number of pending frames |
| 356 | * @crtc: Pointer to drm crtc object |
| 357 | */ |
| 358 | static inline int sde_crtc_frame_pending(struct drm_crtc *crtc) |
| 359 | { |
| 360 | struct sde_crtc *sde_crtc; |
| 361 | |
| 362 | if (!crtc) |
| 363 | return -EINVAL; |
| 364 | |
| 365 | sde_crtc = to_sde_crtc(crtc); |
| 366 | return atomic_read(&sde_crtc->frame_pending); |
| 367 | } |
| 368 | |
| 369 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 370 | * sde_crtc_vblank - enable or disable vblanks for this crtc |
| 371 | * @crtc: Pointer to drm crtc object |
| 372 | * @en: true to enable vblanks, false to disable |
| 373 | */ |
| 374 | int sde_crtc_vblank(struct drm_crtc *crtc, bool en); |
| 375 | |
| 376 | /** |
| 377 | * sde_crtc_commit_kickoff - trigger kickoff of the commit for this crtc |
| 378 | * @crtc: Pointer to drm crtc object |
| 379 | */ |
| 380 | void sde_crtc_commit_kickoff(struct drm_crtc *crtc); |
| 381 | |
| 382 | /** |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 383 | * sde_crtc_prepare_commit - callback to prepare for output fences |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 384 | * @crtc: Pointer to drm crtc object |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 385 | * @old_state: Pointer to drm crtc old state object |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 386 | */ |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 387 | void sde_crtc_prepare_commit(struct drm_crtc *crtc, |
| 388 | struct drm_crtc_state *old_state); |
| 389 | |
| 390 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 391 | * sde_crtc_init - create a new crtc object |
| 392 | * @dev: sde device |
| 393 | * @plane: base plane |
| 394 | * @Return: new crtc object or error |
| 395 | */ |
| 396 | struct drm_crtc *sde_crtc_init(struct drm_device *dev, struct drm_plane *plane); |
| 397 | |
| 398 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 399 | * sde_crtc_cancel_pending_flip - complete flip for clients on lastclose |
| 400 | * @crtc: Pointer to drm crtc object |
| 401 | * @file: client to cancel's file handle |
| 402 | */ |
| 403 | void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file); |
| 404 | |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 405 | /** |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 406 | * sde_crtc_register_custom_event - api for enabling/disabling crtc event |
| 407 | * @kms: Pointer to sde_kms |
| 408 | * @crtc_drm: Pointer to crtc object |
| 409 | * @event: Event that client is interested |
| 410 | * @en: Flag to enable/disable the event |
| 411 | */ |
| 412 | int sde_crtc_register_custom_event(struct sde_kms *kms, |
| 413 | struct drm_crtc *crtc_drm, u32 event, bool en); |
| 414 | |
| 415 | /** |
| 416 | * sde_crtc_get_intf_mode - get interface mode of the given crtc |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 417 | * @crtc: Pointert to crtc |
| 418 | */ |
Alan Kwong | 3e985f0 | 2017-02-12 15:08:44 -0800 | [diff] [blame] | 419 | 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] | 420 | |
| 421 | /** |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 422 | * 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] | 423 | * @crtc: Pointer to crtc |
| 424 | */ |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 425 | static inline enum sde_crtc_client_type sde_crtc_get_client_type( |
| 426 | struct drm_crtc *crtc) |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 427 | { |
| 428 | struct sde_crtc_state *cstate = |
| 429 | crtc ? to_sde_crtc_state(crtc->state) : NULL; |
| 430 | |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 431 | if (!cstate) |
| 432 | return NRT_CLIENT; |
| 433 | |
| 434 | return cstate->rsc_client ? RT_RSC_CLIENT : |
| 435 | (cstate->intf_mode == INTF_MODE_WB_LINE ? NRT_CLIENT : RT_CLIENT); |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | /** |
| 439 | * sde_crtc_is_enabled - check if sde crtc is enabled or not |
| 440 | * @crtc: Pointer to crtc |
| 441 | */ |
| 442 | static inline bool sde_crtc_is_enabled(struct drm_crtc *crtc) |
| 443 | { |
| 444 | return crtc ? crtc->enabled : false; |
| 445 | } |
| 446 | |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 447 | /** |
Alan Kwong | 56f1a94 | 2017-04-04 11:53:42 -0700 | [diff] [blame] | 448 | * sde_crtc_get_inline_prefill - get current inline rotation prefill |
| 449 | * @crtc: Pointer to crtc |
| 450 | * return: number of prefill lines |
| 451 | */ |
| 452 | static inline u32 sde_crtc_get_inline_prefill(struct drm_crtc *crtc) |
| 453 | { |
Clarence Ip | 7eb9045 | 2017-05-23 11:41:19 -0400 | [diff] [blame] | 454 | struct sde_crtc_state *cstate; |
| 455 | |
Alan Kwong | 56f1a94 | 2017-04-04 11:53:42 -0700 | [diff] [blame] | 456 | if (!crtc || !crtc->state) |
| 457 | return 0; |
| 458 | |
Clarence Ip | 7eb9045 | 2017-05-23 11:41:19 -0400 | [diff] [blame] | 459 | cstate = to_sde_crtc_state(crtc->state); |
| 460 | return cstate->sbuf_cfg.rot_op_mode != SDE_CTL_ROT_OP_MODE_OFFLINE ? |
| 461 | cstate->sbuf_prefill_line : 0; |
Alan Kwong | 56f1a94 | 2017-04-04 11:53:42 -0700 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | /** |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 465 | * sde_crtc_event_queue - request event callback |
| 466 | * @crtc: Pointer to drm crtc structure |
| 467 | * @func: Pointer to callback function |
| 468 | * @usr: Pointer to user data to be passed to callback |
| 469 | * Returns: Zero on success |
| 470 | */ |
| 471 | int sde_crtc_event_queue(struct drm_crtc *crtc, |
Gopikrishnaiah Anandan | b6b401f | 2017-03-14 16:39:49 -0700 | [diff] [blame] | 472 | void (*func)(struct drm_crtc *crtc, void *usr), void *usr); |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 473 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 474 | /** |
| 475 | * sde_crtc_res_add - add given resource to resource pool in crtc state |
| 476 | * @state: Pointer to drm crtc state |
| 477 | * @type: Resource type |
| 478 | * @tag: Search tag for given resource |
| 479 | * @val: Resource handle |
| 480 | * @ops: Resource callback operations |
| 481 | * return: 0 if success; error code otherwise |
| 482 | */ |
| 483 | int sde_crtc_res_add(struct drm_crtc_state *state, u32 type, u64 tag, |
| 484 | void *val, struct sde_crtc_res_ops *ops); |
| 485 | |
| 486 | /** |
| 487 | * sde_crtc_res_get - get given resource from resource pool in crtc state |
| 488 | * @state: Pointer to drm crtc state |
| 489 | * @type: Resource type |
| 490 | * @tag: Search tag for given resource |
| 491 | * return: Resource handle if success; pointer error or null otherwise |
| 492 | */ |
| 493 | void *sde_crtc_res_get(struct drm_crtc_state *state, u32 type, u64 tag); |
| 494 | |
| 495 | /** |
| 496 | * sde_crtc_res_put - return given resource to resource pool in crtc state |
| 497 | * @state: Pointer to drm crtc state |
| 498 | * @type: Resource type |
| 499 | * @tag: Search tag for given resource |
| 500 | * return: None |
| 501 | */ |
| 502 | void sde_crtc_res_put(struct drm_crtc_state *state, u32 type, u64 tag); |
| 503 | |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 504 | /** |
| 505 | * sde_crtc_get_crtc_roi - retrieve the crtc_roi from the given state object |
| 506 | * used to allow the planes to adjust their final lm out_xy value in the |
| 507 | * case of partial update |
| 508 | * @crtc_state: Pointer to crtc state |
| 509 | * @crtc_roi: Output pointer to crtc roi in the given state |
| 510 | */ |
| 511 | void sde_crtc_get_crtc_roi(struct drm_crtc_state *state, |
| 512 | const struct sde_rect **crtc_roi); |
| 513 | |
Abhijit Kulkarni | 7444a7d | 2017-06-21 18:53:36 -0700 | [diff] [blame] | 514 | /** sde_crt_get_secure_level - retrieve the secure level from the give state |
| 515 | * object, this is used to determine the secure state of the crtc |
| 516 | * @crtc : Pointer to drm crtc structure |
| 517 | * @usr: Pointer to drm crtc state |
| 518 | * return: secure_level |
| 519 | */ |
| 520 | static inline int sde_crtc_get_secure_level(struct drm_crtc *crtc, |
| 521 | struct drm_crtc_state *state) |
| 522 | { |
| 523 | if (!crtc || !state) |
| 524 | return -EINVAL; |
| 525 | |
| 526 | return sde_crtc_get_property(to_sde_crtc_state(state), |
| 527 | CRTC_PROP_SECURITY_LEVEL); |
| 528 | } |
| 529 | |
| 530 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 531 | #endif /* _SDE_CRTC_H_ */ |