diff options
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/video/bt8xx/bttv-driver.c | 35 | ||||
-rw-r--r-- | linux/drivers/media/video/pwc/pwc-if.c | 12 | ||||
-rw-r--r-- | linux/drivers/media/video/pwc/pwc.h | 8 | ||||
-rw-r--r-- | linux/drivers/media/video/vivi.c | 21 |
4 files changed, 57 insertions, 19 deletions
diff --git a/linux/drivers/media/video/bt8xx/bttv-driver.c b/linux/drivers/media/video/bt8xx/bttv-driver.c index 73c080c09..94dc7f867 100644 --- a/linux/drivers/media/video/bt8xx/bttv-driver.c +++ b/linux/drivers/media/video/bt8xx/bttv-driver.c @@ -1376,7 +1376,7 @@ set_tvnorm(struct bttv *btv, unsigned int norm) /* Call with btv->lock down. */ static void -set_input(struct bttv *btv, unsigned int input) +set_input(struct bttv *btv, unsigned int input, unsigned int norm) { unsigned long flags; @@ -1395,7 +1395,7 @@ set_input(struct bttv *btv, unsigned int input) } audio_input(btv,(input == bttv_tvcards[btv->c.type].tuner ? TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN)); - set_tvnorm(btv,btv->tvnorm); + set_tvnorm(btv, norm); i2c_vidiocschan(btv); } @@ -1486,7 +1486,7 @@ static void bttv_reinit_bt848(struct bttv *btv) init_bt848(btv); btv->pll.pll_current = -1; - set_input(btv,btv->input); + set_input(btv, btv->input, btv->tvnorm); } static int get_control(struct bttv *btv, struct v4l2_control *c) @@ -2056,8 +2056,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) return 0; } - btv->tvnorm = v->norm; - set_input(btv,v->channel); + set_input(btv, v->channel, v->norm); mutex_unlock(&btv->lock); return 0; } @@ -2193,7 +2192,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) if (*i > bttv_tvcards[btv->c.type].video_inputs) return -EINVAL; mutex_lock(&btv->lock); - set_input(btv,*i); + set_input(btv, *i, btv->tvnorm); mutex_unlock(&btv->lock); return 0; } @@ -2297,6 +2296,24 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) printk(KERN_INFO "bttv%d: ================== END STATUS CARD #%d ==================\n", btv->c.nr, btv->c.nr); return 0; } +#ifdef CONFIG_VIDEO_ADV_DEBUG + case VIDIOC_DBG_G_REGISTER: + case VIDIOC_DBG_S_REGISTER: + { + struct v4l2_register *reg = arg; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) + return -EINVAL; + /* bt848 has a 12-bit register space */ + reg->reg &= 0xfff; + if (cmd == VIDIOC_DBG_G_REGISTER) + reg->val = btread(reg->reg); + else + btwrite(reg->val, reg->reg); + return 0; + } +#endif default: return -ENOIOCTLCMD; @@ -3607,6 +3624,8 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, case VIDIOC_G_FREQUENCY: case VIDIOC_S_FREQUENCY: case VIDIOC_LOG_STATUS: + case VIDIOC_DBG_G_REGISTER: + case VIDIOC_DBG_S_REGISTER: return bttv_common_ioctls(btv,cmd,arg); default: @@ -3991,6 +4010,8 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, case VIDIOCGAUDIO: case VIDIOCSAUDIO: case VIDIOC_LOG_STATUS: + case VIDIOC_DBG_G_REGISTER: + case VIDIOC_DBG_S_REGISTER: return bttv_common_ioctls(btv,cmd,arg); default: @@ -4841,7 +4862,7 @@ static int __devinit bttv_probe(struct pci_dev *dev, bt848_hue(btv,32768); bt848_sat(btv,32768); audio_mute(btv, 1); - set_input(btv,0); + set_input(btv, 0, btv->tvnorm); bttv_crop_reset(&btv->crop[0], btv->tvnorm); btv->crop[1] = btv->crop[0]; /* current = default */ disclaim_vbi_lines(btv); diff --git a/linux/drivers/media/video/pwc/pwc-if.c b/linux/drivers/media/video/pwc/pwc-if.c index 282ec2153..5e1755ecf 100644 --- a/linux/drivers/media/video/pwc/pwc-if.c +++ b/linux/drivers/media/video/pwc/pwc-if.c @@ -1136,7 +1136,7 @@ static int pwc_video_open(struct inode *inode, struct file *file) return -EBUSY; } - down(&pdev->modlock); + mutex_lock(&pdev->modlock); if (!pdev->usb_init) { PWC_DEBUG_OPEN("Doing first time initialization.\n"); pdev->usb_init = 1; @@ -1168,7 +1168,7 @@ static int pwc_video_open(struct inode *inode, struct file *file) if (i < 0) { PWC_DEBUG_OPEN("Failed to allocate buffers memory.\n"); pwc_free_buffers(pdev); - up(&pdev->modlock); + mutex_unlock(&pdev->modlock); return i; } @@ -1209,7 +1209,7 @@ static int pwc_video_open(struct inode *inode, struct file *file) if (i) { PWC_DEBUG_OPEN("Second attempt at set_video_mode failed.\n"); pwc_free_buffers(pdev); - up(&pdev->modlock); + mutex_unlock(&pdev->modlock); return i; } @@ -1218,7 +1218,7 @@ static int pwc_video_open(struct inode *inode, struct file *file) PWC_DEBUG_OPEN("Failed to init ISOC stuff = %d.\n", i); pwc_isoc_cleanup(pdev); pwc_free_buffers(pdev); - up(&pdev->modlock); + mutex_unlock(&pdev->modlock); return i; } @@ -1228,7 +1228,7 @@ static int pwc_video_open(struct inode *inode, struct file *file) pdev->vopen++; file->private_data = vdev; - up(&pdev->modlock); + mutex_unlock(&pdev->modlock); PWC_DEBUG_OPEN("<< video_open() returns 0.\n"); return 0; } @@ -1733,7 +1733,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id pdev->angle_range.tilt_max = 2500; } - init_MUTEX(&pdev->modlock); + mutex_init(&pdev->modlock); spin_lock_init(&pdev->ptrlock); pdev->udev = udev; diff --git a/linux/drivers/media/video/pwc/pwc.h b/linux/drivers/media/video/pwc/pwc.h index acbb93129..0c77c3019 100644 --- a/linux/drivers/media/video/pwc/pwc.h +++ b/linux/drivers/media/video/pwc/pwc.h @@ -31,7 +31,11 @@ #include <linux/wait.h> #include <linux/smp_lock.h> #include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include <linux/mutex.h> +#else #include <asm/semaphore.h> +#endif #include <asm/errno.h> #include <linux/videodev.h> #include <media/v4l2-common.h> @@ -244,7 +248,11 @@ struct pwc_device int image_read_pos; /* In case we read data in pieces, keep track of were we are in the imagebuffer */ int image_used[MAX_IMAGES]; /* For MCAPTURE and SYNC */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex modlock; /* to prevent races in video_open(), etc */ +#else struct semaphore modlock; /* to prevent races in video_open(), etc */ +#endif spinlock_t ptrlock; /* for manipulating the buffer pointers */ /*** motorized pan/tilt feature */ diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c index 0cea7c28b..bd418e590 100644 --- a/linux/drivers/media/video/vivi.c +++ b/linux/drivers/media/video/vivi.c @@ -25,6 +25,11 @@ #include <linux/pci.h> #include <linux/random.h> #include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include <linux/mutex.h> +#else +#include <asm/semaphore.h> +#endif #include "compat.h" #include <linux/videodev2.h> #include <linux/dma-mapping.h> @@ -177,7 +182,11 @@ static LIST_HEAD(vivi_devlist); struct vivi_dev { struct list_head vivi_devlist; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex lock; +#else struct semaphore lock; +#endif int users; @@ -970,16 +979,16 @@ static struct videobuf_queue_ops vivi_video_qops = { static int res_get(struct vivi_dev *dev, struct vivi_fh *fh) { /* is it free? */ - down(&dev->lock); + mutex_lock(&dev->lock); if (dev->resources) { /* no, someone else uses it */ - up(&dev->lock); + mutex_unlock(&dev->lock); return 0; } /* it's free, grab it */ dev->resources =1; dprintk(1,"res: get\n"); - up(&dev->lock); + mutex_unlock(&dev->lock); return 1; } @@ -990,10 +999,10 @@ static int res_locked(struct vivi_dev *dev) static void res_free(struct vivi_dev *dev, struct vivi_fh *fh) { - down(&dev->lock); + mutex_lock(&dev->lock); dev->resources = 0; dprintk(1,"res: put\n"); - up(&dev->lock); + mutex_lock(&dev->lock); } /* ------------------------------------------------------------------ @@ -1506,7 +1515,7 @@ static int __init vivi_init(void) init_waitqueue_head(&dev->vidq.wq); /* initialize locks */ - init_MUTEX(&dev->lock); + mutex_init(&dev->lock); dev->vidq.timeout.function = vivi_vid_timeout; dev->vidq.timeout.data = (unsigned long)dev; |