Initial commit
[kernel/linux-3.0.git] / drivers / media / radio / si470x / radio-si4705.h
1 /*
2  *  drivers/media/radio/si4705/radio-si4705.h
3  *
4  *  Driver for radios with Silicon Labs Si4705 FM Radio Receivers
5  *
6  *  Copyright (c) 2009 Tobias Lorenz <tobias.lorenz@gmx.net>
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 as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22
23
24 /* driver definitions */
25 #define DRIVER_NAME "radio-si4705"
26 #define DRIVER_AUTHOR "NULL";
27 #define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 1)
28 #define DRIVER_CARD "Silicon Labs Si4705 FM Radio Receiver"
29 #define DRIVER_DESC "I2C radio driver for Si4705 FM Radio Receivers"
30 #define DRIVER_VERSION "1.0.1"
31
32 /* kernel includes */
33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 #include <linux/interrupt.h>
36 #include <linux/workqueue.h>
37 #include <linux/init.h>
38 #include <linux/sched.h>
39 #include <linux/slab.h>
40 #include <linux/input.h>
41 #include <linux/version.h>
42 #include <linux/videodev2.h>
43 #include <linux/mutex.h>
44 #include <linux/si4705_pdata.h>
45 #include <media/v4l2-common.h>
46 #include <media/v4l2-ioctl.h>
47 #include <asm/unaligned.h>
48
49 /**************************************************************************
50  * Register Definitions
51  **************************************************************************/
52
53 /* Power up device and mode selection. */
54 #define POWER_UP                0x01
55 #define POWER_UP_NARGS          3
56 #define POWER_UP_NRESP          1
57 #define POWER_UP_IN_FUNC_FMRX         0x00
58 #define POWER_UP_IN_FUNC_AMRX         0x01
59 #define POWER_UP_IN_FUNC_FMTX         0x02
60 #define POWER_UP_IN_FUNC_WBRX         0x03
61 #define POWER_UP_IN_FUNC_QUERY        0x0F
62 #define POWER_UP_IN_PATCH             0x20
63 #define POWER_UP_IN_GPO2OEN           0x40
64 #define POWER_UP_IN_CTSIEN            0x80
65 #define POWER_UP_IN_OPMODE_RX_ANALOG  0x05
66 #define POWER_UP_IN_OPMODE_RX_DIGITAL 0xB0
67
68 /* Returns revision information on the device. */
69 #define GET_REV                 0x10
70 #define GET_REV_NARGS           1
71 #define GET_REV_NRESP           9
72
73 /* Power down device. */
74 #define POWER_DOWN              0x11
75 #define POWER_DOWN_NARGS                1
76 #define POWER_DOWN_NRESP                1
77
78 /* Sets the value of a property. */
79 #define SET_PROPERTY            0x12
80 #define SET_PROPERTY_NARGS      6
81 #define SET_PROPERTY_NRESP      1
82
83 /* Retrieves a property¡¯s value. */
84 #define GET_PROPERTY            0x13
85 #define GET_PROPERTY_NARGS      4
86 #define GET_PROPERTY_NRESP      4
87
88 /* Reads interrupt status bits. */
89 #define GET_INT_STATUS          0x14
90 #define GET_INT_STATUS_NARGS    1
91 #define GET_INT_STATUS_NRESP    1
92 #define GET_INT_STATUS_CTS              0x80
93 #define GET_INT_STATUS_ERR              0x40
94 #define GET_INT_STATUS_RSQINT   0x08
95 #define GET_INT_STATUS_RDSINT   0x04
96 #define GET_INT_STATUS_STCINT   0x01
97 #define GET_INT_STATUS_CTS_SHFT         7
98 #define GET_INT_STATUS_ERR_SHFT         6
99 #define GET_INT_STATUS_RSQINT_SHFT      3
100 #define GET_INT_STATUS_RDSINT_SHFT      2
101 #define GET_INT_STATUS_STCINT_SHFT      0
102
103 /* Reserved command used for patch file downloads. */
104 #define PATCH_ARGS              0x15
105
106 /* Reserved command used for patch file downloads. */
107 #define PATCH_DATA              0x16
108
109 /* Selects the FM tuning frequency. */
110 #define FM_TUNE_FREQ            0x20
111 #define FM_TUNE_FREQ_NARGS      5
112 #define FM_TUNE_FREQ_NRESP      1
113
114 /* Begins searching for a valid frequency. */
115 #define FM_SEEK_START           0x21
116 #define FM_SEEK_START_NARGS     2
117 #define FM_SEEK_START_NRESP     1
118 #define FM_SEEK_START_IN_WRAP   0x04
119 #define FM_SEEK_START_IN_SEEKUP 0x08
120
121 /* Queries the status of previous FM_TUNE_FREQ or FM_SEEK_START command. */
122 #define FM_TUNE_STATUS                  0x22
123 #define FM_TUNE_STATUS_NARGS            2
124 #define FM_TUNE_STATUS_NRESP            8
125 #define FM_TUNE_STATUS_IN_INTACK        0x01
126 #define FM_TUNE_STATUS_IN_CANCEL        0x02
127 #define FM_TUNE_STATUS_OUT_VALID        0x01
128 #define FM_TUNE_STATUS_OUT_AFCRL        0x02
129 #define FM_TUNE_STATUS_OUT_BTLF         0x80
130
131 /* Queries the status of the Received Signal Quality (RSQ) */
132 /* of the current channel. */
133 #define FM_RSQ_STATUS                   0x23
134 #define FM_RSQ_STATUS_NARGS             2
135 #define FM_RSQ_STATUS_NRESP             8
136 #define FM_RSQ_STATUS_IN_INTACK         0x01
137 #define FM_RSQ_STATUS_OUT_RSSILINT      0x01
138 #define FM_RSQ_STATUS_OUT_RSSIHINT      0x02
139 #define FM_RSQ_STATUS_OUT_ASNRLINT      0x04
140 #define FM_RSQ_STATUS_OUT_ASNRHINT      0x08
141 #define FM_RSQ_STATUS_OUT_BLENDINT      0x80
142 #define FM_RSQ_STATUS_OUT_VALID         0x01
143 #define FM_RSQ_STATUS_OUT_AFCRL         0x02
144 #define FM_RSQ_STATUS_OUT_SMUTE         0x08
145 #define FM_RSQ_STATUS_OUT_PILOT         0x80
146 #define FM_RSQ_STATUS_OUT_STBLEND       0x7F
147
148 /* Returns RDS information for current channel */
149 /* and reads an entry from RDS FIFO. */
150 #define FM_RDS_STATUS                   0x24
151 #define FM_RDS_STATUS_NARGS             2
152 #define FM_RDS_STATUS_NRESP             13
153 #define FM_RDS_STATUS_IN_INTACK         0x01
154 #define FM_RDS_STATUS_IN_MTFIFO         0x02
155 #define FM_RDS_STATUS_OUT_RECV          0x01
156 #define FM_RDS_STATUS_OUT_SYNCLOST      0x02
157 #define FM_RDS_STATUS_OUT_SYNCFOUND     0x04
158 #define FM_RDS_STATUS_OUT_SYNC          0x01
159 #define FM_RDS_STATUS_OUT_GRPLOST       0x04
160 #define FM_RDS_STATUS_OUT_BLED          0x03
161 #define FM_RDS_STATUS_OUT_BLEC          0x0C
162 #define FM_RDS_STATUS_OUT_BLEB          0x30
163 #define FM_RDS_STATUS_OUT_BLEA          0xC0
164 #define FM_RDS_STATUS_OUT_BLED_SHFT     0
165 #define FM_RDS_STATUS_OUT_BLEC_SHFT     2
166 #define FM_RDS_STATUS_OUT_BLEB_SHFT     4
167 #define FM_RDS_STATUS_OUT_BLEA_SHFT     6
168
169 /* Queries the current AGC settings */
170 #define FM_AGC_STATUS                   0x27
171 #define FM_AGC_STATUS_NARGS             1
172 #define FM_AGC_STATUS_NRESP             3
173 #define FM_AGC_STATUS_RFAGCDIS          0x01
174 #define FM_AGC_STATUS_LNAGAINIDX        0x1F
175
176 /* Override AGC setting by disabling and forcing it to a fixed value */
177 #define FM_AGC_OVERRIDE                 0x28
178 #define FM_AGC_OVERRIDE_NARGS           3
179 #define FM_AGC_OVERRIDE_NRESP           1
180 #define FM_AGC_OVERRIDE_RFAGCDIS        0x01
181 #define FM_AGC_OVERRIDE_LNAGAINIDX      0x1F
182
183 /* Configures GPO1, 2, and 3 as output or Hi-Z. */
184 #define GPIO_CTL                0x80
185 #define GPIO_CTL_NARGS          2
186 #define GPIO_CTL_NRESP          1
187 #define GPIO_CTL_GPO3OEN        0x08
188 #define GPIO_CTL_GPO2OEN        0x04
189 #define GPIO_CTL_GPO1OEN        0x02
190
191 /* Sets GPO1, 2, and 3 output level (low or high) */
192 #define GPIO_SET                0x81
193 #define GPIO_SET_NARGS          2
194 #define GPIO_SET_NRESP          1
195 #define GPIO_SET_GPO3LEVEL      0x08
196 #define GPIO_SET_GPO2LEVEL      0x04
197 #define GPIO_SET_GPO1LEVEL      0x02
198
199 /* STATUS bits - Used by all methods */
200 #define STCINT  0x01
201 #define ASQINT  0x02
202 #define RDSINT  0x04
203 #define RSQINT  0x08
204 #define ERR     0x40
205 #define CTS     0x80
206
207 /*==================================================================
208  General Properties
209 ==================================================================*/
210
211 /* GPO_IEN */
212 #define GPO_IEN 0x0001
213 #define GPO_IEN_STCIEN_MASK 0x0001
214 #define GPO_IEN_ASQIEN_MASK 0x0002
215 #define GPO_IEN_RDSIEN_MASK 0x0004
216 #define GPO_IEN_RSQIEN_MASK 0x0008
217 #define GPO_IEN_ERRIEN_MASK 0x0040
218 #define GPO_IEN_CTSIEN_MASK 0x0080
219 #define GPO_IEN_STCREP_MASK 0x0100
220 #define GPO_IEN_ASQREP_MASK 0x0200
221 #define GPO_IEN_RDSREP_MASK 0x0400
222 #define GPO_IEN_RSQREP_MASK 0x0800
223 #define GPO_IEN_STCIEN_SHFT 0
224 #define GPO_IEN_ASQIEN_SHFT 1
225 #define GPO_IEN_RDSIEN_SHFT 2
226 #define GPO_IEN_RSQIEN_SHFT 3
227 #define GPO_IEN_ERRIEN_SHFT 6
228 #define GPO_IEN_CTSIEN_SHFT 7
229 #define GPO_IEN_STCREP_SHFT 8
230 #define GPO_IEN_ASQREP_SHFT 9
231 #define GPO_IEN_RDSREP_SHFT 10
232 #define GPO_IEN_RSQREP_SHFT 11
233
234 /* DIGITAL_INPUT_FORMAT */
235 #define DIGITAL_INPUT_FORMAT            0x0101
236 #define DIGITAL_INPUT_FORMAT_ISIZE_MASK 0x0003
237 #define DIGITAL_INPUT_FORMAT_IMONO_MASK 0x0004
238 #define DIGITAL_INPUT_FORMAT_IMODE_MASK 0x0078
239 #define DIGITAL_INPUT_FORMAT_IFALL_MASK 0x0080
240 #define DIGITAL_INPUT_FORMAT_ISIZE_SHFT 0
241 #define DIGITAL_INPUT_FORMAT_IMONO_SHFT 2
242 #define DIGITAL_INPUT_FORMAT_IMODE_SHFT 3
243 #define DIGITAL_INPUT_FORMAT_IFALL_SHFT 7
244
245 /* DIGITAL_INPUT_SAMPLE_RATE */
246 #define DIGITAL_INPUT_SAMPLE_RATE 0x0103
247
248 /* DIGITAL_OUTPUT_FORMAT */
249 #define DIGITAL_OUTPUT_FORMAT            0x0102
250 #define DIGITAL_OUTPUT_FORMAT_OSIZE_MASK 0x0003
251 #define DIGITAL_OUTPUT_FORMAT_OMONO_MASK 0x0004
252 #define DIGITAL_OUTPUT_FORMAT_OMODE_MASK 0x0078
253 #define DIGITAL_OUTPUT_FORMAT_OFALL_MASK 0x0080
254 #define DIGITAL_OUTPUT_FORMAT_OSIZE_SHFT 0
255 #define DIGITAL_OUTPUT_FORMAT_OMONO_SHFT 2
256 #define DIGITAL_OUTPUT_FORMAT_OMODE_SHFT 3
257 #define DIGITAL_OUTPUT_FORMAT_OFALL_SHFT 7
258
259 /* DIGITAL_OUTPUT_SAMPLE_RATE */
260 #define DIGITAL_OUTPUT_SAMPLE_RATE 0x0104
261
262 /* REFCLK_FREQ */
263 #define REFCLK_FREQ 0x0201
264
265 /* REFCLK_PRESCALE */
266 #define REFCLK_PRESCALE      0x0202
267 #define REFCLK_PRESCALE_MASK 0x0FFF
268 #define REFCLK_PRESCALE_SHFT 0
269
270 /*==================================================================
271  FM Receive Properties
272 ==================================================================*/
273
274 /* FM_DEEMPHASIS */
275 #define FM_DEEMPHASIS      0x1100
276 #define FM_DEEMPHASIS_MASK 0x0003
277 #define FM_DEEMPHASIS_SHFT 0
278
279 /* FM_BLEND_STEREO_THRESHOLD */
280 #define FM_BLEND_STEREO_THRESHOLD      0x1105
281 #define FM_BLEND_STEREO_THRESHOLD_MASK 0x007F
282 #define FM_BLEND_STEREO_THRESHOLD_SHFT 0
283
284 /* FM_BLEND_MONO_THRESHOLD */
285 #define FM_BLEND_MONO_THRESHOLD      0x1106
286 #define FM_BLEND_MONO_THRESHOLD_MASK 0x007F
287 #define FM_BLEND_MONO_THRESHOLD_SHFT 0
288
289 /* FM_ANTENNA_INPUT */
290 #define FM_ANTENNA_INPUT      0x1107
291 #define FM_ANTENNA_INPUT_MASK 0x0001
292 #define FM_ANTENNA_INPUT_SHFT 0
293
294 /* FM_MAX_TUNE_ERROR */
295 #define FM_MAX_TUNE_ERROR      0x1108
296 #define FM_MAX_TUNE_ERROR_MASK 0x007F
297 #define FM_MAX_TUNE_ERROR_SHFT 0
298
299 /* FM_RSQ_INT_SOURCE */
300 #define FM_RSQ_INT_SOURCE               0x1200
301 #define FM_RSQ_INT_SOURCE_RSSILIEN_MASK 0x0001
302 #define FM_RSQ_INT_SOURCE_RSSIHIEN_MASK 0x0002
303 #define FM_RSQ_INT_SOURCE_ASNRLIEN_MASK 0x0004
304 #define FM_RSQ_INT_SOURCE_ASNRHIEN_MASK 0x0008
305 #define FM_RSQ_INT_SOURCE_BLENDIEN_MASK 0x0080
306 #define FM_RSQ_INT_SOURCE_RSSILIEN_SHFT 0
307 #define FM_RSQ_INT_SOURCE_RSSIHIEN_SHFT 1
308 #define FM_RSQ_INT_SOURCE_ASNRLIEN_SHFT 2
309 #define FM_RSQ_INT_SOURCE_ASNRHIEN_SHFT 3
310 #define FM_RSQ_INT_SOURCE_BLENDIEN_SHFT 7
311
312 /* FM_RSQ_SNR_HI_THRESHOLD */
313 #define FM_RSQ_SNR_HI_THRESHOLD      0x1201
314 #define FM_RSQ_SNR_HI_THRESHOLD_MASK 0x007F
315 #define FM_RSQ_SNR_HI_THRESHOLD_SHFT 0
316
317 /* FM_RSQ_SNR_LO_THRESHOLD */
318 #define FM_RSQ_SNR_LO_THRESHOLD      0x1202
319 #define FM_RSQ_SNR_LO_THRESHOLD_MASK 0x007F
320 #define FM_RSQ_SNR_LO_THRESHOLD_SHFT 0
321
322 /* FM_RSQ_RSSI_HI_THRESHOLD */
323 #define FM_RSQ_RSSI_HI_THRESHOLD      0x1203
324 #define FM_RSQ_RSSI_HI_THRESHOLD_MASK 0x007F
325 #define FM_RSQ_RSSI_HI_THRESHOLD_SHFT 0
326
327 /* FM_RSQ_RSSI_LO_THRESHOLD */
328 #define FM_RSQ_RSSI_LO_THRESHOLD      0x1204
329 #define FM_RSQ_RSSI_LO_THRESHOLD_MASK 0x007F
330 #define FM_RSQ_RSSI_LO_THRESHOLD_SHFT 0
331
332 /* FM_RSQ_BLEND_THRESHOLD */
333 #define FM_RSQ_BLEND_THRESHOLD            0x1207
334 #define FM_RSQ_BLEND_THRESHOLD_BLEND_MASK 0x007F
335 #define FM_RSQ_BLEND_THRESHOLD_PILOT_MASK 0x0080
336 #define FM_RSQ_BLEND_THRESHOLD_BLEND_SHFT 0
337 #define FM_RSQ_BLEND_THRESHOLD_PILOT_SHFT 7
338
339 /* FM_SOFT_MUTE_RATE */
340 #define FM_SOFT_MUTE_RATE      0x1300
341 #define FM_SOFT_MUTE_RATE_MASK 0x00FF
342 #define FM_SOFT_MUTE_RATE_SHFT 0
343
344 /* FM_SOFT_MUTE_MAX_ATTENUATION */
345 #define FM_SOFT_MUTE_MAX_ATTENUATION      0x1302
346 #define FM_SOFT_MUTE_MAX_ATTENUATION_MASK 0x001F
347 #define FM_SOFT_MUTE_MAX_ATTENUATION_SHFT 0
348
349 /* FM_SOFT_MUTE_SNR_THRESHOLD */
350 #define FM_SOFT_MUTE_SNR_THRESHOLD      0x1303
351 #define FM_SOFT_MUTE_SNR_THRESHOLD_MASK 0x000F
352 #define FM_SOFT_MUTE_SNR_THRESHOLD_SHFT 0
353
354 /* FM_SEEK_BAND_BOTTOM */
355 #define FM_SEEK_BAND_BOTTOM 0x1400
356
357 /* FM_SEEK_BAND_TOP */
358 #define FM_SEEK_BAND_TOP 0x1401
359
360 /* FM_SEEK_FREQ_SPACING */
361 #define FM_SEEK_FREQ_SPACING      0x1402
362 #define FM_SEEK_FREQ_SPACING_MASK 0x001F
363 #define FM_SEEK_FREQ_SPACING_SHFT 0
364
365 /* FM_SEEK_TUNE_SNR_THRESHOLD */
366 #define FM_SEEK_TUNE_SNR_THRESHOLD      0x1403
367 #define FM_SEEK_TUNE_SNR_THRESHOLD_MASK 0x007F
368 #define FM_SEEK_TUNE_SNR_THRESHOLD_SHFT 0
369 #define FM_SEEK_TUNE_SNR_THRESHOLD_DEFAULT 0xa
370
371 /* FM_SEEK_TUNE_RSSI_THRESHOLD */
372 #define FM_SEEK_TUNE_RSSI_THRESHOLD      0x1404
373 #define FM_SEEK_TUNE_RSSI_THRESHOLD_MASK 0x007F
374 #define FM_SEEK_TUNE_RSSI_THRESHOLD_SHFT 0
375 #define FM_SEEK_TUNE_RSSI_THRESHOLD_DEFAULT 0x14
376
377 /* RDS_INT_SOURCE */
378 #define RDS_INT_SOURCE                0x1500
379 #define RDS_INT_SOURCE_RECV_MASK      0x0001
380 #define RDS_INT_SOURCE_SYNCLOST_MASK  0x0002
381 #define RDS_INT_SOURCE_SYNCFOUND_MASK 0x0004
382 #define RDS_INT_SOURCE_RECV_SHFT      0
383 #define RDS_INT_SOURCE_SYNCLOST_SHFT  1
384 #define RDS_INT_SOURCE_SYNCFOUND_SHFT 2
385
386 /* RDS_INT_FIFO_COUNT */
387 #define RDS_INT_FIFO_COUNT      0x1501
388 #define RDS_INT_FIFO_COUNT_MASK 0x00FF
389 #define RDS_INT_FIFO_COUNT_SHFT 0
390
391 /* RDS_CONFIG */
392 #define RDS_CONFIG             0x1502
393 #define RDS_CONFIG_RDSEN_MASK  0x0001
394 #define RDS_CONFIG_BLETHD_MASK 0x0300
395 #define RDS_CONFIG_BLETHC_MASK 0x0C00
396 #define RDS_CONFIG_BLETHB_MASK 0x3000
397 #define RDS_CONFIG_BLETHA_MASK 0xC000
398 #define RDS_CONFIG_RDSEN_SHFT  0
399 #define RDS_CONFIG_BLETHD_SHFT 8
400 #define RDS_CONFIG_BLETHC_SHFT 10
401 #define RDS_CONFIG_BLETHB_SHFT 12
402 #define RDS_CONFIG_BLETHA_SHFT 14
403
404 /*==================================================================
405  General Receive Properties
406 ==================================================================*/
407
408 /* RX_VOLUME */
409 #define RX_VOLUME      0x4000
410 #define RX_VOLUME_MASK 0x003F
411 #define RX_VOLUME_MAX  0x003F
412 #define RX_VOLUME_SHFT 0
413
414 /* RX_HARD_MUTE */
415 #define RX_HARD_MUTE 0x4001
416 #define RX_HARD_MUTE_RMUTE_MASK 0x0001
417 #define RX_HARD_MUTE_LMUTE_MASK 0x0002
418 #define RX_HARD_MUTE_RMUTE_SHFT 0
419 #define RX_HARD_MUTE_LMUTE_SHFT 1
420
421 /*==================================================================
422  Bit Definitions for Properties
423 ==================================================================*/
424
425 /* DIGITAL_MODE - used for input or output */
426 #define DIGITAL_MODE_I2S    0x0
427 #define DIGITAL_MODE_LEFT   0x6
428 #define DIGITAL_MODE_MSB1ST 0xC
429 #define DIGITAL_MODE_MSB2ND 0x8
430
431 /* DIGITAL_SIZE - used for input or output */
432 #define DIGITAL_SIZE_16 0x0
433 #define DIGITAL_SIZE_20 0x1
434 #define DIGITAL_SIZE_24 0x2
435 #define DIGITAL_SIZE_8  0x3
436
437 /* FM_DEEMPH */
438 #define FM_DEEMPH_75US 0x2
439 #define FM_DEEMPH_50US 0x1
440
441 /* FM_RDS_BLETH - used for all block error thresholds */
442 #define FM_RDS_BLETH_NO_ERRORS     0x0
443 #define FM_RDS_BLETH_1OR2_ERRORS   0x1
444 #define FM_RDS_BLETH_3TO5_ERRORS   0x2
445 #define FM_RDS_BLETH_UNCORRECTABLE 0x3
446
447 /**************************************************************************
448  * General Driver Definitions
449  **************************************************************************/
450 enum {
451         RADIO_OP_LP_MODE        = 0,
452         /* radio playback routed directly codec. default */
453         RADIO_OP_RICH_MODE,
454         /* radio playback routed via AP */
455         RADIO_OP_DEFAULT = RADIO_OP_LP_MODE
456 };
457
458 /*
459  * si4705_device - private data
460  */
461 struct si4705_device {
462         struct video_device *videodev;
463
464         /* driver management */
465         unsigned int users;
466         unsigned char op_mode;
467         unsigned char power_state;
468         unsigned char power_state_at_suspend;
469
470         /* si4705 int_status (0..7) */
471         unsigned char int_status;
472
473         /* RDS receive buffer */
474         wait_queue_head_t read_queue;
475         struct mutex lock;              /* buffer locking */
476         struct work_struct resp_work;
477         struct workqueue_struct *queue;
478         unsigned char *buffer;          /* size is always multiple of three */
479         unsigned int buf_size;
480         unsigned int rd_index;
481         unsigned int wr_index;
482
483         struct completion completion;
484         bool stci_enabled;              /* Seek/Tune Complete Interrupt */
485
486         struct i2c_client *client;
487         struct si4705_pdata *pdata;
488 };
489
490
491
492 /**************************************************************************
493  * Firmware Versions
494  **************************************************************************/
495
496 #define RADIO_FW_VERSION        15
497
498
499
500 /**************************************************************************
501  * Frequency Multiplicator
502  **************************************************************************/
503
504 /*
505  * The frequency is set in units of 62.5 Hz when using V4L2_TUNER_CAP_LOW,
506  * 62.5 kHz otherwise.
507  * The tuner is able to have a channel spacing of 50, 100 or 200 kHz.
508  * tuner->capability is therefore set to V4L2_TUNER_CAP_LOW
509  * The FREQ_MUL is then: 1 MHz / 62.5 Hz = 16000
510  */
511 #define FREQ_MUL (10000000 / 625)
512
513
514
515 /**************************************************************************
516  * Common Functions
517  **************************************************************************/
518 extern struct video_device si4705_viddev_template;
519 int si4705_power_up(struct si4705_device *radio);
520 int si4705_power_down(struct si4705_device *radio);
521 int si4705_set_property(struct si4705_device *radio, u16 prop, u16 val);
522 int si4705_get_property(struct si4705_device *radio, u16 prop, u16 *pVal);
523 int si4705_get_int_status(struct si4705_device *radio, u8 *cts, u8 *err,
524                 u8 *rsqint, u8 *rdsint, u8 *stcint);
525 int si4705_fm_tune_freq(struct si4705_device *radio, u16 freq, u8 antcap);
526 int si4705_fm_seek_start(struct si4705_device *radio, u8 seekUp, u8 wrap);
527 int si4705_fm_tune_status(struct si4705_device *radio, u8 cancel,
528                 u8 intack, u8 *bltf, u16 *freq, u8 *rssi, u8 *snr, u8 *antcap);
529 int si4705_fm_rsq_status(struct si4705_device *radio, u8 intack,
530                 u8 *intStatus, u8 *indStatus, u8 *stBlend, u8 *rssi,
531                 u8 *snr, u8 *freqOff);
532 int si4705_fm_rds_status(struct si4705_device *radio, u8 mtfifo,
533                 u8 intack, u8 *rdsInd, u8 *sync, u8 *fifoUsed, u16 *rdsFifo,
534                 u8 *ble);
535 int si4705_fm_agc_status(struct si4705_device *radio, u8 *rfAgcDis,
536                 u8 *lnaGainIndex);
537 int si4705_fm_agc_override(struct si4705_device *radio, u8 *rfAgcDis,
538                 u8 *lnaGainIndex);
539 int si4705_gpio_ctl(struct si4705_device *radio, u8 gpio1,
540                 u8 gpio2, u8 gpio3);
541 int si4705_gpio_set(struct si4705_device *radio, u8 gpio1,
542                 u8 gpio2, u8 gpio3);
543 int si4705_disconnect_check(struct si4705_device *radio);
544 u16 si4705_vol_conv_index_to_value(struct si4705_device *radio, s32 index);
545 s32 si4705_vol_conv_value_to_index(struct si4705_device *radio, u16 value);
546 u16 si4705_get_seek_tune_rssi_threshold_value(struct si4705_device *radio);
547 u16 si4705_get_seek_tune_snr_threshold_value(struct si4705_device *radio);