• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4  * Copyright (C) 2013 Red Hat
5  * Author: Rob Clark <robdclark@gmail.com>
6  */
7 
8 #ifndef _DPU_PLANE_H_
9 #define _DPU_PLANE_H_
10 
11 #include <drm/drm_crtc.h>
12 
13 #include "dpu_kms.h"
14 #include "dpu_hw_mdss.h"
15 #include "dpu_hw_sspp.h"
16 
17 /**
18  * struct dpu_plane_state: Define dpu extension of drm plane state object
19  * @base:	base drm plane state object
20  * @aspace:	pointer to address space for input/output buffers
21  * @stage:	assigned by crtc blender
22  * @needs_qos_remap: qos remap settings need to be updated
23  * @multirect_index: index of the rectangle of SSPP
24  * @multirect_mode: parallel or time multiplex multirect mode
25  * @pending:	whether the current update is still pending
26  * @scaler3_cfg: configuration data for scaler3
27  * @pixel_ext: configuration data for pixel extensions
28  * @cdp_cfg:	CDP configuration
29  * @plane_fetch_bw: calculated BW per plane
30  * @plane_clk: calculated clk per plane
31  * @needs_dirtyfb: whether attached CRTC needs pixel data explicitly flushed
32  */
33 struct dpu_plane_state {
34 	struct drm_plane_state base;
35 	struct msm_gem_address_space *aspace;
36 	enum dpu_stage stage;
37 	bool needs_qos_remap;
38 	uint32_t multirect_index;
39 	uint32_t multirect_mode;
40 	bool pending;
41 
42 	/* scaler configuration */
43 	struct dpu_hw_scaler3_cfg scaler3_cfg;
44 	struct dpu_hw_pixel_ext pixel_ext;
45 
46 	struct dpu_hw_pipe_cdp_cfg cdp_cfg;
47 	u64 plane_fetch_bw;
48 	u64 plane_clk;
49 
50 	bool needs_dirtyfb;
51 };
52 
53 /**
54  * struct dpu_multirect_plane_states: Defines multirect pair of drm plane states
55  * @r0: drm plane configured on rect 0
56  * @r1: drm plane configured on rect 1
57  */
58 struct dpu_multirect_plane_states {
59 	const struct drm_plane_state *r0;
60 	const struct drm_plane_state *r1;
61 };
62 
63 #define to_dpu_plane_state(x) \
64 	container_of(x, struct dpu_plane_state, base)
65 
66 /**
67  * dpu_plane_pipe - return sspp identifier for the given plane
68  * @plane:   Pointer to DRM plane object
69  * Returns: sspp identifier of the given plane
70  */
71 enum dpu_sspp dpu_plane_pipe(struct drm_plane *plane);
72 
73 /**
74  * is_dpu_plane_virtual - check for virtual plane
75  * @plane: Pointer to DRM plane object
76  * returns: true - if the plane is virtual
77  *          false - if the plane is primary
78  */
79 bool is_dpu_plane_virtual(struct drm_plane *plane);
80 
81 /**
82  * dpu_plane_get_ctl_flush - get control flush mask
83  * @plane:   Pointer to DRM plane object
84  * @ctl: Pointer to control hardware
85  * @flush_sspp: Pointer to sspp flush control word
86  */
87 void dpu_plane_get_ctl_flush(struct drm_plane *plane, struct dpu_hw_ctl *ctl,
88 		u32 *flush_sspp);
89 
90 /**
91  * dpu_plane_flush - final plane operations before commit flush
92  * @plane: Pointer to drm plane structure
93  */
94 void dpu_plane_flush(struct drm_plane *plane);
95 
96 /**
97  * dpu_plane_set_error: enable/disable error condition
98  * @plane: pointer to drm_plane structure
99  */
100 void dpu_plane_set_error(struct drm_plane *plane, bool error);
101 
102 /**
103  * dpu_plane_init - create new dpu plane for the given pipe
104  * @dev:   Pointer to DRM device
105  * @pipe:  dpu hardware pipe identifier
106  * @type:  Plane type - PRIMARY/OVERLAY/CURSOR
107  * @possible_crtcs: bitmask of crtc that can be attached to the given pipe
108  * @master_plane_id: primary plane id of a multirect pipe. 0 value passed for
109  *                   a regular plane initialization. A non-zero primary plane
110  *                   id will be passed for a virtual pipe initialization.
111  *
112  */
113 struct drm_plane *dpu_plane_init(struct drm_device *dev,
114 		uint32_t pipe, enum drm_plane_type type,
115 		unsigned long possible_crtcs, u32 master_plane_id);
116 
117 /**
118  * dpu_plane_validate_multirecti_v2 - validate the multirect planes
119  *				      against hw limitations
120  * @plane: drm plate states of the multirect pair
121  */
122 int dpu_plane_validate_multirect_v2(struct dpu_multirect_plane_states *plane);
123 
124 /**
125  * dpu_plane_clear_multirect - clear multirect bits for the given pipe
126  * @drm_state: Pointer to DRM plane state
127  */
128 void dpu_plane_clear_multirect(const struct drm_plane_state *drm_state);
129 
130 /**
131  * dpu_plane_color_fill - enables color fill on plane
132  * @plane:  Pointer to DRM plane object
133  * @color:  RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
134  * @alpha:  8-bit fill alpha value, 255 selects 100% alpha
135  * Returns: 0 on success
136  */
137 int dpu_plane_color_fill(struct drm_plane *plane,
138 		uint32_t color, uint32_t alpha);
139 
140 #endif /* _DPU_PLANE_H_ */
141