xref: /linux/drivers/gpu/drm/imx/dc/dc-pe.h (revision 260f6f4fda93c8485c8037865c941b42b9cba5d2)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2024 NXP
4  */
5 
6 #ifndef __DC_PIXEL_ENGINE_H__
7 #define __DC_PIXEL_ENGINE_H__
8 
9 #include <linux/clk.h>
10 #include <linux/device.h>
11 #include <linux/regmap.h>
12 
13 #include "dc-de.h"
14 
15 #define SHDEN			BIT(0)
16 
17 #define CLKEN_MASK_SHIFT	24
18 #define CLKEN_MASK		(0x3 << CLKEN_MASK_SHIFT)
19 #define CLKEN(n)		((n) << CLKEN_MASK_SHIFT)
20 
21 #define DC_DISP_FU_CNT		2
22 #define DC_LB_CNT		4
23 
24 enum dc_link_id {
25 	LINK_ID_NONE		= 0x00,
26 	LINK_ID_CONSTFRAME0	= 0x0c,
27 	LINK_ID_CONSTFRAME4	= 0x0e,
28 	LINK_ID_CONSTFRAME1	= 0x10,
29 	LINK_ID_CONSTFRAME5	= 0x12,
30 	LINK_ID_FETCHWARP2	= 0x14,
31 	LINK_ID_FETCHLAYER0	= 0x1a,
32 	LINK_ID_LAYERBLEND0	= 0x21,
33 	LINK_ID_LAYERBLEND1	= 0x22,
34 	LINK_ID_LAYERBLEND2	= 0x23,
35 	LINK_ID_LAYERBLEND3	= 0x24,
36 };
37 
38 enum dc_lb_mode {
39 	LB_NEUTRAL,	/* Output is same as primary input. */
40 	LB_BLEND,
41 };
42 
43 enum dc_pec_clken {
44 	CLKEN_DISABLE,
45 	CLKEN_AUTOMATIC,
46 };
47 
48 struct dc_cf {
49 	struct regmap *reg_cfg;
50 	enum dc_link_id link;
51 };
52 
53 struct dc_ed {
54 	struct device *dev;
55 	struct regmap *reg_pec;
56 	struct regmap *reg_cfg;
57 	int irq_shdload;
58 };
59 
60 struct dc_lb {
61 	struct device *dev;
62 	struct regmap *reg_pec;
63 	struct regmap *reg_cfg;
64 	int id;
65 	enum dc_link_id link;
66 };
67 
68 struct dc_pe {
69 	struct device *dev;
70 	struct clk *clk_axi;
71 	struct dc_cf *cf_safe[DC_DISPLAYS];
72 	struct dc_cf *cf_cont[DC_DISPLAYS];
73 	struct dc_ed *ed_safe[DC_DISPLAYS];
74 	struct dc_ed *ed_cont[DC_DISPLAYS];
75 	struct dc_fu *fu_disp[DC_DISP_FU_CNT];
76 	struct dc_lb *lb[DC_LB_CNT];
77 };
78 
79 /* Constant Frame Unit */
80 enum dc_link_id dc_cf_get_link_id(struct dc_cf *cf);
81 void dc_cf_framedimensions(struct dc_cf *cf, unsigned int w, unsigned int h);
82 void dc_cf_constantcolor_black(struct dc_cf *cf);
83 void dc_cf_constantcolor_blue(struct dc_cf *cf);
84 void dc_cf_init(struct dc_cf *cf);
85 
86 /* External Destination Unit */
87 void dc_ed_pec_src_sel(struct dc_ed *ed, enum dc_link_id src);
88 void dc_ed_pec_sync_trigger(struct dc_ed *ed);
89 void dc_ed_init(struct dc_ed *ed);
90 
91 /* Layer Blend Unit */
92 enum dc_link_id dc_lb_get_link_id(struct dc_lb *lb);
93 void dc_lb_pec_dynamic_prim_sel(struct dc_lb *lb, enum dc_link_id prim);
94 void dc_lb_pec_dynamic_sec_sel(struct dc_lb *lb, enum dc_link_id sec);
95 void dc_lb_pec_clken(struct dc_lb *lb, enum dc_pec_clken clken);
96 void dc_lb_mode(struct dc_lb *lb, enum dc_lb_mode mode);
97 void dc_lb_position(struct dc_lb *lb, int x, int y);
98 int dc_lb_get_id(struct dc_lb *lb);
99 void dc_lb_init(struct dc_lb *lb);
100 
101 #endif /* __DC_PIXEL_ENGINE_H__ */
102