This source file includes following definitions.
- is_writeback_only
- is_only_changed_connector
- has_flip_h
1
2
3
4
5
6
7 #ifndef _KOMEDA_KMS_H_
8 #define _KOMEDA_KMS_H_
9
10 #include <linux/list.h>
11 #include <drm/drm_atomic.h>
12 #include <drm/drm_atomic_helper.h>
13 #include <drm/drm_crtc_helper.h>
14 #include <drm/drm_device.h>
15 #include <drm/drm_writeback.h>
16 #include <drm/drm_print.h>
17
18
19
20
21 struct komeda_plane {
22
23 struct drm_plane base;
24
25
26
27
28
29
30
31
32
33 struct komeda_layer *layer;
34 };
35
36
37
38
39
40
41
42 struct komeda_plane_state {
43
44 struct drm_plane_state base;
45
46 struct list_head zlist_node;
47
48
49 u8 layer_split : 1;
50 };
51
52
53
54
55 struct komeda_wb_connector {
56
57 struct drm_writeback_connector base;
58
59
60 struct komeda_layer *wb_layer;
61 };
62
63
64
65
66 struct komeda_crtc {
67
68 struct drm_crtc base;
69
70 struct komeda_pipeline *master;
71
72
73
74
75
76
77 struct komeda_pipeline *slave;
78
79
80 u32 slave_planes;
81
82
83 struct komeda_wb_connector *wb_conn;
84
85
86 struct completion *disable_done;
87 };
88
89
90
91
92 struct komeda_crtc_state {
93
94 struct drm_crtc_state base;
95
96
97
98
99
100
101
102
103 u32 affected_pipes;
104
105
106
107
108 u32 active_pipes;
109
110
111 u64 clock_ratio;
112
113
114 u32 max_slave_zorder;
115 };
116
117
118 struct komeda_kms_dev {
119
120 struct drm_device base;
121
122
123 int n_crtcs;
124
125 struct komeda_crtc crtcs[KOMEDA_MAX_PIPELINES];
126 };
127
128 #define to_kplane(p) container_of(p, struct komeda_plane, base)
129 #define to_kplane_st(p) container_of(p, struct komeda_plane_state, base)
130 #define to_kconn(p) container_of(p, struct komeda_wb_connector, base)
131 #define to_kcrtc(p) container_of(p, struct komeda_crtc, base)
132 #define to_kcrtc_st(p) container_of(p, struct komeda_crtc_state, base)
133 #define to_kdev(p) container_of(p, struct komeda_kms_dev, base)
134 #define to_wb_conn(x) container_of(x, struct drm_writeback_connector, base)
135
136 static inline bool is_writeback_only(struct drm_crtc_state *st)
137 {
138 struct komeda_wb_connector *wb_conn = to_kcrtc(st->crtc)->wb_conn;
139 struct drm_connector *conn = wb_conn ? &wb_conn->base.base : NULL;
140
141 return conn && (st->connector_mask == BIT(drm_connector_index(conn)));
142 }
143
144 static inline bool
145 is_only_changed_connector(struct drm_crtc_state *st, struct drm_connector *conn)
146 {
147 struct drm_crtc_state *old_st;
148 u32 changed_connectors;
149
150 old_st = drm_atomic_get_old_crtc_state(st->state, st->crtc);
151 changed_connectors = st->connector_mask ^ old_st->connector_mask;
152
153 return BIT(drm_connector_index(conn)) == changed_connectors;
154 }
155
156 static inline bool has_flip_h(u32 rot)
157 {
158 u32 rotation = drm_rotation_simplify(rot,
159 DRM_MODE_ROTATE_0 |
160 DRM_MODE_ROTATE_90 |
161 DRM_MODE_REFLECT_MASK);
162
163 if (rotation & DRM_MODE_ROTATE_90)
164 return !!(rotation & DRM_MODE_REFLECT_Y);
165 else
166 return !!(rotation & DRM_MODE_REFLECT_X);
167 }
168
169 unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st);
170
171 int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
172
173 int komeda_kms_add_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
174 int komeda_kms_add_planes(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
175 int komeda_kms_add_private_objs(struct komeda_kms_dev *kms,
176 struct komeda_dev *mdev);
177 int komeda_kms_add_wb_connectors(struct komeda_kms_dev *kms,
178 struct komeda_dev *mdev);
179 void komeda_kms_cleanup_private_objs(struct komeda_kms_dev *kms);
180
181 void komeda_crtc_handle_event(struct komeda_crtc *kcrtc,
182 struct komeda_events *evts);
183
184 struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev);
185 void komeda_kms_detach(struct komeda_kms_dev *kms);
186
187 #endif