xref: /OK3568_Linux_fs/kernel/drivers/media/platform/rockchip/cif/subdev-itf.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Rockchip CIF Driver
4  *
5  * Copyright (C) 2020 Rockchip Electronics Co., Ltd.
6  */
7 
8 #ifndef _RKCIF_SDITF_H
9 #define _RKCIF_SDITF_H
10 
11 #include <linux/mutex.h>
12 #include <media/media-device.h>
13 #include <media/media-entity.h>
14 #include <media/v4l2-ctrls.h>
15 #include <media/v4l2-device.h>
16 #include <media/videobuf2-v4l2.h>
17 #include <media/v4l2-mc.h>
18 #include <linux/rk-camera-module.h>
19 #include "hw.h"
20 #include "../isp/isp_external.h"
21 
22 #define RKISP0_DEVNAME "rkisp0"
23 #define RKISP1_DEVNAME "rkisp1"
24 #define RKISP_UNITE_DEVNAME "rkisp-unite"
25 
26 #define RKCIF_TOISP_CH0	0
27 #define RKCIF_TOISP_CH1	1
28 #define RKCIF_TOISP_CH2	2
29 #define TOISP_CH_MAX 3
30 
31 #define SDITF_PIXEL_RATE_MAX (1000000000)
32 
33 struct capture_info {
34 	unsigned int offset_x;
35 	unsigned int offset_y;
36 	unsigned int width;
37 	unsigned int height;
38 };
39 
40 enum toisp_link_mode {
41 	TOISP_NONE,
42 	TOISP0,
43 	TOISP1,
44 	TOISP_UNITE,
45 };
46 
47 struct toisp_ch_info {
48 	bool is_valid;
49 	int id;
50 };
51 
52 struct toisp_info {
53 	struct toisp_ch_info ch_info[TOISP_CH_MAX];
54 	enum toisp_link_mode link_mode;
55 };
56 
57 struct sditf_work_struct {
58 	struct work_struct	work;
59 	struct rkisp_rx_buffer *buf;
60 };
61 
62 struct sditf_priv {
63 	struct device *dev;
64 	struct v4l2_async_notifier notifier;
65 	struct v4l2_subdev sd;
66 	struct media_pad pads[2];
67 	struct rkcif_device *cif_dev;
68 	struct rkmodule_hdr_cfg	hdr_cfg;
69 	struct capture_info cap_info;
70 	struct rkisp_vicap_mode mode;
71 	struct toisp_info toisp_inf;
72 	struct v4l2_ctrl *pixel_rate;
73 	struct v4l2_ctrl_handler ctrl_handler;
74 	struct v4l2_subdev *sensor_sd;
75 	struct sditf_work_struct buffree_work;
76 	struct list_head buf_free_list;
77 	int buf_num;
78 	int num_sensors;
79 	int combine_index;
80 	bool is_combine_mode;
81 	atomic_t power_cnt;
82 	atomic_t stream_cnt;
83 };
84 
85 extern struct platform_driver rkcif_subdev_driver;
86 void sditf_change_to_online(struct sditf_priv *priv);
87 
88 #endif
89