xref: /OK3568_Linux_fs/kernel/drivers/video/rockchip/vehicle/vehicle_cfg.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Rockchip Vehicle driver
4  *
5  * Copyright (C) 2022 Rockchip Electronics Co., Ltd.
6  */
7 #ifndef __VEHICLE_CFG
8 #define __VEHICLE_CFG
9 #include <media/v4l2-mediabus.h>
10 #include <linux/rk-camera-module.h>
11 
12 /* Driver information */
13 #define VEHICLE_DRIVER_NAME		"Vehicle"
14 
15 static int vehicle_debug;
16 #define VEHICLE_DG(format, ...) do {	\
17 	if (vehicle_debug)	\
18 		pr_info("%s %s(%d): " format, __func__, __LINE__, ## __VA_ARGS__);	\
19 	} while (0)
20 
21 #define VEHICLE_DGERR(format, ...)  \
22 	pr_info("%s %s(%d):" format, VEHICLE_DRIVER_NAME, __func__, __LINE__, ## __VA_ARGS__)
23 #define VEHICLE_INFO(format, ...)  \
24 	pr_info("%s %s(%d):" format, VEHICLE_DRIVER_NAME, __func__, __LINE__, ## __VA_ARGS__)
25 
26 #define MAX_BUF_NUM (6)
27 
28 #define CVBS_DOUBLE_FPS_MODE	/*PAL 50fps; NTSC 60fps*/
29 
30 enum {
31 	CIF_INPUT_FORMAT_YUV = 0,
32 	CIF_INPUT_FORMAT_PAL = 2,
33 	CIF_INPUT_FORMAT_NTSC = 3,
34 	CIF_INPUT_FORMAT_RAW = 4,
35 	CIF_INPUT_FORMAT_JPEG = 5,
36 	CIF_INPUT_FORMAT_MIPI = 6,
37 	CIF_INPUT_FORMAT_PAL_SW_COMPOSITE = 0xff000000,
38 	CIF_INPUT_FORMAT_NTSC_SW_COMPOSITE = 0xfe000000,
39 };
40 
41 enum {
42 	CIF_OUTPUT_FORMAT_422 = 0,
43 	CIF_OUTPUT_FORMAT_420 = 1,
44 };
45 
46 struct vehicle_cfg {
47 	/* output */
48 	int width;
49 	int height;
50 	/* sensor output */
51 	int src_width;
52 	int src_height;
53 	/*
54 	 * action:	source video data input format.
55 	 * 000 - YUV
56 	 * 010 - PAL
57 	 * 011 - NTSC
58 	 * 100 - RAW
59 	 * 101 - JPEG
60 	 * 110 - MIPI
61 	 */
62 	int input_format;
63 	/*
64 	 * 0 - output is 422
65 	 * 1 - output is 420
66 	 */
67 	int output_format;
68 	/*
69 	 * YUV input order
70 	 * 00 - UYVY
71 	 * 01 - YVYU
72 	 * 10 - VYUY
73 	 * 11 - YUYV
74 	 */
75 	int yuv_order;
76 	/*
77 	 * ccir input order
78 	 * 0 : odd field first
79 	 * 1 : even field first
80 	 */
81 	int field_order;
82 
83 	/*
84 	 * BT.656 not use
85 	 * BT.601 hsync polarity
86 	 * val:
87 	 * 0-low active
88 	 * 1-high active
89 	 */
90 	int href;
91 	/*
92 	 * BT.656 not use
93 	 * BT.601 hsync polarity
94 	 * val :
95 	 * 0-low active
96 	 * 1-high active
97 	 */
98 	int vsync;
99 
100 	/*
101 	 * enum v4l2_mbus_type - media bus type
102 	 * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync
103 	 * @V4L2_MBUS_BT656:	parallel interface with embedded synchronisation, can
104 	 *			also be used for BT.1120
105 	 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface
106 	 * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2)
107 	 * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
108 	 */
109 	enum v4l2_mbus_type type;
110 
111 	/*
112 	 * Signal polarity flags
113 	 * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused
114 	 * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying
115 	 * configuration of hardware that uses [HV]REF signals
116 	 */
117 	unsigned int mbus_flags;
118 
119 	/*
120 	 * Note: in BT.656/601 mode mipi_freq are unused
121 	 * only used when v4l2_mbus_type is V4L2_MBUS_CSI2
122 	 */
123 	s64 mipi_freq;
124 	/*
125 	 * Note: in BT.656/601 mode mipi_freq are unused
126 	 * only used when v4l2_mbus_type is V4L2_MBUS_CSI2
127 	 */
128 	int lanes;
129 
130 	u32 mbus_code;
131 
132 	int start_x;
133 	int start_y;
134 	int frame_rate;
135 
136 	unsigned int buf_phy_addr[MAX_BUF_NUM];
137 	unsigned int buf_num;
138 	int ad_ready;
139 	/*0:no, 1:90; 2:180; 4:270; 0x10:mirror-y; 0x20:mirror-x*/
140 	int rotate_mirror;
141 	struct rkmodule_csi_dphy_param *dphy_param;
142 	int drop_frames;
143 };
144 
145 #endif
146