xref: /OK3568_Linux_fs/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_coax_protocol.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /********************************************************************************
3  *
4  *  Copyright (C) 2017 	NEXTCHIP Inc. All rights reserved.
5  *  Module		: Jaguar1 Device Driver
6  *  Description	: coax_protocol.h
7  *  Author		:
8  *  Date         :
9  *  Version		: Version 1.0
10  *
11  ********************************************************************************
12  *  History      :
13  *
14  *
15  ********************************************************************************/
16 #ifndef _JAGUAR1_COAX_PROTOCOL_
17 #define _JAGUAR1_COAX_PROTOCOL_
18 
19 #include "jaguar1_common.h"
20 
21 #define BANK1 0x01
22 #define BANK2 0x02
23 #define BANK3 0x03
24 #define BANKC 0x0C
25 
26 #define FW_SUCCESS 0
27 #define FW_FAILURE -1
28 
29 #define DBG_TX_INIT_PRINT 0
30 #define DBG_TX_CMD_PRINT 0
31 #define DBG_RX_INIT_PRINT 0
32 
33 /* ACP command status */
34 #define ACP_CAM_STAT			0x55
35 #define ACP_REG_WR				0x60
36 #define ACP_REG_RD				0x61
37 #define ACP_MODE_ID				0x60
38 
39 typedef enum NC_COAX_CMD_DEF
40 {
41 	COAX_CMD_UNKNOWN = 0,
42 	COAX_CMD_IRIS_INC,
43 	COAX_CMD_IRIS_DEC,
44 	COAX_CMD_FOCUS_INC,
45 	COAX_CMD_FOCUS_DEC,
46 	COAX_CMD_ZOOM_INC,
47 	COAX_CMD_ZOOM_DEC,
48 	COAX_CMD_OSD_ON,
49 	COAX_CMD_PTZ_UP,
50 	COAX_CMD_PTZ_DOWN,
51 	COAX_CMD_PTZ_LEFT,
52 	COAX_CMD_PTZ_RIGHT,
53 	COAX_CMD_OSD_ENTER,
54 	COAX_CMD_SPECIAL_FW,
55 	COAX_CMD_SPECIAL_CAMEQ,
56 	COAX_CMD_SPECIAL_FPS,
57 	COAX_CMD_SPECIAL_MOTION,
58 	COAX_CMD_TVI_DOWNSTREAM_REQUEST,
59 
60 	COAX_CMD_MAX,
61 
62 } NC_COAX_CMD_DEF;
63 
64 typedef struct _nc_acp_rw_data_
65 {
66 	unsigned char opt;
67     unsigned char ch;
68 	unsigned int addr;
69 	unsigned char data;
70 }nc_acp_rw_data;
71 
72 
73 /*=============================================================
74  * Coaxial Test Structure[APP <-> DRV]
75  ==============================================================*/
76 typedef struct NC_VD_COAX_TEST_STR{
77 	unsigned char ch;
78 	unsigned char chip_num;
79 	unsigned char bank;
80 	unsigned char data_addr;
81 	unsigned char param;
82 
83 	unsigned char rx_src;             //B5/6/7/8 0x7C
84 	unsigned char rx_slice_lev;       //B5/6/7/8 0x7D
85 	unsigned char tx_baud;            //B3/4 0x00/80
86 	unsigned char tx_pel_baud;        //B3/4 0x02/82
87 	unsigned char tx_line_pos0;       //B3/4 0x03/83
88 	unsigned char tx_line_pos1;       //B3/4 0x04/84
89 	unsigned char tx_pel_line_pos0;   //B3/4 0x07/87
90 	unsigned char tx_pel_line_pos1;   //B3/4 0x08/88
91 	unsigned char tx_line_count;      //B3/4 0x05/85
92 	unsigned char tx_line_count_max;  //B3/4 0x0A/8A
93 	unsigned char tx_mode;            //B3/4 0x0B/8B
94 	unsigned char tx_sync_pos0;       //B3/4 0x0D/8D
95 	unsigned char tx_sync_pos1;       //B3/4 0x0E/8E
96 	unsigned char tx_even;            //B3/4 0x2F/AF
97 	unsigned char tx_zero_length;     //B3/4 0x0C/
98 }NC_VD_COAX_TEST_STR;
99 
100 typedef struct NC_VD_COAX_BANK_DUMP_STR{
101 	unsigned char ch;
102 	unsigned char vd_dev;
103 	unsigned char bank;
104 
105 	unsigned char rx_pelco_data[256];
106 
107 }NC_VD_COAX_BANK_DUMP_STR;
108 
109 /*=============================================================
110  * Coaxial UP/Down Stream Initialize Structure[APP -> DRV]
111  ==============================================================*/
112 typedef struct NC_VD_COAX_STR{
113 	char *name;
114 	unsigned char ch;
115 	unsigned char vd_dev;
116 	unsigned char param;
117 	NC_FORMAT_STANDARD format_standard;
118 	NC_FORMAT_RESOLUTION format_resolution;
119 	NC_FORMAT_FPS format_fps;
120 	NC_VIVO_CH_FORMATDEF vivo_fmt;
121 	NC_COAX_CMD_DEF cmd;
122 
123 	unsigned char rx_pelco_data[8];
124 	unsigned char rx_data1[8];
125 	unsigned char rx_data2[8];
126 	unsigned char rx_data3[8];
127 	unsigned char rx_data4[8];
128 	unsigned char rx_data5[8];
129 	unsigned char rx_data6[8];
130 
131 }NC_VD_COAX_STR;
132 
133 /*=============================================================
134  * COAX FW Upgrade
135  ==============================================================*/
136 typedef struct __file_information
137 {
138 	unsigned int	channel;                // FirmUP Channel
139 	unsigned int	cp_mode;                // Channel Format
140 	unsigned char 	filename[64];           //
141 	unsigned char 	filePullname[64+32];    // FirmUP FileNmae
142 	unsigned int	filesize;
143 	unsigned int	filechecksum;			// (sum of file&0x0000FFFFF)
144 	unsigned int	currentpacketnum;		// current packet sequnce number(0,1,2........)
145 	unsigned int	filepacketnum;			// file packet number = (total size/128bytes), if remain exist, file packet number++
146 	unsigned char 	onepacketbuf[128+32];
147 
148 	unsigned int	currentFileOffset;		// Current file offset
149 	unsigned int	readsize;				// currnet read size
150 
151 	unsigned int receive_addr;
152 
153 	unsigned int	ispossiblefirmup[16]; 	// is it possible to update firmware?
154 	int 			result;
155 
156 	int				appstatus[16];			// Application status
157 
158 } FIRMWARE_UP_FILE_INFO, *PFIRMWARE_UP_FILE_INFO;
159 
160 // Coaxial UP Stream Function
161 void coax_tx_init( void *p_param );     // Coax Tx : Initialize
162 void coax_tx_cmd_send( void *p_param ); // Coax Tx : Command Send
163 
164 void coax_tx_16bit_init( void *p_param );
165 void coax_tx_16bit_cmd_send( void *p_param );
166 void coax_tx_cvi_new_cmd_send( void *p_param );
167 
168 // Coaxial Down Stream Function
169 void coax_rx_init( void *p_param );          // Coax Rx : Initialize
170 void coax_rx_data_get( void *p_param );      // Coax Rx : All Rx Buffer read
171 void coax_rx_buffer_clear( void *p_param );  // Coax Rx : Rx Buffer Clear
172 void coax_rx_deinit( void *p_param );        // Coax Rx : 3x63 Set[ 1 -> 0 ]
173 void coax_acp_rx_detect_get( void *p_param );
174 
175 // Coaxial FW Update Function
176 void coax_fw_ready_header_check_from_isp_recv(void *p_param);
177 void coax_fw_ready_cmd_to_isp_send(void *p_param);                // 1.1 FW Update Ready Command Send
178 void coax_fw_ready_cmd_ack_from_isp_recv(void *p_param);          // 1.2 FW Update Ready ACK
179 void coax_fw_start_cmd_to_isp_send( void *p_param );              // 2.1 FW Update Start Command Send
180 void coax_fw_start_cmd_ack_from_isp_recv( void *p_param );        // 2.2 FW Update Start ACK
181 void coax_fw_one_packet_data_to_isp_send( void *p_param );        // 3.1 FW Update One Packet Data Send
182 void coax_fw_one_packet_data_ack_from_isp_recv( void *p_param );  // 3.2 FW Update One Packet Data ACK
183 void coax_fw_end_cmd_to_isp_send( void *p_param );                // 4.1 FW Update End Command Send
184 void coax_fw_end_cmd_ack_from_isp_recv( void *p_param );          // 4.2 FW Update End ACK
185 void coax_fw_revert_to_previous_fmt_set(void *p_param);
186 
187 // Coaxial Option
188 void coax_option_rt_nrt_mode_change_set(void *p_param);    // RT, NRT Mode change
189 
190 // Coaxial Test Function
191 void coax_test_tx_init_read(NC_VD_COAX_TEST_STR *coax_tx_mode);    // Coax Test : Tx Init Read
192 void coax_test_data_set(NC_VD_COAX_TEST_STR *coax_data);           // Coax Test : 1byte Data write
193 void coax_test_data_get(NC_VD_COAX_TEST_STR *coax_data);           // Coax Test : 1byte Data read
194 void coax_test_Bank_dump_get(NC_VD_COAX_BANK_DUMP_STR *coax_data); // Bank Dump
195 void acp_isp_write(unsigned char ch, unsigned int reg_addr, unsigned char reg_data);
196 unsigned char acp_isp_read(unsigned char ch, unsigned int reg_addr);
197 
198 #endif
199 /********************************************************************
200  *  End of file
201  ********************************************************************/
202