summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-03-13 13:45:51 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-03-13 13:45:51 -0300
commit619f7ef871542e60ea54401cb52dda1b6679cfb9 (patch)
tree7cbe64d7995c02e309f96ed5cd01a98f5f53b29d /linux/drivers/media/video
parent3e244cec9e4cc19caff52ac59ff3535a1b5f9212 (diff)
parent8a7a0ee25a1986aafc124cb0b77f61b219f4d505 (diff)
downloadmediapointer-dvb-s2-619f7ef871542e60ea54401cb52dda1b6679cfb9.tar.gz
mediapointer-dvb-s2-619f7ef871542e60ea54401cb52dda1b6679cfb9.tar.bz2
merge: http://linuxtv.org/hg/~hverkuil/v4l-dvb
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video')
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-driver.c86
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-driver.h2
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-fileops.c3
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-ioctl.c310
-rw-r--r--linux/drivers/media/video/msp3400-driver.c22
-rw-r--r--linux/drivers/media/video/saa7115.c1
-rw-r--r--linux/drivers/media/video/tuner-core.c18
7 files changed, 245 insertions, 197 deletions
diff --git a/linux/drivers/media/video/ivtv/ivtv-driver.c b/linux/drivers/media/video/ivtv/ivtv-driver.c
index adfc8a869..2fcf3e7c3 100644
--- a/linux/drivers/media/video/ivtv/ivtv-driver.c
+++ b/linux/drivers/media/video/ivtv/ivtv-driver.c
@@ -625,8 +625,8 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv)
mutex_init(&itv->i2c_bus_lock);
mutex_init(&itv->udma.lock);
- itv->lock = SPIN_LOCK_UNLOCKED;
- itv->dma_reg_lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&itv->lock);
+ spin_lock_init(&itv->dma_reg_lock);
itv->irq_work_queues = create_workqueue(itv->name);
if (itv->irq_work_queues == NULL) {
@@ -1138,46 +1138,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
if (itv->options.radio > 0)
itv->v4l2_cap |= V4L2_CAP_RADIO;
- retval = ivtv_streams_setup(itv);
- if (retval) {
- IVTV_ERR("Error %d setting up streams\n", retval);
- goto free_i2c;
- }
-
- /* Start Threads */
- IVTV_DEBUG_INFO("Starting Threads\n");
-
- /* Decoder Thread */
- if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
- ivtv_init_mpeg_decoder(itv);
- }
-
- IVTV_DEBUG_IRQ("Masking interrupts\n");
- /* clear interrupt mask, effectively disabling interrupts */
- ivtv_set_irq_mask(itv, 0xffffffff);
-
- /* Register IRQ */
- retval = request_irq(itv->dev->irq, ivtv_irq_handler,
- IRQF_SHARED | IRQF_DISABLED, itv->name, (void *)itv);
- if (retval) {
- IVTV_ERR("Failed to register irq %d\n", retval);
- goto free_streams;
- }
-
- /* On a cx23416 this seems to be able to enable DMA to the chip? */
- if (!itv->has_cx23415)
- write_reg_sync(0x03, IVTV_REG_DMACONTROL);
-
- /* Default interrupts enabled. For the PVR350 this includes the
- decoder VSYNC interrupt, which is always on. It is not only used
- during decoding but also by the OSD.
- Some old PVR250 cards had a cx23415, so testing for that is too
- general. Instead test if the card has video output capability. */
- if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
- ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC);
- else
- ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT);
-
if (itv->options.tuner > -1) {
struct tuner_setup setup;
@@ -1216,6 +1176,43 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
itv->std_out = itv->std;
ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_STD, &itv->tuner_std);
ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_FREQUENCY, &vf);
+
+ retval = ivtv_streams_setup(itv);
+ if (retval) {
+ IVTV_ERR("Error %d setting up streams\n", retval);
+ goto free_i2c;
+ }
+
+ if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
+ ivtv_init_mpeg_decoder(itv);
+ }
+
+ IVTV_DEBUG_IRQ("Masking interrupts\n");
+ /* clear interrupt mask, effectively disabling interrupts */
+ ivtv_set_irq_mask(itv, 0xffffffff);
+
+ /* Register IRQ */
+ retval = request_irq(itv->dev->irq, ivtv_irq_handler,
+ IRQF_SHARED | IRQF_DISABLED, itv->name, (void *)itv);
+ if (retval) {
+ IVTV_ERR("Failed to register irq %d\n", retval);
+ goto free_streams;
+ }
+
+ /* On a cx23416 this seems to be able to enable DMA to the chip? */
+ if (!itv->has_cx23415)
+ write_reg_sync(0x03, IVTV_REG_DMACONTROL);
+
+ /* Default interrupts enabled. For the PVR350 this includes the
+ decoder VSYNC interrupt, which is always on. It is not only used
+ during decoding but also by the OSD.
+ Some old PVR250 cards had a cx23415, so testing for that is too
+ general. Instead test if the card has video output capability. */
+ if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
+ ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC);
+ else
+ ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT);
+
if (itv->has_cx23415)
ivtv_set_osd_alpha(itv);
@@ -1337,7 +1334,7 @@ static int module_start(void)
printk(KERN_INFO "ivtv: debug value must be >= 0 and <= 511!\n");
}
- if (pci_module_init(&ivtv_pci_driver)) {
+ if (pci_register_driver(&ivtv_pci_driver)) {
printk(KERN_ERR "ivtv: Error detecting PCI card\n");
return -ENODEV;
}
@@ -1349,6 +1346,8 @@ static void module_cleanup(void)
{
int i, j;
+ pci_unregister_driver(&ivtv_pci_driver);
+
for (i = 0; i < ivtv_cards_active; i++) {
if (ivtv_cards[i] == NULL)
continue;
@@ -1357,7 +1356,6 @@ static void module_cleanup(void)
}
kfree(ivtv_cards[i]);
}
- pci_unregister_driver(&ivtv_pci_driver);
}
/* Note: These symbols are exported because they are used by the ivtv-fb
diff --git a/linux/drivers/media/video/ivtv/ivtv-driver.h b/linux/drivers/media/video/ivtv/ivtv-driver.h
index cb87caa63..e84caa59b 100644
--- a/linux/drivers/media/video/ivtv/ivtv-driver.h
+++ b/linux/drivers/media/video/ivtv/ivtv-driver.h
@@ -509,6 +509,7 @@ struct ivtv_stream {
struct ivtv_open_id {
u32 open_id;
int type;
+ enum v4l2_priority prio;
struct ivtv *itv;
};
@@ -739,6 +740,7 @@ struct ivtv {
u32 base_addr;
u32 irqmask;
+ struct v4l2_prio_state prio;
struct workqueue_struct *irq_work_queues;
struct work_struct irq_work_queue;
struct timer_list dma_timer; /* Timer used to catch unfinished DMAs */
diff --git a/linux/drivers/media/video/ivtv/ivtv-fileops.c b/linux/drivers/media/video/ivtv/ivtv-fileops.c
index 2f38bb14a..1637097dd 100644
--- a/linux/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/linux/drivers/media/video/ivtv/ivtv-fileops.c
@@ -766,6 +766,8 @@ int ivtv_v4l2_close(struct inode *inode, struct file *filp)
IVTV_DEBUG_IOCTL("close() of %s\n", s->name);
+ v4l2_prio_close(&itv->prio, &id->prio);
+
/* Easy case first: this stream was never claimed by us */
if (s->id != id->open_id) {
kfree(id);
@@ -849,6 +851,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
}
item->itv = itv;
item->type = y;
+ v4l2_prio_open(&itv->prio, &item->prio);
item->open_id = itv->open_id++;
filp->private_data = item;
diff --git a/linux/drivers/media/video/ivtv/ivtv-ioctl.c b/linux/drivers/media/video/ivtv/ivtv-ioctl.c
index 8c99b8024..d6f0b0235 100644
--- a/linux/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/linux/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -277,6 +277,7 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
switch (vc->cmd) {
case VIDEO_CMD_PLAY: {
+ vc->flags = 0;
vc->play.speed = ivtv_validate_speed(itv->speed, vc->play.speed);
if (vc->play.speed < 0)
vc->play.format = VIDEO_PLAY_FMT_GOP;
@@ -288,6 +289,7 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
}
case VIDEO_CMD_STOP:
+ vc->flags &= ~(VIDEO_CMD_STOP_IMMEDIATELY|VIDEO_CMD_STOP_TO_BLACK);
if (vc->flags & VIDEO_CMD_STOP_IMMEDIATELY)
vc->stop.pts = 0;
if (try) break;
@@ -300,6 +302,7 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
return ivtv_stop_v4l2_decode_stream(s, vc->flags, vc->stop.pts);
case VIDEO_CMD_FREEZE:
+ vc->flags &= ~VIDEO_CMD_FREEZE_TO_BLACK;
if (try) break;
if (itv->output_mode != OUT_MPG)
return -EBUSY;
@@ -310,6 +313,7 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
break;
case VIDEO_CMD_CONTINUE:
+ vc->flags = 0;
if (try) break;
if (itv->output_mode != OUT_MPG)
return -EBUSY;
@@ -638,7 +642,7 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
return 0;
}
-static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg)
+static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg)
{
struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data;
struct ivtv *itv = id->itv;
@@ -647,7 +651,6 @@ static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg)
switch (cmd) {
/* ioctls to allow direct access to the encoder registers for testing */
case VIDIOC_DBG_G_REGISTER:
- IVTV_DEBUG_IOCTL("VIDIOC_DBG_G_REGISTER\n");
if (v4l2_chip_match_host(reg->match_type, reg->match_chip))
return ivtv_itvc(itv, cmd, arg);
if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
@@ -655,7 +658,6 @@ static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg)
return ivtv_call_i2c_client(itv, reg->match_chip, cmd, arg);
case VIDIOC_DBG_S_REGISTER:
- IVTV_DEBUG_IOCTL("VIDIOC_DBG_S_REGISTER\n");
if (v4l2_chip_match_host(reg->match_type, reg->match_chip))
return ivtv_itvc(itv, cmd, arg);
if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
@@ -665,7 +667,6 @@ static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg)
case VIDIOC_G_CHIP_IDENT: {
struct v4l2_chip_ident *chip = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_G_CHIP_IDENT\n");
chip->ident = V4L2_IDENT_NONE;
chip->revision = 0;
if (reg->match_type == V4L2_CHIP_MATCH_HOST) {
@@ -686,13 +687,11 @@ static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg)
case VIDIOC_INT_S_AUDIO_ROUTING: {
struct v4l2_routing *route = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_INT_S_AUDIO_ROUTING\n");
ivtv_audio_set_route(itv, route);
break;
}
case VIDIOC_INT_RESET:
- IVTV_DEBUG_IOCTL("VIDIOC_INT_RESET\n");
ivtv_reset_ir_gpio(itv);
break;
@@ -709,11 +708,24 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
if (filp) id = (struct ivtv_open_id *)filp->private_data;
switch (cmd) {
+ case VIDIOC_G_PRIORITY:
+ {
+ enum v4l2_priority *p = arg;
+
+ *p = v4l2_prio_max(&itv->prio);
+ break;
+ }
+
+ case VIDIOC_S_PRIORITY:
+ {
+ enum v4l2_priority *prio = arg;
+
+ return v4l2_prio_change(&itv->prio, &id->prio, *prio);
+ }
+
case VIDIOC_QUERYCAP:{
struct v4l2_capability *vcap = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_QUERYCAP\n");
-
memset(vcap, 0, sizeof(*vcap));
strcpy(vcap->driver, IVTV_DRIVER_NAME); /* driver name */
strcpy(vcap->card, itv->card_name); /* card type */
@@ -730,15 +742,12 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_ENUMAUDIO:{
struct v4l2_audio *vin = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_ENUMAUDIO\n");
-
return ivtv_get_audio_input(itv, vin->index, vin);
}
case VIDIOC_G_AUDIO:{
struct v4l2_audio *vin = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_G_AUDIO\n");
vin->index = itv->audio_input;
return ivtv_get_audio_input(itv, vin->index, vin);
}
@@ -746,8 +755,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_S_AUDIO:{
struct v4l2_audio *vout = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_S_AUDIO\n");
-
if (vout->index >= itv->nof_audio_inputs)
return -EINVAL;
itv->audio_input = vout->index;
@@ -758,8 +765,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_ENUMAUDOUT:{
struct v4l2_audioout *vin = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_ENUMAUDOUT\n");
-
/* set it to defaults from our table */
return ivtv_get_audio_output(itv, vin->index, vin);
}
@@ -767,7 +772,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_G_AUDOUT:{
struct v4l2_audioout *vin = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_G_AUDOUT\n");
vin->index = 0;
return ivtv_get_audio_output(itv, vin->index, vin);
}
@@ -775,16 +779,12 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_S_AUDOUT:{
struct v4l2_audioout *vout = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_S_AUDOUT\n");
-
return ivtv_get_audio_output(itv, vout->index, vout);
}
case VIDIOC_ENUMINPUT:{
struct v4l2_input *vin = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_ENUMINPUT\n");
-
/* set it to defaults from our table */
return ivtv_get_input(itv, vin->index, vin);
}
@@ -792,8 +792,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_ENUMOUTPUT:{
struct v4l2_output *vout = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_ENUMOUTPUT\n");
-
return ivtv_get_output(itv, vout->index, vout);
}
@@ -801,11 +799,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_S_FMT: {
struct v4l2_format *fmt = arg;
- if (cmd == VIDIOC_S_FMT) {
- IVTV_DEBUG_IOCTL("VIDIOC_S_FMT\n");
- } else {
- IVTV_DEBUG_IOCTL("VIDIOC_TRY_FMT\n");
- }
return ivtv_try_or_set_fmt(itv, id->type, fmt, cmd == VIDIOC_S_FMT);
}
@@ -813,7 +806,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
struct v4l2_format *fmt = arg;
int type = fmt->type;
- IVTV_DEBUG_IOCTL("VIDIOC_G_FMT\n");
memset(fmt, 0, sizeof(*fmt));
fmt->type = type;
return ivtv_get_fmt(itv, id->type, fmt);
@@ -822,7 +814,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_S_CROP: {
struct v4l2_crop *crop = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_S_CROP\n");
if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return itv->video_dec_func(itv, VIDIOC_S_CROP, arg);
@@ -831,7 +822,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_G_CROP: {
struct v4l2_crop *crop = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_G_CROP\n");
if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return itv->video_dec_func(itv, VIDIOC_G_CROP, arg);
@@ -869,8 +859,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
}
case VIDIOC_G_INPUT:{
- IVTV_DEBUG_IOCTL("VIDIOC_G_INPUT\n");
-
*(int *)arg = itv->active_input;
break;
}
@@ -878,8 +866,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_S_INPUT:{
int inp = *(int *)arg;
- IVTV_DEBUG_IOCTL("VIDIOC_S_INPUT\n");
-
if (inp < 0 || inp >= itv->nof_inputs)
return -EINVAL;
@@ -905,8 +891,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
}
case VIDIOC_G_OUTPUT:{
- IVTV_DEBUG_IOCTL("VIDIOC_G_OUTPUT\n");
-
if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
return -EINVAL;
*(int *)arg = itv->active_output;
@@ -917,8 +901,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
int outp = *(int *)arg;
struct v4l2_routing route;
- IVTV_DEBUG_IOCTL("VIDIOC_S_OUTPUT\n");
-
if (outp >= itv->card->nof_outputs)
return -EINVAL;
@@ -939,8 +921,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_G_FREQUENCY:{
struct v4l2_frequency *vf = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_G_FREQUENCY\n");
-
if (vf->tuner != 0)
return -EINVAL;
ivtv_call_i2c_clients(itv, cmd, arg);
@@ -950,8 +930,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_S_FREQUENCY:{
struct v4l2_frequency vf = *(struct v4l2_frequency *)arg;
- IVTV_DEBUG_IOCTL("VIDIOC_S_FREQUENCY\n");
-
if (vf.tuner != 0)
return -EINVAL;
@@ -966,8 +944,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
struct v4l2_standard *vs = arg;
int idx = vs->index;
- IVTV_DEBUG_IOCTL("VIDIOC_ENUMSTD\n");
-
if (idx < 0 || idx >= ARRAY_SIZE(enum_stds))
return -EINVAL;
@@ -980,7 +956,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
}
case VIDIOC_G_STD:{
- IVTV_DEBUG_IOCTL("VIDIOC_G_STD\n");
*(v4l2_std_id *) arg = itv->std;
break;
}
@@ -988,8 +963,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_S_STD: {
v4l2_std_id std = *(v4l2_std_id *) arg;
- IVTV_DEBUG_IOCTL("VIDIOC_S_STD\n");
-
if ((std & V4L2_STD_ALL) == 0)
return -EINVAL;
@@ -1040,8 +1013,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_S_TUNER: { /* Setting tuner can only set audio mode */
struct v4l2_tuner *vt = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_S_TUNER\n");
-
if (vt->index != 0)
return -EINVAL;
@@ -1052,8 +1023,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
case VIDIOC_G_TUNER: {
struct v4l2_tuner *vt = arg;
- IVTV_DEBUG_IOCTL("VIDIOC_G_TUNER\n");
-
if (vt->index != 0)
return -EINVAL;
@@ -1080,7 +1049,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
enum v4l2_buf_type type = VIDIOC_G_SLICED_VBI_CAP;
#endif
- IVTV_DEBUG_IOCTL("VIDIOC_G_SLICED_VBI_CAP\n");
memset(cap, 0, sizeof(*cap));
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
cap->type = type;
@@ -1110,6 +1078,104 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
return -EINVAL;
}
+ case VIDIOC_G_ENC_INDEX: {
+ struct v4l2_enc_idx *idx = arg;
+ int i;
+
+ idx->entries = (itv->pgm_info_write_idx + IVTV_MAX_PGM_INDEX - itv->pgm_info_read_idx) %
+ IVTV_MAX_PGM_INDEX;
+ if (idx->entries > V4L2_ENC_IDX_ENTRIES)
+ idx->entries = V4L2_ENC_IDX_ENTRIES;
+ for (i = 0; i < idx->entries; i++) {
+ idx->entry[i] = itv->pgm_info[(itv->pgm_info_read_idx + i) % IVTV_MAX_PGM_INDEX];
+ }
+ itv->pgm_info_read_idx = (itv->pgm_info_read_idx + idx->entries) % IVTV_MAX_PGM_INDEX;
+ break;
+ }
+
+ case VIDIOC_ENCODER_CMD:
+ case VIDIOC_TRY_ENCODER_CMD: {
+ struct v4l2_encoder_cmd *enc = arg;
+ int try = cmd == VIDIOC_TRY_ENCODER_CMD;
+
+ memset(&enc->raw, 0, sizeof(enc->raw));
+ switch (enc->cmd) {
+ case V4L2_ENC_CMD_START:
+ enc->flags = 0;
+ if (try)
+ return 0;
+ return ivtv_start_capture(id);
+
+ case V4L2_ENC_CMD_STOP:
+ enc->flags &= ~V4L2_ENC_CMD_STOP_AT_GOP_END;
+ if (try)
+ return 0;
+ ivtv_stop_capture(id, enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END);
+ return 0;
+
+ case V4L2_ENC_CMD_PAUSE:
+ enc->flags = 0;
+ if (try)
+ return 0;
+ if (!atomic_read(&itv->capturing))
+ return -EPERM;
+ if (test_and_set_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags))
+ return 0;
+ ivtv_mute(itv);
+ ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 0);
+ break;
+
+ case V4L2_ENC_CMD_RESUME:
+ enc->flags = 0;
+ if (try)
+ return 0;
+ if (!atomic_read(&itv->capturing))
+ return -EPERM;
+ if (!test_and_clear_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags))
+ return 0;
+ ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 1);
+ ivtv_unmute(itv);
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+
+ case VIDIOC_G_FBUF: {
+ struct v4l2_framebuffer *fb = arg;
+
+ memset(fb, 0, sizeof(*fb));
+ if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
+ break;
+ fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY |
+ V4L2_FBUF_CAP_LOCAL_ALPHA | V4L2_FBUF_CAP_GLOBAL_ALPHA;
+ fb->fmt.pixelformat = itv->osd_pixelformat;
+ fb->fmt.width = itv->osd_rect.width;
+ fb->fmt.height = itv->osd_rect.height;
+ fb->fmt.left = itv->osd_rect.left;
+ fb->fmt.top = itv->osd_rect.top;
+ fb->base = (void *)itv->osd_video_pbase;
+ if (itv->osd_global_alpha_state)
+ fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA;
+ if (itv->osd_local_alpha_state)
+ fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA;
+ if (itv->osd_color_key_state)
+ fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY;
+ break;
+ }
+
+ case VIDIOC_S_FBUF: {
+ struct v4l2_framebuffer *fb = arg;
+
+ if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
+ break;
+ itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0;
+ itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0;
+ itv->osd_color_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0;
+ break;
+ }
+
case VIDIOC_LOG_STATUS:
{
int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT;
@@ -1172,7 +1238,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
return 0;
}
-static int ivtv_ivtv_ioctls(struct file *filp, unsigned int cmd, void *arg)
+static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
{
struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data;
struct ivtv *itv = id->itv;
@@ -1352,96 +1418,6 @@ static int ivtv_ivtv_ioctls(struct file *filp, unsigned int cmd, void *arg)
break;
}
- case VIDIOC_G_ENC_INDEX: {
- struct v4l2_enc_idx *idx = arg;
- int i;
-
- IVTV_DEBUG_IOCTL("VIDIOC_G_ENC_INDEX\n");
- idx->entries = (itv->pgm_info_write_idx + IVTV_MAX_PGM_INDEX - itv->pgm_info_read_idx) %
- IVTV_MAX_PGM_INDEX;
- if (idx->entries > V4L2_ENC_IDX_ENTRIES)
- idx->entries = V4L2_ENC_IDX_ENTRIES;
- for (i = 0; i < idx->entries; i++) {
- idx->entry[i] = itv->pgm_info[(itv->pgm_info_read_idx + i) % IVTV_MAX_PGM_INDEX];
- }
- itv->pgm_info_read_idx = (itv->pgm_info_read_idx + idx->entries) % IVTV_MAX_PGM_INDEX;
- break;
- }
-
- case VIDIOC_ENCODER_CMD:
- case VIDIOC_TRY_ENCODER_CMD: {
- struct v4l2_encoder_cmd *enc = arg;
- int try = cmd == VIDIOC_TRY_ENCODER_CMD;
-
- if (try)
- IVTV_DEBUG_IOCTL("VIDIOC_TRY_ENCODER_CMD\n");
- else
- IVTV_DEBUG_IOCTL("VIDIOC_ENCODER_CMD\n");
- switch (enc->cmd) {
- case V4L2_ENC_CMD_START:
- return ivtv_start_capture(id);
-
- case V4L2_ENC_CMD_STOP:
- ivtv_stop_capture(id, enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END);
- return 0;
-
- case V4L2_ENC_CMD_PAUSE:
- if (!atomic_read(&itv->capturing))
- return -EPERM;
- if (test_and_set_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags))
- return 0;
- ivtv_mute(itv);
- ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 0);
- break;
-
- case V4L2_ENC_CMD_RESUME:
- if (!atomic_read(&itv->capturing))
- return -EPERM;
- if (!test_and_clear_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags))
- return 0;
- ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 1);
- ivtv_unmute(itv);
- break;
- }
- break;
- }
-
- case VIDIOC_G_FBUF: {
- struct v4l2_framebuffer *fb = arg;
-
- IVTV_DEBUG_IOCTL("VIDIOC_G_FBUF\n");
- memset(fb, 0, sizeof(*fb));
- if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
- break;
- fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY |
- V4L2_FBUF_CAP_LOCAL_ALPHA | V4L2_FBUF_CAP_GLOBAL_ALPHA;
- fb->fmt.pixelformat = itv->osd_pixelformat;
- fb->fmt.width = itv->osd_rect.width;
- fb->fmt.height = itv->osd_rect.height;
- fb->fmt.left = itv->osd_rect.left;
- fb->fmt.top = itv->osd_rect.top;
- fb->base = (void *)itv->osd_video_pbase;
- if (itv->osd_global_alpha_state)
- fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA;
- if (itv->osd_local_alpha_state)
- fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA;
- if (itv->osd_color_key_state)
- fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY;
- break;
- }
-
- case VIDIOC_S_FBUF: {
- struct v4l2_framebuffer *fb = arg;
-
- IVTV_DEBUG_IOCTL("VIDIOC_S_FBUF\n");
- if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
- break;
- itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0;
- itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0;
- itv->osd_color_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0;
- break;
- }
-
default:
return -EINVAL;
}
@@ -1453,8 +1429,26 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
{
struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data;
struct ivtv *itv = id->itv;
+ int ret;
- IVTV_DEBUG_IOCTL("v4l2 ioctl 0x%08x\n", cmd);
+ /* check priority */
+ switch (cmd) {
+ case VIDIOC_S_CTRL:
+ case VIDIOC_S_STD:
+ case VIDIOC_S_INPUT:
+ case VIDIOC_S_OUTPUT:
+ case VIDIOC_S_TUNER:
+ case VIDIOC_S_FREQUENCY:
+ case VIDIOC_S_FMT:
+ case VIDIOC_S_CROP:
+ case VIDIOC_S_AUDIO:
+ case VIDIOC_S_AUDOUT:
+ case VIDIOC_S_EXT_CTRLS:
+ case VIDIOC_S_FBUF:
+ ret = v4l2_prio_check(&itv->prio, &id->prio);
+ if (ret)
+ return ret;
+ }
switch (cmd) {
case VIDIOC_DBG_G_REGISTER:
@@ -1462,8 +1456,14 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
case VIDIOC_G_CHIP_IDENT:
case VIDIOC_INT_S_AUDIO_ROUTING:
case VIDIOC_INT_RESET:
- return ivtv_internal_ioctls(filp, cmd, arg);
+ if (ivtv_debug & IVTV_DBGFLG_IOCTL) {
+ printk(KERN_INFO "ivtv%d ioctl: ", itv->num);
+ v4l_printk_ioctl(cmd);
+ }
+ return ivtv_debug_ioctls(filp, cmd, arg);
+ case VIDIOC_G_PRIORITY:
+ case VIDIOC_S_PRIORITY:
case VIDIOC_QUERYCAP:
case VIDIOC_ENUMINPUT:
case VIDIOC_G_INPUT:
@@ -1492,6 +1492,15 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
case VIDIOC_G_AUDOUT:
case VIDIOC_G_SLICED_VBI_CAP:
case VIDIOC_LOG_STATUS:
+ case VIDIOC_G_ENC_INDEX:
+ case VIDIOC_ENCODER_CMD:
+ case VIDIOC_TRY_ENCODER_CMD:
+ case VIDIOC_G_FBUF:
+ case VIDIOC_S_FBUF:
+ if (ivtv_debug & IVTV_DBGFLG_IOCTL) {
+ printk(KERN_INFO "ivtv%d ioctl: ", itv->num);
+ v4l_printk_ioctl(cmd);
+ }
return ivtv_v4l2_ioctls(itv, filp, cmd, arg);
case VIDIOC_QUERYMENU:
@@ -1501,6 +1510,10 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
case VIDIOC_S_EXT_CTRLS:
case VIDIOC_G_EXT_CTRLS:
case VIDIOC_TRY_EXT_CTRLS:
+ if (ivtv_debug & IVTV_DBGFLG_IOCTL) {
+ printk(KERN_INFO "ivtv%d ioctl: ", itv->num);
+ v4l_printk_ioctl(cmd);
+ }
return ivtv_control_ioctls(itv, cmd, arg);
case IVTV_IOC_DMA_FRAME:
@@ -1513,12 +1526,7 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
case VIDEO_CONTINUE:
case VIDEO_COMMAND:
case VIDEO_TRY_COMMAND:
- case VIDIOC_G_ENC_INDEX:
- case VIDIOC_ENCODER_CMD:
- case VIDIOC_TRY_ENCODER_CMD:
- case VIDIOC_G_FBUF:
- case VIDIOC_S_FBUF:
- return ivtv_ivtv_ioctls(filp, cmd, arg);
+ return ivtv_decoder_ioctls(filp, cmd, arg);
case 0x00005401: /* Handle isatty() calls */
return -EINVAL;
diff --git a/linux/drivers/media/video/msp3400-driver.c b/linux/drivers/media/video/msp3400-driver.c
index 0e21a5b57..d6364b01f 100644
--- a/linux/drivers/media/video/msp3400-driver.c
+++ b/linux/drivers/media/video/msp3400-driver.c
@@ -829,7 +829,11 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,14)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)
+static int msp_suspend(struct i2c_client *client, pm_message_t state)
+#else
static int msp_suspend(struct device * dev, pm_message_t state)
+#endif
#else
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)
static int msp_suspend(struct device * dev, pm_message_t state, u32 level)
@@ -838,7 +842,9 @@ static int msp_suspend(struct device * dev, u32 state, u32 level)
#endif
#endif
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
struct i2c_client *client = container_of(dev, struct i2c_client, dev);
+#endif
v4l_dbg(1, msp_debug, client, "suspend\n");
msp_reset(client);
@@ -846,12 +852,18 @@ static int msp_suspend(struct device * dev, u32 state, u32 level)
}
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,14)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)
+static int msp_resume(struct i2c_client *client)
+#else
static int msp_resume(struct device * dev)
+#endif
#else
static int msp_resume(struct device * dev, u32 level)
#endif
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
struct i2c_client *client = container_of(dev, struct i2c_client, dev);
+#endif
v4l_dbg(1, msp_debug, client, "resume\n");
msp_wake_thread(client);
@@ -894,7 +906,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
if (msp_reset(client) == -1) {
v4l_dbg(1, msp_debug, client, "msp3400 not found\n");
kfree(client);
- return -1;
+ return 0;
}
state = kmalloc(sizeof(*state), GFP_KERNEL);
@@ -928,7 +940,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n");
kfree(state);
kfree(client);
- return -1;
+ return 0;
}
#if 0
@@ -1110,14 +1122,20 @@ static struct i2c_driver i2c_driver = {
.id = I2C_DRIVERID_MSP3400,
.attach_adapter = msp_probe,
.detach_client = msp_detach,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)
+ .suspend = msp_suspend,
+ .resume = msp_resume,
+#endif
.command = msp_command,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
.driver = {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
.name = "msp3400",
#endif
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
.suspend = msp_suspend,
.resume = msp_resume,
+#endif
},
#endif
};
diff --git a/linux/drivers/media/video/saa7115.c b/linux/drivers/media/video/saa7115.c
index ac2660e76..74c89b458 100644
--- a/linux/drivers/media/video/saa7115.c
+++ b/linux/drivers/media/video/saa7115.c
@@ -1505,6 +1505,7 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
if (memcmp(name, "1f711", 5)) {
v4l_dbg(1, debug, client, "chip found @ 0x%x (ID %s) does not match a known saa711x chip.\n",
address << 1, name);
+ kfree(client);
return 0;
}
diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c
index 02fb067e2..e7bc60a5e 100644
--- a/linux/drivers/media/video/tuner-core.c
+++ b/linux/drivers/media/video/tuner-core.c
@@ -903,7 +903,11 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,14)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)
+static int tuner_suspend(struct i2c_client *c, pm_message_t state)
+#else
static int tuner_suspend(struct device *dev, pm_message_t state)
+#endif
#else
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)
static int tuner_suspend(struct device *dev, pm_message_t state, u32 level)
@@ -912,7 +916,9 @@ static int tuner_suspend(struct device *dev, u32 state, u32 level)
#endif
#endif
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
struct i2c_client *c = container_of (dev, struct i2c_client, dev);
+#endif
struct tuner *t = i2c_get_clientdata (c);
tuner_dbg ("suspend\n");
@@ -921,12 +927,18 @@ static int tuner_suspend(struct device *dev, u32 state, u32 level)
}
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,14)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)
+static int tuner_resume(struct i2c_client *c)
+#else
static int tuner_resume(struct device *dev)
+#endif
#else
static int tuner_resume(struct device *dev, u32 level)
#endif
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
struct i2c_client *c = container_of (dev, struct i2c_client, dev);
+#endif
struct tuner *t = i2c_get_clientdata (c);
tuner_dbg ("resume\n");
@@ -955,13 +967,19 @@ static struct i2c_driver driver = {
.attach_adapter = tuner_probe,
.detach_client = tuner_detach,
.command = tuner_command,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20)
+ .suspend = tuner_suspend,
+ .resume = tuner_resume,
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
.driver = {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
.name = "tuner",
#endif
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
.suspend = tuner_suspend,
.resume = tuner_resume,
+#endif
},
#endif
};