blob: bd3d68bddb2fc401c433bf8521d2f859cebbae2c [file] [log] [blame]
Dhaval Patel14d46ce2017-01-17 16:28:12 -08001/*
2 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
3 * Copyright (C) 2013 Red Hat
4 * Author: Rob Clark <robdclark@gmail.com>
Alan Kwong83285fb2016-10-21 20:51:17 -04005 *
Dhaval Patel14d46ce2017-01-17 16:28:12 -08006 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
Alan Kwong83285fb2016-10-21 20:51:17 -04009 *
Dhaval Patel14d46ce2017-01-17 16:28:12 -080010 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
Alan Kwong83285fb2016-10-21 20:51:17 -040017 */
18
19#ifndef __SDE_ENCODER_H__
20#define __SDE_ENCODER_H__
21
22#include <drm/drm_crtc.h>
23
24#include "msm_prop.h"
25#include "sde_hw_mdss.h"
26
Lloyd Atkinson8c49c582016-11-18 14:23:54 -050027#define SDE_ENCODER_FRAME_EVENT_DONE BIT(0)
28#define SDE_ENCODER_FRAME_EVENT_ERROR BIT(1)
29#define SDE_ENCODER_FRAME_EVENT_PANEL_DEAD BIT(2)
Alan Kwong628d19e2016-10-31 13:50:13 -040030
Alan Kwong83285fb2016-10-21 20:51:17 -040031/**
32 * Encoder functions and data types
33 * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused
34 * @wbs: Writebacks this encoder is using, INTF_MODE_NONE if unused
35 * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -080036 * @needs_dsc: Request to allocate DSC block
Alan Kwong83285fb2016-10-21 20:51:17 -040037 * @display_num_of_h_tiles:
38 */
39struct sde_encoder_hw_resources {
40 enum sde_intf_mode intfs[INTF_MAX];
41 enum sde_intf_mode wbs[WB_MAX];
42 bool needs_cdm;
Jeykumar Sankaran5c2f0702017-03-09 18:03:15 -080043 bool needs_dsc;
Alan Kwong83285fb2016-10-21 20:51:17 -040044 u32 display_num_of_h_tiles;
45};
46
47/**
Alan Kwong4aacd532017-02-04 18:51:33 -080048 * sde_encoder_kickoff_params - info encoder requires at kickoff
49 * @inline_rotate_prefill: number of lines to prefill for inline rotation
Lloyd Atkinson73fb8092017-02-08 16:02:55 -050050 * @affected_displays: bitmask, bit set means the ROI of the commit lies within
51 * the bounds of the physical display at the bit index
Alan Kwong4aacd532017-02-04 18:51:33 -080052 */
53struct sde_encoder_kickoff_params {
54 u32 inline_rotate_prefill;
Lloyd Atkinson73fb8092017-02-08 16:02:55 -050055 unsigned long affected_displays;
Alan Kwong4aacd532017-02-04 18:51:33 -080056};
57
58/**
Alan Kwong83285fb2016-10-21 20:51:17 -040059 * sde_encoder_get_hw_resources - Populate table of required hardware resources
60 * @encoder: encoder pointer
61 * @hw_res: resource table to populate with encoder required resources
62 * @conn_state: report hw reqs based on this proposed connector state
63 */
64void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
65 struct sde_encoder_hw_resources *hw_res,
66 struct drm_connector_state *conn_state);
67
68/**
69 * sde_encoder_register_vblank_callback - provide callback to encoder that
70 * will be called on the next vblank.
71 * @encoder: encoder pointer
72 * @cb: callback pointer, provide NULL to deregister and disable IRQs
73 * @data: user data provided to callback
74 */
75void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
76 void (*cb)(void *), void *data);
77
78/**
Alan Kwong628d19e2016-10-31 13:50:13 -040079 * sde_encoder_register_frame_event_callback - provide callback to encoder that
80 * will be called after the request is complete, or other events.
81 * @encoder: encoder pointer
82 * @cb: callback pointer, provide NULL to deregister
83 * @data: user data provided to callback
84 */
85void sde_encoder_register_frame_event_callback(struct drm_encoder *encoder,
86 void (*cb)(void *, u32), void *data);
87
88/**
Dhaval Patel30fae8a2017-04-21 18:42:41 -070089 * sde_encoder_get_rsc_client - gets the rsc client state for primary
Dhaval Patel82c8dbc2017-02-18 23:15:10 -080090 * for primary display.
91 * @encoder: encoder pointer
Dhaval Patel82c8dbc2017-02-18 23:15:10 -080092 */
Dhaval Patel30fae8a2017-04-21 18:42:41 -070093struct sde_rsc_client *sde_encoder_get_rsc_client(struct drm_encoder *encoder);
Dhaval Patel82c8dbc2017-02-18 23:15:10 -080094
95/**
Alan Kwong628d19e2016-10-31 13:50:13 -040096 * sde_encoder_prepare_for_kickoff - schedule double buffer flip of the ctl
97 * path (i.e. ctl flush and start) at next appropriate time.
Alan Kwong83285fb2016-10-21 20:51:17 -040098 * Immediately: if no previous commit is outstanding.
Alan Kwong628d19e2016-10-31 13:50:13 -040099 * Delayed: Block until next trigger can be issued.
Alan Kwong83285fb2016-10-21 20:51:17 -0400100 * @encoder: encoder pointer
Alan Kwong4aacd532017-02-04 18:51:33 -0800101 * @params: kickoff time parameters
Alan Kwong83285fb2016-10-21 20:51:17 -0400102 */
Alan Kwong4aacd532017-02-04 18:51:33 -0800103void sde_encoder_prepare_for_kickoff(struct drm_encoder *encoder,
104 struct sde_encoder_kickoff_params *params);
Alan Kwong628d19e2016-10-31 13:50:13 -0400105
106/**
107 * sde_encoder_kickoff - trigger a double buffer flip of the ctl path
108 * (i.e. ctl flush and start) immediately.
109 * @encoder: encoder pointer
110 */
Alan Kwong67a3f792016-11-01 23:16:53 -0400111void sde_encoder_kickoff(struct drm_encoder *encoder);
Alan Kwong83285fb2016-10-21 20:51:17 -0400112
113/**
114 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
115 * current pending frames to hardware at a vblank or ctl_start
116 * Encoders will map this differently depending on irqs
117 * vid mode -> vsync_irq
118 * @encoder: encoder pointer
119 * Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
120 */
121int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
122
Alan Kwong67a3f792016-11-01 23:16:53 -0400123/*
124 * sde_encoder_get_intf_mode - get interface mode of the given encoder
125 * @encoder: Pointer to drm encoder object
126 */
127enum sde_intf_mode sde_encoder_get_intf_mode(struct drm_encoder *encoder);
128
Alan Kwong83285fb2016-10-21 20:51:17 -0400129/**
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -0700130 * sde_encoder_virt_restore - restore the encoder configs
131 * @encoder: encoder pointer
132 */
133void sde_encoder_virt_restore(struct drm_encoder *encoder);
134
135/**
Alan Kwong4aacd532017-02-04 18:51:33 -0800136 * enum sde_encoder_property - property tags for sde enoder
137 * @SDE_ENCODER_PROPERTY_INLINE_ROTATE_REFILL: # of prefill line, 0 to disable
138 */
139enum sde_encoder_property {
140 SDE_ENCODER_PROPERTY_INLINE_ROTATE_PREFILL,
141 SDE_ENCODER_PROPERTY_MAX,
142};
143
144/*
145 * sde_encoder_set_property - set the property tag to the given value
146 * @encoder: Pointer to drm encoder object
147 * @tag: property tag
148 * @val: property value
149 * return: 0 if success; errror code otherwise
150 */
151int sde_encoder_set_property(struct drm_encoder *encoder, u32 tag, u64 val);
152
153/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400154 * sde_encoder_init - initialize virtual encoder object
155 * @dev: Pointer to drm device structure
156 * @disp_info: Pointer to display information structure
157 * Returns: Pointer to newly created drm encoder
158 */
159struct drm_encoder *sde_encoder_init(
160 struct drm_device *dev,
161 struct msm_display_info *disp_info);
162
163/**
164 * sde_encoder_destroy - destroy previously initialized virtual encoder
165 * @drm_enc: Pointer to previously created drm encoder structure
166 */
167void sde_encoder_destroy(struct drm_encoder *drm_enc);
168
169#endif /* __SDE_ENCODER_H__ */