blob: 6ee1d8d0cc04f93ce1f97ad2a80e8af8943dce57 [file] [log] [blame]
Benjamin Chan59a06052017-01-12 18:06:03 -05001/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#ifndef SDE_ROTATOR_CORE_H
15#define SDE_ROTATOR_CORE_H
16
17#include <linux/list.h>
18#include <linux/file.h>
19#include <linux/ktime.h>
20#include <linux/mutex.h>
21#include <linux/types.h>
22#include <linux/cdev.h>
23#include <linux/pm_runtime.h>
24
25#include "sde_rotator_base.h"
26#include "sde_rotator_util.h"
27#include "sde_rotator_sync.h"
28
29/**********************************************************************
30 * Rotation request flag
31 **********************************************************************/
32/* no rotation flag */
33#define SDE_ROTATION_NOP 0x01
34
35/* left/right flip */
36#define SDE_ROTATION_FLIP_LR 0x02
37
38/* up/down flip */
39#define SDE_ROTATION_FLIP_UD 0x04
40
41/* rotate 90 degree */
42#define SDE_ROTATION_90 0x08
43
44/* rotate 180 degre */
45#define SDE_ROTATION_180 (SDE_ROTATION_FLIP_LR | SDE_ROTATION_FLIP_UD)
46
47/* rotate 270 degree */
48#define SDE_ROTATION_270 (SDE_ROTATION_90 | SDE_ROTATION_180)
49
50/* format is interlaced */
51#define SDE_ROTATION_DEINTERLACE 0x10
52
53/* secure data */
54#define SDE_ROTATION_SECURE 0x80
55
56/* verify input configuration only */
57#define SDE_ROTATION_VERIFY_INPUT_ONLY 0x10000
58
59/* use client provided dma buf instead of ion fd */
60#define SDE_ROTATION_EXT_DMA_BUF 0x20000
61
Abhijit Kulkarni298c8232016-09-26 22:32:10 -070062/* secure camera operation*/
63#define SDE_ROTATION_SECURE_CAMERA 0x40000
64
Alan Kwong6bc64622017-02-04 17:36:03 -080065/* use client mapped i/o virtual address */
66#define SDE_ROTATION_EXT_IOVA 0x80000
67
Alan Kwonga94684f2016-01-16 22:06:36 -050068/**********************************************************************
69 * configuration structures
70 **********************************************************************/
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -070071
Alan Kwongf94a2552016-12-28 09:41:22 -080072/*
73 * struct sde_rotation_buf_info - input/output buffer configuration
74 * @width: width of buffer region to be processed
75 * @height: height of buffer region to be processed
76 * @format: pixel format of buffer
77 * @comp_ratio: compression ratio for the session
Alan Kwong6bc64622017-02-04 17:36:03 -080078 * @sbuf: true if buffer is streaming buffer
Alan Kwongf94a2552016-12-28 09:41:22 -080079 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -070080struct sde_rotation_buf_info {
81 uint32_t width;
82 uint32_t height;
83 uint32_t format;
84 struct sde_mult_factor comp_ratio;
Alan Kwong6bc64622017-02-04 17:36:03 -080085 bool sbuf;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -070086};
87
Alan Kwongf94a2552016-12-28 09:41:22 -080088/*
89 * struct sde_rotation_config - rotation configuration for given session
90 * @session_id: identifier of the given session
91 * @input: input buffer information
92 * @output: output buffer information
93 * @frame_rate: session frame rate in fps
94 * @flags: configuration flags, e.g. rotation angle, flip, etc...
95 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -070096struct sde_rotation_config {
97 uint32_t session_id;
98 struct sde_rotation_buf_info input;
99 struct sde_rotation_buf_info output;
100 uint32_t frame_rate;
101 uint32_t flags;
102};
103
104enum sde_rotator_ts {
105 SDE_ROTATOR_TS_SRCQB, /* enqueue source buffer */
106 SDE_ROTATOR_TS_DSTQB, /* enqueue destination buffer */
107 SDE_ROTATOR_TS_FENCE, /* wait for source buffer fence */
108 SDE_ROTATOR_TS_QUEUE, /* wait for h/w resource */
109 SDE_ROTATOR_TS_COMMIT, /* prepare h/w command */
110 SDE_ROTATOR_TS_FLUSH, /* initiate h/w processing */
111 SDE_ROTATOR_TS_DONE, /* receive h/w completion */
112 SDE_ROTATOR_TS_RETIRE, /* signal destination buffer fence */
113 SDE_ROTATOR_TS_SRCDQB, /* dequeue source buffer */
114 SDE_ROTATOR_TS_DSTDQB, /* dequeue destination buffer */
115 SDE_ROTATOR_TS_MAX
116};
117
Benjamin Chan77aed192016-10-17 17:49:41 -0400118enum sde_rotator_clk_type {
119 SDE_ROTATOR_CLK_MDSS_AHB,
120 SDE_ROTATOR_CLK_MDSS_AXI,
121 SDE_ROTATOR_CLK_ROT_CORE,
122 SDE_ROTATOR_CLK_MDSS_ROT,
123 SDE_ROTATOR_CLK_MNOC_AHB,
Alan Kwonge1947ab2016-11-26 13:32:25 -0800124 SDE_ROTATOR_CLK_GCC_AHB,
125 SDE_ROTATOR_CLK_GCC_AXI,
Benjamin Chan77aed192016-10-17 17:49:41 -0400126 SDE_ROTATOR_CLK_MAX
127};
128
Alan Kwong6bc64622017-02-04 17:36:03 -0800129enum sde_rotator_trigger {
130 SDE_ROTATOR_TRIGGER_IMMEDIATE,
131 SDE_ROTATOR_TRIGGER_VIDEO,
132 SDE_ROTATOR_TRIGGER_COMMAND,
133};
134
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700135struct sde_rotation_item {
136 /* rotation request flag */
137 uint32_t flags;
138
Alan Kwong6bc64622017-02-04 17:36:03 -0800139 /* rotation trigger mode */
140 uint32_t trigger;
141
Alan Kwong498d59f2017-02-11 18:56:34 -0800142 /* prefill bandwidth in Bps */
143 uint64_t prefill_bw;
144
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700145 /* Source crop rectangle */
146 struct sde_rect src_rect;
147
148 /* Destination rectangle */
149 struct sde_rect dst_rect;
150
151 /* Input buffer for the request */
152 struct sde_layer_buffer input;
153
154 /* The output buffer for the request */
155 struct sde_layer_buffer output;
156
Alan Kwonga94684f2016-01-16 22:06:36 -0500157 /*
158 * DMA pipe selection for this request by client:
159 * 0: DMA pipe 0
160 * 1: DMA pipe 1
161 * or SDE_ROTATION_HW_ANY if client wants
162 * driver to allocate any that is available
163 *
164 * OR
165 *
166 * Reserved
167 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700168 uint32_t pipe_idx;
169
Alan Kwonga94684f2016-01-16 22:06:36 -0500170 /*
171 * Write-back block selection for this request by client:
172 * 0: Write-back block 0
173 * 1: Write-back block 1
174 * or SDE_ROTATION_HW_ANY if client wants
175 * driver to allocate any that is available
176 *
177 * OR
178 *
179 * Priority selection for this request by client:
180 * 0: Highest
181 * 1..n: Limited by the lowest available priority
182 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700183 uint32_t wb_idx;
184
Alan Kwonga94684f2016-01-16 22:06:36 -0500185 /*
186 * Sequence ID of this request within the session
187 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700188 uint32_t sequence_id;
189
190 /* Which session ID is this request scheduled on */
191 uint32_t session_id;
192
193 /* Time stamp for profiling purposes */
194 ktime_t *ts;
195};
196
197/*
198 * Defining characteristics about rotation work, that has corresponding
199 * fmt and roi checks in open session
200 */
201#define SDE_ROT_DEFINING_FLAG_BITS SDE_ROTATION_90
202
203struct sde_rot_entry;
204struct sde_rot_perf;
205
206struct sde_rot_clk {
207 struct clk *clk;
208 char clk_name[32];
209 unsigned long rate;
210};
211
212struct sde_rot_hw_resource {
213 u32 wb_id;
214 u32 pending_count;
215 atomic_t num_active;
216 int max_active;
217 wait_queue_head_t wait_queue;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700218};
219
220struct sde_rot_queue {
221 struct workqueue_struct *rot_work_queue;
222 struct sde_rot_timeline *timeline;
223 struct sde_rot_hw_resource *hw;
224};
225
Alan Kwongf94a2552016-12-28 09:41:22 -0800226/*
227 * struct sde_rot_entry_container - rotation request
228 * @list: list of active requests managed by rotator manager
229 * @flags: reserved
230 * @count: size of rotation entries
231 * @pending_count: count of entries pending completion
232 * @failed_count: count of entries failed completion
233 * @finished: true if client is finished with the request
234 * @retireq: workqueue to post completion notification
235 * @retire_work: work for completion notification
236 * @entries: array of rotation entries
237 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700238struct sde_rot_entry_container {
239 struct list_head list;
240 u32 flags;
241 u32 count;
242 atomic_t pending_count;
243 atomic_t failed_count;
244 struct workqueue_struct *retireq;
245 struct work_struct *retire_work;
Alan Kwongf94a2552016-12-28 09:41:22 -0800246 bool finished;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700247 struct sde_rot_entry *entries;
248};
249
250struct sde_rot_mgr;
251struct sde_rot_file_private;
252
Alan Kwong6bc64622017-02-04 17:36:03 -0800253/*
254 * struct sde_rot_entry - rotation entry
255 * @item: rotation item
256 * @commit_work: work descriptor for commit handler
257 * @done_work: work descriptor for done handler
258 * @commitq: pointer to commit handler rotator queue
259 * @fenceq: pointer to fence signaling rotator queue
260 * @doneq: pointer to done handler rotator queue
261 * @request: pointer to containing request
262 * @src_buf: descriptor of source buffer
263 * @dst_buf: descriptor of destination buffer
264 * @input_fence: pointer to input fence for when input content is available
265 * @output_fence: pointer to output fence for when output content is available
266 * @output_signaled: true if output fence of this entry has been signaled
267 * @dnsc_factor_w: calculated width downscale factor for this entry
268 * @dnsc_factor_w: calculated height downscale factor for this entry
269 * @perf: pointer to performance configuration associated with this entry
270 * @work_assigned: true if this item is assigned to h/w queue/unit
271 * @private: pointer to controlling session context
272 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700273struct sde_rot_entry {
274 struct sde_rotation_item item;
275 struct work_struct commit_work;
276 struct work_struct done_work;
277 struct sde_rot_queue *commitq;
278 struct sde_rot_queue *fenceq;
279 struct sde_rot_queue *doneq;
280 struct sde_rot_entry_container *request;
281
282 struct sde_mdp_data src_buf;
283 struct sde_mdp_data dst_buf;
284
285 struct sde_rot_sync_fence *input_fence;
286
287 struct sde_rot_sync_fence *output_fence;
288 bool output_signaled;
289
290 u32 dnsc_factor_w;
291 u32 dnsc_factor_h;
292
293 struct sde_rot_perf *perf;
294 bool work_assigned; /* Used when cleaning up work_distribution */
295 struct sde_rot_file_private *private;
296};
297
Alan Kwong6bc64622017-02-04 17:36:03 -0800298/*
299 * struct sde_rot_perf - rotator session performance configuration
300 * @list: list of performance configuration under one session
301 * @config: current rotation configuration
302 * @clk_rate: current clock rate in Hz
303 * @bw: current bandwidth in byte per second
304 * @work_dis_lock: serialization lock for updating work distribution (not used)
305 * @work_distribution: work distribution among multiple hardware queue/unit
306 * @last_wb_idx: last queue/unit index, used to account for pre-distributed work
307 * @rdot_limit: read OT limit of this session
308 * @wrot_limit: write OT limit of this session
309 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700310struct sde_rot_perf {
311 struct list_head list;
312 struct sde_rotation_config config;
313 unsigned long clk_rate;
314 u64 bw;
315 struct mutex work_dis_lock;
316 u32 *work_distribution;
317 int last_wb_idx; /* last known wb index, used when above count is 0 */
Alan Kwongeffb5ee2016-03-12 19:47:45 -0500318 u32 rdot_limit;
319 u32 wrot_limit;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700320};
321
Alan Kwong6bc64622017-02-04 17:36:03 -0800322/*
323 * struct sde_rot_file_private - rotator manager per session context
324 * @list: list of all session context
325 * @req_list: list of rotation request for this session
326 * @perf_list: list of performance configuration for this session (only one)
327 * @mgr: pointer to the controlling rotator manager
328 * @fenceq: pointer to rotator queue to signal when entry is done
329 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700330struct sde_rot_file_private {
331 struct list_head list;
332 struct list_head req_list;
333 struct list_head perf_list;
334 struct sde_rot_mgr *mgr;
335 struct sde_rot_queue *fenceq;
336};
337
Alan Kwong6bc64622017-02-04 17:36:03 -0800338/*
339 * struct sde_rot_bus_data_type - rotator bus scaling configuration
340 * @bus_cale_pdata: pointer to bus scaling configuration table
341 * @bus_hdl: msm bus scaling handle
342 * @curr_bw_uc_idx; current usecase index into configuration table
343 * @curr_quota_val: current bandwidth request in byte per second
344 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700345struct sde_rot_bus_data_type {
346 struct msm_bus_scale_pdata *bus_scale_pdata;
347 u32 bus_hdl;
348 u32 curr_bw_uc_idx;
349 u64 curr_quota_val;
350};
351
Alan Kwong6bc64622017-02-04 17:36:03 -0800352/*
353 * struct sde_rot_mgr - core rotator manager
354 * @lock: serialization lock to rotator manager functions
355 * @device_suspended: 0 if device is not suspended; non-zero suspended
356 * @pdev: pointer to controlling platform device
357 * @device: pointer to controlling device
358 * @queue_count: number of hardware queue/unit available
359 * @commitq: array of rotator commit queue corresponding to hardware queue
360 * @doneq: array of rotator done queue corresponding to hardware queue
361 * @file_list: list of all sessions managed by rotator manager
362 * @pending_close_bw_vote: bandwidth of closed sessions with pending work
363 * @data_bus: data bus configuration state
364 * @reg_bus: register bus configuration state
365 * @module_power: power/clock configuration state
366 * @regulator_enable: true if foot switch is enabled; false otherwise
367 * @res_ref_cnt: reference count of how many times resource is requested
368 * @rot_enable_clk_cnt: reference count of how many times clock is requested
369 * @rot_clk: array of rotator and periphery clocks
370 * @num_rot_clk: size of the rotator clock array
371 * @rdot_limit: current read OT limit
372 * @wrot_limit: current write OT limit
373 * @hwacquire_timeout: maximum wait time for hardware availability in msec
374 * @pixel_per_clk: rotator hardware performance in pixel for clock
375 * @fudge_factor: fudge factor for clock calculation
376 * @overhead: software overhead for offline rotation in msec
377 * @sbuf_ctx: pointer to sbuf session context
378 * @ops_xxx: function pointers of rotator HAL layer
379 * @hw_data: private handle of rotator HAL layer
380 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700381struct sde_rot_mgr {
382 struct mutex lock;
383 atomic_t device_suspended;
384 struct platform_device *pdev;
385 struct device *device;
386
387 /*
388 * Managing rotation queues, depends on
389 * how many hw pipes available on the system
390 */
391 int queue_count;
392 struct sde_rot_queue *commitq;
393 struct sde_rot_queue *doneq;
394
395 /*
396 * managing all the open file sessions to bw calculations,
397 * and resource clean up during suspend
398 */
399 struct list_head file_list;
400
401 u64 pending_close_bw_vote;
402 struct sde_rot_bus_data_type data_bus;
403 struct sde_rot_bus_data_type reg_bus;
404
405 /* Module power is only used for regulator management */
406 struct sde_module_power module_power;
407 bool regulator_enable;
408
409 int res_ref_cnt;
410 int rot_enable_clk_cnt;
411 struct sde_rot_clk *rot_clk;
412 int num_rot_clk;
Alan Kwongeffb5ee2016-03-12 19:47:45 -0500413 u32 rdot_limit;
414 u32 wrot_limit;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700415
416 u32 hwacquire_timeout;
417 struct sde_mult_factor pixel_per_clk;
Benjamin Chandbe13112016-09-26 12:10:06 -0400418 struct sde_mult_factor fudge_factor;
419 struct sde_mult_factor overhead;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700420
Alan Kwong6bc64622017-02-04 17:36:03 -0800421 struct sde_rot_file_private *sbuf_ctx;
422
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700423 int (*ops_config_hw)(struct sde_rot_hw_resource *hw,
424 struct sde_rot_entry *entry);
425 int (*ops_kickoff_entry)(struct sde_rot_hw_resource *hw,
426 struct sde_rot_entry *entry);
427 int (*ops_wait_for_entry)(struct sde_rot_hw_resource *hw,
428 struct sde_rot_entry *entry);
429 struct sde_rot_hw_resource *(*ops_hw_alloc)(struct sde_rot_mgr *mgr,
430 u32 pipe_id, u32 wb_id);
431 void (*ops_hw_free)(struct sde_rot_mgr *mgr,
432 struct sde_rot_hw_resource *hw);
433 int (*ops_hw_init)(struct sde_rot_mgr *mgr);
Benjamin Chan0f9e61d2016-09-16 16:01:09 -0400434 void (*ops_hw_pre_pmevent)(struct sde_rot_mgr *mgr, bool pmon);
435 void (*ops_hw_post_pmevent)(struct sde_rot_mgr *mgr, bool pmon);
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700436 void (*ops_hw_destroy)(struct sde_rot_mgr *mgr);
437 ssize_t (*ops_hw_show_caps)(struct sde_rot_mgr *mgr,
438 struct device_attribute *attr, char *buf, ssize_t len);
439 ssize_t (*ops_hw_show_state)(struct sde_rot_mgr *mgr,
440 struct device_attribute *attr, char *buf, ssize_t len);
441 int (*ops_hw_create_debugfs)(struct sde_rot_mgr *mgr,
442 struct dentry *debugfs_root);
443 int (*ops_hw_validate_entry)(struct sde_rot_mgr *mgr,
444 struct sde_rot_entry *entry);
Alan Kwongda16e442016-08-14 20:47:18 -0400445 u32 (*ops_hw_get_pixfmt)(struct sde_rot_mgr *mgr, int index,
446 bool input);
447 int (*ops_hw_is_valid_pixfmt)(struct sde_rot_mgr *mgr, u32 pixfmt,
448 bool input);
Alan Kwong6bc64622017-02-04 17:36:03 -0800449 int (*ops_hw_get_downscale_caps)(struct sde_rot_mgr *mgr, char *caps,
450 int len);
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700451
452 void *hw_data;
453};
454
Alan Kwongda16e442016-08-14 20:47:18 -0400455static inline int sde_rotator_is_valid_pixfmt(struct sde_rot_mgr *mgr,
456 u32 pixfmt, bool input)
457{
458 if (mgr && mgr->ops_hw_is_valid_pixfmt)
459 return mgr->ops_hw_is_valid_pixfmt(mgr, pixfmt, input);
460
461 return false;
462}
463
464static inline u32 sde_rotator_get_pixfmt(struct sde_rot_mgr *mgr,
465 int index, bool input)
466{
467 if (mgr && mgr->ops_hw_get_pixfmt)
468 return mgr->ops_hw_get_pixfmt(mgr, index, input);
469
470 return 0;
471}
472
Alan Kwong6bc64622017-02-04 17:36:03 -0800473static inline int sde_rotator_get_downscale_caps(struct sde_rot_mgr *mgr,
474 char *caps, int len)
475{
476 if (mgr && mgr->ops_hw_get_downscale_caps)
477 return mgr->ops_hw_get_downscale_caps(mgr, caps, len);
478
479 return 0;
480}
481
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700482static inline int __compare_session_item_rect(
483 struct sde_rotation_buf_info *s_rect,
484 struct sde_rect *i_rect, uint32_t i_fmt, bool src)
485{
486 if ((s_rect->width != i_rect->w) || (s_rect->height != i_rect->h) ||
487 (s_rect->format != i_fmt)) {
488 SDEROT_DBG(
489 "%s: session{%u,%u}f:%u mismatch from item{%u,%u}f:%u\n",
490 (src ? "src":"dst"), s_rect->width, s_rect->height,
491 s_rect->format, i_rect->w, i_rect->h, i_fmt);
492 return -EINVAL;
493 }
494 return 0;
495}
496
497/*
498 * Compare all important flag bits associated with rotation between session
499 * config and item request. Format and roi validation is done during open
500 * session and is based certain defining bits. If these defining bits are
501 * different in item request, there is a possibility that rotation item
502 * is not a valid configuration.
503 */
504static inline int __compare_session_rotations(uint32_t cfg_flag,
505 uint32_t item_flag)
506{
507 cfg_flag &= SDE_ROT_DEFINING_FLAG_BITS;
508 item_flag &= SDE_ROT_DEFINING_FLAG_BITS;
509 if (cfg_flag != item_flag) {
510 SDEROT_DBG(
511 "Rotation degree request different from open session\n");
512 return -EINVAL;
513 }
514 return 0;
515}
516
Alan Kwongf94a2552016-12-28 09:41:22 -0800517/*
518 * sde_rotator_core_init - initialize rotator manager for the given platform
519 * device
520 * @pmgr: Pointer to pointer of the newly initialized rotator manager
521 * @pdev: Pointer to platform device
522 * return: 0 if success; error code otherwise
523 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700524int sde_rotator_core_init(struct sde_rot_mgr **pmgr,
525 struct platform_device *pdev);
526
Alan Kwongf94a2552016-12-28 09:41:22 -0800527/*
528 * sde_rotator_core_destroy - destroy given rotator manager
529 * @mgr: Pointer to rotator manager
530 * return: none
531 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700532void sde_rotator_core_destroy(struct sde_rot_mgr *mgr);
533
Alan Kwongf94a2552016-12-28 09:41:22 -0800534/*
535 * sde_rotator_session_open - open a new rotator per file session
536 * @mgr: Pointer to rotator manager
537 * @pprivate: Pointer to pointer of the newly initialized per file session
538 * @session_id: identifier of the newly created session
539 * @queue: Pointer to fence queue of the new session
540 * return: 0 if success; error code otherwise
541 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700542int sde_rotator_session_open(struct sde_rot_mgr *mgr,
543 struct sde_rot_file_private **pprivate, int session_id,
544 struct sde_rot_queue *queue);
545
Alan Kwongf94a2552016-12-28 09:41:22 -0800546/*
547 * sde_rotator_session_close - close the given rotator per file session
548 * @mgr: Pointer to rotator manager
549 * @private: Pointer to per file session
550 * @session_id: identifier of the session
551 * return: none
552 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700553void sde_rotator_session_close(struct sde_rot_mgr *mgr,
554 struct sde_rot_file_private *private, int session_id);
555
Alan Kwongf94a2552016-12-28 09:41:22 -0800556/*
557 * sde_rotator_session_config - configure the given rotator per file session
558 * @mgr: Pointer to rotator manager
559 * @private: Pointer to per file session
560 * @config: Pointer to rotator configuration
561 * return: 0 if success; error code otherwise
562 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700563int sde_rotator_session_config(struct sde_rot_mgr *mgr,
564 struct sde_rot_file_private *private,
565 struct sde_rotation_config *config);
566
Alan Kwongf94a2552016-12-28 09:41:22 -0800567/*
568 * sde_rotator_req_init - allocate a new request and initialzie with given
569 * array of rotation items
570 * @rot_dev: Pointer to rotator device
571 * @private: Pointer to rotator manager per file context
572 * @items: Pointer to array of rotation item
573 * @count: size of rotation item array
574 * @flags: rotation request flags
575 * return: Pointer to new rotation request if success; ERR_PTR otherwise
576 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700577struct sde_rot_entry_container *sde_rotator_req_init(
578 struct sde_rot_mgr *rot_dev,
579 struct sde_rot_file_private *private,
580 struct sde_rotation_item *items,
581 u32 count, u32 flags);
582
Alan Kwongf94a2552016-12-28 09:41:22 -0800583/*
584 * sde_rotator_req_finish - notify manager that client is finished with the
585 * given request and manager can release the request as required
586 * @rot_dev: Pointer to rotator device
587 * @private: Pointer to rotator manager per file context
588 * @req: Pointer to rotation request
589 * return: none
590 */
591void sde_rotator_req_finish(struct sde_rot_mgr *mgr,
592 struct sde_rot_file_private *private,
593 struct sde_rot_entry_container *req);
594
595/*
596 * sde_rotator_handle_request_common - add the given request to rotator
597 * manager and clean up completed requests
598 * @rot_dev: Pointer to rotator device
599 * @private: Pointer to rotator manager per file context
600 * @req: Pointer to rotation request
601 * return: 0 if success; error code otherwise
602 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700603int sde_rotator_handle_request_common(struct sde_rot_mgr *rot_dev,
604 struct sde_rot_file_private *ctx,
Alan Kwongf94a2552016-12-28 09:41:22 -0800605 struct sde_rot_entry_container *req);
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700606
Alan Kwongf94a2552016-12-28 09:41:22 -0800607/*
608 * sde_rotator_queue_request - queue/schedule the given request for h/w commit
609 * @rot_dev: Pointer to rotator device
610 * @private: Pointer to rotator manager per file context
611 * @req: Pointer to rotation request
612 * return: 0 if success; error code otherwise
613 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700614void sde_rotator_queue_request(struct sde_rot_mgr *rot_dev,
615 struct sde_rot_file_private *ctx,
616 struct sde_rot_entry_container *req);
617
Alan Kwongf94a2552016-12-28 09:41:22 -0800618/*
Alan Kwong6bc64622017-02-04 17:36:03 -0800619 * sde_rotator_commit_request - queue/schedule the given request and wait
620 * until h/w commit
621 * @rot_dev: Pointer to rotator device
622 * @private: Pointer to rotator manager per file context
623 * @req: Pointer to rotation request
624 * return: 0 if success; error code otherwise
625 */
626void sde_rotator_commit_request(struct sde_rot_mgr *mgr,
627 struct sde_rot_file_private *ctx,
628 struct sde_rot_entry_container *req);
629
630/*
Alan Kwongf94a2552016-12-28 09:41:22 -0800631 * sde_rotator_verify_config_all - verify given rotation configuration
632 * @rot_dev: Pointer to rotator device
633 * @config: Pointer to rotator configuration
634 * return: 0 if success; error code otherwise
635 */
Benjamin Chan59a06052017-01-12 18:06:03 -0500636int sde_rotator_verify_config_all(struct sde_rot_mgr *rot_dev,
637 struct sde_rotation_config *config);
638
Alan Kwongf94a2552016-12-28 09:41:22 -0800639/*
640 * sde_rotator_verify_config_input - verify rotation input configuration
641 * @rot_dev: Pointer to rotator device
642 * @config: Pointer to rotator configuration
643 * return: 0 if success; error code otherwise
644 */
Benjamin Chan59a06052017-01-12 18:06:03 -0500645int sde_rotator_verify_config_input(struct sde_rot_mgr *rot_dev,
646 struct sde_rotation_config *config);
647
Alan Kwongf94a2552016-12-28 09:41:22 -0800648/*
649 * sde_rotator_verify_config_output - verify rotation output configuration
650 * @rot_dev: Pointer to rotator device
651 * @config: Pointer to rotator configuration
652 * return: 0 if success; error code otherwise
653 */
Benjamin Chan59a06052017-01-12 18:06:03 -0500654int sde_rotator_verify_config_output(struct sde_rot_mgr *rot_dev,
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700655 struct sde_rotation_config *config);
656
Alan Kwongf94a2552016-12-28 09:41:22 -0800657/*
658 * sde_rotator_validate_request - validates given rotation request with
659 * previous rotator configuration
660 * @rot_dev: Pointer to rotator device
661 * @private: Pointer to rotator manager per file context
662 * @req: Pointer to rotation request
663 * return: 0 if success; error code otherwise
664 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700665int sde_rotator_validate_request(struct sde_rot_mgr *rot_dev,
666 struct sde_rot_file_private *ctx,
667 struct sde_rot_entry_container *req);
668
Alan Kwongf94a2552016-12-28 09:41:22 -0800669/*
670 * sde_rotator_clk_ctrl - enable/disable rotator clock with reference counting
671 * @mgr: Pointer to rotator manager
672 * @enable: true to enable clock; false to disable clock
673 * return: 0 if success; error code otherwise
674 */
Benjamin Chan0f9e61d2016-09-16 16:01:09 -0400675int sde_rotator_clk_ctrl(struct sde_rot_mgr *mgr, int enable);
676
Alan Kwongf94a2552016-12-28 09:41:22 -0800677/*
678 * sde_rot_mgr_lock - serialization lock prior to rotator manager calls
679 * @mgr: Pointer to rotator manager
680 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700681static inline void sde_rot_mgr_lock(struct sde_rot_mgr *mgr)
682{
683 mutex_lock(&mgr->lock);
684}
685
Alan Kwongf94a2552016-12-28 09:41:22 -0800686/*
687 * sde_rot_mgr_lock - serialization unlock after rotator manager calls
688 * @mgr: Pointer to rotator manager
689 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700690static inline void sde_rot_mgr_unlock(struct sde_rot_mgr *mgr)
691{
692 mutex_unlock(&mgr->lock);
693}
694
Alan Kwong3428f672016-04-18 12:32:06 -0400695#if defined(CONFIG_PM)
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700696int sde_rotator_runtime_resume(struct device *dev);
697int sde_rotator_runtime_suspend(struct device *dev);
698int sde_rotator_runtime_idle(struct device *dev);
699#endif
700
701#if defined(CONFIG_PM_SLEEP)
702int sde_rotator_pm_suspend(struct device *dev);
703int sde_rotator_pm_resume(struct device *dev);
704#endif
705
706#if defined(CONFIG_PM) && !defined(CONFIG_PM_SLEEP)
707int sde_rotator_suspend(struct platform_device *dev, pm_message_t state);
708int sde_rotator_resume(struct platform_device *dev);
709#else
710#define sde_rotator_suspend NULL
711#define sde_rotator_resume NULL
712#endif
713#endif /* __SDE_ROTATOR_CORE_H__ */