xref: /linux/drivers/gpu/drm/meson/meson_drv.h (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
11ccea77eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2bbbe775eSNeil Armstrong /*
3bbbe775eSNeil Armstrong  * Copyright (C) 2016 BayLibre, SAS
4bbbe775eSNeil Armstrong  * Author: Neil Armstrong <narmstrong@baylibre.com>
5bbbe775eSNeil Armstrong  */
6bbbe775eSNeil Armstrong 
7bbbe775eSNeil Armstrong #ifndef __MESON_DRV_H
8bbbe775eSNeil Armstrong #define __MESON_DRV_H
9bbbe775eSNeil Armstrong 
1066620f48SSam Ravnborg #include <linux/device.h>
11bbbe775eSNeil Armstrong #include <linux/of.h>
12528a25d0SJulien Masson #include <linux/regmap.h>
1366620f48SSam Ravnborg 
1466620f48SSam Ravnborg struct drm_crtc;
1566620f48SSam Ravnborg struct drm_device;
1666620f48SSam Ravnborg struct drm_plane;
1766620f48SSam Ravnborg struct meson_drm;
1866620f48SSam Ravnborg struct meson_afbcd_ops;
19d1b5e41eSNeil Armstrong 
20bbbe775eSNeil Armstrong enum vpu_compatible {
21528a25d0SJulien Masson 	VPU_COMPATIBLE_GXBB = 0,
22528a25d0SJulien Masson 	VPU_COMPATIBLE_GXL  = 1,
23528a25d0SJulien Masson 	VPU_COMPATIBLE_GXM  = 2,
24528a25d0SJulien Masson 	VPU_COMPATIBLE_G12A = 3,
25528a25d0SJulien Masson };
26528a25d0SJulien Masson 
27528a25d0SJulien Masson enum {
2809847723SAdrián Larumbe 	MESON_ENC_CVBS = 0,
2909847723SAdrián Larumbe 	MESON_ENC_HDMI,
3009847723SAdrián Larumbe 	MESON_ENC_DSI,
31*42dcf15fSNeil Armstrong 	MESON_ENC_LAST,
3209847723SAdrián Larumbe };
3309847723SAdrián Larumbe 
3409847723SAdrián Larumbe struct meson_drm_match_data {
35d1b5e41eSNeil Armstrong 	enum vpu_compatible compat;
36d1b5e41eSNeil Armstrong 	struct meson_afbcd_ops *afbcd_ops;
37d1b5e41eSNeil Armstrong };
38d1b5e41eSNeil Armstrong 
39d1b5e41eSNeil Armstrong struct meson_drm_soc_limits {
408976eeeeSNeil Armstrong 	unsigned int max_hdmi_phy_freq;
418976eeeeSNeil Armstrong };
428976eeeeSNeil Armstrong 
438976eeeeSNeil Armstrong struct meson_drm {
44bbbe775eSNeil Armstrong 	struct device *dev;
45bbbe775eSNeil Armstrong 	enum vpu_compatible compat;
46528a25d0SJulien Masson 	void __iomem *io_base;
47bbbe775eSNeil Armstrong 	struct regmap *hhi;
48bbbe775eSNeil Armstrong 	int vsync_irq;
49bbbe775eSNeil Armstrong 
50bbbe775eSNeil Armstrong 	struct meson_canvas *canvas;
5166cae477SMaxime Jourdan 	u8 canvas_id_osd1;
5266cae477SMaxime Jourdan 	u8 canvas_id_vd1_0;
53f9a23481SNeil Armstrong 	u8 canvas_id_vd1_1;
54f9a23481SNeil Armstrong 	u8 canvas_id_vd1_2;
55f9a23481SNeil Armstrong 
5666cae477SMaxime Jourdan 	struct drm_device *drm;
57bbbe775eSNeil Armstrong 	struct drm_crtc *crtc;
58bbbe775eSNeil Armstrong 	struct drm_plane *primary_plane;
59bbbe775eSNeil Armstrong 	struct drm_plane *overlay_plane;
60f9a23481SNeil Armstrong 	void *encoders[MESON_ENC_LAST];
6109847723SAdrián Larumbe 
62bbbe775eSNeil Armstrong 	const struct meson_drm_soc_limits *limits;
638976eeeeSNeil Armstrong 
648976eeeeSNeil Armstrong 	/* Components Data */
65bbbe775eSNeil Armstrong 	struct {
66bbbe775eSNeil Armstrong 		bool osd1_enabled;
67bbbe775eSNeil Armstrong 		bool osd1_interlace;
68bbbe775eSNeil Armstrong 		bool osd1_commit;
69bbbe775eSNeil Armstrong 		bool osd1_afbcd;
7068e2f64eSNeil Armstrong 		uint32_t osd1_ctrl_stat;
71bbbe775eSNeil Armstrong 		uint32_t osd1_ctrl_stat2;
7268e2f64eSNeil Armstrong 		uint32_t osd1_blk0_cfg[5];
73bbbe775eSNeil Armstrong 		uint32_t osd1_blk1_cfg4;
7468e2f64eSNeil Armstrong 		uint32_t osd1_blk2_cfg4;
7568e2f64eSNeil Armstrong 		uint32_t osd1_addr;
76e88230a3SNeil Armstrong 		uint32_t osd1_stride;
77e88230a3SNeil Armstrong 		uint32_t osd1_height;
78e88230a3SNeil Armstrong 		uint32_t osd1_width;
79ce7cb472SNeil Armstrong 		uint32_t osd_sc_ctrl0;
8020d7fe03SNeil Armstrong 		uint32_t osd_sc_i_wh_m1;
8120d7fe03SNeil Armstrong 		uint32_t osd_sc_o_h_start_end;
8220d7fe03SNeil Armstrong 		uint32_t osd_sc_o_v_start_end;
8320d7fe03SNeil Armstrong 		uint32_t osd_sc_v_ini_phase;
8420d7fe03SNeil Armstrong 		uint32_t osd_sc_v_phase_step;
8520d7fe03SNeil Armstrong 		uint32_t osd_sc_h_ini_phase;
8620d7fe03SNeil Armstrong 		uint32_t osd_sc_h_phase_step;
8720d7fe03SNeil Armstrong 		uint32_t osd_sc_h_ctrl0;
8820d7fe03SNeil Armstrong 		uint32_t osd_sc_v_ctrl0;
8920d7fe03SNeil Armstrong 		uint32_t osd_blend_din0_scope_h;
9068679d41SNeil Armstrong 		uint32_t osd_blend_din0_scope_v;
9168679d41SNeil Armstrong 		uint32_t osb_blend0_size;
9268679d41SNeil Armstrong 		uint32_t osb_blend1_size;
9368679d41SNeil Armstrong 
94f9a23481SNeil Armstrong 		bool vd1_enabled;
95f9a23481SNeil Armstrong 		bool vd1_commit;
96f9a23481SNeil Armstrong 		bool vd1_afbc;
97e860785dSNeil Armstrong 		unsigned int vd1_planes;
98f9a23481SNeil Armstrong 		uint32_t vd1_if0_gen_reg;
99f9a23481SNeil Armstrong 		uint32_t vd1_if0_luma_x0;
100f9a23481SNeil Armstrong 		uint32_t vd1_if0_luma_y0;
101f9a23481SNeil Armstrong 		uint32_t vd1_if0_chroma_x0;
102f9a23481SNeil Armstrong 		uint32_t vd1_if0_chroma_y0;
103f9a23481SNeil Armstrong 		uint32_t vd1_if0_repeat_loop;
104f9a23481SNeil Armstrong 		uint32_t vd1_if0_luma0_rpt_pat;
105f9a23481SNeil Armstrong 		uint32_t vd1_if0_chroma0_rpt_pat;
106f9a23481SNeil Armstrong 		uint32_t vd1_range_map_y;
107f9a23481SNeil Armstrong 		uint32_t vd1_range_map_cb;
108f9a23481SNeil Armstrong 		uint32_t vd1_range_map_cr;
109f9a23481SNeil Armstrong 		uint32_t viu_vd1_fmt_w;
110f9a23481SNeil Armstrong 		uint32_t vd1_if0_canvas0;
111f9a23481SNeil Armstrong 		uint32_t vd1_if0_gen_reg2;
112f9a23481SNeil Armstrong 		uint32_t viu_vd1_fmt_ctrl;
113f9a23481SNeil Armstrong 		uint32_t vd1_addr0;
114f9a23481SNeil Armstrong 		uint32_t vd1_addr1;
115f9a23481SNeil Armstrong 		uint32_t vd1_addr2;
116f9a23481SNeil Armstrong 		uint32_t vd1_stride0;
117f9a23481SNeil Armstrong 		uint32_t vd1_stride1;
118f9a23481SNeil Armstrong 		uint32_t vd1_stride2;
119f9a23481SNeil Armstrong 		uint32_t vd1_height0;
120f9a23481SNeil Armstrong 		uint32_t vd1_height1;
121f9a23481SNeil Armstrong 		uint32_t vd1_height2;
122f9a23481SNeil Armstrong 		uint32_t vd1_afbc_mode;
123e860785dSNeil Armstrong 		uint32_t vd1_afbc_en;
124e860785dSNeil Armstrong 		uint32_t vd1_afbc_head_addr;
125e860785dSNeil Armstrong 		uint32_t vd1_afbc_body_addr;
126e860785dSNeil Armstrong 		uint32_t vd1_afbc_conv_ctrl;
127e860785dSNeil Armstrong 		uint32_t vd1_afbc_dec_def_color;
128e860785dSNeil Armstrong 		uint32_t vd1_afbc_vd_cfmt_ctrl;
129e860785dSNeil Armstrong 		uint32_t vd1_afbc_vd_cfmt_w;
130e860785dSNeil Armstrong 		uint32_t vd1_afbc_vd_cfmt_h;
131e860785dSNeil Armstrong 		uint32_t vd1_afbc_mif_hor_scope;
132e860785dSNeil Armstrong 		uint32_t vd1_afbc_mif_ver_scope;
133e860785dSNeil Armstrong 		uint32_t vd1_afbc_size_out;
134e860785dSNeil Armstrong 		uint32_t vd1_afbc_pixel_hor_scope;
135e860785dSNeil Armstrong 		uint32_t vd1_afbc_pixel_ver_scope;
136e860785dSNeil Armstrong 		uint32_t vd1_afbc_size_in;
137e860785dSNeil Armstrong 		uint32_t vpp_pic_in_height;
138f9a23481SNeil Armstrong 		uint32_t vpp_postblend_vd1_h_start_end;
139f9a23481SNeil Armstrong 		uint32_t vpp_postblend_vd1_v_start_end;
140f9a23481SNeil Armstrong 		uint32_t vpp_hsc_region12_startp;
141f9a23481SNeil Armstrong 		uint32_t vpp_hsc_region34_startp;
142f9a23481SNeil Armstrong 		uint32_t vpp_hsc_region4_endp;
143f9a23481SNeil Armstrong 		uint32_t vpp_hsc_start_phase_step;
144f9a23481SNeil Armstrong 		uint32_t vpp_hsc_region1_phase_slope;
145f9a23481SNeil Armstrong 		uint32_t vpp_hsc_region3_phase_slope;
146f9a23481SNeil Armstrong 		uint32_t vpp_line_in_length;
147f9a23481SNeil Armstrong 		uint32_t vpp_preblend_h_size;
148f9a23481SNeil Armstrong 		uint32_t vpp_vsc_region12_startp;
149f9a23481SNeil Armstrong 		uint32_t vpp_vsc_region34_startp;
150f9a23481SNeil Armstrong 		uint32_t vpp_vsc_region4_endp;
151f9a23481SNeil Armstrong 		uint32_t vpp_vsc_start_phase_step;
152f9a23481SNeil Armstrong 		uint32_t vpp_vsc_ini_phase;
153f9a23481SNeil Armstrong 		uint32_t vpp_vsc_phase_ctrl;
154f9a23481SNeil Armstrong 		uint32_t vpp_hsc_phase_ctrl;
155f9a23481SNeil Armstrong 		uint32_t vpp_blend_vd2_h_start_end;
156f9a23481SNeil Armstrong 		uint32_t vpp_blend_vd2_v_start_end;
157f9a23481SNeil Armstrong 	} viu;
158bbbe775eSNeil Armstrong 
159bbbe775eSNeil Armstrong 	struct {
160bbbe775eSNeil Armstrong 		unsigned int current_mode;
161bbbe775eSNeil Armstrong 		bool hdmi_repeat;
1623f68be7dSNeil Armstrong 		bool venc_repeat;
1633f68be7dSNeil Armstrong 		bool hdmi_use_enci;
1643f68be7dSNeil Armstrong 	} venc;
165bbbe775eSNeil Armstrong 
16663fba242SNeil Armstrong 	struct {
16763fba242SNeil Armstrong 		dma_addr_t addr_dma;
16850b81d77SArnd Bergmann 		uint32_t *addr;
16963fba242SNeil Armstrong 		unsigned int offset;
17063fba242SNeil Armstrong 	} rdma;
17163fba242SNeil Armstrong 
172d1b5e41eSNeil Armstrong 	struct {
173d1b5e41eSNeil Armstrong 		struct meson_afbcd_ops *ops;
174d1b5e41eSNeil Armstrong 		u64 modifier;
175d1b5e41eSNeil Armstrong 		u32 format;
176d1b5e41eSNeil Armstrong 	} afbcd;
177d1b5e41eSNeil Armstrong };
178bbbe775eSNeil Armstrong 
meson_vpu_is_compatible(struct meson_drm * priv,enum vpu_compatible family)179bbbe775eSNeil Armstrong static inline int meson_vpu_is_compatible(struct meson_drm *priv,
180bbbe775eSNeil Armstrong 					  enum vpu_compatible family)
181528a25d0SJulien Masson {
182bbbe775eSNeil Armstrong 	return priv->compat == family;
183528a25d0SJulien Masson }
184bbbe775eSNeil Armstrong 
185bbbe775eSNeil Armstrong #endif /* __MESON_DRV_H */
186bbbe775eSNeil Armstrong