Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 1 | /* |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 2 | * Driver for the Siano SMS1xxx USB dongle |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 3 | * |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 4 | * author: Anatoly Greenblat |
| 5 | * |
| 6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 9 | * it under the terms of the GNU General Public License version 3 as |
| 10 | * published by the Free Software Foundation; |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 11 | * |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 12 | * Software distributed under the License is distributed on an "AS IS" |
| 13 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 14 | * |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 15 | * See the GNU General Public License for more details. |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ |
| 21 | |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 22 | #ifndef __smscoreapi_h__ |
| 23 | #define __smscoreapi_h__ |
| 24 | |
Steven Toth | 955e9ca | 2008-05-22 15:46:32 -0300 | [diff] [blame] | 25 | #include <linux/version.h> |
| 26 | #include <linux/device.h> |
| 27 | #include <linux/list.h> |
| 28 | #include <linux/mm.h> |
| 29 | #include <asm/scatterlist.h> |
| 30 | #include <asm/page.h> |
| 31 | |
Steven Toth | 19d703d | 2008-05-22 18:06:41 -0300 | [diff] [blame] | 32 | #include "dmxdev.h" |
| 33 | #include "dvbdev.h" |
| 34 | #include "dvb_demux.h" |
| 35 | #include "dvb_frontend.h" |
| 36 | |
Steven Toth | 955e9ca | 2008-05-22 15:46:32 -0300 | [diff] [blame] | 37 | #include <linux/mutex.h> |
| 38 | |
| 39 | typedef struct mutex kmutex_t; |
| 40 | |
| 41 | #define kmutex_init(_p_) mutex_init(_p_) |
| 42 | #define kmutex_lock(_p_) mutex_lock(_p_) |
| 43 | #define kmutex_trylock(_p_) mutex_trylock(_p_) |
| 44 | #define kmutex_unlock(_p_) mutex_unlock(_p_) |
| 45 | |
| 46 | |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 47 | #ifndef min |
| 48 | #define min(a,b) (((a) < (b)) ? (a) : (b)) |
| 49 | #endif |
| 50 | |
| 51 | #define SMS_ALLOC_ALIGNMENT 128 |
| 52 | #define SMS_DMA_ALIGNMENT 16 |
| 53 | #define SMS_ALIGN_ADDRESS(addr) ((((u32)(addr)) + (SMS_DMA_ALIGNMENT-1)) & ~(SMS_DMA_ALIGNMENT-1)) |
| 54 | |
| 55 | #define SMS_DEVICE_FAMILY2 1 |
| 56 | #define SMS_ROM_NO_RESPONSE 2 |
| 57 | #define SMS_DEVICE_NOT_READY 0x8000000 |
| 58 | |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 59 | typedef enum { |
| 60 | SMS_STELLAR= 0, |
| 61 | SMS_NOVA_A0, |
| 62 | SMS_NOVA_B0, |
| 63 | SMS_VEGA, |
| 64 | SMS_NUM_OF_DEVICE_TYPES |
| 65 | } sms_device_type_st; |
| 66 | |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 67 | typedef struct _smscore_device smscore_device_t; |
| 68 | typedef struct _smscore_client smscore_client_t; |
| 69 | typedef struct _smscore_buffer smscore_buffer_t; |
| 70 | |
| 71 | typedef int (*hotplug_t)(smscore_device_t *coredev, struct device *device, int arrival); |
| 72 | |
| 73 | typedef int (*setmode_t)(void *context, int mode); |
| 74 | typedef void (*detectmode_t)(void *context, int *mode); |
| 75 | typedef int (*sendrequest_t)(void *context, void *buffer, size_t size); |
| 76 | typedef int (*loadfirmware_t)(void *context, void *buffer, size_t size); |
| 77 | typedef int (*preload_t)(void *context); |
| 78 | typedef int (*postload_t)(void *context); |
| 79 | |
| 80 | typedef int (*onresponse_t)(void *context, smscore_buffer_t *cb); |
| 81 | typedef void (*onremove_t)(void *context); |
| 82 | |
| 83 | typedef struct _smscore_buffer |
| 84 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 85 | /* public members, once passed to clients can be changed freely */ |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 86 | struct list_head entry; |
| 87 | int size; |
| 88 | int offset; |
| 89 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 90 | /* private members, read-only for clients */ |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 91 | void *p; |
| 92 | dma_addr_t phys; |
| 93 | unsigned long offset_in_common; |
| 94 | } *psmscore_buffer_t; |
| 95 | |
| 96 | typedef struct _smsdevice_params |
| 97 | { |
| 98 | struct device *device; |
| 99 | |
| 100 | int buffer_size; |
| 101 | int num_buffers; |
| 102 | |
| 103 | char devpath[32]; |
| 104 | unsigned long flags; |
| 105 | |
| 106 | setmode_t setmode_handler; |
| 107 | detectmode_t detectmode_handler; |
| 108 | sendrequest_t sendrequest_handler; |
| 109 | preload_t preload_handler; |
| 110 | postload_t postload_handler; |
| 111 | |
| 112 | void *context; |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 113 | sms_device_type_st device_type; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 114 | } smsdevice_params_t; |
| 115 | |
| 116 | typedef struct _smsclient_params |
| 117 | { |
| 118 | int initial_id; |
| 119 | int data_type; |
| 120 | onresponse_t onresponse_handler; |
| 121 | onremove_t onremove_handler; |
| 122 | |
| 123 | void *context; |
| 124 | } smsclient_params_t; |
| 125 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 126 | /* GPIO definitions for antenna frequency domain control (SMS8021) */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 127 | #define SMS_ANTENNA_GPIO_0 1 |
| 128 | #define SMS_ANTENNA_GPIO_1 0 |
| 129 | |
| 130 | #define BW_8_MHZ 0 |
| 131 | #define BW_7_MHZ 1 |
| 132 | #define BW_6_MHZ 2 |
| 133 | #define BW_5_MHZ 3 |
| 134 | #define BW_ISDBT_1SEG 4 |
| 135 | #define BW_ISDBT_3SEG 5 |
| 136 | |
| 137 | #define MSG_HDR_FLAG_SPLIT_MSG 4 |
| 138 | |
| 139 | #define MAX_GPIO_PIN_NUMBER 31 |
| 140 | |
| 141 | #define HIF_TASK 11 |
| 142 | #define SMS_HOST_LIB 150 |
| 143 | #define DVBT_BDA_CONTROL_MSG_ID 201 |
| 144 | |
| 145 | #define SMS_MAX_PAYLOAD_SIZE 240 |
| 146 | #define SMS_TUNE_TIMEOUT 500 |
| 147 | |
| 148 | #define MSG_SMS_GPIO_CONFIG_REQ 507 |
| 149 | #define MSG_SMS_GPIO_CONFIG_RES 508 |
| 150 | #define MSG_SMS_GPIO_SET_LEVEL_REQ 509 |
| 151 | #define MSG_SMS_GPIO_SET_LEVEL_RES 510 |
| 152 | #define MSG_SMS_GPIO_GET_LEVEL_REQ 511 |
| 153 | #define MSG_SMS_GPIO_GET_LEVEL_RES 512 |
| 154 | #define MSG_SMS_RF_TUNE_REQ 561 |
| 155 | #define MSG_SMS_RF_TUNE_RES 562 |
| 156 | #define MSG_SMS_INIT_DEVICE_REQ 578 |
| 157 | #define MSG_SMS_INIT_DEVICE_RES 579 |
| 158 | #define MSG_SMS_ADD_PID_FILTER_REQ 601 |
| 159 | #define MSG_SMS_ADD_PID_FILTER_RES 602 |
| 160 | #define MSG_SMS_REMOVE_PID_FILTER_REQ 603 |
| 161 | #define MSG_SMS_REMOVE_PID_FILTER_RES 604 |
| 162 | #define MSG_SMS_DAB_CHANNEL 607 |
| 163 | #define MSG_SMS_GET_PID_FILTER_LIST_REQ 608 |
| 164 | #define MSG_SMS_GET_PID_FILTER_LIST_RES 609 |
| 165 | #define MSG_SMS_GET_STATISTICS_REQ 615 |
| 166 | #define MSG_SMS_GET_STATISTICS_RES 616 |
| 167 | #define MSG_SMS_SET_ANTENNA_CONFIG_REQ 651 |
| 168 | #define MSG_SMS_SET_ANTENNA_CONFIG_RES 652 |
| 169 | #define MSG_SMS_GET_STATISTICS_EX_REQ 653 |
| 170 | #define MSG_SMS_GET_STATISTICS_EX_RES 654 |
| 171 | #define MSG_SMS_SLEEP_RESUME_COMP_IND 655 |
| 172 | #define MSG_SMS_DATA_DOWNLOAD_REQ 660 |
| 173 | #define MSG_SMS_DATA_DOWNLOAD_RES 661 |
| 174 | #define MSG_SMS_SWDOWNLOAD_TRIGGER_REQ 664 |
| 175 | #define MSG_SMS_SWDOWNLOAD_TRIGGER_RES 665 |
| 176 | #define MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ 666 |
| 177 | #define MSG_SMS_SWDOWNLOAD_BACKDOOR_RES 667 |
| 178 | #define MSG_SMS_GET_VERSION_EX_REQ 668 |
| 179 | #define MSG_SMS_GET_VERSION_EX_RES 669 |
| 180 | #define MSG_SMS_SET_CLOCK_OUTPUT_REQ 670 |
| 181 | #define MSG_SMS_I2C_SET_FREQ_REQ 685 |
| 182 | #define MSG_SMS_GENERIC_I2C_REQ 687 |
| 183 | #define MSG_SMS_GENERIC_I2C_RES 688 |
| 184 | #define MSG_SMS_DVBT_BDA_DATA 693 |
| 185 | #define MSG_SW_RELOAD_REQ 697 |
| 186 | #define MSG_SMS_DATA_MSG 699 |
| 187 | #define MSG_SW_RELOAD_START_REQ 702 |
| 188 | #define MSG_SW_RELOAD_START_RES 703 |
| 189 | #define MSG_SW_RELOAD_EXEC_REQ 704 |
| 190 | #define MSG_SW_RELOAD_EXEC_RES 705 |
| 191 | #define MSG_SMS_SPI_INT_LINE_SET_REQ 710 |
| 192 | #define MSG_SMS_ISDBT_TUNE_REQ 776 |
| 193 | #define MSG_SMS_ISDBT_TUNE_RES 777 |
| 194 | |
| 195 | #define SMS_INIT_MSG_EX(ptr, type, src, dst, len) do { \ |
| 196 | (ptr)->msgType = type; (ptr)->msgSrcId = src; (ptr)->msgDstId = dst; \ |
| 197 | (ptr)->msgLength = len; (ptr)->msgFlags = 0; \ |
| 198 | } while (0) |
| 199 | #define SMS_INIT_MSG(ptr, type, len) SMS_INIT_MSG_EX(ptr, type, 0, HIF_TASK, len) |
| 200 | |
| 201 | typedef enum |
| 202 | { |
| 203 | DEVICE_MODE_NONE = -1, |
| 204 | DEVICE_MODE_DVBT = 0, |
| 205 | DEVICE_MODE_DVBH, |
| 206 | DEVICE_MODE_DAB_TDMB, |
| 207 | DEVICE_MODE_DAB_TDMB_DABIP, |
| 208 | DEVICE_MODE_DVBT_BDA, |
| 209 | DEVICE_MODE_ISDBT, |
| 210 | DEVICE_MODE_ISDBT_BDA, |
| 211 | DEVICE_MODE_CMMB, |
| 212 | DEVICE_MODE_RAW_TUNER, |
| 213 | DEVICE_MODE_MAX, |
| 214 | } SMS_DEVICE_MODE; |
| 215 | |
| 216 | typedef unsigned char UINT8; |
| 217 | typedef unsigned short UINT16; |
| 218 | typedef unsigned int UINT32; |
| 219 | typedef int INT32; |
| 220 | |
| 221 | typedef struct SmsMsgHdr_S |
| 222 | { |
| 223 | UINT16 msgType; |
| 224 | UINT8 msgSrcId; |
| 225 | UINT8 msgDstId; |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 226 | UINT16 msgLength; /* Length of entire message, including header */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 227 | UINT16 msgFlags; |
| 228 | } SmsMsgHdr_ST; |
| 229 | |
| 230 | typedef struct SmsMsgData_S |
| 231 | { |
| 232 | SmsMsgHdr_ST xMsgHeader; |
| 233 | UINT32 msgData[1]; |
| 234 | } SmsMsgData_ST; |
| 235 | |
| 236 | typedef struct SmsDataDownload_S |
| 237 | { |
| 238 | SmsMsgHdr_ST xMsgHeader; |
| 239 | UINT32 MemAddr; |
| 240 | UINT8 Payload[SMS_MAX_PAYLOAD_SIZE]; |
| 241 | } SmsDataDownload_ST; |
| 242 | |
| 243 | typedef struct SmsVersionRes_S |
| 244 | { |
| 245 | SmsMsgHdr_ST xMsgHeader; |
| 246 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 247 | UINT16 ChipModel; /* e.g. 0x1102 for SMS-1102 "Nova" */ |
| 248 | UINT8 Step; /* 0 - Step A */ |
| 249 | UINT8 MetalFix; /* 0 - Metal 0 */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 250 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 251 | UINT8 FirmwareId; /* 0xFF � ROM, otherwise the value indicated by SMSHOSTLIB_DEVICE_MODES_E */ |
| 252 | UINT8 SupportedProtocols; /* Bitwise OR combination of supported protocols */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 253 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 254 | UINT8 VersionMajor; |
| 255 | UINT8 VersionMinor; |
| 256 | UINT8 VersionPatch; |
| 257 | UINT8 VersionFieldPatch; |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 258 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 259 | UINT8 RomVersionMajor; |
| 260 | UINT8 RomVersionMinor; |
| 261 | UINT8 RomVersionPatch; |
| 262 | UINT8 RomVersionFieldPatch; |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 263 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 264 | UINT8 TextLabel[34]; |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 265 | } SmsVersionRes_ST; |
| 266 | |
| 267 | typedef struct SmsFirmware_S |
| 268 | { |
| 269 | UINT32 CheckSum; |
| 270 | UINT32 Length; |
| 271 | UINT32 StartAddress; |
| 272 | UINT8 Payload[1]; |
| 273 | } SmsFirmware_ST; |
| 274 | |
| 275 | typedef struct SMSHOSTLIB_STATISTICS_S |
| 276 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 277 | UINT32 Reserved; /* Reserved */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 278 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 279 | /* Common parameters */ |
| 280 | UINT32 IsRfLocked; /* 0 - not locked, 1 - locked */ |
| 281 | UINT32 IsDemodLocked; /* 0 - not locked, 1 - locked */ |
| 282 | UINT32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 283 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 284 | /* Reception quality */ |
| 285 | INT32 SNR; /* dB */ |
| 286 | UINT32 BER; /* Post Viterbi BER [1E-5] */ |
| 287 | UINT32 FIB_CRC; /* CRC errors percentage, valid only for DAB */ |
| 288 | UINT32 TS_PER; /* Transport stream PER, 0xFFFFFFFF indicate N/A, valid only for DVB-T/H */ |
| 289 | UINT32 MFER; /* DVB-H frame error rate in percentage, 0xFFFFFFFF indicate N/A, valid only for DVB-H */ |
| 290 | INT32 RSSI; /* dBm */ |
| 291 | INT32 InBandPwr; /* In band power in dBM */ |
| 292 | INT32 CarrierOffset; /* Carrier Offset in bin/1024 */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 293 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 294 | /* Transmission parameters */ |
| 295 | UINT32 Frequency; /* Frequency in Hz */ |
| 296 | UINT32 Bandwidth; /* Bandwidth in MHz, valid only for DVB-T/H */ |
| 297 | UINT32 TransmissionMode; /* Transmission Mode, for DAB modes 1-4, for DVB-T/H FFT mode carriers in Kilos */ |
| 298 | UINT32 ModemState; /* from SMS_DvbModemState_ET , valid only for DVB-T/H */ |
| 299 | UINT32 GuardInterval; /* Guard Interval, 1 divided by value , valid only for DVB-T/H */ |
| 300 | UINT32 CodeRate; /* Code Rate from SMS_DvbModemState_ET, valid only for DVB-T/H */ |
| 301 | UINT32 LPCodeRate; /* Low Priority Code Rate from SMS_DvbModemState_ET, valid only for DVB-T/H */ |
| 302 | UINT32 Hierarchy; /* Hierarchy from SMS_Hierarchy_ET, valid only for DVB-T/H */ |
| 303 | UINT32 Constellation; /* Constellation from SMS_Constellation_ET, valid only for DVB-T/H */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 304 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 305 | /* Burst parameters, valid only for DVB-H */ |
| 306 | UINT32 BurstSize; /* Current burst size in bytes, valid only for DVB-H */ |
| 307 | UINT32 BurstDuration; /* Current burst duration in mSec, valid only for DVB-H */ |
| 308 | UINT32 BurstCycleTime; /* Current burst cycle time in mSec, valid only for DVB-H */ |
| 309 | UINT32 CalculatedBurstCycleTime; /* Current burst cycle time in mSec, as calculated by demodulator, valid only for DVB-H */ |
| 310 | UINT32 NumOfRows; /* Number of rows in MPE table, valid only for DVB-H */ |
| 311 | UINT32 NumOfPaddCols; /* Number of padding columns in MPE table, valid only for DVB-H */ |
| 312 | UINT32 NumOfPunctCols; /* Number of puncturing columns in MPE table, valid only for DVB-H */ |
| 313 | UINT32 ErrorTSPackets; /* Number of erroneous transport-stream packets */ |
| 314 | UINT32 TotalTSPackets; /* Total number of transport-stream packets */ |
| 315 | UINT32 NumOfValidMpeTlbs; /* Number of MPE tables which do not include errors after MPE RS decoding */ |
| 316 | UINT32 NumOfInvalidMpeTlbs; /* Number of MPE tables which include errors after MPE RS decoding */ |
| 317 | UINT32 NumOfCorrectedMpeTlbs; /* Number of MPE tables which were corrected by MPE RS decoding */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 318 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 319 | /* Common params */ |
| 320 | UINT32 BERErrorCount; /* Number of errornous SYNC bits. */ |
| 321 | UINT32 BERBitCount; /* Total number of SYNC bits. */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 322 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 323 | /* Interface information */ |
| 324 | UINT32 SmsToHostTxErrors; /* Total number of transmission errors. */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 325 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 326 | /* DAB/T-DMB */ |
| 327 | UINT32 PreBER; /* DAB/T-DMB only: Pre Viterbi BER [1E-5] */ |
| 328 | |
| 329 | /* DVB-H TPS parameters */ |
| 330 | UINT32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero; if set to 0xFFFFFFFF cell_id not yet recovered */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 331 | |
| 332 | } SMSHOSTLIB_STATISTICS_ST; |
| 333 | |
| 334 | typedef struct |
| 335 | { |
| 336 | UINT32 RequestResult; |
| 337 | |
| 338 | SMSHOSTLIB_STATISTICS_ST Stat; |
| 339 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 340 | /* Split the calc of the SNR in DAB */ |
| 341 | UINT32 Signal; /* dB */ |
| 342 | UINT32 Noise; /* dB */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 343 | |
| 344 | } SmsMsgStatisticsInfo_ST; |
| 345 | |
| 346 | typedef struct SMSHOSTLIB_ISDBT_LAYER_STAT_S |
| 347 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 348 | /* Per-layer information */ |
| 349 | UINT32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET, 255 means layer does not exist */ |
| 350 | UINT32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET, 255 means layer does not exist */ |
| 351 | UINT32 BER; /* Post Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */ |
| 352 | UINT32 BERErrorCount; /* Post Viterbi Error Bits Count */ |
| 353 | UINT32 BERBitCount; /* Post Viterbi Total Bits Count */ |
| 354 | UINT32 PreBER; /* Pre Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */ |
| 355 | UINT32 TS_PER; /* Transport stream PER [%], 0xFFFFFFFF indicate N/A */ |
| 356 | UINT32 ErrorTSPackets; /* Number of erroneous transport-stream packets */ |
| 357 | UINT32 TotalTSPackets; /* Total number of transport-stream packets */ |
| 358 | UINT32 TILdepthI; /* Time interleaver depth I parameter, 255 means layer does not exist */ |
| 359 | UINT32 NumberOfSegments; /* Number of segments in layer A, 255 means layer does not exist */ |
| 360 | UINT32 TMCCErrors; /* TMCC errors */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 361 | } SMSHOSTLIB_ISDBT_LAYER_STAT_ST; |
| 362 | |
| 363 | typedef struct SMSHOSTLIB_STATISTICS_ISDBT_S |
| 364 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 365 | UINT32 StatisticsType; /* Enumerator identifying the type of the |
| 366 | * structure. Values are the same as |
| 367 | * SMSHOSTLIB_DEVICE_MODES_E |
| 368 | * |
| 369 | * This field MUST always be first in any |
| 370 | * statistics structure */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 371 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 372 | UINT32 FullSize; /* Total size of the structure returned by the modem. If the size requested by |
| 373 | * the host is smaller than FullSize, the struct will be truncated */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 374 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 375 | /* Common parameters */ |
| 376 | UINT32 IsRfLocked; /* 0 - not locked, 1 - locked */ |
| 377 | UINT32 IsDemodLocked; /* 0 - not locked, 1 - locked */ |
| 378 | UINT32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 379 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 380 | /* Reception quality */ |
| 381 | INT32 SNR; /* dB */ |
| 382 | INT32 RSSI; /* dBm */ |
| 383 | INT32 InBandPwr; /* In band power in dBM */ |
| 384 | INT32 CarrierOffset; /* Carrier Offset in Hz */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 385 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 386 | /* Transmission parameters */ |
| 387 | UINT32 Frequency; /* Frequency in Hz */ |
| 388 | UINT32 Bandwidth; /* Bandwidth in MHz */ |
| 389 | UINT32 TransmissionMode; /* ISDB-T transmission mode */ |
| 390 | UINT32 ModemState; /* 0 - Acquisition, 1 - Locked */ |
| 391 | UINT32 GuardInterval; /* Guard Interval, 1 divided by value */ |
| 392 | UINT32 SystemType; /* ISDB-T system type (ISDB-T / ISDB-Tsb) */ |
| 393 | UINT32 PartialReception; /* TRUE - partial reception, FALSE otherwise */ |
| 394 | UINT32 NumOfLayers; /* Number of ISDB-T layers in the network */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 395 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 396 | /* Per-layer information */ |
| 397 | /* Layers A, B and C */ |
| 398 | SMSHOSTLIB_ISDBT_LAYER_STAT_ST LayerInfo[3]; /* Per-layer statistics, see SMSHOSTLIB_ISDBT_LAYER_STAT_ST */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 399 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 400 | /* Interface information */ |
| 401 | UINT32 SmsToHostTxErrors; /* Total number of transmission errors. */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 402 | |
| 403 | } SMSHOSTLIB_STATISTICS_ISDBT_ST; |
| 404 | |
| 405 | typedef struct SMSHOSTLIB_STATISTICS_DVB_S |
| 406 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 407 | UINT32 StatisticsType; /* Enumerator identifying the type of the structure. Values are the same as SMSHOSTLIB_DEVICE_MODES_E |
| 408 | * This fiels MUST always first in any statistics structure */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 409 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 410 | UINT32 FullSize; /* Total size of the structure returned by the modem. If the size requested by |
| 411 | * the host is smaller than FullSize, the struct will be truncated */ |
| 412 | /* Common parameters */ |
| 413 | UINT32 IsRfLocked; /* 0 - not locked, 1 - locked */ |
| 414 | UINT32 IsDemodLocked; /* 0 - not locked, 1 - locked */ |
| 415 | UINT32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 416 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 417 | /* Reception quality */ |
| 418 | INT32 SNR; /* dB */ |
| 419 | UINT32 BER; /* Post Viterbi BER [1E-5] */ |
| 420 | UINT32 BERErrorCount; /* Number of errornous SYNC bits. */ |
| 421 | UINT32 BERBitCount; /* Total number of SYNC bits. */ |
| 422 | UINT32 TS_PER; /* Transport stream PER, 0xFFFFFFFF indicate N/A */ |
| 423 | UINT32 MFER; /* DVB-H frame error rate in percentage, 0xFFFFFFFF indicate N/A, valid only for DVB-H */ |
| 424 | INT32 RSSI; /* dBm */ |
| 425 | INT32 InBandPwr; /* In band power in dBM */ |
| 426 | INT32 CarrierOffset; /* Carrier Offset in bin/1024 */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 427 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 428 | /* Transmission parameters */ |
| 429 | UINT32 Frequency; /* Frequency in Hz */ |
| 430 | UINT32 Bandwidth; /* Bandwidth in MHz */ |
| 431 | UINT32 ModemState; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */ |
| 432 | UINT32 TransmissionMode; /* FFT mode carriers in Kilos */ |
| 433 | UINT32 GuardInterval; /* Guard Interval, 1 divided by value */ |
| 434 | UINT32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET */ |
| 435 | UINT32 LPCodeRate; /* Low Priority Code Rate from SMSHOSTLIB_CODE_RATE_ET */ |
| 436 | UINT32 Hierarchy; /* Hierarchy from SMSHOSTLIB_HIERARCHY_ET */ |
| 437 | UINT32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 438 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 439 | /* Burst parameters, valid only for DVB-H */ |
| 440 | UINT32 BurstSize; /* Current burst size in bytes, valid only for DVB-H */ |
| 441 | UINT32 BurstDuration; /* Current burst duration in mSec, valid only for DVB-H */ |
| 442 | UINT32 BurstCycleTime; /* Current burst cycle time in mSec, valid only for DVB-H */ |
| 443 | UINT32 CalculatedBurstCycleTime; /* Current burst cycle time in mSec, as calculated by demodulator, valid only for DVB-H */ |
| 444 | UINT32 NumOfRows; /* Number of rows in MPE table, valid only for DVB-H */ |
| 445 | UINT32 NumOfPaddCols; /* Number of padding columns in MPE table, valid only for DVB-H */ |
| 446 | UINT32 NumOfPunctCols; /* Number of puncturing columns in MPE table, valid only for DVB-H */ |
| 447 | UINT32 ErrorTSPackets; /* Number of erroneous transport-stream packets */ |
| 448 | UINT32 TotalTSPackets; /* Total number of transport-stream packets */ |
| 449 | UINT32 NumOfValidMpeTlbs; /* Number of MPE tables which do not include errors after MPE RS decoding, valid only for DVB-H */ |
| 450 | UINT32 NumOfInvalidMpeTlbs; /* Number of MPE tables which include errors after MPE RS decoding, valid only for DVB-H */ |
| 451 | UINT32 NumOfCorrectedMpeTlbs; /* Number of MPE tables which were corrected by MPE RS decoding, valid only for DVB-H */ |
| 452 | UINT32 NumMPEReceived; /* DVB-H, Num MPE section received */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 453 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 454 | /* DVB-H TPS parameters */ |
| 455 | UINT32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero; if set to 0xFFFFFFFF cell_id not yet recovered */ |
| 456 | UINT32 DvbhSrvIndHP; /* DVB-H service indication info, bit 1 - Time Slicing indicator, bit 0 - MPE-FEC indicator */ |
| 457 | UINT32 DvbhSrvIndLP; /* DVB-H service indication info, bit 1 - Time Slicing indicator, bit 0 - MPE-FEC indicator */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 458 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 459 | /* Interface information */ |
| 460 | UINT32 SmsToHostTxErrors; /* Total number of transmission errors. */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 461 | |
| 462 | } SMSHOSTLIB_STATISTICS_DVB_ST; |
| 463 | |
| 464 | typedef struct SMSHOSTLIB_GPIO_CONFIG_S |
| 465 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 466 | UINT8 Direction; /* GPIO direction: Input - 0, Output - 1 */ |
| 467 | UINT8 PullUpDown; /* PullUp/PullDown: None - 0, PullDown - 1, PullUp - 2, Keeper - 3 */ |
| 468 | UINT8 InputCharacteristics; /* Input Characteristics: Normal - 0, Schmitt trigger - 1 */ |
| 469 | UINT8 OutputSlewRate; /* Output Slew Rate: Fast slew rate - 0, Slow slew rate - 1 */ |
| 470 | UINT8 OutputDriving; /* Output driving capability: 4mA - 0, 8mA - 1, 12mA - 2, 16mA - 3 */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 471 | } SMSHOSTLIB_GPIO_CONFIG_ST; |
| 472 | |
| 473 | typedef struct SMSHOSTLIB_I2C_REQ_S |
| 474 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 475 | UINT32 DeviceAddress; /* I2c device address */ |
| 476 | UINT32 WriteCount; /* number of bytes to write */ |
| 477 | UINT32 ReadCount; /* number of bytes to read */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 478 | UINT8 Data[1]; |
| 479 | } SMSHOSTLIB_I2C_REQ_ST; |
| 480 | |
| 481 | typedef struct SMSHOSTLIB_I2C_RES_S |
| 482 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 483 | UINT32 Status; /* non-zero value in case of failure */ |
| 484 | UINT32 ReadCount; /* number of bytes read */ |
Steven Toth | 9e4fb5e | 2008-05-22 15:48:54 -0300 | [diff] [blame] | 485 | UINT8 Data[1]; |
| 486 | } SMSHOSTLIB_I2C_RES_ST; |
| 487 | |
Steven Toth | 3dd24378 | 2008-05-22 18:01:02 -0300 | [diff] [blame] | 488 | typedef struct _smsdvb_client |
| 489 | { |
| 490 | struct list_head entry; |
| 491 | |
| 492 | smscore_device_t *coredev; |
| 493 | smscore_client_t *smsclient; |
| 494 | |
| 495 | struct dvb_adapter adapter; |
| 496 | struct dvb_demux demux; |
| 497 | struct dmxdev dmxdev; |
| 498 | struct dvb_frontend frontend; |
| 499 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 500 | fe_status_t fe_status; |
| 501 | int fe_ber, fe_snr, fe_signal_strength; |
Steven Toth | 3dd24378 | 2008-05-22 18:01:02 -0300 | [diff] [blame] | 502 | |
| 503 | struct completion tune_done, stat_done; |
| 504 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 505 | /* todo: save freq/band instead whole struct */ |
Steven Toth | 3dd24378 | 2008-05-22 18:01:02 -0300 | [diff] [blame] | 506 | struct dvb_frontend_parameters fe_params; |
| 507 | |
| 508 | } smsdvb_client_t; |
| 509 | |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 510 | extern void smscore_registry_setmode(char *devpath, int mode); |
| 511 | extern int smscore_registry_getmode(char *devpath); |
| 512 | |
| 513 | extern int smscore_register_hotplug(hotplug_t hotplug); |
| 514 | extern void smscore_unregister_hotplug(hotplug_t hotplug); |
| 515 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 516 | extern int smscore_register_device(smsdevice_params_t *params, |
| 517 | smscore_device_t **coredev); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 518 | extern void smscore_unregister_device(smscore_device_t *coredev); |
| 519 | |
| 520 | extern int smscore_start_device(smscore_device_t *coredev); |
Michael Krufky | a83ccdd | 2008-05-06 03:11:51 -0300 | [diff] [blame] | 521 | extern int smscore_load_firmware(smscore_device_t *coredev, char *filename, |
| 522 | loadfirmware_t loadfirmware_handler); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 523 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 524 | extern int smscore_load_firmware_from_buffer(smscore_device_t *coredev, |
| 525 | u8 *buffer, int size, |
| 526 | int new_mode); |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 527 | |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 528 | extern int smscore_set_device_mode(smscore_device_t *coredev, int mode); |
| 529 | extern int smscore_get_device_mode(smscore_device_t *coredev); |
| 530 | |
Michael Krufky | a83ccdd | 2008-05-06 03:11:51 -0300 | [diff] [blame] | 531 | extern int smscore_register_client(smscore_device_t *coredev, |
| 532 | smsclient_params_t *params, |
| 533 | smscore_client_t **client); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 534 | extern void smscore_unregister_client(smscore_client_t *client); |
| 535 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 536 | extern int smsclient_sendrequest(smscore_client_t *client, |
| 537 | void *buffer, size_t size); |
| 538 | extern void smscore_onresponse(smscore_device_t *coredev, |
| 539 | smscore_buffer_t *cb); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 540 | |
| 541 | extern int smscore_get_common_buffer_size(smscore_device_t *coredev); |
Michael Krufky | a83ccdd | 2008-05-06 03:11:51 -0300 | [diff] [blame] | 542 | extern int smscore_map_common_buffer(smscore_device_t *coredev, |
| 543 | struct vm_area_struct *vma); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 544 | |
| 545 | extern smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev); |
| 546 | extern void smscore_putbuffer(smscore_device_t *coredev, smscore_buffer_t *cb); |
| 547 | |
Steven Toth | 3dd24378 | 2008-05-22 18:01:02 -0300 | [diff] [blame] | 548 | /* smsdvb.c */ |
Steven Toth | eae5566 | 2008-05-22 18:04:36 -0300 | [diff] [blame] | 549 | int smsdvb_register(void); |
| 550 | void smsdvb_unregister(void); |
| 551 | |
| 552 | /* smsusb.c */ |
| 553 | int smsusb_register(void); |
| 554 | void smsusb_unregister(void); |
Steven Toth | 3dd24378 | 2008-05-22 18:01:02 -0300 | [diff] [blame] | 555 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame^] | 556 | #endif /* __smscoreapi_h__ */ |