blob: f465fef0a6cba2b41134d70c3712d90f1da1648f [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"
Ben Chan78647cd2016-06-26 22:02:47 -040027
Clarence Ip31c19b52016-06-10 15:42:08 -040028/**
29 * SDE_DEBUG - macro for kms/plane/crtc/encoder/connector logs
30 * @fmt: Pointer to format string
31 */
32#define SDE_DEBUG(fmt, ...) \
33 do { \
34 if (unlikely(drm_debug & DRM_UT_KMS)) \
35 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
36 else \
37 pr_debug(fmt, ##__VA_ARGS__); \
38 } while (0)
39
40/**
41 * SDE_DEBUG_DRIVER - macro for hardware driver logging
42 * @fmt: Pointer to format string
43 */
44#define SDE_DEBUG_DRIVER(fmt, ...) \
45 do { \
46 if (unlikely(drm_debug & DRM_UT_DRIVER)) \
47 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
48 else \
49 pr_debug(fmt, ##__VA_ARGS__); \
50 } while (0)
51
52#define SDE_ERROR(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
53
Ben Chan78647cd2016-06-26 22:02:47 -040054/*
55 * struct sde_irq_callback - IRQ callback handlers
56 * @func: intr handler
57 * @arg: argument for the handler
58 */
59struct sde_irq_callback {
60 void (*func)(void *arg, int irq_idx);
61 void *arg;
62};
63
64/**
65 * struct sde_irq: IRQ structure contains callback registration info
66 * @total_irq: total number of irq_idx obtained from HW interrupts mapping
67 * @irq_cb_tbl: array of IRQ callbacks setting
68 * @cb_lock: callback lock
69 */
70struct sde_irq {
71 u32 total_irqs;
72 struct sde_irq_callback *irq_cb_tbl;
73 spinlock_t cb_lock;
74};
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070075
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040076/**
77 * struct sde_hw_res_map : Default resource table identifying default
78 * hw resource map. Primarily used for forcing DSI to use CTL_0/1
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -040079 * and PingPong 0/1, if the field is set to SDE_NONE means any HW
80 * instance for that type is allowed as long as it is unused.
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040081 */
82struct sde_hw_res_map {
83 enum sde_intf intf;
Alan Kwongd21960f2016-07-29 03:33:17 -040084 enum sde_wb wb;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040085 enum sde_lm lm;
86 enum sde_pingpong pp;
87 enum sde_ctl ctl;
Alan Kwongd21960f2016-07-29 03:33:17 -040088 enum sde_cdm cdm;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040089};
90
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -040091/* struct sde_hw_resource_manager : Resource manager maintains the current
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -040092 * default platform config and manages shared
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040093 * hw resources ex:ctl_path hw driver context
94 * is needed by CRTCs/PLANEs/ENCODERs
95 * @ctl : table of control path hw driver contexts allocated
Alan Kwongd21960f2016-07-29 03:33:17 -040096 * @cdm : table of chroma down path hw driver contexts allocated
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040097 * @mixer : list of mixer hw drivers contexts allocated
98 * @intr : pointer to hw interrupt context
99 * @res_table : pointer to default hw_res table for this platform
100 * @feature_map :BIT map for default enabled features ex:specifies if PP_SPLIT
Lloyd Atkinsone5c2c0b2016-07-05 12:23:29 -0400101 * is enabled/disabled by default for this platform
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400102 */
103struct sde_hw_resource_manager {
104 struct sde_hw_ctl *ctl[CTL_MAX];
Alan Kwongd21960f2016-07-29 03:33:17 -0400105 struct sde_hw_cdm *cdm[CDM_MAX];
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400106 struct sde_hw_mixer *mixer[LM_MAX];
107 struct sde_hw_intr *intr;
108 const struct sde_hw_res_map *res_table;
109 bool feature_map;
110};
111
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700112struct sde_kms {
Ben Chan78647cd2016-06-26 22:02:47 -0400113 struct msm_kms base;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700114 struct drm_device *dev;
115 int rev;
116 struct sde_mdss_cfg *catalog;
117
Alan Kwong112a84f2016-05-24 20:49:21 -0400118 struct msm_mmu *mmu[MSM_SMMU_DOMAIN_MAX];
119 int mmu_id[MSM_SMMU_DOMAIN_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700120
Clarence Ip4ce59322016-06-26 22:27:51 -0400121 /* directory entry for debugfs */
122 void *debugfs_root;
123
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700124 /* io/register spaces: */
Alan Kwongdfa8c082016-07-29 04:10:00 -0400125 void __iomem *mmio, *vbif[VBIF_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700126
127 struct regulator *vdd;
128 struct regulator *mmagic;
129 struct regulator *venus;
130
131 struct clk *axi_clk;
132 struct clk *ahb_clk;
133 struct clk *src_clk;
134 struct clk *core_clk;
135 struct clk *lut_clk;
136 struct clk *mmagic_clk;
Alan Kwong112a84f2016-05-24 20:49:21 -0400137 struct clk *iommu_axi_clk[MSM_SMMU_DOMAIN_MAX];
138 struct clk *iommu_ahb_clk[MSM_SMMU_DOMAIN_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700139 struct clk *vsync_clk;
140
141 struct {
142 unsigned long enabled_mask;
143 struct irq_domain *domain;
144 } irqcontroller;
Ben Chan78647cd2016-06-26 22:02:47 -0400145
146 struct sde_hw_intr *hw_intr;
147 struct sde_irq irq_obj;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400148 struct sde_hw_resource_manager hw_res;
Ben Chan78647cd2016-06-26 22:02:47 -0400149};
150
151struct vsync_info {
152 u32 frame_count;
153 u32 line_count;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700154};
155
156#define to_sde_kms(x) container_of(x, struct sde_kms, base)
157
158struct sde_plane_state {
159 struct drm_plane_state base;
160
161 /* aligned with property */
Clarence Ipe78efb72016-06-24 18:35:21 -0400162 uint64_t property_values[PLANE_PROP_COUNT];
163
164 /* blob properties */
165 struct drm_property_blob *property_blobs[PLANE_PROP_BLOBCOUNT];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700166
Clarence Ipcae1bb62016-07-07 12:07:13 -0400167 /* dereferenced input fence pointer */
168 void *input_fence;
Clarence Ipae4e60c2016-06-26 22:44:04 -0400169
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700170 /* assigned by crtc blender */
171 enum sde_stage stage;
172
173 /* some additional transactional status to help us know in the
174 * apply path whether we need to update SMP allocation, and
175 * whether current update is still pending:
176 */
177 bool mode_changed : 1;
178 bool pending : 1;
179};
180
181#define to_sde_plane_state(x) \
Clarence Ip4c1d9772016-06-26 09:35:38 -0400182 container_of(x, struct sde_plane_state, base)
183
184/**
185 * sde_plane_get_property - Query integer value of plane property
186 *
187 * @S: Pointer to plane state
188 * @X: Property index, from enum msm_mdp_plane_property
189 *
190 * Return: Integer value of requested property
191 */
192#define sde_plane_get_property(S, X) \
193 ((S) && ((X) < PLANE_PROP_COUNT) ? ((S)->property_values[(X)]) : 0)
194
195/**
196 * sde_plane_get_property32 - Query 32-bit representation of plane property
197 *
198 * @S: Pointer to plane state
199 * @X: Property index, from enum msm_mdp_plane_property
200 *
201 * Return: 32-bit value of requested property
202 */
203#define sde_plane_get_property32(S, X) \
204 ((S) && ((X) < PLANE_PROP_COUNT) ? \
205 (uint32_t)((S)->property_values[(X)]) : 0)
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700206
207int sde_disable(struct sde_kms *sde_kms);
208int sde_enable(struct sde_kms *sde_kms);
209
Ben Chan78647cd2016-06-26 22:02:47 -0400210/**
Clarence Ip4ce59322016-06-26 22:27:51 -0400211 * Debugfs functions - extra helper functions for debugfs support
212 *
213 * Main debugfs documentation is located at,
214 *
215 * Documentation/filesystems/debugfs.txt
216 *
217 * @sde_debugfs_setup_regset32: Initialize data for sde_debugfs_create_regset32
218 * @sde_debugfs_create_regset32: Create 32-bit register dump file
219 * @sde_debugfs_get_root: Get root dentry for SDE_KMS's debugfs node
220 */
221
222/**
223 * Companion structure for sde_debugfs_create_regset32. Do not initialize the
224 * members of this structure explicitly; use sde_debugfs_setup_regset32 instead.
225 */
226struct sde_debugfs_regset32 {
227 uint32_t offset;
228 uint32_t blk_len;
229 void __iomem *base;
230};
231
232/**
233 * sde_debugfs_setup_regset32 - Initialize register block definition for debugfs
234 * This function is meant to initialize sde_debugfs_regset32 structures for use
235 * with sde_debugfs_create_regset32.
236 * @regset: opaque register definition structure
237 * @offset: sub-block offset
238 * @length: sub-block length, in bytes
239 * @base: base IOMEM address
240 */
241void sde_debugfs_setup_regset32(struct sde_debugfs_regset32 *regset,
242 uint32_t offset, uint32_t length, void __iomem *base);
243
244/**
245 * sde_debugfs_create_regset32 - Create register read back file for debugfs
246 *
247 * This function is almost identical to the standard debugfs_create_regset32()
248 * function, with the main difference being that a list of register
249 * names/offsets do not need to be provided. The 'read' function simply outputs
250 * sequential register values over a specified range.
251 *
252 * Similar to the related debugfs_create_regset32 API, the structure pointed to
253 * by regset needs to persist for the lifetime of the created file. The calling
254 * code is responsible for initialization/management of this structure.
255 *
256 * The structure pointed to by regset is meant to be opaque. Please use
257 * sde_debugfs_setup_regset32 to initialize it.
258 *
259 * @name: File name within debugfs
260 * @mode: File mode within debugfs
261 * @parent: Parent directory entry within debugfs, can be NULL
262 * @regset: Pointer to persistent register block definition
263 *
264 * Return: dentry pointer for newly created file, use either debugfs_remove()
265 * or debugfs_remove_recursive() (on a parent directory) to remove the
266 * file
267 */
268void *sde_debugfs_create_regset32(const char *name, umode_t mode,
269 void *parent, struct sde_debugfs_regset32 *regset);
270
271/**
272 * sde_debugfs_get_root - Return root directory entry for SDE's debugfs
273 *
274 * The return value should be passed as the 'parent' argument to subsequent
275 * debugfs create calls.
276 *
277 * @sde_kms: Pointer to SDE's KMS structure
278 *
279 * Return: dentry pointer for SDE's debugfs location
280 */
281void *sde_debugfs_get_root(struct sde_kms *sde_kms);
282
283/**
Clarence Ipb218a3c2016-07-15 14:17:42 -0400284 * SDE info management functions
285 * These functions/definitions allow for building up a 'sde_info' structure
286 * containing one or more "key=value\n" entries.
287 */
288#define SDE_KMS_INFO_MAX_SIZE 4096
289
290/**
291 * struct sde_kms_info - connector information structure container
292 * @data: Array of information character data
293 * @len: Current length of information data
294 * @staged_len: Temporary data buffer length, commit to
295 * len using sde_kms_info_stop
296 * @start: Whether or not a partial data entry was just started
297 */
298struct sde_kms_info {
299 char data[SDE_KMS_INFO_MAX_SIZE];
300 uint32_t len;
301 uint32_t staged_len;
302 bool start;
303};
304
305/**
306 * SDE_KMS_INFO_DATA - Macro for accessing sde_kms_info data bytes
307 * @S: Pointer to sde_kms_info structure
308 * Returns: Pointer to byte data
309 */
310#define SDE_KMS_INFO_DATA(S) ((S) ? ((struct sde_kms_info *)(S))->data : 0)
311
312/**
313 * SDE_KMS_INFO_DATALEN - Macro for accessing sde_kms_info data length
314 * @S: Pointer to sde_kms_info structure
315 * Returns: Size of available byte data
316 */
317#define SDE_KMS_INFO_DATALEN(S) ((S) ? ((struct sde_kms_info *)(S))->len : 0)
318
319/**
320 * sde_kms_info_reset - reset sde_kms_info structure
321 * @info: Pointer to sde_kms_info structure
322 */
323void sde_kms_info_reset(struct sde_kms_info *info);
324
325/**
326 * sde_kms_info_add_keyint - add integer value to 'sde_kms_info'
327 * @info: Pointer to sde_kms_info structure
328 * @key: Pointer to key string
329 * @value: Signed 32-bit integer value
330 */
331void sde_kms_info_add_keyint(struct sde_kms_info *info,
332 const char *key,
333 int32_t value);
334
335/**
336 * sde_kms_info_add_keystr - add string value to 'sde_kms_info'
337 * @info: Pointer to sde_kms_info structure
338 * @key: Pointer to key string
339 * @value: Pointer to string value
340 */
341void sde_kms_info_add_keystr(struct sde_kms_info *info,
342 const char *key,
343 const char *value);
344
345/**
346 * sde_kms_info_start - begin adding key to 'sde_kms_info'
347 * Usage:
348 * sde_kms_info_start(key)
349 * sde_kms_info_append(val_1)
350 * ...
351 * sde_kms_info_append(val_n)
352 * sde_kms_info_stop
353 * @info: Pointer to sde_kms_info structure
354 * @key: Pointer to key string
355 */
356void sde_kms_info_start(struct sde_kms_info *info,
357 const char *key);
358
359/**
360 * sde_kms_info_append - append value string to 'sde_kms_info'
361 * Usage:
362 * sde_kms_info_start(key)
363 * sde_kms_info_append(val_1)
364 * ...
365 * sde_kms_info_append(val_n)
366 * sde_kms_info_stop
367 * @info: Pointer to sde_kms_info structure
368 * @str: Pointer to partial value string
369 */
370void sde_kms_info_append(struct sde_kms_info *info,
371 const char *str);
372
373/**
374 * sde_kms_info_append_format - append format code string to 'sde_kms_info'
375 * Usage:
376 * sde_kms_info_start(key)
377 * sde_kms_info_append_format(fourcc, modifier)
378 * ...
379 * sde_kms_info_stop
380 * @info: Pointer to sde_kms_info structure
381 * @pixel_format: FOURCC format code
382 * @modifier: 64-bit drm format modifier
383 */
384void sde_kms_info_append_format(struct sde_kms_info *info,
385 uint32_t pixel_format,
386 uint64_t modifier);
387
388/**
389 * sde_kms_info_stop - finish adding key to 'sde_kms_info'
390 * Usage:
391 * sde_kms_info_start(key)
392 * sde_kms_info_append(val_1)
393 * ...
394 * sde_kms_info_append(val_n)
395 * sde_kms_info_stop
396 * @info: Pointer to sde_kms_info structure
397 */
398void sde_kms_info_stop(struct sde_kms_info *info);
399
400/**
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400401 * HW resource manager functions
402 * @sde_rm_acquire_ctl_path : Allocates control path
403 * @sde_rm_get_ctl_path : returns control path driver context for already
404 * acquired ctl path
405 * @sde_rm_release_ctl_path : Frees control path driver context
406 * @sde_rm_acquire_mixer : Allocates mixer hw driver context
407 * @sde_rm_get_mixer : returns mixer context for already
408 * acquired mixer
409 * @sde_rm_release_mixer : Frees mixer hw driver context
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400410 * @sde_rm_acquire_intr : Allocate hw intr context
411 * @sde_rm_get_intr : Returns already acquired intr context
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400412 * @sde_rm_get_hw_res_map : Returns map for the passed INTF
413 */
414struct sde_hw_ctl *sde_rm_acquire_ctl_path(struct sde_kms *sde_kms,
415 enum sde_ctl idx);
416struct sde_hw_ctl *sde_rm_get_ctl_path(struct sde_kms *sde_kms,
417 enum sde_ctl idx);
418void sde_rm_release_ctl_path(struct sde_kms *sde_kms,
419 enum sde_ctl idx);
Alan Kwongd21960f2016-07-29 03:33:17 -0400420
421struct sde_hw_cdm *sde_rm_acquire_cdm_path(struct sde_kms *sde_kms,
422 enum sde_cdm idx, struct sde_hw_mdp *hw_mdp);
423struct sde_hw_cdm *sde_rm_get_cdm_path(struct sde_kms *sde_kms,
424 enum sde_cdm idx);
425void sde_rm_release_cdm_path(struct sde_kms *sde_kms,
426 enum sde_cdm idx);
427
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400428struct sde_hw_mixer *sde_rm_acquire_mixer(struct sde_kms *sde_kms,
429 enum sde_lm idx);
430struct sde_hw_mixer *sde_rm_get_mixer(struct sde_kms *sde_kms,
431 enum sde_lm idx);
432void sde_rm_release_mixer(struct sde_kms *sde_kms,
433 enum sde_lm idx);
434struct sde_hw_intr *sde_rm_acquire_intr(struct sde_kms *sde_kms);
435struct sde_hw_intr *sde_rm_get_intr(struct sde_kms *sde_kms);
436
437const struct sde_hw_res_map *sde_rm_get_res_map(struct sde_kms *sde_kms,
Alan Kwongd21960f2016-07-29 03:33:17 -0400438 enum sde_intf intf, enum sde_wb wb);
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400439
440/**
Ben Chan78647cd2016-06-26 22:02:47 -0400441 * IRQ functions
442 */
443int sde_irq_domain_init(struct sde_kms *sde_kms);
444int sde_irq_domain_fini(struct sde_kms *sde_kms);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700445void sde_irq_preinstall(struct msm_kms *kms);
446int sde_irq_postinstall(struct msm_kms *kms);
447void sde_irq_uninstall(struct msm_kms *kms);
448irqreturn_t sde_irq(struct msm_kms *kms);
Ben Chan78647cd2016-06-26 22:02:47 -0400449
450/**
451 * sde_set_irqmask - IRQ helper function for writing IRQ mask
452 * to SDE HW interrupt register.
453 * @sde_kms: SDE handle
454 * @reg_off: SDE HW interrupt register offset
455 * @irqmask: IRQ mask
456 */
457void sde_set_irqmask(
458 struct sde_kms *sde_kms,
459 uint32_t reg_off,
460 uint32_t irqmask);
461
462/**
463 * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
464 * interrupt mapping table.
465 * @sde_kms: SDE handle
466 * @intr_type: SDE HW interrupt type for lookup
467 * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
468 * @return: irq_idx or -EINVAL when fail to lookup
469 */
470int sde_irq_idx_lookup(
471 struct sde_kms *sde_kms,
472 enum sde_intr_type intr_type,
473 uint32_t instance_idx);
474
475/**
476 * sde_enable_irq - IRQ helper function for enabling one or more IRQs
477 * @sde_kms: SDE handle
478 * @irq_idxs: Array of irq index
479 * @irq_count: Number of irq_idx provided in the array
480 * @return: 0 for success enabling IRQ, otherwise failure
481 */
482int sde_enable_irq(
483 struct sde_kms *sde_kms,
484 int *irq_idxs,
485 uint32_t irq_count);
486
487/**
488 * sde_disable_irq - IRQ helper function for diabling one of more IRQs
489 * @sde_kms: SDE handle
490 * @irq_idxs: Array of irq index
491 * @irq_count: Number of irq_idx provided in the array
492 * @return: 0 for success disabling IRQ, otherwise failure
493 */
494int sde_disable_irq(
495 struct sde_kms *sde_kms,
496 int *irq_idxs,
497 uint32_t irq_count);
498
499/**
Alan Kwong2fad18c2016-07-29 02:10:37 -0400500 * sde_read_irq - IRQ helper function for reading IRQ status
501 * @sde_kms: SDE handle
502 * @irq_idx: irq index
503 * @clear: True to clear the irq after read
504 * @return: non-zero if irq detected; otherwise no irq detected
505 */
506u32 sde_read_irq(
507 struct sde_kms *sde_kms,
508 int irq_idx,
509 bool clear);
510
511/**
Ben Chan78647cd2016-06-26 22:02:47 -0400512 * sde_register_irq_callback - For registering callback function on IRQ
513 * interrupt
514 * @sde_kms: SDE handle
515 * @irq_idx: irq index
516 * @irq_cb: IRQ callback structure, containing callback function
517 * and argument. Passing NULL for irq_cb will unregister
518 * the callback for the given irq_idx
519 * @return: 0 for success registering callback, otherwise failure
520 */
521int sde_register_irq_callback(
522 struct sde_kms *sde_kms,
523 int irq_idx,
524 struct sde_irq_callback *irq_cb);
525
526/**
527 * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
528 * @sde_kms: SDE handle
529 */
530void sde_clear_all_irqs(struct sde_kms *sde_kms);
531
532/**
533 * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
534 * @sde_kms: SDE handle
535 */
536void sde_disable_all_irqs(struct sde_kms *sde_kms);
537
538/**
539 * Vblank enable/disable functions
540 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700541int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
542void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
543
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400544/**
545 * Plane functions
546 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700547enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
Clarence Ipcae1bb62016-07-07 12:07:13 -0400548void sde_plane_flush(struct drm_plane *plane);
Clarence Ipdbde9832016-06-26 09:48:36 -0400549struct drm_plane *sde_plane_init(struct drm_device *dev,
550 uint32_t pipe, bool primary_plane);
Clarence Ip7a753bb2016-07-07 11:47:44 -0400551
552/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400553 * sde_plane_wait_input_fence - wait for input fence object
Clarence Ip7a753bb2016-07-07 11:47:44 -0400554 * @plane: Pointer to DRM plane object
555 * @wait_ms: Wait timeout value
556 * Returns: Zero on success
557 */
Clarence Ipcae1bb62016-07-07 12:07:13 -0400558int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
Clarence Ipcb410d42016-06-26 22:52:33 -0400559
560/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400561 * sde_plane_color_fill - Enables color fill on plane
Clarence Ipcb410d42016-06-26 22:52:33 -0400562 * @plane: Pointer to DRM plane object
563 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
564 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
565 *
566 * Returns: 0 on success
567 */
568int sde_plane_color_fill(struct drm_plane *plane,
569 uint32_t color, uint32_t alpha);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700570
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400571/**
572 * CRTC functions
573 */
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400574int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400575void sde_crtc_wait_for_commit_done(struct drm_crtc *crtc);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700576void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400577void sde_crtc_commit_kickoff(struct drm_crtc *crtc);
Clarence Ip24f80662016-06-13 19:05:32 -0400578
579/**
580 * sde_crtc_prepare_fence - callback to prepare for output fences
581 * @crtc: Pointer to drm crtc object
582 */
583void sde_crtc_prepare_fence(struct drm_crtc *crtc);
584
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700585struct drm_crtc *sde_crtc_init(struct drm_device *dev,
586 struct drm_encoder *encoder,
587 struct drm_plane *plane, int id);
588
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400589/**
Clarence Ip24f80662016-06-13 19:05:32 -0400590 * sde_crtc_complete_commit - callback signalling completion of current commit
591 * @crtc: Pointer to drm crtc object
592 */
593void sde_crtc_complete_commit(struct drm_crtc *crtc);
594
595/**
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400596 * Encoder functions and data types
597 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400598struct sde_encoder_hw_resources {
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400599 enum sde_intf_mode intfs[INTF_MAX];
Alan Kwongd21960f2016-07-29 03:33:17 -0400600 enum sde_intf_mode wbs[WB_MAX];
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400601 bool pingpongs[PINGPONG_MAX];
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400602 bool ctls[CTL_MAX];
603 bool pingpongsplit;
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400604};
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400605
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400606/**
607 * sde_encoder_get_hw_resources - Populate table of required hardware resources
608 * @encoder: encoder pointer
609 * @hw_res: resource table to populate with encoder required resources
610 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400611void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
612 struct sde_encoder_hw_resources *hw_res);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700613
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400614/**
615 * sde_encoder_register_vblank_callback - provide callback to encoder that
616 * will be called on the next vblank.
617 * @encoder: encoder pointer
618 * @cb: callback pointer, provide NULL to deregister and disable IRQs
619 * @data: user data provided to callback
620 */
621void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
622 void (*cb)(void *), void *data);
623
624/**
625 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
626 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
627 * at the appropriate time.
628 * Immediately: if no previous commit is outstanding.
629 * Delayed: Save the callback, and return. Does not block. Callback will
630 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
631 * irq if it outstanding.
632 * Callback registered is expected to flush _all_ ctl paths of the crtc
633 * @encoder: encoder pointer
634 * @cb: callback pointer, provide NULL to deregister
635 * @data: user data provided to callback
636 */
637void sde_encoder_schedule_kickoff(struct drm_encoder *encoder,
638 void (*cb)(void *), void *data);
639
640/**
641 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
642 * current pending frames to hardware at a vblank or ctl_start
643 * Encoders will map this differently depending on irqs
644 * vid mode -> vsync_irq
645 * @encoder: encoder pointer
646 *
647 * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
648 */
649int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
650
651/**
652 * sde_encoders_init - query platform, create all encoders and bridges,
653 * and register them with the drm_device
654 * @dev: drm device pointer
655 */
656void sde_encoders_init(struct drm_device *dev);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700657
658#endif /* __sde_kms_H__ */