blob: 6a221156ebf968e38f453043271fbd7a13a9e00c [file] [log] [blame]
Dhaval Patel14d46ce2017-01-17 16:28:12 -08001/*
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 Kulkarni40e38162016-06-26 22:12:09 -04005 *
Dhaval Patel14d46ce2017-01-17 16:28:12 -08006 * 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 Kulkarni40e38162016-06-26 22:12:09 -04009 *
Dhaval Patel14d46ce2017-01-17 16:28:12 -080010 * 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 Kulkarni40e38162016-06-26 22:12:09 -040017 */
18
19#ifndef _SDE_CRTC_H_
20#define _SDE_CRTC_H_
21
Clarence Ipa18d4832017-03-13 12:35:44 -070022#include <linux/kthread.h>
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040023#include "drm_crtc.h"
Clarence Ip7a753bb2016-07-07 11:47:44 -040024#include "msm_prop.h"
Clarence Ip24f80662016-06-13 19:05:32 -040025#include "sde_fence.h"
Clarence Ip7a753bb2016-07-07 11:47:44 -040026#include "sde_kms.h"
Alan Kwong9aa061c2016-11-06 21:17:12 -050027#include "sde_core_perf.h"
Alan Kwongcdb2f282017-03-18 13:42:06 -070028#include "sde_hw_blk.h"
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040029
Clarence Ip8f7366c2016-07-05 12:15:26 -040030#define SDE_CRTC_NAME_SIZE 12
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040031
Alan Kwong628d19e2016-10-31 13:50:13 -040032/* define the maximum number of in-flight frame events */
33#define SDE_CRTC_FRAME_EVENT_SIZE 2
34
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040035/**
Dhaval Patel4d424602017-02-18 19:40:14 -080036 * 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 */
43enum sde_crtc_client_type {
44 RT_CLIENT,
45 NRT_CLIENT,
46 RT_RSC_CLIENT,
47};
48
49/**
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -040050 * 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 Anandane0e5e0c2016-05-25 11:05:33 -070053 * @hw_dspp: DSPP HW driver context
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -040054 * @encoder: Encoder attached to this lm & ctl
Dhaval Patel48c76022016-09-01 17:51:23 -070055 * @mixer_op_mode: mixer blending operation mode
56 * @flush_mask: mixer flush mask for ctl, mixer and pipe
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040057 */
58struct sde_crtc_mixer {
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040059 struct sde_hw_mixer *hw_lm;
Lloyd Atkinsonc44a52e2016-08-16 16:40:17 -040060 struct sde_hw_ctl *hw_ctl;
Gopikrishnaiah Anandane0e5e0c2016-05-25 11:05:33 -070061 struct sde_hw_dspp *hw_dspp;
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -040062 struct drm_encoder *encoder;
Dhaval Patel48c76022016-09-01 17:51:23 -070063 u32 mixer_op_mode;
64 u32 flush_mask;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040065};
66
67/**
Alan Kwong628d19e2016-10-31 13:50:13 -040068 * 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 */
75struct 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 Ipa18d4832017-03-13 12:35:44 -070084 * 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 */
91struct sde_crtc_event {
92 struct list_head list;
93 struct kthread_work kt_work;
94 void *sde_crtc;
95
Gopikrishnaiah Anandanb6b401f2017-03-14 16:39:49 -070096 void (*cb_func)(struct drm_crtc *crtc, void *usr);
Clarence Ipa18d4832017-03-13 12:35:44 -070097 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 Kulkarni40e38162016-06-26 22:12:09 -0400106 * struct sde_crtc - virtualized CRTC data structure
107 * @base : Base drm crtc structure
108 * @name : ASCII description of this crtc
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400109 * @num_ctls : Number of ctl paths in use
110 * @num_mixers : Number of mixers in use
Lloyd Atkinsona9d7e752017-01-17 16:31:43 -0500111 * @mixers : List of active mixers
Lloyd Atkinson9eabe7a2016-09-14 13:39:15 -0400112 * @event : Pointer to last received drm vblank event. If there is a
113 * pending vblank event, this will be non-null.
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400114 * @vsync_count : Running count of received vsync events
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -0400115 * @drm_requested_vblank : Whether vblanks have been enabled in the encoder
Clarence Ip7a753bb2016-07-07 11:47:44 -0400116 * @property_info : Opaque structure for generic property support
117 * @property_defaults : Array of default values for generic property support
Dhaval Patel39323d42017-03-01 23:48:24 -0800118 * @output_fence : output release fence context
Clarence Ip8f7366c2016-07-05 12:15:26 -0400119 * @stage_cfg : H/w mixer stage configuration
120 * @debugfs_root : Parent of debugfs node
Alan Kwong07da0982016-11-04 12:57:45 -0400121 * @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 Ip7f70ce42017-03-20 06:53:46 -0700124 * @suspend : whether or not a suspend operation is in progress
Gopikrishnaiah Anandane0e5e0c2016-05-25 11:05:33 -0700125 * @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 Anandan9ba43782017-01-31 18:23:08 -0800128 * @ad_dirty: list containing ad properties that are dirty
129 * @ad_active: list containing ad properties that are active
Dhaval Patel3fbe6bf2016-10-20 20:00:41 -0700130 * @crtc_lock : crtc lock around create, destroy and access.
Alan Kwong628d19e2016-10-31 13:50:13 -0400131 * @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 Ipa18d4832017-03-13 12:35:44 -0700135 * @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 Patelf9245d62017-03-28 16:24:00 -0700140 * @misr_enable : boolean entry indicates misr enable/disable status.
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -0700141 * @power_event : registered power event handle
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400142 */
143struct sde_crtc {
144 struct drm_crtc base;
Clarence Ip8f7366c2016-07-05 12:15:26 -0400145 char name[SDE_CRTC_NAME_SIZE];
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400146
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400147 /* HW Resources reserved for the crtc */
Lloyd Atkinsonc44a52e2016-08-16 16:40:17 -0400148 u32 num_ctls;
149 u32 num_mixers;
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400150 struct sde_crtc_mixer mixers[CRTC_DUAL_MIXERS];
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400151
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400152 struct drm_pending_vblank_event *event;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400153 u32 vsync_count;
Clarence Ip8f7366c2016-07-05 12:15:26 -0400154
Clarence Ip7a753bb2016-07-07 11:47:44 -0400155 struct msm_property_info property_info;
156 struct msm_property_data property_data[CRTC_PROP_COUNT];
Dhaval Patele4a5dda2016-10-13 19:29:30 -0700157 struct drm_property_blob *blob_info;
Clarence Ip7a753bb2016-07-07 11:47:44 -0400158
Clarence Ip24f80662016-06-13 19:05:32 -0400159 /* output fence support */
Dhaval Patel39323d42017-03-01 23:48:24 -0800160 struct sde_fence_context output_fence;
Clarence Ip24f80662016-06-13 19:05:32 -0400161
Clarence Ip8f7366c2016-07-05 12:15:26 -0400162 struct sde_hw_stage_cfg stage_cfg;
163 struct dentry *debugfs_root;
Gopikrishnaiah Anandane0e5e0c2016-05-25 11:05:33 -0700164
Alan Kwong07da0982016-11-04 12:57:45 -0400165 u32 vblank_cb_count;
166 ktime_t vblank_cb_time;
167 atomic_t vblank_refcount;
Clarence Ip7f70ce42017-03-20 06:53:46 -0700168 bool suspend;
Alan Kwong07da0982016-11-04 12:57:45 -0400169
Gopikrishnaiah Anandane0e5e0c2016-05-25 11:05:33 -0700170 struct list_head feature_list;
171 struct list_head active_list;
172 struct list_head dirty_list;
Gopikrishnaiah Anandan9ba43782017-01-31 18:23:08 -0800173 struct list_head ad_dirty;
174 struct list_head ad_active;
Gopikrishnaiah Anandande2c81b2017-03-15 12:41:29 -0700175 struct list_head user_event_list;
Dhaval Patel3fbe6bf2016-10-20 20:00:41 -0700176
177 struct mutex crtc_lock;
Alan Kwong628d19e2016-10-31 13:50:13 -0400178
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 Ipa18d4832017-03-13 12:35:44 -0700183
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 Patelf9245d62017-03-28 16:24:00 -0700190 bool misr_enable;
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -0700191
192 struct sde_power_event *power_event;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400193};
194
195#define to_sde_crtc(x) container_of(x, struct sde_crtc, base)
196
Clarence Ip7a753bb2016-07-07 11:47:44 -0400197/**
Alan Kwongcdb2f282017-03-18 13:42:06 -0700198 * struct sde_crtc_res_ops - common operations for crtc resources
199 * @get: get given resource
200 * @put: put given resource
201 */
202struct 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 */
225struct 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 */
241struct sde_crtc_respool {
242 u32 sequence_id;
243 struct list_head res_list;
244 struct sde_crtc_res_ops ops;
245};
246
247/**
Clarence Ip7a753bb2016-07-07 11:47:44 -0400248 * struct sde_crtc_state - sde container for atomic crtc state
249 * @base: Base drm crtc state structure
Clarence Ip0d0e96d2016-10-24 18:13:13 -0400250 * @connectors : Currently associated drm connectors
251 * @num_connectors: Number of associated drm connectors
Alan Kwong67a3f792016-11-01 23:16:53 -0400252 * @intf_mode : Interface mode of the primary connector
Dhaval Patel4d424602017-02-18 19:40:14 -0800253 * @rsc_client : sde rsc client when mode is valid
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400254 * @crtc_roi : Current CRTC ROI. Possibly sub-rectangle of mode.
255 * Origin top left of CRTC.
Lloyd Atkinson73fb8092017-02-08 16:02:55 -0500256 * @lm_bounds : LM boundaries based on current mode full resolution, no ROI.
257 * Origin top left of CRTC.
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400258 * @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 Ip7a753bb2016-07-07 11:47:44 -0400261 * @property_values: Current crtc property values
Clarence Ipcae1bb62016-07-07 12:07:13 -0400262 * @input_fence_timeout_ns : Cached input fence timeout, in ns
Clarence Ip7a753bb2016-07-07 11:47:44 -0400263 * @property_blobs: Reference pointers for blob properties
Veera Sundaram Sankaran3171ff82017-01-04 14:34:47 -0800264 * @num_dim_layers: Number of dim layers
265 * @dim_layer: Dim layer configs
Alan Kwong9aa061c2016-11-06 21:17:12 -0500266 * @cur_perf: current performance state
267 * @new_perf: new performance state
Alan Kwong4dd64c82017-02-04 18:41:51 -0800268 * @sbuf_cfg: stream buffer configuration
Alan Kwong4aacd532017-02-04 18:51:33 -0800269 * @sbuf_prefill_line: number of line for inline rotator prefetch
Clarence Ip7a753bb2016-07-07 11:47:44 -0400270 */
271struct sde_crtc_state {
272 struct drm_crtc_state base;
Clarence Ip0d0e96d2016-10-24 18:13:13 -0400273
274 struct drm_connector *connectors[MAX_CONNECTORS];
275 int num_connectors;
Alan Kwong67a3f792016-11-01 23:16:53 -0400276 enum sde_intf_mode intf_mode;
Dhaval Patel4d424602017-02-18 19:40:14 -0800277 struct sde_rsc_client *rsc_client;
Dhaval Patel82c8dbc2017-02-18 23:15:10 -0800278 bool rsc_update;
Clarence Ip0d0e96d2016-10-24 18:13:13 -0400279
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400280 struct sde_rect crtc_roi;
Lloyd Atkinson73fb8092017-02-08 16:02:55 -0500281 struct sde_rect lm_bounds[CRTC_DUAL_MIXERS];
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400282 struct sde_rect lm_roi[CRTC_DUAL_MIXERS];
283 struct msm_roi_list user_roi_list;
Lloyd Atkinsona9d7e752017-01-17 16:31:43 -0500284
Clarence Ip7a753bb2016-07-07 11:47:44 -0400285 uint64_t property_values[CRTC_PROP_COUNT];
Clarence Ipcae1bb62016-07-07 12:07:13 -0400286 uint64_t input_fence_timeout_ns;
Clarence Ip7a753bb2016-07-07 11:47:44 -0400287 struct drm_property_blob *property_blobs[CRTC_PROP_COUNT];
Veera Sundaram Sankaran3171ff82017-01-04 14:34:47 -0800288 uint32_t num_dim_layers;
289 struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS];
Alan Kwong9aa061c2016-11-06 21:17:12 -0500290
291 struct sde_core_perf_params cur_perf;
292 struct sde_core_perf_params new_perf;
Alan Kwong4dd64c82017-02-04 18:41:51 -0800293 struct sde_ctl_sbuf_cfg sbuf_cfg;
Alan Kwong4aacd532017-02-04 18:51:33 -0800294 u64 sbuf_prefill_line;
Alan Kwongcdb2f282017-03-18 13:42:06 -0700295
296 struct sde_crtc_respool rp;
Clarence Ip7a753bb2016-07-07 11:47:44 -0400297};
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 Patel48c76022016-09-01 17:51:23 -0700311static 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 Atkinson9eabe7a2016-09-14 13:39:15 -0400321/**
Veera Sundaram Sankaranc9efbec2017-03-29 18:59:05 -0700322 * sde_crtc_frame_pending - retun the number of pending frames
323 * @crtc: Pointer to drm crtc object
324 */
325static 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 Atkinson9eabe7a2016-09-14 13:39:15 -0400337 * 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 */
341int 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 */
347void sde_crtc_commit_kickoff(struct drm_crtc *crtc);
348
349/**
Clarence Ip0d0e96d2016-10-24 18:13:13 -0400350 * sde_crtc_prepare_commit - callback to prepare for output fences
Lloyd Atkinson9eabe7a2016-09-14 13:39:15 -0400351 * @crtc: Pointer to drm crtc object
Clarence Ip0d0e96d2016-10-24 18:13:13 -0400352 * @old_state: Pointer to drm crtc old state object
Lloyd Atkinson9eabe7a2016-09-14 13:39:15 -0400353 */
Clarence Ip0d0e96d2016-10-24 18:13:13 -0400354void 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 */
362void sde_crtc_complete_commit(struct drm_crtc *crtc,
363 struct drm_crtc_state *old_state);
Lloyd Atkinson9eabe7a2016-09-14 13:39:15 -0400364
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 */
371struct drm_crtc *sde_crtc_init(struct drm_device *dev, struct drm_plane *plane);
372
373/**
Lloyd Atkinson9eabe7a2016-09-14 13:39:15 -0400374 * 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 */
378void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
379
Clarence Ip0d0e96d2016-10-24 18:13:13 -0400380/**
Gopikrishnaiah Anandande2c81b2017-03-15 12:41:29 -0700381 * 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 */
387int 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 Kwong9aa061c2016-11-06 21:17:12 -0500392 * @crtc: Pointert to crtc
393 */
Alan Kwong3e985f02017-02-12 15:08:44 -0800394enum sde_intf_mode sde_crtc_get_intf_mode(struct drm_crtc *crtc);
Alan Kwong9aa061c2016-11-06 21:17:12 -0500395
396/**
Dhaval Patel4d424602017-02-18 19:40:14 -0800397 * sde_crtc_get_client_type - check the crtc type- rt, nrt, rsc, etc.
Alan Kwong9aa061c2016-11-06 21:17:12 -0500398 * @crtc: Pointer to crtc
399 */
Dhaval Patel82c8dbc2017-02-18 23:15:10 -0800400static inline enum sde_crtc_client_type sde_crtc_get_client_type(
401 struct drm_crtc *crtc)
Alan Kwong9aa061c2016-11-06 21:17:12 -0500402{
403 struct sde_crtc_state *cstate =
404 crtc ? to_sde_crtc_state(crtc->state) : NULL;
405
Dhaval Patel82c8dbc2017-02-18 23:15:10 -0800406 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 Kwong9aa061c2016-11-06 21:17:12 -0500411}
412
413/**
414 * sde_crtc_is_enabled - check if sde crtc is enabled or not
415 * @crtc: Pointer to crtc
416 */
417static inline bool sde_crtc_is_enabled(struct drm_crtc *crtc)
418{
419 return crtc ? crtc->enabled : false;
420}
421
Clarence Ipa18d4832017-03-13 12:35:44 -0700422/**
Alan Kwong56f1a942017-04-04 11:53:42 -0700423 * sde_crtc_get_inline_prefill - get current inline rotation prefill
424 * @crtc: Pointer to crtc
425 * return: number of prefill lines
426 */
427static 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 Ipa18d4832017-03-13 12:35:44 -0700436 * 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 */
442int sde_crtc_event_queue(struct drm_crtc *crtc,
Gopikrishnaiah Anandanb6b401f2017-03-14 16:39:49 -0700443 void (*func)(struct drm_crtc *crtc, void *usr), void *usr);
Clarence Ipa18d4832017-03-13 12:35:44 -0700444
Alan Kwongcdb2f282017-03-18 13:42:06 -0700445/**
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 */
454int 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 */
464void *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 */
473void sde_crtc_res_put(struct drm_crtc_state *state, u32 type, u64 tag);
474
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400475/**
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 */
482void sde_crtc_get_crtc_roi(struct drm_crtc_state *state,
483 const struct sde_rect **crtc_roi);
484
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400485#endif /* _SDE_CRTC_H_ */