This source file includes following definitions.
- component_disabling_inputs
- component_changed_inputs
- __printf
1
2
3
4
5
6
7 #ifndef _KOMEDA_PIPELINE_H_
8 #define _KOMEDA_PIPELINE_H_
9
10 #include <linux/types.h>
11 #include <drm/drm_atomic.h>
12 #include <drm/drm_atomic_helper.h>
13 #include "malidp_utils.h"
14
15 #define KOMEDA_MAX_PIPELINES 2
16 #define KOMEDA_PIPELINE_MAX_LAYERS 4
17 #define KOMEDA_PIPELINE_MAX_SCALERS 2
18 #define KOMEDA_COMPONENT_N_INPUTS 5
19
20
21 enum {
22 KOMEDA_COMPONENT_LAYER0 = 0,
23 KOMEDA_COMPONENT_LAYER1 = 1,
24 KOMEDA_COMPONENT_LAYER2 = 2,
25 KOMEDA_COMPONENT_LAYER3 = 3,
26 KOMEDA_COMPONENT_WB_LAYER = 7,
27 KOMEDA_COMPONENT_SCALER0 = 8,
28 KOMEDA_COMPONENT_SCALER1 = 9,
29 KOMEDA_COMPONENT_SPLITTER = 12,
30 KOMEDA_COMPONENT_MERGER = 14,
31 KOMEDA_COMPONENT_COMPIZ0 = 16,
32 KOMEDA_COMPONENT_COMPIZ1 = 17,
33 KOMEDA_COMPONENT_IPS0 = 20,
34 KOMEDA_COMPONENT_IPS1 = 21,
35 KOMEDA_COMPONENT_TIMING_CTRLR = 22,
36 };
37
38 #define KOMEDA_PIPELINE_LAYERS (BIT(KOMEDA_COMPONENT_LAYER0) |\
39 BIT(KOMEDA_COMPONENT_LAYER1) |\
40 BIT(KOMEDA_COMPONENT_LAYER2) |\
41 BIT(KOMEDA_COMPONENT_LAYER3))
42
43 #define KOMEDA_PIPELINE_SCALERS (BIT(KOMEDA_COMPONENT_SCALER0) |\
44 BIT(KOMEDA_COMPONENT_SCALER1))
45
46 #define KOMEDA_PIPELINE_COMPIZS (BIT(KOMEDA_COMPONENT_COMPIZ0) |\
47 BIT(KOMEDA_COMPONENT_COMPIZ1))
48
49 #define KOMEDA_PIPELINE_IMPROCS (BIT(KOMEDA_COMPONENT_IPS0) |\
50 BIT(KOMEDA_COMPONENT_IPS1))
51 struct komeda_component;
52 struct komeda_component_state;
53
54
55 struct komeda_component_funcs {
56
57
58
59
60 int (*validate)(struct komeda_component *c,
61 struct komeda_component_state *state);
62
63 void (*update)(struct komeda_component *c,
64 struct komeda_component_state *state);
65
66 void (*disable)(struct komeda_component *c);
67
68 void (*dump_register)(struct komeda_component *c, struct seq_file *seq);
69 };
70
71
72
73
74
75
76
77
78 struct komeda_component {
79
80 struct drm_private_obj obj;
81
82 struct komeda_pipeline *pipeline;
83
84 char name[32];
85
86
87
88
89
90 u32 __iomem *reg;
91
92 u32 id;
93
94
95
96
97 u32 hw_id;
98
99
100
101
102
103
104
105
106
107
108
109 u8 max_active_inputs;
110
111 u8 max_active_outputs;
112
113
114
115
116
117
118
119
120 u32 supported_inputs;
121
122 u32 supported_outputs;
123
124
125
126
127 const struct komeda_component_funcs *funcs;
128 };
129
130
131
132
133
134
135
136
137 struct komeda_component_output {
138
139 struct komeda_component *component;
140
141
142
143
144 u8 output_port;
145 };
146
147
148
149
150
151
152
153
154 struct komeda_component_state {
155
156 struct drm_private_state obj;
157
158 struct komeda_component *component;
159
160
161
162
163
164
165
166
167
168
169 union {
170
171 struct drm_crtc *crtc;
172
173 struct drm_plane *plane;
174
175 struct drm_connector *wb_conn;
176 void *binding_user;
177 };
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194 u16 active_inputs;
195
196 u16 changed_active_inputs;
197
198 u16 affected_inputs;
199
200
201
202
203
204
205 struct komeda_component_output inputs[KOMEDA_COMPONENT_N_INPUTS];
206 };
207
208 static inline u16 component_disabling_inputs(struct komeda_component_state *st)
209 {
210 return st->affected_inputs ^ st->active_inputs;
211 }
212
213 static inline u16 component_changed_inputs(struct komeda_component_state *st)
214 {
215 return component_disabling_inputs(st) | st->changed_active_inputs;
216 }
217
218 #define for_each_changed_input(st, i) \
219 for ((i) = 0; (i) < (st)->component->max_active_inputs; (i)++) \
220 if (has_bit((i), component_changed_inputs(st)))
221
222 #define to_comp(__c) (((__c) == NULL) ? NULL : &((__c)->base))
223 #define to_cpos(__c) ((struct komeda_component **)&(__c))
224
225 struct komeda_layer {
226 struct komeda_component base;
227
228 struct malidp_range hsize_in, vsize_in;
229 u32 layer_type;
230 u32 supported_rots;
231
232
233
234
235
236 struct komeda_layer *right;
237 };
238
239 struct komeda_layer_state {
240 struct komeda_component_state base;
241
242 u16 hsize, vsize;
243 u32 rot;
244 u16 afbc_crop_l;
245 u16 afbc_crop_r;
246 u16 afbc_crop_t;
247 u16 afbc_crop_b;
248 dma_addr_t addr[3];
249 };
250
251 struct komeda_scaler {
252 struct komeda_component base;
253 struct malidp_range hsize, vsize;
254 u32 max_upscaling;
255 u32 max_downscaling;
256 u8 scaling_split_overlap;
257 u8 enh_split_overlap;
258 };
259
260 struct komeda_scaler_state {
261 struct komeda_component_state base;
262 u16 hsize_in, vsize_in;
263 u16 hsize_out, vsize_out;
264 u16 total_hsize_in, total_vsize_in;
265 u16 total_hsize_out;
266 u16 left_crop, right_crop;
267 u8 en_scaling : 1,
268 en_alpha : 1,
269 en_img_enhancement : 1,
270 en_split : 1,
271 right_part : 1;
272 };
273
274 struct komeda_compiz {
275 struct komeda_component base;
276 struct malidp_range hsize, vsize;
277 };
278
279 struct komeda_compiz_input_cfg {
280 u16 hsize, vsize;
281 u16 hoffset, voffset;
282 u8 pixel_blend_mode, layer_alpha;
283 };
284
285 struct komeda_compiz_state {
286 struct komeda_component_state base;
287
288 u16 hsize, vsize;
289 struct komeda_compiz_input_cfg cins[KOMEDA_COMPONENT_N_INPUTS];
290 };
291
292 struct komeda_merger {
293 struct komeda_component base;
294 struct malidp_range hsize_merged;
295 struct malidp_range vsize_merged;
296 };
297
298 struct komeda_merger_state {
299 struct komeda_component_state base;
300 u16 hsize_merged;
301 u16 vsize_merged;
302 };
303
304 struct komeda_splitter {
305 struct komeda_component base;
306 struct malidp_range hsize, vsize;
307 };
308
309 struct komeda_splitter_state {
310 struct komeda_component_state base;
311 u16 hsize, vsize;
312 u16 overlap;
313 };
314
315 struct komeda_improc {
316 struct komeda_component base;
317 u32 supported_color_formats;
318 u32 supported_color_depths;
319 u8 supports_degamma : 1;
320 u8 supports_csc : 1;
321 u8 supports_gamma : 1;
322 };
323
324 struct komeda_improc_state {
325 struct komeda_component_state base;
326 u16 hsize, vsize;
327 };
328
329
330 struct komeda_timing_ctrlr {
331 struct komeda_component base;
332 u8 supports_dual_link : 1;
333 };
334
335 struct komeda_timing_ctrlr_state {
336 struct komeda_component_state base;
337 };
338
339
340
341
342
343
344
345
346 struct komeda_data_flow_cfg {
347 struct komeda_component_output input;
348 u16 in_x, in_y, in_w, in_h;
349 u32 out_x, out_y, out_w, out_h;
350 u16 total_in_h, total_in_w;
351 u16 total_out_w;
352 u16 left_crop, right_crop, overlap;
353 u32 rot;
354 int blending_zorder;
355 u8 pixel_blend_mode, layer_alpha;
356 u8 en_scaling : 1,
357 en_img_enhancement : 1,
358 en_split : 1,
359 is_yuv : 1,
360 right_part : 1;
361 };
362
363 struct komeda_pipeline_funcs {
364
365
366
367 int (*downscaling_clk_check)(struct komeda_pipeline *pipe,
368 struct drm_display_mode *mode,
369 unsigned long aclk_rate,
370 struct komeda_data_flow_cfg *dflow);
371
372 void (*dump_register)(struct komeda_pipeline *pipe,
373 struct seq_file *sf);
374 };
375
376
377
378
379
380
381 struct komeda_pipeline {
382
383 struct drm_private_obj obj;
384
385 struct komeda_dev *mdev;
386
387 struct clk *pxlclk;
388
389 int id;
390
391 u32 avail_comps;
392
393 int n_layers;
394
395 struct komeda_layer *layers[KOMEDA_PIPELINE_MAX_LAYERS];
396
397 int n_scalers;
398
399 struct komeda_scaler *scalers[KOMEDA_PIPELINE_MAX_SCALERS];
400
401 struct komeda_compiz *compiz;
402
403 struct komeda_splitter *splitter;
404
405 struct komeda_merger *merger;
406
407 struct komeda_layer *wb_layer;
408
409 struct komeda_improc *improc;
410
411 struct komeda_timing_ctrlr *ctrlr;
412
413 const struct komeda_pipeline_funcs *funcs;
414
415
416 struct device_node *of_node;
417
418 struct device_node *of_output_port;
419
420 struct device_node *of_output_links[2];
421
422 bool dual_link;
423 };
424
425
426
427
428
429
430
431
432 struct komeda_pipeline_state {
433
434 struct drm_private_state obj;
435
436 struct komeda_pipeline *pipe;
437
438 struct drm_crtc *crtc;
439
440
441
442
443
444 u32 active_comps;
445 };
446
447 #define to_layer(c) container_of(c, struct komeda_layer, base)
448 #define to_compiz(c) container_of(c, struct komeda_compiz, base)
449 #define to_scaler(c) container_of(c, struct komeda_scaler, base)
450 #define to_splitter(c) container_of(c, struct komeda_splitter, base)
451 #define to_merger(c) container_of(c, struct komeda_merger, base)
452 #define to_improc(c) container_of(c, struct komeda_improc, base)
453 #define to_ctrlr(c) container_of(c, struct komeda_timing_ctrlr, base)
454
455 #define to_layer_st(c) container_of(c, struct komeda_layer_state, base)
456 #define to_compiz_st(c) container_of(c, struct komeda_compiz_state, base)
457 #define to_scaler_st(c) container_of(c, struct komeda_scaler_state, base)
458 #define to_splitter_st(c) container_of(c, struct komeda_splitter_state, base)
459 #define to_merger_st(c) container_of(c, struct komeda_merger_state, base)
460 #define to_improc_st(c) container_of(c, struct komeda_improc_state, base)
461 #define to_ctrlr_st(c) container_of(c, struct komeda_timing_ctrlr_state, base)
462
463 #define priv_to_comp_st(o) container_of(o, struct komeda_component_state, obj)
464 #define priv_to_pipe_st(o) container_of(o, struct komeda_pipeline_state, obj)
465
466
467 struct komeda_pipeline *
468 komeda_pipeline_add(struct komeda_dev *mdev, size_t size,
469 const struct komeda_pipeline_funcs *funcs);
470 void komeda_pipeline_destroy(struct komeda_dev *mdev,
471 struct komeda_pipeline *pipe);
472 struct komeda_pipeline *
473 komeda_pipeline_get_slave(struct komeda_pipeline *master);
474 int komeda_assemble_pipelines(struct komeda_dev *mdev);
475 struct komeda_component *
476 komeda_pipeline_get_component(struct komeda_pipeline *pipe, int id);
477 struct komeda_component *
478 komeda_pipeline_get_first_component(struct komeda_pipeline *pipe,
479 u32 comp_mask);
480
481 void komeda_pipeline_dump_register(struct komeda_pipeline *pipe,
482 struct seq_file *sf);
483
484
485 extern __printf(10, 11)
486 struct komeda_component *
487 komeda_component_add(struct komeda_pipeline *pipe,
488 size_t comp_sz, u32 id, u32 hw_id,
489 const struct komeda_component_funcs *funcs,
490 u8 max_active_inputs, u32 supported_inputs,
491 u8 max_active_outputs, u32 __iomem *reg,
492 const char *name_fmt, ...);
493
494 void komeda_component_destroy(struct komeda_dev *mdev,
495 struct komeda_component *c);
496
497 static inline struct komeda_component *
498 komeda_component_pickup_output(struct komeda_component *c, u32 avail_comps)
499 {
500 u32 avail_inputs = c->supported_outputs & (avail_comps);
501
502 return komeda_pipeline_get_first_component(c->pipeline, avail_inputs);
503 }
504
505 struct komeda_plane_state;
506 struct komeda_crtc_state;
507 struct komeda_crtc;
508
509 void pipeline_composition_size(struct komeda_crtc_state *kcrtc_st,
510 u16 *hsize, u16 *vsize);
511
512 int komeda_build_layer_data_flow(struct komeda_layer *layer,
513 struct komeda_plane_state *kplane_st,
514 struct komeda_crtc_state *kcrtc_st,
515 struct komeda_data_flow_cfg *dflow);
516 int komeda_build_wb_data_flow(struct komeda_layer *wb_layer,
517 struct drm_connector_state *conn_st,
518 struct komeda_crtc_state *kcrtc_st,
519 struct komeda_data_flow_cfg *dflow);
520 int komeda_build_display_data_flow(struct komeda_crtc *kcrtc,
521 struct komeda_crtc_state *kcrtc_st);
522
523 int komeda_build_layer_split_data_flow(struct komeda_layer *left,
524 struct komeda_plane_state *kplane_st,
525 struct komeda_crtc_state *kcrtc_st,
526 struct komeda_data_flow_cfg *dflow);
527 int komeda_build_wb_split_data_flow(struct komeda_layer *wb_layer,
528 struct drm_connector_state *conn_st,
529 struct komeda_crtc_state *kcrtc_st,
530 struct komeda_data_flow_cfg *dflow);
531
532 int komeda_release_unclaimed_resources(struct komeda_pipeline *pipe,
533 struct komeda_crtc_state *kcrtc_st);
534
535 struct komeda_pipeline_state *
536 komeda_pipeline_get_old_state(struct komeda_pipeline *pipe,
537 struct drm_atomic_state *state);
538 void komeda_pipeline_disable(struct komeda_pipeline *pipe,
539 struct drm_atomic_state *old_state);
540 void komeda_pipeline_update(struct komeda_pipeline *pipe,
541 struct drm_atomic_state *old_state);
542
543 void komeda_complete_data_flow_cfg(struct komeda_layer *layer,
544 struct komeda_data_flow_cfg *dflow,
545 struct drm_framebuffer *fb);
546
547 #endif