Skip to content

Commit

Permalink
[media] tea575x-tuner: update to latest V4L2 framework requirements
Browse files Browse the repository at this point in the history
The tea575x-tuner module has been updated to use the latest V4L2 framework
functionality. This also required changes in the drivers that rely on it.

The tea575x changes are:

- The drivers must provide a v4l2_device struct to the tea module.
- The radio_nr module parameter must be part of the actual radio driver,
  and not of the tea module.
- Changed the frequency range to the normal 76-108 MHz range instead of
  50-150.
- Add hardware frequency seek support.
- Fix broken rxsubchans/audmode handling.
- The application can now select between stereo and mono.
- Support polling for control events.
- Add V4L2 priority handling.

And radio-sf16fmr2.c now uses the isa bus kernel framework.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Thanks-to: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 19, 2012
1 parent 9f1dfcc commit d4ecc83
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 76 deletions.
61 changes: 54 additions & 7 deletions drivers/media/radio/radio-sf16fmr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,30 @@
#include <linux/delay.h>
#include <linux/module.h> /* Modules */
#include <linux/init.h> /* Initdata */
#include <linux/slab.h>
#include <linux/ioport.h> /* request_region */
#include <linux/io.h> /* outb, outb_p */
#include <linux/isa.h>
#include <sound/tea575x-tuner.h>

MODULE_AUTHOR("Ondrej Zary");
MODULE_DESCRIPTION("MediaForte SF16-FMR2 FM radio card driver");
MODULE_LICENSE("GPL");

static int radio_nr = -1;
module_param(radio_nr, int, 0444);
MODULE_PARM_DESC(radio_nr, "Radio device number");

struct fmr2 {
int io;
struct v4l2_device v4l2_dev;
struct snd_tea575x tea;
struct v4l2_ctrl *volume;
struct v4l2_ctrl *balance;
};

/* the port is hardwired so no need to support multiple cards */
#define FMR2_PORT 0x384
static struct fmr2 fmr2_card;

/* TEA575x tuner pins */
#define STR_DATA (1 << 0)
Expand Down Expand Up @@ -180,39 +186,80 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
return 0;
}

static int __init fmr2_init(void)
static int __init fmr2_probe(struct device *pdev, unsigned int dev)
{
struct fmr2 *fmr2 = &fmr2_card;
struct fmr2 *fmr2;
int err;

fmr2 = kzalloc(sizeof(*fmr2), GFP_KERNEL);
if (fmr2 == NULL)
return -ENOMEM;

strlcpy(fmr2->v4l2_dev.name, dev_name(pdev),
sizeof(fmr2->v4l2_dev.name));
fmr2->io = FMR2_PORT;

if (!request_region(fmr2->io, 2, "SF16-FMR2")) {
if (!request_region(fmr2->io, 2, fmr2->v4l2_dev.name)) {
printk(KERN_ERR "radio-sf16fmr2: I/O port 0x%x already in use\n", fmr2->io);
kfree(fmr2);
return -EBUSY;
}

dev_set_drvdata(pdev, fmr2);
err = v4l2_device_register(pdev, &fmr2->v4l2_dev);
if (err < 0) {
v4l2_err(&fmr2->v4l2_dev, "Could not register v4l2_device\n");
release_region(fmr2->io, 2);
kfree(fmr2);
return err;
}
fmr2->tea.v4l2_dev = &fmr2->v4l2_dev;
fmr2->tea.private_data = fmr2;
fmr2->tea.radio_nr = radio_nr;
fmr2->tea.ops = &fmr2_tea_ops;
fmr2->tea.ext_init = fmr2_tea_ext_init;
strlcpy(fmr2->tea.card, "SF16-FMR2", sizeof(fmr2->tea.card));
strcpy(fmr2->tea.bus_info, "ISA");
snprintf(fmr2->tea.bus_info, sizeof(fmr2->tea.bus_info), "ISA:%s",
fmr2->v4l2_dev.name);

if (snd_tea575x_init(&fmr2->tea)) {
printk(KERN_ERR "radio-sf16fmr2: Unable to detect TEA575x tuner\n");
release_region(fmr2->io, 2);
kfree(fmr2);
return -ENODEV;
}

printk(KERN_INFO "radio-sf16fmr2: SF16-FMR2 radio card at 0x%x.\n", fmr2->io);
return 0;
}

static void __exit fmr2_exit(void)
static int __exit fmr2_remove(struct device *pdev, unsigned int dev)
{
struct fmr2 *fmr2 = &fmr2_card;
struct fmr2 *fmr2 = dev_get_drvdata(pdev);

snd_tea575x_exit(&fmr2->tea);
release_region(fmr2->io, 2);
v4l2_device_unregister(&fmr2->v4l2_dev);
kfree(fmr2);
return 0;
}

struct isa_driver fmr2_driver = {
.probe = fmr2_probe,
.remove = fmr2_remove,
.driver = {
.name = "radio-sf16fmr2",
},
};

static int __init fmr2_init(void)
{
return isa_register_driver(&fmr2_driver, 1);
}

static void __exit fmr2_exit(void)
{
isa_unregister_driver(&fmr2_driver);
}

module_init(fmr2_init);
Expand Down
6 changes: 5 additions & 1 deletion include/sound/tea575x-tuner.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/videodev2.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>

#define TEA575X_FMIF 10700

Expand All @@ -42,13 +43,16 @@ struct snd_tea575x_ops {
};

struct snd_tea575x {
struct v4l2_device *v4l2_dev;
struct video_device vd; /* video device */
int radio_nr; /* radio_nr */
bool tea5759; /* 5759 chip is present */
bool cannot_read_data; /* Device cannot read the data pin */
bool mute; /* Device is muted? */
bool stereo; /* receiving stereo */
bool tuned; /* tuned to a station */
unsigned int val; /* hw value */
unsigned long freq; /* frequency */
u32 freq; /* frequency */
struct mutex mutex;
struct snd_tea575x_ops *ops;
void *private_data;
Expand Down
Loading

0 comments on commit d4ecc83

Please sign in to comment.