4 #include <linux/device.h>
5 #include <linux/miscdevice.h>
6 #include <linux/mutex.h>
8 #if defined(CONFIG_RK_IOMMU) && defined(CONFIG_ION_ROCKCHIP)
9 #define CONFIG_IEP_IOMMU
12 #ifdef CONFIG_IEP_IOMMU
13 #include <linux/rockchip_ion.h>
14 #include <linux/rockchip-iovmm.h>
15 #include <linux/dma-buf.h>
19 #define IEP_REG_LEN 0x100
20 #define IEP_CMD_REG_LEN 0xE
21 #define IEP_ADD_REG_LEN 0xE0
22 #define IEP_RAW_REG_LEN 0xA
23 #define IEP_SYS_REG_LEN 0x6
24 #define IEP_CNF_REG_LEN 0x2
26 #define IEP_CNF_REG_BASE 0x0
27 #define IEP_SYS_REG_BASE 0x2
28 #define IEP_CMD_REG_BASE 0x8
29 #define IEP_ADD_REG_BASE 0x20
30 #define IEP_RAW_REG_BASE 0x16
32 #if defined(CONFIG_IEP_MMU)
33 #define IEP_MMU_REG_BASE 0x200
34 #define IEP_MMU_REG_LEN 0xA
37 struct iep_parameter_req {
42 struct iep_parameter_deinterlace {
46 struct iep_img src_itemp;
47 struct iep_img src_ftemp;
49 struct iep_img dst_itemp;
50 struct iep_img dst_ftemp;
54 // deinterlace high frequency
58 // deinterlace edge interpolation
65 struct iep_parameter_enhance {
69 float yuv_enh_saturation; //0-1.992
70 float yuv_enh_contrast; //0-1.992
71 s8 yuv_enh_brightness; //-32<brightness<31
72 s8 yuv_enh_hue_angle; //0-30,value is 0 - 30
75 u8 color_bar_y; //0-127
76 u8 color_bar_u; //0-127
77 u8 color_bar_v; //0-127
81 u8 rgb_cg_en; //sw_rgb_con_gam_en
85 u8 rgb_color_enhance_en; //sw_rgb_color_enh_en
86 float rgb_enh_coe; //0-3.96875
89 struct iep_parameter_scale {
93 struct iep_parameter_convert {
95 u8 dither_down_en; //not to be used
100 u8 global_alpha_value;
106 typedef struct iep_session {
107 /* a linked list of data so we can access them for debugging */
108 struct list_head list_session;
109 /* a linked list of register data waiting for process */
110 struct list_head waiting;
111 /* a linked list of register data in ready */
112 struct list_head ready;
113 /* a linked list of register data in processing */
114 struct list_head running;
115 /* all coommand this thread done */
117 wait_queue_head_t wait;
119 atomic_t task_running;
122 #if defined(CONFIG_IEP_MMU)
124 struct list_head pte_list;
125 struct task_struct *tsk;
129 typedef struct iep_service_info {
131 struct timer_list timer; /* timer for power off */
132 struct list_head waiting; /* link to link_reg in struct iep_reg */
134 struct list_head ready; /* link to link_reg in struct iep_reg */
135 struct list_head running; /* link to link_reg in struct iep_reg */
136 struct list_head done; /* link to link_reg in struct iep_reg */
137 struct list_head session; /* link to list_session in struct vpu_session */
138 atomic_t total_running;
143 struct mutex mutex; // mutex
145 #ifdef CONFIG_IEP_IOMMU
146 struct ion_client *ion_client;
148 struct device *iommu_dev;
152 iep_session *session;
153 struct list_head session_link; /* link to rga service session */
154 struct list_head status_link; /* link to register set list */
165 #if defined(CONFIG_IEP_IOMMU)
166 struct list_head mem_region_list;
170 #if defined(CONFIG_IEP_IOMMU)
171 struct iep_mem_region {
172 struct list_head srv_lnk;
173 struct list_head reg_lnk;
174 struct list_head session_lnk;
175 unsigned long iova; /* virtual address for iommu */
177 struct ion_handle *hdl;