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