blob: e1b07c23f5b92b510a8caea797ad00b011d158e2 [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_PLANE_H_
20#define _SDE_PLANE_H_
21
22#include <drm/drm_crtc.h>
23
24#include "msm_prop.h"
Alan Kwong4dd64c82017-02-04 18:41:51 -080025#include "sde_kms.h"
Alan Kwong83285fb2016-10-21 20:51:17 -040026#include "sde_hw_mdss.h"
Alan Kwong4dd64c82017-02-04 18:41:51 -080027#include "sde_hw_rot.h"
28#include "sde_hw_sspp.h"
29
30/**
31 * struct sde_plane_rot_state - state of pre-sspp rotator stage
32 * @sequence_id: sequence identifier, incremented per state duplication
33 * @rot_hw: Pointer to rotator hardware driver
34 * @rot90: true if rotation of 90 degree is required
35 * @hflip: true if horizontal flip is required
36 * @vflip: true if vertical flip is required
Alan Kwong4dd64c82017-02-04 18:41:51 -080037 * @rot_cmd: rotator configuration command
38 * @nplane: total number of drm plane attached to rotator
39 * @in_fb: input fb attached to rotator
40 * @in_rotation: input rotation property of rotator stage
41 * @in_rot_rect: input rectangle of the rotator in plane fb coordinate
42 * @out_rotation: output rotation property of rotator stage
43 * @out_rot_rect: output rectangle of the rotator in plane fb coordinate
44 * @out_src_rect: output rectangle of the plane source in plane fb coordinate
45 * @out_src_x: output src_x of rotator stage in rotator output fb coordinate
46 * @out_src_y: output src y of rotator stage in rotator output fb coordinate
47 * @out_src_w: output src w of rotator stage in rotator output fb ooordinate
48 * @out_src_h: output src h of rotator stage in rotator output fb coordinate
49 * @out_fb_width: output framebuffer width of rotator stage
50 * @out_fb_height: output framebuffer height of rotator stage
51 * @out_fb_pixel_format: output framebuffer pixel format of rotator stage
52 * @out_fb_modifier: output framebuffer modifier of rotator stage
53 * @out_fb_flags: output framebuffer flags of rotator stage
54 * @out_sbuf: true if output streaming buffer is required
55 * @out_fb_format: Pointer to output framebuffer format of rotator stage
56 * @out_fb: Pointer to output drm framebuffer of rotator stage
57 * @out_fbo: framebuffer object of output streaming buffer
58 * @out_xpos: relative horizontal position of the plane (0 - leftmost)
59 */
60struct sde_plane_rot_state {
61 u32 sequence_id;
62 struct sde_hw_rot *rot_hw;
63 bool rot90;
64 bool hflip;
65 bool vflip;
Alan Kwong4dd64c82017-02-04 18:41:51 -080066 struct sde_hw_rot_cmd rot_cmd;
67 int nplane;
68 /* input */
69 struct drm_framebuffer *in_fb;
70 struct drm_rect in_rot_rect;
71 u32 in_rotation;
72 /* output */
73 struct drm_rect out_rot_rect;
74 struct drm_rect out_src_rect;
75 u32 out_rotation;
76 u32 out_src_x;
77 u32 out_src_y;
78 u32 out_src_w;
79 u32 out_src_h;
80 u32 out_fb_width;
81 u32 out_fb_height;
82 u32 out_fb_pixel_format;
83 u64 out_fb_modifier[4];
84 u32 out_fb_flags;
85 bool out_sbuf;
86 const struct sde_format *out_fb_format;
87 struct drm_framebuffer *out_fb;
88 struct sde_kms_fbo *out_fbo;
89 int out_xpos;
90};
Alan Kwong83285fb2016-10-21 20:51:17 -040091
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -070092/* dirty bits for update function */
93#define SDE_PLANE_DIRTY_RECTS 0x1
94#define SDE_PLANE_DIRTY_FORMAT 0x2
95#define SDE_PLANE_DIRTY_SHARPEN 0x4
Alan Kwong2349d742017-04-20 08:27:30 -070096#define SDE_PLANE_DIRTY_PERF 0x8
Abhijit Kulkarni333d6c02017-05-01 18:32:18 -070097#define SDE_PLANE_DIRTY_FB_TRANSLATION_MODE 0x10
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -070098#define SDE_PLANE_DIRTY_ALL 0xFFFFFFFF
99
Alan Kwong83285fb2016-10-21 20:51:17 -0400100/**
Clarence Ip172033f2017-06-13 10:52:56 -0400101 * enum sde_plane_sclcheck_state - User scaler data status
102 *
103 * @SDE_PLANE_SCLCHECK_NONE: No user data provided
104 * @SDE_PLANE_SCLCHECK_INVALID: Invalid user data provided
105 * @SDE_PLANE_SCLCHECK_SCALER_V1: Valid scaler v1 data
106 * @SDE_PLANE_SCLCHECK_SCALER_V1_CHECK: Unchecked scaler v1 data
107 * @SDE_PLANE_SCLCHECK_SCALER_V2: Valid scaler v2 data
108 * @SDE_PLANE_SCLCHECK_SCALER_V2_CHECK: Unchecked scaler v2 data
109 */
110enum sde_plane_sclcheck_state {
111 SDE_PLANE_SCLCHECK_NONE,
112 SDE_PLANE_SCLCHECK_INVALID,
113 SDE_PLANE_SCLCHECK_SCALER_V1,
114 SDE_PLANE_SCLCHECK_SCALER_V1_CHECK,
115 SDE_PLANE_SCLCHECK_SCALER_V2,
116 SDE_PLANE_SCLCHECK_SCALER_V2_CHECK,
117};
118
119/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400120 * struct sde_plane_state: Define sde extension of drm plane state object
121 * @base: base drm plane state object
Clarence Ip4a2955d2017-07-04 18:04:33 -0400122 * @property_state: Local storage for msm_prop properties
Alan Kwong83285fb2016-10-21 20:51:17 -0400123 * @property_values: cached plane property values
Abhijit Kulkarni333d6c02017-05-01 18:32:18 -0700124 * @aspace: pointer to address space for input/output buffers
Alan Kwong83285fb2016-10-21 20:51:17 -0400125 * @input_fence: dereferenced input fence pointer
126 * @stage: assigned by crtc blender
Veera Sundaram Sankaran02dd6ac2016-12-22 15:08:29 -0800127 * @excl_rect: exclusion rect values
Alan Kwong83285fb2016-10-21 20:51:17 -0400128 * @dirty: bitmask for which pipe h/w config functions need to be updated
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800129 * @multirect_index: index of the rectangle of SSPP
130 * @multirect_mode: parallel or time multiplex multirect mode
Alan Kwong83285fb2016-10-21 20:51:17 -0400131 * @pending: whether the current update is still pending
Veera Sundaram Sankaran47e718f2017-09-13 16:47:23 -0700132 * @defer_prepare_fb: indicate if prepare_fb call was deferred
Clarence Ip172033f2017-06-13 10:52:56 -0400133 * @scaler3_cfg: configuration data for scaler3
134 * @pixel_ext: configuration data for pixel extensions
135 * @scaler_check_state: indicates status of user provided pixel extension data
Alan Kwong143f50c2017-04-28 07:34:28 -0700136 * @cdp_cfg: CDP configuration
Alan Kwong83285fb2016-10-21 20:51:17 -0400137 */
138struct sde_plane_state {
139 struct drm_plane_state base;
Clarence Ip4a2955d2017-07-04 18:04:33 -0400140 struct msm_property_state property_state;
141 struct msm_property_value property_values[PLANE_PROP_COUNT];
Abhijit Kulkarni333d6c02017-05-01 18:32:18 -0700142 struct msm_gem_address_space *aspace;
Alan Kwong83285fb2016-10-21 20:51:17 -0400143 void *input_fence;
144 enum sde_stage stage;
Veera Sundaram Sankaran02dd6ac2016-12-22 15:08:29 -0800145 struct sde_rect excl_rect;
Alan Kwong83285fb2016-10-21 20:51:17 -0400146 uint32_t dirty;
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800147 uint32_t multirect_index;
148 uint32_t multirect_mode;
Alan Kwong83285fb2016-10-21 20:51:17 -0400149 bool pending;
Veera Sundaram Sankaran47e718f2017-09-13 16:47:23 -0700150 bool defer_prepare_fb;
Alan Kwong4dd64c82017-02-04 18:41:51 -0800151
Clarence Ip172033f2017-06-13 10:52:56 -0400152 /* scaler configuration */
153 struct sde_hw_scaler3_cfg scaler3_cfg;
154 struct sde_hw_pixel_ext pixel_ext;
155 enum sde_plane_sclcheck_state scaler_check_state;
156
Alan Kwong4dd64c82017-02-04 18:41:51 -0800157 /* @sc_cfg: system_cache configuration */
158 struct sde_hw_pipe_sc_cfg sc_cfg;
159 struct sde_plane_rot_state rot;
Alan Kwong143f50c2017-04-28 07:34:28 -0700160
161 struct sde_hw_pipe_cdp_cfg cdp_cfg;
Alan Kwong83285fb2016-10-21 20:51:17 -0400162};
163
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800164/**
165 * struct sde_multirect_plane_states: Defines multirect pair of drm plane states
166 * @r0: drm plane configured on rect 0
167 * @r1: drm plane configured on rect 1
168 */
169struct sde_multirect_plane_states {
170 const struct drm_plane_state *r0;
171 const struct drm_plane_state *r1;
172};
173
Alan Kwong83285fb2016-10-21 20:51:17 -0400174#define to_sde_plane_state(x) \
175 container_of(x, struct sde_plane_state, base)
176
177/**
178 * sde_plane_get_property - Query integer value of plane property
179 * @S: Pointer to plane state
180 * @X: Property index, from enum msm_mdp_plane_property
181 * Returns: Integer value of requested property
182 */
Clarence Ip4a2955d2017-07-04 18:04:33 -0400183#define sde_plane_get_property(S, X) ((S) && ((X) < PLANE_PROP_COUNT) ? \
184 ((S)->property_values[(X)].value) : 0)
Alan Kwong83285fb2016-10-21 20:51:17 -0400185
186/**
187 * sde_plane_pipe - return sspp identifier for the given plane
188 * @plane: Pointer to DRM plane object
189 * Returns: sspp identifier of the given plane
190 */
191enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
192
193/**
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800194 * is_sde_plane_virtual - check for virtual plane
195 * @plane: Pointer to DRM plane object
196 * returns: true - if the plane is virtual
197 * false - if the plane is primary
198 */
199bool is_sde_plane_virtual(struct drm_plane *plane);
200
201/**
Alan Kwong4dd64c82017-02-04 18:41:51 -0800202 * sde_plane_get_ctl_flush - get control flush mask
203 * @plane: Pointer to DRM plane object
204 * @ctl: Pointer to control hardware
Clarence Ip7e5f0002017-05-29 18:46:56 -0400205 * @flush_sspp: Pointer to sspp flush control word
206 * @flush_rot: Pointer to rotator flush control word
Alan Kwong4dd64c82017-02-04 18:41:51 -0800207 */
208void sde_plane_get_ctl_flush(struct drm_plane *plane, struct sde_hw_ctl *ctl,
Clarence Ip7e5f0002017-05-29 18:46:56 -0400209 u32 *flush_sspp, u32 *flush_rot);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800210
211/**
Clarence Ipb776b532017-09-12 18:30:06 -0400212 * sde_plane_rot_calc_prefill - calculate rotator start prefill
213 * @plane: Pointer to drm plane
214 * return: prefill time in line
Alan Kwong4dd64c82017-02-04 18:41:51 -0800215 */
Clarence Ipb776b532017-09-12 18:30:06 -0400216u32 sde_plane_rot_calc_prefill(struct drm_plane *plane);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800217
218/**
Alan Kwong346223e2017-06-30 15:29:22 -0400219 * sde_plane_restore - restore hw state if previously power collapsed
220 * @plane: Pointer to drm plane structure
221 */
222void sde_plane_restore(struct drm_plane *plane);
223
224/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400225 * sde_plane_flush - final plane operations before commit flush
226 * @plane: Pointer to drm plane structure
227 */
228void sde_plane_flush(struct drm_plane *plane);
229
230/**
Clarence Ip8ee49952017-09-20 11:10:50 -0400231 * sde_plane_kickoff_rot - final plane rotator operations before commit kickoff
Clarence Ipeb39cce2017-07-19 14:12:43 -0400232 * @plane: Pointer to drm plane structure
Clarence Ip8ee49952017-09-20 11:10:50 -0400233 * Returns: Zero on success
Clarence Ipeb39cce2017-07-19 14:12:43 -0400234 */
Clarence Ip8ee49952017-09-20 11:10:50 -0400235int sde_plane_kickoff_rot(struct drm_plane *plane);
Clarence Ipeb39cce2017-07-19 14:12:43 -0400236
237/**
Abhijit Kulkarni1b3340c2017-06-22 12:39:37 -0700238 * sde_plane_set_error: enable/disable error condition
239 * @plane: pointer to drm_plane structure
240 */
241void sde_plane_set_error(struct drm_plane *plane, bool error);
242
243/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400244 * sde_plane_init - create new sde plane for the given pipe
245 * @dev: Pointer to DRM device
246 * @pipe: sde hardware pipe identifier
247 * @primary_plane: true if this pipe is primary plane for crtc
248 * @possible_crtcs: bitmask of crtc that can be attached to the given pipe
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800249 * @master_plane_id: primary plane id of a multirect pipe. 0 value passed for
250 * a regular plane initialization. A non-zero primary plane
251 * id will be passed for a virtual pipe initialization.
252 *
Alan Kwong83285fb2016-10-21 20:51:17 -0400253 */
254struct drm_plane *sde_plane_init(struct drm_device *dev,
255 uint32_t pipe, bool primary_plane,
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800256 unsigned long possible_crtcs, u32 master_plane_id);
257
258/**
259 * sde_plane_validate_multirecti_v2 - validate the multirect planes
260 * against hw limitations
261 * @plane: drm plate states of the multirect pair
262 */
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800263int sde_plane_validate_multirect_v2(struct sde_multirect_plane_states *plane);
Alan Kwong83285fb2016-10-21 20:51:17 -0400264
265/**
Jeykumar Sankarane964dc72017-05-10 19:26:43 -0700266 * sde_plane_clear_multirect - clear multirect bits for the given pipe
267 * @drm_state: Pointer to DRM plane state
268 */
269void sde_plane_clear_multirect(const struct drm_plane_state *drm_state);
270
271/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400272 * sde_plane_wait_input_fence - wait for input fence object
273 * @plane: Pointer to DRM plane object
274 * @wait_ms: Wait timeout value
275 * Returns: Zero on success
276 */
277int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
278
279/**
280 * sde_plane_color_fill - enables color fill on plane
281 * @plane: Pointer to DRM plane object
282 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
283 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
284 * Returns: 0 on success
285 */
286int sde_plane_color_fill(struct drm_plane *plane,
287 uint32_t color, uint32_t alpha);
288
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -0700289/**
290 * sde_plane_set_revalidate - sets revalidate flag which forces a full
291 * validation of the plane properties in the next atomic check
292 * @plane: Pointer to DRM plane object
293 * @enable: Boolean to set/unset the flag
294 */
295void sde_plane_set_revalidate(struct drm_plane *plane, bool enable);
296
Lloyd Atkinsone08229c2017-10-02 17:53:30 -0400297/**
298 * sde_plane_helper_reset_properties - reset properties to default values in the
299 * given DRM plane state object
300 * @plane: Pointer to DRM plane object
301 * @plane_state: Pointer to DRM plane state object
302 * Returns: 0 on success, negative errno on failure
303 */
304int sde_plane_helper_reset_custom_properties(struct drm_plane *plane,
305 struct drm_plane_state *plane_state);
306
Alan Kwong83285fb2016-10-21 20:51:17 -0400307#endif /* _SDE_PLANE_H_ */