aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/bt8xx/bttv-driver.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-04-14 07:11:02 -0400
committerPaul Mackerras <paulus@samba.org>2008-04-14 07:11:02 -0400
commitac7c5353b189e10cf5dd27399f64f7b013abffc6 (patch)
tree8222d92b774c256d6ec4399c716d76b3f05ddc4b /drivers/media/video/bt8xx/bttv-driver.c
parenta8f75ea70c58546205fb7673be41455b9da5d9a7 (diff)
parent120dd64cacd4fb796bca0acba3665553f1d9ecaa (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/media/video/bt8xx/bttv-driver.c')
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index a080c149cc6c..fcf8f2d208a8 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -1990,7 +1990,7 @@ static int bttv_g_frequency(struct file *file, void *priv,
1990 if (0 != err) 1990 if (0 != err)
1991 return err; 1991 return err;
1992 1992
1993 f->type = V4L2_TUNER_ANALOG_TV; 1993 f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1994 f->frequency = btv->freq; 1994 f->frequency = btv->freq;
1995 1995
1996 return 0; 1996 return 0;
@@ -2009,7 +2009,8 @@ static int bttv_s_frequency(struct file *file, void *priv,
2009 2009
2010 if (unlikely(f->tuner != 0)) 2010 if (unlikely(f->tuner != 0))
2011 return -EINVAL; 2011 return -EINVAL;
2012 if (unlikely(f->type != V4L2_TUNER_ANALOG_TV)) 2012 if (unlikely(f->type != (btv->radio_user
2013 ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV)))
2013 return -EINVAL; 2014 return -EINVAL;
2014 mutex_lock(&btv->lock); 2015 mutex_lock(&btv->lock);
2015 btv->freq = f->frequency; 2016 btv->freq = f->frequency;
@@ -3415,6 +3416,7 @@ static int radio_open(struct inode *inode, struct file *file)
3415{ 3416{
3416 int minor = iminor(inode); 3417 int minor = iminor(inode);
3417 struct bttv *btv = NULL; 3418 struct bttv *btv = NULL;
3419 struct bttv_fh *fh;
3418 unsigned int i; 3420 unsigned int i;
3419 3421
3420 dprintk("bttv: open minor=%d\n",minor); 3422 dprintk("bttv: open minor=%d\n",minor);
@@ -3429,12 +3431,19 @@ static int radio_open(struct inode *inode, struct file *file)
3429 return -ENODEV; 3431 return -ENODEV;
3430 3432
3431 dprintk("bttv%d: open called (radio)\n",btv->c.nr); 3433 dprintk("bttv%d: open called (radio)\n",btv->c.nr);
3434
3435 /* allocate per filehandle data */
3436 fh = kmalloc(sizeof(*fh), GFP_KERNEL);
3437 if (NULL == fh)
3438 return -ENOMEM;
3439 file->private_data = fh;
3440 *fh = btv->init;
3441 v4l2_prio_open(&btv->prio, &fh->prio);
3442
3432 mutex_lock(&btv->lock); 3443 mutex_lock(&btv->lock);
3433 3444
3434 btv->radio_user++; 3445 btv->radio_user++;
3435 3446
3436 file->private_data = btv;
3437
3438 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL); 3447 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL);
3439 audio_input(btv,TVAUDIO_INPUT_RADIO); 3448 audio_input(btv,TVAUDIO_INPUT_RADIO);
3440 3449
@@ -3444,7 +3453,8 @@ static int radio_open(struct inode *inode, struct file *file)
3444 3453
3445static int radio_release(struct inode *inode, struct file *file) 3454static int radio_release(struct inode *inode, struct file *file)
3446{ 3455{
3447 struct bttv *btv = file->private_data; 3456 struct bttv_fh *fh = file->private_data;
3457 struct bttv *btv = fh->btv;
3448 struct rds_command cmd; 3458 struct rds_command cmd;
3449 3459
3450 btv->radio_user--; 3460 btv->radio_user--;
@@ -3508,8 +3518,12 @@ static int radio_enum_input(struct file *file, void *priv,
3508static int radio_g_audio(struct file *file, void *priv, 3518static int radio_g_audio(struct file *file, void *priv,
3509 struct v4l2_audio *a) 3519 struct v4l2_audio *a)
3510{ 3520{
3521 if (a->index != 0)
3522 return -EINVAL;
3523
3511 memset(a, 0, sizeof(*a)); 3524 memset(a, 0, sizeof(*a));
3512 strcpy(a->name, "Radio"); 3525 strcpy(a->name, "Radio");
3526
3513 return 0; 3527 return 0;
3514} 3528}
3515 3529
@@ -3569,7 +3583,8 @@ static int radio_g_input(struct file *filp, void *priv, unsigned int *i)
3569static ssize_t radio_read(struct file *file, char __user *data, 3583static ssize_t radio_read(struct file *file, char __user *data,
3570 size_t count, loff_t *ppos) 3584 size_t count, loff_t *ppos)
3571{ 3585{
3572 struct bttv *btv = file->private_data; 3586 struct bttv_fh *fh = file->private_data;
3587 struct bttv *btv = fh->btv;
3573 struct rds_command cmd; 3588 struct rds_command cmd;
3574 cmd.block_count = count/3; 3589 cmd.block_count = count/3;
3575 cmd.buffer = data; 3590 cmd.buffer = data;
@@ -3583,7 +3598,8 @@ static ssize_t radio_read(struct file *file, char __user *data,
3583 3598
3584static unsigned int radio_poll(struct file *file, poll_table *wait) 3599static unsigned int radio_poll(struct file *file, poll_table *wait)
3585{ 3600{
3586 struct bttv *btv = file->private_data; 3601 struct bttv_fh *fh = file->private_data;
3602 struct bttv *btv = fh->btv;
3587 struct rds_command cmd; 3603 struct rds_command cmd;
3588 cmd.instance = file; 3604 cmd.instance = file;
3589 cmd.event_list = wait; 3605 cmd.event_list = wait;
@@ -3599,6 +3615,7 @@ static const struct file_operations radio_fops =
3599 .open = radio_open, 3615 .open = radio_open,
3600 .read = radio_read, 3616 .read = radio_read,
3601 .release = radio_release, 3617 .release = radio_release,
3618 .compat_ioctl = v4l_compat_ioctl32,
3602 .ioctl = video_ioctl2, 3619 .ioctl = video_ioctl2,
3603 .llseek = no_llseek, 3620 .llseek = no_llseek,
3604 .poll = radio_poll, 3621 .poll = radio_poll,