blob: be36f421649c11cf86bd90d7fd3e7ef34bbbd86b [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 Kwongf366a012017-02-10 20:54:46 -080068/* use client provided clock/bandwidth parameters */
69#define SDE_ROTATION_EXT_PERF 0x100000
70
Alan Kwonga94684f2016-01-16 22:06:36 -050071/**********************************************************************
72 * configuration structures
73 **********************************************************************/
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -070074
Alan Kwongf94a2552016-12-28 09:41:22 -080075/*
76 * struct sde_rotation_buf_info - input/output buffer configuration
77 * @width: width of buffer region to be processed
78 * @height: height of buffer region to be processed
79 * @format: pixel format of buffer
80 * @comp_ratio: compression ratio for the session
Alan Kwong6bc64622017-02-04 17:36:03 -080081 * @sbuf: true if buffer is streaming buffer
Alan Kwongf94a2552016-12-28 09:41:22 -080082 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -070083struct sde_rotation_buf_info {
84 uint32_t width;
85 uint32_t height;
86 uint32_t format;
87 struct sde_mult_factor comp_ratio;
Alan Kwong6bc64622017-02-04 17:36:03 -080088 bool sbuf;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -070089};
90
Alan Kwongf94a2552016-12-28 09:41:22 -080091/*
92 * struct sde_rotation_config - rotation configuration for given session
93 * @session_id: identifier of the given session
94 * @input: input buffer information
95 * @output: output buffer information
96 * @frame_rate: session frame rate in fps
Alan Kwongf366a012017-02-10 20:54:46 -080097 * @clk_rate: requested rotator clock rate if SDE_ROTATION_EXT_PERF is set
98 * @data_bw: requested data bus bandwidth if SDE_ROTATION_EXT_PERF is set
Alan Kwongf94a2552016-12-28 09:41:22 -080099 * @flags: configuration flags, e.g. rotation angle, flip, etc...
100 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700101struct sde_rotation_config {
102 uint32_t session_id;
103 struct sde_rotation_buf_info input;
104 struct sde_rotation_buf_info output;
105 uint32_t frame_rate;
Alan Kwongf366a012017-02-10 20:54:46 -0800106 uint64_t clk_rate;
107 uint64_t data_bw;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700108 uint32_t flags;
109};
110
111enum sde_rotator_ts {
112 SDE_ROTATOR_TS_SRCQB, /* enqueue source buffer */
113 SDE_ROTATOR_TS_DSTQB, /* enqueue destination buffer */
114 SDE_ROTATOR_TS_FENCE, /* wait for source buffer fence */
115 SDE_ROTATOR_TS_QUEUE, /* wait for h/w resource */
116 SDE_ROTATOR_TS_COMMIT, /* prepare h/w command */
117 SDE_ROTATOR_TS_FLUSH, /* initiate h/w processing */
118 SDE_ROTATOR_TS_DONE, /* receive h/w completion */
119 SDE_ROTATOR_TS_RETIRE, /* signal destination buffer fence */
120 SDE_ROTATOR_TS_SRCDQB, /* dequeue source buffer */
121 SDE_ROTATOR_TS_DSTDQB, /* dequeue destination buffer */
122 SDE_ROTATOR_TS_MAX
123};
124
Benjamin Chan77aed192016-10-17 17:49:41 -0400125enum sde_rotator_clk_type {
126 SDE_ROTATOR_CLK_MDSS_AHB,
127 SDE_ROTATOR_CLK_MDSS_AXI,
128 SDE_ROTATOR_CLK_ROT_CORE,
129 SDE_ROTATOR_CLK_MDSS_ROT,
130 SDE_ROTATOR_CLK_MNOC_AHB,
Alan Kwonge1947ab2016-11-26 13:32:25 -0800131 SDE_ROTATOR_CLK_GCC_AHB,
132 SDE_ROTATOR_CLK_GCC_AXI,
Benjamin Chan77aed192016-10-17 17:49:41 -0400133 SDE_ROTATOR_CLK_MAX
134};
135
Alan Kwong6bc64622017-02-04 17:36:03 -0800136enum sde_rotator_trigger {
137 SDE_ROTATOR_TRIGGER_IMMEDIATE,
138 SDE_ROTATOR_TRIGGER_VIDEO,
139 SDE_ROTATOR_TRIGGER_COMMAND,
140};
141
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700142struct sde_rotation_item {
143 /* rotation request flag */
144 uint32_t flags;
145
Alan Kwong6bc64622017-02-04 17:36:03 -0800146 /* rotation trigger mode */
147 uint32_t trigger;
148
Alan Kwong498d59f2017-02-11 18:56:34 -0800149 /* prefill bandwidth in Bps */
150 uint64_t prefill_bw;
151
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700152 /* Source crop rectangle */
153 struct sde_rect src_rect;
154
155 /* Destination rectangle */
156 struct sde_rect dst_rect;
157
158 /* Input buffer for the request */
159 struct sde_layer_buffer input;
160
161 /* The output buffer for the request */
162 struct sde_layer_buffer output;
163
Alan Kwonga94684f2016-01-16 22:06:36 -0500164 /*
165 * DMA pipe selection for this request by client:
166 * 0: DMA pipe 0
167 * 1: DMA pipe 1
168 * or SDE_ROTATION_HW_ANY if client wants
169 * driver to allocate any that is available
170 *
171 * OR
172 *
173 * Reserved
174 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700175 uint32_t pipe_idx;
176
Alan Kwonga94684f2016-01-16 22:06:36 -0500177 /*
178 * Write-back block selection for this request by client:
179 * 0: Write-back block 0
180 * 1: Write-back block 1
181 * or SDE_ROTATION_HW_ANY if client wants
182 * driver to allocate any that is available
183 *
184 * OR
185 *
186 * Priority selection for this request by client:
187 * 0: Highest
188 * 1..n: Limited by the lowest available priority
189 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700190 uint32_t wb_idx;
191
Alan Kwonga94684f2016-01-16 22:06:36 -0500192 /*
193 * Sequence ID of this request within the session
194 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700195 uint32_t sequence_id;
196
197 /* Which session ID is this request scheduled on */
198 uint32_t session_id;
199
200 /* Time stamp for profiling purposes */
201 ktime_t *ts;
202};
203
204/*
205 * Defining characteristics about rotation work, that has corresponding
206 * fmt and roi checks in open session
207 */
208#define SDE_ROT_DEFINING_FLAG_BITS SDE_ROTATION_90
209
210struct sde_rot_entry;
211struct sde_rot_perf;
212
213struct sde_rot_clk {
214 struct clk *clk;
215 char clk_name[32];
216 unsigned long rate;
217};
218
219struct sde_rot_hw_resource {
220 u32 wb_id;
221 u32 pending_count;
222 atomic_t num_active;
223 int max_active;
224 wait_queue_head_t wait_queue;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700225};
226
227struct sde_rot_queue {
228 struct workqueue_struct *rot_work_queue;
229 struct sde_rot_timeline *timeline;
230 struct sde_rot_hw_resource *hw;
231};
232
Alan Kwongf94a2552016-12-28 09:41:22 -0800233/*
234 * struct sde_rot_entry_container - rotation request
235 * @list: list of active requests managed by rotator manager
236 * @flags: reserved
237 * @count: size of rotation entries
238 * @pending_count: count of entries pending completion
239 * @failed_count: count of entries failed completion
240 * @finished: true if client is finished with the request
241 * @retireq: workqueue to post completion notification
242 * @retire_work: work for completion notification
243 * @entries: array of rotation entries
244 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700245struct sde_rot_entry_container {
246 struct list_head list;
247 u32 flags;
248 u32 count;
249 atomic_t pending_count;
250 atomic_t failed_count;
251 struct workqueue_struct *retireq;
252 struct work_struct *retire_work;
Alan Kwongf94a2552016-12-28 09:41:22 -0800253 bool finished;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700254 struct sde_rot_entry *entries;
255};
256
257struct sde_rot_mgr;
258struct sde_rot_file_private;
259
Alan Kwong6bc64622017-02-04 17:36:03 -0800260/*
261 * struct sde_rot_entry - rotation entry
262 * @item: rotation item
263 * @commit_work: work descriptor for commit handler
264 * @done_work: work descriptor for done handler
265 * @commitq: pointer to commit handler rotator queue
266 * @fenceq: pointer to fence signaling rotator queue
267 * @doneq: pointer to done handler rotator queue
268 * @request: pointer to containing request
269 * @src_buf: descriptor of source buffer
270 * @dst_buf: descriptor of destination buffer
271 * @input_fence: pointer to input fence for when input content is available
272 * @output_fence: pointer to output fence for when output content is available
273 * @output_signaled: true if output fence of this entry has been signaled
274 * @dnsc_factor_w: calculated width downscale factor for this entry
275 * @dnsc_factor_w: calculated height downscale factor for this entry
276 * @perf: pointer to performance configuration associated with this entry
277 * @work_assigned: true if this item is assigned to h/w queue/unit
278 * @private: pointer to controlling session context
279 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700280struct sde_rot_entry {
281 struct sde_rotation_item item;
282 struct work_struct commit_work;
283 struct work_struct done_work;
284 struct sde_rot_queue *commitq;
285 struct sde_rot_queue *fenceq;
286 struct sde_rot_queue *doneq;
287 struct sde_rot_entry_container *request;
288
289 struct sde_mdp_data src_buf;
290 struct sde_mdp_data dst_buf;
291
292 struct sde_rot_sync_fence *input_fence;
293
294 struct sde_rot_sync_fence *output_fence;
295 bool output_signaled;
296
297 u32 dnsc_factor_w;
298 u32 dnsc_factor_h;
299
300 struct sde_rot_perf *perf;
301 bool work_assigned; /* Used when cleaning up work_distribution */
302 struct sde_rot_file_private *private;
303};
304
Alan Kwong6bc64622017-02-04 17:36:03 -0800305/*
306 * struct sde_rot_perf - rotator session performance configuration
307 * @list: list of performance configuration under one session
308 * @config: current rotation configuration
309 * @clk_rate: current clock rate in Hz
310 * @bw: current bandwidth in byte per second
311 * @work_dis_lock: serialization lock for updating work distribution (not used)
312 * @work_distribution: work distribution among multiple hardware queue/unit
313 * @last_wb_idx: last queue/unit index, used to account for pre-distributed work
314 * @rdot_limit: read OT limit of this session
315 * @wrot_limit: write OT limit of this session
316 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700317struct sde_rot_perf {
318 struct list_head list;
319 struct sde_rotation_config config;
320 unsigned long clk_rate;
321 u64 bw;
322 struct mutex work_dis_lock;
323 u32 *work_distribution;
324 int last_wb_idx; /* last known wb index, used when above count is 0 */
Alan Kwongeffb5ee2016-03-12 19:47:45 -0500325 u32 rdot_limit;
326 u32 wrot_limit;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700327};
328
Alan Kwong6bc64622017-02-04 17:36:03 -0800329/*
330 * struct sde_rot_file_private - rotator manager per session context
331 * @list: list of all session context
332 * @req_list: list of rotation request for this session
333 * @perf_list: list of performance configuration for this session (only one)
334 * @mgr: pointer to the controlling rotator manager
335 * @fenceq: pointer to rotator queue to signal when entry is done
336 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700337struct sde_rot_file_private {
338 struct list_head list;
339 struct list_head req_list;
340 struct list_head perf_list;
341 struct sde_rot_mgr *mgr;
342 struct sde_rot_queue *fenceq;
343};
344
Alan Kwong6bc64622017-02-04 17:36:03 -0800345/*
346 * struct sde_rot_bus_data_type - rotator bus scaling configuration
347 * @bus_cale_pdata: pointer to bus scaling configuration table
348 * @bus_hdl: msm bus scaling handle
349 * @curr_bw_uc_idx; current usecase index into configuration table
350 * @curr_quota_val: current bandwidth request in byte per second
351 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700352struct sde_rot_bus_data_type {
353 struct msm_bus_scale_pdata *bus_scale_pdata;
354 u32 bus_hdl;
355 u32 curr_bw_uc_idx;
356 u64 curr_quota_val;
357};
358
Alan Kwong6bc64622017-02-04 17:36:03 -0800359/*
360 * struct sde_rot_mgr - core rotator manager
361 * @lock: serialization lock to rotator manager functions
362 * @device_suspended: 0 if device is not suspended; non-zero suspended
363 * @pdev: pointer to controlling platform device
364 * @device: pointer to controlling device
365 * @queue_count: number of hardware queue/unit available
366 * @commitq: array of rotator commit queue corresponding to hardware queue
367 * @doneq: array of rotator done queue corresponding to hardware queue
368 * @file_list: list of all sessions managed by rotator manager
369 * @pending_close_bw_vote: bandwidth of closed sessions with pending work
370 * @data_bus: data bus configuration state
371 * @reg_bus: register bus configuration state
372 * @module_power: power/clock configuration state
373 * @regulator_enable: true if foot switch is enabled; false otherwise
374 * @res_ref_cnt: reference count of how many times resource is requested
375 * @rot_enable_clk_cnt: reference count of how many times clock is requested
376 * @rot_clk: array of rotator and periphery clocks
377 * @num_rot_clk: size of the rotator clock array
378 * @rdot_limit: current read OT limit
379 * @wrot_limit: current write OT limit
380 * @hwacquire_timeout: maximum wait time for hardware availability in msec
381 * @pixel_per_clk: rotator hardware performance in pixel for clock
382 * @fudge_factor: fudge factor for clock calculation
383 * @overhead: software overhead for offline rotation in msec
384 * @sbuf_ctx: pointer to sbuf session context
385 * @ops_xxx: function pointers of rotator HAL layer
386 * @hw_data: private handle of rotator HAL layer
387 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700388struct sde_rot_mgr {
389 struct mutex lock;
390 atomic_t device_suspended;
391 struct platform_device *pdev;
392 struct device *device;
393
394 /*
395 * Managing rotation queues, depends on
396 * how many hw pipes available on the system
397 */
398 int queue_count;
399 struct sde_rot_queue *commitq;
400 struct sde_rot_queue *doneq;
401
402 /*
403 * managing all the open file sessions to bw calculations,
404 * and resource clean up during suspend
405 */
406 struct list_head file_list;
407
408 u64 pending_close_bw_vote;
409 struct sde_rot_bus_data_type data_bus;
410 struct sde_rot_bus_data_type reg_bus;
411
412 /* Module power is only used for regulator management */
413 struct sde_module_power module_power;
414 bool regulator_enable;
415
416 int res_ref_cnt;
417 int rot_enable_clk_cnt;
418 struct sde_rot_clk *rot_clk;
419 int num_rot_clk;
Alan Kwongeffb5ee2016-03-12 19:47:45 -0500420 u32 rdot_limit;
421 u32 wrot_limit;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700422
423 u32 hwacquire_timeout;
424 struct sde_mult_factor pixel_per_clk;
Benjamin Chandbe13112016-09-26 12:10:06 -0400425 struct sde_mult_factor fudge_factor;
426 struct sde_mult_factor overhead;
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700427
Alan Kwong6bc64622017-02-04 17:36:03 -0800428 struct sde_rot_file_private *sbuf_ctx;
429
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700430 int (*ops_config_hw)(struct sde_rot_hw_resource *hw,
431 struct sde_rot_entry *entry);
432 int (*ops_kickoff_entry)(struct sde_rot_hw_resource *hw,
433 struct sde_rot_entry *entry);
434 int (*ops_wait_for_entry)(struct sde_rot_hw_resource *hw,
435 struct sde_rot_entry *entry);
436 struct sde_rot_hw_resource *(*ops_hw_alloc)(struct sde_rot_mgr *mgr,
437 u32 pipe_id, u32 wb_id);
438 void (*ops_hw_free)(struct sde_rot_mgr *mgr,
439 struct sde_rot_hw_resource *hw);
440 int (*ops_hw_init)(struct sde_rot_mgr *mgr);
Benjamin Chan0f9e61d2016-09-16 16:01:09 -0400441 void (*ops_hw_pre_pmevent)(struct sde_rot_mgr *mgr, bool pmon);
442 void (*ops_hw_post_pmevent)(struct sde_rot_mgr *mgr, bool pmon);
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700443 void (*ops_hw_destroy)(struct sde_rot_mgr *mgr);
444 ssize_t (*ops_hw_show_caps)(struct sde_rot_mgr *mgr,
445 struct device_attribute *attr, char *buf, ssize_t len);
446 ssize_t (*ops_hw_show_state)(struct sde_rot_mgr *mgr,
447 struct device_attribute *attr, char *buf, ssize_t len);
448 int (*ops_hw_create_debugfs)(struct sde_rot_mgr *mgr,
449 struct dentry *debugfs_root);
450 int (*ops_hw_validate_entry)(struct sde_rot_mgr *mgr,
451 struct sde_rot_entry *entry);
Alan Kwongda16e442016-08-14 20:47:18 -0400452 u32 (*ops_hw_get_pixfmt)(struct sde_rot_mgr *mgr, int index,
453 bool input);
454 int (*ops_hw_is_valid_pixfmt)(struct sde_rot_mgr *mgr, u32 pixfmt,
455 bool input);
Alan Kwong6bc64622017-02-04 17:36:03 -0800456 int (*ops_hw_get_downscale_caps)(struct sde_rot_mgr *mgr, char *caps,
457 int len);
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700458
459 void *hw_data;
460};
461
Alan Kwongda16e442016-08-14 20:47:18 -0400462static inline int sde_rotator_is_valid_pixfmt(struct sde_rot_mgr *mgr,
463 u32 pixfmt, bool input)
464{
465 if (mgr && mgr->ops_hw_is_valid_pixfmt)
466 return mgr->ops_hw_is_valid_pixfmt(mgr, pixfmt, input);
467
468 return false;
469}
470
471static inline u32 sde_rotator_get_pixfmt(struct sde_rot_mgr *mgr,
472 int index, bool input)
473{
474 if (mgr && mgr->ops_hw_get_pixfmt)
475 return mgr->ops_hw_get_pixfmt(mgr, index, input);
476
477 return 0;
478}
479
Alan Kwong6bc64622017-02-04 17:36:03 -0800480static inline int sde_rotator_get_downscale_caps(struct sde_rot_mgr *mgr,
481 char *caps, int len)
482{
483 if (mgr && mgr->ops_hw_get_downscale_caps)
484 return mgr->ops_hw_get_downscale_caps(mgr, caps, len);
485
486 return 0;
487}
488
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700489static inline int __compare_session_item_rect(
490 struct sde_rotation_buf_info *s_rect,
491 struct sde_rect *i_rect, uint32_t i_fmt, bool src)
492{
493 if ((s_rect->width != i_rect->w) || (s_rect->height != i_rect->h) ||
494 (s_rect->format != i_fmt)) {
495 SDEROT_DBG(
496 "%s: session{%u,%u}f:%u mismatch from item{%u,%u}f:%u\n",
497 (src ? "src":"dst"), s_rect->width, s_rect->height,
498 s_rect->format, i_rect->w, i_rect->h, i_fmt);
499 return -EINVAL;
500 }
501 return 0;
502}
503
504/*
505 * Compare all important flag bits associated with rotation between session
506 * config and item request. Format and roi validation is done during open
507 * session and is based certain defining bits. If these defining bits are
508 * different in item request, there is a possibility that rotation item
509 * is not a valid configuration.
510 */
511static inline int __compare_session_rotations(uint32_t cfg_flag,
512 uint32_t item_flag)
513{
514 cfg_flag &= SDE_ROT_DEFINING_FLAG_BITS;
515 item_flag &= SDE_ROT_DEFINING_FLAG_BITS;
516 if (cfg_flag != item_flag) {
517 SDEROT_DBG(
518 "Rotation degree request different from open session\n");
519 return -EINVAL;
520 }
521 return 0;
522}
523
Alan Kwongf94a2552016-12-28 09:41:22 -0800524/*
525 * sde_rotator_core_init - initialize rotator manager for the given platform
526 * device
527 * @pmgr: Pointer to pointer of the newly initialized rotator manager
528 * @pdev: Pointer to platform device
529 * return: 0 if success; error code otherwise
530 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700531int sde_rotator_core_init(struct sde_rot_mgr **pmgr,
532 struct platform_device *pdev);
533
Alan Kwongf94a2552016-12-28 09:41:22 -0800534/*
535 * sde_rotator_core_destroy - destroy given rotator manager
536 * @mgr: Pointer to rotator manager
537 * return: none
538 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700539void sde_rotator_core_destroy(struct sde_rot_mgr *mgr);
540
Alan Kwongf94a2552016-12-28 09:41:22 -0800541/*
542 * sde_rotator_session_open - open a new rotator per file session
543 * @mgr: Pointer to rotator manager
544 * @pprivate: Pointer to pointer of the newly initialized per file session
545 * @session_id: identifier of the newly created session
546 * @queue: Pointer to fence queue of the new session
547 * return: 0 if success; error code otherwise
548 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700549int sde_rotator_session_open(struct sde_rot_mgr *mgr,
550 struct sde_rot_file_private **pprivate, int session_id,
551 struct sde_rot_queue *queue);
552
Alan Kwongf94a2552016-12-28 09:41:22 -0800553/*
554 * sde_rotator_session_close - close the given rotator per file session
555 * @mgr: Pointer to rotator manager
556 * @private: Pointer to per file session
557 * @session_id: identifier of the session
558 * return: none
559 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700560void sde_rotator_session_close(struct sde_rot_mgr *mgr,
561 struct sde_rot_file_private *private, int session_id);
562
Alan Kwongf94a2552016-12-28 09:41:22 -0800563/*
564 * sde_rotator_session_config - configure the given rotator per file session
565 * @mgr: Pointer to rotator manager
566 * @private: Pointer to per file session
567 * @config: Pointer to rotator configuration
568 * return: 0 if success; error code otherwise
569 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700570int sde_rotator_session_config(struct sde_rot_mgr *mgr,
571 struct sde_rot_file_private *private,
572 struct sde_rotation_config *config);
573
Alan Kwongf94a2552016-12-28 09:41:22 -0800574/*
575 * sde_rotator_req_init - allocate a new request and initialzie with given
576 * array of rotation items
577 * @rot_dev: Pointer to rotator device
578 * @private: Pointer to rotator manager per file context
579 * @items: Pointer to array of rotation item
580 * @count: size of rotation item array
581 * @flags: rotation request flags
582 * return: Pointer to new rotation request if success; ERR_PTR otherwise
583 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700584struct sde_rot_entry_container *sde_rotator_req_init(
585 struct sde_rot_mgr *rot_dev,
586 struct sde_rot_file_private *private,
587 struct sde_rotation_item *items,
588 u32 count, u32 flags);
589
Alan Kwongf94a2552016-12-28 09:41:22 -0800590/*
591 * sde_rotator_req_finish - notify manager that client is finished with the
592 * given request and manager can release the request as required
593 * @rot_dev: Pointer to rotator device
594 * @private: Pointer to rotator manager per file context
595 * @req: Pointer to rotation request
596 * return: none
597 */
598void sde_rotator_req_finish(struct sde_rot_mgr *mgr,
599 struct sde_rot_file_private *private,
600 struct sde_rot_entry_container *req);
601
602/*
603 * sde_rotator_handle_request_common - add the given request to rotator
604 * manager and clean up completed requests
605 * @rot_dev: Pointer to rotator device
606 * @private: Pointer to rotator manager per file context
607 * @req: Pointer to rotation request
608 * return: 0 if success; error code otherwise
609 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700610int sde_rotator_handle_request_common(struct sde_rot_mgr *rot_dev,
611 struct sde_rot_file_private *ctx,
Alan Kwongf94a2552016-12-28 09:41:22 -0800612 struct sde_rot_entry_container *req);
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700613
Alan Kwongf94a2552016-12-28 09:41:22 -0800614/*
615 * sde_rotator_queue_request - queue/schedule the given request for h/w commit
616 * @rot_dev: Pointer to rotator device
617 * @private: Pointer to rotator manager per file context
618 * @req: Pointer to rotation request
619 * return: 0 if success; error code otherwise
620 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700621void sde_rotator_queue_request(struct sde_rot_mgr *rot_dev,
622 struct sde_rot_file_private *ctx,
623 struct sde_rot_entry_container *req);
624
Alan Kwongf94a2552016-12-28 09:41:22 -0800625/*
Alan Kwong6bc64622017-02-04 17:36:03 -0800626 * sde_rotator_commit_request - queue/schedule the given request and wait
627 * until h/w commit
628 * @rot_dev: Pointer to rotator device
629 * @private: Pointer to rotator manager per file context
630 * @req: Pointer to rotation request
631 * return: 0 if success; error code otherwise
632 */
633void sde_rotator_commit_request(struct sde_rot_mgr *mgr,
634 struct sde_rot_file_private *ctx,
635 struct sde_rot_entry_container *req);
636
637/*
Alan Kwongf94a2552016-12-28 09:41:22 -0800638 * sde_rotator_verify_config_all - verify given rotation configuration
639 * @rot_dev: Pointer to rotator device
640 * @config: Pointer to rotator configuration
641 * return: 0 if success; error code otherwise
642 */
Benjamin Chan59a06052017-01-12 18:06:03 -0500643int sde_rotator_verify_config_all(struct sde_rot_mgr *rot_dev,
644 struct sde_rotation_config *config);
645
Alan Kwongf94a2552016-12-28 09:41:22 -0800646/*
647 * sde_rotator_verify_config_input - verify rotation input configuration
648 * @rot_dev: Pointer to rotator device
649 * @config: Pointer to rotator configuration
650 * return: 0 if success; error code otherwise
651 */
Benjamin Chan59a06052017-01-12 18:06:03 -0500652int sde_rotator_verify_config_input(struct sde_rot_mgr *rot_dev,
653 struct sde_rotation_config *config);
654
Alan Kwongf94a2552016-12-28 09:41:22 -0800655/*
656 * sde_rotator_verify_config_output - verify rotation output configuration
657 * @rot_dev: Pointer to rotator device
658 * @config: Pointer to rotator configuration
659 * return: 0 if success; error code otherwise
660 */
Benjamin Chan59a06052017-01-12 18:06:03 -0500661int sde_rotator_verify_config_output(struct sde_rot_mgr *rot_dev,
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700662 struct sde_rotation_config *config);
663
Alan Kwongf94a2552016-12-28 09:41:22 -0800664/*
665 * sde_rotator_validate_request - validates given rotation request with
666 * previous rotator configuration
667 * @rot_dev: Pointer to rotator device
668 * @private: Pointer to rotator manager per file context
669 * @req: Pointer to rotation request
670 * return: 0 if success; error code otherwise
671 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700672int sde_rotator_validate_request(struct sde_rot_mgr *rot_dev,
673 struct sde_rot_file_private *ctx,
674 struct sde_rot_entry_container *req);
675
Alan Kwongf94a2552016-12-28 09:41:22 -0800676/*
677 * sde_rotator_clk_ctrl - enable/disable rotator clock with reference counting
678 * @mgr: Pointer to rotator manager
679 * @enable: true to enable clock; false to disable clock
680 * return: 0 if success; error code otherwise
681 */
Benjamin Chan0f9e61d2016-09-16 16:01:09 -0400682int sde_rotator_clk_ctrl(struct sde_rot_mgr *mgr, int enable);
683
Alan Kwongf94a2552016-12-28 09:41:22 -0800684/*
685 * sde_rot_mgr_lock - serialization lock prior to rotator manager calls
686 * @mgr: Pointer to rotator manager
687 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700688static inline void sde_rot_mgr_lock(struct sde_rot_mgr *mgr)
689{
690 mutex_lock(&mgr->lock);
691}
692
Alan Kwongf94a2552016-12-28 09:41:22 -0800693/*
694 * sde_rot_mgr_lock - serialization unlock after rotator manager calls
695 * @mgr: Pointer to rotator manager
696 */
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700697static inline void sde_rot_mgr_unlock(struct sde_rot_mgr *mgr)
698{
699 mutex_unlock(&mgr->lock);
700}
701
Alan Kwong3428f672016-04-18 12:32:06 -0400702#if defined(CONFIG_PM)
Adrian Salido-Moreno5c150382016-04-06 09:29:37 -0700703int sde_rotator_runtime_resume(struct device *dev);
704int sde_rotator_runtime_suspend(struct device *dev);
705int sde_rotator_runtime_idle(struct device *dev);
706#endif
707
708#if defined(CONFIG_PM_SLEEP)
709int sde_rotator_pm_suspend(struct device *dev);
710int sde_rotator_pm_resume(struct device *dev);
711#endif
712
713#if defined(CONFIG_PM) && !defined(CONFIG_PM_SLEEP)
714int sde_rotator_suspend(struct platform_device *dev, pm_message_t state);
715int sde_rotator_resume(struct platform_device *dev);
716#else
717#define sde_rotator_suspend NULL
718#define sde_rotator_resume NULL
719#endif
720#endif /* __SDE_ROTATOR_CORE_H__ */