V4L/DVB (11282): saa7134: add RDS support.
authorHans Verkuil <hverkuil@xs4all.nl>
Sun, 29 Mar 2009 09:26:27 +0000 (06:26 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:43:47 +0000 (12:43 -0300)
The Terratec Cinergy 600 TV MK3 supports the RDS decoder saa6588.
Add support to saa7134 for such devices.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/saa7134/Kconfig
drivers/media/video/saa7134/saa7134-cards.c
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-video.c
drivers/media/video/saa7134/saa7134.h

index a2089ac..0ba6898 100644 (file)
@@ -6,6 +6,7 @@ config VIDEO_SAA7134
        select VIDEO_TUNER
        select VIDEO_TVEEPROM
        select CRC32
+       select VIDEO_SAA6588 if VIDEO_HELPER_CHIPS_AUTO
        ---help---
          This is a video4linux driver for Philips SAA713x based
          TV cards.
index 3a03813..a790a72 100644 (file)
@@ -1704,6 +1704,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
+               .rds_addr       = 0x10,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
                        .name = name_tv,
index 4c24c9c..dafa0d8 100644 (file)
@@ -990,6 +990,17 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
                        sd->grp_id = GRP_EMPRESS;
        }
 
+       if (saa7134_boards[dev->board].rds_addr) {
+               unsigned short addrs[2] = { 0, I2C_CLIENT_END };
+               struct v4l2_subdev *sd;
+
+               addrs[0] = saa7134_boards[dev->board].rds_addr;
+               sd = v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "saa6588",
+                           "saa6588", addrs);
+               if (sd)
+                       printk(KERN_INFO "%s: found RDS decoder\n", dev->name);
+       }
+
        request_submodules(dev);
 
        v4l2_prio_init(&dev->prio);
index 6a4ae89..404f70e 100644 (file)
@@ -30,6 +30,7 @@
 #include "saa7134-reg.h"
 #include "saa7134.h"
 #include <media/v4l2-common.h>
+#include <media/rds.h>
 
 /* ------------------------------------------------------------------ */
 
@@ -1462,6 +1463,7 @@ static int video_release(struct file *file)
 {
        struct saa7134_fh  *fh  = file->private_data;
        struct saa7134_dev *dev = fh->dev;
+       struct rds_command cmd;
        unsigned long flags;
 
        /* turn off overlay */
@@ -1495,6 +1497,8 @@ static int video_release(struct file *file)
        saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0);
 
        saa_call_all(dev, core, s_standby, 0);
+       if (fh->radio)
+               saa_call_all(dev, core, ioctl, RDS_CMD_CLOSE, &cmd);
 
        /* free stuff */
        videobuf_mmap_free(&fh->cap);
@@ -1515,6 +1519,37 @@ static int video_mmap(struct file *file, struct vm_area_struct * vma)
        return videobuf_mmap_mapper(saa7134_queue(fh), vma);
 }
 
+static ssize_t radio_read(struct file *file, char __user *data,
+                        size_t count, loff_t *ppos)
+{
+       struct saa7134_fh *fh = file->private_data;
+       struct saa7134_dev *dev = fh->dev;
+       struct rds_command cmd;
+
+       cmd.block_count = count/3;
+       cmd.buffer = data;
+       cmd.instance = file;
+       cmd.result = -ENODEV;
+
+       saa_call_all(dev, core, ioctl, RDS_CMD_READ, &cmd);
+
+       return cmd.result;
+}
+
+static unsigned int radio_poll(struct file *file, poll_table *wait)
+{
+       struct saa7134_fh *fh = file->private_data;
+       struct saa7134_dev *dev = fh->dev;
+       struct rds_command cmd;
+
+       cmd.instance = file;
+       cmd.event_list = wait;
+       cmd.result = -ENODEV;
+       saa_call_all(dev, core, ioctl, RDS_CMD_POLL, &cmd);
+
+       return cmd.result;
+}
+
 /* ------------------------------------------------------------------ */
 
 static int saa7134_try_get_set_fmt_vbi_cap(struct file *file, void *priv,
@@ -2439,8 +2474,10 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 static const struct v4l2_file_operations radio_fops = {
        .owner    = THIS_MODULE,
        .open     = video_open,
+       .read     = radio_read,
        .release  = video_release,
        .ioctl    = video_ioctl2,
+       .poll     = radio_poll,
 };
 
 static const struct v4l2_ioctl_ops radio_ioctl_ops = {
index 1139668..a2dd326 100644 (file)
@@ -333,6 +333,7 @@ struct saa7134_board {
        unsigned char           tuner_addr;
        unsigned char           radio_addr;
        unsigned char           empress_addr;
+       unsigned char           rds_addr;
 
        unsigned int            tda9887_conf;
        unsigned int            tuner_config;