blob: c9563451bfe5d901605be0f84683be628d1cfb38 [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
Clarence Ip172033f2017-06-13 10:52:56 -0400132 * @scaler3_cfg: configuration data for scaler3
133 * @pixel_ext: configuration data for pixel extensions
134 * @scaler_check_state: indicates status of user provided pixel extension data
Alan Kwong143f50c2017-04-28 07:34:28 -0700135 * @cdp_cfg: CDP configuration
Alan Kwong83285fb2016-10-21 20:51:17 -0400136 */
137struct sde_plane_state {
138 struct drm_plane_state base;
Clarence Ip4a2955d2017-07-04 18:04:33 -0400139 struct msm_property_state property_state;
140 struct msm_property_value property_values[PLANE_PROP_COUNT];
Abhijit Kulkarni333d6c02017-05-01 18:32:18 -0700141 struct msm_gem_address_space *aspace;
Alan Kwong83285fb2016-10-21 20:51:17 -0400142 void *input_fence;
143 enum sde_stage stage;
Veera Sundaram Sankaran02dd6ac2016-12-22 15:08:29 -0800144 struct sde_rect excl_rect;
Alan Kwong83285fb2016-10-21 20:51:17 -0400145 uint32_t dirty;
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800146 uint32_t multirect_index;
147 uint32_t multirect_mode;
Alan Kwong83285fb2016-10-21 20:51:17 -0400148 bool pending;
Alan Kwong4dd64c82017-02-04 18:41:51 -0800149
Clarence Ip172033f2017-06-13 10:52:56 -0400150 /* scaler configuration */
151 struct sde_hw_scaler3_cfg scaler3_cfg;
152 struct sde_hw_pixel_ext pixel_ext;
153 enum sde_plane_sclcheck_state scaler_check_state;
154
Alan Kwong4dd64c82017-02-04 18:41:51 -0800155 /* @sc_cfg: system_cache configuration */
156 struct sde_hw_pipe_sc_cfg sc_cfg;
157 struct sde_plane_rot_state rot;
Alan Kwong143f50c2017-04-28 07:34:28 -0700158
159 struct sde_hw_pipe_cdp_cfg cdp_cfg;
Alan Kwong83285fb2016-10-21 20:51:17 -0400160};
161
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800162/**
163 * struct sde_multirect_plane_states: Defines multirect pair of drm plane states
164 * @r0: drm plane configured on rect 0
165 * @r1: drm plane configured on rect 1
166 */
167struct sde_multirect_plane_states {
168 const struct drm_plane_state *r0;
169 const struct drm_plane_state *r1;
170};
171
Alan Kwong83285fb2016-10-21 20:51:17 -0400172#define to_sde_plane_state(x) \
173 container_of(x, struct sde_plane_state, base)
174
175/**
176 * sde_plane_get_property - Query integer value of plane property
177 * @S: Pointer to plane state
178 * @X: Property index, from enum msm_mdp_plane_property
179 * Returns: Integer value of requested property
180 */
Clarence Ip4a2955d2017-07-04 18:04:33 -0400181#define sde_plane_get_property(S, X) ((S) && ((X) < PLANE_PROP_COUNT) ? \
182 ((S)->property_values[(X)].value) : 0)
Alan Kwong83285fb2016-10-21 20:51:17 -0400183
184/**
185 * sde_plane_pipe - return sspp identifier for the given plane
186 * @plane: Pointer to DRM plane object
187 * Returns: sspp identifier of the given plane
188 */
189enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
190
191/**
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800192 * is_sde_plane_virtual - check for virtual plane
193 * @plane: Pointer to DRM plane object
194 * returns: true - if the plane is virtual
195 * false - if the plane is primary
196 */
197bool is_sde_plane_virtual(struct drm_plane *plane);
198
199/**
Alan Kwong4dd64c82017-02-04 18:41:51 -0800200 * sde_plane_get_ctl_flush - get control flush mask
201 * @plane: Pointer to DRM plane object
202 * @ctl: Pointer to control hardware
Clarence Ip7e5f0002017-05-29 18:46:56 -0400203 * @flush_sspp: Pointer to sspp flush control word
204 * @flush_rot: Pointer to rotator flush control word
Alan Kwong4dd64c82017-02-04 18:41:51 -0800205 */
206void sde_plane_get_ctl_flush(struct drm_plane *plane, struct sde_hw_ctl *ctl,
Clarence Ip7e5f0002017-05-29 18:46:56 -0400207 u32 *flush_sspp, u32 *flush_rot);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800208
209/**
Clarence Ipb776b532017-09-12 18:30:06 -0400210 * sde_plane_rot_calc_prefill - calculate rotator start prefill
211 * @plane: Pointer to drm plane
212 * return: prefill time in line
Alan Kwong4dd64c82017-02-04 18:41:51 -0800213 */
Clarence Ipb776b532017-09-12 18:30:06 -0400214u32 sde_plane_rot_calc_prefill(struct drm_plane *plane);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800215
216/**
Alan Kwong346223e2017-06-30 15:29:22 -0400217 * sde_plane_restore - restore hw state if previously power collapsed
218 * @plane: Pointer to drm plane structure
219 */
220void sde_plane_restore(struct drm_plane *plane);
221
222/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400223 * sde_plane_flush - final plane operations before commit flush
224 * @plane: Pointer to drm plane structure
225 */
226void sde_plane_flush(struct drm_plane *plane);
227
228/**
Clarence Ipeb39cce2017-07-19 14:12:43 -0400229 * sde_plane_kickoff - final plane operations before commit kickoff
230 * @plane: Pointer to drm plane structure
231 */
232void sde_plane_kickoff(struct drm_plane *plane);
233
234/**
Abhijit Kulkarni1b3340c2017-06-22 12:39:37 -0700235 * sde_plane_set_error: enable/disable error condition
236 * @plane: pointer to drm_plane structure
237 */
238void sde_plane_set_error(struct drm_plane *plane, bool error);
239
240/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400241 * sde_plane_init - create new sde plane for the given pipe
242 * @dev: Pointer to DRM device
243 * @pipe: sde hardware pipe identifier
244 * @primary_plane: true if this pipe is primary plane for crtc
245 * @possible_crtcs: bitmask of crtc that can be attached to the given pipe
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800246 * @master_plane_id: primary plane id of a multirect pipe. 0 value passed for
247 * a regular plane initialization. A non-zero primary plane
248 * id will be passed for a virtual pipe initialization.
249 *
Alan Kwong83285fb2016-10-21 20:51:17 -0400250 */
251struct drm_plane *sde_plane_init(struct drm_device *dev,
252 uint32_t pipe, bool primary_plane,
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800253 unsigned long possible_crtcs, u32 master_plane_id);
254
255/**
256 * sde_plane_validate_multirecti_v2 - validate the multirect planes
257 * against hw limitations
258 * @plane: drm plate states of the multirect pair
259 */
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800260int sde_plane_validate_multirect_v2(struct sde_multirect_plane_states *plane);
Alan Kwong83285fb2016-10-21 20:51:17 -0400261
262/**
Jeykumar Sankarane964dc72017-05-10 19:26:43 -0700263 * sde_plane_clear_multirect - clear multirect bits for the given pipe
264 * @drm_state: Pointer to DRM plane state
265 */
266void sde_plane_clear_multirect(const struct drm_plane_state *drm_state);
267
268/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400269 * sde_plane_wait_input_fence - wait for input fence object
270 * @plane: Pointer to DRM plane object
271 * @wait_ms: Wait timeout value
272 * Returns: Zero on success
273 */
274int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
275
276/**
277 * sde_plane_color_fill - enables color fill on plane
278 * @plane: Pointer to DRM plane object
279 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
280 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
281 * Returns: 0 on success
282 */
283int sde_plane_color_fill(struct drm_plane *plane,
284 uint32_t color, uint32_t alpha);
285
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -0700286/**
287 * sde_plane_set_revalidate - sets revalidate flag which forces a full
288 * validation of the plane properties in the next atomic check
289 * @plane: Pointer to DRM plane object
290 * @enable: Boolean to set/unset the flag
291 */
292void sde_plane_set_revalidate(struct drm_plane *plane, bool enable);
293
Alan Kwong83285fb2016-10-21 20:51:17 -0400294#endif /* _SDE_PLANE_H_ */