blob: 19b7548ead3563688507914a94ae4a92d7c5a99e [file] [log] [blame]
Dhaval Patel14d46ce2017-01-17 16:28:12 -08001/*
Veera Sundaram Sankaran7b121cb2018-03-02 08:43:04 -08002 * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
Dhaval Patel14d46ce2017-01-17 16:28:12 -08003 * 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
Jeykumar Sankaran7126ad62017-11-30 11:36:37 -0800131 * @const_alpha_en: const alpha channel is enabled for this HW pipe
Alan Kwong83285fb2016-10-21 20:51:17 -0400132 * @pending: whether the current update is still pending
Veera Sundaram Sankaran47e718f2017-09-13 16:47:23 -0700133 * @defer_prepare_fb: indicate if prepare_fb call was deferred
Clarence Ip172033f2017-06-13 10:52:56 -0400134 * @scaler3_cfg: configuration data for scaler3
135 * @pixel_ext: configuration data for pixel extensions
136 * @scaler_check_state: indicates status of user provided pixel extension data
Alan Kwong143f50c2017-04-28 07:34:28 -0700137 * @cdp_cfg: CDP configuration
Alan Kwong83285fb2016-10-21 20:51:17 -0400138 */
139struct sde_plane_state {
140 struct drm_plane_state base;
Clarence Ip4a2955d2017-07-04 18:04:33 -0400141 struct msm_property_state property_state;
142 struct msm_property_value property_values[PLANE_PROP_COUNT];
Abhijit Kulkarni333d6c02017-05-01 18:32:18 -0700143 struct msm_gem_address_space *aspace;
Alan Kwong83285fb2016-10-21 20:51:17 -0400144 void *input_fence;
145 enum sde_stage stage;
Veera Sundaram Sankaran02dd6ac2016-12-22 15:08:29 -0800146 struct sde_rect excl_rect;
Alan Kwong83285fb2016-10-21 20:51:17 -0400147 uint32_t dirty;
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800148 uint32_t multirect_index;
149 uint32_t multirect_mode;
Jeykumar Sankaran7126ad62017-11-30 11:36:37 -0800150 bool const_alpha_en;
Alan Kwong83285fb2016-10-21 20:51:17 -0400151 bool pending;
Veera Sundaram Sankaran47e718f2017-09-13 16:47:23 -0700152 bool defer_prepare_fb;
Alan Kwong4dd64c82017-02-04 18:41:51 -0800153
Clarence Ip172033f2017-06-13 10:52:56 -0400154 /* scaler configuration */
155 struct sde_hw_scaler3_cfg scaler3_cfg;
156 struct sde_hw_pixel_ext pixel_ext;
157 enum sde_plane_sclcheck_state scaler_check_state;
158
Alan Kwong4dd64c82017-02-04 18:41:51 -0800159 /* @sc_cfg: system_cache configuration */
160 struct sde_hw_pipe_sc_cfg sc_cfg;
161 struct sde_plane_rot_state rot;
Alan Kwong143f50c2017-04-28 07:34:28 -0700162
163 struct sde_hw_pipe_cdp_cfg cdp_cfg;
Alan Kwong83285fb2016-10-21 20:51:17 -0400164};
165
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800166/**
167 * struct sde_multirect_plane_states: Defines multirect pair of drm plane states
168 * @r0: drm plane configured on rect 0
169 * @r1: drm plane configured on rect 1
170 */
171struct sde_multirect_plane_states {
172 const struct drm_plane_state *r0;
173 const struct drm_plane_state *r1;
174};
175
Alan Kwong83285fb2016-10-21 20:51:17 -0400176#define to_sde_plane_state(x) \
177 container_of(x, struct sde_plane_state, base)
178
179/**
180 * sde_plane_get_property - Query integer value of plane property
181 * @S: Pointer to plane state
182 * @X: Property index, from enum msm_mdp_plane_property
183 * Returns: Integer value of requested property
184 */
Clarence Ip4a2955d2017-07-04 18:04:33 -0400185#define sde_plane_get_property(S, X) ((S) && ((X) < PLANE_PROP_COUNT) ? \
186 ((S)->property_values[(X)].value) : 0)
Alan Kwong83285fb2016-10-21 20:51:17 -0400187
188/**
189 * sde_plane_pipe - return sspp identifier for the given plane
190 * @plane: Pointer to DRM plane object
191 * Returns: sspp identifier of the given plane
192 */
193enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
194
195/**
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800196 * is_sde_plane_virtual - check for virtual plane
197 * @plane: Pointer to DRM plane object
198 * returns: true - if the plane is virtual
199 * false - if the plane is primary
200 */
201bool is_sde_plane_virtual(struct drm_plane *plane);
202
203/**
Clarence Ipa8a93eb2017-11-24 10:38:24 -0500204 * sde_plane_confirm_hw_rsvps - reserve an sbuf resource, if needed
205 * @plane: Pointer to DRM plane object
206 * @state: Pointer to plane state
Alan Kwonga15ae762017-12-16 18:03:16 -0500207 * @cstate: Pointer to crtc state containing the resource pool
Clarence Ipa8a93eb2017-11-24 10:38:24 -0500208 * Returns: Zero on success
209 */
210int sde_plane_confirm_hw_rsvps(struct drm_plane *plane,
Alan Kwonga15ae762017-12-16 18:03:16 -0500211 const struct drm_plane_state *state,
212 struct drm_crtc_state *cstate);
Clarence Ipa8a93eb2017-11-24 10:38:24 -0500213
214/**
Alan Kwong4dd64c82017-02-04 18:41:51 -0800215 * sde_plane_get_ctl_flush - get control flush mask
216 * @plane: Pointer to DRM plane object
217 * @ctl: Pointer to control hardware
Clarence Ip7e5f0002017-05-29 18:46:56 -0400218 * @flush_sspp: Pointer to sspp flush control word
219 * @flush_rot: Pointer to rotator flush control word
Alan Kwong4dd64c82017-02-04 18:41:51 -0800220 */
221void sde_plane_get_ctl_flush(struct drm_plane *plane, struct sde_hw_ctl *ctl,
Clarence Ip7e5f0002017-05-29 18:46:56 -0400222 u32 *flush_sspp, u32 *flush_rot);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800223
224/**
Clarence Ip8dece622017-12-22 18:25:25 -0500225 * sde_plane_rot_get_prefill - calculate rotator start prefill
Clarence Ipb776b532017-09-12 18:30:06 -0400226 * @plane: Pointer to drm plane
Clarence Ip8dece622017-12-22 18:25:25 -0500227 * return: prefill time in lines
Alan Kwong4dd64c82017-02-04 18:41:51 -0800228 */
Clarence Ip8dece622017-12-22 18:25:25 -0500229u32 sde_plane_rot_get_prefill(struct drm_plane *plane);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800230
231/**
Alan Kwong346223e2017-06-30 15:29:22 -0400232 * sde_plane_restore - restore hw state if previously power collapsed
233 * @plane: Pointer to drm plane structure
234 */
235void sde_plane_restore(struct drm_plane *plane);
236
237/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400238 * sde_plane_flush - final plane operations before commit flush
239 * @plane: Pointer to drm plane structure
240 */
241void sde_plane_flush(struct drm_plane *plane);
242
243/**
Clarence Ip2606dd62017-10-14 21:11:14 -0400244 * sde_plane_halt_requests - control halting of vbif transactions for this plane
245 * This function isn't thread safe. Plane halt enable/disable requests
246 * should always be made from the same commit cycle.
247 * @plane: Pointer to drm plane structure
248 * @enable: Whether to enable/disable halting of vbif transactions
249 */
250void sde_plane_halt_requests(struct drm_plane *plane, bool enable);
251
252/**
253 * sde_plane_reset_rot - reset rotator operations before commit kickoff
254 * @plane: Pointer to drm plane structure
255 * @state: Pointer to plane state associated with reset request
256 * Returns: Zero on success
257 */
258int sde_plane_reset_rot(struct drm_plane *plane, struct drm_plane_state *state);
259
260/**
Clarence Ip8ee49952017-09-20 11:10:50 -0400261 * sde_plane_kickoff_rot - final plane rotator operations before commit kickoff
Clarence Ipeb39cce2017-07-19 14:12:43 -0400262 * @plane: Pointer to drm plane structure
Clarence Ip8ee49952017-09-20 11:10:50 -0400263 * Returns: Zero on success
Clarence Ipeb39cce2017-07-19 14:12:43 -0400264 */
Clarence Ip8ee49952017-09-20 11:10:50 -0400265int sde_plane_kickoff_rot(struct drm_plane *plane);
Clarence Ipeb39cce2017-07-19 14:12:43 -0400266
267/**
Abhijit Kulkarni1b3340c2017-06-22 12:39:37 -0700268 * sde_plane_set_error: enable/disable error condition
269 * @plane: pointer to drm_plane structure
270 */
271void sde_plane_set_error(struct drm_plane *plane, bool error);
272
273/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400274 * sde_plane_init - create new sde plane for the given pipe
275 * @dev: Pointer to DRM device
276 * @pipe: sde hardware pipe identifier
277 * @primary_plane: true if this pipe is primary plane for crtc
278 * @possible_crtcs: bitmask of crtc that can be attached to the given pipe
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800279 * @master_plane_id: primary plane id of a multirect pipe. 0 value passed for
280 * a regular plane initialization. A non-zero primary plane
281 * id will be passed for a virtual pipe initialization.
282 *
Alan Kwong83285fb2016-10-21 20:51:17 -0400283 */
284struct drm_plane *sde_plane_init(struct drm_device *dev,
285 uint32_t pipe, bool primary_plane,
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800286 unsigned long possible_crtcs, u32 master_plane_id);
287
288/**
289 * sde_plane_validate_multirecti_v2 - validate the multirect planes
290 * against hw limitations
291 * @plane: drm plate states of the multirect pair
292 */
Jeykumar Sankaran2e655032017-02-04 14:05:45 -0800293int sde_plane_validate_multirect_v2(struct sde_multirect_plane_states *plane);
Alan Kwong83285fb2016-10-21 20:51:17 -0400294
295/**
Jeykumar Sankarane964dc72017-05-10 19:26:43 -0700296 * sde_plane_clear_multirect - clear multirect bits for the given pipe
297 * @drm_state: Pointer to DRM plane state
298 */
299void sde_plane_clear_multirect(const struct drm_plane_state *drm_state);
300
301/**
Alan Kwong83285fb2016-10-21 20:51:17 -0400302 * sde_plane_wait_input_fence - wait for input fence object
303 * @plane: Pointer to DRM plane object
304 * @wait_ms: Wait timeout value
305 * Returns: Zero on success
306 */
307int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
308
309/**
310 * sde_plane_color_fill - enables color fill on plane
311 * @plane: Pointer to DRM plane object
312 * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
313 * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
314 * Returns: 0 on success
315 */
316int sde_plane_color_fill(struct drm_plane *plane,
317 uint32_t color, uint32_t alpha);
318
Veera Sundaram Sankaran82916e02017-03-29 18:44:22 -0700319/**
320 * sde_plane_set_revalidate - sets revalidate flag which forces a full
321 * validation of the plane properties in the next atomic check
322 * @plane: Pointer to DRM plane object
323 * @enable: Boolean to set/unset the flag
324 */
325void sde_plane_set_revalidate(struct drm_plane *plane, bool enable);
326
Lloyd Atkinsone08229c2017-10-02 17:53:30 -0400327/**
328 * sde_plane_helper_reset_properties - reset properties to default values in the
329 * given DRM plane state object
330 * @plane: Pointer to DRM plane object
331 * @plane_state: Pointer to DRM plane state object
332 * Returns: 0 on success, negative errno on failure
333 */
334int sde_plane_helper_reset_custom_properties(struct drm_plane *plane,
335 struct drm_plane_state *plane_state);
336
Veera Sundaram Sankaran7b121cb2018-03-02 08:43:04 -0800337/**
338 * sde_plane_is_sec_ui_allowed - indicates if the sspp allows secure-ui layers
339 * @plane: Pointer to DRM plane object
340 * Returns: true if allowed; false otherwise
341 */
342bool sde_plane_is_sec_ui_allowed(struct drm_plane *plane);
343
Alan Kwong83285fb2016-10-21 20:51:17 -0400344#endif /* _SDE_PLANE_H_ */