blob: e8a69888e800ebd527c64f1d38202e74bcbede47 [file] [log] [blame]
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07001/* 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 Kwong112a84f2016-05-24 20:49:21 -040018#include "msm_mmu.h"
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070019#include "mdp/mdp_kms.h"
20#include "sde_hw_catalog.h"
Clarence Ipc475b082016-06-26 09:27:23 -040021#include "sde_hw_ctl.h"
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040022#include "sde_hw_lm.h"
Ben Chan78647cd2016-06-26 22:02:47 -040023#include "sde_hw_interrupts.h"
Alan Kwongd21960f2016-07-29 03:33:17 -040024#include "sde_hw_wb.h"
25#include "sde_hw_top.h"
Clarence Ipe59fb3f2016-07-26 13:39:59 -040026#include "sde_connector.h"
Lloyd Atkinson11f34442016-08-11 11:19:52 -040027#include "sde_rm.h"
Dhaval Patel3949f032016-06-20 16:24:33 -070028#include "sde_power_handle.h"
Ben Chan78647cd2016-06-26 22:02:47 -040029
Clarence Ip31c19b52016-06-10 15:42:08 -040030/**
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 Patelec10fad2016-08-22 14:40:48 -070056#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 Ipfd96ba22016-09-09 16:45:44 -040067/**
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 Chan78647cd2016-06-26 22:02:47 -040078/*
79 * struct sde_irq_callback - IRQ callback handlers
80 * @func: intr handler
81 * @arg: argument for the handler
82 */
83struct 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 */
94struct sde_irq {
95 u32 total_irqs;
96 struct sde_irq_callback *irq_cb_tbl;
97 spinlock_t cb_lock;
98};
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070099
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400100/**
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400101 * 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 Kulkarni40e38162016-06-26 22:12:09 -0400106 */
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400107struct 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 Kulkarni40e38162016-06-26 22:12:09 -0400112};
113
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700114struct sde_kms {
Ben Chan78647cd2016-06-26 22:02:47 -0400115 struct msm_kms base;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700116 struct drm_device *dev;
Dhaval Patel3949f032016-06-20 16:24:33 -0700117 int core_rev;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700118 struct sde_mdss_cfg *catalog;
119
Alan Kwong112a84f2016-05-24 20:49:21 -0400120 struct msm_mmu *mmu[MSM_SMMU_DOMAIN_MAX];
121 int mmu_id[MSM_SMMU_DOMAIN_MAX];
Dhaval Patel3949f032016-06-20 16:24:33 -0700122 struct sde_power_client *core_client;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700123
Clarence Ip4ce59322016-06-26 22:27:51 -0400124 /* directory entry for debugfs */
125 void *debugfs_root;
126
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700127 /* io/register spaces: */
Alan Kwongdfa8c082016-07-29 04:10:00 -0400128 void __iomem *mmio, *vbif[VBIF_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700129
130 struct regulator *vdd;
131 struct regulator *mmagic;
132 struct regulator *venus;
133
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700134 struct {
135 unsigned long enabled_mask;
136 struct irq_domain *domain;
137 } irqcontroller;
Ben Chan78647cd2016-06-26 22:02:47 -0400138
139 struct sde_hw_intr *hw_intr;
140 struct sde_irq irq_obj;
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400141
142 struct sde_rm rm;
Alan Kwong5d324e42016-07-28 22:56:18 -0400143
144 struct sde_hw_vbif *hw_vbif[VBIF_MAX];
145 struct sde_hw_mdp *hw_mdp;
Ben Chan78647cd2016-06-26 22:02:47 -0400146};
147
148struct vsync_info {
149 u32 frame_count;
150 u32 line_count;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700151};
152
153#define to_sde_kms(x) container_of(x, struct sde_kms, base)
154
Alan Kwong5d324e42016-07-28 22:56:18 -0400155struct sde_vbif_set_ot_params {
156 u32 xin_id;
157 u32 num;
158 u32 width;
159 u32 height;
160 u32 frame_rate;
161 bool rd;
162 bool is_wfd;
163 u32 vbif_idx;
164 u32 clk_ctrl;
165};
166
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700167struct sde_plane_state {
168 struct drm_plane_state base;
169
170 /* aligned with property */
Clarence Ipe78efb72016-06-24 18:35:21 -0400171 uint64_t property_values[PLANE_PROP_COUNT];
172
173 /* blob properties */
174 struct drm_property_blob *property_blobs[PLANE_PROP_BLOBCOUNT];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700175
Clarence Ipcae1bb62016-07-07 12:07:13 -0400176 /* dereferenced input fence pointer */
177 void *input_fence;
Clarence Ipae4e60c2016-06-26 22:44:04 -0400178
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700179 /* assigned by crtc blender */
180 enum sde_stage stage;
181
182 /* some additional transactional status to help us know in the
183 * apply path whether we need to update SMP allocation, and
184 * whether current update is still pending:
185 */
186 bool mode_changed : 1;
187 bool pending : 1;
188};
189
190#define to_sde_plane_state(x) \
Clarence Ip4c1d9772016-06-26 09:35:38 -0400191 container_of(x, struct sde_plane_state, base)
192
193/**
194 * sde_plane_get_property - Query integer value of plane property
195 *
196 * @S: Pointer to plane state
197 * @X: Property index, from enum msm_mdp_plane_property
198 *
199 * Return: Integer value of requested property
200 */
201#define sde_plane_get_property(S, X) \
202 ((S) && ((X) < PLANE_PROP_COUNT) ? ((S)->property_values[(X)]) : 0)
203
204/**
205 * sde_plane_get_property32 - Query 32-bit representation of plane property
206 *
207 * @S: Pointer to plane state
208 * @X: Property index, from enum msm_mdp_plane_property
209 *
210 * Return: 32-bit value of requested property
211 */
212#define sde_plane_get_property32(S, X) \
213 ((S) && ((X) < PLANE_PROP_COUNT) ? \
214 (uint32_t)((S)->property_values[(X)]) : 0)
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700215
Ben Chan78647cd2016-06-26 22:02:47 -0400216/**
Clarence Ip4ce59322016-06-26 22:27:51 -0400217 * Debugfs functions - extra helper functions for debugfs support
218 *
219 * Main debugfs documentation is located at,
220 *
221 * Documentation/filesystems/debugfs.txt
222 *
223 * @sde_debugfs_setup_regset32: Initialize data for sde_debugfs_create_regset32
224 * @sde_debugfs_create_regset32: Create 32-bit register dump file
225 * @sde_debugfs_get_root: Get root dentry for SDE_KMS's debugfs node
226 */
227
228/**
229 * Companion structure for sde_debugfs_create_regset32. Do not initialize the
230 * members of this structure explicitly; use sde_debugfs_setup_regset32 instead.
231 */
232struct sde_debugfs_regset32 {
233 uint32_t offset;
234 uint32_t blk_len;
235 void __iomem *base;
236};
237
238/**
239 * sde_debugfs_setup_regset32 - Initialize register block definition for debugfs
240 * This function is meant to initialize sde_debugfs_regset32 structures for use
241 * with sde_debugfs_create_regset32.
242 * @regset: opaque register definition structure
243 * @offset: sub-block offset
244 * @length: sub-block length, in bytes
245 * @base: base IOMEM address
246 */
247void sde_debugfs_setup_regset32(struct sde_debugfs_regset32 *regset,
248 uint32_t offset, uint32_t length, void __iomem *base);
249
250/**
251 * sde_debugfs_create_regset32 - Create register read back file for debugfs
252 *
253 * This function is almost identical to the standard debugfs_create_regset32()
254 * function, with the main difference being that a list of register
255 * names/offsets do not need to be provided. The 'read' function simply outputs
256 * sequential register values over a specified range.
257 *
258 * Similar to the related debugfs_create_regset32 API, the structure pointed to
259 * by regset needs to persist for the lifetime of the created file. The calling
260 * code is responsible for initialization/management of this structure.
261 *
262 * The structure pointed to by regset is meant to be opaque. Please use
263 * sde_debugfs_setup_regset32 to initialize it.
264 *
265 * @name: File name within debugfs
266 * @mode: File mode within debugfs
267 * @parent: Parent directory entry within debugfs, can be NULL
268 * @regset: Pointer to persistent register block definition
269 *
270 * Return: dentry pointer for newly created file, use either debugfs_remove()
271 * or debugfs_remove_recursive() (on a parent directory) to remove the
272 * file
273 */
274void *sde_debugfs_create_regset32(const char *name, umode_t mode,
275 void *parent, struct sde_debugfs_regset32 *regset);
276
277/**
278 * sde_debugfs_get_root - Return root directory entry for SDE's debugfs
279 *
280 * The return value should be passed as the 'parent' argument to subsequent
281 * debugfs create calls.
282 *
283 * @sde_kms: Pointer to SDE's KMS structure
284 *
285 * Return: dentry pointer for SDE's debugfs location
286 */
287void *sde_debugfs_get_root(struct sde_kms *sde_kms);
288
289/**
Clarence Ipb218a3c2016-07-15 14:17:42 -0400290 * SDE info management functions
291 * These functions/definitions allow for building up a 'sde_info' structure
292 * containing one or more "key=value\n" entries.
293 */
294#define SDE_KMS_INFO_MAX_SIZE 4096
295
296/**
297 * struct sde_kms_info - connector information structure container
298 * @data: Array of information character data
299 * @len: Current length of information data
300 * @staged_len: Temporary data buffer length, commit to
301 * len using sde_kms_info_stop
302 * @start: Whether or not a partial data entry was just started
303 */
304struct sde_kms_info {
305 char data[SDE_KMS_INFO_MAX_SIZE];
306 uint32_t len;
307 uint32_t staged_len;
308 bool start;
309};
310
311/**
312 * SDE_KMS_INFO_DATA - Macro for accessing sde_kms_info data bytes
313 * @S: Pointer to sde_kms_info structure
314 * Returns: Pointer to byte data
315 */
316#define SDE_KMS_INFO_DATA(S) ((S) ? ((struct sde_kms_info *)(S))->data : 0)
317
318/**
319 * SDE_KMS_INFO_DATALEN - Macro for accessing sde_kms_info data length
320 * @S: Pointer to sde_kms_info structure
321 * Returns: Size of available byte data
322 */
323#define SDE_KMS_INFO_DATALEN(S) ((S) ? ((struct sde_kms_info *)(S))->len : 0)
324
325/**
326 * sde_kms_info_reset - reset sde_kms_info structure
327 * @info: Pointer to sde_kms_info structure
328 */
329void sde_kms_info_reset(struct sde_kms_info *info);
330
331/**
332 * sde_kms_info_add_keyint - add integer value to 'sde_kms_info'
333 * @info: Pointer to sde_kms_info structure
334 * @key: Pointer to key string
335 * @value: Signed 32-bit integer value
336 */
337void sde_kms_info_add_keyint(struct sde_kms_info *info,
338 const char *key,
339 int32_t value);
340
341/**
342 * sde_kms_info_add_keystr - add string value to 'sde_kms_info'
343 * @info: Pointer to sde_kms_info structure
344 * @key: Pointer to key string
345 * @value: Pointer to string value
346 */
347void sde_kms_info_add_keystr(struct sde_kms_info *info,
348 const char *key,
349 const char *value);
350
351/**
352 * sde_kms_info_start - begin adding key to 'sde_kms_info'
353 * Usage:
354 * sde_kms_info_start(key)
355 * sde_kms_info_append(val_1)
356 * ...
357 * sde_kms_info_append(val_n)
358 * sde_kms_info_stop
359 * @info: Pointer to sde_kms_info structure
360 * @key: Pointer to key string
361 */
362void sde_kms_info_start(struct sde_kms_info *info,
363 const char *key);
364
365/**
366 * sde_kms_info_append - append value string to 'sde_kms_info'
367 * Usage:
368 * sde_kms_info_start(key)
369 * sde_kms_info_append(val_1)
370 * ...
371 * sde_kms_info_append(val_n)
372 * sde_kms_info_stop
373 * @info: Pointer to sde_kms_info structure
374 * @str: Pointer to partial value string
375 */
376void sde_kms_info_append(struct sde_kms_info *info,
377 const char *str);
378
379/**
380 * sde_kms_info_append_format - append format code string to 'sde_kms_info'
381 * Usage:
382 * sde_kms_info_start(key)
383 * sde_kms_info_append_format(fourcc, modifier)
384 * ...
385 * sde_kms_info_stop
386 * @info: Pointer to sde_kms_info structure
387 * @pixel_format: FOURCC format code
388 * @modifier: 64-bit drm format modifier
389 */
390void sde_kms_info_append_format(struct sde_kms_info *info,
391 uint32_t pixel_format,
392 uint64_t modifier);
393
394/**
395 * sde_kms_info_stop - finish adding key to 'sde_kms_info'
396 * Usage:
397 * sde_kms_info_start(key)
398 * sde_kms_info_append(val_1)
399 * ...
400 * sde_kms_info_append(val_n)
401 * sde_kms_info_stop
402 * @info: Pointer to sde_kms_info structure
403 */
404void sde_kms_info_stop(struct sde_kms_info *info);
405
406/**
Ben Chan78647cd2016-06-26 22:02:47 -0400407 * IRQ functions
408 */
409int sde_irq_domain_init(struct sde_kms *sde_kms);
410int sde_irq_domain_fini(struct sde_kms *sde_kms);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700411void sde_irq_preinstall(struct msm_kms *kms);
412int sde_irq_postinstall(struct msm_kms *kms);
413void sde_irq_uninstall(struct msm_kms *kms);
414irqreturn_t sde_irq(struct msm_kms *kms);
Ben Chan78647cd2016-06-26 22:02:47 -0400415
416/**
417 * sde_set_irqmask - IRQ helper function for writing IRQ mask
418 * to SDE HW interrupt register.
419 * @sde_kms: SDE handle
420 * @reg_off: SDE HW interrupt register offset
421 * @irqmask: IRQ mask
422 */
423void sde_set_irqmask(
424 struct sde_kms *sde_kms,
425 uint32_t reg_off,
426 uint32_t irqmask);
427
428/**
429 * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
430 * interrupt mapping table.
431 * @sde_kms: SDE handle
432 * @intr_type: SDE HW interrupt type for lookup
433 * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
434 * @return: irq_idx or -EINVAL when fail to lookup
435 */
436int sde_irq_idx_lookup(
437 struct sde_kms *sde_kms,
438 enum sde_intr_type intr_type,
439 uint32_t instance_idx);
440
441/**
442 * sde_enable_irq - IRQ helper function for enabling one or more IRQs
443 * @sde_kms: SDE handle
444 * @irq_idxs: Array of irq index
445 * @irq_count: Number of irq_idx provided in the array
446 * @return: 0 for success enabling IRQ, otherwise failure
447 */
448int sde_enable_irq(
449 struct sde_kms *sde_kms,
450 int *irq_idxs,
451 uint32_t irq_count);
452
453/**
454 * sde_disable_irq - IRQ helper function for diabling one of more IRQs
455 * @sde_kms: SDE handle
456 * @irq_idxs: Array of irq index
457 * @irq_count: Number of irq_idx provided in the array
458 * @return: 0 for success disabling IRQ, otherwise failure
459 */
460int sde_disable_irq(
461 struct sde_kms *sde_kms,
462 int *irq_idxs,
463 uint32_t irq_count);
464
465/**
Alan Kwong2fad18c2016-07-29 02:10:37 -0400466 * sde_read_irq - IRQ helper function for reading IRQ status
467 * @sde_kms: SDE handle
468 * @irq_idx: irq index
469 * @clear: True to clear the irq after read
470 * @return: non-zero if irq detected; otherwise no irq detected
471 */
472u32 sde_read_irq(
473 struct sde_kms *sde_kms,
474 int irq_idx,
475 bool clear);
476
477/**
Ben Chan78647cd2016-06-26 22:02:47 -0400478 * sde_register_irq_callback - For registering callback function on IRQ
479 * interrupt
480 * @sde_kms: SDE handle
481 * @irq_idx: irq index
482 * @irq_cb: IRQ callback structure, containing callback function
483 * and argument. Passing NULL for irq_cb will unregister
484 * the callback for the given irq_idx
485 * @return: 0 for success registering callback, otherwise failure
486 */
487int sde_register_irq_callback(
488 struct sde_kms *sde_kms,
489 int irq_idx,
490 struct sde_irq_callback *irq_cb);
491
492/**
493 * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
494 * @sde_kms: SDE handle
495 */
496void sde_clear_all_irqs(struct sde_kms *sde_kms);
497
498/**
499 * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
500 * @sde_kms: SDE handle
501 */
502void sde_disable_all_irqs(struct sde_kms *sde_kms);
503
504/**
505 * Vblank enable/disable functions
506 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700507int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
508void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
509
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400510/**
511 * Plane functions
512 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700513enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
Clarence Ipcae1bb62016-07-07 12:07:13 -0400514void sde_plane_flush(struct drm_plane *plane);
Clarence Ipdbde9832016-06-26 09:48:36 -0400515struct drm_plane *sde_plane_init(struct drm_device *dev,
516 uint32_t pipe, bool primary_plane);
Clarence Ip7a753bb2016-07-07 11:47:44 -0400517
518/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400519 * sde_plane_wait_input_fence - wait for input fence object
Clarence Ip7a753bb2016-07-07 11:47:44 -0400520 * @plane: Pointer to DRM plane object
521 * @wait_ms: Wait timeout value
522 * Returns: Zero on success
523 */
Clarence Ipcae1bb62016-07-07 12:07:13 -0400524int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
Clarence Ipcb410d42016-06-26 22:52:33 -0400525
526/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400527 * sde_plane_color_fill - Enables color fill on plane
Clarence Ipcb410d42016-06-26 22:52:33 -0400528 * @plane: Pointer to DRM plane object
529 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
530 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
531 *
532 * Returns: 0 on success
533 */
534int sde_plane_color_fill(struct drm_plane *plane,
535 uint32_t color, uint32_t alpha);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700536
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400537/**
538 * CRTC functions
539 */
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400540int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700541void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400542void sde_crtc_commit_kickoff(struct drm_crtc *crtc);
Clarence Ip24f80662016-06-13 19:05:32 -0400543
544/**
545 * sde_crtc_prepare_fence - callback to prepare for output fences
546 * @crtc: Pointer to drm crtc object
547 */
548void sde_crtc_prepare_fence(struct drm_crtc *crtc);
549
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400550/**
551 * sde_crtc_init - create a new crtc object
552 * @dev: sde device
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400553 * @plane: base plane
554 * @vblank_id: Id for reporting vblank. Id in range from 0..dev->num_crtcs.
555 * @Return: new crtc object or error
556 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700557struct drm_crtc *sde_crtc_init(struct drm_device *dev,
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400558 struct drm_plane *plane,
559 int vblank_id);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700560
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400561/**
Clarence Ip24f80662016-06-13 19:05:32 -0400562 * sde_crtc_complete_commit - callback signalling completion of current commit
563 * @crtc: Pointer to drm crtc object
564 */
565void sde_crtc_complete_commit(struct drm_crtc *crtc);
566
567/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400568 * sde_encoder_get_hw_resources - Populate table of required hardware resources
569 * @encoder: encoder pointer
570 * @hw_res: resource table to populate with encoder required resources
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400571 * @conn_state: report hw reqs based on this proposed connector state
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400572 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400573void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400574 struct sde_encoder_hw_resources *hw_res,
575 struct drm_connector_state *conn_state);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700576
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400577/**
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400578 * sde_encoder_needs_ctl_start - Get whether encoder type requires ctl_start
579 * CMD and WB encoders need ctl_start, video encs do not.
580 * @encoder: encoder pointer
581 * @Return: true if the encoder type requires ctl_start issued
582 */
583bool sde_encoder_needs_ctl_start(struct drm_encoder *encoder);
584
585/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400586 * sde_encoder_register_vblank_callback - provide callback to encoder that
587 * will be called on the next vblank.
588 * @encoder: encoder pointer
589 * @cb: callback pointer, provide NULL to deregister and disable IRQs
590 * @data: user data provided to callback
591 */
592void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
593 void (*cb)(void *), void *data);
594
595/**
596 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
597 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
598 * at the appropriate time.
599 * Immediately: if no previous commit is outstanding.
600 * Delayed: Save the callback, and return. Does not block. Callback will
601 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
602 * irq if it outstanding.
603 * Callback registered is expected to flush _all_ ctl paths of the crtc
604 * @encoder: encoder pointer
605 * @cb: callback pointer, provide NULL to deregister
606 * @data: user data provided to callback
607 */
608void sde_encoder_schedule_kickoff(struct drm_encoder *encoder,
609 void (*cb)(void *), void *data);
610
611/**
612 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
613 * current pending frames to hardware at a vblank or ctl_start
614 * Encoders will map this differently depending on irqs
615 * vid mode -> vsync_irq
616 * @encoder: encoder pointer
617 *
618 * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
619 */
620int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
621
622/**
Clarence Ip03521982016-08-26 10:49:47 -0400623 * sde_encoder_get_intf_mode - returns current underlying interface mode
624 * @encoder: encoder pointer
625 * Returns: Interface mode of underlying physical master encoder
626 */
627enum sde_intf_mode sde_encoder_get_intf_mode(struct drm_encoder *encoder);
628
629/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400630 * sde_encoders_init - query platform, create all encoders and bridges,
631 * and register them with the drm_device
632 * @dev: drm device pointer
633 */
634void sde_encoders_init(struct drm_device *dev);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700635
Alan Kwong5d324e42016-07-28 22:56:18 -0400636/**
637 * sde_vbif_set_ot_limit - set OT limit for vbif client
638 * @sde_kms: SDE handler
639 * @params: Pointer to OT configuration parameters
640 */
641void sde_vbif_set_ot_limit(struct sde_kms *sde_kms,
642 struct sde_vbif_set_ot_params *params);
643
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700644#endif /* __sde_kms_H__ */