smscoreapi.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. /****************************************************************
  2. Siano Mobile Silicon, Inc.
  3. MDTV receiver kernel modules.
  4. Copyright (C) 2006-2008, Uri Shkolnik, Anatoly Greenblat
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ****************************************************************/
  16. #ifndef __SMS_CORE_API_H__
  17. #define __SMS_CORE_API_H__
  18. #include <linux/version.h>
  19. #include <linux/device.h>
  20. #include <linux/list.h>
  21. #include <linux/mm.h>
  22. #include <linux/scatterlist.h>
  23. #include <linux/types.h>
  24. #include <linux/mutex.h>
  25. #include <linux/wait.h>
  26. #include <linux/timer.h>
  27. #include <asm/page.h>
  28. #include "smsir.h"
  29. #define kmutex_init(_p_) mutex_init(_p_)
  30. #define kmutex_lock(_p_) mutex_lock(_p_)
  31. #define kmutex_trylock(_p_) mutex_trylock(_p_)
  32. #define kmutex_unlock(_p_) mutex_unlock(_p_)
  33. #ifndef min
  34. #define min(a, b) (((a) < (b)) ? (a) : (b))
  35. #endif
  36. #define SMS_PROTOCOL_MAX_RAOUNDTRIP_MS (10000)
  37. #define SMS_ALLOC_ALIGNMENT 128
  38. #define SMS_DMA_ALIGNMENT 16
  39. #define SMS_ALIGN_ADDRESS(addr) \
  40. ((((uintptr_t)(addr)) + (SMS_DMA_ALIGNMENT-1)) & ~(SMS_DMA_ALIGNMENT-1))
  41. #define SMS_DEVICE_FAMILY2 1
  42. #define SMS_ROM_NO_RESPONSE 2
  43. #define SMS_DEVICE_NOT_READY 0x8000000
  44. enum sms_device_type_st {
  45. SMS_STELLAR = 0,
  46. SMS_NOVA_A0,
  47. SMS_NOVA_B0,
  48. SMS_VEGA,
  49. SMS_NUM_OF_DEVICE_TYPES
  50. };
  51. struct smscore_device_t;
  52. struct smscore_client_t;
  53. struct smscore_buffer_t;
  54. typedef int (*hotplug_t)(struct smscore_device_t *coredev,
  55. struct device *device, int arrival);
  56. typedef int (*setmode_t)(void *context, int mode);
  57. typedef void (*detectmode_t)(void *context, int *mode);
  58. typedef int (*sendrequest_t)(void *context, void *buffer, size_t size);
  59. typedef int (*loadfirmware_t)(void *context, void *buffer, size_t size);
  60. typedef int (*preload_t)(void *context);
  61. typedef int (*postload_t)(void *context);
  62. typedef int (*onresponse_t)(void *context, struct smscore_buffer_t *cb);
  63. typedef void (*onremove_t)(void *context);
  64. struct smscore_buffer_t {
  65. /* public members, once passed to clients can be changed freely */
  66. struct list_head entry;
  67. int size;
  68. int offset;
  69. /* private members, read-only for clients */
  70. void *p;
  71. dma_addr_t phys;
  72. unsigned long offset_in_common;
  73. };
  74. struct smsdevice_params_t {
  75. struct device *device;
  76. int buffer_size;
  77. int num_buffers;
  78. char devpath[32];
  79. unsigned long flags;
  80. setmode_t setmode_handler;
  81. detectmode_t detectmode_handler;
  82. sendrequest_t sendrequest_handler;
  83. preload_t preload_handler;
  84. postload_t postload_handler;
  85. void *context;
  86. enum sms_device_type_st device_type;
  87. };
  88. struct smsclient_params_t {
  89. int initial_id;
  90. int data_type;
  91. onresponse_t onresponse_handler;
  92. onremove_t onremove_handler;
  93. void *context;
  94. };
  95. struct smscore_device_t {
  96. struct list_head entry;
  97. struct list_head clients;
  98. struct list_head subclients;
  99. spinlock_t clientslock;
  100. struct list_head buffers;
  101. spinlock_t bufferslock;
  102. int num_buffers;
  103. void *common_buffer;
  104. int common_buffer_size;
  105. dma_addr_t common_buffer_phys;
  106. void *context;
  107. struct device *device;
  108. char devpath[32];
  109. unsigned long device_flags;
  110. setmode_t setmode_handler;
  111. detectmode_t detectmode_handler;
  112. sendrequest_t sendrequest_handler;
  113. preload_t preload_handler;
  114. postload_t postload_handler;
  115. int mode, modes_supported;
  116. /* host <--> device messages */
  117. struct completion version_ex_done, data_download_done, trigger_done;
  118. struct completion init_device_done, reload_start_done, resume_done;
  119. struct completion gpio_configuration_done, gpio_set_level_done;
  120. struct completion gpio_get_level_done, ir_init_done;
  121. /* Buffer management */
  122. wait_queue_head_t buffer_mng_waitq;
  123. /* GPIO */
  124. int gpio_get_res;
  125. /* Target hardware board */
  126. int board_id;
  127. /* Firmware */
  128. u8 *fw_buf;
  129. u32 fw_buf_size;
  130. /* Infrared (IR) */
  131. struct ir_t ir;
  132. int led_state;
  133. };
  134. /* GPIO definitions for antenna frequency domain control (SMS8021) */
  135. #define SMS_ANTENNA_GPIO_0 1
  136. #define SMS_ANTENNA_GPIO_1 0
  137. #define BW_8_MHZ 0
  138. #define BW_7_MHZ 1
  139. #define BW_6_MHZ 2
  140. #define BW_5_MHZ 3
  141. #define BW_ISDBT_1SEG 4
  142. #define BW_ISDBT_3SEG 5
  143. #define MSG_HDR_FLAG_SPLIT_MSG 4
  144. #define MAX_GPIO_PIN_NUMBER 31
  145. #define HIF_TASK 11
  146. #define SMS_HOST_LIB 150
  147. #define DVBT_BDA_CONTROL_MSG_ID 201
  148. #define SMS_MAX_PAYLOAD_SIZE 240
  149. #define SMS_TUNE_TIMEOUT 500
  150. #define MSG_SMS_GPIO_CONFIG_REQ 507
  151. #define MSG_SMS_GPIO_CONFIG_RES 508
  152. #define MSG_SMS_GPIO_SET_LEVEL_REQ 509
  153. #define MSG_SMS_GPIO_SET_LEVEL_RES 510
  154. #define MSG_SMS_GPIO_GET_LEVEL_REQ 511
  155. #define MSG_SMS_GPIO_GET_LEVEL_RES 512
  156. #define MSG_SMS_RF_TUNE_REQ 561
  157. #define MSG_SMS_RF_TUNE_RES 562
  158. #define MSG_SMS_INIT_DEVICE_REQ 578
  159. #define MSG_SMS_INIT_DEVICE_RES 579
  160. #define MSG_SMS_ADD_PID_FILTER_REQ 601
  161. #define MSG_SMS_ADD_PID_FILTER_RES 602
  162. #define MSG_SMS_REMOVE_PID_FILTER_REQ 603
  163. #define MSG_SMS_REMOVE_PID_FILTER_RES 604
  164. #define MSG_SMS_DAB_CHANNEL 607
  165. #define MSG_SMS_GET_PID_FILTER_LIST_REQ 608
  166. #define MSG_SMS_GET_PID_FILTER_LIST_RES 609
  167. #define MSG_SMS_GET_STATISTICS_RES 616
  168. #define MSG_SMS_GET_STATISTICS_REQ 615
  169. #define MSG_SMS_HO_PER_SLICES_IND 630
  170. #define MSG_SMS_SET_ANTENNA_CONFIG_REQ 651
  171. #define MSG_SMS_SET_ANTENNA_CONFIG_RES 652
  172. #define MSG_SMS_SLEEP_RESUME_COMP_IND 655
  173. #define MSG_SMS_DATA_DOWNLOAD_REQ 660
  174. #define MSG_SMS_DATA_DOWNLOAD_RES 661
  175. #define MSG_SMS_SWDOWNLOAD_TRIGGER_REQ 664
  176. #define MSG_SMS_SWDOWNLOAD_TRIGGER_RES 665
  177. #define MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ 666
  178. #define MSG_SMS_SWDOWNLOAD_BACKDOOR_RES 667
  179. #define MSG_SMS_GET_VERSION_EX_REQ 668
  180. #define MSG_SMS_GET_VERSION_EX_RES 669
  181. #define MSG_SMS_SET_CLOCK_OUTPUT_REQ 670
  182. #define MSG_SMS_I2C_SET_FREQ_REQ 685
  183. #define MSG_SMS_GENERIC_I2C_REQ 687
  184. #define MSG_SMS_GENERIC_I2C_RES 688
  185. #define MSG_SMS_DVBT_BDA_DATA 693
  186. #define MSG_SW_RELOAD_REQ 697
  187. #define MSG_SMS_DATA_MSG 699
  188. #define MSG_SW_RELOAD_START_REQ 702
  189. #define MSG_SW_RELOAD_START_RES 703
  190. #define MSG_SW_RELOAD_EXEC_REQ 704
  191. #define MSG_SW_RELOAD_EXEC_RES 705
  192. #define MSG_SMS_SPI_INT_LINE_SET_REQ 710
  193. #define MSG_SMS_GPIO_CONFIG_EX_REQ 712
  194. #define MSG_SMS_GPIO_CONFIG_EX_RES 713
  195. #define MSG_SMS_ISDBT_TUNE_REQ 776
  196. #define MSG_SMS_ISDBT_TUNE_RES 777
  197. #define MSG_SMS_TRANSMISSION_IND 782
  198. #define MSG_SMS_START_IR_REQ 800
  199. #define MSG_SMS_START_IR_RES 801
  200. #define MSG_SMS_IR_SAMPLES_IND 802
  201. #define MSG_SMS_SIGNAL_DETECTED_IND 827
  202. #define MSG_SMS_NO_SIGNAL_IND 828
  203. #define SMS_INIT_MSG_EX(ptr, type, src, dst, len) do { \
  204. (ptr)->msgType = type; (ptr)->msgSrcId = src; (ptr)->msgDstId = dst; \
  205. (ptr)->msgLength = len; (ptr)->msgFlags = 0; \
  206. } while (0)
  207. #define SMS_INIT_MSG(ptr, type, len) \
  208. SMS_INIT_MSG_EX(ptr, type, 0, HIF_TASK, len)
  209. enum SMS_DVB3_EVENTS {
  210. DVB3_EVENT_INIT = 0,
  211. DVB3_EVENT_SLEEP,
  212. DVB3_EVENT_HOTPLUG,
  213. DVB3_EVENT_FE_LOCK,
  214. DVB3_EVENT_FE_UNLOCK,
  215. DVB3_EVENT_UNC_OK,
  216. DVB3_EVENT_UNC_ERR
  217. };
  218. enum SMS_DEVICE_MODE {
  219. DEVICE_MODE_NONE = -1,
  220. DEVICE_MODE_DVBT = 0,
  221. DEVICE_MODE_DVBH,
  222. DEVICE_MODE_DAB_TDMB,
  223. DEVICE_MODE_DAB_TDMB_DABIP,
  224. DEVICE_MODE_DVBT_BDA,
  225. DEVICE_MODE_ISDBT,
  226. DEVICE_MODE_ISDBT_BDA,
  227. DEVICE_MODE_CMMB,
  228. DEVICE_MODE_RAW_TUNER,
  229. DEVICE_MODE_MAX,
  230. };
  231. struct SmsMsgHdr_ST {
  232. u16 msgType;
  233. u8 msgSrcId;
  234. u8 msgDstId;
  235. u16 msgLength; /* Length of entire message, including header */
  236. u16 msgFlags;
  237. };
  238. struct SmsMsgData_ST {
  239. struct SmsMsgHdr_ST xMsgHeader;
  240. u32 msgData[1];
  241. };
  242. struct SmsMsgData_ST2 {
  243. struct SmsMsgHdr_ST xMsgHeader;
  244. u32 msgData[2];
  245. };
  246. struct SmsDataDownload_ST {
  247. struct SmsMsgHdr_ST xMsgHeader;
  248. u32 MemAddr;
  249. u8 Payload[SMS_MAX_PAYLOAD_SIZE];
  250. };
  251. struct SmsVersionRes_ST {
  252. struct SmsMsgHdr_ST xMsgHeader;
  253. u16 ChipModel; /* e.g. 0x1102 for SMS-1102 "Nova" */
  254. u8 Step; /* 0 - Step A */
  255. u8 MetalFix; /* 0 - Metal 0 */
  256. /* FirmwareId 0xFF if ROM, otherwise the
  257. * value indicated by SMSHOSTLIB_DEVICE_MODES_E */
  258. u8 FirmwareId;
  259. /* SupportedProtocols Bitwise OR combination of
  260. * supported protocols */
  261. u8 SupportedProtocols;
  262. u8 VersionMajor;
  263. u8 VersionMinor;
  264. u8 VersionPatch;
  265. u8 VersionFieldPatch;
  266. u8 RomVersionMajor;
  267. u8 RomVersionMinor;
  268. u8 RomVersionPatch;
  269. u8 RomVersionFieldPatch;
  270. u8 TextLabel[34];
  271. };
  272. struct SmsFirmware_ST {
  273. u32 CheckSum;
  274. u32 Length;
  275. u32 StartAddress;
  276. u8 Payload[1];
  277. };
  278. /* Statistics information returned as response for
  279. * SmsHostApiGetStatistics_Req */
  280. struct SMSHOSTLIB_STATISTICS_ST {
  281. u32 Reserved; /* Reserved */
  282. /* Common parameters */
  283. u32 IsRfLocked; /* 0 - not locked, 1 - locked */
  284. u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
  285. u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
  286. /* Reception quality */
  287. s32 SNR; /* dB */
  288. u32 BER; /* Post Viterbi BER [1E-5] */
  289. u32 FIB_CRC; /* CRC errors percentage, valid only for DAB */
  290. u32 TS_PER; /* Transport stream PER,
  291. 0xFFFFFFFF indicate N/A, valid only for DVB-T/H */
  292. u32 MFER; /* DVB-H frame error rate in percentage,
  293. 0xFFFFFFFF indicate N/A, valid only for DVB-H */
  294. s32 RSSI; /* dBm */
  295. s32 InBandPwr; /* In band power in dBM */
  296. s32 CarrierOffset; /* Carrier Offset in bin/1024 */
  297. /* Transmission parameters */
  298. u32 Frequency; /* Frequency in Hz */
  299. u32 Bandwidth; /* Bandwidth in MHz, valid only for DVB-T/H */
  300. u32 TransmissionMode; /* Transmission Mode, for DAB modes 1-4,
  301. for DVB-T/H FFT mode carriers in Kilos */
  302. u32 ModemState; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET,
  303. valid only for DVB-T/H */
  304. u32 GuardInterval; /* Guard Interval from
  305. SMSHOSTLIB_GUARD_INTERVALS_ET, valid only for DVB-T/H */
  306. u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET,
  307. valid only for DVB-T/H */
  308. u32 LPCodeRate; /* Low Priority Code Rate from
  309. SMSHOSTLIB_CODE_RATE_ET, valid only for DVB-T/H */
  310. u32 Hierarchy; /* Hierarchy from SMSHOSTLIB_HIERARCHY_ET,
  311. valid only for DVB-T/H */
  312. u32 Constellation; /* Constellation from
  313. SMSHOSTLIB_CONSTELLATION_ET, valid only for DVB-T/H */
  314. /* Burst parameters, valid only for DVB-H */
  315. u32 BurstSize; /* Current burst size in bytes,
  316. valid only for DVB-H */
  317. u32 BurstDuration; /* Current burst duration in mSec,
  318. valid only for DVB-H */
  319. u32 BurstCycleTime; /* Current burst cycle time in mSec,
  320. valid only for DVB-H */
  321. u32 CalculatedBurstCycleTime;/* Current burst cycle time in mSec,
  322. as calculated by demodulator, valid only for DVB-H */
  323. u32 NumOfRows; /* Number of rows in MPE table,
  324. valid only for DVB-H */
  325. u32 NumOfPaddCols; /* Number of padding columns in MPE table,
  326. valid only for DVB-H */
  327. u32 NumOfPunctCols; /* Number of puncturing columns in MPE table,
  328. valid only for DVB-H */
  329. u32 ErrorTSPackets; /* Number of erroneous
  330. transport-stream packets */
  331. u32 TotalTSPackets; /* Total number of transport-stream packets */
  332. u32 NumOfValidMpeTlbs; /* Number of MPE tables which do not include
  333. errors after MPE RS decoding */
  334. u32 NumOfInvalidMpeTlbs;/* Number of MPE tables which include errors
  335. after MPE RS decoding */
  336. u32 NumOfCorrectedMpeTlbs;/* Number of MPE tables which were
  337. corrected by MPE RS decoding */
  338. /* Common params */
  339. u32 BERErrorCount; /* Number of errornous SYNC bits. */
  340. u32 BERBitCount; /* Total number of SYNC bits. */
  341. /* Interface information */
  342. u32 SmsToHostTxErrors; /* Total number of transmission errors. */
  343. /* DAB/T-DMB */
  344. u32 PreBER; /* DAB/T-DMB only: Pre Viterbi BER [1E-5] */
  345. /* DVB-H TPS parameters */
  346. u32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero;
  347. if set to 0xFFFFFFFF cell_id not yet recovered */
  348. u32 DvbhSrvIndHP; /* DVB-H service indication info, bit 1 -
  349. Time Slicing indicator, bit 0 - MPE-FEC indicator */
  350. u32 DvbhSrvIndLP; /* DVB-H service indication info, bit 1 -
  351. Time Slicing indicator, bit 0 - MPE-FEC indicator */
  352. u32 NumMPEReceived; /* DVB-H, Num MPE section received */
  353. u32 ReservedFields[10]; /* Reserved */
  354. };
  355. struct SmsMsgStatisticsInfo_ST {
  356. u32 RequestResult;
  357. struct SMSHOSTLIB_STATISTICS_ST Stat;
  358. /* Split the calc of the SNR in DAB */
  359. u32 Signal; /* dB */
  360. u32 Noise; /* dB */
  361. };
  362. struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST {
  363. /* Per-layer information */
  364. u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET,
  365. * 255 means layer does not exist */
  366. u32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET,
  367. * 255 means layer does not exist */
  368. u32 BER; /* Post Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */
  369. u32 BERErrorCount; /* Post Viterbi Error Bits Count */
  370. u32 BERBitCount; /* Post Viterbi Total Bits Count */
  371. u32 PreBER; /* Pre Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */
  372. u32 TS_PER; /* Transport stream PER [%], 0xFFFFFFFF indicate N/A */
  373. u32 ErrorTSPackets; /* Number of erroneous transport-stream packets */
  374. u32 TotalTSPackets; /* Total number of transport-stream packets */
  375. u32 TILdepthI; /* Time interleaver depth I parameter,
  376. * 255 means layer does not exist */
  377. u32 NumberOfSegments; /* Number of segments in layer A,
  378. * 255 means layer does not exist */
  379. u32 TMCCErrors; /* TMCC errors */
  380. };
  381. struct SMSHOSTLIB_STATISTICS_ISDBT_ST {
  382. u32 StatisticsType; /* Enumerator identifying the type of the
  383. * structure. Values are the same as
  384. * SMSHOSTLIB_DEVICE_MODES_E
  385. *
  386. * This field MUST always be first in any
  387. * statistics structure */
  388. u32 FullSize; /* Total size of the structure returned by the modem.
  389. * If the size requested by the host is smaller than
  390. * FullSize, the struct will be truncated */
  391. /* Common parameters */
  392. u32 IsRfLocked; /* 0 - not locked, 1 - locked */
  393. u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
  394. u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
  395. /* Reception quality */
  396. s32 SNR; /* dB */
  397. s32 RSSI; /* dBm */
  398. s32 InBandPwr; /* In band power in dBM */
  399. s32 CarrierOffset; /* Carrier Offset in Hz */
  400. /* Transmission parameters */
  401. u32 Frequency; /* Frequency in Hz */
  402. u32 Bandwidth; /* Bandwidth in MHz */
  403. u32 TransmissionMode; /* ISDB-T transmission mode */
  404. u32 ModemState; /* 0 - Acquisition, 1 - Locked */
  405. u32 GuardInterval; /* Guard Interval, 1 divided by value */
  406. u32 SystemType; /* ISDB-T system type (ISDB-T / ISDB-Tsb) */
  407. u32 PartialReception; /* TRUE - partial reception, FALSE otherwise */
  408. u32 NumOfLayers; /* Number of ISDB-T layers in the network */
  409. /* Per-layer information */
  410. /* Layers A, B and C */
  411. struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST LayerInfo[3];
  412. /* Per-layer statistics, see SMSHOSTLIB_ISDBT_LAYER_STAT_ST */
  413. /* Interface information */
  414. u32 SmsToHostTxErrors; /* Total number of transmission errors. */
  415. };
  416. struct PID_STATISTICS_DATA_S {
  417. struct PID_BURST_S {
  418. u32 size;
  419. u32 padding_cols;
  420. u32 punct_cols;
  421. u32 duration;
  422. u32 cycle;
  423. u32 calc_cycle;
  424. } burst;
  425. u32 tot_tbl_cnt;
  426. u32 invalid_tbl_cnt;
  427. u32 tot_cor_tbl;
  428. };
  429. struct PID_DATA_S {
  430. u32 pid;
  431. u32 num_rows;
  432. struct PID_STATISTICS_DATA_S pid_statistics;
  433. };
  434. #define CORRECT_STAT_RSSI(_stat) ((_stat).RSSI *= -1)
  435. #define CORRECT_STAT_BANDWIDTH(_stat) (_stat.Bandwidth = 8 - _stat.Bandwidth)
  436. #define CORRECT_STAT_TRANSMISSON_MODE(_stat) \
  437. if (_stat.TransmissionMode == 0) \
  438. _stat.TransmissionMode = 2; \
  439. else if (_stat.TransmissionMode == 1) \
  440. _stat.TransmissionMode = 8; \
  441. else \
  442. _stat.TransmissionMode = 4;
  443. struct TRANSMISSION_STATISTICS_S {
  444. u32 Frequency; /* Frequency in Hz */
  445. u32 Bandwidth; /* Bandwidth in MHz */
  446. u32 TransmissionMode; /* FFT mode carriers in Kilos */
  447. u32 GuardInterval; /* Guard Interval from
  448. SMSHOSTLIB_GUARD_INTERVALS_ET */
  449. u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET */
  450. u32 LPCodeRate; /* Low Priority Code Rate from
  451. SMSHOSTLIB_CODE_RATE_ET */
  452. u32 Hierarchy; /* Hierarchy from SMSHOSTLIB_HIERARCHY_ET */
  453. u32 Constellation; /* Constellation from
  454. SMSHOSTLIB_CONSTELLATION_ET */
  455. /* DVB-H TPS parameters */
  456. u32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero;
  457. if set to 0xFFFFFFFF cell_id not yet recovered */
  458. u32 DvbhSrvIndHP; /* DVB-H service indication info, bit 1 -
  459. Time Slicing indicator, bit 0 - MPE-FEC indicator */
  460. u32 DvbhSrvIndLP; /* DVB-H service indication info, bit 1 -
  461. Time Slicing indicator, bit 0 - MPE-FEC indicator */
  462. u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
  463. };
  464. struct RECEPTION_STATISTICS_S {
  465. u32 IsRfLocked; /* 0 - not locked, 1 - locked */
  466. u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
  467. u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
  468. u32 ModemState; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */
  469. s32 SNR; /* dB */
  470. u32 BER; /* Post Viterbi BER [1E-5] */
  471. u32 BERErrorCount; /* Number of erronous SYNC bits. */
  472. u32 BERBitCount; /* Total number of SYNC bits. */
  473. u32 TS_PER; /* Transport stream PER,
  474. 0xFFFFFFFF indicate N/A */
  475. u32 MFER; /* DVB-H frame error rate in percentage,
  476. 0xFFFFFFFF indicate N/A, valid only for DVB-H */
  477. s32 RSSI; /* dBm */
  478. s32 InBandPwr; /* In band power in dBM */
  479. s32 CarrierOffset; /* Carrier Offset in bin/1024 */
  480. u32 ErrorTSPackets; /* Number of erroneous
  481. transport-stream packets */
  482. u32 TotalTSPackets; /* Total number of transport-stream packets */
  483. s32 MRC_SNR; /* dB */
  484. s32 MRC_RSSI; /* dBm */
  485. s32 MRC_InBandPwr; /* In band power in dBM */
  486. };
  487. /* Statistics information returned as response for
  488. * SmsHostApiGetStatisticsEx_Req for DVB applications, SMS1100 and up */
  489. struct SMSHOSTLIB_STATISTICS_DVB_S {
  490. /* Reception */
  491. struct RECEPTION_STATISTICS_S ReceptionData;
  492. /* Transmission parameters */
  493. struct TRANSMISSION_STATISTICS_S TransmissionData;
  494. /* Burst parameters, valid only for DVB-H */
  495. #define SRVM_MAX_PID_FILTERS 8
  496. struct PID_DATA_S PidData[SRVM_MAX_PID_FILTERS];
  497. };
  498. struct SRVM_SIGNAL_STATUS_S {
  499. u32 result;
  500. u32 snr;
  501. u32 tsPackets;
  502. u32 etsPackets;
  503. u32 constellation;
  504. u32 hpCode;
  505. u32 tpsSrvIndLP;
  506. u32 tpsSrvIndHP;
  507. u32 cellId;
  508. u32 reason;
  509. s32 inBandPower;
  510. u32 requestId;
  511. };
  512. struct SMSHOSTLIB_I2C_REQ_ST {
  513. u32 DeviceAddress; /* I2c device address */
  514. u32 WriteCount; /* number of bytes to write */
  515. u32 ReadCount; /* number of bytes to read */
  516. u8 Data[1];
  517. };
  518. struct SMSHOSTLIB_I2C_RES_ST {
  519. u32 Status; /* non-zero value in case of failure */
  520. u32 ReadCount; /* number of bytes read */
  521. u8 Data[1];
  522. };
  523. struct smscore_config_gpio {
  524. #define SMS_GPIO_DIRECTION_INPUT 0
  525. #define SMS_GPIO_DIRECTION_OUTPUT 1
  526. u8 direction;
  527. #define SMS_GPIO_PULLUPDOWN_NONE 0
  528. #define SMS_GPIO_PULLUPDOWN_PULLDOWN 1
  529. #define SMS_GPIO_PULLUPDOWN_PULLUP 2
  530. #define SMS_GPIO_PULLUPDOWN_KEEPER 3
  531. u8 pullupdown;
  532. #define SMS_GPIO_INPUTCHARACTERISTICS_NORMAL 0
  533. #define SMS_GPIO_INPUTCHARACTERISTICS_SCHMITT 1
  534. u8 inputcharacteristics;
  535. #define SMS_GPIO_OUTPUTSLEWRATE_FAST 0
  536. #define SMS_GPIO_OUTPUTSLEWRATE_SLOW 1
  537. u8 outputslewrate;
  538. #define SMS_GPIO_OUTPUTDRIVING_4mA 0
  539. #define SMS_GPIO_OUTPUTDRIVING_8mA 1
  540. #define SMS_GPIO_OUTPUTDRIVING_12mA 2
  541. #define SMS_GPIO_OUTPUTDRIVING_16mA 3
  542. u8 outputdriving;
  543. };
  544. struct smscore_gpio_config {
  545. #define SMS_GPIO_DIRECTION_INPUT 0
  546. #define SMS_GPIO_DIRECTION_OUTPUT 1
  547. u8 Direction;
  548. #define SMS_GPIO_PULL_UP_DOWN_NONE 0
  549. #define SMS_GPIO_PULL_UP_DOWN_PULLDOWN 1
  550. #define SMS_GPIO_PULL_UP_DOWN_PULLUP 2
  551. #define SMS_GPIO_PULL_UP_DOWN_KEEPER 3
  552. u8 PullUpDown;
  553. #define SMS_GPIO_INPUT_CHARACTERISTICS_NORMAL 0
  554. #define SMS_GPIO_INPUT_CHARACTERISTICS_SCHMITT 1
  555. u8 InputCharacteristics;
  556. #define SMS_GPIO_OUTPUT_SLEW_RATE_SLOW 1 /* 10xx */
  557. #define SMS_GPIO_OUTPUT_SLEW_RATE_FAST 0 /* 10xx */
  558. #define SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS 0 /* 11xx */
  559. #define SMS_GPIO_OUTPUT_SLEW_RATE_0_9_V_NS 1 /* 11xx */
  560. #define SMS_GPIO_OUTPUT_SLEW_RATE_1_7_V_NS 2 /* 11xx */
  561. #define SMS_GPIO_OUTPUT_SLEW_RATE_3_3_V_NS 3 /* 11xx */
  562. u8 OutputSlewRate;
  563. #define SMS_GPIO_OUTPUT_DRIVING_S_4mA 0 /* 10xx */
  564. #define SMS_GPIO_OUTPUT_DRIVING_S_8mA 1 /* 10xx */
  565. #define SMS_GPIO_OUTPUT_DRIVING_S_12mA 2 /* 10xx */
  566. #define SMS_GPIO_OUTPUT_DRIVING_S_16mA 3 /* 10xx */
  567. #define SMS_GPIO_OUTPUT_DRIVING_1_5mA 0 /* 11xx */
  568. #define SMS_GPIO_OUTPUT_DRIVING_2_8mA 1 /* 11xx */
  569. #define SMS_GPIO_OUTPUT_DRIVING_4mA 2 /* 11xx */
  570. #define SMS_GPIO_OUTPUT_DRIVING_7mA 3 /* 11xx */
  571. #define SMS_GPIO_OUTPUT_DRIVING_10mA 4 /* 11xx */
  572. #define SMS_GPIO_OUTPUT_DRIVING_11mA 5 /* 11xx */
  573. #define SMS_GPIO_OUTPUT_DRIVING_14mA 6 /* 11xx */
  574. #define SMS_GPIO_OUTPUT_DRIVING_16mA 7 /* 11xx */
  575. u8 OutputDriving;
  576. };
  577. extern void smscore_registry_setmode(char *devpath, int mode);
  578. extern int smscore_registry_getmode(char *devpath);
  579. extern int smscore_register_hotplug(hotplug_t hotplug);
  580. extern void smscore_unregister_hotplug(hotplug_t hotplug);
  581. extern int smscore_register_device(struct smsdevice_params_t *params,
  582. struct smscore_device_t **coredev);
  583. extern void smscore_unregister_device(struct smscore_device_t *coredev);
  584. extern int smscore_start_device(struct smscore_device_t *coredev);
  585. extern int smscore_load_firmware(struct smscore_device_t *coredev,
  586. char *filename,
  587. loadfirmware_t loadfirmware_handler);
  588. extern int smscore_set_device_mode(struct smscore_device_t *coredev, int mode);
  589. extern int smscore_get_device_mode(struct smscore_device_t *coredev);
  590. extern int smscore_register_client(struct smscore_device_t *coredev,
  591. struct smsclient_params_t *params,
  592. struct smscore_client_t **client);
  593. extern void smscore_unregister_client(struct smscore_client_t *client);
  594. extern int smsclient_sendrequest(struct smscore_client_t *client,
  595. void *buffer, size_t size);
  596. extern void smscore_onresponse(struct smscore_device_t *coredev,
  597. struct smscore_buffer_t *cb);
  598. extern int smscore_get_common_buffer_size(struct smscore_device_t *coredev);
  599. extern int smscore_map_common_buffer(struct smscore_device_t *coredev,
  600. struct vm_area_struct *vma);
  601. extern int smscore_get_fw_filename(struct smscore_device_t *coredev,
  602. int mode, char *filename);
  603. extern int smscore_send_fw_file(struct smscore_device_t *coredev,
  604. u8 *ufwbuf, int size);
  605. extern
  606. struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev);
  607. extern void smscore_putbuffer(struct smscore_device_t *coredev,
  608. struct smscore_buffer_t *cb);
  609. /* old GPIO management */
  610. int smscore_configure_gpio(struct smscore_device_t *coredev, u32 pin,
  611. struct smscore_config_gpio *pinconfig);
  612. int smscore_set_gpio(struct smscore_device_t *coredev, u32 pin, int level);
  613. /* new GPIO management */
  614. extern int smscore_gpio_configure(struct smscore_device_t *coredev, u8 PinNum,
  615. struct smscore_gpio_config *pGpioConfig);
  616. extern int smscore_gpio_set_level(struct smscore_device_t *coredev, u8 PinNum,
  617. u8 NewLevel);
  618. extern int smscore_gpio_get_level(struct smscore_device_t *coredev, u8 PinNum,
  619. u8 *level);
  620. void smscore_set_board_id(struct smscore_device_t *core, int id);
  621. int smscore_get_board_id(struct smscore_device_t *core);
  622. int smscore_led_state(struct smscore_device_t *core, int led);
  623. /* ------------------------------------------------------------------------ */
  624. #define DBG_INFO 1
  625. #define DBG_ADV 2
  626. #define sms_printk(kern, fmt, arg...) \
  627. printk(kern "%s: " fmt "\n", __func__, ##arg)
  628. #define dprintk(kern, lvl, fmt, arg...) do {\
  629. if (sms_dbg & lvl) \
  630. sms_printk(kern, fmt, ##arg); } while (0)
  631. #define sms_log(fmt, arg...) sms_printk(KERN_INFO, fmt, ##arg)
  632. #define sms_err(fmt, arg...) \
  633. sms_printk(KERN_ERR, "line: %d: " fmt, __LINE__, ##arg)
  634. #define sms_warn(fmt, arg...) sms_printk(KERN_WARNING, fmt, ##arg)
  635. #define sms_info(fmt, arg...) \
  636. dprintk(KERN_INFO, DBG_INFO, fmt, ##arg)
  637. #define sms_debug(fmt, arg...) \
  638. dprintk(KERN_DEBUG, DBG_ADV, fmt, ##arg)
  639. #endif /* __SMS_CORE_API_H__ */