Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * Copyright (C) 2017 Free Electrons
0004  * Maxime Ripard <maxime.ripard@free-electrons.com>
0005  */
0006 
0007 #ifndef _SUN4I_FRONTEND_H_
0008 #define _SUN4I_FRONTEND_H_
0009 
0010 #include <linux/list.h>
0011 
0012 #define SUN4I_FRONTEND_EN_REG           0x000
0013 #define SUN4I_FRONTEND_EN_EN                BIT(0)
0014 
0015 #define SUN4I_FRONTEND_FRM_CTRL_REG     0x004
0016 #define SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL    BIT(23)
0017 #define SUN4I_FRONTEND_FRM_CTRL_FRM_START       BIT(16)
0018 #define SUN4I_FRONTEND_FRM_CTRL_COEF_RDY        BIT(1)
0019 #define SUN4I_FRONTEND_FRM_CTRL_REG_RDY         BIT(0)
0020 
0021 #define SUN4I_FRONTEND_BYPASS_REG       0x008
0022 #define SUN4I_FRONTEND_BYPASS_CSC_EN            BIT(1)
0023 
0024 #define SUN4I_FRONTEND_BUF_ADDR0_REG        0x020
0025 #define SUN4I_FRONTEND_BUF_ADDR1_REG        0x024
0026 #define SUN4I_FRONTEND_BUF_ADDR2_REG        0x028
0027 
0028 #define SUN4I_FRONTEND_TB_OFF0_REG      0x030
0029 #define SUN4I_FRONTEND_TB_OFF1_REG      0x034
0030 #define SUN4I_FRONTEND_TB_OFF2_REG      0x038
0031 #define SUN4I_FRONTEND_TB_OFF_X1(x1)            ((x1) << 16)
0032 #define SUN4I_FRONTEND_TB_OFF_Y0(y0)            ((y0) << 8)
0033 #define SUN4I_FRONTEND_TB_OFF_X0(x0)            (x0)
0034 
0035 #define SUN4I_FRONTEND_LINESTRD0_REG        0x040
0036 #define SUN4I_FRONTEND_LINESTRD1_REG        0x044
0037 #define SUN4I_FRONTEND_LINESTRD2_REG        0x048
0038 
0039 /*
0040  * In tiled mode, the stride is defined as the distance between the start of the
0041  * end line of the current tile and the start of the first line in the next
0042  * vertical tile.
0043  *
0044  * Tiles are represented in row-major order, thus the end line of current tile
0045  * starts at: 31 * 32 (31 lines of 32 cols), the next vertical tile starts at:
0046  * 32-bit-aligned-width * 32 and the distance is:
0047  * 32 * (32-bit-aligned-width - 31).
0048  */
0049 #define SUN4I_FRONTEND_LINESTRD_TILED(stride)       (((stride) - 31) * 32)
0050 
0051 #define SUN4I_FRONTEND_INPUT_FMT_REG        0x04c
0052 #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PLANAR    (0 << 8)
0053 #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED    (1 << 8)
0054 #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_SEMIPLANAR    (2 << 8)
0055 #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_MB32_PLANAR   (4 << 8)
0056 #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_MB32_SEMIPLANAR (6 << 8)
0057 #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV444    (0 << 4)
0058 #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV422    (1 << 4)
0059 #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV420    (2 << 4)
0060 #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV411    (3 << 4)
0061 #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB       (5 << 4)
0062 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UYVY       0
0063 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YUYV       1
0064 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VYUY       2
0065 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YVYU       3
0066 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UV     0
0067 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VU     1
0068 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_BGRX       0
0069 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB       1
0070 
0071 #define SUN4I_FRONTEND_OUTPUT_FMT_REG       0x05c
0072 #define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_BGRX8888 1
0073 #define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888 2
0074 
0075 #define SUN4I_FRONTEND_CSC_COEF_REG(c)      (0x070 + (0x4 * (c)))
0076 
0077 #define SUN4I_FRONTEND_CH0_INSIZE_REG       0x100
0078 #define SUN4I_FRONTEND_INSIZE(h, w)         ((((h) - 1) << 16) | (((w) - 1)))
0079 
0080 #define SUN4I_FRONTEND_CH0_OUTSIZE_REG      0x104
0081 #define SUN4I_FRONTEND_OUTSIZE(h, w)            ((((h) - 1) << 16) | (((w) - 1)))
0082 
0083 #define SUN4I_FRONTEND_CH0_HORZFACT_REG     0x108
0084 #define SUN4I_FRONTEND_HORZFACT(i, f)           (((i) << 16) | (f))
0085 
0086 #define SUN4I_FRONTEND_CH0_VERTFACT_REG     0x10c
0087 #define SUN4I_FRONTEND_VERTFACT(i, f)           (((i) << 16) | (f))
0088 
0089 #define SUN4I_FRONTEND_CH0_HORZPHASE_REG    0x110
0090 #define SUN4I_FRONTEND_CH0_VERTPHASE0_REG   0x114
0091 #define SUN4I_FRONTEND_CH0_VERTPHASE1_REG   0x118
0092 
0093 #define SUN4I_FRONTEND_CH1_INSIZE_REG       0x200
0094 #define SUN4I_FRONTEND_CH1_OUTSIZE_REG      0x204
0095 #define SUN4I_FRONTEND_CH1_HORZFACT_REG     0x208
0096 #define SUN4I_FRONTEND_CH1_VERTFACT_REG     0x20c
0097 
0098 #define SUN4I_FRONTEND_CH1_HORZPHASE_REG    0x210
0099 #define SUN4I_FRONTEND_CH1_VERTPHASE0_REG   0x214
0100 #define SUN4I_FRONTEND_CH1_VERTPHASE1_REG   0x218
0101 
0102 #define SUN4I_FRONTEND_CH0_HORZCOEF0_REG(i) (0x400 + i * 4)
0103 #define SUN4I_FRONTEND_CH0_HORZCOEF1_REG(i) (0x480 + i * 4)
0104 #define SUN4I_FRONTEND_CH0_VERTCOEF_REG(i)  (0x500 + i * 4)
0105 #define SUN4I_FRONTEND_CH1_HORZCOEF0_REG(i) (0x600 + i * 4)
0106 #define SUN4I_FRONTEND_CH1_HORZCOEF1_REG(i) (0x680 + i * 4)
0107 #define SUN4I_FRONTEND_CH1_VERTCOEF_REG(i)  (0x700 + i * 4)
0108 
0109 struct clk;
0110 struct device_node;
0111 struct drm_plane;
0112 struct regmap;
0113 struct reset_control;
0114 
0115 struct sun4i_frontend_data {
0116     bool    has_coef_access_ctrl;
0117     bool    has_coef_rdy;
0118     u32 ch_phase[2];
0119 };
0120 
0121 struct sun4i_frontend {
0122     struct list_head    list;
0123     struct device       *dev;
0124     struct device_node  *node;
0125 
0126     struct clk      *bus_clk;
0127     struct clk      *mod_clk;
0128     struct clk      *ram_clk;
0129     struct regmap       *regs;
0130     struct reset_control    *reset;
0131 
0132     const struct sun4i_frontend_data    *data;
0133 };
0134 
0135 extern const struct of_device_id sun4i_frontend_of_table[];
0136 extern const u32 sunxi_bt601_yuv2rgb_coef[12];
0137 
0138 int sun4i_frontend_init(struct sun4i_frontend *frontend);
0139 void sun4i_frontend_exit(struct sun4i_frontend *frontend);
0140 int sun4i_frontend_enable(struct sun4i_frontend *frontend);
0141 
0142 void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend,
0143                   struct drm_plane *plane);
0144 void sun4i_frontend_update_coord(struct sun4i_frontend *frontend,
0145                  struct drm_plane *plane);
0146 int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,
0147                   struct drm_plane *plane, uint32_t out_fmt);
0148 bool sun4i_frontend_format_is_supported(uint32_t fmt, uint64_t modifier);
0149 
0150 #endif /* _SUN4I_FRONTEND_H_ */