blob: cc47cdc2ce225815a5c940696740185f4e148023 [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"
Clarence Ipe59fb3f2016-07-26 13:39:59 -040024#include "sde_connector.h"
Ben Chan78647cd2016-06-26 22:02:47 -040025
Clarence Ip31c19b52016-06-10 15:42:08 -040026/**
27 * SDE_DEBUG - macro for kms/plane/crtc/encoder/connector logs
28 * @fmt: Pointer to format string
29 */
30#define SDE_DEBUG(fmt, ...) \
31 do { \
32 if (unlikely(drm_debug & DRM_UT_KMS)) \
33 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
34 else \
35 pr_debug(fmt, ##__VA_ARGS__); \
36 } while (0)
37
38/**
39 * SDE_DEBUG_DRIVER - macro for hardware driver logging
40 * @fmt: Pointer to format string
41 */
42#define SDE_DEBUG_DRIVER(fmt, ...) \
43 do { \
44 if (unlikely(drm_debug & DRM_UT_DRIVER)) \
45 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
46 else \
47 pr_debug(fmt, ##__VA_ARGS__); \
48 } while (0)
49
50#define SDE_ERROR(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
51
Ben Chan78647cd2016-06-26 22:02:47 -040052/*
53 * struct sde_irq_callback - IRQ callback handlers
54 * @func: intr handler
55 * @arg: argument for the handler
56 */
57struct sde_irq_callback {
58 void (*func)(void *arg, int irq_idx);
59 void *arg;
60};
61
62/**
63 * struct sde_irq: IRQ structure contains callback registration info
64 * @total_irq: total number of irq_idx obtained from HW interrupts mapping
65 * @irq_cb_tbl: array of IRQ callbacks setting
66 * @cb_lock: callback lock
67 */
68struct sde_irq {
69 u32 total_irqs;
70 struct sde_irq_callback *irq_cb_tbl;
71 spinlock_t cb_lock;
72};
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070073
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040074/**
75 * struct sde_hw_res_map : Default resource table identifying default
76 * hw resource map. Primarily used for forcing DSI to use CTL_0/1
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -040077 * and PingPong 0/1, if the field is set to SDE_NONE means any HW
78 * instance for that type is allowed as long as it is unused.
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040079 */
80struct sde_hw_res_map {
81 enum sde_intf intf;
82 enum sde_lm lm;
83 enum sde_pingpong pp;
84 enum sde_ctl ctl;
85};
86
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -040087/* struct sde_hw_resource_manager : Resource manager maintains the current
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -040088 * default platform config and manages shared
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040089 * hw resources ex:ctl_path hw driver context
90 * is needed by CRTCs/PLANEs/ENCODERs
91 * @ctl : table of control path hw driver contexts allocated
92 * @mixer : list of mixer hw drivers contexts allocated
93 * @intr : pointer to hw interrupt context
94 * @res_table : pointer to default hw_res table for this platform
95 * @feature_map :BIT map for default enabled features ex:specifies if PP_SPLIT
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -040096 * is enabled/disabled by default for this platform
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040097 */
98struct sde_hw_resource_manager {
99 struct sde_hw_ctl *ctl[CTL_MAX];
100 struct sde_hw_mixer *mixer[LM_MAX];
101 struct sde_hw_intr *intr;
102 const struct sde_hw_res_map *res_table;
103 bool feature_map;
104};
105
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700106struct sde_kms {
Ben Chan78647cd2016-06-26 22:02:47 -0400107 struct msm_kms base;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700108 struct drm_device *dev;
109 int rev;
110 struct sde_mdss_cfg *catalog;
111
Alan Kwong112a84f2016-05-24 20:49:21 -0400112 struct msm_mmu *mmu[MSM_SMMU_DOMAIN_MAX];
113 int mmu_id[MSM_SMMU_DOMAIN_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700114
Clarence Ip4ce59322016-06-26 22:27:51 -0400115 /* directory entry for debugfs */
116 void *debugfs_root;
117
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700118 /* io/register spaces: */
119 void __iomem *mmio, *vbif;
120
121 struct regulator *vdd;
122 struct regulator *mmagic;
123 struct regulator *venus;
124
125 struct clk *axi_clk;
126 struct clk *ahb_clk;
127 struct clk *src_clk;
128 struct clk *core_clk;
129 struct clk *lut_clk;
130 struct clk *mmagic_clk;
Alan Kwong112a84f2016-05-24 20:49:21 -0400131 struct clk *iommu_axi_clk[MSM_SMMU_DOMAIN_MAX];
132 struct clk *iommu_ahb_clk[MSM_SMMU_DOMAIN_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700133 struct clk *vsync_clk;
134
135 struct {
136 unsigned long enabled_mask;
137 struct irq_domain *domain;
138 } irqcontroller;
Ben Chan78647cd2016-06-26 22:02:47 -0400139
140 struct sde_hw_intr *hw_intr;
141 struct sde_irq irq_obj;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400142 struct sde_hw_resource_manager hw_res;
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
201int sde_disable(struct sde_kms *sde_kms);
202int sde_enable(struct sde_kms *sde_kms);
203
Ben Chan78647cd2016-06-26 22:02:47 -0400204/**
Clarence Ip4ce59322016-06-26 22:27:51 -0400205 * Debugfs functions - extra helper functions for debugfs support
206 *
207 * Main debugfs documentation is located at,
208 *
209 * Documentation/filesystems/debugfs.txt
210 *
211 * @sde_debugfs_setup_regset32: Initialize data for sde_debugfs_create_regset32
212 * @sde_debugfs_create_regset32: Create 32-bit register dump file
213 * @sde_debugfs_get_root: Get root dentry for SDE_KMS's debugfs node
214 */
215
216/**
217 * Companion structure for sde_debugfs_create_regset32. Do not initialize the
218 * members of this structure explicitly; use sde_debugfs_setup_regset32 instead.
219 */
220struct sde_debugfs_regset32 {
221 uint32_t offset;
222 uint32_t blk_len;
223 void __iomem *base;
224};
225
226/**
227 * sde_debugfs_setup_regset32 - Initialize register block definition for debugfs
228 * This function is meant to initialize sde_debugfs_regset32 structures for use
229 * with sde_debugfs_create_regset32.
230 * @regset: opaque register definition structure
231 * @offset: sub-block offset
232 * @length: sub-block length, in bytes
233 * @base: base IOMEM address
234 */
235void sde_debugfs_setup_regset32(struct sde_debugfs_regset32 *regset,
236 uint32_t offset, uint32_t length, void __iomem *base);
237
238/**
239 * sde_debugfs_create_regset32 - Create register read back file for debugfs
240 *
241 * This function is almost identical to the standard debugfs_create_regset32()
242 * function, with the main difference being that a list of register
243 * names/offsets do not need to be provided. The 'read' function simply outputs
244 * sequential register values over a specified range.
245 *
246 * Similar to the related debugfs_create_regset32 API, the structure pointed to
247 * by regset needs to persist for the lifetime of the created file. The calling
248 * code is responsible for initialization/management of this structure.
249 *
250 * The structure pointed to by regset is meant to be opaque. Please use
251 * sde_debugfs_setup_regset32 to initialize it.
252 *
253 * @name: File name within debugfs
254 * @mode: File mode within debugfs
255 * @parent: Parent directory entry within debugfs, can be NULL
256 * @regset: Pointer to persistent register block definition
257 *
258 * Return: dentry pointer for newly created file, use either debugfs_remove()
259 * or debugfs_remove_recursive() (on a parent directory) to remove the
260 * file
261 */
262void *sde_debugfs_create_regset32(const char *name, umode_t mode,
263 void *parent, struct sde_debugfs_regset32 *regset);
264
265/**
266 * sde_debugfs_get_root - Return root directory entry for SDE's debugfs
267 *
268 * The return value should be passed as the 'parent' argument to subsequent
269 * debugfs create calls.
270 *
271 * @sde_kms: Pointer to SDE's KMS structure
272 *
273 * Return: dentry pointer for SDE's debugfs location
274 */
275void *sde_debugfs_get_root(struct sde_kms *sde_kms);
276
277/**
Clarence Ipb218a3c2016-07-15 14:17:42 -0400278 * SDE info management functions
279 * These functions/definitions allow for building up a 'sde_info' structure
280 * containing one or more "key=value\n" entries.
281 */
282#define SDE_KMS_INFO_MAX_SIZE 4096
283
284/**
285 * struct sde_kms_info - connector information structure container
286 * @data: Array of information character data
287 * @len: Current length of information data
288 * @staged_len: Temporary data buffer length, commit to
289 * len using sde_kms_info_stop
290 * @start: Whether or not a partial data entry was just started
291 */
292struct sde_kms_info {
293 char data[SDE_KMS_INFO_MAX_SIZE];
294 uint32_t len;
295 uint32_t staged_len;
296 bool start;
297};
298
299/**
300 * SDE_KMS_INFO_DATA - Macro for accessing sde_kms_info data bytes
301 * @S: Pointer to sde_kms_info structure
302 * Returns: Pointer to byte data
303 */
304#define SDE_KMS_INFO_DATA(S) ((S) ? ((struct sde_kms_info *)(S))->data : 0)
305
306/**
307 * SDE_KMS_INFO_DATALEN - Macro for accessing sde_kms_info data length
308 * @S: Pointer to sde_kms_info structure
309 * Returns: Size of available byte data
310 */
311#define SDE_KMS_INFO_DATALEN(S) ((S) ? ((struct sde_kms_info *)(S))->len : 0)
312
313/**
314 * sde_kms_info_reset - reset sde_kms_info structure
315 * @info: Pointer to sde_kms_info structure
316 */
317void sde_kms_info_reset(struct sde_kms_info *info);
318
319/**
320 * sde_kms_info_add_keyint - add integer value to 'sde_kms_info'
321 * @info: Pointer to sde_kms_info structure
322 * @key: Pointer to key string
323 * @value: Signed 32-bit integer value
324 */
325void sde_kms_info_add_keyint(struct sde_kms_info *info,
326 const char *key,
327 int32_t value);
328
329/**
330 * sde_kms_info_add_keystr - add string value to 'sde_kms_info'
331 * @info: Pointer to sde_kms_info structure
332 * @key: Pointer to key string
333 * @value: Pointer to string value
334 */
335void sde_kms_info_add_keystr(struct sde_kms_info *info,
336 const char *key,
337 const char *value);
338
339/**
340 * sde_kms_info_start - begin adding key to 'sde_kms_info'
341 * Usage:
342 * sde_kms_info_start(key)
343 * sde_kms_info_append(val_1)
344 * ...
345 * sde_kms_info_append(val_n)
346 * sde_kms_info_stop
347 * @info: Pointer to sde_kms_info structure
348 * @key: Pointer to key string
349 */
350void sde_kms_info_start(struct sde_kms_info *info,
351 const char *key);
352
353/**
354 * sde_kms_info_append - append value string to 'sde_kms_info'
355 * Usage:
356 * sde_kms_info_start(key)
357 * sde_kms_info_append(val_1)
358 * ...
359 * sde_kms_info_append(val_n)
360 * sde_kms_info_stop
361 * @info: Pointer to sde_kms_info structure
362 * @str: Pointer to partial value string
363 */
364void sde_kms_info_append(struct sde_kms_info *info,
365 const char *str);
366
367/**
368 * sde_kms_info_append_format - append format code string to 'sde_kms_info'
369 * Usage:
370 * sde_kms_info_start(key)
371 * sde_kms_info_append_format(fourcc, modifier)
372 * ...
373 * sde_kms_info_stop
374 * @info: Pointer to sde_kms_info structure
375 * @pixel_format: FOURCC format code
376 * @modifier: 64-bit drm format modifier
377 */
378void sde_kms_info_append_format(struct sde_kms_info *info,
379 uint32_t pixel_format,
380 uint64_t modifier);
381
382/**
383 * sde_kms_info_stop - finish adding key to 'sde_kms_info'
384 * Usage:
385 * sde_kms_info_start(key)
386 * sde_kms_info_append(val_1)
387 * ...
388 * sde_kms_info_append(val_n)
389 * sde_kms_info_stop
390 * @info: Pointer to sde_kms_info structure
391 */
392void sde_kms_info_stop(struct sde_kms_info *info);
393
394/**
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400395 * HW resource manager functions
396 * @sde_rm_acquire_ctl_path : Allocates control path
397 * @sde_rm_get_ctl_path : returns control path driver context for already
398 * acquired ctl path
399 * @sde_rm_release_ctl_path : Frees control path driver context
400 * @sde_rm_acquire_mixer : Allocates mixer hw driver context
401 * @sde_rm_get_mixer : returns mixer context for already
402 * acquired mixer
403 * @sde_rm_release_mixer : Frees mixer hw driver context
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400404 * @sde_rm_acquire_intr : Allocate hw intr context
405 * @sde_rm_get_intr : Returns already acquired intr context
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400406 * @sde_rm_get_hw_res_map : Returns map for the passed INTF
407 */
408struct sde_hw_ctl *sde_rm_acquire_ctl_path(struct sde_kms *sde_kms,
409 enum sde_ctl idx);
410struct sde_hw_ctl *sde_rm_get_ctl_path(struct sde_kms *sde_kms,
411 enum sde_ctl idx);
412void sde_rm_release_ctl_path(struct sde_kms *sde_kms,
413 enum sde_ctl idx);
414struct sde_hw_mixer *sde_rm_acquire_mixer(struct sde_kms *sde_kms,
415 enum sde_lm idx);
416struct sde_hw_mixer *sde_rm_get_mixer(struct sde_kms *sde_kms,
417 enum sde_lm idx);
418void sde_rm_release_mixer(struct sde_kms *sde_kms,
419 enum sde_lm idx);
420struct sde_hw_intr *sde_rm_acquire_intr(struct sde_kms *sde_kms);
421struct sde_hw_intr *sde_rm_get_intr(struct sde_kms *sde_kms);
422
423const struct sde_hw_res_map *sde_rm_get_res_map(struct sde_kms *sde_kms,
424 enum sde_intf idx);
425
426/**
Ben Chan78647cd2016-06-26 22:02:47 -0400427 * IRQ functions
428 */
429int sde_irq_domain_init(struct sde_kms *sde_kms);
430int sde_irq_domain_fini(struct sde_kms *sde_kms);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700431void sde_irq_preinstall(struct msm_kms *kms);
432int sde_irq_postinstall(struct msm_kms *kms);
433void sde_irq_uninstall(struct msm_kms *kms);
434irqreturn_t sde_irq(struct msm_kms *kms);
Ben Chan78647cd2016-06-26 22:02:47 -0400435
436/**
437 * sde_set_irqmask - IRQ helper function for writing IRQ mask
438 * to SDE HW interrupt register.
439 * @sde_kms: SDE handle
440 * @reg_off: SDE HW interrupt register offset
441 * @irqmask: IRQ mask
442 */
443void sde_set_irqmask(
444 struct sde_kms *sde_kms,
445 uint32_t reg_off,
446 uint32_t irqmask);
447
448/**
449 * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
450 * interrupt mapping table.
451 * @sde_kms: SDE handle
452 * @intr_type: SDE HW interrupt type for lookup
453 * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
454 * @return: irq_idx or -EINVAL when fail to lookup
455 */
456int sde_irq_idx_lookup(
457 struct sde_kms *sde_kms,
458 enum sde_intr_type intr_type,
459 uint32_t instance_idx);
460
461/**
462 * sde_enable_irq - IRQ helper function for enabling one or more IRQs
463 * @sde_kms: SDE handle
464 * @irq_idxs: Array of irq index
465 * @irq_count: Number of irq_idx provided in the array
466 * @return: 0 for success enabling IRQ, otherwise failure
467 */
468int sde_enable_irq(
469 struct sde_kms *sde_kms,
470 int *irq_idxs,
471 uint32_t irq_count);
472
473/**
474 * sde_disable_irq - IRQ helper function for diabling one of more IRQs
475 * @sde_kms: SDE handle
476 * @irq_idxs: Array of irq index
477 * @irq_count: Number of irq_idx provided in the array
478 * @return: 0 for success disabling IRQ, otherwise failure
479 */
480int sde_disable_irq(
481 struct sde_kms *sde_kms,
482 int *irq_idxs,
483 uint32_t irq_count);
484
485/**
486 * sde_register_irq_callback - For registering callback function on IRQ
487 * interrupt
488 * @sde_kms: SDE handle
489 * @irq_idx: irq index
490 * @irq_cb: IRQ callback structure, containing callback function
491 * and argument. Passing NULL for irq_cb will unregister
492 * the callback for the given irq_idx
493 * @return: 0 for success registering callback, otherwise failure
494 */
495int sde_register_irq_callback(
496 struct sde_kms *sde_kms,
497 int irq_idx,
498 struct sde_irq_callback *irq_cb);
499
500/**
501 * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
502 * @sde_kms: SDE handle
503 */
504void sde_clear_all_irqs(struct sde_kms *sde_kms);
505
506/**
507 * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
508 * @sde_kms: SDE handle
509 */
510void sde_disable_all_irqs(struct sde_kms *sde_kms);
511
512/**
513 * Vblank enable/disable functions
514 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700515int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
516void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
517
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400518/**
519 * Plane functions
520 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700521enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
Clarence Ipcae1bb62016-07-07 12:07:13 -0400522void sde_plane_flush(struct drm_plane *plane);
Clarence Ipdbde9832016-06-26 09:48:36 -0400523struct drm_plane *sde_plane_init(struct drm_device *dev,
524 uint32_t pipe, bool primary_plane);
Clarence Ip7a753bb2016-07-07 11:47:44 -0400525
526/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400527 * sde_plane_wait_input_fence - wait for input fence object
Clarence Ip7a753bb2016-07-07 11:47:44 -0400528 * @plane: Pointer to DRM plane object
529 * @wait_ms: Wait timeout value
530 * Returns: Zero on success
531 */
Clarence Ipcae1bb62016-07-07 12:07:13 -0400532int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
Clarence Ipcb410d42016-06-26 22:52:33 -0400533
534/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400535 * sde_plane_color_fill - Enables color fill on plane
Clarence Ipcb410d42016-06-26 22:52:33 -0400536 * @plane: Pointer to DRM plane object
537 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
538 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
539 *
540 * Returns: 0 on success
541 */
542int sde_plane_color_fill(struct drm_plane *plane,
543 uint32_t color, uint32_t alpha);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700544
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400545/**
546 * CRTC functions
547 */
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400548int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400549void sde_crtc_wait_for_commit_done(struct drm_crtc *crtc);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700550void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400551void sde_crtc_commit_kickoff(struct drm_crtc *crtc);
Clarence Ip24f80662016-06-13 19:05:32 -0400552
553/**
554 * sde_crtc_prepare_fence - callback to prepare for output fences
555 * @crtc: Pointer to drm crtc object
556 */
557void sde_crtc_prepare_fence(struct drm_crtc *crtc);
558
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700559struct drm_crtc *sde_crtc_init(struct drm_device *dev,
560 struct drm_encoder *encoder,
561 struct drm_plane *plane, int id);
562
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400563/**
Clarence Ip24f80662016-06-13 19:05:32 -0400564 * sde_crtc_complete_commit - callback signalling completion of current commit
565 * @crtc: Pointer to drm crtc object
566 */
567void sde_crtc_complete_commit(struct drm_crtc *crtc);
568
569/**
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400570 * Encoder functions and data types
571 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400572struct sde_encoder_hw_resources {
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400573 enum sde_intf_mode intfs[INTF_MAX];
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400574 bool pingpongs[PINGPONG_MAX];
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400575 bool ctls[CTL_MAX];
576 bool pingpongsplit;
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400577};
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400578
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400579/**
580 * sde_encoder_get_hw_resources - Populate table of required hardware resources
581 * @encoder: encoder pointer
582 * @hw_res: resource table to populate with encoder required resources
583 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400584void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
585 struct sde_encoder_hw_resources *hw_res);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700586
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400587/**
588 * sde_encoder_register_vblank_callback - provide callback to encoder that
589 * will be called on the next vblank.
590 * @encoder: encoder pointer
591 * @cb: callback pointer, provide NULL to deregister and disable IRQs
592 * @data: user data provided to callback
593 */
594void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
595 void (*cb)(void *), void *data);
596
597/**
598 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
599 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
600 * at the appropriate time.
601 * Immediately: if no previous commit is outstanding.
602 * Delayed: Save the callback, and return. Does not block. Callback will
603 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
604 * irq if it outstanding.
605 * Callback registered is expected to flush _all_ ctl paths of the crtc
606 * @encoder: encoder pointer
607 * @cb: callback pointer, provide NULL to deregister
608 * @data: user data provided to callback
609 */
610void sde_encoder_schedule_kickoff(struct drm_encoder *encoder,
611 void (*cb)(void *), void *data);
612
613/**
614 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
615 * current pending frames to hardware at a vblank or ctl_start
616 * Encoders will map this differently depending on irqs
617 * vid mode -> vsync_irq
618 * @encoder: encoder pointer
619 *
620 * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
621 */
622int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
623
624/**
625 * sde_encoders_init - query platform, create all encoders and bridges,
626 * and register them with the drm_device
627 * @dev: drm device pointer
628 */
629void sde_encoders_init(struct drm_device *dev);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700630
631#endif /* __sde_kms_H__ */