aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-sf16fmr2.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 17:39:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 17:39:09 -0400
commite317234975cb7463b8ca21a93bb6862d9dcf113f (patch)
tree4446fa3a21364f3cba23a22aa2a94027f169d8df /drivers/media/radio/radio-sf16fmr2.c
parentf37ab0fba271e43edab0e3ae9fe644fcda455402 (diff)
parent7483d45f0aee3afc0646d185cabd4af9f6cab58c (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - V4L2 API additions to better support JPEG compression control - media API additions to properly support MPEG decoders - V4L2 API additions for image crop/scaling - a few other V4L2 API DocBook fixes/improvements - two new DVB frontend drivers: m88rs2000 and rtl2830 - two new DVB drivers: az6007 and rtl28xxu - a framework for ISA drivers, that removed lots of common code found at the ISA radio drivers - a new FM transmitter driver (radio-keene) - a GPIO-based IR receiver driver - a new sensor driver: mt9m032 - some new video drivers: adv7183, blackfin, mx2_emmaprp, sii9234_drv, vs6624 - several new board additions, driver fixes, improvements and cleanups. * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (295 commits) [media] update CARDLIST.em28xx [media] partially reverts changeset fa5527c [media] stb0899: fix the limits for signal strength values [media] em28xx: support for 2304:0242 PCTV QuatroStick (510e) [media] em28xx: support for 2013:0251 PCTV QuatroStick nano (520e) [media] -EINVAL -> -ENOTTY [media] gspca - sn9c20x: Cleanup source [media] gspca - sn9c20x: Simplify register write for capture start/stop [media] gspca - sn9c20x: Add automatic JPEG compression mechanism [media] gspca - sn9c20x: Greater delay in case of sensor no response [media] gspca - sn9c20x: Optimize the code of write sequences [media] gspca - sn9c20x: Add the JPEG compression quality control [media] gspca - sn9c20x: Add a delay after Omnivision sensor reset [media] gspca - sn9c20x: Propagate USB errors to higher level [media] gspca - sn9c20x: Use the new video control mechanism [media] gspca - sn9c20x: Fix loss of frame start [media] gspca - zc3xx: Lack of register 08 value for sensor cs2102k [media] gspca - ov534_9: Add brightness to OmniVision 5621 sensor [media] gspca - zc3xx: Add V4L2_CID_JPEG_COMPRESSION_QUALITY control support [media] pvrusb2: fix 7MHz & 8MHz DVB-T tuner support for HVR1900 rev D1F5 ...
Diffstat (limited to 'drivers/media/radio/radio-sf16fmr2.c')
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c61
1 files changed, 54 insertions, 7 deletions
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 7ab9afadf29b..7c69214334bf 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -9,16 +9,23 @@
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/module.h> /* Modules */ 10#include <linux/module.h> /* Modules */
11#include <linux/init.h> /* Initdata */ 11#include <linux/init.h> /* Initdata */
12#include <linux/slab.h>
12#include <linux/ioport.h> /* request_region */ 13#include <linux/ioport.h> /* request_region */
13#include <linux/io.h> /* outb, outb_p */ 14#include <linux/io.h> /* outb, outb_p */
15#include <linux/isa.h>
14#include <sound/tea575x-tuner.h> 16#include <sound/tea575x-tuner.h>
15 17
16MODULE_AUTHOR("Ondrej Zary"); 18MODULE_AUTHOR("Ondrej Zary");
17MODULE_DESCRIPTION("MediaForte SF16-FMR2 FM radio card driver"); 19MODULE_DESCRIPTION("MediaForte SF16-FMR2 FM radio card driver");
18MODULE_LICENSE("GPL"); 20MODULE_LICENSE("GPL");
19 21
22static int radio_nr = -1;
23module_param(radio_nr, int, 0444);
24MODULE_PARM_DESC(radio_nr, "Radio device number");
25
20struct fmr2 { 26struct fmr2 {
21 int io; 27 int io;
28 struct v4l2_device v4l2_dev;
22 struct snd_tea575x tea; 29 struct snd_tea575x tea;
23 struct v4l2_ctrl *volume; 30 struct v4l2_ctrl *volume;
24 struct v4l2_ctrl *balance; 31 struct v4l2_ctrl *balance;
@@ -26,7 +33,6 @@ struct fmr2 {
26 33
27/* the port is hardwired so no need to support multiple cards */ 34/* the port is hardwired so no need to support multiple cards */
28#define FMR2_PORT 0x384 35#define FMR2_PORT 0x384
29static struct fmr2 fmr2_card;
30 36
31/* TEA575x tuner pins */ 37/* TEA575x tuner pins */
32#define STR_DATA (1 << 0) 38#define STR_DATA (1 << 0)
@@ -180,26 +186,46 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
180 return 0; 186 return 0;
181} 187}
182 188
183static int __init fmr2_init(void) 189static int __devinit fmr2_probe(struct device *pdev, unsigned int dev)
184{ 190{
185 struct fmr2 *fmr2 = &fmr2_card; 191 struct fmr2 *fmr2;
192 int err;
193
194 fmr2 = kzalloc(sizeof(*fmr2), GFP_KERNEL);
195 if (fmr2 == NULL)
196 return -ENOMEM;
186 197
198 strlcpy(fmr2->v4l2_dev.name, dev_name(pdev),
199 sizeof(fmr2->v4l2_dev.name));
187 fmr2->io = FMR2_PORT; 200 fmr2->io = FMR2_PORT;
188 201
189 if (!request_region(fmr2->io, 2, "SF16-FMR2")) { 202 if (!request_region(fmr2->io, 2, fmr2->v4l2_dev.name)) {
190 printk(KERN_ERR "radio-sf16fmr2: I/O port 0x%x already in use\n", fmr2->io); 203 printk(KERN_ERR "radio-sf16fmr2: I/O port 0x%x already in use\n", fmr2->io);
204 kfree(fmr2);
191 return -EBUSY; 205 return -EBUSY;
192 } 206 }
193 207
208 dev_set_drvdata(pdev, fmr2);
209 err = v4l2_device_register(pdev, &fmr2->v4l2_dev);
210 if (err < 0) {
211 v4l2_err(&fmr2->v4l2_dev, "Could not register v4l2_device\n");
212 release_region(fmr2->io, 2);
213 kfree(fmr2);
214 return err;
215 }
216 fmr2->tea.v4l2_dev = &fmr2->v4l2_dev;
194 fmr2->tea.private_data = fmr2; 217 fmr2->tea.private_data = fmr2;
218 fmr2->tea.radio_nr = radio_nr;
195 fmr2->tea.ops = &fmr2_tea_ops; 219 fmr2->tea.ops = &fmr2_tea_ops;
196 fmr2->tea.ext_init = fmr2_tea_ext_init; 220 fmr2->tea.ext_init = fmr2_tea_ext_init;
197 strlcpy(fmr2->tea.card, "SF16-FMR2", sizeof(fmr2->tea.card)); 221 strlcpy(fmr2->tea.card, "SF16-FMR2", sizeof(fmr2->tea.card));
198 strcpy(fmr2->tea.bus_info, "ISA"); 222 snprintf(fmr2->tea.bus_info, sizeof(fmr2->tea.bus_info), "ISA:%s",
223 fmr2->v4l2_dev.name);
199 224
200 if (snd_tea575x_init(&fmr2->tea)) { 225 if (snd_tea575x_init(&fmr2->tea)) {
201 printk(KERN_ERR "radio-sf16fmr2: Unable to detect TEA575x tuner\n"); 226 printk(KERN_ERR "radio-sf16fmr2: Unable to detect TEA575x tuner\n");
202 release_region(fmr2->io, 2); 227 release_region(fmr2->io, 2);
228 kfree(fmr2);
203 return -ENODEV; 229 return -ENODEV;
204 } 230 }
205 231
@@ -207,12 +233,33 @@ static int __init fmr2_init(void)
207 return 0; 233 return 0;
208} 234}
209 235
210static void __exit fmr2_exit(void) 236static int __exit fmr2_remove(struct device *pdev, unsigned int dev)
211{ 237{
212 struct fmr2 *fmr2 = &fmr2_card; 238 struct fmr2 *fmr2 = dev_get_drvdata(pdev);
213 239
214 snd_tea575x_exit(&fmr2->tea); 240 snd_tea575x_exit(&fmr2->tea);
215 release_region(fmr2->io, 2); 241 release_region(fmr2->io, 2);
242 v4l2_device_unregister(&fmr2->v4l2_dev);
243 kfree(fmr2);
244 return 0;
245}
246
247struct isa_driver fmr2_driver = {
248 .probe = fmr2_probe,
249 .remove = fmr2_remove,
250 .driver = {
251 .name = "radio-sf16fmr2",
252 },
253};
254
255static int __init fmr2_init(void)
256{
257 return isa_register_driver(&fmr2_driver, 1);
258}
259
260static void __exit fmr2_exit(void)
261{
262 isa_unregister_driver(&fmr2_driver);
216} 263}
217 264
218module_init(fmr2_init); 265module_init(fmr2_init);