2 * drivers/media/radio/radio-si470x.c
4 * Driver for USB radios for the Silicon Labs Si470x FM Radio Receivers:
5 * - Silicon Labs USB FM Radio Reference Design
6 * - ADS/Tech FM Radio Receiver (formerly Instant FM Music) (RDX-155-EF)
8 * Copyright (c) 2008 Tobias Lorenz <tobias.lorenz@gmx.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 * 2008-01-12 Tobias Lorenz <tobias.lorenz@gmx.net>
30 * - First working version
31 * 2008-01-13 Tobias Lorenz <tobias.lorenz@gmx.net>
33 * - Improved error handling, every function now returns errno
34 * - Improved multi user access (start/mute/stop)
35 * - Channel doesn't get lost anymore after start/mute/stop
36 * - RDS support added (polling mode via interrupt EP 1)
37 * - marked default module parameters with *value*
38 * - switched from bit structs to bit masks
39 * - header file cleaned and integrated
40 * 2008-01-14 Tobias Lorenz <tobias.lorenz@gmx.net>
42 * - hex values are now lower case
43 * - commented USB ID for ADS/Tech moved on todo list
44 * - blacklisted si470x in hid-quirks.c
45 * - rds buffer handling functions integrated into *_work, *_read
46 * - rds_command in si470x_poll exchanged against simple retval
47 * - check for firmware version 15
48 * - code order and prototypes still remain the same
49 * - spacing and bottom of band codes remain the same
50 * 2008-01-16 Tobias Lorenz <tobias.lorenz@gmx.net>
52 * - code reordered to avoid function prototypes
53 * - switch/case defaults are now more user-friendly
54 * - unified comment style
55 * - applied all checkpatch.pl v1.12 suggestions
56 * except the warning about the too long lines with bit comments
57 * - renamed FMRADIO to RADIO to cut line length (checkpatch.pl)
58 * 2008-01-22 Tobias Lorenz <tobias.lorenz@gmx.net>
60 * - avoid poss. locking when doing copy_to_user which may sleep
61 * - RDS is automatically activated on read now
62 * - code cleaned of unnecessary rds_commands
63 * - USB Vendor/Product ID for ADS/Tech FM Radio Receiver verified
64 * (thanks to Guillaume RAMOUSSE)
65 <<<<<<< HEAD:drivers/media/radio/radio-si470x.c
67 * 2008-01-27 Tobias Lorenz <tobias.lorenz@gmx.net>
69 * - number of seek_retries changed to tune_timeout
70 * - fixed problem with incomplete tune operations by own buffers
71 * - optimization of variables and printf types
72 * - improved error logging
73 * 2008-01-31 Tobias Lorenz <tobias.lorenz@gmx.net>
74 * Oliver Neukum <oliver@neukum.org>
76 * - fixed coverity checker warnings in *_usb_driver_disconnect
77 * - probe()/open() race by correct ordering in probe()
78 * - DMA coherency rules by separate allocation of all buffers
79 * - use of endianness macros
80 * - abuse of spinlock, replaced by mutex
81 * - racy handling of timer in disconnect,
82 * replaced by delayed_work
83 * - racy interruptible_sleep_on(),
84 * replaced with wait_event_interruptible()
85 * - handle signals in read()
86 * 2008-02-08 Tobias Lorenz <tobias.lorenz@gmx.net>
87 * Oliver Neukum <oliver@neukum.org>
89 * - usb autosuspend support
90 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/media/radio/radio-si470x.c
93 * - add seeking support
94 * - add firmware download/update support
95 * - RDS support: interrupt mode, instead of polling
96 * - add LED status output (check if that's not already done in firmware)
100 /* driver definitions */
101 #define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@gmx.net>"
102 #define DRIVER_NAME "radio-si470x"
103 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
104 #define DRIVER_VERSION KERNEL_VERSION(1, 0, 4)
106 #define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 6)
107 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
108 #define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
109 #define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers"
110 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
112 #define DRIVER_VERSION "1.0.6"
113 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
116 /* kernel includes */
117 #include <linux/kernel.h>
118 #include <linux/module.h>
119 #include <linux/init.h>
120 #include <linux/slab.h>
121 #include <linux/input.h>
122 #include <linux/usb.h>
123 #include <linux/hid.h>
124 #include <linux/version.h>
125 #include <linux/videodev2.h>
126 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
128 #include <linux/mutex.h>
129 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
130 #include <media/v4l2-common.h>
131 #include <media/rds.h>
132 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
134 #include <asm/unaligned.h>
135 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
138 /* USB Device ID List */
139 static struct usb_device_id si470x_usb_driver_id_table
[] = {
140 /* Silicon Labs USB FM Radio Reference Design */
141 { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID
, 0, 0) },
142 /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */
143 { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID
, 0, 0) },
144 /* Terminating entry */
147 MODULE_DEVICE_TABLE(usb
, si470x_usb_driver_id_table
);
151 /**************************************************************************
153 **************************************************************************/
156 static int radio_nr
= -1;
157 module_param(radio_nr
, int, 0);
158 MODULE_PARM_DESC(radio_nr
, "Radio Nr");
161 /* 0: 200 kHz (USA, Australia) */
162 /* 1: 100 kHz (Europe, Japan) */
164 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
165 static int space
= 2;
166 module_param(space
, int, 0);
168 static unsigned short space
= 2;
169 module_param(space
, ushort
, 0);
170 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
171 MODULE_PARM_DESC(radio_nr
, "Spacing: 0=200kHz 1=100kHz *2=50kHz*");
173 /* Bottom of Band (MHz) */
174 /* 0: 87.5 - 108 MHz (USA, Europe)*/
175 /* 1: 76 - 108 MHz (Japan wide band) */
176 /* 2: 76 - 90 MHz (Japan) */
177 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
179 module_param(band
, int, 0);
181 static unsigned short band
= 1;
182 module_param(band
, ushort
, 0);
183 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
184 MODULE_PARM_DESC(radio_nr
, "Band: 0=87.5..108MHz *1=76..108MHz* 2=76..90MHz");
188 /* 1: 50 us (Europe, Australia, Japan) */
189 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
191 module_param(de
, int, 0);
193 static unsigned short de
= 1;
194 module_param(de
, ushort
, 0);
195 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
196 MODULE_PARM_DESC(radio_nr
, "De-emphasis: 0=75us *1=50us*");
199 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
200 static int usb_timeout
= 500;
201 module_param(usb_timeout
, int, 0);
203 static unsigned int usb_timeout
= 500;
204 module_param(usb_timeout
, uint
, 0);
205 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
206 MODULE_PARM_DESC(usb_timeout
, "USB timeout (ms): *500*");
208 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
210 static int seek_retries
= 100;
211 module_param(seek_retries
, int, 0);
212 MODULE_PARM_DESC(seek_retries
, "Seek retries: *100*");
215 static unsigned int tune_timeout
= 3000;
216 module_param(tune_timeout
, uint
, 0);
217 MODULE_PARM_DESC(tune_timeout
, "Tune timeout: *3000*");
218 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
220 /* RDS buffer blocks */
221 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
222 static int rds_buf
= 100;
223 module_param(rds_buf
, int, 0);
225 static unsigned int rds_buf
= 100;
226 module_param(rds_buf
, uint
, 0);
227 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
228 MODULE_PARM_DESC(rds_buf
, "RDS buffer entries: *100*");
230 /* RDS maximum block errors */
231 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
232 static int max_rds_errors
= 1;
234 static unsigned short max_rds_errors
= 1;
235 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
236 /* 0 means 0 errors requiring correction */
237 /* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */
238 /* 2 means 3-5 errors requiring correction */
239 /* 3 means 6+ errors or errors in checkword, correction not possible */
240 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
241 module_param(max_rds_errors
, int, 0);
243 module_param(max_rds_errors
, ushort
, 0);
244 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
245 MODULE_PARM_DESC(max_rds_errors
, "RDS maximum block errors: *1*");
247 /* RDS poll frequency */
248 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
249 static int rds_poll_time
= 40;
251 static unsigned int rds_poll_time
= 40;
252 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
253 /* 40 is used by the original USBRadio.exe */
254 /* 50 is used by radio-cadet */
255 /* 75 should be okay */
256 /* 80 is the usual RDS receive interval */
257 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
258 module_param(rds_poll_time
, int, 0);
260 module_param(rds_poll_time
, uint
, 0);
261 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
262 MODULE_PARM_DESC(rds_poll_time
, "RDS poll time (ms): *40*");
266 /**************************************************************************
267 * Register Definitions
268 **************************************************************************/
269 #define RADIO_REGISTER_SIZE 2 /* 16 register bit width */
270 #define RADIO_REGISTER_NUM 16 /* DEVICEID ... RDSD */
271 #define RDS_REGISTER_NUM 6 /* STATUSRSSI ... RDSD */
273 #define DEVICEID 0 /* Device ID */
274 #define DEVICEID_PN 0xf000 /* bits 15..12: Part Number */
275 #define DEVICEID_MFGID 0x0fff /* bits 11..00: Manufacturer ID */
277 #define CHIPID 1 /* Chip ID */
278 #define CHIPID_REV 0xfc00 /* bits 15..10: Chip Version */
279 #define CHIPID_DEV 0x0200 /* bits 09..09: Device */
280 #define CHIPID_FIRMWARE 0x01ff /* bits 08..00: Firmware Version */
282 #define POWERCFG 2 /* Power Configuration */
283 #define POWERCFG_DSMUTE 0x8000 /* bits 15..15: Softmute Disable */
284 #define POWERCFG_DMUTE 0x4000 /* bits 14..14: Mute Disable */
285 #define POWERCFG_MONO 0x2000 /* bits 13..13: Mono Select */
286 #define POWERCFG_RDSM 0x0800 /* bits 11..11: RDS Mode (Si4701 only) */
287 #define POWERCFG_SKMODE 0x0400 /* bits 10..10: Seek Mode */
288 #define POWERCFG_SEEKUP 0x0200 /* bits 09..09: Seek Direction */
289 #define POWERCFG_SEEK 0x0100 /* bits 08..08: Seek */
290 #define POWERCFG_DISABLE 0x0040 /* bits 06..06: Powerup Disable */
291 #define POWERCFG_ENABLE 0x0001 /* bits 00..00: Powerup Enable */
293 #define CHANNEL 3 /* Channel */
294 #define CHANNEL_TUNE 0x8000 /* bits 15..15: Tune */
295 #define CHANNEL_CHAN 0x03ff /* bits 09..00: Channel Select */
297 #define SYSCONFIG1 4 /* System Configuration 1 */
298 #define SYSCONFIG1_RDSIEN 0x8000 /* bits 15..15: RDS Interrupt Enable (Si4701 only) */
299 #define SYSCONFIG1_STCIEN 0x4000 /* bits 14..14: Seek/Tune Complete Interrupt Enable */
300 #define SYSCONFIG1_RDS 0x1000 /* bits 12..12: RDS Enable (Si4701 only) */
301 #define SYSCONFIG1_DE 0x0800 /* bits 11..11: De-emphasis (0=75us 1=50us) */
302 #define SYSCONFIG1_AGCD 0x0400 /* bits 10..10: AGC Disable */
303 #define SYSCONFIG1_BLNDADJ 0x00c0 /* bits 07..06: Stereo/Mono Blend Level Adjustment */
304 #define SYSCONFIG1_GPIO3 0x0030 /* bits 05..04: General Purpose I/O 3 */
305 #define SYSCONFIG1_GPIO2 0x000c /* bits 03..02: General Purpose I/O 2 */
306 #define SYSCONFIG1_GPIO1 0x0003 /* bits 01..00: General Purpose I/O 1 */
308 #define SYSCONFIG2 5 /* System Configuration 2 */
309 #define SYSCONFIG2_SEEKTH 0xff00 /* bits 15..08: RSSI Seek Threshold */
310 #define SYSCONFIG2_BAND 0x0080 /* bits 07..06: Band Select */
311 #define SYSCONFIG2_SPACE 0x0030 /* bits 05..04: Channel Spacing */
312 #define SYSCONFIG2_VOLUME 0x000f /* bits 03..00: Volume */
314 #define SYSCONFIG3 6 /* System Configuration 3 */
315 #define SYSCONFIG3_SMUTER 0xc000 /* bits 15..14: Softmute Attack/Recover Rate */
316 #define SYSCONFIG3_SMUTEA 0x3000 /* bits 13..12: Softmute Attenuation */
317 #define SYSCONFIG3_SKSNR 0x00f0 /* bits 07..04: Seek SNR Threshold */
318 #define SYSCONFIG3_SKCNT 0x000f /* bits 03..00: Seek FM Impulse Detection Threshold */
320 #define TEST1 7 /* Test 1 */
321 #define TEST1_AHIZEN 0x4000 /* bits 14..14: Audio High-Z Enable */
323 #define TEST2 8 /* Test 2 */
324 /* TEST2 only contains reserved bits */
326 #define BOOTCONFIG 9 /* Boot Configuration */
327 /* BOOTCONFIG only contains reserved bits */
329 #define STATUSRSSI 10 /* Status RSSI */
330 #define STATUSRSSI_RDSR 0x8000 /* bits 15..15: RDS Ready (Si4701 only) */
331 #define STATUSRSSI_STC 0x4000 /* bits 14..14: Seek/Tune Complete */
332 #define STATUSRSSI_SF 0x2000 /* bits 13..13: Seek Fail/Band Limit */
333 #define STATUSRSSI_AFCRL 0x1000 /* bits 12..12: AFC Rail */
334 #define STATUSRSSI_RDSS 0x0800 /* bits 11..11: RDS Synchronized (Si4701 only) */
335 #define STATUSRSSI_BLERA 0x0600 /* bits 10..09: RDS Block A Errors (Si4701 only) */
336 #define STATUSRSSI_ST 0x0100 /* bits 08..08: Stereo Indicator */
337 #define STATUSRSSI_RSSI 0x00ff /* bits 07..00: RSSI (Received Signal Strength Indicator) */
339 #define READCHAN 11 /* Read Channel */
340 #define READCHAN_BLERB 0xc000 /* bits 15..14: RDS Block D Errors (Si4701 only) */
341 #define READCHAN_BLERC 0x3000 /* bits 13..12: RDS Block C Errors (Si4701 only) */
342 #define READCHAN_BLERD 0x0c00 /* bits 11..10: RDS Block B Errors (Si4701 only) */
343 #define READCHAN_READCHAN 0x03ff /* bits 09..00: Read Channel */
345 #define RDSA 12 /* RDSA */
346 #define RDSA_RDSA 0xffff /* bits 15..00: RDS Block A Data (Si4701 only) */
348 #define RDSB 13 /* RDSB */
349 #define RDSB_RDSB 0xffff /* bits 15..00: RDS Block B Data (Si4701 only) */
351 #define RDSC 14 /* RDSC */
352 #define RDSC_RDSC 0xffff /* bits 15..00: RDS Block C Data (Si4701 only) */
354 #define RDSD 15 /* RDSD */
355 #define RDSD_RDSD 0xffff /* bits 15..00: RDS Block D Data (Si4701 only) */
359 /**************************************************************************
361 **************************************************************************/
363 /* Reports 1-16 give direct read/write access to the 16 Si470x registers */
364 /* with the (REPORT_ID - 1) corresponding to the register address across USB */
365 /* endpoint 0 using GET_REPORT and SET_REPORT */
366 #define REGISTER_REPORT_SIZE (RADIO_REGISTER_SIZE + 1)
367 #define REGISTER_REPORT(reg) ((reg) + 1)
369 /* Report 17 gives direct read/write access to the entire Si470x register */
370 /* map across endpoint 0 using GET_REPORT and SET_REPORT */
371 #define ENTIRE_REPORT_SIZE (RADIO_REGISTER_NUM * RADIO_REGISTER_SIZE + 1)
372 #define ENTIRE_REPORT 17
374 /* Report 18 is used to send the lowest 6 Si470x registers up the HID */
375 /* interrupt endpoint 1 to Windows every 20 milliseconds for status */
376 #define RDS_REPORT_SIZE (RDS_REGISTER_NUM * RADIO_REGISTER_SIZE + 1)
377 #define RDS_REPORT 18
379 /* Report 19: LED state */
380 #define LED_REPORT_SIZE 3
381 #define LED_REPORT 19
383 /* Report 19: stream */
384 #define STREAM_REPORT_SIZE 3
385 #define STREAM_REPORT 19
387 /* Report 20: scratch */
388 #define SCRATCH_PAGE_SIZE 63
389 #define SCRATCH_REPORT_SIZE (SCRATCH_PAGE_SIZE + 1)
390 #define SCRATCH_REPORT 20
392 /* Reports 19-22: flash upgrade of the C8051F321 */
393 #define WRITE_REPORT 19
394 #define FLASH_REPORT 20
395 #define CRC_REPORT 21
396 #define RESPONSE_REPORT 22
398 /* Report 23: currently unused, but can accept 60 byte reports on the HID */
399 /* interrupt out endpoint 2 every 1 millisecond */
400 #define UNUSED_REPORT 23
404 /**************************************************************************
405 * Software/Hardware Versions
406 **************************************************************************/
407 #define RADIO_SW_VERSION_NOT_BOOTLOADABLE 6
408 #define RADIO_SW_VERSION 7
409 #define RADIO_SW_VERSION_CURRENT 15
410 #define RADIO_HW_VERSION 1
412 #define SCRATCH_PAGE_SW_VERSION 1
413 #define SCRATCH_PAGE_HW_VERSION 2
417 /**************************************************************************
418 * LED State Definitions
419 **************************************************************************/
420 #define LED_COMMAND 0x35
422 #define NO_CHANGE_LED 0x00
423 #define ALL_COLOR_LED 0x01 /* streaming state */
424 #define BLINK_GREEN_LED 0x02 /* connect state */
425 #define BLINK_RED_LED 0x04
426 #define BLINK_ORANGE_LED 0x10 /* disconnect state */
427 #define SOLID_GREEN_LED 0x20 /* tuning/seeking state */
428 #define SOLID_RED_LED 0x40 /* bootload state */
429 #define SOLID_ORANGE_LED 0x80
433 /**************************************************************************
434 * Stream State Definitions
435 **************************************************************************/
436 #define STREAM_COMMAND 0x36
437 #define STREAM_VIDPID 0x00
438 #define STREAM_AUDIO 0xff
442 /**************************************************************************
443 * Bootloader / Flash Commands
444 **************************************************************************/
446 /* unique id sent to bootloader and required to put into a bootload state */
447 #define UNIQUE_BL_ID 0x34
449 /* mask for the flash data */
450 #define FLASH_DATA_MASK 0x55
452 /* bootloader commands */
453 #define GET_SW_VERSION_COMMAND 0x00
454 #define SET_PAGE_COMMAND 0x01
455 #define ERASE_PAGE_COMMAND 0x02
456 #define WRITE_PAGE_COMMAND 0x03
457 #define CRC_ON_PAGE_COMMAND 0x04
458 #define READ_FLASH_BYTE_COMMAND 0x05
459 #define RESET_DEVICE_COMMAND 0x06
460 #define GET_HW_VERSION_COMMAND 0x07
463 /* bootloader command responses */
464 #define COMMAND_OK 0x01
465 #define COMMAND_FAILED 0x02
466 #define COMMAND_PENDING 0x03
469 #define COMMAND_BUFFER_SIZE 4
470 #define RESPONSE_BUFFER_SIZE 2
471 #define FLASH_BUFFER_SIZE 64
472 #define CRC_BUFFER_SIZE 3
476 /**************************************************************************
477 * General Driver Definitions
478 **************************************************************************/
481 * si470x_device - private data
483 struct si470x_device
{
484 /* reference to USB and video device */
485 struct usb_device
*usbdev
;
486 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
488 struct usb_interface
*intf
;
489 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
490 struct video_device
*videodev
;
492 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
493 /* are these really necessary ? */
496 /* report buffer (maximum 64 bytes) */
497 unsigned char buf
[64];
499 /* driver management */
501 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
503 /* Silabs internal registers (0..15) */
504 unsigned short registers
[RADIO_REGISTER_NUM
];
506 /* RDS receive buffer */
507 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
508 struct work_struct work
;
510 struct delayed_work work
;
511 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
512 wait_queue_head_t read_queue
;
513 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
514 struct timer_list timer
;
515 spinlock_t lock
; /* buffer locking */
517 struct mutex lock
; /* buffer locking */
518 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
519 unsigned char *buffer
; /* size is always multiple of three */
520 unsigned int buf_size
;
521 unsigned int rd_index
;
522 unsigned int wr_index
;
527 * The frequency is set in units of 62.5 Hz when using V4L2_TUNER_CAP_LOW,
528 * 62.5 kHz otherwise.
529 * The tuner is able to have a channel spacing of 50, 100 or 200 kHz.
530 * tuner->capability is therefore set to V4L2_TUNER_CAP_LOW
531 * The FREQ_MUL is then: 1 MHz / 62.5 Hz = 16000
533 #define FREQ_MUL (1000000 / 62.5)
537 /**************************************************************************
538 * General Driver Functions
539 **************************************************************************/
542 * si470x_get_report - receive a HID report
544 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
545 static int si470x_get_report(struct si470x_device
*radio
, int size
)
547 static int si470x_get_report(struct si470x_device
*radio
, void *buf
, int size
)
548 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
550 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
551 return usb_control_msg(radio
->usbdev
,
553 unsigned char *report
= (unsigned char *) buf
;
556 retval
= usb_control_msg(radio
->usbdev
,
557 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
558 usb_rcvctrlpipe(radio
->usbdev
, 0),
560 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_IN
,
561 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
563 radio
->buf
, size
, usb_timeout
);
566 buf
, size
, usb_timeout
);
568 printk(KERN_WARNING DRIVER_NAME
569 ": si470x_get_report: usb_control_msg returned %d\n",
573 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
578 * si470x_set_report - send a HID report
580 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
581 static int si470x_set_report(struct si470x_device
*radio
, int size
)
583 static int si470x_set_report(struct si470x_device
*radio
, void *buf
, int size
)
584 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
586 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
587 return usb_control_msg(radio
->usbdev
,
589 unsigned char *report
= (unsigned char *) buf
;
592 retval
= usb_control_msg(radio
->usbdev
,
593 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
594 usb_sndctrlpipe(radio
->usbdev
, 0),
596 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_OUT
,
597 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
599 radio
->buf
, size
, usb_timeout
);
602 buf
, size
, usb_timeout
);
604 printk(KERN_WARNING DRIVER_NAME
605 ": si470x_set_report: usb_control_msg returned %d\n",
609 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
614 * si470x_get_register - read register
616 static int si470x_get_register(struct si470x_device
*radio
, int regnr
)
618 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
620 unsigned char buf
[REGISTER_REPORT_SIZE
];
621 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
624 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
625 radio
->buf
[0] = REGISTER_REPORT(regnr
);
627 buf
[0] = REGISTER_REPORT(regnr
);
629 retval
= si470x_get_report(radio
, (void *) &buf
, sizeof(buf
));
630 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
632 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
633 retval
= si470x_get_report(radio
, REGISTER_REPORT_SIZE
);
635 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
637 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
638 radio
->registers
[regnr
] = (radio
->buf
[1] << 8) | radio
->buf
[2];
640 radio
->registers
[regnr
] = be16_to_cpu(get_unaligned(
641 (unsigned short *) &buf
[1]));
642 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
644 return (retval
< 0) ? -EINVAL
: 0;
649 * si470x_set_register - write register
651 static int si470x_set_register(struct si470x_device
*radio
, int regnr
)
653 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
655 unsigned char buf
[REGISTER_REPORT_SIZE
];
656 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
659 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
660 radio
->buf
[0] = REGISTER_REPORT(regnr
);
661 radio
->buf
[1] = (radio
->registers
[regnr
] & 0xff00) >> 8;
662 radio
->buf
[2] = (radio
->registers
[regnr
] & 0x00ff);
664 buf
[0] = REGISTER_REPORT(regnr
);
665 put_unaligned(cpu_to_be16(radio
->registers
[regnr
]),
666 (unsigned short *) &buf
[1]);
667 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
669 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
670 retval
= si470x_set_report(radio
, REGISTER_REPORT_SIZE
);
672 retval
= si470x_set_report(radio
, (void *) &buf
, sizeof(buf
));
673 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
675 return (retval
< 0) ? -EINVAL
: 0;
680 * si470x_get_all_registers - read entire registers
682 static int si470x_get_all_registers(struct si470x_device
*radio
)
684 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
686 unsigned char buf
[ENTIRE_REPORT_SIZE
];
687 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
689 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
693 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
695 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
696 radio
->buf
[0] = ENTIRE_REPORT
;
698 buf
[0] = ENTIRE_REPORT
;
699 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
701 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
702 retval
= si470x_get_report(radio
, ENTIRE_REPORT_SIZE
);
704 retval
= si470x_get_report(radio
, (void *) &buf
, sizeof(buf
));
705 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
708 for (regnr
= 0; regnr
< RADIO_REGISTER_NUM
; regnr
++)
709 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
710 radio
->registers
[regnr
] =
711 (radio
->buf
[regnr
* RADIO_REGISTER_SIZE
+ 1] << 8) |
712 radio
->buf
[regnr
* RADIO_REGISTER_SIZE
+ 2];
714 radio
->registers
[regnr
] = be16_to_cpu(get_unaligned(
716 &buf
[regnr
* RADIO_REGISTER_SIZE
+ 1]));
717 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
719 return (retval
< 0) ? -EINVAL
: 0;
724 * si470x_get_rds_registers - read rds registers
726 static int si470x_get_rds_registers(struct si470x_device
*radio
)
728 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
730 unsigned char buf
[RDS_REPORT_SIZE
];
731 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
733 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
736 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
738 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
741 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
743 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
744 radio
->buf
[0] = RDS_REPORT
;
747 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
749 retval
= usb_interrupt_msg(radio
->usbdev
,
750 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
751 usb_rcvctrlpipe(radio
->usbdev
, 1),
752 radio
->buf
, RDS_REPORT_SIZE
, &size
, usb_timeout
);
754 usb_rcvintpipe(radio
->usbdev
, 1),
755 (void *) &buf
, sizeof(buf
), &size
, usb_timeout
);
756 if (size
!= sizeof(buf
))
757 printk(KERN_WARNING DRIVER_NAME
": si470x_get_rds_register: "
758 "return size differs: %d != %zu\n", size
, sizeof(buf
));
760 printk(KERN_WARNING DRIVER_NAME
": si470x_get_rds_registers: "
761 "usb_interrupt_msg returned %d\n", retval
);
762 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
765 for (regnr
= 0; regnr
< RDS_REGISTER_NUM
; regnr
++)
766 radio
->registers
[STATUSRSSI
+ regnr
] =
767 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
768 (radio
->buf
[regnr
* RADIO_REGISTER_SIZE
+ 1] << 8) |
769 radio
->buf
[regnr
* RADIO_REGISTER_SIZE
+ 2];
771 be16_to_cpu(get_unaligned((unsigned short *)
772 &buf
[regnr
* RADIO_REGISTER_SIZE
+ 1]));
773 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
775 return (retval
< 0) ? -EINVAL
: 0;
780 * si470x_set_chan - set the channel
782 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
783 static int si470x_set_chan(struct si470x_device
*radio
, int chan
)
785 static int si470x_set_chan(struct si470x_device
*radio
, unsigned short chan
)
786 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
788 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
792 unsigned long timeout
;
794 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
797 radio
->registers
[CHANNEL
] &= ~CHANNEL_CHAN
;
798 radio
->registers
[CHANNEL
] |= CHANNEL_TUNE
| chan
;
799 retval
= si470x_set_register(radio
, CHANNEL
);
803 /* wait till seek operation has completed */
804 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
807 timeout
= jiffies
+ msecs_to_jiffies(tune_timeout
);
808 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
810 retval
= si470x_get_register(radio
, STATUSRSSI
);
813 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
814 } while ((radio
->registers
[STATUSRSSI
] & STATUSRSSI_STC
) &&
815 (++i
< seek_retries
));
816 if (i
>= seek_retries
)
818 timed_out
= time_after(jiffies
, timeout
);
819 } while (((radio
->registers
[STATUSRSSI
] & STATUSRSSI_STC
) == 0) &&
822 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
823 printk(KERN_WARNING DRIVER_NAME
824 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
825 ": seek does not finish after %d tries\n", i
);
827 ": seek does not finish after %u ms\n", tune_timeout
);
828 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
831 radio
->registers
[CHANNEL
] &= ~CHANNEL_TUNE
;
832 return si470x_set_register(radio
, CHANNEL
);
837 * si470x_get_freq - get the frequency
839 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
840 static int si470x_get_freq(struct si470x_device
*radio
)
842 static unsigned int si470x_get_freq(struct si470x_device
*radio
)
843 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
845 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
846 int spacing
, band_bottom
, chan
, freq
;
848 unsigned int spacing
, band_bottom
, freq
;
850 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
855 /* 0: 200 kHz (USA, Australia) */
856 case 0 : spacing
= 0.200 * FREQ_MUL
; break;
857 /* 1: 100 kHz (Europe, Japan) */
858 case 1 : spacing
= 0.100 * FREQ_MUL
; break;
860 default: spacing
= 0.050 * FREQ_MUL
; break;
863 /* Bottom of Band (MHz) */
865 /* 0: 87.5 - 108 MHz (USA, Europe) */
866 case 0 : band_bottom
= 87.5 * FREQ_MUL
; break;
867 /* 1: 76 - 108 MHz (Japan wide band) */
868 default: band_bottom
= 76 * FREQ_MUL
; break;
869 /* 2: 76 - 90 MHz (Japan) */
870 case 2 : band_bottom
= 76 * FREQ_MUL
; break;
874 retval
= si470x_get_register(radio
, READCHAN
);
877 chan
= radio
->registers
[READCHAN
] & READCHAN_READCHAN
;
879 /* Frequency (MHz) = Spacing (kHz) x Channel + Bottom of Band (MHz) */
880 freq
= chan
* spacing
+ band_bottom
;
887 * si470x_set_freq - set the frequency
889 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
890 static int si470x_set_freq(struct si470x_device
*radio
, int freq
)
892 static int si470x_set_freq(struct si470x_device
*radio
, unsigned int freq
)
893 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
895 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
896 int spacing
, band_bottom
, chan
;
898 unsigned int spacing
, band_bottom
;
900 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
904 /* 0: 200 kHz (USA, Australia) */
905 case 0 : spacing
= 0.200 * FREQ_MUL
; break;
906 /* 1: 100 kHz (Europe, Japan) */
907 case 1 : spacing
= 0.100 * FREQ_MUL
; break;
909 default: spacing
= 0.050 * FREQ_MUL
; break;
912 /* Bottom of Band (MHz) */
914 /* 0: 87.5 - 108 MHz (USA, Europe) */
915 case 0 : band_bottom
= 87.5 * FREQ_MUL
; break;
916 /* 1: 76 - 108 MHz (Japan wide band) */
917 default: band_bottom
= 76 * FREQ_MUL
; break;
918 /* 2: 76 - 90 MHz (Japan) */
919 case 2 : band_bottom
= 76 * FREQ_MUL
; break;
922 /* Chan = [ Freq (Mhz) - Bottom of Band (MHz) ] / Spacing (kHz) */
923 chan
= (freq
- band_bottom
) / spacing
;
925 return si470x_set_chan(radio
, chan
);
930 * si470x_start - switch on radio
932 static int si470x_start(struct si470x_device
*radio
)
937 radio
->registers
[POWERCFG
] =
938 POWERCFG_DMUTE
| POWERCFG_ENABLE
| POWERCFG_RDSM
;
939 retval
= si470x_set_register(radio
, POWERCFG
);
944 radio
->registers
[SYSCONFIG1
] = SYSCONFIG1_DE
;
945 retval
= si470x_set_register(radio
, SYSCONFIG1
);
950 radio
->registers
[SYSCONFIG2
] =
951 (0x3f << 8) | /* SEEKTH */
952 (band
<< 6) | /* BAND */
953 (space
<< 4) | /* SPACE */
954 15; /* VOLUME (max) */
955 retval
= si470x_set_register(radio
, SYSCONFIG2
);
959 /* reset last channel */
960 return si470x_set_chan(radio
,
961 radio
->registers
[CHANNEL
] & CHANNEL_CHAN
);
966 * si470x_stop - switch off radio
968 static int si470x_stop(struct si470x_device
*radio
)
973 radio
->registers
[SYSCONFIG1
] &= ~SYSCONFIG1_RDS
;
974 retval
= si470x_set_register(radio
, SYSCONFIG1
);
979 radio
->registers
[POWERCFG
] &= ~POWERCFG_DMUTE
;
980 /* POWERCFG_ENABLE has to automatically go low */
981 radio
->registers
[POWERCFG
] |= POWERCFG_ENABLE
| POWERCFG_DISABLE
;
982 return si470x_set_register(radio
, POWERCFG
);
987 * si470x_rds_on - switch on rds reception
989 static int si470x_rds_on(struct si470x_device
*radio
)
991 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
995 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
997 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
999 mutex_lock(&radio
->lock
);
1000 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1001 radio
->registers
[SYSCONFIG1
] |= SYSCONFIG1_RDS
;
1002 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1003 return si470x_set_register(radio
, SYSCONFIG1
);
1005 retval
= si470x_set_register(radio
, SYSCONFIG1
);
1007 radio
->registers
[SYSCONFIG1
] &= ~SYSCONFIG1_RDS
;
1008 mutex_unlock(&radio
->lock
);
1011 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1016 /**************************************************************************
1017 * RDS Driver Functions
1018 **************************************************************************/
1021 * si470x_rds - rds processing function
1023 static void si470x_rds(struct si470x_device
*radio
)
1025 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1026 unsigned char tmpbuf
[3];
1028 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1029 unsigned char blocknum
;
1030 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1031 unsigned char bler
; /* rds block errors */
1033 unsigned short bler
; /* rds block errors */
1034 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1036 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1039 unsigned char tmpbuf
[3];
1040 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1042 /* get rds blocks */
1043 if (si470x_get_rds_registers(radio
) < 0)
1045 if ((radio
->registers
[STATUSRSSI
] & STATUSRSSI_RDSR
) == 0) {
1046 /* No RDS group ready */
1049 if ((radio
->registers
[STATUSRSSI
] & STATUSRSSI_RDSS
) == 0) {
1050 /* RDS decoder not synchronized */
1054 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1055 /* copy four RDS blocks to internal buffer */
1056 if (spin_trylock(&radio
->lock
)) {
1057 /* process each rds block */
1058 for (blocknum
= 0; blocknum
< 4; blocknum
++) {
1061 bler
= (radio
->registers
[STATUSRSSI
] &
1062 STATUSRSSI_BLERA
) >> 9;
1063 rds
= radio
->registers
[RDSA
];
1066 bler
= (radio
->registers
[READCHAN
] &
1067 READCHAN_BLERB
) >> 14;
1068 rds
= radio
->registers
[RDSB
];
1071 bler
= (radio
->registers
[READCHAN
] &
1072 READCHAN_BLERC
) >> 12;
1073 rds
= radio
->registers
[RDSC
];
1076 bler
= (radio
->registers
[READCHAN
] &
1077 READCHAN_BLERD
) >> 10;
1078 rds
= radio
->registers
[RDSD
];
1082 /* Fill the V4L2 RDS buffer */
1083 tmpbuf
[0] = rds
& 0x00ff; /* LSB */
1084 tmpbuf
[1] = (rds
& 0xff00) >> 8;/* MSB */
1085 tmpbuf
[2] = blocknum
; /* offset name */
1086 tmpbuf
[2] |= blocknum
<< 3; /* received offset */
1087 if (bler
> max_rds_errors
)
1088 tmpbuf
[2] |= 0x80; /* uncorrectable errors */
1090 tmpbuf
[2] |= 0x40; /* corrected error(s) */
1092 /* copy RDS block to internal buffer */
1093 for (i
= 0; i
< 3; i
++) {
1094 radio
->buffer
[radio
->wr_index
] = tmpbuf
[i
];
1098 /* wrap write pointer */
1099 if (radio
->wr_index
>= radio
->buf_size
)
1100 radio
->wr_index
= 0;
1102 /* check for overflow */
1103 if (radio
->wr_index
== radio
->rd_index
) {
1104 /* increment and wrap read pointer */
1105 radio
->rd_index
+= 3;
1106 if (radio
->rd_index
>= radio
->buf_size
)
1107 radio
->rd_index
= 0;
1110 /* copy all four RDS blocks to internal buffer */
1111 mutex_lock(&radio
->lock
);
1112 for (blocknum
= 0; blocknum
< 4; blocknum
++) {
1115 bler
= (radio
->registers
[STATUSRSSI
] &
1116 STATUSRSSI_BLERA
) >> 9;
1117 rds
= radio
->registers
[RDSA
];
1120 bler
= (radio
->registers
[READCHAN
] &
1121 READCHAN_BLERB
) >> 14;
1122 rds
= radio
->registers
[RDSB
];
1125 bler
= (radio
->registers
[READCHAN
] &
1126 READCHAN_BLERC
) >> 12;
1127 rds
= radio
->registers
[RDSC
];
1130 bler
= (radio
->registers
[READCHAN
] &
1131 READCHAN_BLERD
) >> 10;
1132 rds
= radio
->registers
[RDSD
];
1136 /* Fill the V4L2 RDS buffer */
1137 put_unaligned(cpu_to_le16(rds
), (unsigned short *) &tmpbuf
);
1138 tmpbuf
[2] = blocknum
; /* offset name */
1139 tmpbuf
[2] |= blocknum
<< 3; /* received offset */
1140 if (bler
> max_rds_errors
)
1141 tmpbuf
[2] |= 0x80; /* uncorrectable errors */
1143 tmpbuf
[2] |= 0x40; /* corrected error(s) */
1145 /* copy RDS block to internal buffer */
1146 memcpy(&radio
->buffer
[radio
->wr_index
], &tmpbuf
, 3);
1147 radio
->wr_index
+= 3;
1149 /* wrap write pointer */
1150 if (radio
->wr_index
>= radio
->buf_size
)
1151 radio
->wr_index
= 0;
1153 /* check for overflow */
1154 if (radio
->wr_index
== radio
->rd_index
) {
1155 /* increment and wrap read pointer */
1156 radio
->rd_index
+= 3;
1157 if (radio
->rd_index
>= radio
->buf_size
)
1158 radio
->rd_index
= 0;
1159 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1161 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1162 spin_unlock(&radio
->lock
);
1164 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1166 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1168 mutex_unlock(&radio
->lock
);
1169 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1171 /* wake up read queue */
1172 if (radio
->wr_index
!= radio
->rd_index
)
1173 wake_up_interruptible(&radio
->read_queue
);
1178 <<<<<<< HEAD:drivers/media/radio/radio-si470x.c
1179 * si470x_timer - rds timer function
1181 static void si470x_timer(unsigned long data
)
1183 struct si470x_device
*radio
= (struct si470x_device
*) data
;
1185 schedule_work(&radio
->work
);
1191 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/media/radio/radio-si470x.c
1192 * si470x_work - rds work function
1194 static void si470x_work(struct work_struct
*work
)
1196 struct si470x_device
*radio
= container_of(work
, struct si470x_device
,
1197 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1201 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1203 if ((radio
->registers
[SYSCONFIG1
] & SYSCONFIG1_RDS
) == 0)
1207 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1208 mod_timer(&radio
->timer
, jiffies
+ msecs_to_jiffies(rds_poll_time
));
1210 schedule_delayed_work(&radio
->work
, msecs_to_jiffies(rds_poll_time
));
1211 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1216 /**************************************************************************
1217 * File Operations Interface
1218 **************************************************************************/
1221 * si470x_fops_read - read RDS data
1223 static ssize_t
si470x_fops_read(struct file
*file
, char __user
*buf
,
1224 size_t count
, loff_t
*ppos
)
1226 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1228 unsigned int block_count
= 0;
1230 /* switch on rds reception */
1231 if ((radio
->registers
[SYSCONFIG1
] & SYSCONFIG1_RDS
) == 0) {
1232 si470x_rds_on(radio
);
1233 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1234 schedule_work(&radio
->work
);
1236 schedule_delayed_work(&radio
->work
,
1237 msecs_to_jiffies(rds_poll_time
));
1238 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1241 /* block if no new data available */
1242 while (radio
->wr_index
== radio
->rd_index
) {
1243 if (file
->f_flags
& O_NONBLOCK
)
1244 return -EWOULDBLOCK
;
1245 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1246 interruptible_sleep_on(&radio
->read_queue
);
1248 if (wait_event_interruptible(radio
->read_queue
,
1249 radio
->wr_index
!= radio
->rd_index
) < 0)
1251 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1254 /* calculate block count from byte count */
1257 /* copy RDS block out of internal buffer and to user buffer */
1258 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1259 if (spin_trylock(&radio
->lock
)) {
1260 while (block_count
< count
) {
1261 if (radio
->rd_index
== radio
->wr_index
)
1264 /* always transfer rds complete blocks */
1265 if (copy_to_user(buf
,
1266 &radio
->buffer
[radio
->rd_index
], 3))
1267 /* retval = -EFAULT; */
1270 /* increment and wrap read pointer */
1271 radio
->rd_index
+= 3;
1272 if (radio
->rd_index
>= radio
->buf_size
)
1273 radio
->rd_index
= 0;
1275 /* increment counters */
1281 spin_unlock(&radio
->lock
);
1283 mutex_lock(&radio
->lock
);
1284 while (block_count
< count
) {
1285 if (radio
->rd_index
== radio
->wr_index
)
1288 /* always transfer rds complete blocks */
1289 if (copy_to_user(buf
, &radio
->buffer
[radio
->rd_index
], 3))
1290 /* retval = -EFAULT; */
1293 /* increment and wrap read pointer */
1294 radio
->rd_index
+= 3;
1295 if (radio
->rd_index
>= radio
->buf_size
)
1296 radio
->rd_index
= 0;
1298 /* increment counters */
1302 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1304 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1306 mutex_unlock(&radio
->lock
);
1307 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1314 * si470x_fops_poll - poll RDS data
1316 static unsigned int si470x_fops_poll(struct file
*file
,
1317 struct poll_table_struct
*pts
)
1319 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1321 /* switch on rds reception */
1322 if ((radio
->registers
[SYSCONFIG1
] & SYSCONFIG1_RDS
) == 0) {
1323 si470x_rds_on(radio
);
1324 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1325 schedule_work(&radio
->work
);
1327 schedule_delayed_work(&radio
->work
,
1328 msecs_to_jiffies(rds_poll_time
));
1329 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1332 poll_wait(file
, &radio
->read_queue
, pts
);
1334 if (radio
->rd_index
!= radio
->wr_index
)
1335 return POLLIN
| POLLRDNORM
;
1342 * si470x_fops_open - file open
1344 static int si470x_fops_open(struct inode
*inode
, struct file
*file
)
1346 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1347 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1350 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1353 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1354 if (radio
->users
== 1)
1355 return si470x_start(radio
);
1358 retval
= usb_autopm_get_interface(radio
->intf
);
1364 if (radio
->users
== 1) {
1365 retval
= si470x_start(radio
);
1367 usb_autopm_put_interface(radio
->intf
);
1370 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1377 * si470x_fops_release - file release
1379 static int si470x_fops_release(struct inode
*inode
, struct file
*file
)
1381 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1382 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1385 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1391 if (radio
->users
== 0) {
1392 /* stop rds reception */
1393 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1394 del_timer_sync(&radio
->timer
);
1395 flush_scheduled_work();
1397 cancel_delayed_work_sync(&radio
->work
);
1398 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1400 /* cancel read processes */
1401 wake_up_interruptible(&radio
->read_queue
);
1403 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1404 return si470x_stop(radio
);
1406 retval
= si470x_stop(radio
);
1407 usb_autopm_put_interface(radio
->intf
);
1409 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1417 * si470x_fops - file operations interface
1419 static const struct file_operations si470x_fops
= {
1420 .owner
= THIS_MODULE
,
1421 .llseek
= no_llseek
,
1422 .read
= si470x_fops_read
,
1423 .poll
= si470x_fops_poll
,
1424 .ioctl
= video_ioctl2
,
1425 .compat_ioctl
= v4l_compat_ioctl32
,
1426 .open
= si470x_fops_open
,
1427 .release
= si470x_fops_release
,
1432 /**************************************************************************
1433 * Video4Linux Interface
1434 **************************************************************************/
1437 * si470x_v4l2_queryctrl - query control
1439 static struct v4l2_queryctrl si470x_v4l2_queryctrl
[] = {
1440 /* HINT: the disabled controls are only here to satify kradio and such apps */
1442 .id
= V4L2_CID_AUDIO_VOLUME
,
1443 .type
= V4L2_CTRL_TYPE_INTEGER
,
1448 .default_value
= 15,
1451 .id
= V4L2_CID_AUDIO_BALANCE
,
1452 .flags
= V4L2_CTRL_FLAG_DISABLED
,
1455 .id
= V4L2_CID_AUDIO_BASS
,
1456 .flags
= V4L2_CTRL_FLAG_DISABLED
,
1459 .id
= V4L2_CID_AUDIO_TREBLE
,
1460 .flags
= V4L2_CTRL_FLAG_DISABLED
,
1463 .id
= V4L2_CID_AUDIO_MUTE
,
1464 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
1472 .id
= V4L2_CID_AUDIO_LOUDNESS
,
1473 .flags
= V4L2_CTRL_FLAG_DISABLED
,
1479 * si470x_vidioc_querycap - query device capabilities
1481 static int si470x_vidioc_querycap(struct file
*file
, void *priv
,
1482 struct v4l2_capability
*capability
)
1484 strlcpy(capability
->driver
, DRIVER_NAME
, sizeof(capability
->driver
));
1485 strlcpy(capability
->card
, DRIVER_CARD
, sizeof(capability
->card
));
1486 sprintf(capability
->bus_info
, "USB");
1487 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1488 capability
->version
= DRIVER_VERSION
;
1490 capability
->version
= DRIVER_KERNEL_VERSION
;
1491 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1492 capability
->capabilities
= V4L2_CAP_TUNER
| V4L2_CAP_RADIO
;
1499 * si470x_vidioc_g_input - get input
1501 static int si470x_vidioc_g_input(struct file
*filp
, void *priv
,
1511 * si470x_vidioc_s_input - set input
1513 static int si470x_vidioc_s_input(struct file
*filp
, void *priv
, unsigned int i
)
1523 * si470x_vidioc_queryctrl - enumerate control items
1525 static int si470x_vidioc_queryctrl(struct file
*file
, void *priv
,
1526 struct v4l2_queryctrl
*qc
)
1528 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1532 int retval
= -EINVAL
;
1533 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1535 for (i
= 0; i
< ARRAY_SIZE(si470x_v4l2_queryctrl
); i
++) {
1536 if (qc
->id
&& qc
->id
== si470x_v4l2_queryctrl
[i
].id
) {
1537 memcpy(qc
, &(si470x_v4l2_queryctrl
[i
]), sizeof(*qc
));
1538 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1543 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1546 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1549 printk(KERN_WARNING DRIVER_NAME
1550 ": query control failed with %d\n", retval
);
1551 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1553 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1557 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1562 * si470x_vidioc_g_ctrl - get the value of a control
1564 static int si470x_vidioc_g_ctrl(struct file
*file
, void *priv
,
1565 struct v4l2_control
*ctrl
)
1567 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1570 case V4L2_CID_AUDIO_VOLUME
:
1571 ctrl
->value
= radio
->registers
[SYSCONFIG2
] &
1574 case V4L2_CID_AUDIO_MUTE
:
1575 ctrl
->value
= ((radio
->registers
[POWERCFG
] &
1576 POWERCFG_DMUTE
) == 0) ? 1 : 0;
1585 * si470x_vidioc_s_ctrl - set the value of a control
1587 static int si470x_vidioc_s_ctrl(struct file
*file
, void *priv
,
1588 struct v4l2_control
*ctrl
)
1590 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1591 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1594 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1597 case V4L2_CID_AUDIO_VOLUME
:
1598 radio
->registers
[SYSCONFIG2
] &= ~SYSCONFIG2_VOLUME
;
1599 radio
->registers
[SYSCONFIG2
] |= ctrl
->value
;
1600 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1601 return si470x_set_register(radio
, SYSCONFIG2
);
1603 retval
= si470x_set_register(radio
, SYSCONFIG2
);
1605 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1606 case V4L2_CID_AUDIO_MUTE
:
1607 if (ctrl
->value
== 1)
1608 radio
->registers
[POWERCFG
] &= ~POWERCFG_DMUTE
;
1610 radio
->registers
[POWERCFG
] |= POWERCFG_DMUTE
;
1611 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1612 return si470x_set_register(radio
, POWERCFG
);
1614 retval
= si470x_set_register(radio
, POWERCFG
);
1618 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1620 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1623 printk(KERN_WARNING DRIVER_NAME
1624 ": set control failed with %d\n", retval
);
1625 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1627 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1631 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1636 * si470x_vidioc_g_audio - get audio attributes
1638 static int si470x_vidioc_g_audio(struct file
*file
, void *priv
,
1639 struct v4l2_audio
*audio
)
1641 if (audio
->index
> 1)
1644 strcpy(audio
->name
, "Radio");
1645 audio
->capability
= V4L2_AUDCAP_STEREO
;
1652 * si470x_vidioc_s_audio - set audio attributes
1654 static int si470x_vidioc_s_audio(struct file
*file
, void *priv
,
1655 struct v4l2_audio
*audio
)
1657 if (audio
->index
!= 0)
1665 * si470x_vidioc_g_tuner - get tuner attributes
1667 static int si470x_vidioc_g_tuner(struct file
*file
, void *priv
,
1668 struct v4l2_tuner
*tuner
)
1670 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1673 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1674 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1675 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1678 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1680 if (tuner
->index
> 0)
1683 /* read status rssi */
1684 retval
= si470x_get_register(radio
, STATUSRSSI
);
1688 strcpy(tuner
->name
, "FM");
1689 tuner
->type
= V4L2_TUNER_RADIO
;
1691 /* 0: 87.5 - 108 MHz (USA, Europe, default) */
1693 tuner
->rangelow
= 87.5 * FREQ_MUL
;
1694 tuner
->rangehigh
= 108 * FREQ_MUL
;
1696 /* 1: 76 - 108 MHz (Japan wide band) */
1698 tuner
->rangelow
= 76 * FREQ_MUL
;
1699 tuner
->rangehigh
= 108 * FREQ_MUL
;
1701 /* 2: 76 - 90 MHz (Japan) */
1703 tuner
->rangelow
= 76 * FREQ_MUL
;
1704 tuner
->rangehigh
= 90 * FREQ_MUL
;
1707 tuner
->rxsubchans
= V4L2_TUNER_SUB_MONO
| V4L2_TUNER_SUB_STEREO
;
1708 tuner
->capability
= V4L2_TUNER_CAP_LOW
;
1710 /* Stereo indicator == Stereo (instead of Mono) */
1711 if ((radio
->registers
[STATUSRSSI
] & STATUSRSSI_ST
) == 1)
1712 tuner
->audmode
= V4L2_TUNER_MODE_STEREO
;
1714 tuner
->audmode
= V4L2_TUNER_MODE_MONO
;
1716 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */
1717 tuner
->signal
= (radio
->registers
[STATUSRSSI
] & STATUSRSSI_RSSI
)
1720 /* automatic frequency control: -1: freq to low, 1 freq to high */
1728 * si470x_vidioc_s_tuner - set tuner attributes
1730 static int si470x_vidioc_s_tuner(struct file
*file
, void *priv
,
1731 struct v4l2_tuner
*tuner
)
1733 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1734 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1737 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1739 if (tuner
->index
> 0)
1742 if (tuner
->audmode
== V4L2_TUNER_MODE_MONO
)
1743 radio
->registers
[POWERCFG
] |= POWERCFG_MONO
; /* force mono */
1745 radio
->registers
[POWERCFG
] &= ~POWERCFG_MONO
; /* try stereo */
1747 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1748 return si470x_set_register(radio
, POWERCFG
);
1750 retval
= si470x_set_register(radio
, POWERCFG
);
1752 printk(KERN_WARNING DRIVER_NAME
1753 ": set tuner failed with %d\n", retval
);
1756 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1761 * si470x_vidioc_g_frequency - get tuner or modulator radio frequency
1763 static int si470x_vidioc_g_frequency(struct file
*file
, void *priv
,
1764 struct v4l2_frequency
*freq
)
1766 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1768 freq
->type
= V4L2_TUNER_RADIO
;
1769 freq
->frequency
= si470x_get_freq(radio
);
1776 * si470x_vidioc_s_frequency - set tuner or modulator radio frequency
1778 static int si470x_vidioc_s_frequency(struct file
*file
, void *priv
,
1779 struct v4l2_frequency
*freq
)
1781 struct si470x_device
*radio
= video_get_drvdata(video_devdata(file
));
1782 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1785 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1787 if (freq
->type
!= V4L2_TUNER_RADIO
)
1790 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1791 return si470x_set_freq(radio
, freq
->frequency
);
1793 retval
= si470x_set_freq(radio
, freq
->frequency
);
1795 printk(KERN_WARNING DRIVER_NAME
1796 ": set frequency failed with %d\n", retval
);
1799 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1804 * si470x_viddev_tamples - video device interface
1806 static struct video_device si470x_viddev_template
= {
1807 .fops
= &si470x_fops
,
1808 .name
= DRIVER_NAME
,
1809 .type
= VID_TYPE_TUNER
,
1810 .release
= video_device_release
,
1811 .vidioc_querycap
= si470x_vidioc_querycap
,
1812 .vidioc_g_input
= si470x_vidioc_g_input
,
1813 .vidioc_s_input
= si470x_vidioc_s_input
,
1814 .vidioc_queryctrl
= si470x_vidioc_queryctrl
,
1815 .vidioc_g_ctrl
= si470x_vidioc_g_ctrl
,
1816 .vidioc_s_ctrl
= si470x_vidioc_s_ctrl
,
1817 .vidioc_g_audio
= si470x_vidioc_g_audio
,
1818 .vidioc_s_audio
= si470x_vidioc_s_audio
,
1819 .vidioc_g_tuner
= si470x_vidioc_g_tuner
,
1820 .vidioc_s_tuner
= si470x_vidioc_s_tuner
,
1821 .vidioc_g_frequency
= si470x_vidioc_g_frequency
,
1822 .vidioc_s_frequency
= si470x_vidioc_s_frequency
,
1823 .owner
= THIS_MODULE
,
1828 /**************************************************************************
1830 **************************************************************************/
1833 * si470x_usb_driver_probe - probe for the device
1835 static int si470x_usb_driver_probe(struct usb_interface
*intf
,
1836 const struct usb_device_id
*id
)
1838 struct si470x_device
*radio
;
1839 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1841 int retval
= -ENOMEM
;
1842 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1844 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1845 /* memory and interface allocations */
1846 radio
= kmalloc(sizeof(struct si470x_device
), GFP_KERNEL
);
1848 /* private data allocation */
1849 radio
= kzalloc(sizeof(struct si470x_device
), GFP_KERNEL
);
1850 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1852 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1857 /* video device allocation */
1858 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1859 radio
->videodev
= video_device_alloc();
1860 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1861 if (!radio
->videodev
) {
1866 if (!radio
->videodev
)
1869 /* initial configuration */
1870 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1871 memcpy(radio
->videodev
, &si470x_viddev_template
,
1872 sizeof(si470x_viddev_template
));
1874 radio
->usbdev
= interface_to_usbdev(intf
);
1875 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1878 mutex_init(&radio
->lock
);
1879 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1880 video_set_drvdata(radio
->videodev
, radio
);
1881 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1882 if (video_register_device(radio
->videodev
, VFL_TYPE_RADIO
, radio_nr
)) {
1883 printk(KERN_WARNING DRIVER_NAME
1884 ": Could not register video device\n");
1885 video_device_release(radio
->videodev
);
1889 usb_set_intfdata(intf
, radio
);
1891 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1893 /* show some infos about the specific device */
1894 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1895 if (si470x_get_all_registers(radio
) < 0) {
1896 video_device_release(radio
->videodev
);
1900 printk(KERN_INFO DRIVER_NAME
": DeviceID=0x%4.4x ChipID=0x%4.4x\n",
1903 if (si470x_get_all_registers(radio
) < 0)
1905 printk(KERN_INFO DRIVER_NAME
": DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
1906 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1907 radio
->registers
[DEVICEID
], radio
->registers
[CHIPID
]);
1909 /* check if firmware is current */
1910 if ((radio
->registers
[CHIPID
] & CHIPID_FIRMWARE
)
1911 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1912 < RADIO_SW_VERSION_CURRENT
)
1914 < RADIO_SW_VERSION_CURRENT
) {
1915 printk(KERN_WARNING DRIVER_NAME
1916 ": This driver is known to work with "
1917 "firmware version %hu,\n", RADIO_SW_VERSION_CURRENT
);
1918 printk(KERN_WARNING DRIVER_NAME
1919 ": but the device has firmware version %hu.\n",
1920 radio
->registers
[CHIPID
] & CHIPID_FIRMWARE
);
1921 printk(KERN_WARNING DRIVER_NAME
1922 ": If you have some trouble using this driver,\n");
1923 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1924 printk(KERN_WARNING DRIVER_NAME
1925 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1926 ": This driver is known to work with chip version %d, "
1927 "but the device has firmware %d.\n"
1929 "If you have some trouble using this driver, please "
1930 "report to V4L ML at video4linux-list@redhat.com\n",
1931 radio
->registers
[CHIPID
] & CHIPID_FIRMWARE
,
1932 RADIO_SW_VERSION_CURRENT
);
1934 ": please report to V4L ML at "
1935 "video4linux-list@redhat.com\n");
1937 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1939 /* set initial frequency */
1940 si470x_set_freq(radio
, 87.5 * FREQ_MUL
); /* available in all regions */
1942 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1943 /* rds initialization */
1945 /* rds buffer allocation */
1946 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1947 radio
->buf_size
= rds_buf
* 3;
1948 radio
->buffer
= kmalloc(radio
->buf_size
, GFP_KERNEL
);
1949 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1950 if (!radio
->buffer
) {
1951 video_device_release(radio
->videodev
);
1959 /* rds buffer configuration */
1960 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
1961 radio
->wr_index
= 0;
1962 radio
->rd_index
= 0;
1963 init_waitqueue_head(&radio
->read_queue
);
1965 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
1966 /* prepare polling via eventd */
1967 INIT_WORK(&radio
->work
, si470x_work
);
1968 init_timer(&radio
->timer
);
1969 radio
->timer
.function
= si470x_timer
;
1970 radio
->timer
.data
= (unsigned long) radio
;
1972 /* prepare rds work function */
1973 INIT_DELAYED_WORK(&radio
->work
, si470x_work
);
1975 /* register video device */
1976 if (video_register_device(radio
->videodev
, VFL_TYPE_RADIO
, radio_nr
)) {
1977 printk(KERN_WARNING DRIVER_NAME
1978 ": Could not register video device\n");
1981 usb_set_intfdata(intf
, radio
);
1985 video_device_release(radio
->videodev
);
1986 kfree(radio
->buffer
);
1995 * si470x_usb_driver_suspend - suspend the device
1997 static int si470x_usb_driver_suspend(struct usb_interface
*intf
,
1998 pm_message_t message
)
2000 struct si470x_device
*radio
= usb_get_intfdata(intf
);
2002 printk(KERN_INFO DRIVER_NAME
": suspending now...\n");
2004 cancel_delayed_work_sync(&radio
->work
);
2011 * si470x_usb_driver_resume - resume the device
2013 static int si470x_usb_driver_resume(struct usb_interface
*intf
)
2015 struct si470x_device
*radio
= usb_get_intfdata(intf
);
2017 printk(KERN_INFO DRIVER_NAME
": resuming now...\n");
2019 mutex_lock(&radio
->lock
);
2020 if (radio
->users
&& radio
->registers
[SYSCONFIG1
] & SYSCONFIG1_RDS
)
2021 schedule_delayed_work(&radio
->work
,
2022 msecs_to_jiffies(rds_poll_time
));
2023 mutex_unlock(&radio
->lock
);
2024 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
2031 * si470x_usb_driver_disconnect - disconnect the device
2033 static void si470x_usb_driver_disconnect(struct usb_interface
*intf
)
2035 struct si470x_device
*radio
= usb_get_intfdata(intf
);
2037 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
2038 del_timer_sync(&radio
->timer
);
2039 flush_scheduled_work();
2042 cancel_delayed_work_sync(&radio
->work
);
2043 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
2044 usb_set_intfdata(intf
, NULL
);
2045 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
2047 video_unregister_device(radio
->videodev
);
2048 kfree(radio
->buffer
);
2052 video_unregister_device(radio
->videodev
);
2053 kfree(radio
->buffer
);
2055 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
2060 * si470x_usb_driver - usb driver interface
2062 static struct usb_driver si470x_usb_driver
= {
2063 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
2064 .name
= DRIVER_NAME
,
2065 .probe
= si470x_usb_driver_probe
,
2066 .disconnect
= si470x_usb_driver_disconnect
,
2067 .id_table
= si470x_usb_driver_id_table
,
2069 .name
= DRIVER_NAME
,
2070 .probe
= si470x_usb_driver_probe
,
2071 .disconnect
= si470x_usb_driver_disconnect
,
2072 .suspend
= si470x_usb_driver_suspend
,
2073 .resume
= si470x_usb_driver_resume
,
2074 .id_table
= si470x_usb_driver_id_table
,
2075 .supports_autosuspend
= 1,
2076 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
2081 /**************************************************************************
2083 **************************************************************************/
2086 * si470x_module_init - module init
2088 static int __init
si470x_module_init(void)
2090 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
2091 printk(KERN_INFO DRIVER_DESC
"\n");
2093 printk(KERN_INFO DRIVER_DESC
", Version " DRIVER_VERSION
"\n");
2094 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c
2095 return usb_register(&si470x_usb_driver
);
2100 * si470x_module_exit - module exit
2102 static void __exit
si470x_module_exit(void)
2104 usb_deregister(&si470x_usb_driver
);
2108 module_init(si470x_module_init
);
2109 module_exit(si470x_module_exit
);
2111 MODULE_LICENSE("GPL");
2112 MODULE_AUTHOR(DRIVER_AUTHOR
);
2113 MODULE_DESCRIPTION(DRIVER_DESC
);
2114 <<<<<<< HEAD
:drivers
/media
/radio
/radio
-si470x
.c
2115 MODULE_VERSION("1.0.4");
2117 MODULE_VERSION(DRIVER_VERSION
);
2118 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/radio
/radio
-si470x
.c