forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/sun4i/sun4i_frontend.h
....@@ -22,16 +22,57 @@
2222 #define SUN4I_FRONTEND_BYPASS_CSC_EN BIT(1)
2323
2424 #define SUN4I_FRONTEND_BUF_ADDR0_REG 0x020
25
+#define SUN4I_FRONTEND_BUF_ADDR1_REG 0x024
26
+#define SUN4I_FRONTEND_BUF_ADDR2_REG 0x028
27
+
28
+#define SUN4I_FRONTEND_TB_OFF0_REG 0x030
29
+#define SUN4I_FRONTEND_TB_OFF1_REG 0x034
30
+#define SUN4I_FRONTEND_TB_OFF2_REG 0x038
31
+#define SUN4I_FRONTEND_TB_OFF_X1(x1) ((x1) << 16)
32
+#define SUN4I_FRONTEND_TB_OFF_Y0(y0) ((y0) << 8)
33
+#define SUN4I_FRONTEND_TB_OFF_X0(x0) (x0)
2534
2635 #define SUN4I_FRONTEND_LINESTRD0_REG 0x040
36
+#define SUN4I_FRONTEND_LINESTRD1_REG 0x044
37
+#define SUN4I_FRONTEND_LINESTRD2_REG 0x048
38
+
39
+/*
40
+ * In tiled mode, the stride is defined as the distance between the start of the
41
+ * end line of the current tile and the start of the first line in the next
42
+ * vertical tile.
43
+ *
44
+ * Tiles are represented in row-major order, thus the end line of current tile
45
+ * starts at: 31 * 32 (31 lines of 32 cols), the next vertical tile starts at:
46
+ * 32-bit-aligned-width * 32 and the distance is:
47
+ * 32 * (32-bit-aligned-width - 31).
48
+ */
49
+#define SUN4I_FRONTEND_LINESTRD_TILED(stride) (((stride) - 31) * 32)
2750
2851 #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c
29
-#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(mod) ((mod) << 8)
30
-#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(fmt) ((fmt) << 4)
31
-#define SUN4I_FRONTEND_INPUT_FMT_PS(ps) (ps)
52
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PLANAR (0 << 8)
53
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED (1 << 8)
54
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_SEMIPLANAR (2 << 8)
55
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_MB32_PLANAR (4 << 8)
56
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_MB32_SEMIPLANAR (6 << 8)
57
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV444 (0 << 4)
58
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV422 (1 << 4)
59
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV420 (2 << 4)
60
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV411 (3 << 4)
61
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB (5 << 4)
62
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UYVY 0
63
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YUYV 1
64
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VYUY 2
65
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YVYU 3
66
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UV 0
67
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VU 1
68
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_BGRX 0
69
+#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1
3270
3371 #define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c
34
-#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(fmt) (fmt)
72
+#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_BGRX8888 1
73
+#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888 2
74
+
75
+#define SUN4I_FRONTEND_CSC_COEF_REG(c) (0x070 + (0x4 * (c)))
3576
3677 #define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100
3778 #define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1)))
....@@ -71,6 +112,12 @@
71112 struct regmap;
72113 struct reset_control;
73114
115
+struct sun4i_frontend_data {
116
+ bool has_coef_access_ctrl;
117
+ bool has_coef_rdy;
118
+ u32 ch_phase[2];
119
+};
120
+
74121 struct sun4i_frontend {
75122 struct list_head list;
76123 struct device *dev;
....@@ -81,9 +128,12 @@
81128 struct clk *ram_clk;
82129 struct regmap *regs;
83130 struct reset_control *reset;
131
+
132
+ const struct sun4i_frontend_data *data;
84133 };
85134
86135 extern const struct of_device_id sun4i_frontend_of_table[];
136
+extern const u32 sunxi_bt601_yuv2rgb_coef[12];
87137
88138 int sun4i_frontend_init(struct sun4i_frontend *frontend);
89139 void sun4i_frontend_exit(struct sun4i_frontend *frontend);
....@@ -95,5 +145,6 @@
95145 struct drm_plane *plane);
96146 int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,
97147 struct drm_plane *plane, uint32_t out_fmt);
148
+bool sun4i_frontend_format_is_supported(uint32_t fmt, uint64_t modifier);
98149
99150 #endif /* _SUN4I_FRONTEND_H_ */