1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (C) 2017 Free Electrons 4 * Maxime Ripard <maxime.ripard@free-electrons.com> 5 */ 6 7 #ifndef _SUN4I_FRONTEND_H_ 8 #define _SUN4I_FRONTEND_H_ 9 10 #include <linux/list.h> 11 12 #define SUN4I_FRONTEND_EN_REG 0x000 13 #define SUN4I_FRONTEND_EN_EN BIT(0) 14 15 #define SUN4I_FRONTEND_FRM_CTRL_REG 0x004 16 #define SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL BIT(23) 17 #define SUN4I_FRONTEND_FRM_CTRL_FRM_START BIT(16) 18 #define SUN4I_FRONTEND_FRM_CTRL_COEF_RDY BIT(1) 19 #define SUN4I_FRONTEND_FRM_CTRL_REG_RDY BIT(0) 20 21 #define SUN4I_FRONTEND_BYPASS_REG 0x008 22 #define SUN4I_FRONTEND_BYPASS_CSC_EN BIT(1) 23 24 #define SUN4I_FRONTEND_BUF_ADDR0_REG 0x020 25 26 #define SUN4I_FRONTEND_LINESTRD0_REG 0x040 27 28 #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c 29 #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED (1 << 8) 30 #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV422 (1 << 4) 31 #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB (5 << 4) 32 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UYVY 0 33 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YUYV 1 34 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VYUY 2 35 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YVYU 3 36 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_BGRX 0 37 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1 38 39 #define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c 40 #define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_BGRX8888 1 41 #define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888 2 42 43 #define SUN4I_FRONTEND_CSC_COEF_REG(c) (0x070 + (0x4 * (c))) 44 45 #define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100 46 #define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1))) 47 48 #define SUN4I_FRONTEND_CH0_OUTSIZE_REG 0x104 49 #define SUN4I_FRONTEND_OUTSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1))) 50 51 #define SUN4I_FRONTEND_CH0_HORZFACT_REG 0x108 52 #define SUN4I_FRONTEND_HORZFACT(i, f) (((i) << 16) | (f)) 53 54 #define SUN4I_FRONTEND_CH0_VERTFACT_REG 0x10c 55 #define SUN4I_FRONTEND_VERTFACT(i, f) (((i) << 16) | (f)) 56 57 #define SUN4I_FRONTEND_CH0_HORZPHASE_REG 0x110 58 #define SUN4I_FRONTEND_CH0_VERTPHASE0_REG 0x114 59 #define SUN4I_FRONTEND_CH0_VERTPHASE1_REG 0x118 60 61 #define SUN4I_FRONTEND_CH1_INSIZE_REG 0x200 62 #define SUN4I_FRONTEND_CH1_OUTSIZE_REG 0x204 63 #define SUN4I_FRONTEND_CH1_HORZFACT_REG 0x208 64 #define SUN4I_FRONTEND_CH1_VERTFACT_REG 0x20c 65 66 #define SUN4I_FRONTEND_CH1_HORZPHASE_REG 0x210 67 #define SUN4I_FRONTEND_CH1_VERTPHASE0_REG 0x214 68 #define SUN4I_FRONTEND_CH1_VERTPHASE1_REG 0x218 69 70 #define SUN4I_FRONTEND_CH0_HORZCOEF0_REG(i) (0x400 + i * 4) 71 #define SUN4I_FRONTEND_CH0_HORZCOEF1_REG(i) (0x480 + i * 4) 72 #define SUN4I_FRONTEND_CH0_VERTCOEF_REG(i) (0x500 + i * 4) 73 #define SUN4I_FRONTEND_CH1_HORZCOEF0_REG(i) (0x600 + i * 4) 74 #define SUN4I_FRONTEND_CH1_HORZCOEF1_REG(i) (0x680 + i * 4) 75 #define SUN4I_FRONTEND_CH1_VERTCOEF_REG(i) (0x700 + i * 4) 76 77 struct clk; 78 struct device_node; 79 struct drm_plane; 80 struct regmap; 81 struct reset_control; 82 83 struct sun4i_frontend { 84 struct list_head list; 85 struct device *dev; 86 struct device_node *node; 87 88 struct clk *bus_clk; 89 struct clk *mod_clk; 90 struct clk *ram_clk; 91 struct regmap *regs; 92 struct reset_control *reset; 93 }; 94 95 extern const struct of_device_id sun4i_frontend_of_table[]; 96 extern const u32 sunxi_bt601_yuv2rgb_coef[12]; 97 98 int sun4i_frontend_init(struct sun4i_frontend *frontend); 99 void sun4i_frontend_exit(struct sun4i_frontend *frontend); 100 int sun4i_frontend_enable(struct sun4i_frontend *frontend); 101 102 void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, 103 struct drm_plane *plane); 104 void sun4i_frontend_update_coord(struct sun4i_frontend *frontend, 105 struct drm_plane *plane); 106 int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, 107 struct drm_plane *plane, uint32_t out_fmt); 108 bool sun4i_frontend_format_is_supported(uint32_t fmt, uint64_t modifier); 109 110 #endif /* _SUN4I_FRONTEND_H_ */ 111