blob: b7563131a9711e045c9c45ad828238b63bbeca41 [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 Sankaran2b098072017-03-16 17:25:59 -070036 * @display_num_of_h_tiles: Number of horizontal tiles in case of split
37 * interface
38 * @topology: Topology of the display
Alan Kwong83285fb2016-10-21 20:51:17 -040039 */
40struct sde_encoder_hw_resources {
41 enum sde_intf_mode intfs[INTF_MAX];
42 enum sde_intf_mode wbs[WB_MAX];
43 bool needs_cdm;
44 u32 display_num_of_h_tiles;
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070045 struct msm_display_topology topology;
Alan Kwong83285fb2016-10-21 20:51:17 -040046};
47
48/**
Alan Kwong4aacd532017-02-04 18:51:33 -080049 * sde_encoder_kickoff_params - info encoder requires at kickoff
50 * @inline_rotate_prefill: number of lines to prefill for inline rotation
Lloyd Atkinson73fb8092017-02-08 16:02:55 -050051 * @affected_displays: bitmask, bit set means the ROI of the commit lies within
52 * the bounds of the physical display at the bit index
Alan Kwong4aacd532017-02-04 18:51:33 -080053 */
54struct sde_encoder_kickoff_params {
55 u32 inline_rotate_prefill;
Lloyd Atkinson73fb8092017-02-08 16:02:55 -050056 unsigned long affected_displays;
Alan Kwong4aacd532017-02-04 18:51:33 -080057};
58
59/**
Alan Kwong83285fb2016-10-21 20:51:17 -040060 * sde_encoder_get_hw_resources - Populate table of required hardware resources
61 * @encoder: encoder pointer
62 * @hw_res: resource table to populate with encoder required resources
63 * @conn_state: report hw reqs based on this proposed connector state
64 */
65void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
66 struct sde_encoder_hw_resources *hw_res,
67 struct drm_connector_state *conn_state);
68
69/**
70 * sde_encoder_register_vblank_callback - provide callback to encoder that
71 * will be called on the next vblank.
72 * @encoder: encoder pointer
73 * @cb: callback pointer, provide NULL to deregister and disable IRQs
74 * @data: user data provided to callback
75 */
76void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
77 void (*cb)(void *), void *data);
78
79/**
Alan Kwong628d19e2016-10-31 13:50:13 -040080 * sde_encoder_register_frame_event_callback - provide callback to encoder that
81 * will be called after the request is complete, or other events.
82 * @encoder: encoder pointer
83 * @cb: callback pointer, provide NULL to deregister
84 * @data: user data provided to callback
85 */
86void sde_encoder_register_frame_event_callback(struct drm_encoder *encoder,
87 void (*cb)(void *, u32), void *data);
88
89/**
Dhaval Patel30fae8a2017-04-21 18:42:41 -070090 * sde_encoder_get_rsc_client - gets the rsc client state for primary
Dhaval Patel82c8dbc2017-02-18 23:15:10 -080091 * for primary display.
92 * @encoder: encoder pointer
Dhaval Patel82c8dbc2017-02-18 23:15:10 -080093 */
Dhaval Patel30fae8a2017-04-21 18:42:41 -070094struct sde_rsc_client *sde_encoder_get_rsc_client(struct drm_encoder *encoder);
Dhaval Patel82c8dbc2017-02-18 23:15:10 -080095
96/**
Alan Kwong628d19e2016-10-31 13:50:13 -040097 * sde_encoder_prepare_for_kickoff - schedule double buffer flip of the ctl
98 * path (i.e. ctl flush and start) at next appropriate time.
Alan Kwong83285fb2016-10-21 20:51:17 -040099 * Immediately: if no previous commit is outstanding.
Alan Kwong628d19e2016-10-31 13:50:13 -0400100 * Delayed: Block until next trigger can be issued.
Alan Kwong83285fb2016-10-21 20:51:17 -0400101 * @encoder: encoder pointer
Alan Kwong4aacd532017-02-04 18:51:33 -0800102 * @params: kickoff time parameters
Alan Kwong83285fb2016-10-21 20:51:17 -0400103 */
Alan Kwong4aacd532017-02-04 18:51:33 -0800104void sde_encoder_prepare_for_kickoff(struct drm_encoder *encoder,
105 struct sde_encoder_kickoff_params *params);
Alan Kwong628d19e2016-10-31 13:50:13 -0400106
107/**
Dhaval Patel0e558f42017-04-30 00:51:40 -0700108 * sde_encoder_trigger_kickoff_pending - Clear the flush bits from previous
109 * kickoff and trigger the ctl prepare progress for command mode display.
110 * @encoder: encoder pointer
111 */
112void sde_encoder_trigger_kickoff_pending(struct drm_encoder *encoder);
113
114/**
Alan Kwong628d19e2016-10-31 13:50:13 -0400115 * sde_encoder_kickoff - trigger a double buffer flip of the ctl path
116 * (i.e. ctl flush and start) immediately.
117 * @encoder: encoder pointer
118 */
Alan Kwong67a3f792016-11-01 23:16:53 -0400119void sde_encoder_kickoff(struct drm_encoder *encoder);
Alan Kwong83285fb2016-10-21 20:51:17 -0400120
121/**
122 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
123 * current pending frames to hardware at a vblank or ctl_start
124 * Encoders will map this differently depending on irqs
125 * vid mode -> vsync_irq
126 * @encoder: encoder pointer
127 * Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
128 */
129int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
130
Alan Kwong67a3f792016-11-01 23:16:53 -0400131/*
132 * sde_encoder_get_intf_mode - get interface mode of the given encoder
133 * @encoder: Pointer to drm encoder object
134 */
135enum sde_intf_mode sde_encoder_get_intf_mode(struct drm_encoder *encoder);
136
Alan Kwong83285fb2016-10-21 20:51:17 -0400137/**
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -0700138 * sde_encoder_virt_restore - restore the encoder configs
139 * @encoder: encoder pointer
140 */
141void sde_encoder_virt_restore(struct drm_encoder *encoder);
142
143/**
Alan Kwong4aacd532017-02-04 18:51:33 -0800144 * enum sde_encoder_property - property tags for sde enoder
145 * @SDE_ENCODER_PROPERTY_INLINE_ROTATE_REFILL: # of prefill line, 0 to disable
146 */
147enum sde_encoder_property {
148 SDE_ENCODER_PROPERTY_INLINE_ROTATE_PREFILL,
149 SDE_ENCODER_PROPERTY_MAX,
150};
151
152/*
153 * sde_encoder_set_property - set the property tag to the given value
154 * @encoder: Pointer to drm encoder object
155 * @tag: property tag
156 * @val: property value
157 * return: 0 if success; errror code otherwise
158 */
159int sde_encoder_set_property(struct drm_encoder *encoder, u32 tag, u64 val);
160
161/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400162 * sde_encoder_init - initialize virtual encoder object
163 * @dev: Pointer to drm device structure
164 * @disp_info: Pointer to display information structure
165 * Returns: Pointer to newly created drm encoder
166 */
167struct drm_encoder *sde_encoder_init(
168 struct drm_device *dev,
169 struct msm_display_info *disp_info);
170
171/**
172 * sde_encoder_destroy - destroy previously initialized virtual encoder
173 * @drm_enc: Pointer to previously created drm encoder structure
174 */
175void sde_encoder_destroy(struct drm_encoder *drm_enc);
176
177#endif /* __SDE_ENCODER_H__ */