video: rockchip: iep: add drm support
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / iep / iep_drv.h
1 #ifndef IEP_DRV_H_
2 #define IEP_DRV_H_
3
4 #include <linux/device.h>
5 #include <linux/miscdevice.h>
6 #include <linux/mutex.h>
7
8 #if defined(CONFIG_RK_IOMMU)
9 #include <linux/rockchip-iovmm.h>
10 #include <linux/dma-buf.h>
11 #endif
12 #include "iep.h"
13
14 #define IEP_REG_LEN         0x100
15 #define IEP_CMD_REG_LEN     0xE
16 #define IEP_ADD_REG_LEN     0xE0
17 #define IEP_RAW_REG_LEN     0xA
18 #define IEP_SYS_REG_LEN     0x6
19 #define IEP_CNF_REG_LEN     0x2
20
21 #define IEP_CNF_REG_BASE    0x0
22 #define IEP_SYS_REG_BASE    0x2
23 #define IEP_CMD_REG_BASE    0x8
24 #define IEP_ADD_REG_BASE    0x20
25 #define IEP_RAW_REG_BASE    0x16
26
27 struct iep_parameter_req {
28         struct iep_img src;
29         struct iep_img dst;
30 };
31
32 struct iep_parameter_deinterlace {
33         struct iep_img src1;
34         struct iep_img dst1;
35
36         struct iep_img src_itemp;
37         struct iep_img src_ftemp;
38
39         struct iep_img dst_itemp;
40         struct iep_img dst_ftemp;
41
42         u8 dein_mode;
43
44         // deinterlace high frequency
45         u8 dein_high_fre_en;
46         u8 dein_high_fre_fct;
47
48         // deinterlace edge interpolation
49         u8 dein_ei_mode;
50         u8 dein_ei_smooth;
51         u8 dein_ei_sel;
52         u8 dein_ei_radius;
53 };
54
55 struct iep_parameter_enhance {
56         u8 yuv_3D_denoise_en;
57
58         u8 yuv_enhance_en;
59         float yuv_enh_saturation; //0-1.992
60         float yuv_enh_contrast; //0-1.992
61         s8 yuv_enh_brightness; //-32<brightness<31
62         s8 yuv_enh_hue_angle; //0-30,value is 0 - 30
63
64         u8 video_mode; //0-3
65         u8 color_bar_y; //0-127
66         u8 color_bar_u; //0-127
67         u8 color_bar_v; //0-127
68
69         u8 rgb_enhance_en;
70
71         u8 rgb_cg_en; //sw_rgb_con_gam_en
72         double cg_rr;
73         double cg_rg;
74         double cg_rb;
75         u8 rgb_color_enhance_en; //sw_rgb_color_enh_en
76         float rgb_enh_coe; //0-3.96875
77 };
78
79 struct iep_parameter_scale {
80         u8 scale_up_mode;
81 };
82
83 struct iep_parameter_convert {
84         u8 dither_up_en;
85         u8 dither_down_en; //not to be used
86
87         u8 yuv2rgb_mode;
88         u8 rgb2yuv_mode;
89
90         u8 global_alpha_value;
91
92         u8 rgb2yuv_clip_en;
93         u8 yuv2rgb_clip_en;
94 };
95
96 typedef struct iep_session {
97         /* a linked list of data so we can access them for debugging */
98         struct list_head    list_session;
99         /* a linked list of register data waiting for process */
100         struct list_head    waiting;
101         /* a linked list of register data in ready */
102         struct list_head    ready;
103         /* a linked list of register data in processing */
104         struct list_head    running;
105         /* all coommand this thread done */
106         atomic_t            done;
107         wait_queue_head_t   wait;
108         pid_t               pid;
109         atomic_t            task_running;
110         atomic_t            num_done;
111 } iep_session;
112
113 typedef struct iep_service_info {
114         struct mutex        lock;
115         struct timer_list       timer;          /* timer for power off */
116         struct list_head        waiting;        /* link to link_reg in struct iep_reg */
117         atomic_t            waitcnt;
118         struct list_head    ready;          /* link to link_reg in struct iep_reg */
119         struct list_head        running;        /* link to link_reg in struct iep_reg */
120         struct list_head        done;           /* link to link_reg in struct iep_reg */
121         struct list_head        session;        /* link to list_session in struct vpu_session */
122         atomic_t                    total_running;
123
124         struct iep_reg      *reg;
125         bool                enable;
126
127         struct mutex        mutex;  // mutex
128
129         struct iep_iommu_info *iommu_info;
130
131         struct device *iommu_dev;
132         u32 alloc_type;
133 } iep_service_info;
134
135 struct iep_reg {
136         iep_session *session;
137         struct list_head        session_link;      /* link to rga service session */
138         struct list_head        status_link;       /* link to register set list */
139         uint32_t                        reg[0x300];
140         bool                dpi_en;
141         int                 off_x;
142         int                 off_y;
143         int                 act_width;
144         int                 act_height;
145         int                 vir_width;
146         int                 vir_height;
147         int                 layer;
148         unsigned int        format;
149         struct list_head    mem_region_list;
150 };
151
152 struct iep_mem_region {
153         struct list_head srv_lnk;
154         struct list_head reg_lnk;
155         struct list_head session_lnk;
156         unsigned long iova;              /* virtual address for iommu */
157         unsigned long len;
158         int hdl;
159 };
160
161 #endif
162