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