blob: f115d43457234fbf7adec997782b8b6de06fc32b [file] [log] [blame]
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __SDE_KMS_H__
14#define __SDE_KMS_H__
15
16#include "msm_drv.h"
17#include "msm_kms.h"
Alan Kwong112a84f2016-05-24 20:49:21 -040018#include "msm_mmu.h"
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070019#include "mdp/mdp_kms.h"
20#include "sde_hw_catalog.h"
Clarence Ipc475b082016-06-26 09:27:23 -040021#include "sde_hw_ctl.h"
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040022#include "sde_hw_lm.h"
Ben Chan78647cd2016-06-26 22:02:47 -040023#include "sde_hw_interrupts.h"
Alan Kwongd21960f2016-07-29 03:33:17 -040024#include "sde_hw_wb.h"
25#include "sde_hw_top.h"
Clarence Ipe59fb3f2016-07-26 13:39:59 -040026#include "sde_connector.h"
Lloyd Atkinson11f34442016-08-11 11:19:52 -040027#include "sde_rm.h"
Ben Chan78647cd2016-06-26 22:02:47 -040028
Clarence Ip31c19b52016-06-10 15:42:08 -040029/**
30 * SDE_DEBUG - macro for kms/plane/crtc/encoder/connector logs
31 * @fmt: Pointer to format string
32 */
33#define SDE_DEBUG(fmt, ...) \
34 do { \
35 if (unlikely(drm_debug & DRM_UT_KMS)) \
36 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
37 else \
38 pr_debug(fmt, ##__VA_ARGS__); \
39 } while (0)
40
41/**
42 * SDE_DEBUG_DRIVER - macro for hardware driver logging
43 * @fmt: Pointer to format string
44 */
45#define SDE_DEBUG_DRIVER(fmt, ...) \
46 do { \
47 if (unlikely(drm_debug & DRM_UT_DRIVER)) \
48 drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
49 else \
50 pr_debug(fmt, ##__VA_ARGS__); \
51 } while (0)
52
53#define SDE_ERROR(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
54
Ben Chan78647cd2016-06-26 22:02:47 -040055/*
56 * struct sde_irq_callback - IRQ callback handlers
57 * @func: intr handler
58 * @arg: argument for the handler
59 */
60struct sde_irq_callback {
61 void (*func)(void *arg, int irq_idx);
62 void *arg;
63};
64
65/**
66 * struct sde_irq: IRQ structure contains callback registration info
67 * @total_irq: total number of irq_idx obtained from HW interrupts mapping
68 * @irq_cb_tbl: array of IRQ callbacks setting
69 * @cb_lock: callback lock
70 */
71struct sde_irq {
72 u32 total_irqs;
73 struct sde_irq_callback *irq_cb_tbl;
74 spinlock_t cb_lock;
75};
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070076
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040077/**
Lloyd Atkinson11f34442016-08-11 11:19:52 -040078 * Encoder functions and data types
79 * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused
80 * @wbs: Writebacks this encoder is using, INTF_MODE_NONE if unused
81 * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs
82 * @display_num_of_h_tiles:
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040083 */
Lloyd Atkinson11f34442016-08-11 11:19:52 -040084struct sde_encoder_hw_resources {
85 enum sde_intf_mode intfs[INTF_MAX];
86 enum sde_intf_mode wbs[WB_MAX];
87 bool needs_cdm;
88 u32 display_num_of_h_tiles;
Abhijit Kulkarni40e38162016-06-26 22:12:09 -040089};
90
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070091struct sde_kms {
Ben Chan78647cd2016-06-26 22:02:47 -040092 struct msm_kms base;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070093 struct drm_device *dev;
94 int rev;
95 struct sde_mdss_cfg *catalog;
96
Alan Kwong112a84f2016-05-24 20:49:21 -040097 struct msm_mmu *mmu[MSM_SMMU_DOMAIN_MAX];
98 int mmu_id[MSM_SMMU_DOMAIN_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070099
Clarence Ip4ce59322016-06-26 22:27:51 -0400100 /* directory entry for debugfs */
101 void *debugfs_root;
102
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700103 /* io/register spaces: */
Alan Kwongdfa8c082016-07-29 04:10:00 -0400104 void __iomem *mmio, *vbif[VBIF_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700105
106 struct regulator *vdd;
107 struct regulator *mmagic;
108 struct regulator *venus;
109
110 struct clk *axi_clk;
111 struct clk *ahb_clk;
112 struct clk *src_clk;
113 struct clk *core_clk;
114 struct clk *lut_clk;
115 struct clk *mmagic_clk;
Alan Kwong112a84f2016-05-24 20:49:21 -0400116 struct clk *iommu_axi_clk[MSM_SMMU_DOMAIN_MAX];
117 struct clk *iommu_ahb_clk[MSM_SMMU_DOMAIN_MAX];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700118 struct clk *vsync_clk;
119
120 struct {
121 unsigned long enabled_mask;
122 struct irq_domain *domain;
123 } irqcontroller;
Ben Chan78647cd2016-06-26 22:02:47 -0400124
125 struct sde_hw_intr *hw_intr;
126 struct sde_irq irq_obj;
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400127
128 struct sde_rm rm;
Ben Chan78647cd2016-06-26 22:02:47 -0400129};
130
131struct vsync_info {
132 u32 frame_count;
133 u32 line_count;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700134};
135
136#define to_sde_kms(x) container_of(x, struct sde_kms, base)
137
138struct sde_plane_state {
139 struct drm_plane_state base;
140
141 /* aligned with property */
Clarence Ipe78efb72016-06-24 18:35:21 -0400142 uint64_t property_values[PLANE_PROP_COUNT];
143
144 /* blob properties */
145 struct drm_property_blob *property_blobs[PLANE_PROP_BLOBCOUNT];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700146
Clarence Ipcae1bb62016-07-07 12:07:13 -0400147 /* dereferenced input fence pointer */
148 void *input_fence;
Clarence Ipae4e60c2016-06-26 22:44:04 -0400149
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700150 /* assigned by crtc blender */
151 enum sde_stage stage;
152
153 /* some additional transactional status to help us know in the
154 * apply path whether we need to update SMP allocation, and
155 * whether current update is still pending:
156 */
157 bool mode_changed : 1;
158 bool pending : 1;
159};
160
161#define to_sde_plane_state(x) \
Clarence Ip4c1d9772016-06-26 09:35:38 -0400162 container_of(x, struct sde_plane_state, base)
163
164/**
165 * sde_plane_get_property - Query integer value of plane property
166 *
167 * @S: Pointer to plane state
168 * @X: Property index, from enum msm_mdp_plane_property
169 *
170 * Return: Integer value of requested property
171 */
172#define sde_plane_get_property(S, X) \
173 ((S) && ((X) < PLANE_PROP_COUNT) ? ((S)->property_values[(X)]) : 0)
174
175/**
176 * sde_plane_get_property32 - Query 32-bit representation of plane property
177 *
178 * @S: Pointer to plane state
179 * @X: Property index, from enum msm_mdp_plane_property
180 *
181 * Return: 32-bit value of requested property
182 */
183#define sde_plane_get_property32(S, X) \
184 ((S) && ((X) < PLANE_PROP_COUNT) ? \
185 (uint32_t)((S)->property_values[(X)]) : 0)
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700186
187int sde_disable(struct sde_kms *sde_kms);
188int sde_enable(struct sde_kms *sde_kms);
189
Ben Chan78647cd2016-06-26 22:02:47 -0400190/**
Clarence Ip4ce59322016-06-26 22:27:51 -0400191 * Debugfs functions - extra helper functions for debugfs support
192 *
193 * Main debugfs documentation is located at,
194 *
195 * Documentation/filesystems/debugfs.txt
196 *
197 * @sde_debugfs_setup_regset32: Initialize data for sde_debugfs_create_regset32
198 * @sde_debugfs_create_regset32: Create 32-bit register dump file
199 * @sde_debugfs_get_root: Get root dentry for SDE_KMS's debugfs node
200 */
201
202/**
203 * Companion structure for sde_debugfs_create_regset32. Do not initialize the
204 * members of this structure explicitly; use sde_debugfs_setup_regset32 instead.
205 */
206struct sde_debugfs_regset32 {
207 uint32_t offset;
208 uint32_t blk_len;
209 void __iomem *base;
210};
211
212/**
213 * sde_debugfs_setup_regset32 - Initialize register block definition for debugfs
214 * This function is meant to initialize sde_debugfs_regset32 structures for use
215 * with sde_debugfs_create_regset32.
216 * @regset: opaque register definition structure
217 * @offset: sub-block offset
218 * @length: sub-block length, in bytes
219 * @base: base IOMEM address
220 */
221void sde_debugfs_setup_regset32(struct sde_debugfs_regset32 *regset,
222 uint32_t offset, uint32_t length, void __iomem *base);
223
224/**
225 * sde_debugfs_create_regset32 - Create register read back file for debugfs
226 *
227 * This function is almost identical to the standard debugfs_create_regset32()
228 * function, with the main difference being that a list of register
229 * names/offsets do not need to be provided. The 'read' function simply outputs
230 * sequential register values over a specified range.
231 *
232 * Similar to the related debugfs_create_regset32 API, the structure pointed to
233 * by regset needs to persist for the lifetime of the created file. The calling
234 * code is responsible for initialization/management of this structure.
235 *
236 * The structure pointed to by regset is meant to be opaque. Please use
237 * sde_debugfs_setup_regset32 to initialize it.
238 *
239 * @name: File name within debugfs
240 * @mode: File mode within debugfs
241 * @parent: Parent directory entry within debugfs, can be NULL
242 * @regset: Pointer to persistent register block definition
243 *
244 * Return: dentry pointer for newly created file, use either debugfs_remove()
245 * or debugfs_remove_recursive() (on a parent directory) to remove the
246 * file
247 */
248void *sde_debugfs_create_regset32(const char *name, umode_t mode,
249 void *parent, struct sde_debugfs_regset32 *regset);
250
251/**
252 * sde_debugfs_get_root - Return root directory entry for SDE's debugfs
253 *
254 * The return value should be passed as the 'parent' argument to subsequent
255 * debugfs create calls.
256 *
257 * @sde_kms: Pointer to SDE's KMS structure
258 *
259 * Return: dentry pointer for SDE's debugfs location
260 */
261void *sde_debugfs_get_root(struct sde_kms *sde_kms);
262
263/**
Clarence Ipb218a3c2016-07-15 14:17:42 -0400264 * SDE info management functions
265 * These functions/definitions allow for building up a 'sde_info' structure
266 * containing one or more "key=value\n" entries.
267 */
268#define SDE_KMS_INFO_MAX_SIZE 4096
269
270/**
271 * struct sde_kms_info - connector information structure container
272 * @data: Array of information character data
273 * @len: Current length of information data
274 * @staged_len: Temporary data buffer length, commit to
275 * len using sde_kms_info_stop
276 * @start: Whether or not a partial data entry was just started
277 */
278struct sde_kms_info {
279 char data[SDE_KMS_INFO_MAX_SIZE];
280 uint32_t len;
281 uint32_t staged_len;
282 bool start;
283};
284
285/**
286 * SDE_KMS_INFO_DATA - Macro for accessing sde_kms_info data bytes
287 * @S: Pointer to sde_kms_info structure
288 * Returns: Pointer to byte data
289 */
290#define SDE_KMS_INFO_DATA(S) ((S) ? ((struct sde_kms_info *)(S))->data : 0)
291
292/**
293 * SDE_KMS_INFO_DATALEN - Macro for accessing sde_kms_info data length
294 * @S: Pointer to sde_kms_info structure
295 * Returns: Size of available byte data
296 */
297#define SDE_KMS_INFO_DATALEN(S) ((S) ? ((struct sde_kms_info *)(S))->len : 0)
298
299/**
300 * sde_kms_info_reset - reset sde_kms_info structure
301 * @info: Pointer to sde_kms_info structure
302 */
303void sde_kms_info_reset(struct sde_kms_info *info);
304
305/**
306 * sde_kms_info_add_keyint - add integer value to 'sde_kms_info'
307 * @info: Pointer to sde_kms_info structure
308 * @key: Pointer to key string
309 * @value: Signed 32-bit integer value
310 */
311void sde_kms_info_add_keyint(struct sde_kms_info *info,
312 const char *key,
313 int32_t value);
314
315/**
316 * sde_kms_info_add_keystr - add string value to 'sde_kms_info'
317 * @info: Pointer to sde_kms_info structure
318 * @key: Pointer to key string
319 * @value: Pointer to string value
320 */
321void sde_kms_info_add_keystr(struct sde_kms_info *info,
322 const char *key,
323 const char *value);
324
325/**
326 * sde_kms_info_start - begin adding key to 'sde_kms_info'
327 * Usage:
328 * sde_kms_info_start(key)
329 * sde_kms_info_append(val_1)
330 * ...
331 * sde_kms_info_append(val_n)
332 * sde_kms_info_stop
333 * @info: Pointer to sde_kms_info structure
334 * @key: Pointer to key string
335 */
336void sde_kms_info_start(struct sde_kms_info *info,
337 const char *key);
338
339/**
340 * sde_kms_info_append - append value string 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 * @str: Pointer to partial value string
349 */
350void sde_kms_info_append(struct sde_kms_info *info,
351 const char *str);
352
353/**
354 * sde_kms_info_append_format - append format code string to 'sde_kms_info'
355 * Usage:
356 * sde_kms_info_start(key)
357 * sde_kms_info_append_format(fourcc, modifier)
358 * ...
359 * sde_kms_info_stop
360 * @info: Pointer to sde_kms_info structure
361 * @pixel_format: FOURCC format code
362 * @modifier: 64-bit drm format modifier
363 */
364void sde_kms_info_append_format(struct sde_kms_info *info,
365 uint32_t pixel_format,
366 uint64_t modifier);
367
368/**
369 * sde_kms_info_stop - finish adding key to 'sde_kms_info'
370 * Usage:
371 * sde_kms_info_start(key)
372 * sde_kms_info_append(val_1)
373 * ...
374 * sde_kms_info_append(val_n)
375 * sde_kms_info_stop
376 * @info: Pointer to sde_kms_info structure
377 */
378void sde_kms_info_stop(struct sde_kms_info *info);
379
380/**
Ben Chan78647cd2016-06-26 22:02:47 -0400381 * IRQ functions
382 */
383int sde_irq_domain_init(struct sde_kms *sde_kms);
384int sde_irq_domain_fini(struct sde_kms *sde_kms);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700385void sde_irq_preinstall(struct msm_kms *kms);
386int sde_irq_postinstall(struct msm_kms *kms);
387void sde_irq_uninstall(struct msm_kms *kms);
388irqreturn_t sde_irq(struct msm_kms *kms);
Ben Chan78647cd2016-06-26 22:02:47 -0400389
390/**
391 * sde_set_irqmask - IRQ helper function for writing IRQ mask
392 * to SDE HW interrupt register.
393 * @sde_kms: SDE handle
394 * @reg_off: SDE HW interrupt register offset
395 * @irqmask: IRQ mask
396 */
397void sde_set_irqmask(
398 struct sde_kms *sde_kms,
399 uint32_t reg_off,
400 uint32_t irqmask);
401
402/**
403 * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
404 * interrupt mapping table.
405 * @sde_kms: SDE handle
406 * @intr_type: SDE HW interrupt type for lookup
407 * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
408 * @return: irq_idx or -EINVAL when fail to lookup
409 */
410int sde_irq_idx_lookup(
411 struct sde_kms *sde_kms,
412 enum sde_intr_type intr_type,
413 uint32_t instance_idx);
414
415/**
416 * sde_enable_irq - IRQ helper function for enabling one or more IRQs
417 * @sde_kms: SDE handle
418 * @irq_idxs: Array of irq index
419 * @irq_count: Number of irq_idx provided in the array
420 * @return: 0 for success enabling IRQ, otherwise failure
421 */
422int sde_enable_irq(
423 struct sde_kms *sde_kms,
424 int *irq_idxs,
425 uint32_t irq_count);
426
427/**
428 * sde_disable_irq - IRQ helper function for diabling one of more IRQs
429 * @sde_kms: SDE handle
430 * @irq_idxs: Array of irq index
431 * @irq_count: Number of irq_idx provided in the array
432 * @return: 0 for success disabling IRQ, otherwise failure
433 */
434int sde_disable_irq(
435 struct sde_kms *sde_kms,
436 int *irq_idxs,
437 uint32_t irq_count);
438
439/**
Alan Kwong2fad18c2016-07-29 02:10:37 -0400440 * sde_read_irq - IRQ helper function for reading IRQ status
441 * @sde_kms: SDE handle
442 * @irq_idx: irq index
443 * @clear: True to clear the irq after read
444 * @return: non-zero if irq detected; otherwise no irq detected
445 */
446u32 sde_read_irq(
447 struct sde_kms *sde_kms,
448 int irq_idx,
449 bool clear);
450
451/**
Ben Chan78647cd2016-06-26 22:02:47 -0400452 * sde_register_irq_callback - For registering callback function on IRQ
453 * interrupt
454 * @sde_kms: SDE handle
455 * @irq_idx: irq index
456 * @irq_cb: IRQ callback structure, containing callback function
457 * and argument. Passing NULL for irq_cb will unregister
458 * the callback for the given irq_idx
459 * @return: 0 for success registering callback, otherwise failure
460 */
461int sde_register_irq_callback(
462 struct sde_kms *sde_kms,
463 int irq_idx,
464 struct sde_irq_callback *irq_cb);
465
466/**
467 * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
468 * @sde_kms: SDE handle
469 */
470void sde_clear_all_irqs(struct sde_kms *sde_kms);
471
472/**
473 * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
474 * @sde_kms: SDE handle
475 */
476void sde_disable_all_irqs(struct sde_kms *sde_kms);
477
478/**
479 * Vblank enable/disable functions
480 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700481int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
482void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
483
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400484/**
485 * Plane functions
486 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700487enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
Clarence Ipcae1bb62016-07-07 12:07:13 -0400488void sde_plane_flush(struct drm_plane *plane);
Clarence Ipdbde9832016-06-26 09:48:36 -0400489struct drm_plane *sde_plane_init(struct drm_device *dev,
490 uint32_t pipe, bool primary_plane);
Clarence Ip7a753bb2016-07-07 11:47:44 -0400491
492/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400493 * sde_plane_wait_input_fence - wait for input fence object
Clarence Ip7a753bb2016-07-07 11:47:44 -0400494 * @plane: Pointer to DRM plane object
495 * @wait_ms: Wait timeout value
496 * Returns: Zero on success
497 */
Clarence Ipcae1bb62016-07-07 12:07:13 -0400498int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
Clarence Ipcb410d42016-06-26 22:52:33 -0400499
500/**
Clarence Ipcae1bb62016-07-07 12:07:13 -0400501 * sde_plane_color_fill - Enables color fill on plane
Clarence Ipcb410d42016-06-26 22:52:33 -0400502 * @plane: Pointer to DRM plane object
503 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
504 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
505 *
506 * Returns: 0 on success
507 */
508int sde_plane_color_fill(struct drm_plane *plane,
509 uint32_t color, uint32_t alpha);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700510
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400511/**
512 * CRTC functions
513 */
Abhijit Kulkarni7acb3262016-07-05 15:27:25 -0400514int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700515void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400516void sde_crtc_commit_kickoff(struct drm_crtc *crtc);
Clarence Ip24f80662016-06-13 19:05:32 -0400517
518/**
519 * sde_crtc_prepare_fence - callback to prepare for output fences
520 * @crtc: Pointer to drm crtc object
521 */
522void sde_crtc_prepare_fence(struct drm_crtc *crtc);
523
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400524/**
525 * sde_crtc_init - create a new crtc object
526 * @dev: sde device
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400527 * @plane: base plane
528 * @vblank_id: Id for reporting vblank. Id in range from 0..dev->num_crtcs.
529 * @Return: new crtc object or error
530 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700531struct drm_crtc *sde_crtc_init(struct drm_device *dev,
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400532 struct drm_plane *plane,
533 int vblank_id);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700534
Abhijit Kulkarni40e38162016-06-26 22:12:09 -0400535/**
Clarence Ip24f80662016-06-13 19:05:32 -0400536 * sde_crtc_complete_commit - callback signalling completion of current commit
537 * @crtc: Pointer to drm crtc object
538 */
539void sde_crtc_complete_commit(struct drm_crtc *crtc);
540
541/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400542 * sde_encoder_get_hw_resources - Populate table of required hardware resources
543 * @encoder: encoder pointer
544 * @hw_res: resource table to populate with encoder required resources
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400545 * @conn_state: report hw reqs based on this proposed connector state
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400546 */
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400547void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400548 struct sde_encoder_hw_resources *hw_res,
549 struct drm_connector_state *conn_state);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700550
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400551/**
Lloyd Atkinsone7bcdd22016-08-11 10:53:37 -0400552 * sde_encoder_needs_ctl_start - Get whether encoder type requires ctl_start
553 * CMD and WB encoders need ctl_start, video encs do not.
554 * @encoder: encoder pointer
555 * @Return: true if the encoder type requires ctl_start issued
556 */
557bool sde_encoder_needs_ctl_start(struct drm_encoder *encoder);
558
559/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400560 * sde_encoder_register_vblank_callback - provide callback to encoder that
561 * will be called on the next vblank.
562 * @encoder: encoder pointer
563 * @cb: callback pointer, provide NULL to deregister and disable IRQs
564 * @data: user data provided to callback
565 */
566void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
567 void (*cb)(void *), void *data);
568
569/**
570 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
571 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
572 * at the appropriate time.
573 * Immediately: if no previous commit is outstanding.
574 * Delayed: Save the callback, and return. Does not block. Callback will
575 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
576 * irq if it outstanding.
577 * Callback registered is expected to flush _all_ ctl paths of the crtc
578 * @encoder: encoder pointer
579 * @cb: callback pointer, provide NULL to deregister
580 * @data: user data provided to callback
581 */
582void sde_encoder_schedule_kickoff(struct drm_encoder *encoder,
583 void (*cb)(void *), void *data);
584
585/**
586 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
587 * current pending frames to hardware at a vblank or ctl_start
588 * Encoders will map this differently depending on irqs
589 * vid mode -> vsync_irq
590 * @encoder: encoder pointer
591 *
592 * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
593 */
594int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
595
596/**
597 * sde_encoders_init - query platform, create all encoders and bridges,
598 * and register them with the drm_device
599 * @dev: drm device pointer
600 */
601void sde_encoders_init(struct drm_device *dev);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700602
603#endif /* __sde_kms_H__ */