1 /* 2 * A V4L2 driver for nvp6158c yuv cameras. 3 * 4 * Copyright (c) 2019 by Allwinnertech Co., Ltd. http://www.allwinnertech.com 5 * 6 * Authors: Zheng Zequn<zequnzheng@allwinnertech.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 #ifndef _RAPTOR3_COAX_PROTOCOL_ 13 #define _RAPTOR3_COAX_PROTOCOL_ 14 15 #include "common.h" 16 17 /* #define BANK1 0x01 */ 18 /* #define BANK2 0x02 */ 19 /* #define BANK3 0x03 */ 20 /* #define BANKC 0x0C */ 21 22 #define FW_SUCCESS 0 23 #define FW_FAILURE -1 24 25 #define DBG_TX_INIT_PRINT 0 26 #define DBG_TX_CMD_PRINT 0 27 #define DBG_RX_INIT_PRINT 0 28 29 typedef enum NC_COAX_CMD_DEF { 30 COAX_CMD_UNKNOWN = 0, 31 COAX_CMD_IRIS_INC, 32 COAX_CMD_IRIS_DEC, 33 COAX_CMD_FOCUS_INC, 34 COAX_CMD_FOCUS_DEC, 35 COAX_CMD_ZOOM_INC, 36 COAX_CMD_ZOOM_DEC, 37 COAX_CMD_OSD_ON, 38 COAX_CMD_PTZ_UP, 39 COAX_CMD_PTZ_DOWN, 40 COAX_CMD_PTZ_LEFT, 41 COAX_CMD_PTZ_RIGHT, 42 COAX_CMD_OSD_ENTER, 43 COAX_CMD_SPECIAL_FW, 44 COAX_CMD_SPECIAL_CAMEQ, 45 COAX_CMD_SPECIAL_FPS, 46 COAX_CMD_SPECIAL_MOTION, 47 COAX_CMD_TVI_DOWNSTREAM_REQUEST, 48 COAX_CMD_OSD_UP, 49 COAX_CMD_OSD_DOWN, 50 COAX_CMD_OSD_LEFT, 51 COAX_CMD_OSD_RIGHT, 52 COAX_CMD_STOP, 53 54 COAX_CMD_MAX, 55 } NC_COAX_CMD_DEF; 56 57 /*============================================================= 58 * Coaxial Test Structure[APP <-> DRV] 59 ==============================================================*/ 60 typedef struct NC_VD_COAX_TEST_STR { 61 unsigned char ch; 62 unsigned char chip_num; 63 unsigned char bank; 64 unsigned char data_addr; 65 unsigned char param; 66 67 unsigned char rx_src; /* B5/6/7/8 0x7C */ 68 unsigned char rx_slice_lev; /* B5/6/7/8 0x7D */ 69 unsigned char tx_baud; /* B3/4 0x00/80 */ 70 unsigned char tx_pel_baud; /* B3/4 0x02/82 */ 71 unsigned char tx_line_pos0; /* B3/4 0x03/83 */ 72 unsigned char tx_line_pos1; /* B3/4 0x04/84 */ 73 unsigned char tx_pel_line_pos0; /* B3/4 0x07/87 */ 74 unsigned char tx_pel_line_pos1; /* B3/4 0x08/88 */ 75 unsigned char tx_line_count; /* B3/4 0x05/85 */ 76 unsigned char tx_line_count_max; /* B3/4 0x0A/8A */ 77 unsigned char tx_mode; /* B3/4 0x0B/8B */ 78 unsigned char tx_sync_pos0; /* B3/4 0x0D/8D */ 79 unsigned char tx_sync_pos1; /* B3/4 0x0E/8E */ 80 unsigned char tx_even; /* B3/4 0x2F/AF */ 81 unsigned char tx_zero_length; /* B3/4 0x0C */ 82 } NC_VD_COAX_TEST_STR; 83 84 typedef struct NC_VD_COAX_BANK_DUMP_STR { 85 unsigned char ch; 86 unsigned char vd_dev; 87 unsigned char bank; 88 unsigned char rx_pelco_data[256]; 89 } NC_VD_COAX_BANK_DUMP_STR; 90 91 /*============================================================= 92 * Coaxial UP/Down Stream Initialize Structure[APP -> DRV] 93 ==============================================================*/ 94 typedef struct NC_VD_COAX_STR { 95 char *name; 96 unsigned char ch; 97 unsigned char vd_dev; 98 unsigned char param; 99 NC_FORMAT_STANDARD format_standard; 100 NC_FORMAT_RESOLUTION format_resolution; 101 NC_FORMAT_FPS format_fps; 102 NC_VIVO_CH_FORMATDEF vivo_fmt; 103 NC_COAX_CMD_DEF cmd; 104 105 unsigned char rx_pelco_data[8]; 106 unsigned char rx_data1[8]; 107 unsigned char rx_data2[8]; 108 unsigned char rx_data3[8]; 109 unsigned char rx_data4[8]; 110 unsigned char rx_data5[8]; 111 unsigned char rx_data6[8]; 112 } NC_VD_COAX_STR; 113 114 typedef struct _nvp6158_coax_str{ 115 unsigned char ch; 116 unsigned char param; 117 NC_VIVO_CH_FORMATDEF fmt_def; 118 NC_COAX_CMD_DEF cmd; 119 unsigned char rx_pelco_data[8]; 120 unsigned char rx_data1[8]; 121 unsigned char rx_data2[8]; 122 unsigned char rx_data3[8]; 123 unsigned char rx_data4[8]; 124 unsigned char rx_data5[8]; 125 unsigned char rx_data6[8]; 126 } nvp6158_coax_str; 127 128 /*============================================================= 129 * COAX FW Upgrade 130 ==============================================================*/ 131 typedef struct __file_information { 132 unsigned int channel; /* FirmUP Channel */ 133 unsigned int cp_mode; /* Channel Format */ 134 unsigned char filename[64]; 135 unsigned char filePullname[64+32]; /* FirmUP FileNmae */ 136 unsigned int filesize; 137 unsigned int filechecksum; /* (sum of file&0x0000FFFFF) */ 138 unsigned int currentpacketnum; /* current packet sequnce number(0,1,2........) */ 139 unsigned int filepacketnum; /* file packet number = (total size/128bytes), if remain exist, file packet number++ */ 140 unsigned char onepacketbuf[128+32]; 141 142 unsigned int currentFileOffset; /* Current file offset */ 143 unsigned int readsize; /* currnet read size */ 144 145 unsigned int receive_addr; 146 147 unsigned int ispossiblefirmup[16]; /* is it possible to update firmware? */ 148 int result; 149 150 int appstatus[16]; /* Application status */ 151 } FIRMWARE_UP_FILE_INFO, *PFIRMWARE_UP_FILE_INFO; 152 153 /* Coaxial UP Stream Function */ 154 void coax_nvp6158_tx_init(nvp6158_coax_str *ps_coax_str); /* Coax Tx : Initialize */ 155 void coax_nvp6158_tx_cmd_send(nvp6158_coax_str *ps_coax_str); /* Coax Tx : Command Send */ 156 157 int coax_nvp6158_tx_16bit_init(nvp6158_coax_str *ps_coax_str); 158 void coax_nvp6158_tx_16bit_cmd_send(nvp6158_coax_str *ps_coax_str); 159 void coax_nvp6158_tx_cvi_new_cmd_send(nvp6158_coax_str *ps_coax_str); 160 161 /* Coaxial Down Stream Function */ 162 void coax_nvp6158_rx_init(nvp6158_coax_str *ps_coax_str); /* Coax Rx : Initialize */ 163 void coax_nvp6158_rx_data_get(nvp6158_coax_str *coax_rx); /* Coax Rx : All Rx Buffer read */ 164 void coax_nvp6158_rx_buffer_clear(nvp6158_coax_str *ps_coax_str); /* Coax Rx : Rx Buffer Clear */ 165 void coax_nvp6158_rx_deinit(nvp6158_coax_str *ps_coax_str); /* Coax Rx : 3x63 Set[ 1 -> 0 ] */ 166 167 /* Coaxial FW Update Function */ 168 void coax_nvp6158_fw_ready_header_check_from_isp_recv(void *p_param); 169 void coax_nvp6158_fw_ready_cmd_to_isp_send(void *p_param); /* 1.1 FW Update Ready Command Send */ 170 void coax_nvp6158_fw_ready_cmd_ack_from_isp_recv(void *p_param); /* 1.2 FW Update Ready ACK */ 171 void coax_nvp6158_fw_start_cmd_to_isp_send(void *p_param); /* 2.1 FW Update Start Command Send */ 172 void coax_nvp6158_fw_start_cmd_ack_from_isp_recv(void *p_param); /* 2.2 FW Update Start ACK */ 173 void coax_nvp6158_fw_one_packet_data_to_isp_send(void *p_param); /* 3.1 FW Update One Packet Data Send */ 174 void coax_nvp6158_fw_one_packet_data_ack_from_isp_recv(void *p_param); /* 3.2 FW Update One Packet Data ACK */ 175 void coax_nvp6158_fw_end_cmd_to_isp_send(void *p_param); /* 4.1 FW Update End Command Send */ 176 void coax_nvp6158_fw_end_cmd_ack_from_isp_recv(void *p_param); /* 4.2 FW Update End ACK */ 177 178 /* Coaxial Option */ 179 void coax_nvp6158_option_rt_nrt_mode_change_set(void *p_param); /* RT, NRT Mode change */ 180 181 /* Coaxial Test Function */ 182 void coax_nvp6158_test_tx_init_read(NC_VD_COAX_TEST_STR *coax_tx_mode); /* Coax Test : Tx Init Read */ 183 void coax_nvp6158_test_data_set(NC_VD_COAX_TEST_STR *coax_data); /* Coax Test : 1byte Data write */ 184 void coax_nvp6158_test_data_get(NC_VD_COAX_TEST_STR *coax_data); /* Coax Test : 1byte Data read */ 185 void coax_nvp6158_test_Bank_dump_get(NC_VD_COAX_BANK_DUMP_STR *coax_data); /* Bank Dump */ 186 unsigned char acp_isp_read(unsigned char ch, unsigned int reg_addr); 187 188 #endif 189 /******************************************************************** 190 * End of file 191 ********************************************************************/ 192