blob: 154edf3468b566e3671ca203f817aceda61c6901 [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"
18#include "mdp/mdp_kms.h"
19#include "sde_hw_catalog.h"
Clarence Ipc475b082016-06-26 09:27:23 -040020#include "sde_hw_ctl.h"
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040021#include "sde_hw_lm.h"
Ben Chan78647cd2016-06-26 22:02:47 -040022#include "sde_hw_interrupts.h"
23
Clarence Ip31c19b52016-06-10 15:42:08 -040024/**
25 * SDE_DEBUG - macro for kms/plane/crtc/encoder/connector logs
26 * @fmt: Pointer to format string
27 */
28#define SDE_DEBUG(fmt, ...) \
29 do { \
30 if (unlikely(drm_debug & DRM_UT_KMS)) \
31 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
32 else \
33 pr_debug(fmt, ##__VA_ARGS__); \
34 } while (0)
35
36/**
37 * SDE_DEBUG_DRIVER - macro for hardware driver logging
38 * @fmt: Pointer to format string
39 */
40#define SDE_DEBUG_DRIVER(fmt, ...) \
41 do { \
42 if (unlikely(drm_debug & DRM_UT_DRIVER)) \
43 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
44 else \
45 pr_debug(fmt, ##__VA_ARGS__); \
46 } while (0)
47
48#define SDE_ERROR(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
49
Ben Chan78647cd2016-06-26 22:02:47 -040050/*
51 * struct sde_irq_callback - IRQ callback handlers
52 * @func: intr handler
53 * @arg: argument for the handler
54 */
55struct sde_irq_callback {
56 void (*func)(void *arg, int irq_idx);
57 void *arg;
58};
59
60/**
61 * struct sde_irq: IRQ structure contains callback registration info
62 * @total_irq: total number of irq_idx obtained from HW interrupts mapping
63 * @irq_cb_tbl: array of IRQ callbacks setting
64 * @cb_lock: callback lock
65 */
66struct sde_irq {
67 u32 total_irqs;
68 struct sde_irq_callback *irq_cb_tbl;
69 spinlock_t cb_lock;
70};
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070071
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040072/**
73 * struct sde_hw_res_map : Default resource table identifying default
74 * hw resource map. Primarily used for forcing DSI to use CTL_0/1
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -040075 * and PingPong 0/1, if the field is set to SDE_NONE means any HW
76 * instance for that type is allowed as long as it is unused.
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040077 */
78struct sde_hw_res_map {
79 enum sde_intf intf;
80 enum sde_lm lm;
81 enum sde_pingpong pp;
82 enum sde_ctl ctl;
83};
84
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -040085/* struct sde_hw_resource_manager : Resource manager maintains the current
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -040086 * default platform config and manages shared
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040087 * hw resources ex:ctl_path hw driver context
88 * is needed by CRTCs/PLANEs/ENCODERs
89 * @ctl : table of control path hw driver contexts allocated
90 * @mixer : list of mixer hw drivers contexts allocated
91 * @intr : pointer to hw interrupt context
92 * @res_table : pointer to default hw_res table for this platform
93 * @feature_map :BIT map for default enabled features ex:specifies if PP_SPLIT
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -040094 * is enabled/disabled by default for this platform
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040095 */
96struct sde_hw_resource_manager {
97 struct sde_hw_ctl *ctl[CTL_MAX];
98 struct sde_hw_mixer *mixer[LM_MAX];
99 struct sde_hw_intr *intr;
100 const struct sde_hw_res_map *res_table;
101 bool feature_map;
102};
103
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700104struct sde_kms {
Ben Chan78647cd2016-06-26 22:02:47 -0400105 struct msm_kms base;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700106 struct drm_device *dev;
107 int rev;
108 struct sde_mdss_cfg *catalog;
109
110 struct msm_mmu *mmu;
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400111 int mmu_id;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700112
Clarence Ip4ce59322016-06-26 22:27:51 -0400113 /* directory entry for debugfs */
114 void *debugfs_root;
115
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700116 /* io/register spaces: */
117 void __iomem *mmio, *vbif;
118
119 struct regulator *vdd;
120 struct regulator *mmagic;
121 struct regulator *venus;
122
123 struct clk *axi_clk;
124 struct clk *ahb_clk;
125 struct clk *src_clk;
126 struct clk *core_clk;
127 struct clk *lut_clk;
128 struct clk *mmagic_clk;
129 struct clk *iommu_clk;
130 struct clk *vsync_clk;
131
132 struct {
133 unsigned long enabled_mask;
134 struct irq_domain *domain;
135 } irqcontroller;
Ben Chan78647cd2016-06-26 22:02:47 -0400136
137 struct sde_hw_intr *hw_intr;
138 struct sde_irq irq_obj;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400139 struct sde_hw_resource_manager hw_res;
Ben Chan78647cd2016-06-26 22:02:47 -0400140};
141
142struct vsync_info {
143 u32 frame_count;
144 u32 line_count;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700145};
146
147#define to_sde_kms(x) container_of(x, struct sde_kms, base)
148
149struct sde_plane_state {
150 struct drm_plane_state base;
151
152 /* aligned with property */
Clarence Ipe78efb72016-06-24 18:35:21 -0400153 uint64_t property_values[PLANE_PROP_COUNT];
154
155 /* blob properties */
156 struct drm_property_blob *property_blobs[PLANE_PROP_BLOBCOUNT];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700157
Clarence Ipcae1bb62016-07-07 12:07:13 -0400158 /* dereferenced input fence pointer */
159 void *input_fence;
Clarence Ipae4e60c2016-06-26 22:44:04 -0400160
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700161 /* assigned by crtc blender */
162 enum sde_stage stage;
163
164 /* some additional transactional status to help us know in the
165 * apply path whether we need to update SMP allocation, and
166 * whether current update is still pending:
167 */
168 bool mode_changed : 1;
169 bool pending : 1;
170};
171
172#define to_sde_plane_state(x) \
Clarence Ip4c1d9772016-06-26 09:35:38 -0400173 container_of(x, struct sde_plane_state, base)
174
175/**
176 * sde_plane_get_property - Query integer value of plane property
177 *
178 * @S: Pointer to plane state
179 * @X: Property index, from enum msm_mdp_plane_property
180 *
181 * Return: Integer value of requested property
182 */
183#define sde_plane_get_property(S, X) \
184 ((S) && ((X) < PLANE_PROP_COUNT) ? ((S)->property_values[(X)]) : 0)
185
186/**
187 * sde_plane_get_property32 - Query 32-bit representation of plane property
188 *
189 * @S: Pointer to plane state
190 * @X: Property index, from enum msm_mdp_plane_property
191 *
192 * Return: 32-bit value of requested property
193 */
194#define sde_plane_get_property32(S, X) \
195 ((S) && ((X) < PLANE_PROP_COUNT) ? \
196 (uint32_t)((S)->property_values[(X)]) : 0)
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700197
198int sde_disable(struct sde_kms *sde_kms);
199int sde_enable(struct sde_kms *sde_kms);
200
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/**
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400392 * HW resource manager functions
393 * @sde_rm_acquire_ctl_path : Allocates control path
394 * @sde_rm_get_ctl_path : returns control path driver context for already
395 * acquired ctl path
396 * @sde_rm_release_ctl_path : Frees control path driver context
397 * @sde_rm_acquire_mixer : Allocates mixer hw driver context
398 * @sde_rm_get_mixer : returns mixer context for already
399 * acquired mixer
400 * @sde_rm_release_mixer : Frees mixer hw driver context
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400401 * @sde_rm_acquire_intr : Allocate hw intr context
402 * @sde_rm_get_intr : Returns already acquired intr context
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400403 * @sde_rm_get_hw_res_map : Returns map for the passed INTF
404 */
405struct sde_hw_ctl *sde_rm_acquire_ctl_path(struct sde_kms *sde_kms,
406 enum sde_ctl idx);
407struct sde_hw_ctl *sde_rm_get_ctl_path(struct sde_kms *sde_kms,
408 enum sde_ctl idx);
409void sde_rm_release_ctl_path(struct sde_kms *sde_kms,
410 enum sde_ctl idx);
411struct sde_hw_mixer *sde_rm_acquire_mixer(struct sde_kms *sde_kms,
412 enum sde_lm idx);
413struct sde_hw_mixer *sde_rm_get_mixer(struct sde_kms *sde_kms,
414 enum sde_lm idx);
415void sde_rm_release_mixer(struct sde_kms *sde_kms,
416 enum sde_lm idx);
417struct sde_hw_intr *sde_rm_acquire_intr(struct sde_kms *sde_kms);
418struct sde_hw_intr *sde_rm_get_intr(struct sde_kms *sde_kms);
419
420const struct sde_hw_res_map *sde_rm_get_res_map(struct sde_kms *sde_kms,
421 enum sde_intf idx);
422
423/**
Ben Chan78647cd2016-06-26 22:02:47 -0400424 * IRQ functions
425 */
426int sde_irq_domain_init(struct sde_kms *sde_kms);
427int sde_irq_domain_fini(struct sde_kms *sde_kms);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700428void sde_irq_preinstall(struct msm_kms *kms);
429int sde_irq_postinstall(struct msm_kms *kms);
430void sde_irq_uninstall(struct msm_kms *kms);
431irqreturn_t sde_irq(struct msm_kms *kms);
Ben Chan78647cd2016-06-26 22:02:47 -0400432
433/**
434 * sde_set_irqmask - IRQ helper function for writing IRQ mask
435 * to SDE HW interrupt register.
436 * @sde_kms: SDE handle
437 * @reg_off: SDE HW interrupt register offset
438 * @irqmask: IRQ mask
439 */
440void sde_set_irqmask(
441 struct sde_kms *sde_kms,
442 uint32_t reg_off,
443 uint32_t irqmask);
444
445/**
446 * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
447 * interrupt mapping table.
448 * @sde_kms: SDE handle
449 * @intr_type: SDE HW interrupt type for lookup
450 * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
451 * @return: irq_idx or -EINVAL when fail to lookup
452 */
453int sde_irq_idx_lookup(
454 struct sde_kms *sde_kms,
455 enum sde_intr_type intr_type,
456 uint32_t instance_idx);
457
458/**
459 * sde_enable_irq - IRQ helper function for enabling one or more IRQs
460 * @sde_kms: SDE handle
461 * @irq_idxs: Array of irq index
462 * @irq_count: Number of irq_idx provided in the array
463 * @return: 0 for success enabling IRQ, otherwise failure
464 */
465int sde_enable_irq(
466 struct sde_kms *sde_kms,
467 int *irq_idxs,
468 uint32_t irq_count);
469
470/**
471 * sde_disable_irq - IRQ helper function for diabling one of more IRQs
472 * @sde_kms: SDE handle
473 * @irq_idxs: Array of irq index
474 * @irq_count: Number of irq_idx provided in the array
475 * @return: 0 for success disabling IRQ, otherwise failure
476 */
477int sde_disable_irq(
478 struct sde_kms *sde_kms,
479 int *irq_idxs,
480 uint32_t irq_count);
481
482/**
483 * sde_register_irq_callback - For registering callback function on IRQ
484 * interrupt
485 * @sde_kms: SDE handle
486 * @irq_idx: irq index
487 * @irq_cb: IRQ callback structure, containing callback function
488 * and argument. Passing NULL for irq_cb will unregister
489 * the callback for the given irq_idx
490 * @return: 0 for success registering callback, otherwise failure
491 */
492int sde_register_irq_callback(
493 struct sde_kms *sde_kms,
494 int irq_idx,
495 struct sde_irq_callback *irq_cb);
496
497/**
498 * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
499 * @sde_kms: SDE handle
500 */
501void sde_clear_all_irqs(struct sde_kms *sde_kms);
502
503/**
504 * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
505 * @sde_kms: SDE handle
506 */
507void sde_disable_all_irqs(struct sde_kms *sde_kms);
508
509/**
510 * Vblank enable/disable functions
511 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700512int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
513void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
514
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400515/**
516 * Plane functions
517 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700518enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
Clarence Ipcae1bb62016-07-07 12:07:13 -0400519void sde_plane_flush(struct drm_plane *plane);
Clarence Ipdbde9832016-06-26 09:48:36 -0400520struct drm_plane *sde_plane_init(struct drm_device *dev,
521 uint32_t pipe, bool primary_plane);
Clarence Ip7a753bb2016-07-07 11:47:44 -0400522
523/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400524 * sde_plane_wait_input_fence - wait for input fence object
Clarence Ip7a753bb2016-07-07 11:47:44 -0400525 * @plane: Pointer to DRM plane object
526 * @wait_ms: Wait timeout value
527 * Returns: Zero on success
528 */
Clarence Ipcae1bb62016-07-07 12:07:13 -0400529int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
Clarence Ipcb410d42016-06-26 22:52:33 -0400530
531/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400532 * sde_plane_color_fill - Enables color fill on plane
Clarence Ipcb410d42016-06-26 22:52:33 -0400533 * @plane: Pointer to DRM plane object
534 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
535 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
536 *
537 * Returns: 0 on success
538 */
539int sde_plane_color_fill(struct drm_plane *plane,
540 uint32_t color, uint32_t alpha);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700541
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400542/**
543 * CRTC functions
544 */
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400545int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400546void sde_crtc_wait_for_commit_done(struct drm_crtc *crtc);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700547void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400548void sde_crtc_commit_kickoff(struct drm_crtc *crtc);
Clarence Ip24f80662016-06-13 19:05:32 -0400549
550/**
551 * sde_crtc_prepare_fence - callback to prepare for output fences
552 * @crtc: Pointer to drm crtc object
553 */
554void sde_crtc_prepare_fence(struct drm_crtc *crtc);
555
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700556struct drm_crtc *sde_crtc_init(struct drm_device *dev,
557 struct drm_encoder *encoder,
558 struct drm_plane *plane, int id);
559
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400560/**
Clarence Ip24f80662016-06-13 19:05:32 -0400561 * sde_crtc_complete_commit - callback signalling completion of current commit
562 * @crtc: Pointer to drm crtc object
563 */
564void sde_crtc_complete_commit(struct drm_crtc *crtc);
565
566/**
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400567 * Encoder functions and data types
568 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400569struct sde_encoder_hw_resources {
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400570 enum sde_intf_mode intfs[INTF_MAX];
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400571 bool pingpongs[PINGPONG_MAX];
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400572 bool ctls[CTL_MAX];
573 bool pingpongsplit;
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400574};
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400575
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400576/**
577 * sde_encoder_get_hw_resources - Populate table of required hardware resources
578 * @encoder: encoder pointer
579 * @hw_res: resource table to populate with encoder required resources
580 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400581void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
582 struct sde_encoder_hw_resources *hw_res);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700583
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400584/**
585 * sde_encoder_register_vblank_callback - provide callback to encoder that
586 * will be called on the next vblank.
587 * @encoder: encoder pointer
588 * @cb: callback pointer, provide NULL to deregister and disable IRQs
589 * @data: user data provided to callback
590 */
591void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
592 void (*cb)(void *), void *data);
593
594/**
595 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
596 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
597 * at the appropriate time.
598 * Immediately: if no previous commit is outstanding.
599 * Delayed: Save the callback, and return. Does not block. Callback will
600 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
601 * irq if it outstanding.
602 * Callback registered is expected to flush _all_ ctl paths of the crtc
603 * @encoder: encoder pointer
604 * @cb: callback pointer, provide NULL to deregister
605 * @data: user data provided to callback
606 */
607void sde_encoder_schedule_kickoff(struct drm_encoder *encoder,
608 void (*cb)(void *), void *data);
609
610/**
611 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
612 * current pending frames to hardware at a vblank or ctl_start
613 * Encoders will map this differently depending on irqs
614 * vid mode -> vsync_irq
615 * @encoder: encoder pointer
616 *
617 * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
618 */
619int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
620
621/**
622 * sde_encoders_init - query platform, create all encoders and bridges,
623 * and register them with the drm_device
624 * @dev: drm device pointer
625 */
626void sde_encoders_init(struct drm_device *dev);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700627
628#endif /* __sde_kms_H__ */