blob: fccc2649dc59aac826291d88b4fa4b0912b54a62 [file] [log] [blame]
Alan Kwong83285fb2016-10-21 20:51:17 -04001/* 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_ENCODER_H__
14#define __SDE_ENCODER_H__
15
16#include <drm/drm_crtc.h>
17
18#include "msm_prop.h"
19#include "sde_hw_mdss.h"
20
21/**
22 * Encoder functions and data types
23 * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused
24 * @wbs: Writebacks this encoder is using, INTF_MODE_NONE if unused
25 * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs
26 * @display_num_of_h_tiles:
27 */
28struct sde_encoder_hw_resources {
29 enum sde_intf_mode intfs[INTF_MAX];
30 enum sde_intf_mode wbs[WB_MAX];
31 bool needs_cdm;
32 u32 display_num_of_h_tiles;
33};
34
35/**
36 * sde_encoder_get_hw_resources - Populate table of required hardware resources
37 * @encoder: encoder pointer
38 * @hw_res: resource table to populate with encoder required resources
39 * @conn_state: report hw reqs based on this proposed connector state
40 */
41void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
42 struct sde_encoder_hw_resources *hw_res,
43 struct drm_connector_state *conn_state);
44
45/**
46 * sde_encoder_register_vblank_callback - provide callback to encoder that
47 * will be called on the next vblank.
48 * @encoder: encoder pointer
49 * @cb: callback pointer, provide NULL to deregister and disable IRQs
50 * @data: user data provided to callback
51 */
52void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
53 void (*cb)(void *), void *data);
54
55/**
56 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
57 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
58 * at the appropriate time.
59 * Immediately: if no previous commit is outstanding.
60 * Delayed: Save the callback, and return. Does not block. Callback will
61 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
62 * irq if it outstanding.
63 * @encoder: encoder pointer
64 */
65void sde_encoder_schedule_kickoff(struct drm_encoder *encoder);
66
67/**
68 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
69 * current pending frames to hardware at a vblank or ctl_start
70 * Encoders will map this differently depending on irqs
71 * vid mode -> vsync_irq
72 * @encoder: encoder pointer
73 * Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
74 */
75int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
76
77/**
78 * sde_encoder_init - initialize virtual encoder object
79 * @dev: Pointer to drm device structure
80 * @disp_info: Pointer to display information structure
81 * Returns: Pointer to newly created drm encoder
82 */
83struct drm_encoder *sde_encoder_init(
84 struct drm_device *dev,
85 struct msm_display_info *disp_info);
86
87/**
88 * sde_encoder_destroy - destroy previously initialized virtual encoder
89 * @drm_enc: Pointer to previously created drm encoder structure
90 */
91void sde_encoder_destroy(struct drm_encoder *drm_enc);
92
93#endif /* __SDE_ENCODER_H__ */