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 */ |
| 33 | #define SDE_CRTC_FRAME_EVENT_SIZE 2 |
| 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 | a9d7e75 | 2017-01-17 16:31:43 -0500 | [diff] [blame] | 111 | * @mixers : List of active mixers |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 112 | * @event : Pointer to last received drm vblank event. If there is a |
| 113 | * pending vblank event, this will be non-null. |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 114 | * @vsync_count : Running count of received vsync events |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 115 | * @drm_requested_vblank : Whether vblanks have been enabled in the encoder |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 116 | * @property_info : Opaque structure for generic property support |
| 117 | * @property_defaults : Array of default values for generic property support |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 118 | * @output_fence : output release fence context |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 119 | * @stage_cfg : H/w mixer stage configuration |
| 120 | * @debugfs_root : Parent of debugfs node |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 121 | * @vblank_cb_count : count of vblank callback since last reset |
| 122 | * @vblank_cb_time : ktime at vblank count reset |
| 123 | * @vblank_refcount : reference count for vblank enable request |
Clarence Ip | 7f70ce4 | 2017-03-20 06:53:46 -0700 | [diff] [blame] | 124 | * @suspend : whether or not a suspend operation is in progress |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 125 | * @feature_list : list of color processing features supported on a crtc |
| 126 | * @active_list : list of color processing features are active |
| 127 | * @dirty_list : list of color processing features are dirty |
Gopikrishnaiah Anandan | 9ba4378 | 2017-01-31 18:23:08 -0800 | [diff] [blame] | 128 | * @ad_dirty: list containing ad properties that are dirty |
| 129 | * @ad_active: list containing ad properties that are active |
Dhaval Patel | 3fbe6bf | 2016-10-20 20:00:41 -0700 | [diff] [blame] | 130 | * @crtc_lock : crtc lock around create, destroy and access. |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 131 | * @frame_pending : Whether or not an update is pending |
| 132 | * @frame_events : static allocation of in-flight frame events |
| 133 | * @frame_event_list : available frame event list |
| 134 | * @spin_lock : spin lock for frame event, transaction status, etc... |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 135 | * @event_thread : Pointer to event handler thread |
| 136 | * @event_worker : Event worker queue |
| 137 | * @event_cache : Local cache of event worker structures |
| 138 | * @event_free_list : List of available event structures |
| 139 | * @event_lock : Spinlock around event handling code |
Dhaval Patel | f9245d6 | 2017-03-28 16:24:00 -0700 | [diff] [blame] | 140 | * @misr_enable : boolean entry indicates misr enable/disable status. |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 141 | * @power_event : registered power event handle |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 142 | */ |
| 143 | struct sde_crtc { |
| 144 | struct drm_crtc base; |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 145 | char name[SDE_CRTC_NAME_SIZE]; |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 146 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 147 | /* HW Resources reserved for the crtc */ |
Lloyd Atkinson | c44a52e | 2016-08-16 16:40:17 -0400 | [diff] [blame] | 148 | u32 num_ctls; |
| 149 | u32 num_mixers; |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 150 | struct sde_crtc_mixer mixers[CRTC_DUAL_MIXERS]; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 151 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 152 | struct drm_pending_vblank_event *event; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 153 | u32 vsync_count; |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 154 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 155 | struct msm_property_info property_info; |
| 156 | struct msm_property_data property_data[CRTC_PROP_COUNT]; |
Dhaval Patel | e4a5dda | 2016-10-13 19:29:30 -0700 | [diff] [blame] | 157 | struct drm_property_blob *blob_info; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 158 | |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 159 | /* output fence support */ |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 160 | struct sde_fence_context output_fence; |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 161 | |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 162 | struct sde_hw_stage_cfg stage_cfg; |
| 163 | struct dentry *debugfs_root; |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 164 | |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 165 | u32 vblank_cb_count; |
| 166 | ktime_t vblank_cb_time; |
| 167 | atomic_t vblank_refcount; |
Clarence Ip | 7f70ce4 | 2017-03-20 06:53:46 -0700 | [diff] [blame] | 168 | bool suspend; |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 169 | |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 170 | struct list_head feature_list; |
| 171 | struct list_head active_list; |
| 172 | struct list_head dirty_list; |
Gopikrishnaiah Anandan | 9ba4378 | 2017-01-31 18:23:08 -0800 | [diff] [blame] | 173 | struct list_head ad_dirty; |
| 174 | struct list_head ad_active; |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 175 | struct list_head user_event_list; |
Dhaval Patel | 3fbe6bf | 2016-10-20 20:00:41 -0700 | [diff] [blame] | 176 | |
| 177 | struct mutex crtc_lock; |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 178 | |
| 179 | atomic_t frame_pending; |
| 180 | struct sde_crtc_frame_event frame_events[SDE_CRTC_FRAME_EVENT_SIZE]; |
| 181 | struct list_head frame_event_list; |
| 182 | spinlock_t spin_lock; |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 183 | |
| 184 | /* for handling internal event thread */ |
| 185 | struct task_struct *event_thread; |
| 186 | struct kthread_worker event_worker; |
| 187 | struct sde_crtc_event event_cache[SDE_CRTC_MAX_EVENT_COUNT]; |
| 188 | struct list_head event_free_list; |
| 189 | spinlock_t event_lock; |
Dhaval Patel | f9245d6 | 2017-03-28 16:24:00 -0700 | [diff] [blame] | 190 | bool misr_enable; |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 191 | |
| 192 | struct sde_power_event *power_event; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | #define to_sde_crtc(x) container_of(x, struct sde_crtc, base) |
| 196 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 197 | /** |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 198 | * struct sde_crtc_res_ops - common operations for crtc resources |
| 199 | * @get: get given resource |
| 200 | * @put: put given resource |
| 201 | */ |
| 202 | struct sde_crtc_res_ops { |
| 203 | void *(*get)(void *val, u32 type, u64 tag); |
| 204 | void (*put)(void *val); |
| 205 | }; |
| 206 | |
| 207 | /* crtc resource type (0x0-0xffff reserved for hw block type */ |
| 208 | #define SDE_CRTC_RES_ROT_OUT_FBO 0x10000 |
| 209 | #define SDE_CRTC_RES_ROT_OUT_FB 0x10001 |
| 210 | #define SDE_CRTC_RES_ROT_PLANE 0x10002 |
| 211 | #define SDE_CRTC_RES_ROT_IN_FB 0x10003 |
| 212 | |
| 213 | #define SDE_CRTC_RES_FLAG_FREE BIT(0) |
| 214 | |
| 215 | /** |
| 216 | * struct sde_crtc_res - definition of crtc resources |
| 217 | * @list: list of crtc resource |
| 218 | * @type: crtc resource type |
| 219 | * @tag: unique identifier per type |
| 220 | * @refcount: reference/usage count |
| 221 | * @ops: callback operations |
| 222 | * @val: resource handle associated with type/tag |
| 223 | * @flags: customization flags |
| 224 | */ |
| 225 | struct sde_crtc_res { |
| 226 | struct list_head list; |
| 227 | u32 type; |
| 228 | u64 tag; |
| 229 | atomic_t refcount; |
| 230 | struct sde_crtc_res_ops ops; |
| 231 | void *val; |
| 232 | u32 flags; |
| 233 | }; |
| 234 | |
| 235 | /** |
| 236 | * sde_crtc_respool - crtc resource pool |
| 237 | * @sequence_id: sequence identifier, incremented per state duplication |
| 238 | * @res_list: list of resource managed by this resource pool |
| 239 | * @ops: resource operations for parent resource pool |
| 240 | */ |
| 241 | struct sde_crtc_respool { |
| 242 | u32 sequence_id; |
| 243 | struct list_head res_list; |
| 244 | struct sde_crtc_res_ops ops; |
| 245 | }; |
| 246 | |
| 247 | /** |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 248 | * struct sde_crtc_state - sde container for atomic crtc state |
| 249 | * @base: Base drm crtc state structure |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 250 | * @connectors : Currently associated drm connectors |
| 251 | * @num_connectors: Number of associated drm connectors |
Alan Kwong | 67a3f79 | 2016-11-01 23:16:53 -0400 | [diff] [blame] | 252 | * @intf_mode : Interface mode of the primary connector |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 253 | * @rsc_client : sde rsc client when mode is valid |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 254 | * @crtc_roi : Current CRTC ROI. Possibly sub-rectangle of mode. |
| 255 | * Origin top left of CRTC. |
Lloyd Atkinson | 73fb809 | 2017-02-08 16:02:55 -0500 | [diff] [blame] | 256 | * @lm_bounds : LM boundaries based on current mode full resolution, no ROI. |
| 257 | * Origin top left of CRTC. |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 258 | * @lm_roi : Current LM ROI, possibly sub-rectangle of mode. |
| 259 | * Origin top left of CRTC. |
| 260 | * @user_roi_list : List of user's requested ROIs as from set property |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 261 | * @property_values: Current crtc property values |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 262 | * @input_fence_timeout_ns : Cached input fence timeout, in ns |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 263 | * @property_blobs: Reference pointers for blob properties |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 264 | * @num_dim_layers: Number of dim layers |
| 265 | * @dim_layer: Dim layer configs |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 266 | * @cur_perf: current performance state |
| 267 | * @new_perf: new performance state |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 268 | * @sbuf_cfg: stream buffer configuration |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 269 | * @sbuf_prefill_line: number of line for inline rotator prefetch |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 270 | */ |
| 271 | struct sde_crtc_state { |
| 272 | struct drm_crtc_state base; |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 273 | |
| 274 | struct drm_connector *connectors[MAX_CONNECTORS]; |
| 275 | int num_connectors; |
Alan Kwong | 67a3f79 | 2016-11-01 23:16:53 -0400 | [diff] [blame] | 276 | enum sde_intf_mode intf_mode; |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 277 | struct sde_rsc_client *rsc_client; |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 278 | bool rsc_update; |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 279 | |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 280 | struct sde_rect crtc_roi; |
Lloyd Atkinson | 73fb809 | 2017-02-08 16:02:55 -0500 | [diff] [blame] | 281 | struct sde_rect lm_bounds[CRTC_DUAL_MIXERS]; |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 282 | struct sde_rect lm_roi[CRTC_DUAL_MIXERS]; |
| 283 | struct msm_roi_list user_roi_list; |
Lloyd Atkinson | a9d7e75 | 2017-01-17 16:31:43 -0500 | [diff] [blame] | 284 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 285 | uint64_t property_values[CRTC_PROP_COUNT]; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 286 | uint64_t input_fence_timeout_ns; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 287 | struct drm_property_blob *property_blobs[CRTC_PROP_COUNT]; |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 288 | uint32_t num_dim_layers; |
| 289 | struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS]; |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 290 | |
| 291 | struct sde_core_perf_params cur_perf; |
| 292 | struct sde_core_perf_params new_perf; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 293 | struct sde_ctl_sbuf_cfg sbuf_cfg; |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 294 | u64 sbuf_prefill_line; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 295 | |
| 296 | struct sde_crtc_respool rp; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 297 | }; |
| 298 | |
| 299 | #define to_sde_crtc_state(x) \ |
| 300 | container_of(x, struct sde_crtc_state, base) |
| 301 | |
| 302 | /** |
| 303 | * sde_crtc_get_property - query integer value of crtc property |
| 304 | * @S: Pointer to crtc state |
| 305 | * @X: Property index, from enum msm_mdp_crtc_property |
| 306 | * Returns: Integer value of requested property |
| 307 | */ |
| 308 | #define sde_crtc_get_property(S, X) \ |
| 309 | ((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)]) : 0) |
| 310 | |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 311 | static inline int sde_crtc_mixer_width(struct sde_crtc *sde_crtc, |
| 312 | struct drm_display_mode *mode) |
| 313 | { |
| 314 | if (!sde_crtc || !mode) |
| 315 | return 0; |
| 316 | |
| 317 | return sde_crtc->num_mixers == CRTC_DUAL_MIXERS ? |
| 318 | mode->hdisplay / CRTC_DUAL_MIXERS : mode->hdisplay; |
| 319 | } |
| 320 | |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 321 | /** |
Veera Sundaram Sankaran | c9efbec | 2017-03-29 18:59:05 -0700 | [diff] [blame] | 322 | * sde_crtc_frame_pending - retun the number of pending frames |
| 323 | * @crtc: Pointer to drm crtc object |
| 324 | */ |
| 325 | static inline int sde_crtc_frame_pending(struct drm_crtc *crtc) |
| 326 | { |
| 327 | struct sde_crtc *sde_crtc; |
| 328 | |
| 329 | if (!crtc) |
| 330 | return -EINVAL; |
| 331 | |
| 332 | sde_crtc = to_sde_crtc(crtc); |
| 333 | return atomic_read(&sde_crtc->frame_pending); |
| 334 | } |
| 335 | |
| 336 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 337 | * sde_crtc_vblank - enable or disable vblanks for this crtc |
| 338 | * @crtc: Pointer to drm crtc object |
| 339 | * @en: true to enable vblanks, false to disable |
| 340 | */ |
| 341 | int sde_crtc_vblank(struct drm_crtc *crtc, bool en); |
| 342 | |
| 343 | /** |
| 344 | * sde_crtc_commit_kickoff - trigger kickoff of the commit for this crtc |
| 345 | * @crtc: Pointer to drm crtc object |
| 346 | */ |
| 347 | void sde_crtc_commit_kickoff(struct drm_crtc *crtc); |
| 348 | |
| 349 | /** |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 350 | * sde_crtc_prepare_commit - callback to prepare for output fences |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 351 | * @crtc: Pointer to drm crtc object |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 352 | * @old_state: Pointer to drm crtc old state object |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 353 | */ |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 354 | void sde_crtc_prepare_commit(struct drm_crtc *crtc, |
| 355 | struct drm_crtc_state *old_state); |
| 356 | |
| 357 | /** |
| 358 | * sde_crtc_complete_commit - callback signalling completion of current commit |
| 359 | * @crtc: Pointer to drm crtc object |
| 360 | * @old_state: Pointer to drm crtc old state object |
| 361 | */ |
| 362 | void sde_crtc_complete_commit(struct drm_crtc *crtc, |
| 363 | struct drm_crtc_state *old_state); |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 364 | |
| 365 | /** |
| 366 | * sde_crtc_init - create a new crtc object |
| 367 | * @dev: sde device |
| 368 | * @plane: base plane |
| 369 | * @Return: new crtc object or error |
| 370 | */ |
| 371 | struct drm_crtc *sde_crtc_init(struct drm_device *dev, struct drm_plane *plane); |
| 372 | |
| 373 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 374 | * sde_crtc_cancel_pending_flip - complete flip for clients on lastclose |
| 375 | * @crtc: Pointer to drm crtc object |
| 376 | * @file: client to cancel's file handle |
| 377 | */ |
| 378 | void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file); |
| 379 | |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 380 | /** |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 381 | * sde_crtc_register_custom_event - api for enabling/disabling crtc event |
| 382 | * @kms: Pointer to sde_kms |
| 383 | * @crtc_drm: Pointer to crtc object |
| 384 | * @event: Event that client is interested |
| 385 | * @en: Flag to enable/disable the event |
| 386 | */ |
| 387 | int sde_crtc_register_custom_event(struct sde_kms *kms, |
| 388 | struct drm_crtc *crtc_drm, u32 event, bool en); |
| 389 | |
| 390 | /** |
| 391 | * sde_crtc_get_intf_mode - get interface mode of the given crtc |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 392 | * @crtc: Pointert to crtc |
| 393 | */ |
Alan Kwong | 3e985f0 | 2017-02-12 15:08:44 -0800 | [diff] [blame] | 394 | 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] | 395 | |
| 396 | /** |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 397 | * 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] | 398 | * @crtc: Pointer to crtc |
| 399 | */ |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 400 | static inline enum sde_crtc_client_type sde_crtc_get_client_type( |
| 401 | struct drm_crtc *crtc) |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 402 | { |
| 403 | struct sde_crtc_state *cstate = |
| 404 | crtc ? to_sde_crtc_state(crtc->state) : NULL; |
| 405 | |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 406 | if (!cstate) |
| 407 | return NRT_CLIENT; |
| 408 | |
| 409 | return cstate->rsc_client ? RT_RSC_CLIENT : |
| 410 | (cstate->intf_mode == INTF_MODE_WB_LINE ? NRT_CLIENT : RT_CLIENT); |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | /** |
| 414 | * sde_crtc_is_enabled - check if sde crtc is enabled or not |
| 415 | * @crtc: Pointer to crtc |
| 416 | */ |
| 417 | static inline bool sde_crtc_is_enabled(struct drm_crtc *crtc) |
| 418 | { |
| 419 | return crtc ? crtc->enabled : false; |
| 420 | } |
| 421 | |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 422 | /** |
Alan Kwong | 56f1a94 | 2017-04-04 11:53:42 -0700 | [diff] [blame] | 423 | * sde_crtc_get_inline_prefill - get current inline rotation prefill |
| 424 | * @crtc: Pointer to crtc |
| 425 | * return: number of prefill lines |
| 426 | */ |
| 427 | static inline u32 sde_crtc_get_inline_prefill(struct drm_crtc *crtc) |
| 428 | { |
| 429 | if (!crtc || !crtc->state) |
| 430 | return 0; |
| 431 | |
| 432 | return to_sde_crtc_state(crtc->state)->sbuf_prefill_line; |
| 433 | } |
| 434 | |
| 435 | /** |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 436 | * sde_crtc_event_queue - request event callback |
| 437 | * @crtc: Pointer to drm crtc structure |
| 438 | * @func: Pointer to callback function |
| 439 | * @usr: Pointer to user data to be passed to callback |
| 440 | * Returns: Zero on success |
| 441 | */ |
| 442 | int sde_crtc_event_queue(struct drm_crtc *crtc, |
Gopikrishnaiah Anandan | b6b401f | 2017-03-14 16:39:49 -0700 | [diff] [blame] | 443 | void (*func)(struct drm_crtc *crtc, void *usr), void *usr); |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 444 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 445 | /** |
| 446 | * sde_crtc_res_add - add given resource to resource pool in crtc state |
| 447 | * @state: Pointer to drm crtc state |
| 448 | * @type: Resource type |
| 449 | * @tag: Search tag for given resource |
| 450 | * @val: Resource handle |
| 451 | * @ops: Resource callback operations |
| 452 | * return: 0 if success; error code otherwise |
| 453 | */ |
| 454 | int sde_crtc_res_add(struct drm_crtc_state *state, u32 type, u64 tag, |
| 455 | void *val, struct sde_crtc_res_ops *ops); |
| 456 | |
| 457 | /** |
| 458 | * sde_crtc_res_get - get given resource from resource pool in crtc state |
| 459 | * @state: Pointer to drm crtc state |
| 460 | * @type: Resource type |
| 461 | * @tag: Search tag for given resource |
| 462 | * return: Resource handle if success; pointer error or null otherwise |
| 463 | */ |
| 464 | void *sde_crtc_res_get(struct drm_crtc_state *state, u32 type, u64 tag); |
| 465 | |
| 466 | /** |
| 467 | * sde_crtc_res_put - return given resource to resource pool in crtc state |
| 468 | * @state: Pointer to drm crtc state |
| 469 | * @type: Resource type |
| 470 | * @tag: Search tag for given resource |
| 471 | * return: None |
| 472 | */ |
| 473 | void sde_crtc_res_put(struct drm_crtc_state *state, u32 type, u64 tag); |
| 474 | |
Lloyd Atkinson | 8ba4703 | 2017-03-22 17:13:32 -0400 | [diff] [blame] | 475 | /** |
| 476 | * sde_crtc_get_crtc_roi - retrieve the crtc_roi from the given state object |
| 477 | * used to allow the planes to adjust their final lm out_xy value in the |
| 478 | * case of partial update |
| 479 | * @crtc_state: Pointer to crtc state |
| 480 | * @crtc_roi: Output pointer to crtc roi in the given state |
| 481 | */ |
| 482 | void sde_crtc_get_crtc_roi(struct drm_crtc_state *state, |
| 483 | const struct sde_rect **crtc_roi); |
| 484 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 485 | #endif /* _SDE_CRTC_H_ */ |