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 |
| 111 | * @mixer : 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. |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 141 | */ |
| 142 | struct sde_crtc { |
| 143 | struct drm_crtc base; |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 144 | char name[SDE_CRTC_NAME_SIZE]; |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 145 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 146 | /* HW Resources reserved for the crtc */ |
Lloyd Atkinson | c44a52e | 2016-08-16 16:40:17 -0400 | [diff] [blame] | 147 | u32 num_ctls; |
| 148 | u32 num_mixers; |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 149 | struct sde_crtc_mixer mixers[CRTC_DUAL_MIXERS]; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 150 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 151 | struct drm_pending_vblank_event *event; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 152 | u32 vsync_count; |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 153 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 154 | struct msm_property_info property_info; |
| 155 | struct msm_property_data property_data[CRTC_PROP_COUNT]; |
Dhaval Patel | e4a5dda | 2016-10-13 19:29:30 -0700 | [diff] [blame] | 156 | struct drm_property_blob *blob_info; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 157 | |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 158 | /* output fence support */ |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 159 | struct sde_fence_context output_fence; |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 160 | |
Clarence Ip | 8f7366c | 2016-07-05 12:15:26 -0400 | [diff] [blame] | 161 | struct sde_hw_stage_cfg stage_cfg; |
| 162 | struct dentry *debugfs_root; |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 163 | |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 164 | u32 vblank_cb_count; |
| 165 | ktime_t vblank_cb_time; |
| 166 | atomic_t vblank_refcount; |
Clarence Ip | 7f70ce4 | 2017-03-20 06:53:46 -0700 | [diff] [blame] | 167 | bool suspend; |
Alan Kwong | 07da098 | 2016-11-04 12:57:45 -0400 | [diff] [blame] | 168 | |
Gopikrishnaiah Anandan | e0e5e0c | 2016-05-25 11:05:33 -0700 | [diff] [blame] | 169 | struct list_head feature_list; |
| 170 | struct list_head active_list; |
| 171 | struct list_head dirty_list; |
Gopikrishnaiah Anandan | 9ba4378 | 2017-01-31 18:23:08 -0800 | [diff] [blame] | 172 | struct list_head ad_dirty; |
| 173 | struct list_head ad_active; |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 174 | struct list_head user_event_list; |
Dhaval Patel | 3fbe6bf | 2016-10-20 20:00:41 -0700 | [diff] [blame] | 175 | |
| 176 | struct mutex crtc_lock; |
Alan Kwong | 628d19e | 2016-10-31 13:50:13 -0400 | [diff] [blame] | 177 | |
| 178 | atomic_t frame_pending; |
| 179 | struct sde_crtc_frame_event frame_events[SDE_CRTC_FRAME_EVENT_SIZE]; |
| 180 | struct list_head frame_event_list; |
| 181 | spinlock_t spin_lock; |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 182 | |
| 183 | /* for handling internal event thread */ |
| 184 | struct task_struct *event_thread; |
| 185 | struct kthread_worker event_worker; |
| 186 | struct sde_crtc_event event_cache[SDE_CRTC_MAX_EVENT_COUNT]; |
| 187 | struct list_head event_free_list; |
| 188 | spinlock_t event_lock; |
Dhaval Patel | f9245d6 | 2017-03-28 16:24:00 -0700 | [diff] [blame] | 189 | bool misr_enable; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | #define to_sde_crtc(x) container_of(x, struct sde_crtc, base) |
| 193 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 194 | /** |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 195 | * struct sde_crtc_res_ops - common operations for crtc resources |
| 196 | * @get: get given resource |
| 197 | * @put: put given resource |
| 198 | */ |
| 199 | struct sde_crtc_res_ops { |
| 200 | void *(*get)(void *val, u32 type, u64 tag); |
| 201 | void (*put)(void *val); |
| 202 | }; |
| 203 | |
| 204 | /* crtc resource type (0x0-0xffff reserved for hw block type */ |
| 205 | #define SDE_CRTC_RES_ROT_OUT_FBO 0x10000 |
| 206 | #define SDE_CRTC_RES_ROT_OUT_FB 0x10001 |
| 207 | #define SDE_CRTC_RES_ROT_PLANE 0x10002 |
| 208 | #define SDE_CRTC_RES_ROT_IN_FB 0x10003 |
| 209 | |
| 210 | #define SDE_CRTC_RES_FLAG_FREE BIT(0) |
| 211 | |
| 212 | /** |
| 213 | * struct sde_crtc_res - definition of crtc resources |
| 214 | * @list: list of crtc resource |
| 215 | * @type: crtc resource type |
| 216 | * @tag: unique identifier per type |
| 217 | * @refcount: reference/usage count |
| 218 | * @ops: callback operations |
| 219 | * @val: resource handle associated with type/tag |
| 220 | * @flags: customization flags |
| 221 | */ |
| 222 | struct sde_crtc_res { |
| 223 | struct list_head list; |
| 224 | u32 type; |
| 225 | u64 tag; |
| 226 | atomic_t refcount; |
| 227 | struct sde_crtc_res_ops ops; |
| 228 | void *val; |
| 229 | u32 flags; |
| 230 | }; |
| 231 | |
| 232 | /** |
| 233 | * sde_crtc_respool - crtc resource pool |
| 234 | * @sequence_id: sequence identifier, incremented per state duplication |
| 235 | * @res_list: list of resource managed by this resource pool |
| 236 | * @ops: resource operations for parent resource pool |
| 237 | */ |
| 238 | struct sde_crtc_respool { |
| 239 | u32 sequence_id; |
| 240 | struct list_head res_list; |
| 241 | struct sde_crtc_res_ops ops; |
| 242 | }; |
| 243 | |
| 244 | /** |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 245 | * struct sde_crtc_state - sde container for atomic crtc state |
| 246 | * @base: Base drm crtc state structure |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 247 | * @connectors : Currently associated drm connectors |
| 248 | * @num_connectors: Number of associated drm connectors |
Alan Kwong | 67a3f79 | 2016-11-01 23:16:53 -0400 | [diff] [blame] | 249 | * @intf_mode : Interface mode of the primary connector |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 250 | * @rsc_client : sde rsc client when mode is valid |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 251 | * @property_values: Current crtc property values |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 252 | * @input_fence_timeout_ns : Cached input fence timeout, in ns |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 253 | * @property_blobs: Reference pointers for blob properties |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 254 | * @num_dim_layers: Number of dim layers |
| 255 | * @dim_layer: Dim layer configs |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 256 | * @cur_perf: current performance state |
| 257 | * @new_perf: new performance state |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 258 | * @sbuf_cfg: stream buffer configuration |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 259 | * @sbuf_prefill_line: number of line for inline rotator prefetch |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 260 | */ |
| 261 | struct sde_crtc_state { |
| 262 | struct drm_crtc_state base; |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 263 | |
| 264 | struct drm_connector *connectors[MAX_CONNECTORS]; |
| 265 | int num_connectors; |
Alan Kwong | 67a3f79 | 2016-11-01 23:16:53 -0400 | [diff] [blame] | 266 | enum sde_intf_mode intf_mode; |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 267 | struct sde_rsc_client *rsc_client; |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 268 | bool rsc_update; |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 269 | |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 270 | uint64_t property_values[CRTC_PROP_COUNT]; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 271 | uint64_t input_fence_timeout_ns; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 272 | struct drm_property_blob *property_blobs[CRTC_PROP_COUNT]; |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 273 | uint32_t num_dim_layers; |
| 274 | struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS]; |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 275 | |
| 276 | struct sde_core_perf_params cur_perf; |
| 277 | struct sde_core_perf_params new_perf; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 278 | struct sde_ctl_sbuf_cfg sbuf_cfg; |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 279 | u64 sbuf_prefill_line; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 280 | |
| 281 | struct sde_crtc_respool rp; |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 282 | }; |
| 283 | |
| 284 | #define to_sde_crtc_state(x) \ |
| 285 | container_of(x, struct sde_crtc_state, base) |
| 286 | |
| 287 | /** |
| 288 | * sde_crtc_get_property - query integer value of crtc property |
| 289 | * @S: Pointer to crtc state |
| 290 | * @X: Property index, from enum msm_mdp_crtc_property |
| 291 | * Returns: Integer value of requested property |
| 292 | */ |
| 293 | #define sde_crtc_get_property(S, X) \ |
| 294 | ((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)]) : 0) |
| 295 | |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 296 | static inline int sde_crtc_mixer_width(struct sde_crtc *sde_crtc, |
| 297 | struct drm_display_mode *mode) |
| 298 | { |
| 299 | if (!sde_crtc || !mode) |
| 300 | return 0; |
| 301 | |
| 302 | return sde_crtc->num_mixers == CRTC_DUAL_MIXERS ? |
| 303 | mode->hdisplay / CRTC_DUAL_MIXERS : mode->hdisplay; |
| 304 | } |
| 305 | |
| 306 | static inline uint32_t get_crtc_split_width(struct drm_crtc *crtc) |
| 307 | { |
| 308 | struct drm_display_mode *mode; |
| 309 | struct sde_crtc *sde_crtc; |
| 310 | |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 311 | if (!crtc || !crtc->state) |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 312 | return 0; |
| 313 | |
| 314 | sde_crtc = to_sde_crtc(crtc); |
| 315 | mode = &crtc->state->adjusted_mode; |
| 316 | return sde_crtc_mixer_width(sde_crtc, mode); |
| 317 | } |
| 318 | |
Veera Sundaram Sankaran | 3171ff8 | 2017-01-04 14:34:47 -0800 | [diff] [blame] | 319 | static inline uint32_t get_crtc_mixer_height(struct drm_crtc *crtc) |
| 320 | { |
| 321 | struct drm_display_mode *mode; |
| 322 | |
| 323 | if (!crtc || !crtc->state) |
| 324 | return 0; |
| 325 | |
| 326 | mode = &crtc->state->adjusted_mode; |
| 327 | return mode->vdisplay; |
| 328 | } |
| 329 | |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 330 | /** |
| 331 | * sde_crtc_vblank - enable or disable vblanks for this crtc |
| 332 | * @crtc: Pointer to drm crtc object |
| 333 | * @en: true to enable vblanks, false to disable |
| 334 | */ |
| 335 | int sde_crtc_vblank(struct drm_crtc *crtc, bool en); |
| 336 | |
| 337 | /** |
| 338 | * sde_crtc_commit_kickoff - trigger kickoff of the commit for this crtc |
| 339 | * @crtc: Pointer to drm crtc object |
| 340 | */ |
| 341 | void sde_crtc_commit_kickoff(struct drm_crtc *crtc); |
| 342 | |
| 343 | /** |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 344 | * sde_crtc_prepare_commit - callback to prepare for output fences |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 345 | * @crtc: Pointer to drm crtc object |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 346 | * @old_state: Pointer to drm crtc old state object |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 347 | */ |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 348 | void sde_crtc_prepare_commit(struct drm_crtc *crtc, |
| 349 | struct drm_crtc_state *old_state); |
| 350 | |
| 351 | /** |
| 352 | * sde_crtc_complete_commit - callback signalling completion of current commit |
| 353 | * @crtc: Pointer to drm crtc object |
| 354 | * @old_state: Pointer to drm crtc old state object |
| 355 | */ |
| 356 | void sde_crtc_complete_commit(struct drm_crtc *crtc, |
| 357 | struct drm_crtc_state *old_state); |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 358 | |
| 359 | /** |
| 360 | * sde_crtc_init - create a new crtc object |
| 361 | * @dev: sde device |
| 362 | * @plane: base plane |
| 363 | * @Return: new crtc object or error |
| 364 | */ |
| 365 | struct drm_crtc *sde_crtc_init(struct drm_device *dev, struct drm_plane *plane); |
| 366 | |
| 367 | /** |
Lloyd Atkinson | 9eabe7a | 2016-09-14 13:39:15 -0400 | [diff] [blame] | 368 | * sde_crtc_cancel_pending_flip - complete flip for clients on lastclose |
| 369 | * @crtc: Pointer to drm crtc object |
| 370 | * @file: client to cancel's file handle |
| 371 | */ |
| 372 | void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file); |
| 373 | |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 374 | /** |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 375 | * sde_crtc_register_custom_event - api for enabling/disabling crtc event |
| 376 | * @kms: Pointer to sde_kms |
| 377 | * @crtc_drm: Pointer to crtc object |
| 378 | * @event: Event that client is interested |
| 379 | * @en: Flag to enable/disable the event |
| 380 | */ |
| 381 | int sde_crtc_register_custom_event(struct sde_kms *kms, |
| 382 | struct drm_crtc *crtc_drm, u32 event, bool en); |
| 383 | |
| 384 | /** |
| 385 | * sde_crtc_get_intf_mode - get interface mode of the given crtc |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 386 | * @crtc: Pointert to crtc |
| 387 | */ |
Alan Kwong | 3e985f0 | 2017-02-12 15:08:44 -0800 | [diff] [blame] | 388 | 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] | 389 | |
| 390 | /** |
Dhaval Patel | 4d42460 | 2017-02-18 19:40:14 -0800 | [diff] [blame] | 391 | * 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] | 392 | * @crtc: Pointer to crtc |
| 393 | */ |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 394 | static inline enum sde_crtc_client_type sde_crtc_get_client_type( |
| 395 | struct drm_crtc *crtc) |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 396 | { |
| 397 | struct sde_crtc_state *cstate = |
| 398 | crtc ? to_sde_crtc_state(crtc->state) : NULL; |
| 399 | |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 400 | if (!cstate) |
| 401 | return NRT_CLIENT; |
| 402 | |
| 403 | return cstate->rsc_client ? RT_RSC_CLIENT : |
| 404 | (cstate->intf_mode == INTF_MODE_WB_LINE ? NRT_CLIENT : RT_CLIENT); |
Alan Kwong | 9aa061c | 2016-11-06 21:17:12 -0500 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | /** |
| 408 | * sde_crtc_is_enabled - check if sde crtc is enabled or not |
| 409 | * @crtc: Pointer to crtc |
| 410 | */ |
| 411 | static inline bool sde_crtc_is_enabled(struct drm_crtc *crtc) |
| 412 | { |
| 413 | return crtc ? crtc->enabled : false; |
| 414 | } |
| 415 | |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 416 | /** |
| 417 | * sde_crtc_event_queue - request event callback |
| 418 | * @crtc: Pointer to drm crtc structure |
| 419 | * @func: Pointer to callback function |
| 420 | * @usr: Pointer to user data to be passed to callback |
| 421 | * Returns: Zero on success |
| 422 | */ |
| 423 | int sde_crtc_event_queue(struct drm_crtc *crtc, |
Gopikrishnaiah Anandan | b6b401f | 2017-03-14 16:39:49 -0700 | [diff] [blame] | 424 | void (*func)(struct drm_crtc *crtc, void *usr), void *usr); |
Clarence Ip | a18d483 | 2017-03-13 12:35:44 -0700 | [diff] [blame] | 425 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 426 | /** |
| 427 | * sde_crtc_res_add - add given resource to resource pool in crtc state |
| 428 | * @state: Pointer to drm crtc state |
| 429 | * @type: Resource type |
| 430 | * @tag: Search tag for given resource |
| 431 | * @val: Resource handle |
| 432 | * @ops: Resource callback operations |
| 433 | * return: 0 if success; error code otherwise |
| 434 | */ |
| 435 | int sde_crtc_res_add(struct drm_crtc_state *state, u32 type, u64 tag, |
| 436 | void *val, struct sde_crtc_res_ops *ops); |
| 437 | |
| 438 | /** |
| 439 | * sde_crtc_res_get - get given resource from resource pool in crtc state |
| 440 | * @state: Pointer to drm crtc state |
| 441 | * @type: Resource type |
| 442 | * @tag: Search tag for given resource |
| 443 | * return: Resource handle if success; pointer error or null otherwise |
| 444 | */ |
| 445 | void *sde_crtc_res_get(struct drm_crtc_state *state, u32 type, u64 tag); |
| 446 | |
| 447 | /** |
| 448 | * sde_crtc_res_put - return given resource to resource pool in crtc state |
| 449 | * @state: Pointer to drm crtc state |
| 450 | * @type: Resource type |
| 451 | * @tag: Search tag for given resource |
| 452 | * return: None |
| 453 | */ |
| 454 | void sde_crtc_res_put(struct drm_crtc_state *state, u32 type, u64 tag); |
| 455 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 456 | #endif /* _SDE_CRTC_H_ */ |