Benjamin Chan | 59a0605 | 2017-01-12 18:06:03 -0500 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 2 | * |
| 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 Kulkarni | 298c823 | 2016-09-26 22:32:10 -0700 | [diff] [blame] | 62 | /* secure camera operation*/ |
| 63 | #define SDE_ROTATION_SECURE_CAMERA 0x40000 |
| 64 | |
Alan Kwong | a94684f | 2016-01-16 22:06:36 -0500 | [diff] [blame] | 65 | /********************************************************************** |
| 66 | * configuration structures |
| 67 | **********************************************************************/ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 68 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 69 | /* |
| 70 | * struct sde_rotation_buf_info - input/output buffer configuration |
| 71 | * @width: width of buffer region to be processed |
| 72 | * @height: height of buffer region to be processed |
| 73 | * @format: pixel format of buffer |
| 74 | * @comp_ratio: compression ratio for the session |
| 75 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 76 | struct sde_rotation_buf_info { |
| 77 | uint32_t width; |
| 78 | uint32_t height; |
| 79 | uint32_t format; |
| 80 | struct sde_mult_factor comp_ratio; |
| 81 | }; |
| 82 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 83 | /* |
| 84 | * struct sde_rotation_config - rotation configuration for given session |
| 85 | * @session_id: identifier of the given session |
| 86 | * @input: input buffer information |
| 87 | * @output: output buffer information |
| 88 | * @frame_rate: session frame rate in fps |
| 89 | * @flags: configuration flags, e.g. rotation angle, flip, etc... |
| 90 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 91 | struct sde_rotation_config { |
| 92 | uint32_t session_id; |
| 93 | struct sde_rotation_buf_info input; |
| 94 | struct sde_rotation_buf_info output; |
| 95 | uint32_t frame_rate; |
| 96 | uint32_t flags; |
| 97 | }; |
| 98 | |
| 99 | enum sde_rotator_ts { |
| 100 | SDE_ROTATOR_TS_SRCQB, /* enqueue source buffer */ |
| 101 | SDE_ROTATOR_TS_DSTQB, /* enqueue destination buffer */ |
| 102 | SDE_ROTATOR_TS_FENCE, /* wait for source buffer fence */ |
| 103 | SDE_ROTATOR_TS_QUEUE, /* wait for h/w resource */ |
| 104 | SDE_ROTATOR_TS_COMMIT, /* prepare h/w command */ |
| 105 | SDE_ROTATOR_TS_FLUSH, /* initiate h/w processing */ |
| 106 | SDE_ROTATOR_TS_DONE, /* receive h/w completion */ |
| 107 | SDE_ROTATOR_TS_RETIRE, /* signal destination buffer fence */ |
| 108 | SDE_ROTATOR_TS_SRCDQB, /* dequeue source buffer */ |
| 109 | SDE_ROTATOR_TS_DSTDQB, /* dequeue destination buffer */ |
| 110 | SDE_ROTATOR_TS_MAX |
| 111 | }; |
| 112 | |
Benjamin Chan | 77aed19 | 2016-10-17 17:49:41 -0400 | [diff] [blame] | 113 | enum sde_rotator_clk_type { |
| 114 | SDE_ROTATOR_CLK_MDSS_AHB, |
| 115 | SDE_ROTATOR_CLK_MDSS_AXI, |
| 116 | SDE_ROTATOR_CLK_ROT_CORE, |
| 117 | SDE_ROTATOR_CLK_MDSS_ROT, |
| 118 | SDE_ROTATOR_CLK_MNOC_AHB, |
Alan Kwong | e1947ab | 2016-11-26 13:32:25 -0800 | [diff] [blame] | 119 | SDE_ROTATOR_CLK_GCC_AHB, |
| 120 | SDE_ROTATOR_CLK_GCC_AXI, |
Benjamin Chan | 77aed19 | 2016-10-17 17:49:41 -0400 | [diff] [blame] | 121 | SDE_ROTATOR_CLK_MAX |
| 122 | }; |
| 123 | |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 124 | struct sde_rotation_item { |
| 125 | /* rotation request flag */ |
| 126 | uint32_t flags; |
| 127 | |
| 128 | /* Source crop rectangle */ |
| 129 | struct sde_rect src_rect; |
| 130 | |
| 131 | /* Destination rectangle */ |
| 132 | struct sde_rect dst_rect; |
| 133 | |
| 134 | /* Input buffer for the request */ |
| 135 | struct sde_layer_buffer input; |
| 136 | |
| 137 | /* The output buffer for the request */ |
| 138 | struct sde_layer_buffer output; |
| 139 | |
Alan Kwong | a94684f | 2016-01-16 22:06:36 -0500 | [diff] [blame] | 140 | /* |
| 141 | * DMA pipe selection for this request by client: |
| 142 | * 0: DMA pipe 0 |
| 143 | * 1: DMA pipe 1 |
| 144 | * or SDE_ROTATION_HW_ANY if client wants |
| 145 | * driver to allocate any that is available |
| 146 | * |
| 147 | * OR |
| 148 | * |
| 149 | * Reserved |
| 150 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 151 | uint32_t pipe_idx; |
| 152 | |
Alan Kwong | a94684f | 2016-01-16 22:06:36 -0500 | [diff] [blame] | 153 | /* |
| 154 | * Write-back block selection for this request by client: |
| 155 | * 0: Write-back block 0 |
| 156 | * 1: Write-back block 1 |
| 157 | * or SDE_ROTATION_HW_ANY if client wants |
| 158 | * driver to allocate any that is available |
| 159 | * |
| 160 | * OR |
| 161 | * |
| 162 | * Priority selection for this request by client: |
| 163 | * 0: Highest |
| 164 | * 1..n: Limited by the lowest available priority |
| 165 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 166 | uint32_t wb_idx; |
| 167 | |
Alan Kwong | a94684f | 2016-01-16 22:06:36 -0500 | [diff] [blame] | 168 | /* |
| 169 | * Sequence ID of this request within the session |
| 170 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 171 | uint32_t sequence_id; |
| 172 | |
| 173 | /* Which session ID is this request scheduled on */ |
| 174 | uint32_t session_id; |
| 175 | |
| 176 | /* Time stamp for profiling purposes */ |
| 177 | ktime_t *ts; |
| 178 | }; |
| 179 | |
| 180 | /* |
| 181 | * Defining characteristics about rotation work, that has corresponding |
| 182 | * fmt and roi checks in open session |
| 183 | */ |
| 184 | #define SDE_ROT_DEFINING_FLAG_BITS SDE_ROTATION_90 |
| 185 | |
| 186 | struct sde_rot_entry; |
| 187 | struct sde_rot_perf; |
| 188 | |
| 189 | struct sde_rot_clk { |
| 190 | struct clk *clk; |
| 191 | char clk_name[32]; |
| 192 | unsigned long rate; |
| 193 | }; |
| 194 | |
| 195 | struct sde_rot_hw_resource { |
| 196 | u32 wb_id; |
| 197 | u32 pending_count; |
| 198 | atomic_t num_active; |
| 199 | int max_active; |
| 200 | wait_queue_head_t wait_queue; |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 201 | }; |
| 202 | |
| 203 | struct sde_rot_queue { |
| 204 | struct workqueue_struct *rot_work_queue; |
| 205 | struct sde_rot_timeline *timeline; |
| 206 | struct sde_rot_hw_resource *hw; |
| 207 | }; |
| 208 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 209 | /* |
| 210 | * struct sde_rot_entry_container - rotation request |
| 211 | * @list: list of active requests managed by rotator manager |
| 212 | * @flags: reserved |
| 213 | * @count: size of rotation entries |
| 214 | * @pending_count: count of entries pending completion |
| 215 | * @failed_count: count of entries failed completion |
| 216 | * @finished: true if client is finished with the request |
| 217 | * @retireq: workqueue to post completion notification |
| 218 | * @retire_work: work for completion notification |
| 219 | * @entries: array of rotation entries |
| 220 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 221 | struct sde_rot_entry_container { |
| 222 | struct list_head list; |
| 223 | u32 flags; |
| 224 | u32 count; |
| 225 | atomic_t pending_count; |
| 226 | atomic_t failed_count; |
| 227 | struct workqueue_struct *retireq; |
| 228 | struct work_struct *retire_work; |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 229 | bool finished; |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 230 | struct sde_rot_entry *entries; |
| 231 | }; |
| 232 | |
| 233 | struct sde_rot_mgr; |
| 234 | struct sde_rot_file_private; |
| 235 | |
| 236 | struct sde_rot_entry { |
| 237 | struct sde_rotation_item item; |
| 238 | struct work_struct commit_work; |
| 239 | struct work_struct done_work; |
| 240 | struct sde_rot_queue *commitq; |
| 241 | struct sde_rot_queue *fenceq; |
| 242 | struct sde_rot_queue *doneq; |
| 243 | struct sde_rot_entry_container *request; |
| 244 | |
| 245 | struct sde_mdp_data src_buf; |
| 246 | struct sde_mdp_data dst_buf; |
| 247 | |
| 248 | struct sde_rot_sync_fence *input_fence; |
| 249 | |
| 250 | struct sde_rot_sync_fence *output_fence; |
| 251 | bool output_signaled; |
| 252 | |
| 253 | u32 dnsc_factor_w; |
| 254 | u32 dnsc_factor_h; |
| 255 | |
| 256 | struct sde_rot_perf *perf; |
| 257 | bool work_assigned; /* Used when cleaning up work_distribution */ |
| 258 | struct sde_rot_file_private *private; |
| 259 | }; |
| 260 | |
| 261 | struct sde_rot_perf { |
| 262 | struct list_head list; |
| 263 | struct sde_rotation_config config; |
| 264 | unsigned long clk_rate; |
| 265 | u64 bw; |
| 266 | struct mutex work_dis_lock; |
| 267 | u32 *work_distribution; |
| 268 | int last_wb_idx; /* last known wb index, used when above count is 0 */ |
Alan Kwong | effb5ee | 2016-03-12 19:47:45 -0500 | [diff] [blame] | 269 | u32 rdot_limit; |
| 270 | u32 wrot_limit; |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | struct sde_rot_file_private { |
| 274 | struct list_head list; |
| 275 | struct list_head req_list; |
| 276 | struct list_head perf_list; |
| 277 | struct sde_rot_mgr *mgr; |
| 278 | struct sde_rot_queue *fenceq; |
| 279 | }; |
| 280 | |
| 281 | struct sde_rot_bus_data_type { |
| 282 | struct msm_bus_scale_pdata *bus_scale_pdata; |
| 283 | u32 bus_hdl; |
| 284 | u32 curr_bw_uc_idx; |
| 285 | u64 curr_quota_val; |
| 286 | }; |
| 287 | |
| 288 | struct sde_rot_mgr { |
| 289 | struct mutex lock; |
| 290 | atomic_t device_suspended; |
| 291 | struct platform_device *pdev; |
| 292 | struct device *device; |
| 293 | |
| 294 | /* |
| 295 | * Managing rotation queues, depends on |
| 296 | * how many hw pipes available on the system |
| 297 | */ |
| 298 | int queue_count; |
| 299 | struct sde_rot_queue *commitq; |
| 300 | struct sde_rot_queue *doneq; |
| 301 | |
| 302 | /* |
| 303 | * managing all the open file sessions to bw calculations, |
| 304 | * and resource clean up during suspend |
| 305 | */ |
| 306 | struct list_head file_list; |
| 307 | |
| 308 | u64 pending_close_bw_vote; |
| 309 | struct sde_rot_bus_data_type data_bus; |
| 310 | struct sde_rot_bus_data_type reg_bus; |
| 311 | |
| 312 | /* Module power is only used for regulator management */ |
| 313 | struct sde_module_power module_power; |
| 314 | bool regulator_enable; |
| 315 | |
| 316 | int res_ref_cnt; |
| 317 | int rot_enable_clk_cnt; |
| 318 | struct sde_rot_clk *rot_clk; |
| 319 | int num_rot_clk; |
Alan Kwong | effb5ee | 2016-03-12 19:47:45 -0500 | [diff] [blame] | 320 | u32 rdot_limit; |
| 321 | u32 wrot_limit; |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 322 | |
| 323 | u32 hwacquire_timeout; |
| 324 | struct sde_mult_factor pixel_per_clk; |
Benjamin Chan | dbe1311 | 2016-09-26 12:10:06 -0400 | [diff] [blame] | 325 | struct sde_mult_factor fudge_factor; |
| 326 | struct sde_mult_factor overhead; |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 327 | |
| 328 | int (*ops_config_hw)(struct sde_rot_hw_resource *hw, |
| 329 | struct sde_rot_entry *entry); |
| 330 | int (*ops_kickoff_entry)(struct sde_rot_hw_resource *hw, |
| 331 | struct sde_rot_entry *entry); |
| 332 | int (*ops_wait_for_entry)(struct sde_rot_hw_resource *hw, |
| 333 | struct sde_rot_entry *entry); |
| 334 | struct sde_rot_hw_resource *(*ops_hw_alloc)(struct sde_rot_mgr *mgr, |
| 335 | u32 pipe_id, u32 wb_id); |
| 336 | void (*ops_hw_free)(struct sde_rot_mgr *mgr, |
| 337 | struct sde_rot_hw_resource *hw); |
| 338 | int (*ops_hw_init)(struct sde_rot_mgr *mgr); |
Benjamin Chan | 0f9e61d | 2016-09-16 16:01:09 -0400 | [diff] [blame] | 339 | void (*ops_hw_pre_pmevent)(struct sde_rot_mgr *mgr, bool pmon); |
| 340 | void (*ops_hw_post_pmevent)(struct sde_rot_mgr *mgr, bool pmon); |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 341 | void (*ops_hw_destroy)(struct sde_rot_mgr *mgr); |
| 342 | ssize_t (*ops_hw_show_caps)(struct sde_rot_mgr *mgr, |
| 343 | struct device_attribute *attr, char *buf, ssize_t len); |
| 344 | ssize_t (*ops_hw_show_state)(struct sde_rot_mgr *mgr, |
| 345 | struct device_attribute *attr, char *buf, ssize_t len); |
| 346 | int (*ops_hw_create_debugfs)(struct sde_rot_mgr *mgr, |
| 347 | struct dentry *debugfs_root); |
| 348 | int (*ops_hw_validate_entry)(struct sde_rot_mgr *mgr, |
| 349 | struct sde_rot_entry *entry); |
Alan Kwong | da16e44 | 2016-08-14 20:47:18 -0400 | [diff] [blame] | 350 | u32 (*ops_hw_get_pixfmt)(struct sde_rot_mgr *mgr, int index, |
| 351 | bool input); |
| 352 | int (*ops_hw_is_valid_pixfmt)(struct sde_rot_mgr *mgr, u32 pixfmt, |
| 353 | bool input); |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 354 | |
| 355 | void *hw_data; |
| 356 | }; |
| 357 | |
Alan Kwong | da16e44 | 2016-08-14 20:47:18 -0400 | [diff] [blame] | 358 | static inline int sde_rotator_is_valid_pixfmt(struct sde_rot_mgr *mgr, |
| 359 | u32 pixfmt, bool input) |
| 360 | { |
| 361 | if (mgr && mgr->ops_hw_is_valid_pixfmt) |
| 362 | return mgr->ops_hw_is_valid_pixfmt(mgr, pixfmt, input); |
| 363 | |
| 364 | return false; |
| 365 | } |
| 366 | |
| 367 | static inline u32 sde_rotator_get_pixfmt(struct sde_rot_mgr *mgr, |
| 368 | int index, bool input) |
| 369 | { |
| 370 | if (mgr && mgr->ops_hw_get_pixfmt) |
| 371 | return mgr->ops_hw_get_pixfmt(mgr, index, input); |
| 372 | |
| 373 | return 0; |
| 374 | } |
| 375 | |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 376 | static inline int __compare_session_item_rect( |
| 377 | struct sde_rotation_buf_info *s_rect, |
| 378 | struct sde_rect *i_rect, uint32_t i_fmt, bool src) |
| 379 | { |
| 380 | if ((s_rect->width != i_rect->w) || (s_rect->height != i_rect->h) || |
| 381 | (s_rect->format != i_fmt)) { |
| 382 | SDEROT_DBG( |
| 383 | "%s: session{%u,%u}f:%u mismatch from item{%u,%u}f:%u\n", |
| 384 | (src ? "src":"dst"), s_rect->width, s_rect->height, |
| 385 | s_rect->format, i_rect->w, i_rect->h, i_fmt); |
| 386 | return -EINVAL; |
| 387 | } |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | /* |
| 392 | * Compare all important flag bits associated with rotation between session |
| 393 | * config and item request. Format and roi validation is done during open |
| 394 | * session and is based certain defining bits. If these defining bits are |
| 395 | * different in item request, there is a possibility that rotation item |
| 396 | * is not a valid configuration. |
| 397 | */ |
| 398 | static inline int __compare_session_rotations(uint32_t cfg_flag, |
| 399 | uint32_t item_flag) |
| 400 | { |
| 401 | cfg_flag &= SDE_ROT_DEFINING_FLAG_BITS; |
| 402 | item_flag &= SDE_ROT_DEFINING_FLAG_BITS; |
| 403 | if (cfg_flag != item_flag) { |
| 404 | SDEROT_DBG( |
| 405 | "Rotation degree request different from open session\n"); |
| 406 | return -EINVAL; |
| 407 | } |
| 408 | return 0; |
| 409 | } |
| 410 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 411 | /* |
| 412 | * sde_rotator_core_init - initialize rotator manager for the given platform |
| 413 | * device |
| 414 | * @pmgr: Pointer to pointer of the newly initialized rotator manager |
| 415 | * @pdev: Pointer to platform device |
| 416 | * return: 0 if success; error code otherwise |
| 417 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 418 | int sde_rotator_core_init(struct sde_rot_mgr **pmgr, |
| 419 | struct platform_device *pdev); |
| 420 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 421 | /* |
| 422 | * sde_rotator_core_destroy - destroy given rotator manager |
| 423 | * @mgr: Pointer to rotator manager |
| 424 | * return: none |
| 425 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 426 | void sde_rotator_core_destroy(struct sde_rot_mgr *mgr); |
| 427 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 428 | /* |
| 429 | * sde_rotator_session_open - open a new rotator per file session |
| 430 | * @mgr: Pointer to rotator manager |
| 431 | * @pprivate: Pointer to pointer of the newly initialized per file session |
| 432 | * @session_id: identifier of the newly created session |
| 433 | * @queue: Pointer to fence queue of the new session |
| 434 | * return: 0 if success; error code otherwise |
| 435 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 436 | int sde_rotator_session_open(struct sde_rot_mgr *mgr, |
| 437 | struct sde_rot_file_private **pprivate, int session_id, |
| 438 | struct sde_rot_queue *queue); |
| 439 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 440 | /* |
| 441 | * sde_rotator_session_close - close the given rotator per file session |
| 442 | * @mgr: Pointer to rotator manager |
| 443 | * @private: Pointer to per file session |
| 444 | * @session_id: identifier of the session |
| 445 | * return: none |
| 446 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 447 | void sde_rotator_session_close(struct sde_rot_mgr *mgr, |
| 448 | struct sde_rot_file_private *private, int session_id); |
| 449 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 450 | /* |
| 451 | * sde_rotator_session_config - configure the given rotator per file session |
| 452 | * @mgr: Pointer to rotator manager |
| 453 | * @private: Pointer to per file session |
| 454 | * @config: Pointer to rotator configuration |
| 455 | * return: 0 if success; error code otherwise |
| 456 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 457 | int sde_rotator_session_config(struct sde_rot_mgr *mgr, |
| 458 | struct sde_rot_file_private *private, |
| 459 | struct sde_rotation_config *config); |
| 460 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 461 | /* |
| 462 | * sde_rotator_req_init - allocate a new request and initialzie with given |
| 463 | * array of rotation items |
| 464 | * @rot_dev: Pointer to rotator device |
| 465 | * @private: Pointer to rotator manager per file context |
| 466 | * @items: Pointer to array of rotation item |
| 467 | * @count: size of rotation item array |
| 468 | * @flags: rotation request flags |
| 469 | * return: Pointer to new rotation request if success; ERR_PTR otherwise |
| 470 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 471 | struct sde_rot_entry_container *sde_rotator_req_init( |
| 472 | struct sde_rot_mgr *rot_dev, |
| 473 | struct sde_rot_file_private *private, |
| 474 | struct sde_rotation_item *items, |
| 475 | u32 count, u32 flags); |
| 476 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 477 | /* |
| 478 | * sde_rotator_req_finish - notify manager that client is finished with the |
| 479 | * given request and manager can release the request as required |
| 480 | * @rot_dev: Pointer to rotator device |
| 481 | * @private: Pointer to rotator manager per file context |
| 482 | * @req: Pointer to rotation request |
| 483 | * return: none |
| 484 | */ |
| 485 | void sde_rotator_req_finish(struct sde_rot_mgr *mgr, |
| 486 | struct sde_rot_file_private *private, |
| 487 | struct sde_rot_entry_container *req); |
| 488 | |
| 489 | /* |
| 490 | * sde_rotator_handle_request_common - add the given request to rotator |
| 491 | * manager and clean up completed requests |
| 492 | * @rot_dev: Pointer to rotator device |
| 493 | * @private: Pointer to rotator manager per file context |
| 494 | * @req: Pointer to rotation request |
| 495 | * return: 0 if success; error code otherwise |
| 496 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 497 | int sde_rotator_handle_request_common(struct sde_rot_mgr *rot_dev, |
| 498 | struct sde_rot_file_private *ctx, |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 499 | struct sde_rot_entry_container *req); |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 500 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 501 | /* |
| 502 | * sde_rotator_queue_request - queue/schedule the given request for h/w commit |
| 503 | * @rot_dev: Pointer to rotator device |
| 504 | * @private: Pointer to rotator manager per file context |
| 505 | * @req: Pointer to rotation request |
| 506 | * return: 0 if success; error code otherwise |
| 507 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 508 | void sde_rotator_queue_request(struct sde_rot_mgr *rot_dev, |
| 509 | struct sde_rot_file_private *ctx, |
| 510 | struct sde_rot_entry_container *req); |
| 511 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 512 | /* |
| 513 | * sde_rotator_verify_config_all - verify given rotation configuration |
| 514 | * @rot_dev: Pointer to rotator device |
| 515 | * @config: Pointer to rotator configuration |
| 516 | * return: 0 if success; error code otherwise |
| 517 | */ |
Benjamin Chan | 59a0605 | 2017-01-12 18:06:03 -0500 | [diff] [blame] | 518 | int sde_rotator_verify_config_all(struct sde_rot_mgr *rot_dev, |
| 519 | struct sde_rotation_config *config); |
| 520 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 521 | /* |
| 522 | * sde_rotator_verify_config_input - verify rotation input configuration |
| 523 | * @rot_dev: Pointer to rotator device |
| 524 | * @config: Pointer to rotator configuration |
| 525 | * return: 0 if success; error code otherwise |
| 526 | */ |
Benjamin Chan | 59a0605 | 2017-01-12 18:06:03 -0500 | [diff] [blame] | 527 | int sde_rotator_verify_config_input(struct sde_rot_mgr *rot_dev, |
| 528 | struct sde_rotation_config *config); |
| 529 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 530 | /* |
| 531 | * sde_rotator_verify_config_output - verify rotation output configuration |
| 532 | * @rot_dev: Pointer to rotator device |
| 533 | * @config: Pointer to rotator configuration |
| 534 | * return: 0 if success; error code otherwise |
| 535 | */ |
Benjamin Chan | 59a0605 | 2017-01-12 18:06:03 -0500 | [diff] [blame] | 536 | int sde_rotator_verify_config_output(struct sde_rot_mgr *rot_dev, |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 537 | struct sde_rotation_config *config); |
| 538 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 539 | /* |
| 540 | * sde_rotator_validate_request - validates given rotation request with |
| 541 | * previous rotator configuration |
| 542 | * @rot_dev: Pointer to rotator device |
| 543 | * @private: Pointer to rotator manager per file context |
| 544 | * @req: Pointer to rotation request |
| 545 | * return: 0 if success; error code otherwise |
| 546 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 547 | int sde_rotator_validate_request(struct sde_rot_mgr *rot_dev, |
| 548 | struct sde_rot_file_private *ctx, |
| 549 | struct sde_rot_entry_container *req); |
| 550 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 551 | /* |
| 552 | * sde_rotator_clk_ctrl - enable/disable rotator clock with reference counting |
| 553 | * @mgr: Pointer to rotator manager |
| 554 | * @enable: true to enable clock; false to disable clock |
| 555 | * return: 0 if success; error code otherwise |
| 556 | */ |
Benjamin Chan | 0f9e61d | 2016-09-16 16:01:09 -0400 | [diff] [blame] | 557 | int sde_rotator_clk_ctrl(struct sde_rot_mgr *mgr, int enable); |
| 558 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 559 | /* |
| 560 | * sde_rot_mgr_lock - serialization lock prior to rotator manager calls |
| 561 | * @mgr: Pointer to rotator manager |
| 562 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 563 | static inline void sde_rot_mgr_lock(struct sde_rot_mgr *mgr) |
| 564 | { |
| 565 | mutex_lock(&mgr->lock); |
| 566 | } |
| 567 | |
Alan Kwong | f94a255 | 2016-12-28 09:41:22 -0800 | [diff] [blame^] | 568 | /* |
| 569 | * sde_rot_mgr_lock - serialization unlock after rotator manager calls |
| 570 | * @mgr: Pointer to rotator manager |
| 571 | */ |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 572 | static inline void sde_rot_mgr_unlock(struct sde_rot_mgr *mgr) |
| 573 | { |
| 574 | mutex_unlock(&mgr->lock); |
| 575 | } |
| 576 | |
Alan Kwong | 3428f67 | 2016-04-18 12:32:06 -0400 | [diff] [blame] | 577 | #if defined(CONFIG_PM) |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 578 | int sde_rotator_runtime_resume(struct device *dev); |
| 579 | int sde_rotator_runtime_suspend(struct device *dev); |
| 580 | int sde_rotator_runtime_idle(struct device *dev); |
| 581 | #endif |
| 582 | |
| 583 | #if defined(CONFIG_PM_SLEEP) |
| 584 | int sde_rotator_pm_suspend(struct device *dev); |
| 585 | int sde_rotator_pm_resume(struct device *dev); |
| 586 | #endif |
| 587 | |
| 588 | #if defined(CONFIG_PM) && !defined(CONFIG_PM_SLEEP) |
| 589 | int sde_rotator_suspend(struct platform_device *dev, pm_message_t state); |
| 590 | int sde_rotator_resume(struct platform_device *dev); |
| 591 | #else |
| 592 | #define sde_rotator_suspend NULL |
| 593 | #define sde_rotator_resume NULL |
| 594 | #endif |
| 595 | #endif /* __SDE_ROTATOR_CORE_H__ */ |