1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2021 Rockchip Electronics Co., Ltd
4 */
5 #ifndef __SOC_ROCKCHIP_ROCKIT_H
6 #define __SOC_ROCKCHIP_ROCKIT_H
7
8 #include <linux/dma-buf.h>
9 #include <linux/rk-isp2-config.h>
10
11 #define ROCKIT_BUF_NUM_MAX 5
12 #define ROCKIT_ISP_NUM_MAX 3
13 #define ROCKIT_STREAM_NUM_MAX 12
14
15 #define ROCKIT_VICAP_NUM_MAX 6
16
17 enum function_cmd {
18 ROCKIT_BUF_QUE,
19 ROCKIT_MPIBUF_DONE
20 };
21
22 struct rkisp_stream_cfg {
23 struct rkisp_rockit_buffer *rkisp_buff[ROCKIT_BUF_NUM_MAX];
24 int buff_id[ROCKIT_BUF_NUM_MAX];
25 void *node;
26 int fps_cnt;
27 int dst_fps;
28 int cur_fps;
29 u64 old_time;
30 bool is_discard;
31 };
32
33 struct ISP_VIDEO_FRAMES {
34 u32 pMbBlk;
35 u32 u32Width;
36 u32 u32Height;
37 u32 u32VirWidth;
38 u32 u32VirHeight;
39 u32 enField;
40 u32 enPixelFormat;
41 u32 enVideoFormat;
42 u32 enCompressMode;
43 u32 enDynamicRange;
44 u32 enColorGamut;
45 u32 u32TimeRef;
46 u64 u64PTS;
47
48 u64 u64PrivateData;
49 u32 u32FrameFlag; /* FRAME_FLAG_E, can be OR operation. */
50 };
51
52 struct rkisp_dev_cfg {
53 char *isp_name;
54 void *isp_dev;
55 struct rkisp_stream_cfg rkisp_stream_cfg[ROCKIT_STREAM_NUM_MAX];
56 };
57
58 struct rockit_cfg {
59 bool is_alloc;
60 bool is_empty;
61 bool is_qbuf;
62 bool is_color;
63 char *current_name;
64 dma_addr_t dma_addr;
65 int *buff_id;
66 int mpi_id;
67 int isp_num;
68 u32 nick_id;
69 u32 event;
70 void *node;
71 void *mpibuf;
72 void *vvi_dev[ROCKIT_ISP_NUM_MAX];
73 struct dma_buf *buf;
74 struct ISP_VIDEO_FRAMES frame;
75 struct rkisp_dev_cfg rkisp_dev_cfg[ROCKIT_ISP_NUM_MAX];
76 int (*rkisp_rockit_mpibuf_done)(struct rockit_cfg *rockit_isp_cfg);
77 };
78
79 struct rkcif_stream_cfg {
80 struct rkcif_rockit_buffer *rkcif_buff[ROCKIT_BUF_NUM_MAX];
81 int buff_id[ROCKIT_BUF_NUM_MAX];
82 void *node;
83 int fps_cnt;
84 int dst_fps;
85 int cur_fps;
86 u64 old_time;
87 bool is_discard;
88 };
89
90 struct rkcif_dev_cfg {
91 const char *cif_name;
92 void *cif_dev;
93 struct rkcif_stream_cfg rkcif_stream_cfg[ROCKIT_STREAM_NUM_MAX];
94 };
95
96 struct rockit_rkcif_cfg {
97 bool is_alloc;
98 bool is_empty;
99 bool is_qbuf;
100 const char *cur_name;
101 int *buff_id;
102 int mpi_id;
103 u32 nick_id;
104 u32 event;
105 int cif_num;
106 void *node;
107 void *mpibuf;
108 void *vvi_dev[ROCKIT_VICAP_NUM_MAX];
109 struct dma_buf *buf;
110 struct ISP_VIDEO_FRAMES frame;
111 struct rkcif_dev_cfg rkcif_dev_cfg[ROCKIT_VICAP_NUM_MAX];
112 int (*rkcif_rockit_mpibuf_done)(struct rockit_rkcif_cfg *rockit_cif_cfg);
113 };
114
115 #if IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_ISP_VERSION_V32)
116
117 void *rkisp_rockit_function_register(void *function, int cmd);
118 int rkisp_rockit_get_ispdev(char **name);
119 int rkisp_rockit_buf_queue(struct rockit_cfg *input_rockit_cfg);
120 int rkisp_rockit_pause_stream(struct rockit_cfg *input_rockit_cfg);
121 int rkisp_rockit_resume_stream(struct rockit_cfg *input_rockit_cfg);
122 int rkisp_rockit_config_stream(struct rockit_cfg *input_rockit_cfg,
123 int width, int height, int wrap_line);
124 int rkisp_rockit_get_tb_stream_info(struct rockit_cfg *input_rockit_cfg,
125 struct rkisp_tb_stream_info *info);
126 int rkisp_rockit_free_tb_stream_buf(struct rockit_cfg *input_rockit_cfg);
127
128 void *rkcif_rockit_function_register(void *function, int cmd);
129 int rkcif_rockit_get_cifdev(char **name);
130 int rkcif_rockit_buf_queue(struct rockit_rkcif_cfg *input_rockit_cfg);
131 int rkcif_rockit_config_stream(struct rockit_rkcif_cfg *input_rockit_cfg,
132 int width, int height, int v4l2_fmt);
133 int rkcif_rockit_resume_stream(struct rockit_rkcif_cfg *input_rockit_cfg);
134 int rkcif_rockit_pause_stream(struct rockit_rkcif_cfg *input_rockit_cfg);
135
136 #else
137
rkisp_rockit_function_register(void * function,int cmd)138 static inline void *rkisp_rockit_function_register(void *function, int cmd) { return NULL; }
rkisp_rockit_get_ispdev(char ** name)139 static inline int rkisp_rockit_get_ispdev(char **name) { return -EINVAL; }
rkisp_rockit_buf_queue(struct rockit_cfg * input_rockit_cfg)140 static inline int rkisp_rockit_buf_queue(struct rockit_cfg *input_rockit_cfg)
141 {
142 return -EINVAL;
143 }
rkisp_rockit_pause_stream(struct rockit_cfg * input_rockit_cfg)144 static inline int rkisp_rockit_pause_stream(struct rockit_cfg *input_rockit_cfg)
145 {
146 return -EINVAL;
147 }
rkisp_rockit_resume_stream(struct rockit_cfg * input_rockit_cfg)148 static inline int rkisp_rockit_resume_stream(struct rockit_cfg *input_rockit_cfg)
149 {
150 return -EINVAL;
151 }
rkisp_rockit_config_stream(struct rockit_cfg * input_rockit_cfg,int width,int height,int wrap_line)152 static inline int rkisp_rockit_config_stream(struct rockit_cfg *input_rockit_cfg,
153 int width, int height, int wrap_line)
154 {
155 return -EINVAL;
156 }
157
rkisp_rockit_get_tb_stream_info(struct rockit_cfg * input_rockit_cfg,struct rkisp_tb_stream_info * info)158 static inline int rkisp_rockit_get_tb_stream_info(struct rockit_cfg *input_rockit_cfg,
159 struct rkisp_tb_stream_info *info)
160 {
161 return -EINVAL;
162 }
163
rkisp_rockit_free_tb_stream_buf(struct rockit_cfg * input_rockit_cfg)164 static inline int rkisp_rockit_free_tb_stream_buf(struct rockit_cfg *input_rockit_cfg)
165 {
166 return -EINVAL;
167 }
168
169 #endif
170
171 #endif
172