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