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