1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Copyright (C) 2016 BayLibre, SAS 4 * Author: Neil Armstrong <narmstrong@baylibre.com> 5 */ 6 7 #ifndef __MESON_DRV_H 8 #define __MESON_DRV_H 9 10 #include <linux/device.h> 11 #include <linux/of.h> 12 #include <linux/of_device.h> 13 #include <linux/regmap.h> 14 15 struct drm_crtc; 16 struct drm_device; 17 struct drm_plane; 18 struct meson_drm; 19 struct meson_afbcd_ops; 20 21 enum vpu_compatible { 22 VPU_COMPATIBLE_GXBB = 0, 23 VPU_COMPATIBLE_GXL = 1, 24 VPU_COMPATIBLE_GXM = 2, 25 VPU_COMPATIBLE_G12A = 3, 26 }; 27 28 struct meson_drm_match_data { 29 enum vpu_compatible compat; 30 struct meson_afbcd_ops *afbcd_ops; 31 }; 32 33 struct meson_drm_soc_limits { 34 unsigned int max_hdmi_phy_freq; 35 }; 36 37 struct meson_drm { 38 struct device *dev; 39 enum vpu_compatible compat; 40 void __iomem *io_base; 41 struct regmap *hhi; 42 int vsync_irq; 43 44 struct meson_canvas *canvas; 45 u8 canvas_id_osd1; 46 u8 canvas_id_vd1_0; 47 u8 canvas_id_vd1_1; 48 u8 canvas_id_vd1_2; 49 50 struct drm_device *drm; 51 struct drm_crtc *crtc; 52 struct drm_plane *primary_plane; 53 struct drm_plane *overlay_plane; 54 55 const struct meson_drm_soc_limits *limits; 56 57 /* Components Data */ 58 struct { 59 bool osd1_enabled; 60 bool osd1_interlace; 61 bool osd1_commit; 62 bool osd1_afbcd; 63 uint32_t osd1_ctrl_stat; 64 uint32_t osd1_ctrl_stat2; 65 uint32_t osd1_blk0_cfg[5]; 66 uint32_t osd1_blk1_cfg4; 67 uint32_t osd1_blk2_cfg4; 68 uint32_t osd1_addr; 69 uint32_t osd1_stride; 70 uint32_t osd1_height; 71 uint32_t osd1_width; 72 uint32_t osd_sc_ctrl0; 73 uint32_t osd_sc_i_wh_m1; 74 uint32_t osd_sc_o_h_start_end; 75 uint32_t osd_sc_o_v_start_end; 76 uint32_t osd_sc_v_ini_phase; 77 uint32_t osd_sc_v_phase_step; 78 uint32_t osd_sc_h_ini_phase; 79 uint32_t osd_sc_h_phase_step; 80 uint32_t osd_sc_h_ctrl0; 81 uint32_t osd_sc_v_ctrl0; 82 uint32_t osd_blend_din0_scope_h; 83 uint32_t osd_blend_din0_scope_v; 84 uint32_t osb_blend0_size; 85 uint32_t osb_blend1_size; 86 87 bool vd1_enabled; 88 bool vd1_commit; 89 unsigned int vd1_planes; 90 uint32_t vd1_if0_gen_reg; 91 uint32_t vd1_if0_luma_x0; 92 uint32_t vd1_if0_luma_y0; 93 uint32_t vd1_if0_chroma_x0; 94 uint32_t vd1_if0_chroma_y0; 95 uint32_t vd1_if0_repeat_loop; 96 uint32_t vd1_if0_luma0_rpt_pat; 97 uint32_t vd1_if0_chroma0_rpt_pat; 98 uint32_t vd1_range_map_y; 99 uint32_t vd1_range_map_cb; 100 uint32_t vd1_range_map_cr; 101 uint32_t viu_vd1_fmt_w; 102 uint32_t vd1_if0_canvas0; 103 uint32_t vd1_if0_gen_reg2; 104 uint32_t viu_vd1_fmt_ctrl; 105 uint32_t vd1_addr0; 106 uint32_t vd1_addr1; 107 uint32_t vd1_addr2; 108 uint32_t vd1_stride0; 109 uint32_t vd1_stride1; 110 uint32_t vd1_stride2; 111 uint32_t vd1_height0; 112 uint32_t vd1_height1; 113 uint32_t vd1_height2; 114 uint32_t vpp_pic_in_height; 115 uint32_t vpp_postblend_vd1_h_start_end; 116 uint32_t vpp_postblend_vd1_v_start_end; 117 uint32_t vpp_hsc_region12_startp; 118 uint32_t vpp_hsc_region34_startp; 119 uint32_t vpp_hsc_region4_endp; 120 uint32_t vpp_hsc_start_phase_step; 121 uint32_t vpp_hsc_region1_phase_slope; 122 uint32_t vpp_hsc_region3_phase_slope; 123 uint32_t vpp_line_in_length; 124 uint32_t vpp_preblend_h_size; 125 uint32_t vpp_vsc_region12_startp; 126 uint32_t vpp_vsc_region34_startp; 127 uint32_t vpp_vsc_region4_endp; 128 uint32_t vpp_vsc_start_phase_step; 129 uint32_t vpp_vsc_ini_phase; 130 uint32_t vpp_vsc_phase_ctrl; 131 uint32_t vpp_hsc_phase_ctrl; 132 uint32_t vpp_blend_vd2_h_start_end; 133 uint32_t vpp_blend_vd2_v_start_end; 134 } viu; 135 136 struct { 137 unsigned int current_mode; 138 bool hdmi_repeat; 139 bool venc_repeat; 140 bool hdmi_use_enci; 141 } venc; 142 143 struct { 144 dma_addr_t addr_dma; 145 uint32_t *addr; 146 unsigned int offset; 147 } rdma; 148 149 struct { 150 struct meson_afbcd_ops *ops; 151 u64 modifier; 152 u32 format; 153 } afbcd; 154 }; 155 156 static inline int meson_vpu_is_compatible(struct meson_drm *priv, 157 enum vpu_compatible family) 158 { 159 return priv->compat == family; 160 } 161 162 #endif /* __MESON_DRV_H */ 163