diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-03-17 17:19:42 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-03-17 17:19:42 -0200 |
commit | 01d687a75155f9c9181e46572a60c71040d9133d (patch) | |
tree | 23a5939cfc6b1f24d0730c5c70a3d43c96063d6e /linux/drivers/media | |
parent | 806e8a78b6b2b8bbab30dafd89ada8402e9564ed (diff) | |
parent | 13f01356dce8354c14e7e1a3f25162a24a002fff (diff) | |
download | mediapointer-dvb-s2-01d687a75155f9c9181e46572a60c71040d9133d.tar.gz mediapointer-dvb-s2-01d687a75155f9c9181e46572a60c71040d9133d.tar.bz2 |
merge: http://linuxtv.org/hg/~endriss/v4l-dvb
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media')
-rw-r--r-- | linux/drivers/media/dvb/dvb-usb/au6610.c | 6 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dvb-usb/gl861.c | 6 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dvb-usb/m920x.c | 141 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dvb-usb/m920x.h | 46 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-cards.c | 12 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-driver.c | 90 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-driver.h | 3 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-fileops.c | 3 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-ioctl.c | 310 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-yuv.c | 9 | ||||
-rw-r--r-- | linux/drivers/media/video/msp3400-driver.c | 22 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7115.c | 3 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-core.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/video/tveeprom.c | 43 |
14 files changed, 410 insertions, 302 deletions
diff --git a/linux/drivers/media/dvb/dvb-usb/au6610.c b/linux/drivers/media/dvb/dvb-usb/au6610.c index 91079891d..3314f8c0c 100644 --- a/linux/drivers/media/dvb/dvb-usb/au6610.c +++ b/linux/drivers/media/dvb/dvb-usb/au6610.c @@ -40,7 +40,7 @@ static int au6610_usb_msg(struct dvb_usb_device *d, u8 operation, u8 addr, } ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), operation, - USB_TYPE_VENDOR|USB_DIR_IN, addr, index, usb_buf, + USB_TYPE_VENDOR|USB_DIR_IN, addr << 1, index, usb_buf, sizeof(usb_buf), AU6610_USB_TIMEOUT); if (ret < 0) @@ -124,7 +124,7 @@ static int au6610_identify_state(struct usb_device *udev, } static struct zl10353_config au6610_zl10353_config = { - .demod_address = 0x1e, + .demod_address = 0x0f, .no_tuner = 1, .parallel_ts = 1, }; @@ -140,7 +140,7 @@ static int au6610_zl10353_frontend_attach(struct dvb_usb_adapter *adap) } static struct qt1010_config au6610_qt1010_config = { - .i2c_address = 0xc4 + .i2c_address = 0x62 }; static int au6610_qt1010_tuner_attach(struct dvb_usb_adapter *adap) diff --git a/linux/drivers/media/dvb/dvb-usb/gl861.c b/linux/drivers/media/dvb/dvb-usb/gl861.c index 1e5e2c1b9..ce06395b8 100644 --- a/linux/drivers/media/dvb/dvb-usb/gl861.c +++ b/linux/drivers/media/dvb/dvb-usb/gl861.c @@ -20,7 +20,7 @@ static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr, u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) { u16 index; - u16 value = addr << 8; + u16 value = addr << (8 + 1); int wo = (rbuf == NULL || rlen == 0); /* write-only */ u8 req, type; @@ -101,7 +101,7 @@ static int gl861_identify_state(struct usb_device *udev, } static struct zl10353_config gl861_zl10353_config = { - .demod_address = 0x1e, + .demod_address = 0x0f, .no_tuner = 1, .parallel_ts = 1, }; @@ -117,7 +117,7 @@ static int gl861_frontend_attach(struct dvb_usb_adapter *adap) } static struct qt1010_config gl861_qt1010_config = { - .i2c_address = 0xc4 + .i2c_address = 0x62 }; static int gl861_tuner_attach(struct dvb_usb_adapter *adap) diff --git a/linux/drivers/media/dvb/dvb-usb/m920x.c b/linux/drivers/media/dvb/dvb-usb/m920x.c index 1a411316f..e63f1edba 100644 --- a/linux/drivers/media/dvb/dvb-usb/m920x.c +++ b/linux/drivers/media/dvb/dvb-usb/m920x.c @@ -67,16 +67,18 @@ static inline int m9206_write(struct usb_device *udev, u8 request, return ret; } -static int m9206_rc_init(struct usb_device *udev) +static int m9206_init(struct dvb_usb_device *d) { int ret = 0; /* Remote controller init. */ - if ((ret = m9206_write(udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0) - return ret; + if (d->props.rc_query) { + if ((ret = m9206_write(d->udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0) + return ret; - if ((ret = m9206_write(udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0) - return ret; + if ((ret = m9206_write(d->udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0) + return ret; + } return ret; } @@ -87,20 +89,15 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) int i, ret = 0; u8 rc_state[2]; -#if 0 - if (mutex_lock_interruptible(&d->i2c_mutex) < 0) - return -EAGAIN; -#endif - if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) goto unlock; if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) goto unlock; - for (i = 0; i < ARRAY_SIZE(megasky_rc_keys); i++) - if (megasky_rc_keys[i].data == rc_state[1]) { - *event = megasky_rc_keys[i].event; + for (i = 0; i < d->props.rc_key_map_size; i++) + if (d->props.rc_key_map[i].data == rc_state[1]) { + *event = d->props.rc_key_map[i].event; switch(rc_state[0]) { case 0x80: @@ -132,9 +129,6 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) *state = REMOTE_NO_KEY_PRESSED; unlock: -#if 0 - mutex_unlock(&d->i2c_mutex); -#endif return ret; } @@ -144,53 +138,51 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) { struct dvb_usb_device *d = i2c_get_adapdata(adap); - struct m9206_state *m = d->priv; - int i; + int i, j; int ret = 0; + if (!num) + return -EINVAL; + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) return -EAGAIN; - if (num > 2) - return -EINVAL; - for (i = 0; i < num; i++) { - if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].addr, 0x80)) != 0) + if (msg[i].flags & (I2C_M_NO_RD_ACK|I2C_M_IGNORE_NAK|I2C_M_TEN) || + msg[i].len == 0) { + /* For a 0 byte message, I think sending the address to index 0x80|0x40 + * would be the correct thing to do. However, zero byte messages are + * only used for probing, and since we don't know how to get the slave's + * ack, we can't probe. */ + ret = -ENOTSUPP; goto unlock; - - if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[0], 0x0)) != 0) - goto unlock; - - if (i + 1 < num && msg[i + 1].flags & I2C_M_RD) { - int i2c_i; - - for (i2c_i = 0; i2c_i < M9206_I2C_MAX; i2c_i++) - if (msg[i].addr == m->i2c_r[i2c_i].addr) - break; - - if (i2c_i >= M9206_I2C_MAX) { - deb_rc("No magic for i2c addr!\n"); - ret = -EINVAL; + } + /* Send START & address/RW bit */ + if (!(msg[i].flags & I2C_M_NOSTART)) { + if ((ret = m9206_write(d->udev, M9206_I2C, (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0), 0x80)) != 0) goto unlock; + /* Should check for ack here, if we knew how. */ + } + if (msg[i].flags & I2C_M_RD) { + for (j = 0; j < msg[i].len; j++) { + /* Last byte of transaction? Send STOP, otherwise send ACK. */ + int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x01; + if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x20|stop, &msg[i].buf[j], 1)) != 0) + goto unlock; } - - if ((ret = m9206_write(d->udev, M9206_I2C, m->i2c_r[i2c_i].magic, 0x80)) != 0) - goto unlock; - - if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x60, msg[i + 1].buf, msg[i + 1].len)) != 0) - goto unlock; - - i++; } else { - if (msg[i].len != 2) - return -EINVAL; - - if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[1], 0x40)) != 0) - goto unlock; + for (j = 0; j < msg[i].len; j++) { + /* Last byte of transaction? Then send STOP. */ + int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x00; + if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0) + goto unlock; + /* Should check for ack here too. */ + } } } - ret = i; - unlock: + ret = num; + +unlock: mutex_unlock(&d->i2c_mutex); return ret; @@ -388,20 +380,15 @@ static int megasky_mt352_demod_init(struct dvb_frontend *fe) } static struct mt352_config megasky_mt352_config = { - .demod_address = 0x1e, + .demod_address = 0x0f, .no_tuner = 1, .demod_init = megasky_mt352_demod_init, }; static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap) { - struct m9206_state *m = adap->dev->priv; - deb_rc("megasky_frontend_attach!\n"); - m->i2c_r[M9206_I2C_DEMOD].addr = megasky_mt352_config.demod_address; - m->i2c_r[M9206_I2C_DEMOD].magic = 0x1f; - if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL) return -EIO; @@ -409,16 +396,11 @@ static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap) } static struct qt1010_config megasky_qt1010_config = { - .i2c_address = 0xc4 + .i2c_address = 0x62 }; static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap) { - struct m9206_state *m = adap->dev->priv; - - m->i2c_r[M9206_I2C_TUNER].addr = megasky_qt1010_config.i2c_address; - m->i2c_r[M9206_I2C_TUNER].magic = 0xc5; - if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &megasky_qt1010_config) == NULL) return -ENODEV; @@ -436,25 +418,28 @@ static int m920x_probe(struct usb_interface *intf, struct usb_host_interface *alt; int ret; - if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) { - deb_rc("probed!\n"); + deb_rc("Probed!\n"); - alt = usb_altnum_to_altsetting(intf, 1); - if (alt == NULL) { - deb_rc("not alt found!\n"); - return -ENODEV; - } - - ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, - alt->desc.bAlternateSetting); - if (ret < 0) - return ret; + if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) + goto found; - deb_rc("Changed to alternate setting!\n"); + return ret; - if ((ret = m9206_rc_init(d->udev)) != 0) - return ret; +found: + alt = usb_altnum_to_altsetting(intf, 1); + if (alt == NULL) { + deb_rc("No alt found!\n"); + return -ENODEV; } + + ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, + alt->desc.bAlternateSetting); + if (ret < 0) + return ret; + + if ((ret = m9206_init(d)) != 0) + return ret; + return ret; } diff --git a/linux/drivers/media/dvb/dvb-usb/m920x.h b/linux/drivers/media/dvb/dvb-usb/m920x.h index c354196ff..7dd3db65c 100644 --- a/linux/drivers/media/dvb/dvb-usb/m920x.h +++ b/linux/drivers/media/dvb/dvb-usb/m920x.h @@ -19,17 +19,49 @@ #define M9206_MAX_FILTERS 8 -#define M9206_I2C_TUNER 0 -#define M9206_I2C_DEMOD 1 -#define M9206_I2C_MAX 2 +/* +sequences found in logs: +[index value] +0x80 write addr +(0x00 out byte)* +0x40 out byte + +0x80 write addr +(0x00 out byte)* +0x80 read addr +(0x21 in byte)* +0x60 in byte + +this sequence works: +0x80 read addr +(0x21 in byte)* +0x60 in byte + +Guess at API of the I2C function: +I2C operation is done one byte at a time with USB control messages. The +index the messages is sent to is made up of a set of flags that control +the I2C bus state: +0x80: Send START condition. After a START condition, one would normally + always send the 7-bit slave I2C address as the 7 MSB, followed by + the read/write bit as the LSB. +0x40: Send STOP condition. This should be set on the last byte of an + I2C transaction. +0x20: Read a byte from the slave. As opposed to writing a byte to the + slave. The slave will normally not produce any data unless you + set the R/W bit to 1 when sending the slave's address after the + START condition. +0x01: Respond with ACK, as opposed to a NACK. For a multi-byte read, + the master should send an ACK, that is pull SDA low during the 9th + clock cycle, after every byte but the last. This flags only makes + sense when bit 0x20 is set, indicating a read. + +What any other bits might mean, or how to get the slave's ACK/NACK +response to a write, is unknown. +*/ struct m9206_state { u16 filters[M9206_MAX_FILTERS]; int filtering_enabled; int rep_count; - struct { - unsigned char addr; - unsigned char magic; - }i2c_r[M9206_I2C_MAX]; }; #endif diff --git a/linux/drivers/media/video/cx88/cx88-cards.c b/linux/drivers/media/video/cx88/cx88-cards.c index 3a7131342..774bcfed9 100644 --- a/linux/drivers/media/video/cx88/cx88-cards.c +++ b/linux/drivers/media/video/cx88/cx88-cards.c @@ -1570,10 +1570,10 @@ struct cx88_subid cx88_subids[] = { },{ .subvendor = 0x17de, .subdevice = 0x0840, - .card = CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT, - },{ - .subvendor = 0x1421, - .subdevice = 0x0305, + .card = CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT, + },{ + .subvendor = 0x1421, + .subdevice = 0x0305, .card = CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT, },{ .subvendor = 0x18ac, @@ -1664,6 +1664,10 @@ struct cx88_subid cx88_subids[] = { .subvendor = 0x0070, .subdevice = 0x1402, .card = CX88_BOARD_HAUPPAUGE_HVR3000, + },{ + .subvendor = 0x1421, + .subdevice = 0x0341, /* ADS Tech InstantTV DVB-S */ + .card = CX88_BOARD_KWORLD_DVBS_100, }, }; const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); diff --git a/linux/drivers/media/video/ivtv/ivtv-driver.c b/linux/drivers/media/video/ivtv/ivtv-driver.c index adfc8a869..4031df6db 100644 --- a/linux/drivers/media/video/ivtv/ivtv-driver.c +++ b/linux/drivers/media/video/ivtv/ivtv-driver.c @@ -116,7 +116,7 @@ static int dec_yuv_buffers = IVTV_DEFAULT_DEC_YUV_BUFFERS; static int dec_vbi_buffers = IVTV_DEFAULT_DEC_VBI_BUFFERS; static int ivtv_yuv_mode = 0; -static int ivtv_yuv_threshold=480; +static int ivtv_yuv_threshold=-1; static int ivtv_pci_latency = 1; int ivtv_debug = 0; @@ -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; @@ -1214,8 +1174,45 @@ static int __devinit ivtv_probe(struct pci_dev *dev, in one place. */ itv->std++; /* Force full standard initialization */ 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_v4l2_ioctls(itv, NULL, VIDIOC_S_STD, &itv->tuner_std); + + 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..39e1d7e46 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; }; @@ -612,7 +613,6 @@ struct yuv_playback_info int lace_mode; int lace_threshold; - int lace_threshold_last; int lace_sync_field; atomic_t next_dma_frame; @@ -739,6 +739,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/ivtv/ivtv-yuv.c b/linux/drivers/media/video/ivtv/ivtv-yuv.c index 286a0d7e7..bcea09542 100644 --- a/linux/drivers/media/video/ivtv/ivtv-yuv.c +++ b/linux/drivers/media/video/ivtv/ivtv-yuv.c @@ -613,16 +613,19 @@ static void ivtv_yuv_handle_vertical(struct ivtv *itv, struct yuv_frame_info *wi } itv->yuv_info.frame_interlaced_last = itv->yuv_info.frame_interlaced; - itv->yuv_info.lace_threshold_last = itv->yuv_info.lace_threshold; } /* Modify the supplied coordinate information to fit the visible osd area */ static u32 ivtv_yuv_window_setup (struct ivtv *itv, struct yuv_frame_info *window) { - int osd_crop; + int osd_crop, lace_threshold; u32 osd_scale; u32 yuv_update = 0; + lace_threshold = itv->yuv_info.lace_threshold; + if (lace_threshold < 0) + lace_threshold = itv->yuv_info.decode_height - 1; + /* Work out the lace settings */ switch (itv->yuv_info.lace_mode) { case IVTV_YUV_MODE_PROGRESSIVE: /* Progressive mode */ @@ -639,7 +642,7 @@ static u32 ivtv_yuv_window_setup (struct ivtv *itv, struct yuv_frame_info *windo break; case IVTV_YUV_MODE_AUTO: - if (window->tru_h <= itv->yuv_info.lace_threshold || window->tru_h > 576 || window->tru_w > 720){ + if (window->tru_h <= lace_threshold || window->tru_h > 576 || window->tru_w > 720){ itv->yuv_info.frame_interlaced = 0; if ((window->tru_h < 512) || (window->tru_h > 576 && window->tru_h < 1021) || 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 064a81334..74c89b458 100644 --- a/linux/drivers/media/video/saa7115.c +++ b/linux/drivers/media/video/saa7115.c @@ -973,7 +973,7 @@ static void saa711x_set_v4lstd(struct i2c_client *client, v4l2_std_id std) reg |= 0x10; } else if (std == V4L2_STD_NTSC_M_JP) { reg |= 0x40; - } else if (std == V4L2_STD_SECAM) { + } else if (std & V4L2_STD_SECAM) { reg |= 0x50; } saa711x_write(client, R_0E_CHROMA_CNTL_1, reg); @@ -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 }; diff --git a/linux/drivers/media/video/tveeprom.c b/linux/drivers/media/video/tveeprom.c index 61b99971e..f7f046ebb 100644 --- a/linux/drivers/media/video/tveeprom.c +++ b/linux/drivers/media/video/tveeprom.c @@ -233,6 +233,36 @@ hauppauge_tuner[] = /* 120-129 */ { TUNER_ABSENT, "Xceive XC3028"}, { TUNER_ABSENT, "Philips FQ1216LME MK5"}, + { TUNER_ABSENT, "Philips FQD1216LME"}, + { TUNER_ABSENT, "Conexant CX24118A"}, + { TUNER_ABSENT, "TCL DMF11WIP"}, + { TUNER_ABSENT, "TCL MFNM05_4H_E"}, + { TUNER_ABSENT, "TCL MNM05_4H_E"}, + { TUNER_ABSENT, "TCL MPE05_2H_E"}, + { TUNER_ABSENT, "TCL MQNM05_4_U"}, + { TUNER_ABSENT, "TCL M2523_5NH_E"}, + /* 130-139 */ + { TUNER_ABSENT, "TCL M2523_3DBH_E"}, + { TUNER_ABSENT, "TCL M2523_3DIH_E"}, + { TUNER_ABSENT, "TCL MFPE05_2_U"}, + { TUNER_ABSENT, "Philips FMD1216MEX"}, + { TUNER_ABSENT, "Philips FRH2036B"}, + { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, + { TUNER_ABSENT, "MaxLinear MXL5005"}, + { TUNER_ABSENT, "MaxLinear MXL5003"}, + { TUNER_ABSENT, "Xceive XC2028"}, + { TUNER_ABSENT, "Microtune MT2131"}, + /* 140-149 */ + { TUNER_ABSENT, "Philips 8275A_8295"}, + { TUNER_ABSENT, "TCL MF02GIP_5N_E"}, + { TUNER_ABSENT, "TCL MF02GIP_3DB_E"}, + { TUNER_ABSENT, "TCL MF02GIP_3DI_E"}, + { TUNER_ABSENT, "Microtune MT2266"}, + { TUNER_ABSENT, "TCL MF10WPP_4N_E"}, + { TUNER_ABSENT, "LG TAPQ_H702F"}, + { TUNER_ABSENT, "TCL M09WPP_4N_E"}, + { TUNER_ABSENT, "MaxLinear MXL5005_v2"}, + { TUNER_ABSENT, "Philips 18271_8295"}, }; static struct HAUPPAUGE_AUDIOIC @@ -284,11 +314,16 @@ audioIC[] = {AUDIO_CHIP_INTERNAL, "CX883"}, {AUDIO_CHIP_INTERNAL, "CX882"}, {AUDIO_CHIP_INTERNAL, "CX25840"}, - /* 35-38 */ + /* 35-39 */ {AUDIO_CHIP_INTERNAL, "CX25841"}, {AUDIO_CHIP_INTERNAL, "CX25842"}, {AUDIO_CHIP_INTERNAL, "CX25843"}, {AUDIO_CHIP_INTERNAL, "CX23418"}, + {AUDIO_CHIP_INTERNAL, "CX23885"}, + /* 40-42 */ + {AUDIO_CHIP_INTERNAL, "CX23888"}, + {AUDIO_CHIP_INTERNAL, "SAA7131"}, + {AUDIO_CHIP_INTERNAL, "CX23887"}, }; /* This list is supplied by Hauppauge. Thanks! */ @@ -305,8 +340,10 @@ static const char *decoderIC[] = { "CX880", "CX881", "CX883", "SAA7111", "SAA7113", /* 25-29 */ "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", - /* 30-31 */ - "CX25843", "CX23418", + /* 30-34 */ + "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888", + /* 35-37 */ + "SAA7131", "CX25837", "CX23887" }; static int hasRadioTuner(int tunerType) |