blob: a15e5cd1bddbfe15a3a4d27d1cb31ffa86b6cc4f [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"
Ben Chan78647cd2016-06-26 22:02:47 -040028
Clarence Ip31c19b52016-06-10 15:42:08 -040029/**
30 * SDE_DEBUG - macro for kms/plane/crtc/encoder/connector logs
31 * @fmt: Pointer to format string
32 */
33#define SDE_DEBUG(fmt, ...) \
34 do { \
35 if (unlikely(drm_debug & DRM_UT_KMS)) \
36 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
37 else \
38 pr_debug(fmt, ##__VA_ARGS__); \
39 } while (0)
40
41/**
42 * SDE_DEBUG_DRIVER - macro for hardware driver logging
43 * @fmt: Pointer to format string
44 */
45#define SDE_DEBUG_DRIVER(fmt, ...) \
46 do { \
47 if (unlikely(drm_debug & DRM_UT_DRIVER)) \
48 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
49 else \
50 pr_debug(fmt, ##__VA_ARGS__); \
51 } while (0)
52
53#define SDE_ERROR(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
54
Dhaval Patelec10fad2016-08-22 14:40:48 -070055#define POPULATE_RECT(rect, a, b, c, d, Q16_flag) \
56 do { \
57 (rect)->x = (Q16_flag) ? (a) >> 16 : (a); \
58 (rect)->y = (Q16_flag) ? (b) >> 16 : (b); \
59 (rect)->w = (Q16_flag) ? (c) >> 16 : (c); \
60 (rect)->h = (Q16_flag) ? (d) >> 16 : (d); \
61 } while (0)
62
63#define CHECK_LAYER_BOUNDS(offset, size, max_size) \
64 (((size) > (max_size)) || ((offset) > ((max_size) - (size))))
65
Clarence Ipfd96ba22016-09-09 16:45:44 -040066/**
67 * ktime_compare_safe - compare two ktime structures
68 * This macro is similar to the standard ktime_compare() function, but
69 * attempts to also handle ktime overflows.
70 * @A: First ktime value
71 * @B: Second ktime value
72 * Returns: -1 if A < B, 0 if A == B, 1 if A > B
73 */
74#define ktime_compare_safe(A, B) \
75 ktime_compare(ktime_sub((A), (B)), ktime_set(0, 0))
76
Ben Chan78647cd2016-06-26 22:02:47 -040077/*
78 * struct sde_irq_callback - IRQ callback handlers
79 * @func: intr handler
80 * @arg: argument for the handler
81 */
82struct sde_irq_callback {
83 void (*func)(void *arg, int irq_idx);
84 void *arg;
85};
86
87/**
88 * struct sde_irq: IRQ structure contains callback registration info
89 * @total_irq: total number of irq_idx obtained from HW interrupts mapping
90 * @irq_cb_tbl: array of IRQ callbacks setting
91 * @cb_lock: callback lock
92 */
93struct sde_irq {
94 u32 total_irqs;
95 struct sde_irq_callback *irq_cb_tbl;
96 spinlock_t cb_lock;
97};
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070098
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040099/**
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400100 * Encoder functions and data types
101 * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused
102 * @wbs: Writebacks this encoder is using, INTF_MODE_NONE if unused
103 * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs
104 * @display_num_of_h_tiles:
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400105 */
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400106struct sde_encoder_hw_resources {
107 enum sde_intf_mode intfs[INTF_MAX];
108 enum sde_intf_mode wbs[WB_MAX];
109 bool needs_cdm;
110 u32 display_num_of_h_tiles;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400111};
112
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700113struct sde_kms {
Ben Chan78647cd2016-06-26 22:02:47 -0400114 struct msm_kms base;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700115 struct drm_device *dev;
116 int rev;
117 struct sde_mdss_cfg *catalog;
118
Alan Kwong112a84f2016-05-24 20:49:21 -0400119 struct msm_mmu *mmu[MSM_SMMU_DOMAIN_MAX];
120 int mmu_id[MSM_SMMU_DOMAIN_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700121
Clarence Ip4ce59322016-06-26 22:27:51 -0400122 /* directory entry for debugfs */
123 void *debugfs_root;
124
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700125 /* io/register spaces: */
Alan Kwongdfa8c082016-07-29 04:10:00 -0400126 void __iomem *mmio, *vbif[VBIF_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700127
128 struct regulator *vdd;
129 struct regulator *mmagic;
130 struct regulator *venus;
131
132 struct clk *axi_clk;
133 struct clk *ahb_clk;
134 struct clk *src_clk;
135 struct clk *core_clk;
136 struct clk *lut_clk;
137 struct clk *mmagic_clk;
Alan Kwong112a84f2016-05-24 20:49:21 -0400138 struct clk *iommu_axi_clk[MSM_SMMU_DOMAIN_MAX];
139 struct clk *iommu_ahb_clk[MSM_SMMU_DOMAIN_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700140 struct clk *vsync_clk;
141
142 struct {
143 unsigned long enabled_mask;
144 struct irq_domain *domain;
145 } irqcontroller;
Ben Chan78647cd2016-06-26 22:02:47 -0400146
147 struct sde_hw_intr *hw_intr;
148 struct sde_irq irq_obj;
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400149
150 struct sde_rm rm;
Ben Chan78647cd2016-06-26 22:02:47 -0400151};
152
153struct vsync_info {
154 u32 frame_count;
155 u32 line_count;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700156};
157
158#define to_sde_kms(x) container_of(x, struct sde_kms, base)
159
160struct sde_plane_state {
161 struct drm_plane_state base;
162
163 /* aligned with property */
Clarence Ipe78efb72016-06-24 18:35:21 -0400164 uint64_t property_values[PLANE_PROP_COUNT];
165
166 /* blob properties */
167 struct drm_property_blob *property_blobs[PLANE_PROP_BLOBCOUNT];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700168
Clarence Ipcae1bb62016-07-07 12:07:13 -0400169 /* dereferenced input fence pointer */
170 void *input_fence;
Clarence Ipae4e60c2016-06-26 22:44:04 -0400171
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700172 /* assigned by crtc blender */
173 enum sde_stage stage;
174
175 /* some additional transactional status to help us know in the
176 * apply path whether we need to update SMP allocation, and
177 * whether current update is still pending:
178 */
179 bool mode_changed : 1;
180 bool pending : 1;
181};
182
183#define to_sde_plane_state(x) \
Clarence Ip4c1d9772016-06-26 09:35:38 -0400184 container_of(x, struct sde_plane_state, base)
185
186/**
187 * sde_plane_get_property - Query integer value of plane property
188 *
189 * @S: Pointer to plane state
190 * @X: Property index, from enum msm_mdp_plane_property
191 *
192 * Return: Integer value of requested property
193 */
194#define sde_plane_get_property(S, X) \
195 ((S) && ((X) < PLANE_PROP_COUNT) ? ((S)->property_values[(X)]) : 0)
196
197/**
198 * sde_plane_get_property32 - Query 32-bit representation of plane property
199 *
200 * @S: Pointer to plane state
201 * @X: Property index, from enum msm_mdp_plane_property
202 *
203 * Return: 32-bit value of requested property
204 */
205#define sde_plane_get_property32(S, X) \
206 ((S) && ((X) < PLANE_PROP_COUNT) ? \
207 (uint32_t)((S)->property_values[(X)]) : 0)
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700208
209int sde_disable(struct sde_kms *sde_kms);
210int sde_enable(struct sde_kms *sde_kms);
211
Ben Chan78647cd2016-06-26 22:02:47 -0400212/**
Clarence Ip4ce59322016-06-26 22:27:51 -0400213 * Debugfs functions - extra helper functions for debugfs support
214 *
215 * Main debugfs documentation is located at,
216 *
217 * Documentation/filesystems/debugfs.txt
218 *
219 * @sde_debugfs_setup_regset32: Initialize data for sde_debugfs_create_regset32
220 * @sde_debugfs_create_regset32: Create 32-bit register dump file
221 * @sde_debugfs_get_root: Get root dentry for SDE_KMS's debugfs node
222 */
223
224/**
225 * Companion structure for sde_debugfs_create_regset32. Do not initialize the
226 * members of this structure explicitly; use sde_debugfs_setup_regset32 instead.
227 */
228struct sde_debugfs_regset32 {
229 uint32_t offset;
230 uint32_t blk_len;
231 void __iomem *base;
232};
233
234/**
235 * sde_debugfs_setup_regset32 - Initialize register block definition for debugfs
236 * This function is meant to initialize sde_debugfs_regset32 structures for use
237 * with sde_debugfs_create_regset32.
238 * @regset: opaque register definition structure
239 * @offset: sub-block offset
240 * @length: sub-block length, in bytes
241 * @base: base IOMEM address
242 */
243void sde_debugfs_setup_regset32(struct sde_debugfs_regset32 *regset,
244 uint32_t offset, uint32_t length, void __iomem *base);
245
246/**
247 * sde_debugfs_create_regset32 - Create register read back file for debugfs
248 *
249 * This function is almost identical to the standard debugfs_create_regset32()
250 * function, with the main difference being that a list of register
251 * names/offsets do not need to be provided. The 'read' function simply outputs
252 * sequential register values over a specified range.
253 *
254 * Similar to the related debugfs_create_regset32 API, the structure pointed to
255 * by regset needs to persist for the lifetime of the created file. The calling
256 * code is responsible for initialization/management of this structure.
257 *
258 * The structure pointed to by regset is meant to be opaque. Please use
259 * sde_debugfs_setup_regset32 to initialize it.
260 *
261 * @name: File name within debugfs
262 * @mode: File mode within debugfs
263 * @parent: Parent directory entry within debugfs, can be NULL
264 * @regset: Pointer to persistent register block definition
265 *
266 * Return: dentry pointer for newly created file, use either debugfs_remove()
267 * or debugfs_remove_recursive() (on a parent directory) to remove the
268 * file
269 */
270void *sde_debugfs_create_regset32(const char *name, umode_t mode,
271 void *parent, struct sde_debugfs_regset32 *regset);
272
273/**
274 * sde_debugfs_get_root - Return root directory entry for SDE's debugfs
275 *
276 * The return value should be passed as the 'parent' argument to subsequent
277 * debugfs create calls.
278 *
279 * @sde_kms: Pointer to SDE's KMS structure
280 *
281 * Return: dentry pointer for SDE's debugfs location
282 */
283void *sde_debugfs_get_root(struct sde_kms *sde_kms);
284
285/**
Clarence Ipb218a3c2016-07-15 14:17:42 -0400286 * SDE info management functions
287 * These functions/definitions allow for building up a 'sde_info' structure
288 * containing one or more "key=value\n" entries.
289 */
290#define SDE_KMS_INFO_MAX_SIZE 4096
291
292/**
293 * struct sde_kms_info - connector information structure container
294 * @data: Array of information character data
295 * @len: Current length of information data
296 * @staged_len: Temporary data buffer length, commit to
297 * len using sde_kms_info_stop
298 * @start: Whether or not a partial data entry was just started
299 */
300struct sde_kms_info {
301 char data[SDE_KMS_INFO_MAX_SIZE];
302 uint32_t len;
303 uint32_t staged_len;
304 bool start;
305};
306
307/**
308 * SDE_KMS_INFO_DATA - Macro for accessing sde_kms_info data bytes
309 * @S: Pointer to sde_kms_info structure
310 * Returns: Pointer to byte data
311 */
312#define SDE_KMS_INFO_DATA(S) ((S) ? ((struct sde_kms_info *)(S))->data : 0)
313
314/**
315 * SDE_KMS_INFO_DATALEN - Macro for accessing sde_kms_info data length
316 * @S: Pointer to sde_kms_info structure
317 * Returns: Size of available byte data
318 */
319#define SDE_KMS_INFO_DATALEN(S) ((S) ? ((struct sde_kms_info *)(S))->len : 0)
320
321/**
322 * sde_kms_info_reset - reset sde_kms_info structure
323 * @info: Pointer to sde_kms_info structure
324 */
325void sde_kms_info_reset(struct sde_kms_info *info);
326
327/**
328 * sde_kms_info_add_keyint - add integer value to 'sde_kms_info'
329 * @info: Pointer to sde_kms_info structure
330 * @key: Pointer to key string
331 * @value: Signed 32-bit integer value
332 */
333void sde_kms_info_add_keyint(struct sde_kms_info *info,
334 const char *key,
335 int32_t value);
336
337/**
338 * sde_kms_info_add_keystr - add string value to 'sde_kms_info'
339 * @info: Pointer to sde_kms_info structure
340 * @key: Pointer to key string
341 * @value: Pointer to string value
342 */
343void sde_kms_info_add_keystr(struct sde_kms_info *info,
344 const char *key,
345 const char *value);
346
347/**
348 * sde_kms_info_start - begin adding key to 'sde_kms_info'
349 * Usage:
350 * sde_kms_info_start(key)
351 * sde_kms_info_append(val_1)
352 * ...
353 * sde_kms_info_append(val_n)
354 * sde_kms_info_stop
355 * @info: Pointer to sde_kms_info structure
356 * @key: Pointer to key string
357 */
358void sde_kms_info_start(struct sde_kms_info *info,
359 const char *key);
360
361/**
362 * sde_kms_info_append - append value string to 'sde_kms_info'
363 * Usage:
364 * sde_kms_info_start(key)
365 * sde_kms_info_append(val_1)
366 * ...
367 * sde_kms_info_append(val_n)
368 * sde_kms_info_stop
369 * @info: Pointer to sde_kms_info structure
370 * @str: Pointer to partial value string
371 */
372void sde_kms_info_append(struct sde_kms_info *info,
373 const char *str);
374
375/**
376 * sde_kms_info_append_format - append format code string to 'sde_kms_info'
377 * Usage:
378 * sde_kms_info_start(key)
379 * sde_kms_info_append_format(fourcc, modifier)
380 * ...
381 * sde_kms_info_stop
382 * @info: Pointer to sde_kms_info structure
383 * @pixel_format: FOURCC format code
384 * @modifier: 64-bit drm format modifier
385 */
386void sde_kms_info_append_format(struct sde_kms_info *info,
387 uint32_t pixel_format,
388 uint64_t modifier);
389
390/**
391 * sde_kms_info_stop - finish adding key to 'sde_kms_info'
392 * Usage:
393 * sde_kms_info_start(key)
394 * sde_kms_info_append(val_1)
395 * ...
396 * sde_kms_info_append(val_n)
397 * sde_kms_info_stop
398 * @info: Pointer to sde_kms_info structure
399 */
400void sde_kms_info_stop(struct sde_kms_info *info);
401
402/**
Ben Chan78647cd2016-06-26 22:02:47 -0400403 * IRQ functions
404 */
405int sde_irq_domain_init(struct sde_kms *sde_kms);
406int sde_irq_domain_fini(struct sde_kms *sde_kms);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700407void sde_irq_preinstall(struct msm_kms *kms);
408int sde_irq_postinstall(struct msm_kms *kms);
409void sde_irq_uninstall(struct msm_kms *kms);
410irqreturn_t sde_irq(struct msm_kms *kms);
Ben Chan78647cd2016-06-26 22:02:47 -0400411
412/**
413 * sde_set_irqmask - IRQ helper function for writing IRQ mask
414 * to SDE HW interrupt register.
415 * @sde_kms: SDE handle
416 * @reg_off: SDE HW interrupt register offset
417 * @irqmask: IRQ mask
418 */
419void sde_set_irqmask(
420 struct sde_kms *sde_kms,
421 uint32_t reg_off,
422 uint32_t irqmask);
423
424/**
425 * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
426 * interrupt mapping table.
427 * @sde_kms: SDE handle
428 * @intr_type: SDE HW interrupt type for lookup
429 * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
430 * @return: irq_idx or -EINVAL when fail to lookup
431 */
432int sde_irq_idx_lookup(
433 struct sde_kms *sde_kms,
434 enum sde_intr_type intr_type,
435 uint32_t instance_idx);
436
437/**
438 * sde_enable_irq - IRQ helper function for enabling one or more IRQs
439 * @sde_kms: SDE handle
440 * @irq_idxs: Array of irq index
441 * @irq_count: Number of irq_idx provided in the array
442 * @return: 0 for success enabling IRQ, otherwise failure
443 */
444int sde_enable_irq(
445 struct sde_kms *sde_kms,
446 int *irq_idxs,
447 uint32_t irq_count);
448
449/**
450 * sde_disable_irq - IRQ helper function for diabling one of more IRQs
451 * @sde_kms: SDE handle
452 * @irq_idxs: Array of irq index
453 * @irq_count: Number of irq_idx provided in the array
454 * @return: 0 for success disabling IRQ, otherwise failure
455 */
456int sde_disable_irq(
457 struct sde_kms *sde_kms,
458 int *irq_idxs,
459 uint32_t irq_count);
460
461/**
Alan Kwong2fad18c2016-07-29 02:10:37 -0400462 * sde_read_irq - IRQ helper function for reading IRQ status
463 * @sde_kms: SDE handle
464 * @irq_idx: irq index
465 * @clear: True to clear the irq after read
466 * @return: non-zero if irq detected; otherwise no irq detected
467 */
468u32 sde_read_irq(
469 struct sde_kms *sde_kms,
470 int irq_idx,
471 bool clear);
472
473/**
Ben Chan78647cd2016-06-26 22:02:47 -0400474 * sde_register_irq_callback - For registering callback function on IRQ
475 * interrupt
476 * @sde_kms: SDE handle
477 * @irq_idx: irq index
478 * @irq_cb: IRQ callback structure, containing callback function
479 * and argument. Passing NULL for irq_cb will unregister
480 * the callback for the given irq_idx
481 * @return: 0 for success registering callback, otherwise failure
482 */
483int sde_register_irq_callback(
484 struct sde_kms *sde_kms,
485 int irq_idx,
486 struct sde_irq_callback *irq_cb);
487
488/**
489 * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
490 * @sde_kms: SDE handle
491 */
492void sde_clear_all_irqs(struct sde_kms *sde_kms);
493
494/**
495 * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
496 * @sde_kms: SDE handle
497 */
498void sde_disable_all_irqs(struct sde_kms *sde_kms);
499
500/**
501 * Vblank enable/disable functions
502 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700503int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
504void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
505
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400506/**
507 * Plane functions
508 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700509enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
Clarence Ipcae1bb62016-07-07 12:07:13 -0400510void sde_plane_flush(struct drm_plane *plane);
Clarence Ipdbde9832016-06-26 09:48:36 -0400511struct drm_plane *sde_plane_init(struct drm_device *dev,
512 uint32_t pipe, bool primary_plane);
Clarence Ip7a753bb2016-07-07 11:47:44 -0400513
514/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400515 * sde_plane_wait_input_fence - wait for input fence object
Clarence Ip7a753bb2016-07-07 11:47:44 -0400516 * @plane: Pointer to DRM plane object
517 * @wait_ms: Wait timeout value
518 * Returns: Zero on success
519 */
Clarence Ipcae1bb62016-07-07 12:07:13 -0400520int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
Clarence Ipcb410d42016-06-26 22:52:33 -0400521
522/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400523 * sde_plane_color_fill - Enables color fill on plane
Clarence Ipcb410d42016-06-26 22:52:33 -0400524 * @plane: Pointer to DRM plane object
525 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
526 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
527 *
528 * Returns: 0 on success
529 */
530int sde_plane_color_fill(struct drm_plane *plane,
531 uint32_t color, uint32_t alpha);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700532
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400533/**
534 * CRTC functions
535 */
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400536int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700537void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400538void sde_crtc_commit_kickoff(struct drm_crtc *crtc);
Clarence Ip24f80662016-06-13 19:05:32 -0400539
540/**
541 * sde_crtc_prepare_fence - callback to prepare for output fences
542 * @crtc: Pointer to drm crtc object
543 */
544void sde_crtc_prepare_fence(struct drm_crtc *crtc);
545
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400546/**
547 * sde_crtc_init - create a new crtc object
548 * @dev: sde device
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400549 * @plane: base plane
550 * @vblank_id: Id for reporting vblank. Id in range from 0..dev->num_crtcs.
551 * @Return: new crtc object or error
552 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700553struct drm_crtc *sde_crtc_init(struct drm_device *dev,
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400554 struct drm_plane *plane,
555 int vblank_id);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700556
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400557/**
Clarence Ip24f80662016-06-13 19:05:32 -0400558 * sde_crtc_complete_commit - callback signalling completion of current commit
559 * @crtc: Pointer to drm crtc object
560 */
561void sde_crtc_complete_commit(struct drm_crtc *crtc);
562
563/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400564 * sde_encoder_get_hw_resources - Populate table of required hardware resources
565 * @encoder: encoder pointer
566 * @hw_res: resource table to populate with encoder required resources
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400567 * @conn_state: report hw reqs based on this proposed connector state
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400568 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400569void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400570 struct sde_encoder_hw_resources *hw_res,
571 struct drm_connector_state *conn_state);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700572
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400573/**
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400574 * sde_encoder_needs_ctl_start - Get whether encoder type requires ctl_start
575 * CMD and WB encoders need ctl_start, video encs do not.
576 * @encoder: encoder pointer
577 * @Return: true if the encoder type requires ctl_start issued
578 */
579bool sde_encoder_needs_ctl_start(struct drm_encoder *encoder);
580
581/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400582 * sde_encoder_register_vblank_callback - provide callback to encoder that
583 * will be called on the next vblank.
584 * @encoder: encoder pointer
585 * @cb: callback pointer, provide NULL to deregister and disable IRQs
586 * @data: user data provided to callback
587 */
588void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
589 void (*cb)(void *), void *data);
590
591/**
592 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
593 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
594 * at the appropriate time.
595 * Immediately: if no previous commit is outstanding.
596 * Delayed: Save the callback, and return. Does not block. Callback will
597 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
598 * irq if it outstanding.
599 * Callback registered is expected to flush _all_ ctl paths of the crtc
600 * @encoder: encoder pointer
601 * @cb: callback pointer, provide NULL to deregister
602 * @data: user data provided to callback
603 */
604void sde_encoder_schedule_kickoff(struct drm_encoder *encoder,
605 void (*cb)(void *), void *data);
606
607/**
608 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
609 * current pending frames to hardware at a vblank or ctl_start
610 * Encoders will map this differently depending on irqs
611 * vid mode -> vsync_irq
612 * @encoder: encoder pointer
613 *
614 * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
615 */
616int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
617
618/**
Clarence Ip03521982016-08-26 10:49:47 -0400619 * sde_encoder_get_intf_mode - returns current underlying interface mode
620 * @encoder: encoder pointer
621 * Returns: Interface mode of underlying physical master encoder
622 */
623enum sde_intf_mode sde_encoder_get_intf_mode(struct drm_encoder *encoder);
624
625/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400626 * sde_encoders_init - query platform, create all encoders and bridges,
627 * and register them with the drm_device
628 * @dev: drm device pointer
629 */
630void sde_encoders_init(struct drm_device *dev);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700631
632#endif /* __sde_kms_H__ */