blob: 460491e5f4c71d8c82c958a63decf514110c61c6 [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;
Ben Chan78647cd2016-06-26 22:02:47 -0400143};
144
145struct vsync_info {
146 u32 frame_count;
147 u32 line_count;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700148};
149
150#define to_sde_kms(x) container_of(x, struct sde_kms, base)
151
152struct sde_plane_state {
153 struct drm_plane_state base;
154
155 /* aligned with property */
Clarence Ipe78efb72016-06-24 18:35:21 -0400156 uint64_t property_values[PLANE_PROP_COUNT];
157
158 /* blob properties */
159 struct drm_property_blob *property_blobs[PLANE_PROP_BLOBCOUNT];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700160
Clarence Ipcae1bb62016-07-07 12:07:13 -0400161 /* dereferenced input fence pointer */
162 void *input_fence;
Clarence Ipae4e60c2016-06-26 22:44:04 -0400163
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700164 /* assigned by crtc blender */
165 enum sde_stage stage;
166
167 /* some additional transactional status to help us know in the
168 * apply path whether we need to update SMP allocation, and
169 * whether current update is still pending:
170 */
171 bool mode_changed : 1;
172 bool pending : 1;
173};
174
175#define to_sde_plane_state(x) \
Clarence Ip4c1d9772016-06-26 09:35:38 -0400176 container_of(x, struct sde_plane_state, base)
177
178/**
179 * sde_plane_get_property - Query integer value of plane property
180 *
181 * @S: Pointer to plane state
182 * @X: Property index, from enum msm_mdp_plane_property
183 *
184 * Return: Integer value of requested property
185 */
186#define sde_plane_get_property(S, X) \
187 ((S) && ((X) < PLANE_PROP_COUNT) ? ((S)->property_values[(X)]) : 0)
188
189/**
190 * sde_plane_get_property32 - Query 32-bit representation of plane property
191 *
192 * @S: Pointer to plane state
193 * @X: Property index, from enum msm_mdp_plane_property
194 *
195 * Return: 32-bit value of requested property
196 */
197#define sde_plane_get_property32(S, X) \
198 ((S) && ((X) < PLANE_PROP_COUNT) ? \
199 (uint32_t)((S)->property_values[(X)]) : 0)
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700200
Ben Chan78647cd2016-06-26 22:02:47 -0400201/**
Clarence Ip4ce59322016-06-26 22:27:51 -0400202 * Debugfs functions - extra helper functions for debugfs support
203 *
204 * Main debugfs documentation is located at,
205 *
206 * Documentation/filesystems/debugfs.txt
207 *
208 * @sde_debugfs_setup_regset32: Initialize data for sde_debugfs_create_regset32
209 * @sde_debugfs_create_regset32: Create 32-bit register dump file
210 * @sde_debugfs_get_root: Get root dentry for SDE_KMS's debugfs node
211 */
212
213/**
214 * Companion structure for sde_debugfs_create_regset32. Do not initialize the
215 * members of this structure explicitly; use sde_debugfs_setup_regset32 instead.
216 */
217struct sde_debugfs_regset32 {
218 uint32_t offset;
219 uint32_t blk_len;
220 void __iomem *base;
221};
222
223/**
224 * sde_debugfs_setup_regset32 - Initialize register block definition for debugfs
225 * This function is meant to initialize sde_debugfs_regset32 structures for use
226 * with sde_debugfs_create_regset32.
227 * @regset: opaque register definition structure
228 * @offset: sub-block offset
229 * @length: sub-block length, in bytes
230 * @base: base IOMEM address
231 */
232void sde_debugfs_setup_regset32(struct sde_debugfs_regset32 *regset,
233 uint32_t offset, uint32_t length, void __iomem *base);
234
235/**
236 * sde_debugfs_create_regset32 - Create register read back file for debugfs
237 *
238 * This function is almost identical to the standard debugfs_create_regset32()
239 * function, with the main difference being that a list of register
240 * names/offsets do not need to be provided. The 'read' function simply outputs
241 * sequential register values over a specified range.
242 *
243 * Similar to the related debugfs_create_regset32 API, the structure pointed to
244 * by regset needs to persist for the lifetime of the created file. The calling
245 * code is responsible for initialization/management of this structure.
246 *
247 * The structure pointed to by regset is meant to be opaque. Please use
248 * sde_debugfs_setup_regset32 to initialize it.
249 *
250 * @name: File name within debugfs
251 * @mode: File mode within debugfs
252 * @parent: Parent directory entry within debugfs, can be NULL
253 * @regset: Pointer to persistent register block definition
254 *
255 * Return: dentry pointer for newly created file, use either debugfs_remove()
256 * or debugfs_remove_recursive() (on a parent directory) to remove the
257 * file
258 */
259void *sde_debugfs_create_regset32(const char *name, umode_t mode,
260 void *parent, struct sde_debugfs_regset32 *regset);
261
262/**
263 * sde_debugfs_get_root - Return root directory entry for SDE's debugfs
264 *
265 * The return value should be passed as the 'parent' argument to subsequent
266 * debugfs create calls.
267 *
268 * @sde_kms: Pointer to SDE's KMS structure
269 *
270 * Return: dentry pointer for SDE's debugfs location
271 */
272void *sde_debugfs_get_root(struct sde_kms *sde_kms);
273
274/**
Clarence Ipb218a3c2016-07-15 14:17:42 -0400275 * SDE info management functions
276 * These functions/definitions allow for building up a 'sde_info' structure
277 * containing one or more "key=value\n" entries.
278 */
279#define SDE_KMS_INFO_MAX_SIZE 4096
280
281/**
282 * struct sde_kms_info - connector information structure container
283 * @data: Array of information character data
284 * @len: Current length of information data
285 * @staged_len: Temporary data buffer length, commit to
286 * len using sde_kms_info_stop
287 * @start: Whether or not a partial data entry was just started
288 */
289struct sde_kms_info {
290 char data[SDE_KMS_INFO_MAX_SIZE];
291 uint32_t len;
292 uint32_t staged_len;
293 bool start;
294};
295
296/**
297 * SDE_KMS_INFO_DATA - Macro for accessing sde_kms_info data bytes
298 * @S: Pointer to sde_kms_info structure
299 * Returns: Pointer to byte data
300 */
301#define SDE_KMS_INFO_DATA(S) ((S) ? ((struct sde_kms_info *)(S))->data : 0)
302
303/**
304 * SDE_KMS_INFO_DATALEN - Macro for accessing sde_kms_info data length
305 * @S: Pointer to sde_kms_info structure
306 * Returns: Size of available byte data
307 */
308#define SDE_KMS_INFO_DATALEN(S) ((S) ? ((struct sde_kms_info *)(S))->len : 0)
309
310/**
311 * sde_kms_info_reset - reset sde_kms_info structure
312 * @info: Pointer to sde_kms_info structure
313 */
314void sde_kms_info_reset(struct sde_kms_info *info);
315
316/**
317 * sde_kms_info_add_keyint - add integer value to 'sde_kms_info'
318 * @info: Pointer to sde_kms_info structure
319 * @key: Pointer to key string
320 * @value: Signed 32-bit integer value
321 */
322void sde_kms_info_add_keyint(struct sde_kms_info *info,
323 const char *key,
324 int32_t value);
325
326/**
327 * sde_kms_info_add_keystr - add string value to 'sde_kms_info'
328 * @info: Pointer to sde_kms_info structure
329 * @key: Pointer to key string
330 * @value: Pointer to string value
331 */
332void sde_kms_info_add_keystr(struct sde_kms_info *info,
333 const char *key,
334 const char *value);
335
336/**
337 * sde_kms_info_start - begin adding key to 'sde_kms_info'
338 * Usage:
339 * sde_kms_info_start(key)
340 * sde_kms_info_append(val_1)
341 * ...
342 * sde_kms_info_append(val_n)
343 * sde_kms_info_stop
344 * @info: Pointer to sde_kms_info structure
345 * @key: Pointer to key string
346 */
347void sde_kms_info_start(struct sde_kms_info *info,
348 const char *key);
349
350/**
351 * sde_kms_info_append - append value string to 'sde_kms_info'
352 * Usage:
353 * sde_kms_info_start(key)
354 * sde_kms_info_append(val_1)
355 * ...
356 * sde_kms_info_append(val_n)
357 * sde_kms_info_stop
358 * @info: Pointer to sde_kms_info structure
359 * @str: Pointer to partial value string
360 */
361void sde_kms_info_append(struct sde_kms_info *info,
362 const char *str);
363
364/**
365 * sde_kms_info_append_format - append format code string to 'sde_kms_info'
366 * Usage:
367 * sde_kms_info_start(key)
368 * sde_kms_info_append_format(fourcc, modifier)
369 * ...
370 * sde_kms_info_stop
371 * @info: Pointer to sde_kms_info structure
372 * @pixel_format: FOURCC format code
373 * @modifier: 64-bit drm format modifier
374 */
375void sde_kms_info_append_format(struct sde_kms_info *info,
376 uint32_t pixel_format,
377 uint64_t modifier);
378
379/**
380 * sde_kms_info_stop - finish adding key to 'sde_kms_info'
381 * Usage:
382 * sde_kms_info_start(key)
383 * sde_kms_info_append(val_1)
384 * ...
385 * sde_kms_info_append(val_n)
386 * sde_kms_info_stop
387 * @info: Pointer to sde_kms_info structure
388 */
389void sde_kms_info_stop(struct sde_kms_info *info);
390
391/**
Ben Chan78647cd2016-06-26 22:02:47 -0400392 * IRQ functions
393 */
394int sde_irq_domain_init(struct sde_kms *sde_kms);
395int sde_irq_domain_fini(struct sde_kms *sde_kms);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700396void sde_irq_preinstall(struct msm_kms *kms);
397int sde_irq_postinstall(struct msm_kms *kms);
398void sde_irq_uninstall(struct msm_kms *kms);
399irqreturn_t sde_irq(struct msm_kms *kms);
Ben Chan78647cd2016-06-26 22:02:47 -0400400
401/**
402 * sde_set_irqmask - IRQ helper function for writing IRQ mask
403 * to SDE HW interrupt register.
404 * @sde_kms: SDE handle
405 * @reg_off: SDE HW interrupt register offset
406 * @irqmask: IRQ mask
407 */
408void sde_set_irqmask(
409 struct sde_kms *sde_kms,
410 uint32_t reg_off,
411 uint32_t irqmask);
412
413/**
414 * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
415 * interrupt mapping table.
416 * @sde_kms: SDE handle
417 * @intr_type: SDE HW interrupt type for lookup
418 * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
419 * @return: irq_idx or -EINVAL when fail to lookup
420 */
421int sde_irq_idx_lookup(
422 struct sde_kms *sde_kms,
423 enum sde_intr_type intr_type,
424 uint32_t instance_idx);
425
426/**
427 * sde_enable_irq - IRQ helper function for enabling one or more IRQs
428 * @sde_kms: SDE handle
429 * @irq_idxs: Array of irq index
430 * @irq_count: Number of irq_idx provided in the array
431 * @return: 0 for success enabling IRQ, otherwise failure
432 */
433int sde_enable_irq(
434 struct sde_kms *sde_kms,
435 int *irq_idxs,
436 uint32_t irq_count);
437
438/**
439 * sde_disable_irq - IRQ helper function for diabling one of more IRQs
440 * @sde_kms: SDE handle
441 * @irq_idxs: Array of irq index
442 * @irq_count: Number of irq_idx provided in the array
443 * @return: 0 for success disabling IRQ, otherwise failure
444 */
445int sde_disable_irq(
446 struct sde_kms *sde_kms,
447 int *irq_idxs,
448 uint32_t irq_count);
449
450/**
Alan Kwong2fad18c2016-07-29 02:10:37 -0400451 * sde_read_irq - IRQ helper function for reading IRQ status
452 * @sde_kms: SDE handle
453 * @irq_idx: irq index
454 * @clear: True to clear the irq after read
455 * @return: non-zero if irq detected; otherwise no irq detected
456 */
457u32 sde_read_irq(
458 struct sde_kms *sde_kms,
459 int irq_idx,
460 bool clear);
461
462/**
Ben Chan78647cd2016-06-26 22:02:47 -0400463 * sde_register_irq_callback - For registering callback function on IRQ
464 * interrupt
465 * @sde_kms: SDE handle
466 * @irq_idx: irq index
467 * @irq_cb: IRQ callback structure, containing callback function
468 * and argument. Passing NULL for irq_cb will unregister
469 * the callback for the given irq_idx
470 * @return: 0 for success registering callback, otherwise failure
471 */
472int sde_register_irq_callback(
473 struct sde_kms *sde_kms,
474 int irq_idx,
475 struct sde_irq_callback *irq_cb);
476
477/**
478 * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
479 * @sde_kms: SDE handle
480 */
481void sde_clear_all_irqs(struct sde_kms *sde_kms);
482
483/**
484 * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
485 * @sde_kms: SDE handle
486 */
487void sde_disable_all_irqs(struct sde_kms *sde_kms);
488
489/**
490 * Vblank enable/disable functions
491 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700492int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
493void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
494
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400495/**
496 * Plane functions
497 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700498enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
Clarence Ipcae1bb62016-07-07 12:07:13 -0400499void sde_plane_flush(struct drm_plane *plane);
Clarence Ipdbde9832016-06-26 09:48:36 -0400500struct drm_plane *sde_plane_init(struct drm_device *dev,
501 uint32_t pipe, bool primary_plane);
Clarence Ip7a753bb2016-07-07 11:47:44 -0400502
503/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400504 * sde_plane_wait_input_fence - wait for input fence object
Clarence Ip7a753bb2016-07-07 11:47:44 -0400505 * @plane: Pointer to DRM plane object
506 * @wait_ms: Wait timeout value
507 * Returns: Zero on success
508 */
Clarence Ipcae1bb62016-07-07 12:07:13 -0400509int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
Clarence Ipcb410d42016-06-26 22:52:33 -0400510
511/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400512 * sde_plane_color_fill - Enables color fill on plane
Clarence Ipcb410d42016-06-26 22:52:33 -0400513 * @plane: Pointer to DRM plane object
514 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
515 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
516 *
517 * Returns: 0 on success
518 */
519int sde_plane_color_fill(struct drm_plane *plane,
520 uint32_t color, uint32_t alpha);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700521
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400522/**
523 * CRTC functions
524 */
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400525int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700526void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400527void sde_crtc_commit_kickoff(struct drm_crtc *crtc);
Clarence Ip24f80662016-06-13 19:05:32 -0400528
529/**
530 * sde_crtc_prepare_fence - callback to prepare for output fences
531 * @crtc: Pointer to drm crtc object
532 */
533void sde_crtc_prepare_fence(struct drm_crtc *crtc);
534
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400535/**
536 * sde_crtc_init - create a new crtc object
537 * @dev: sde device
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400538 * @plane: base plane
539 * @vblank_id: Id for reporting vblank. Id in range from 0..dev->num_crtcs.
540 * @Return: new crtc object or error
541 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700542struct drm_crtc *sde_crtc_init(struct drm_device *dev,
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400543 struct drm_plane *plane,
544 int vblank_id);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700545
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400546/**
Clarence Ip24f80662016-06-13 19:05:32 -0400547 * sde_crtc_complete_commit - callback signalling completion of current commit
548 * @crtc: Pointer to drm crtc object
549 */
550void sde_crtc_complete_commit(struct drm_crtc *crtc);
551
552/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400553 * sde_encoder_get_hw_resources - Populate table of required hardware resources
554 * @encoder: encoder pointer
555 * @hw_res: resource table to populate with encoder required resources
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400556 * @conn_state: report hw reqs based on this proposed connector state
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400557 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400558void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400559 struct sde_encoder_hw_resources *hw_res,
560 struct drm_connector_state *conn_state);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700561
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400562/**
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400563 * sde_encoder_needs_ctl_start - Get whether encoder type requires ctl_start
564 * CMD and WB encoders need ctl_start, video encs do not.
565 * @encoder: encoder pointer
566 * @Return: true if the encoder type requires ctl_start issued
567 */
568bool sde_encoder_needs_ctl_start(struct drm_encoder *encoder);
569
570/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400571 * sde_encoder_register_vblank_callback - provide callback to encoder that
572 * will be called on the next vblank.
573 * @encoder: encoder pointer
574 * @cb: callback pointer, provide NULL to deregister and disable IRQs
575 * @data: user data provided to callback
576 */
577void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
578 void (*cb)(void *), void *data);
579
580/**
581 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
582 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
583 * at the appropriate time.
584 * Immediately: if no previous commit is outstanding.
585 * Delayed: Save the callback, and return. Does not block. Callback will
586 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
587 * irq if it outstanding.
588 * Callback registered is expected to flush _all_ ctl paths of the crtc
589 * @encoder: encoder pointer
590 * @cb: callback pointer, provide NULL to deregister
591 * @data: user data provided to callback
592 */
593void sde_encoder_schedule_kickoff(struct drm_encoder *encoder,
594 void (*cb)(void *), void *data);
595
596/**
597 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
598 * current pending frames to hardware at a vblank or ctl_start
599 * Encoders will map this differently depending on irqs
600 * vid mode -> vsync_irq
601 * @encoder: encoder pointer
602 *
603 * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
604 */
605int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
606
607/**
Clarence Ip03521982016-08-26 10:49:47 -0400608 * sde_encoder_get_intf_mode - returns current underlying interface mode
609 * @encoder: encoder pointer
610 * Returns: Interface mode of underlying physical master encoder
611 */
612enum sde_intf_mode sde_encoder_get_intf_mode(struct drm_encoder *encoder);
613
614/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400615 * sde_encoders_init - query platform, create all encoders and bridges,
616 * and register them with the drm_device
617 * @dev: drm device pointer
618 */
619void sde_encoders_init(struct drm_device *dev);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700620
621#endif /* __sde_kms_H__ */