xref: /OK3568_Linux_fs/kernel/drivers/media/i2c/nvp6158_drv/nvp6158_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		: Raptor3 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 _RAPTOR3_COAX_PROTOCOL_
17 #define _RAPTOR3_COAX_PROTOCOL_
18 
19 #include "nvp6158_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 typedef enum NC_COAX_CMD_DEF
34 {
35 	COAX_CMD_UNKNOWN = 0,
36 	COAX_CMD_IRIS_INC,
37 	COAX_CMD_IRIS_DEC,
38 	COAX_CMD_FOCUS_INC,
39 	COAX_CMD_FOCUS_DEC,
40 	COAX_CMD_ZOOM_INC,
41 	COAX_CMD_ZOOM_DEC,
42 	COAX_CMD_OSD_ON,
43 	COAX_CMD_PTZ_UP,
44 	COAX_CMD_PTZ_DOWN,
45 	COAX_CMD_PTZ_LEFT,
46 	COAX_CMD_PTZ_RIGHT,
47 	COAX_CMD_OSD_ENTER,
48 	COAX_CMD_SPECIAL_FW,
49 	COAX_CMD_SPECIAL_CAMEQ,
50 	COAX_CMD_SPECIAL_FPS,
51 	COAX_CMD_SPECIAL_MOTION,
52 	COAX_CMD_SPECIAL_3DNR_REQUEST,
53 	COAX_CMD_TVI_DOWNSTREAM_REQUEST,
54 	COAX_CMD_OSD_UP,
55 	COAX_CMD_OSD_DOWN,
56 	COAX_CMD_OSD_LEFT,
57 	COAX_CMD_OSD_RIGHT,
58 	COAX_CMD_STOP,
59 
60 	COAX_CMD_MAX,
61 
62 } NC_COAX_CMD_DEF;
63 
64 /*=============================================================
65  * Coaxial Test Structure[APP <-> DRV]
66  ==============================================================*/
67 typedef struct NC_VD_COAX_TEST_STR{
68 	 unsigned char ch;
69 	 unsigned char chip_num;
70 	 unsigned char bank;
71 	 unsigned char data_addr;
72 	 unsigned char param;
73 
74 	 unsigned char rx_src;             //B5/6/7/8 0x7C
75 	 unsigned char rx_slice_lev;       //B5/6/7/8 0x7D
76 	 unsigned char tx_baud;            //B3/4 0x00/80
77 	 unsigned char tx_pel_baud;        //B3/4 0x02/82
78 	 unsigned char tx_line_pos0;       //B3/4 0x03/83
79 	 unsigned char tx_line_pos1;       //B3/4 0x04/84
80 	 unsigned char tx_pel_line_pos0;   //B3/4 0x07/87
81 	 unsigned char tx_pel_line_pos1;   //B3/4 0x08/88
82 	 unsigned char tx_line_count;      //B3/4 0x05/85
83 	 unsigned char tx_line_count_max;  //B3/4 0x0A/8A
84 	 unsigned char tx_mode;            //B3/4 0x0B/8B
85 	 unsigned char tx_sync_pos0;       //B3/4 0x0D/8D
86 	 unsigned char tx_sync_pos1;       //B3/4 0x0E/8E
87 	 unsigned char tx_even;            //B3/4 0x2F/AF
88 	 unsigned char tx_zero_length;     //B3/4 0x0C/
89 } NC_VD_COAX_TEST_STR;
90 
91 typedef struct NC_VD_COAX_BANK_DUMP_STR{
92 	 unsigned char ch;
93 	 unsigned char vd_dev;
94 	 unsigned char bank;
95 
96 	 unsigned char rx_pelco_data[256];
97 
98 } NC_VD_COAX_BANK_DUMP_STR;
99 
100 /*=============================================================
101  * Coaxial UP/Down Stream Initialize Structure[APP -> DRV]
102  ==============================================================*/
103 typedef struct NC_VD_COAX_STR{
104 	 char *name;
105 	 unsigned char ch;
106 	 unsigned char vd_dev;
107 	 unsigned char param;
108 	 NC_FORMAT_STANDARD format_standard;
109 	 NC_FORMAT_RESOLUTION format_resolution;
110 	 NC_FORMAT_FPS format_fps;
111 	 NC_VIVO_CH_FORMATDEF vivo_fmt;
112 	 NC_COAX_CMD_DEF cmd;
113 
114 	 unsigned char rx_pelco_data[8];
115 	 unsigned char rx_data1[8];
116 	 unsigned char rx_data2[8];
117 	 unsigned char rx_data3[8];
118 	 unsigned char rx_data4[8];
119 	 unsigned char rx_data5[8];
120 	 unsigned char rx_data6[8];
121 
122 } NC_VD_COAX_STR;
123 
124 typedef struct _nvp6158_coax_str{
125 	unsigned char ch;
126 	unsigned char param;
127 	NC_VIVO_CH_FORMATDEF fmt_def;
128 	NC_COAX_CMD_DEF cmd;
129 	unsigned char rx_pelco_data[8];
130 	unsigned char rx_data1[8];
131 	unsigned char rx_data2[8];
132 	unsigned char rx_data3[8];
133 	unsigned char rx_data4[8];
134 	unsigned char rx_data5[8];
135 	unsigned char rx_data6[8];
136 
137 } nvp6158_coax_str;
138 
139 /*=============================================================
140  * COAX FW Upgrade
141  ==============================================================*/
142 typedef struct __file_information
143 {
144 	unsigned int	channel;                // FirmUP Channel
145 	unsigned int	cp_mode;                // Channel Format
146   	unsigned char 	filename[64];           //
147   	unsigned char 	filePullname[64+32];    // FirmUP FileNmae
148   	unsigned int	filesize;
149   	unsigned int	filechecksum;		// (sum of file&0x0000FFFFF)
150   	unsigned int	currentpacketnum;	// current packet sequnce number(0,1,2........)
151   	unsigned int	filepacketnum;		// file packet number = (total size/128bytes), if remain exist, file packet number++
152   	unsigned char 	onepacketbuf[128+32];
153 
154   	unsigned int	currentFileOffset;	// Current file offset
155   	unsigned int	readsize;		// currnet read size
156 
157   	unsigned int	receive_addr;
158 
159   	unsigned int	ispossiblefirmup[16]; 	// is it possible to update firmware?
160   	int 		result;
161 
162   	int		appstatus[16];		// Application status
163 
164 } FIRMWARE_UP_FILE_INFO, *PFIRMWARE_UP_FILE_INFO;
165 
166 // Coaxial UP Stream Function
167 void nvp6158_coax_tx_init( nvp6158_coax_str *ps_coax_str );     // Coax Tx : Initialize
168 void nvp6158_coax_tx_cmd_send( nvp6158_coax_str *ps_coax_str ); // Coax Tx : Command Send
169 
170 int nvp6158_coax_tx_16bit_init( nvp6158_coax_str *ps_coax_str );
171 void nvp6158_coax_tx_16bit_cmd_send( nvp6158_coax_str *ps_coax_str );
172 void nvp6158_coax_tx_cvi_new_cmd_send( nvp6158_coax_str *ps_coax_str );
173 
174 // Coaxial Down Stream Function
175 void nvp6158_coax_rx_init( nvp6158_coax_str *ps_coax_str );          	// Coax Rx : Initialize
176 void nvp6158_coax_rx_data_get( nvp6158_coax_str *coax_rx );      	// Coax Rx : All Rx Buffer read
177 void nvp6158_coax_rx_buffer_clear( nvp6158_coax_str *ps_coax_str );  	// Coax Rx : Rx Buffer Clear
178 void nvp6158_coax_rx_deinit( nvp6158_coax_str *ps_coax_str );        	// Coax Rx : 3x63 Set[ 1 -> 0 ]
179 
180 // Coaxial FW Update Function
181 void nvp6158_coax_fw_ready_header_check_from_isp_recv(void *p_param);
182 void nvp6158_coax_fw_ready_cmd_to_isp_send(void *p_param);                // 1.1 FW Update Ready Command Send
183 void nvp6158_coax_fw_ready_cmd_ack_from_isp_recv(void *p_param);          // 1.2 FW Update Ready ACK
184 void nvp6158_coax_fw_start_cmd_to_isp_send( void *p_param );              // 2.1 FW Update Start Command Send
185 void nvp6158_coax_fw_start_cmd_ack_from_isp_recv( void *p_param );        // 2.2 FW Update Start ACK
186 void nvp6158_coax_fw_one_packet_data_to_isp_send( void *p_param );        // 3.1 FW Update One Packet Data Send
187 void nvp6158_coax_fw_one_packet_data_ack_from_isp_recv( void *p_param );  // 3.2 FW Update One Packet Data ACK
188 void nvp6158_coax_fw_end_cmd_to_isp_send( void *p_param );                // 4.1 FW Update End Command Send
189 void nvp6158_coax_fw_end_cmd_ack_from_isp_recv( void *p_param );          // 4.2 FW Update End ACK
190 
191 // Coaxial Option
192 void nvp6158_coax_option_rt_nrt_mode_change_set(void *p_param);    // RT, NRT Mode change
193 
194 // Coaxial Test Function
195 void nvp6158_coax_test_tx_init_read(NC_VD_COAX_TEST_STR *coax_tx_mode);    // Coax Test : Tx Init Read
196 void nvp6158_coax_test_data_set(NC_VD_COAX_TEST_STR *coax_data);           // Coax Test : 1byte Data write
197 void nvp6158_coax_test_data_get(NC_VD_COAX_TEST_STR *coax_data);           // Coax Test : 1byte Data read
198 void nvp6158_coax_test_Bank_dump_get(NC_VD_COAX_BANK_DUMP_STR *coax_data); // Bank Dump
199 unsigned char nvp6158_coax_acp_isp_read(unsigned char ch, unsigned int reg_addr);
200 unsigned char nvp6158_coax_acp_isp_write(unsigned char ch, unsigned int reg_addr, unsigned char reg_data);
201 
202 #endif
203 /********************************************************************
204  *  End of file
205  ********************************************************************/
206