1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drivers/media/radio/si470x/radio-si470x-common.c
5 * Driver for radios with Silicon Labs Si470x FM Radio Receivers
7 * Copyright (c) 2009 Tobias Lorenz <tobias.lorenz@gmx.net>
8 * Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
14 * 2008-01-12 Tobias Lorenz <tobias.lorenz@gmx.net>
16 * - First working version
17 * 2008-01-13 Tobias Lorenz <tobias.lorenz@gmx.net>
19 * - Improved error handling, every function now returns errno
20 * - Improved multi user access (start/mute/stop)
21 * - Channel doesn't get lost anymore after start/mute/stop
22 * - RDS support added (polling mode via interrupt EP 1)
23 * - marked default module parameters with *value*
24 * - switched from bit structs to bit masks
25 * - header file cleaned and integrated
26 * 2008-01-14 Tobias Lorenz <tobias.lorenz@gmx.net>
28 * - hex values are now lower case
29 * - commented USB ID for ADS/Tech moved on todo list
30 * - blacklisted si470x in hid-quirks.c
31 * - rds buffer handling functions integrated into *_work, *_read
32 * - rds_command in si470x_poll exchanged against simple retval
33 * - check for firmware version 15
34 * - code order and prototypes still remain the same
35 * - spacing and bottom of band codes remain the same
36 * 2008-01-16 Tobias Lorenz <tobias.lorenz@gmx.net>
38 * - code reordered to avoid function prototypes
39 * - switch/case defaults are now more user-friendly
40 * - unified comment style
41 * - applied all checkpatch.pl v1.12 suggestions
42 * except the warning about the too long lines with bit comments
43 * - renamed FMRADIO to RADIO to cut line length (checkpatch.pl)
44 * 2008-01-22 Tobias Lorenz <tobias.lorenz@gmx.net>
46 * - avoid poss. locking when doing copy_to_user which may sleep
47 * - RDS is automatically activated on read now
48 * - code cleaned of unnecessary rds_commands
49 * - USB Vendor/Product ID for ADS/Tech FM Radio Receiver verified
50 * (thanks to Guillaume RAMOUSSE)
51 * 2008-01-27 Tobias Lorenz <tobias.lorenz@gmx.net>
53 * - number of seek_retries changed to tune_timeout
54 * - fixed problem with incomplete tune operations by own buffers
55 * - optimization of variables and printf types
56 * - improved error logging
57 * 2008-01-31 Tobias Lorenz <tobias.lorenz@gmx.net>
58 * Oliver Neukum <oliver@neukum.org>
60 * - fixed coverity checker warnings in *_usb_driver_disconnect
61 * - probe()/open() race by correct ordering in probe()
62 * - DMA coherency rules by separate allocation of all buffers
63 * - use of endianness macros
64 * - abuse of spinlock, replaced by mutex
65 * - racy handling of timer in disconnect,
66 * replaced by delayed_work
67 * - racy interruptible_sleep_on(),
68 * replaced with wait_event_interruptible()
69 * - handle signals in read()
70 * 2008-02-08 Tobias Lorenz <tobias.lorenz@gmx.net>
71 * Oliver Neukum <oliver@neukum.org>
73 * - usb autosuspend support
75 * 2008-05-07 Tobias Lorenz <tobias.lorenz@gmx.net>
77 * - hardware frequency seek support
79 * - more safety checks, let si470x_get_freq return errno
80 * - vidioc behavior corrected according to v4l2 spec
81 * 2008-10-20 Alexey Klimov <klimov.linux@gmail.com>
82 * - add support for KWorld USB FM Radio FM700
83 * - blacklisted KWorld radio in hid-core.c and hid-ids.h
84 * 2008-12-03 Mark Lord <mlord@pobox.com>
85 * - add support for DealExtreme USB Radio
86 * 2009-01-31 Bob Ross <pigiron@gmx.com>
87 * - correction of stereo detection/setting
88 * - correction of signal strength indicator scaling
89 * 2009-01-31 Rick Bronson <rick@efn.org>
90 * Tobias Lorenz <tobias.lorenz@gmx.net>
91 * - add LED status output
92 * - get HW/SW version from scratchpad
93 * 2009-06-16 Edouard Lafargue <edouard@lafargue.name>
95 * - add support for interrupt mode for RDS endpoint,
97 * Improves RDS reception significantly
101 /* kernel includes */
102 #include "radio-si470x.h"
104 /**************************************************************************
106 **************************************************************************/
109 /* 0: 200 kHz (USA, Australia) */
110 /* 1: 100 kHz (Europe, Japan) */
112 static unsigned short space
= 2;
113 module_param(space
, ushort
, 0444);
114 MODULE_PARM_DESC(space
, "Spacing: 0=200kHz 1=100kHz *2=50kHz*");
118 /* 1: 50 us (Europe, Australia, Japan) */
119 static unsigned short de
= 1;
120 module_param(de
, ushort
, 0444);
121 MODULE_PARM_DESC(de
, "De-emphasis: 0=75us *1=50us*");
124 static unsigned int tune_timeout
= 3000;
125 module_param(tune_timeout
, uint
, 0644);
126 MODULE_PARM_DESC(tune_timeout
, "Tune timeout: *3000*");
129 static unsigned int seek_timeout
= 5000;
130 module_param(seek_timeout
, uint
, 0644);
131 MODULE_PARM_DESC(seek_timeout
, "Seek timeout: *5000*");
133 static const struct v4l2_frequency_band bands
[] = {
135 .type
= V4L2_TUNER_RADIO
,
137 .capability
= V4L2_TUNER_CAP_LOW
| V4L2_TUNER_CAP_STEREO
|
138 V4L2_TUNER_CAP_RDS
| V4L2_TUNER_CAP_RDS_BLOCK_IO
|
139 V4L2_TUNER_CAP_FREQ_BANDS
|
140 V4L2_TUNER_CAP_HWSEEK_BOUNDED
|
141 V4L2_TUNER_CAP_HWSEEK_WRAP
,
142 .rangelow
= 87500 * 16,
143 .rangehigh
= 108000 * 16,
144 .modulation
= V4L2_BAND_MODULATION_FM
,
147 .type
= V4L2_TUNER_RADIO
,
149 .capability
= V4L2_TUNER_CAP_LOW
| V4L2_TUNER_CAP_STEREO
|
150 V4L2_TUNER_CAP_RDS
| V4L2_TUNER_CAP_RDS_BLOCK_IO
|
151 V4L2_TUNER_CAP_FREQ_BANDS
|
152 V4L2_TUNER_CAP_HWSEEK_BOUNDED
|
153 V4L2_TUNER_CAP_HWSEEK_WRAP
,
154 .rangelow
= 76000 * 16,
155 .rangehigh
= 108000 * 16,
156 .modulation
= V4L2_BAND_MODULATION_FM
,
159 .type
= V4L2_TUNER_RADIO
,
161 .capability
= V4L2_TUNER_CAP_LOW
| V4L2_TUNER_CAP_STEREO
|
162 V4L2_TUNER_CAP_RDS
| V4L2_TUNER_CAP_RDS_BLOCK_IO
|
163 V4L2_TUNER_CAP_FREQ_BANDS
|
164 V4L2_TUNER_CAP_HWSEEK_BOUNDED
|
165 V4L2_TUNER_CAP_HWSEEK_WRAP
,
166 .rangelow
= 76000 * 16,
167 .rangehigh
= 90000 * 16,
168 .modulation
= V4L2_BAND_MODULATION_FM
,
172 /**************************************************************************
174 **************************************************************************/
177 * si470x_set_band - set the band
179 static int si470x_set_band(struct si470x_device
*radio
, int band
)
181 if (radio
->band
== band
)
185 radio
->registers
[SYSCONFIG2
] &= ~SYSCONFIG2_BAND
;
186 radio
->registers
[SYSCONFIG2
] |= radio
->band
<< 6;
187 return radio
->set_register(radio
, SYSCONFIG2
);
191 * si470x_set_chan - set the channel
193 static int si470x_set_chan(struct si470x_device
*radio
, unsigned short chan
)
196 unsigned long time_left
;
197 bool timed_out
= false;
199 retval
= radio
->get_register(radio
, POWERCFG
);
203 if ((radio
->registers
[POWERCFG
] & (POWERCFG_ENABLE
|POWERCFG_DMUTE
))
204 != (POWERCFG_ENABLE
|POWERCFG_DMUTE
)) {
209 radio
->registers
[CHANNEL
] &= ~CHANNEL_CHAN
;
210 radio
->registers
[CHANNEL
] |= CHANNEL_TUNE
| chan
;
211 retval
= radio
->set_register(radio
, CHANNEL
);
215 /* wait till tune operation has completed */
216 reinit_completion(&radio
->completion
);
217 time_left
= wait_for_completion_timeout(&radio
->completion
,
218 msecs_to_jiffies(tune_timeout
));
222 if ((radio
->registers
[STATUSRSSI
] & STATUSRSSI_STC
) == 0)
223 dev_warn(&radio
->videodev
.dev
, "tune does not complete\n");
225 dev_warn(&radio
->videodev
.dev
,
226 "tune timed out after %u ms\n", tune_timeout
);
229 radio
->registers
[CHANNEL
] &= ~CHANNEL_TUNE
;
230 retval
= radio
->set_register(radio
, CHANNEL
);
237 * si470x_get_step - get channel spacing
239 static unsigned int si470x_get_step(struct si470x_device
*radio
)
242 switch ((radio
->registers
[SYSCONFIG2
] & SYSCONFIG2_SPACE
) >> 4) {
243 /* 0: 200 kHz (USA, Australia) */
246 /* 1: 100 kHz (Europe, Japan) */
257 * si470x_get_freq - get the frequency
259 static int si470x_get_freq(struct si470x_device
*radio
, unsigned int *freq
)
264 retval
= radio
->get_register(radio
, READCHAN
);
265 chan
= radio
->registers
[READCHAN
] & READCHAN_READCHAN
;
267 /* Frequency (MHz) = Spacing (kHz) x Channel + Bottom of Band (MHz) */
268 *freq
= chan
* si470x_get_step(radio
) + bands
[radio
->band
].rangelow
;
275 * si470x_set_freq - set the frequency
277 int si470x_set_freq(struct si470x_device
*radio
, unsigned int freq
)
281 freq
= clamp(freq
, bands
[radio
->band
].rangelow
,
282 bands
[radio
->band
].rangehigh
);
283 /* Chan = [ Freq (Mhz) - Bottom of Band (MHz) ] / Spacing (kHz) */
284 chan
= (freq
- bands
[radio
->band
].rangelow
) / si470x_get_step(radio
);
286 return si470x_set_chan(radio
, chan
);
288 EXPORT_SYMBOL_GPL(si470x_set_freq
);
292 * si470x_set_seek - set seek
294 static int si470x_set_seek(struct si470x_device
*radio
,
295 const struct v4l2_hw_freq_seek
*seek
)
299 bool timed_out
= false;
300 unsigned long time_left
;
303 if (seek
->rangelow
|| seek
->rangehigh
) {
304 for (band
= 0; band
< ARRAY_SIZE(bands
); band
++) {
305 if (bands
[band
].rangelow
== seek
->rangelow
&&
306 bands
[band
].rangehigh
== seek
->rangehigh
)
309 if (band
== ARRAY_SIZE(bands
))
310 return -EINVAL
; /* No matching band found */
312 band
= 1; /* If nothing is specified seek 76 - 108 Mhz */
314 if (radio
->band
!= band
) {
315 retval
= si470x_get_freq(radio
, &freq
);
318 retval
= si470x_set_band(radio
, band
);
321 retval
= si470x_set_freq(radio
, freq
);
327 radio
->registers
[POWERCFG
] |= POWERCFG_SEEK
;
328 if (seek
->wrap_around
)
329 radio
->registers
[POWERCFG
] &= ~POWERCFG_SKMODE
;
331 radio
->registers
[POWERCFG
] |= POWERCFG_SKMODE
;
332 if (seek
->seek_upward
)
333 radio
->registers
[POWERCFG
] |= POWERCFG_SEEKUP
;
335 radio
->registers
[POWERCFG
] &= ~POWERCFG_SEEKUP
;
336 retval
= radio
->set_register(radio
, POWERCFG
);
340 /* wait till tune operation has completed */
341 reinit_completion(&radio
->completion
);
342 time_left
= wait_for_completion_timeout(&radio
->completion
,
343 msecs_to_jiffies(seek_timeout
));
347 if ((radio
->registers
[STATUSRSSI
] & STATUSRSSI_STC
) == 0)
348 dev_warn(&radio
->videodev
.dev
, "seek does not complete\n");
349 if (radio
->registers
[STATUSRSSI
] & STATUSRSSI_SF
)
350 dev_warn(&radio
->videodev
.dev
,
351 "seek failed / band limit reached\n");
354 radio
->registers
[POWERCFG
] &= ~POWERCFG_SEEK
;
355 retval
= radio
->set_register(radio
, POWERCFG
);
357 /* try again, if timed out */
358 if (retval
== 0 && timed_out
)
365 * si470x_start - switch on radio
367 int si470x_start(struct si470x_device
*radio
)
372 radio
->registers
[POWERCFG
] =
373 POWERCFG_DMUTE
| POWERCFG_ENABLE
| POWERCFG_RDSM
;
374 retval
= radio
->set_register(radio
, POWERCFG
);
379 radio
->registers
[SYSCONFIG1
] |= SYSCONFIG1_RDSIEN
| SYSCONFIG1_STCIEN
|
381 radio
->registers
[SYSCONFIG1
] &= ~SYSCONFIG1_GPIO2
;
382 radio
->registers
[SYSCONFIG1
] |= SYSCONFIG1_GPIO2_INT
;
384 radio
->registers
[SYSCONFIG1
] |= SYSCONFIG1_DE
;
385 retval
= radio
->set_register(radio
, SYSCONFIG1
);
390 radio
->registers
[SYSCONFIG2
] =
391 (0x1f << 8) | /* SEEKTH */
392 ((radio
->band
<< 6) & SYSCONFIG2_BAND
) |/* BAND */
393 ((space
<< 4) & SYSCONFIG2_SPACE
) | /* SPACE */
394 15; /* VOLUME (max) */
395 retval
= radio
->set_register(radio
, SYSCONFIG2
);
399 /* reset last channel */
400 retval
= si470x_set_chan(radio
,
401 radio
->registers
[CHANNEL
] & CHANNEL_CHAN
);
406 EXPORT_SYMBOL_GPL(si470x_start
);
410 * si470x_stop - switch off radio
412 int si470x_stop(struct si470x_device
*radio
)
417 radio
->registers
[SYSCONFIG1
] &= ~SYSCONFIG1_RDS
;
418 retval
= radio
->set_register(radio
, SYSCONFIG1
);
423 radio
->registers
[POWERCFG
] &= ~POWERCFG_DMUTE
;
424 /* POWERCFG_ENABLE has to automatically go low */
425 radio
->registers
[POWERCFG
] |= POWERCFG_ENABLE
| POWERCFG_DISABLE
;
426 retval
= radio
->set_register(radio
, POWERCFG
);
431 EXPORT_SYMBOL_GPL(si470x_stop
);
435 * si470x_rds_on - switch on rds reception
437 static int si470x_rds_on(struct si470x_device
*radio
)
442 radio
->registers
[SYSCONFIG1
] |= SYSCONFIG1_RDS
;
443 retval
= radio
->set_register(radio
, SYSCONFIG1
);
445 radio
->registers
[SYSCONFIG1
] &= ~SYSCONFIG1_RDS
;
452 /**************************************************************************
453 * File Operations Interface
454 **************************************************************************/
457 * si470x_fops_read - read RDS data
459 static ssize_t
si470x_fops_read(struct file
*file
, char __user
*buf
,
460 size_t count
, loff_t
*ppos
)
462 struct si470x_device
*radio
= video_drvdata(file
);
464 unsigned int block_count
= 0;
466 /* switch on rds reception */
467 if ((radio
->registers
[SYSCONFIG1
] & SYSCONFIG1_RDS
) == 0)
468 si470x_rds_on(radio
);
470 /* block if no new data available */
471 while (radio
->wr_index
== radio
->rd_index
) {
472 if (file
->f_flags
& O_NONBLOCK
) {
473 retval
= -EWOULDBLOCK
;
476 if (wait_event_interruptible(radio
->read_queue
,
477 radio
->wr_index
!= radio
->rd_index
) < 0) {
483 /* calculate block count from byte count */
486 /* copy RDS block out of internal buffer and to user buffer */
487 while (block_count
< count
) {
488 if (radio
->rd_index
== radio
->wr_index
)
491 /* always transfer rds complete blocks */
492 if (copy_to_user(buf
, &radio
->buffer
[radio
->rd_index
], 3))
493 /* retval = -EFAULT; */
496 /* increment and wrap read pointer */
497 radio
->rd_index
+= 3;
498 if (radio
->rd_index
>= radio
->buf_size
)
501 /* increment counters */
513 * si470x_fops_poll - poll RDS data
515 static __poll_t
si470x_fops_poll(struct file
*file
,
516 struct poll_table_struct
*pts
)
518 struct si470x_device
*radio
= video_drvdata(file
);
519 __poll_t req_events
= poll_requested_events(pts
);
520 __poll_t retval
= v4l2_ctrl_poll(file
, pts
);
522 if (req_events
& (EPOLLIN
| EPOLLRDNORM
)) {
523 /* switch on rds reception */
524 if ((radio
->registers
[SYSCONFIG1
] & SYSCONFIG1_RDS
) == 0)
525 si470x_rds_on(radio
);
527 poll_wait(file
, &radio
->read_queue
, pts
);
529 if (radio
->rd_index
!= radio
->wr_index
)
530 retval
|= EPOLLIN
| EPOLLRDNORM
;
537 static int si470x_fops_open(struct file
*file
)
539 struct si470x_device
*radio
= video_drvdata(file
);
541 return radio
->fops_open(file
);
546 * si470x_fops_release - file release
548 static int si470x_fops_release(struct file
*file
)
550 struct si470x_device
*radio
= video_drvdata(file
);
552 return radio
->fops_release(file
);
557 * si470x_fops - file operations interface
559 static const struct v4l2_file_operations si470x_fops
= {
560 .owner
= THIS_MODULE
,
561 .read
= si470x_fops_read
,
562 .poll
= si470x_fops_poll
,
563 .unlocked_ioctl
= video_ioctl2
,
564 .open
= si470x_fops_open
,
565 .release
= si470x_fops_release
,
570 /**************************************************************************
571 * Video4Linux Interface
572 **************************************************************************/
575 static int si470x_s_ctrl(struct v4l2_ctrl
*ctrl
)
577 struct si470x_device
*radio
=
578 container_of(ctrl
->handler
, struct si470x_device
, hdl
);
581 case V4L2_CID_AUDIO_VOLUME
:
582 radio
->registers
[SYSCONFIG2
] &= ~SYSCONFIG2_VOLUME
;
583 radio
->registers
[SYSCONFIG2
] |= ctrl
->val
;
584 return radio
->set_register(radio
, SYSCONFIG2
);
585 case V4L2_CID_AUDIO_MUTE
:
587 radio
->registers
[POWERCFG
] &= ~POWERCFG_DMUTE
;
589 radio
->registers
[POWERCFG
] |= POWERCFG_DMUTE
;
590 return radio
->set_register(radio
, POWERCFG
);
598 * si470x_vidioc_g_tuner - get tuner attributes
600 static int si470x_vidioc_g_tuner(struct file
*file
, void *priv
,
601 struct v4l2_tuner
*tuner
)
603 struct si470x_device
*radio
= video_drvdata(file
);
606 if (tuner
->index
!= 0)
609 if (!radio
->status_rssi_auto_update
) {
610 retval
= radio
->get_register(radio
, STATUSRSSI
);
615 /* driver constants */
616 strscpy(tuner
->name
, "FM", sizeof(tuner
->name
));
617 tuner
->type
= V4L2_TUNER_RADIO
;
618 tuner
->capability
= V4L2_TUNER_CAP_LOW
| V4L2_TUNER_CAP_STEREO
|
619 V4L2_TUNER_CAP_RDS
| V4L2_TUNER_CAP_RDS_BLOCK_IO
|
620 V4L2_TUNER_CAP_HWSEEK_BOUNDED
|
621 V4L2_TUNER_CAP_HWSEEK_WRAP
;
622 tuner
->rangelow
= 76 * FREQ_MUL
;
623 tuner
->rangehigh
= 108 * FREQ_MUL
;
625 /* stereo indicator == stereo (instead of mono) */
626 if ((radio
->registers
[STATUSRSSI
] & STATUSRSSI_ST
) == 0)
627 tuner
->rxsubchans
= V4L2_TUNER_SUB_MONO
;
629 tuner
->rxsubchans
= V4L2_TUNER_SUB_STEREO
;
630 /* If there is a reliable method of detecting an RDS channel,
631 then this code should check for that before setting this
633 tuner
->rxsubchans
|= V4L2_TUNER_SUB_RDS
;
635 /* mono/stereo selector */
636 if ((radio
->registers
[POWERCFG
] & POWERCFG_MONO
) == 0)
637 tuner
->audmode
= V4L2_TUNER_MODE_STEREO
;
639 tuner
->audmode
= V4L2_TUNER_MODE_MONO
;
641 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */
642 /* measured in units of dbµV in 1 db increments (max at ~75 dbµV) */
643 tuner
->signal
= (radio
->registers
[STATUSRSSI
] & STATUSRSSI_RSSI
);
644 /* the ideal factor is 0xffff/75 = 873,8 */
645 tuner
->signal
= (tuner
->signal
* 873) + (8 * tuner
->signal
/ 10);
646 if (tuner
->signal
> 0xffff)
647 tuner
->signal
= 0xffff;
649 /* automatic frequency control: -1: freq to low, 1 freq to high */
650 /* AFCRL does only indicate that freq. differs, not if too low/high */
651 tuner
->afc
= (radio
->registers
[STATUSRSSI
] & STATUSRSSI_AFCRL
) ? 1 : 0;
658 * si470x_vidioc_s_tuner - set tuner attributes
660 static int si470x_vidioc_s_tuner(struct file
*file
, void *priv
,
661 const struct v4l2_tuner
*tuner
)
663 struct si470x_device
*radio
= video_drvdata(file
);
665 if (tuner
->index
!= 0)
668 /* mono/stereo selector */
669 switch (tuner
->audmode
) {
670 case V4L2_TUNER_MODE_MONO
:
671 radio
->registers
[POWERCFG
] |= POWERCFG_MONO
; /* force mono */
673 case V4L2_TUNER_MODE_STEREO
:
675 radio
->registers
[POWERCFG
] &= ~POWERCFG_MONO
; /* try stereo */
679 return radio
->set_register(radio
, POWERCFG
);
684 * si470x_vidioc_g_frequency - get tuner or modulator radio frequency
686 static int si470x_vidioc_g_frequency(struct file
*file
, void *priv
,
687 struct v4l2_frequency
*freq
)
689 struct si470x_device
*radio
= video_drvdata(file
);
691 if (freq
->tuner
!= 0)
694 freq
->type
= V4L2_TUNER_RADIO
;
695 return si470x_get_freq(radio
, &freq
->frequency
);
700 * si470x_vidioc_s_frequency - set tuner or modulator radio frequency
702 static int si470x_vidioc_s_frequency(struct file
*file
, void *priv
,
703 const struct v4l2_frequency
*freq
)
705 struct si470x_device
*radio
= video_drvdata(file
);
708 if (freq
->tuner
!= 0)
711 if (freq
->frequency
< bands
[radio
->band
].rangelow
||
712 freq
->frequency
> bands
[radio
->band
].rangehigh
) {
713 /* Switch to band 1 which covers everything we support */
714 retval
= si470x_set_band(radio
, 1);
718 return si470x_set_freq(radio
, freq
->frequency
);
723 * si470x_vidioc_s_hw_freq_seek - set hardware frequency seek
725 static int si470x_vidioc_s_hw_freq_seek(struct file
*file
, void *priv
,
726 const struct v4l2_hw_freq_seek
*seek
)
728 struct si470x_device
*radio
= video_drvdata(file
);
730 if (seek
->tuner
!= 0)
733 if (file
->f_flags
& O_NONBLOCK
)
736 return si470x_set_seek(radio
, seek
);
740 * si470x_vidioc_enum_freq_bands - enumerate supported bands
742 static int si470x_vidioc_enum_freq_bands(struct file
*file
, void *priv
,
743 struct v4l2_frequency_band
*band
)
745 if (band
->tuner
!= 0)
747 if (band
->index
>= ARRAY_SIZE(bands
))
749 *band
= bands
[band
->index
];
753 const struct v4l2_ctrl_ops si470x_ctrl_ops
= {
754 .s_ctrl
= si470x_s_ctrl
,
756 EXPORT_SYMBOL_GPL(si470x_ctrl_ops
);
758 static int si470x_vidioc_querycap(struct file
*file
, void *priv
,
759 struct v4l2_capability
*capability
)
761 struct si470x_device
*radio
= video_drvdata(file
);
763 return radio
->vidioc_querycap(file
, priv
, capability
);
767 * si470x_ioctl_ops - video device ioctl operations
769 static const struct v4l2_ioctl_ops si470x_ioctl_ops
= {
770 .vidioc_querycap
= si470x_vidioc_querycap
,
771 .vidioc_g_tuner
= si470x_vidioc_g_tuner
,
772 .vidioc_s_tuner
= si470x_vidioc_s_tuner
,
773 .vidioc_g_frequency
= si470x_vidioc_g_frequency
,
774 .vidioc_s_frequency
= si470x_vidioc_s_frequency
,
775 .vidioc_s_hw_freq_seek
= si470x_vidioc_s_hw_freq_seek
,
776 .vidioc_enum_freq_bands
= si470x_vidioc_enum_freq_bands
,
777 .vidioc_subscribe_event
= v4l2_ctrl_subscribe_event
,
778 .vidioc_unsubscribe_event
= v4l2_event_unsubscribe
,
783 * si470x_viddev_template - video device interface
785 const struct video_device si470x_viddev_template
= {
786 .fops
= &si470x_fops
,
788 .release
= video_device_release_empty
,
789 .ioctl_ops
= &si470x_ioctl_ops
,
791 EXPORT_SYMBOL_GPL(si470x_viddev_template
);
793 MODULE_LICENSE("GPL");