Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. |
| 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 | #ifndef __SDE_KMS_H__ |
| 14 | #define __SDE_KMS_H__ |
| 15 | |
| 16 | #include "msm_drv.h" |
| 17 | #include "msm_kms.h" |
Alan Kwong | 112a84f | 2016-05-24 20:49:21 -0400 | [diff] [blame] | 18 | #include "msm_mmu.h" |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 19 | #include "sde_hw_catalog.h" |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 20 | #include "sde_hw_ctl.h" |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 21 | #include "sde_hw_lm.h" |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 22 | #include "sde_hw_interrupts.h" |
Alan Kwong | d21960f | 2016-07-29 03:33:17 -0400 | [diff] [blame] | 23 | #include "sde_hw_wb.h" |
| 24 | #include "sde_hw_top.h" |
Clarence Ip | e59fb3f | 2016-07-26 13:39:59 -0400 | [diff] [blame] | 25 | #include "sde_connector.h" |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 26 | #include "sde_rm.h" |
Dhaval Patel | 3949f03 | 2016-06-20 16:24:33 -0700 | [diff] [blame] | 27 | #include "sde_power_handle.h" |
Alan Kwong | f5dd86c | 2016-08-09 18:08:17 -0400 | [diff] [blame] | 28 | #include "sde_irq.h" |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 29 | |
Clarence Ip | 31c19b5 | 2016-06-10 15:42:08 -0400 | [diff] [blame] | 30 | /** |
| 31 | * SDE_DEBUG - macro for kms/plane/crtc/encoder/connector logs |
| 32 | * @fmt: Pointer to format string |
| 33 | */ |
| 34 | #define SDE_DEBUG(fmt, ...) \ |
| 35 | do { \ |
| 36 | if (unlikely(drm_debug & DRM_UT_KMS)) \ |
| 37 | drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \ |
| 38 | else \ |
| 39 | pr_debug(fmt, ##__VA_ARGS__); \ |
| 40 | } while (0) |
| 41 | |
| 42 | /** |
| 43 | * SDE_DEBUG_DRIVER - macro for hardware driver logging |
| 44 | * @fmt: Pointer to format string |
| 45 | */ |
| 46 | #define SDE_DEBUG_DRIVER(fmt, ...) \ |
| 47 | do { \ |
| 48 | if (unlikely(drm_debug & DRM_UT_DRIVER)) \ |
| 49 | drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \ |
| 50 | else \ |
| 51 | pr_debug(fmt, ##__VA_ARGS__); \ |
| 52 | } while (0) |
| 53 | |
| 54 | #define SDE_ERROR(fmt, ...) pr_err(fmt, ##__VA_ARGS__) |
| 55 | |
Dhaval Patel | ec10fad | 2016-08-22 14:40:48 -0700 | [diff] [blame] | 56 | #define POPULATE_RECT(rect, a, b, c, d, Q16_flag) \ |
| 57 | do { \ |
| 58 | (rect)->x = (Q16_flag) ? (a) >> 16 : (a); \ |
| 59 | (rect)->y = (Q16_flag) ? (b) >> 16 : (b); \ |
| 60 | (rect)->w = (Q16_flag) ? (c) >> 16 : (c); \ |
| 61 | (rect)->h = (Q16_flag) ? (d) >> 16 : (d); \ |
| 62 | } while (0) |
| 63 | |
| 64 | #define CHECK_LAYER_BOUNDS(offset, size, max_size) \ |
| 65 | (((size) > (max_size)) || ((offset) > ((max_size) - (size)))) |
| 66 | |
Clarence Ip | fd96ba2 | 2016-09-09 16:45:44 -0400 | [diff] [blame] | 67 | /** |
| 68 | * ktime_compare_safe - compare two ktime structures |
| 69 | * This macro is similar to the standard ktime_compare() function, but |
| 70 | * attempts to also handle ktime overflows. |
| 71 | * @A: First ktime value |
| 72 | * @B: Second ktime value |
| 73 | * Returns: -1 if A < B, 0 if A == B, 1 if A > B |
| 74 | */ |
| 75 | #define ktime_compare_safe(A, B) \ |
| 76 | ktime_compare(ktime_sub((A), (B)), ktime_set(0, 0)) |
| 77 | |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 78 | /* |
| 79 | * struct sde_irq_callback - IRQ callback handlers |
| 80 | * @func: intr handler |
| 81 | * @arg: argument for the handler |
| 82 | */ |
| 83 | struct sde_irq_callback { |
| 84 | void (*func)(void *arg, int irq_idx); |
| 85 | void *arg; |
| 86 | }; |
| 87 | |
| 88 | /** |
| 89 | * struct sde_irq: IRQ structure contains callback registration info |
| 90 | * @total_irq: total number of irq_idx obtained from HW interrupts mapping |
| 91 | * @irq_cb_tbl: array of IRQ callbacks setting |
| 92 | * @cb_lock: callback lock |
| 93 | */ |
| 94 | struct sde_irq { |
| 95 | u32 total_irqs; |
| 96 | struct sde_irq_callback *irq_cb_tbl; |
| 97 | spinlock_t cb_lock; |
| 98 | }; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 99 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 100 | /** |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 101 | * Encoder functions and data types |
| 102 | * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused |
| 103 | * @wbs: Writebacks this encoder is using, INTF_MODE_NONE if unused |
| 104 | * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs |
| 105 | * @display_num_of_h_tiles: |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 106 | */ |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 107 | struct sde_encoder_hw_resources { |
| 108 | enum sde_intf_mode intfs[INTF_MAX]; |
| 109 | enum sde_intf_mode wbs[WB_MAX]; |
| 110 | bool needs_cdm; |
| 111 | u32 display_num_of_h_tiles; |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 112 | }; |
| 113 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 114 | struct sde_kms { |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 115 | struct msm_kms base; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 116 | struct drm_device *dev; |
Dhaval Patel | 3949f03 | 2016-06-20 16:24:33 -0700 | [diff] [blame] | 117 | int core_rev; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 118 | struct sde_mdss_cfg *catalog; |
| 119 | |
Alan Kwong | 112a84f | 2016-05-24 20:49:21 -0400 | [diff] [blame] | 120 | struct msm_mmu *mmu[MSM_SMMU_DOMAIN_MAX]; |
| 121 | int mmu_id[MSM_SMMU_DOMAIN_MAX]; |
Dhaval Patel | 3949f03 | 2016-06-20 16:24:33 -0700 | [diff] [blame] | 122 | struct sde_power_client *core_client; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 123 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 124 | /* directory entry for debugfs */ |
| 125 | void *debugfs_root; |
| 126 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 127 | /* io/register spaces: */ |
Alan Kwong | dfa8c08 | 2016-07-29 04:10:00 -0400 | [diff] [blame] | 128 | void __iomem *mmio, *vbif[VBIF_MAX]; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 129 | |
| 130 | struct regulator *vdd; |
| 131 | struct regulator *mmagic; |
| 132 | struct regulator *venus; |
| 133 | |
Alan Kwong | f5dd86c | 2016-08-09 18:08:17 -0400 | [diff] [blame] | 134 | struct sde_irq_controller irq_controller; |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 135 | |
| 136 | struct sde_hw_intr *hw_intr; |
| 137 | struct sde_irq irq_obj; |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 138 | |
| 139 | struct sde_rm rm; |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 140 | |
| 141 | struct sde_hw_vbif *hw_vbif[VBIF_MAX]; |
| 142 | struct sde_hw_mdp *hw_mdp; |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | struct vsync_info { |
| 146 | u32 frame_count; |
| 147 | u32 line_count; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | #define to_sde_kms(x) container_of(x, struct sde_kms, base) |
| 151 | |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 152 | struct sde_vbif_set_ot_params { |
| 153 | u32 xin_id; |
| 154 | u32 num; |
| 155 | u32 width; |
| 156 | u32 height; |
| 157 | u32 frame_rate; |
| 158 | bool rd; |
| 159 | bool is_wfd; |
| 160 | u32 vbif_idx; |
| 161 | u32 clk_ctrl; |
| 162 | }; |
| 163 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 164 | struct sde_plane_state { |
| 165 | struct drm_plane_state base; |
| 166 | |
| 167 | /* aligned with property */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 168 | uint64_t property_values[PLANE_PROP_COUNT]; |
| 169 | |
| 170 | /* blob properties */ |
| 171 | struct drm_property_blob *property_blobs[PLANE_PROP_BLOBCOUNT]; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 172 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 173 | /* dereferenced input fence pointer */ |
| 174 | void *input_fence; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 175 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 176 | /* assigned by crtc blender */ |
| 177 | enum sde_stage stage; |
| 178 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame^] | 179 | /* bitmask for which pipe h/w config functions need to be updated */ |
| 180 | uint32_t dirty; |
| 181 | |
| 182 | /* whether the current update is still pending */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 183 | bool pending : 1; |
| 184 | }; |
| 185 | |
| 186 | #define to_sde_plane_state(x) \ |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 187 | container_of(x, struct sde_plane_state, base) |
| 188 | |
| 189 | /** |
| 190 | * sde_plane_get_property - Query integer value of plane property |
| 191 | * |
| 192 | * @S: Pointer to plane state |
| 193 | * @X: Property index, from enum msm_mdp_plane_property |
| 194 | * |
| 195 | * Return: Integer value of requested property |
| 196 | */ |
| 197 | #define sde_plane_get_property(S, X) \ |
| 198 | ((S) && ((X) < PLANE_PROP_COUNT) ? ((S)->property_values[(X)]) : 0) |
| 199 | |
| 200 | /** |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 201 | * Debugfs functions - extra helper functions for debugfs support |
| 202 | * |
| 203 | * Main debugfs documentation is located at, |
| 204 | * |
| 205 | * Documentation/filesystems/debugfs.txt |
| 206 | * |
| 207 | * @sde_debugfs_setup_regset32: Initialize data for sde_debugfs_create_regset32 |
| 208 | * @sde_debugfs_create_regset32: Create 32-bit register dump file |
| 209 | * @sde_debugfs_get_root: Get root dentry for SDE_KMS's debugfs node |
| 210 | */ |
| 211 | |
| 212 | /** |
| 213 | * Companion structure for sde_debugfs_create_regset32. Do not initialize the |
| 214 | * members of this structure explicitly; use sde_debugfs_setup_regset32 instead. |
| 215 | */ |
| 216 | struct sde_debugfs_regset32 { |
| 217 | uint32_t offset; |
| 218 | uint32_t blk_len; |
| 219 | void __iomem *base; |
| 220 | }; |
| 221 | |
| 222 | /** |
| 223 | * sde_debugfs_setup_regset32 - Initialize register block definition for debugfs |
| 224 | * This function is meant to initialize sde_debugfs_regset32 structures for use |
| 225 | * with sde_debugfs_create_regset32. |
| 226 | * @regset: opaque register definition structure |
| 227 | * @offset: sub-block offset |
| 228 | * @length: sub-block length, in bytes |
| 229 | * @base: base IOMEM address |
| 230 | */ |
| 231 | void sde_debugfs_setup_regset32(struct sde_debugfs_regset32 *regset, |
| 232 | uint32_t offset, uint32_t length, void __iomem *base); |
| 233 | |
| 234 | /** |
| 235 | * sde_debugfs_create_regset32 - Create register read back file for debugfs |
| 236 | * |
| 237 | * This function is almost identical to the standard debugfs_create_regset32() |
| 238 | * function, with the main difference being that a list of register |
| 239 | * names/offsets do not need to be provided. The 'read' function simply outputs |
| 240 | * sequential register values over a specified range. |
| 241 | * |
| 242 | * Similar to the related debugfs_create_regset32 API, the structure pointed to |
| 243 | * by regset needs to persist for the lifetime of the created file. The calling |
| 244 | * code is responsible for initialization/management of this structure. |
| 245 | * |
| 246 | * The structure pointed to by regset is meant to be opaque. Please use |
| 247 | * sde_debugfs_setup_regset32 to initialize it. |
| 248 | * |
| 249 | * @name: File name within debugfs |
| 250 | * @mode: File mode within debugfs |
| 251 | * @parent: Parent directory entry within debugfs, can be NULL |
| 252 | * @regset: Pointer to persistent register block definition |
| 253 | * |
| 254 | * Return: dentry pointer for newly created file, use either debugfs_remove() |
| 255 | * or debugfs_remove_recursive() (on a parent directory) to remove the |
| 256 | * file |
| 257 | */ |
| 258 | void *sde_debugfs_create_regset32(const char *name, umode_t mode, |
| 259 | void *parent, struct sde_debugfs_regset32 *regset); |
| 260 | |
| 261 | /** |
| 262 | * sde_debugfs_get_root - Return root directory entry for SDE's debugfs |
| 263 | * |
| 264 | * The return value should be passed as the 'parent' argument to subsequent |
| 265 | * debugfs create calls. |
| 266 | * |
| 267 | * @sde_kms: Pointer to SDE's KMS structure |
| 268 | * |
| 269 | * Return: dentry pointer for SDE's debugfs location |
| 270 | */ |
| 271 | void *sde_debugfs_get_root(struct sde_kms *sde_kms); |
| 272 | |
| 273 | /** |
Clarence Ip | b218a3c | 2016-07-15 14:17:42 -0400 | [diff] [blame] | 274 | * SDE info management functions |
| 275 | * These functions/definitions allow for building up a 'sde_info' structure |
| 276 | * containing one or more "key=value\n" entries. |
| 277 | */ |
| 278 | #define SDE_KMS_INFO_MAX_SIZE 4096 |
| 279 | |
| 280 | /** |
| 281 | * struct sde_kms_info - connector information structure container |
| 282 | * @data: Array of information character data |
| 283 | * @len: Current length of information data |
| 284 | * @staged_len: Temporary data buffer length, commit to |
| 285 | * len using sde_kms_info_stop |
| 286 | * @start: Whether or not a partial data entry was just started |
| 287 | */ |
| 288 | struct sde_kms_info { |
| 289 | char data[SDE_KMS_INFO_MAX_SIZE]; |
| 290 | uint32_t len; |
| 291 | uint32_t staged_len; |
| 292 | bool start; |
| 293 | }; |
| 294 | |
| 295 | /** |
| 296 | * SDE_KMS_INFO_DATA - Macro for accessing sde_kms_info data bytes |
| 297 | * @S: Pointer to sde_kms_info structure |
| 298 | * Returns: Pointer to byte data |
| 299 | */ |
| 300 | #define SDE_KMS_INFO_DATA(S) ((S) ? ((struct sde_kms_info *)(S))->data : 0) |
| 301 | |
| 302 | /** |
| 303 | * SDE_KMS_INFO_DATALEN - Macro for accessing sde_kms_info data length |
| 304 | * @S: Pointer to sde_kms_info structure |
| 305 | * Returns: Size of available byte data |
| 306 | */ |
| 307 | #define SDE_KMS_INFO_DATALEN(S) ((S) ? ((struct sde_kms_info *)(S))->len : 0) |
| 308 | |
| 309 | /** |
| 310 | * sde_kms_info_reset - reset sde_kms_info structure |
| 311 | * @info: Pointer to sde_kms_info structure |
| 312 | */ |
| 313 | void sde_kms_info_reset(struct sde_kms_info *info); |
| 314 | |
| 315 | /** |
| 316 | * sde_kms_info_add_keyint - add integer value to 'sde_kms_info' |
| 317 | * @info: Pointer to sde_kms_info structure |
| 318 | * @key: Pointer to key string |
| 319 | * @value: Signed 32-bit integer value |
| 320 | */ |
| 321 | void sde_kms_info_add_keyint(struct sde_kms_info *info, |
| 322 | const char *key, |
| 323 | int32_t value); |
| 324 | |
| 325 | /** |
| 326 | * sde_kms_info_add_keystr - add string value to 'sde_kms_info' |
| 327 | * @info: Pointer to sde_kms_info structure |
| 328 | * @key: Pointer to key string |
| 329 | * @value: Pointer to string value |
| 330 | */ |
| 331 | void sde_kms_info_add_keystr(struct sde_kms_info *info, |
| 332 | const char *key, |
| 333 | const char *value); |
| 334 | |
| 335 | /** |
| 336 | * sde_kms_info_start - begin adding key to 'sde_kms_info' |
| 337 | * Usage: |
| 338 | * sde_kms_info_start(key) |
| 339 | * sde_kms_info_append(val_1) |
| 340 | * ... |
| 341 | * sde_kms_info_append(val_n) |
| 342 | * sde_kms_info_stop |
| 343 | * @info: Pointer to sde_kms_info structure |
| 344 | * @key: Pointer to key string |
| 345 | */ |
| 346 | void sde_kms_info_start(struct sde_kms_info *info, |
| 347 | const char *key); |
| 348 | |
| 349 | /** |
| 350 | * sde_kms_info_append - append value string to 'sde_kms_info' |
| 351 | * Usage: |
| 352 | * sde_kms_info_start(key) |
| 353 | * sde_kms_info_append(val_1) |
| 354 | * ... |
| 355 | * sde_kms_info_append(val_n) |
| 356 | * sde_kms_info_stop |
| 357 | * @info: Pointer to sde_kms_info structure |
| 358 | * @str: Pointer to partial value string |
| 359 | */ |
| 360 | void sde_kms_info_append(struct sde_kms_info *info, |
| 361 | const char *str); |
| 362 | |
| 363 | /** |
| 364 | * sde_kms_info_append_format - append format code string to 'sde_kms_info' |
| 365 | * Usage: |
| 366 | * sde_kms_info_start(key) |
| 367 | * sde_kms_info_append_format(fourcc, modifier) |
| 368 | * ... |
| 369 | * sde_kms_info_stop |
| 370 | * @info: Pointer to sde_kms_info structure |
| 371 | * @pixel_format: FOURCC format code |
| 372 | * @modifier: 64-bit drm format modifier |
| 373 | */ |
| 374 | void sde_kms_info_append_format(struct sde_kms_info *info, |
| 375 | uint32_t pixel_format, |
| 376 | uint64_t modifier); |
| 377 | |
| 378 | /** |
| 379 | * sde_kms_info_stop - finish adding key to 'sde_kms_info' |
| 380 | * Usage: |
| 381 | * sde_kms_info_start(key) |
| 382 | * sde_kms_info_append(val_1) |
| 383 | * ... |
| 384 | * sde_kms_info_append(val_n) |
| 385 | * sde_kms_info_stop |
| 386 | * @info: Pointer to sde_kms_info structure |
| 387 | */ |
| 388 | void sde_kms_info_stop(struct sde_kms_info *info); |
| 389 | |
| 390 | /** |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 391 | * Vblank enable/disable functions |
| 392 | */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 393 | int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc); |
| 394 | void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc); |
| 395 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 396 | /** |
| 397 | * Plane functions |
| 398 | */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 399 | enum sde_sspp sde_plane_pipe(struct drm_plane *plane); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 400 | void sde_plane_flush(struct drm_plane *plane); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 401 | struct drm_plane *sde_plane_init(struct drm_device *dev, |
| 402 | uint32_t pipe, bool primary_plane); |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 403 | |
| 404 | /** |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 405 | * sde_plane_wait_input_fence - wait for input fence object |
Clarence Ip | 7a753bb | 2016-07-07 11:47:44 -0400 | [diff] [blame] | 406 | * @plane: Pointer to DRM plane object |
| 407 | * @wait_ms: Wait timeout value |
| 408 | * Returns: Zero on success |
| 409 | */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 410 | int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 411 | |
| 412 | /** |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 413 | * sde_plane_color_fill - Enables color fill on plane |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 414 | * @plane: Pointer to DRM plane object |
| 415 | * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red |
| 416 | * @alpha: 8-bit fill alpha value, 255 selects 100% alpha |
| 417 | * |
| 418 | * Returns: 0 on success |
| 419 | */ |
| 420 | int sde_plane_color_fill(struct drm_plane *plane, |
| 421 | uint32_t color, uint32_t alpha); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 422 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 423 | /** |
| 424 | * CRTC functions |
| 425 | */ |
Abhijit Kulkarni | 7acb326 | 2016-07-05 15:27:25 -0400 | [diff] [blame] | 426 | int sde_crtc_vblank(struct drm_crtc *crtc, bool en); |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 427 | void sde_crtc_commit_kickoff(struct drm_crtc *crtc); |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 428 | |
| 429 | /** |
| 430 | * sde_crtc_prepare_fence - callback to prepare for output fences |
| 431 | * @crtc: Pointer to drm crtc object |
| 432 | */ |
| 433 | void sde_crtc_prepare_fence(struct drm_crtc *crtc); |
| 434 | |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 435 | /** |
| 436 | * sde_crtc_init - create a new crtc object |
| 437 | * @dev: sde device |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 438 | * @plane: base plane |
| 439 | * @vblank_id: Id for reporting vblank. Id in range from 0..dev->num_crtcs. |
| 440 | * @Return: new crtc object or error |
| 441 | */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 442 | struct drm_crtc *sde_crtc_init(struct drm_device *dev, |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 443 | struct drm_plane *plane, |
| 444 | int vblank_id); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 445 | |
Abhijit Kulkarni | 40e3816 | 2016-06-26 22:12:09 -0400 | [diff] [blame] | 446 | /** |
Clarence Ip | 24f8066 | 2016-06-13 19:05:32 -0400 | [diff] [blame] | 447 | * sde_crtc_complete_commit - callback signalling completion of current commit |
| 448 | * @crtc: Pointer to drm crtc object |
| 449 | */ |
| 450 | void sde_crtc_complete_commit(struct drm_crtc *crtc); |
| 451 | |
| 452 | /** |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 453 | * sde_encoder_get_hw_resources - Populate table of required hardware resources |
| 454 | * @encoder: encoder pointer |
| 455 | * @hw_res: resource table to populate with encoder required resources |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 456 | * @conn_state: report hw reqs based on this proposed connector state |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 457 | */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 458 | void sde_encoder_get_hw_resources(struct drm_encoder *encoder, |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 459 | struct sde_encoder_hw_resources *hw_res, |
| 460 | struct drm_connector_state *conn_state); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 461 | |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 462 | /** |
Lloyd Atkinson | e7bcdd2 | 2016-08-11 10:53:37 -0400 | [diff] [blame] | 463 | * sde_encoder_needs_ctl_start - Get whether encoder type requires ctl_start |
| 464 | * CMD and WB encoders need ctl_start, video encs do not. |
| 465 | * @encoder: encoder pointer |
| 466 | * @Return: true if the encoder type requires ctl_start issued |
| 467 | */ |
| 468 | bool sde_encoder_needs_ctl_start(struct drm_encoder *encoder); |
| 469 | |
| 470 | /** |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 471 | * sde_encoder_register_vblank_callback - provide callback to encoder that |
| 472 | * will be called on the next vblank. |
| 473 | * @encoder: encoder pointer |
| 474 | * @cb: callback pointer, provide NULL to deregister and disable IRQs |
| 475 | * @data: user data provided to callback |
| 476 | */ |
| 477 | void sde_encoder_register_vblank_callback(struct drm_encoder *encoder, |
| 478 | void (*cb)(void *), void *data); |
| 479 | |
| 480 | /** |
| 481 | * sde_encoder_schedule_kickoff - Register a callback with the encoder to |
| 482 | * trigger a double buffer flip of the ctl path (i.e. ctl flush and start) |
| 483 | * at the appropriate time. |
| 484 | * Immediately: if no previous commit is outstanding. |
| 485 | * Delayed: Save the callback, and return. Does not block. Callback will |
| 486 | * be triggered later. E.g. cmd encoder will trigger at pp_done irq |
| 487 | * irq if it outstanding. |
| 488 | * Callback registered is expected to flush _all_ ctl paths of the crtc |
| 489 | * @encoder: encoder pointer |
| 490 | * @cb: callback pointer, provide NULL to deregister |
| 491 | * @data: user data provided to callback |
| 492 | */ |
| 493 | void sde_encoder_schedule_kickoff(struct drm_encoder *encoder, |
| 494 | void (*cb)(void *), void *data); |
| 495 | |
| 496 | /** |
| 497 | * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the |
| 498 | * current pending frames to hardware at a vblank or ctl_start |
| 499 | * Encoders will map this differently depending on irqs |
| 500 | * vid mode -> vsync_irq |
| 501 | * @encoder: encoder pointer |
| 502 | * |
| 503 | * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise |
| 504 | */ |
| 505 | int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder); |
| 506 | |
| 507 | /** |
| 508 | * sde_encoders_init - query platform, create all encoders and bridges, |
| 509 | * and register them with the drm_device |
| 510 | * @dev: drm device pointer |
| 511 | */ |
| 512 | void sde_encoders_init(struct drm_device *dev); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 513 | |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 514 | /** |
| 515 | * sde_vbif_set_ot_limit - set OT limit for vbif client |
| 516 | * @sde_kms: SDE handler |
| 517 | * @params: Pointer to OT configuration parameters |
| 518 | */ |
| 519 | void sde_vbif_set_ot_limit(struct sde_kms *sde_kms, |
| 520 | struct sde_vbif_set_ot_params *params); |
| 521 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 522 | #endif /* __sde_kms_H__ */ |