• 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  * @multirect_index: index of the rectangle of SSPP
23  * @multirect_mode: parallel or time multiplex multirect mode
24  * @pending:	whether the current update is still pending
25  * @scaler3_cfg: configuration data for scaler3
26  * @pixel_ext: configuration data for pixel extensions
27  * @cdp_cfg:	CDP configuration
28  * @plane_fetch_bw: calculated BW per plane
29  * @plane_clk: calculated clk per plane
30  */
31 struct dpu_plane_state {
32 	struct drm_plane_state base;
33 	struct msm_gem_address_space *aspace;
34 	enum dpu_stage stage;
35 	uint32_t multirect_index;
36 	uint32_t multirect_mode;
37 	bool pending;
38 
39 	/* scaler configuration */
40 	struct dpu_hw_scaler3_cfg scaler3_cfg;
41 	struct dpu_hw_pixel_ext pixel_ext;
42 
43 	struct dpu_hw_pipe_cdp_cfg cdp_cfg;
44 	u64 plane_fetch_bw;
45 	u64 plane_clk;
46 };
47 
48 /**
49  * struct dpu_multirect_plane_states: Defines multirect pair of drm plane states
50  * @r0: drm plane configured on rect 0
51  * @r1: drm plane configured on rect 1
52  */
53 struct dpu_multirect_plane_states {
54 	const struct drm_plane_state *r0;
55 	const struct drm_plane_state *r1;
56 };
57 
58 #define to_dpu_plane_state(x) \
59 	container_of(x, struct dpu_plane_state, base)
60 
61 /**
62  * dpu_plane_pipe - return sspp identifier for the given plane
63  * @plane:   Pointer to DRM plane object
64  * Returns: sspp identifier of the given plane
65  */
66 enum dpu_sspp dpu_plane_pipe(struct drm_plane *plane);
67 
68 /**
69  * is_dpu_plane_virtual - check for virtual plane
70  * @plane: Pointer to DRM plane object
71  * returns: true - if the plane is virtual
72  *          false - if the plane is primary
73  */
74 bool is_dpu_plane_virtual(struct drm_plane *plane);
75 
76 /**
77  * dpu_plane_get_ctl_flush - get control flush mask
78  * @plane:   Pointer to DRM plane object
79  * @ctl: Pointer to control hardware
80  * @flush_sspp: Pointer to sspp flush control word
81  */
82 void dpu_plane_get_ctl_flush(struct drm_plane *plane, struct dpu_hw_ctl *ctl,
83 		u32 *flush_sspp);
84 
85 /**
86  * dpu_plane_restore - restore hw state if previously power collapsed
87  * @plane: Pointer to drm plane structure
88  */
89 void dpu_plane_restore(struct drm_plane *plane);
90 
91 /**
92  * dpu_plane_flush - final plane operations before commit flush
93  * @plane: Pointer to drm plane structure
94  */
95 void dpu_plane_flush(struct drm_plane *plane);
96 
97 /**
98  * dpu_plane_set_error: enable/disable error condition
99  * @plane: pointer to drm_plane structure
100  */
101 void dpu_plane_set_error(struct drm_plane *plane, bool error);
102 
103 /**
104  * dpu_plane_init - create new dpu plane for the given pipe
105  * @dev:   Pointer to DRM device
106  * @pipe:  dpu hardware pipe identifier
107  * @type:  Plane type - PRIMARY/OVERLAY/CURSOR
108  * @possible_crtcs: bitmask of crtc that can be attached to the given pipe
109  * @master_plane_id: primary plane id of a multirect pipe. 0 value passed for
110  *                   a regular plane initialization. A non-zero primary plane
111  *                   id will be passed for a virtual pipe initialization.
112  *
113  */
114 struct drm_plane *dpu_plane_init(struct drm_device *dev,
115 		uint32_t pipe, enum drm_plane_type type,
116 		unsigned long possible_crtcs, u32 master_plane_id);
117 
118 /**
119  * dpu_plane_validate_multirecti_v2 - validate the multirect planes
120  *				      against hw limitations
121  * @plane: drm plate states of the multirect pair
122  */
123 int dpu_plane_validate_multirect_v2(struct dpu_multirect_plane_states *plane);
124 
125 /**
126  * dpu_plane_clear_multirect - clear multirect bits for the given pipe
127  * @drm_state: Pointer to DRM plane state
128  */
129 void dpu_plane_clear_multirect(const struct drm_plane_state *drm_state);
130 
131 /**
132  * dpu_plane_color_fill - enables color fill on plane
133  * @plane:  Pointer to DRM plane object
134  * @color:  RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
135  * @alpha:  8-bit fill alpha value, 255 selects 100% alpha
136  * Returns: 0 on success
137  */
138 int dpu_plane_color_fill(struct drm_plane *plane,
139 		uint32_t color, uint32_t alpha);
140 
141 #endif /* _DPU_PLANE_H_ */
142