diff options
author | Gerd Knorr <devnull@localhost> | 2004-09-23 13:58:19 +0000 |
---|---|---|
committer | Gerd Knorr <devnull@localhost> | 2004-09-23 13:58:19 +0000 |
commit | 2f9202097e4418d085a0d6ef636de1d0b0fb84dd (patch) | |
tree | 346e618d5502ac1f9abce855416aad2bb0b20a47 /linux | |
parent | 953f8692136acd6aa9201f9388697a7005756894 (diff) | |
download | mediapointer-dvb-s2-2f9202097e4418d085a0d6ef636de1d0b0fb84dd.tar.gz mediapointer-dvb-s2-2f9202097e4418d085a0d6ef636de1d0b0fb84dd.tar.bz2 |
- make video-bufg don't touch struct file any more, pass through
a void ptr instead of a file ptr everythere.
- add cx22702 fe driver,
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/media/video/bttv-driver.c | 58 | ||||
-rw-r--r-- | linux/drivers/media/video/bttv-vbi.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-blackbird.c | 39 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-cards.c | 58 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-dvb.c | 64 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-i2c.c | 19 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-vbi.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-video.c | 49 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88.h | 21 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-ts.c | 37 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-vbi.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-video.c | 55 | ||||
-rw-r--r-- | linux/drivers/media/video/video-buf.c | 102 | ||||
-rw-r--r-- | linux/include/media/video-buf.h | 45 |
14 files changed, 332 insertions, 267 deletions
diff --git a/linux/drivers/media/video/bttv-driver.c b/linux/drivers/media/video/bttv-driver.c index 44e8c00cc..df30742ed 100644 --- a/linux/drivers/media/video/bttv-driver.c +++ b/linux/drivers/media/video/bttv-driver.c @@ -1,5 +1,5 @@ /* - $Id: bttv-driver.c,v 1.15 2004/09/20 11:39:43 kraxel Exp $ + $Id: bttv-driver.c,v 1.16 2004/09/23 13:58:19 kraxel Exp $ bttv - Bt848 frame grabber driver @@ -1414,9 +1414,9 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf, } static int -buffer_setup(struct file *file, unsigned int *count, unsigned int *size) +buffer_setup(void *priv, unsigned int *count, unsigned int *size) { - struct bttv_fh *fh = file->private_data; + struct bttv_fh *fh = priv; *size = fh->fmt->depth*fh->width*fh->height >> 3; if (0 == *count) @@ -1427,21 +1427,21 @@ buffer_setup(struct file *file, unsigned int *count, unsigned int *size) } static int -buffer_prepare(struct file *file, struct videobuf_buffer *vb, +buffer_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { struct bttv_buffer *buf = (struct bttv_buffer*)vb; - struct bttv_fh *fh = file->private_data; + struct bttv_fh *fh = priv; return bttv_prepare_buffer(fh->btv, buf, fh->fmt, fh->width, fh->height, field); } static void -buffer_queue(struct file *file, struct videobuf_buffer *vb) +buffer_queue(void *priv, struct videobuf_buffer *vb) { struct bttv_buffer *buf = (struct bttv_buffer*)vb; - struct bttv_fh *fh = file->private_data; + struct bttv_fh *fh = priv; buf->vb.state = STATE_QUEUED; list_add_tail(&buf->vb.queue,&fh->btv->capture); @@ -1449,10 +1449,10 @@ buffer_queue(struct file *file, struct videobuf_buffer *vb) bttv_set_dma(fh->btv, 0x03, fh->btv->curr.irqflags); } -static void buffer_release(struct file *file, struct videobuf_buffer *vb) +static void buffer_release(void *priv, struct videobuf_buffer *vb) { struct bttv_buffer *buf = (struct bttv_buffer*)vb; - struct bttv_fh *fh = file->private_data; + struct bttv_fh *fh = priv; bttv_dma_free(fh->btv,buf); } @@ -2384,7 +2384,8 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, unsigned int i; down(&fh->cap.lock); - retval = videobuf_mmap_setup(file,&fh->cap,gbuffers,gbufsize, + retval = videobuf_mmap_setup(file->private_data, + &fh->cap,gbuffers,gbufsize, V4L2_MEMORY_MMAP); if (retval < 0) goto fh_unlock_and_return; @@ -2425,7 +2426,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, if (0 != retval) goto fh_unlock_and_return; spin_lock_irqsave(&btv->s_lock,flags); - buffer_queue(file,&buf->vb); + buffer_queue(file->private_data,&buf->vb); spin_unlock_irqrestore(&btv->s_lock,flags); up(&fh->cap.lock); return 0; @@ -2682,16 +2683,17 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_REQBUFS: - return videobuf_reqbufs(file,bttv_queue(fh),arg); + return videobuf_reqbufs(file->private_data,bttv_queue(fh),arg); case VIDIOC_QUERYBUF: return videobuf_querybuf(bttv_queue(fh),arg); case VIDIOC_QBUF: - return videobuf_qbuf(file,bttv_queue(fh),arg); + return videobuf_qbuf(file->private_data,bttv_queue(fh),arg); case VIDIOC_DQBUF: - return videobuf_dqbuf(file,bttv_queue(fh),arg); + return videobuf_dqbuf(file->private_data,bttv_queue(fh),arg, + file->f_flags & O_NONBLOCK); case VIDIOC_STREAMON: { @@ -2699,13 +2701,13 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, if (!check_alloc_btres(btv,fh,res)) return -EBUSY; - return videobuf_streamon(file,bttv_queue(fh)); + return videobuf_streamon(file->private_data,bttv_queue(fh)); } case VIDIOC_STREAMOFF: { int res = bttv_resource(fh); - retval = videobuf_streamoff(file,bttv_queue(fh)); + retval = videobuf_streamoff(file->private_data,bttv_queue(fh)); if (retval < 0) return retval; free_btres(btv,fh,res); @@ -2842,12 +2844,16 @@ static ssize_t bttv_read(struct file *file, char __user *data, case V4L2_BUF_TYPE_VIDEO_CAPTURE: if (locked_btres(fh->btv,RESOURCE_VIDEO)) return -EBUSY; - retval = videobuf_read_one(file, &fh->cap, data, count, ppos); + retval = videobuf_read_one(file->private_data, + &fh->cap, data, count, ppos, + file->f_flags & O_NONBLOCK); break; case V4L2_BUF_TYPE_VBI_CAPTURE: if (!check_alloc_btres(fh->btv,fh,RESOURCE_VBI)) return -EBUSY; - retval = videobuf_read_stream(file, &fh->vbi, data, count, ppos, 1); + retval = videobuf_read_stream(file->private_data, + &fh->vbi, data, count, ppos, 1, + file->f_flags & O_NONBLOCK); break; default: BUG(); @@ -2864,7 +2870,7 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { if (!check_alloc_btres(fh->btv,fh,RESOURCE_VBI)) return -EBUSY; - return videobuf_poll_stream(file, &fh->vbi, wait); + return videobuf_poll_stream(file->private_data, &fh->vbi, wait); } if (check_btres(fh,RESOURCE_VIDEO)) { @@ -2888,11 +2894,11 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) } fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; field = videobuf_next_field(&fh->cap); - if (0 != fh->cap.ops->buf_prepare(file,fh->cap.read_buf,field)) { + if (0 != fh->cap.ops->buf_prepare(file->private_data,fh->cap.read_buf,field)) { up(&fh->cap.lock); return POLLERR; } - fh->cap.ops->buf_queue(file,fh->cap.read_buf); + fh->cap.ops->buf_queue(file->private_data,fh->cap.read_buf); fh->cap.read_off = 0; } up(&fh->cap.lock); @@ -2978,20 +2984,20 @@ static int bttv_release(struct inode *inode, struct file *file) /* stop video capture */ if (check_btres(fh, RESOURCE_VIDEO)) { - videobuf_streamoff(file,&fh->cap); + videobuf_streamoff(file->private_data,&fh->cap); free_btres(btv,fh,RESOURCE_VIDEO); } if (fh->cap.read_buf) { - buffer_release(file,fh->cap.read_buf); + buffer_release(file->private_data,fh->cap.read_buf); kfree(fh->cap.read_buf); } /* stop vbi capture */ if (check_btres(fh, RESOURCE_VBI)) { if (fh->vbi.streaming) - videobuf_streamoff(file,&fh->vbi); + videobuf_streamoff(file->private_data,&fh->vbi); if (fh->vbi.reading) - videobuf_read_stop(file,&fh->vbi); + videobuf_read_stop(file->private_data,&fh->vbi); free_btres(btv,fh,RESOURCE_VBI); } @@ -3859,12 +3865,10 @@ static int __devinit bttv_probe(struct pci_dev *dev, /* register video4linux + input */ if (!bttv_tvcards[btv->c.type].no_video) { bttv_register_video(btv); -#if 0 bt848_bright(btv,32768); bt848_contrast(btv,32768); bt848_hue(btv,32768); bt848_sat(btv,32768); -#endif audio_mux(btv,AUDIO_MUTE); set_input(btv,0); } diff --git a/linux/drivers/media/video/bttv-vbi.c b/linux/drivers/media/video/bttv-vbi.c index 3f3f24b04..5dcbfd854 100644 --- a/linux/drivers/media/video/bttv-vbi.c +++ b/linux/drivers/media/video/bttv-vbi.c @@ -1,5 +1,5 @@ /* - $Id: bttv-vbi.c,v 1.3 2004/09/15 16:15:24 kraxel Exp $ + $Id: bttv-vbi.c,v 1.4 2004/09/23 13:58:19 kraxel Exp $ bttv - Bt848 frame grabber driver vbi interface @@ -63,10 +63,10 @@ vbi_buffer_risc(struct bttv *btv, struct bttv_buffer *buf, int lines) return 0; } -static int vbi_buffer_setup(struct file *file, +static int vbi_buffer_setup(void *priv, unsigned int *count, unsigned int *size) { - struct bttv_fh *fh = file->private_data; + struct bttv_fh *fh = priv; struct bttv *btv = fh->btv; if (0 == *count) @@ -76,10 +76,10 @@ static int vbi_buffer_setup(struct file *file, return 0; } -static int vbi_buffer_prepare(struct file *file, struct videobuf_buffer *vb, +static int vbi_buffer_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { - struct bttv_fh *fh = file->private_data; + struct bttv_fh *fh = priv; struct bttv *btv = fh->btv; struct bttv_buffer *buf = (struct bttv_buffer*)vb; int rc; @@ -107,9 +107,9 @@ static int vbi_buffer_prepare(struct file *file, struct videobuf_buffer *vb, } static void -vbi_buffer_queue(struct file *file, struct videobuf_buffer *vb) +vbi_buffer_queue(void *priv, struct videobuf_buffer *vb) { - struct bttv_fh *fh = file->private_data; + struct bttv_fh *fh = priv; struct bttv *btv = fh->btv; struct bttv_buffer *buf = (struct bttv_buffer*)vb; @@ -122,9 +122,9 @@ vbi_buffer_queue(struct file *file, struct videobuf_buffer *vb) } } -static void vbi_buffer_release(struct file *file, struct videobuf_buffer *vb) +static void vbi_buffer_release(void *priv, struct videobuf_buffer *vb) { - struct bttv_fh *fh = file->private_data; + struct bttv_fh *fh = priv; struct bttv *btv = fh->btv; struct bttv_buffer *buf = (struct bttv_buffer*)vb; diff --git a/linux/drivers/media/video/cx88/cx88-blackbird.c b/linux/drivers/media/video/cx88/cx88-blackbird.c index bc14f84f1..d15f15ccb 100644 --- a/linux/drivers/media/video/cx88/cx88-blackbird.c +++ b/linux/drivers/media/video/cx88/cx88-blackbird.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-blackbird.c,v 1.9 2004/09/10 08:50:22 kraxel Exp $ + * $Id: cx88-blackbird.c,v 1.10 2004/09/23 13:58:19 kraxel Exp $ * * Support for a cx23416 mpeg encoder via cx2388x host port. * "blackbird" reference design. @@ -543,9 +543,9 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) /* ------------------------------------------------------------------ */ -static int bb_buf_setup(struct file *file, unsigned int *count, unsigned int *size) +static int bb_buf_setup(void *priv, unsigned int *count, unsigned int *size) { - struct cx8802_fh *fh = file->private_data; + struct cx8802_fh *fh = priv; fh->dev->ts_packet_size = 512; fh->dev->ts_packet_count = 100; @@ -561,23 +561,23 @@ static int bb_buf_setup(struct file *file, unsigned int *count, unsigned int *si } static int -bb_buf_prepare(struct file *file, struct videobuf_buffer *vb, +bb_buf_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { - struct cx8802_fh *fh = file->private_data; + struct cx8802_fh *fh = priv; return cx8802_buf_prepare(fh->dev, (struct cx88_buffer*)vb); } static void -bb_buf_queue(struct file *file, struct videobuf_buffer *vb) +bb_buf_queue(void *priv, struct videobuf_buffer *vb) { - struct cx8802_fh *fh = file->private_data; + struct cx8802_fh *fh = priv; cx8802_buf_queue(fh->dev, (struct cx88_buffer*)vb); } -static void bb_buf_release(struct file *file, struct videobuf_buffer *vb) +static void bb_buf_release(void *priv, struct videobuf_buffer *vb) { - struct cx8802_fh *fh = file->private_data; + struct cx8802_fh *fh = priv; cx88_free_buffer(fh->dev->pci, (struct cx88_buffer*)vb); } @@ -635,22 +635,23 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, /* --- streaming capture ------------------------------------- */ case VIDIOC_REQBUFS: - return videobuf_reqbufs(file, &fh->mpegq, arg); + return videobuf_reqbufs(file->private_data, &fh->mpegq, arg); case VIDIOC_QUERYBUF: return videobuf_querybuf(&fh->mpegq, arg); case VIDIOC_QBUF: - return videobuf_qbuf(file, &fh->mpegq, arg); + return videobuf_qbuf(file->private_data, &fh->mpegq, arg); case VIDIOC_DQBUF: - return videobuf_dqbuf(file, &fh->mpegq, arg); + return videobuf_dqbuf(file->private_data, &fh->mpegq, arg, + file->f_flags & O_NONBLOCK); case VIDIOC_STREAMON: - return videobuf_streamon(file, &fh->mpegq); + return videobuf_streamon(file->private_data, &fh->mpegq); case VIDIOC_STREAMOFF: - return videobuf_streamoff(file, &fh->mpegq); + return videobuf_streamoff(file->private_data, &fh->mpegq); default: return -EINVAL; @@ -709,9 +710,9 @@ static int mpeg_release(struct inode *inode, struct file *file) /* stop mpeg capture */ if (fh->mpegq.streaming) - videobuf_streamoff(file,&fh->mpegq); + videobuf_streamoff(file->private_data,&fh->mpegq); if (fh->mpegq.reading) - videobuf_read_stop(file,&fh->mpegq); + videobuf_read_stop(file->private_data,&fh->mpegq); file->private_data = NULL; kfree(fh); @@ -723,7 +724,9 @@ mpeg_read(struct file *file, char *data, size_t count, loff_t *ppos) { struct cx8802_fh *fh = file->private_data; - return videobuf_read_stream(file, &fh->mpegq, data, count, ppos, 0); + return videobuf_read_stream(file->private_data, + &fh->mpegq, data, count, ppos, 0, + file->f_flags & O_NONBLOCK); } static unsigned int @@ -731,7 +734,7 @@ mpeg_poll(struct file *file, struct poll_table_struct *wait) { struct cx8802_fh *fh = file->private_data; - return videobuf_poll_stream(file, &fh->mpegq, wait); + return videobuf_poll_stream(file->private_data, &fh->mpegq, wait); } static int diff --git a/linux/drivers/media/video/cx88/cx88-cards.c b/linux/drivers/media/video/cx88/cx88-cards.c index ac5c20451..2caf7155b 100644 --- a/linux/drivers/media/video/cx88/cx88-cards.c +++ b/linux/drivers/media/video/cx88/cx88-cards.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-cards.c,v 1.40 2004/09/22 11:47:11 kraxel Exp $ + * $Id: cx88-cards.c,v 1.41 2004/09/23 13:58:19 kraxel Exp $ * * device driver for Conexant 2388x based TV cards * card-specific stuff. @@ -27,6 +27,7 @@ #include <linux/delay.h> #include "cx88.h" +#include "cx22702.h" /* ------------------------------------------------------------------ */ /* board config info */ @@ -631,6 +632,49 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) core->tuner_type, radio ? "yes" : "no"); } +static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee) +{ + int model; + int tuner; + char *tname; + + /* Make sure we support the board model */ + model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c]; + switch(model) { + case 90002: + case 90500: + case 90501: + /* known */ + break; + default: + printk("%s: warning: unknown hauppauge model #%d\n", + core->name, model); + break; + } + + /* Make sure we support the tuner */ + tuner = ee[0x2d]; + switch(tuner) { + case 0x4B: + tname = "Thomson DTT 7595"; + core->pll_type = PLLTYPE_DTT7595; + break; + case 0x4C: + tname = "Thomson DTT 7592"; + core->pll_type = PLLTYPE_DTT7592; + break; + default: + printk("%s: error: unknown hauppauge tuner 0x%02x\n", + core->name, tuner); + return -ENODEV; + } + printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%s (%d)\n", + core->name, model, tname, tuner); + + core->pll_addr = 0x61; + core->demod_addr = 0x43; +} + /* ----------------------------------------------------------------------- */ /* some GDI (was: Modular Technology) specific stuff */ @@ -743,7 +787,6 @@ void cx88_card_list(struct cx88_core *core, struct pci_dev *pci) void cx88_card_setup(struct cx88_core *core) { static u8 eeprom[128]; - char *frontend = NULL; switch (core->board) { case CX88_BOARD_HAUPPAUGE: @@ -767,15 +810,18 @@ void cx88_card_setup(struct cx88_core *core) cx_clear(MO_GP0_IO, 0x00000001); msleep(1); cx_set(MO_GP0_IO, 0x00000101); - frontend = "mt352"; break; case CX88_BOARD_HAUPPAUGE_DVB_T1: + if (0 == core->i2c_rc) + i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom)); + hauppauge_eeprom_dvb(core,eeprom); + break; case CX88_BOARD_CONEXANT_DVB_T1: - frontend = "cx22702"; + core->pll_type = PLLTYPE_DTT7579; + core->pll_addr = 0x60; + core->demod_addr = 0x43; break; } - if (frontend) - request_module(frontend); if (cx88_boards[core->board].radio.type == CX88_RADIO) core->has_radio = 1; } diff --git a/linux/drivers/media/video/cx88/cx88-dvb.c b/linux/drivers/media/video/cx88/cx88-dvb.c index 598b0e601..fa5cb5eb6 100644 --- a/linux/drivers/media/video/cx88/cx88-dvb.c +++ b/linux/drivers/media/video/cx88/cx88-dvb.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-dvb.c,v 1.9 2004/09/15 16:15:24 kraxel Exp $ + * $Id: cx88-dvb.c,v 1.10 2004/09/23 13:58:19 kraxel Exp $ * * device driver for Conexant 2388x based TV cards * MPEG Transport Stream (DVB) routines @@ -30,6 +30,7 @@ #include <linux/file.h> #include "cx88.h" +#include "cx22702.h" MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); @@ -45,9 +46,9 @@ MODULE_PARM_DESC(debug,"enable debug messages [dvb]"); /* ------------------------------------------------------------------ */ -static int dvb_buf_setup(struct file *file, unsigned int *count, unsigned int *size) +static int dvb_buf_setup(void *priv, unsigned int *count, unsigned int *size) { - struct cx8802_dev *dev = file->private_data; + struct cx8802_dev *dev = priv; dev->ts_packet_size = 188 * 4; dev->ts_packet_count = 32; @@ -57,22 +58,22 @@ static int dvb_buf_setup(struct file *file, unsigned int *count, unsigned int *s return 0; } -static int dvb_buf_prepare(struct file *file, struct videobuf_buffer *vb, +static int dvb_buf_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { - struct cx8802_dev *dev = file->private_data; + struct cx8802_dev *dev = priv; return cx8802_buf_prepare(dev, (struct cx88_buffer*)vb); } -static void dvb_buf_queue(struct file *file, struct videobuf_buffer *vb) +static void dvb_buf_queue(void *priv, struct videobuf_buffer *vb) { - struct cx8802_dev *dev = file->private_data; + struct cx8802_dev *dev = priv; cx8802_buf_queue(dev, (struct cx88_buffer*)vb); } -static void dvb_buf_release(struct file *file, struct videobuf_buffer *vb) +static void dvb_buf_release(void *priv, struct videobuf_buffer *vb) { - struct cx8802_dev *dev = file->private_data; + struct cx8802_dev *dev = priv; cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb); } @@ -87,14 +88,11 @@ static int dvb_thread(void *data) { struct cx8802_dev *dev = data; struct videobuf_buffer *buf; - struct file *file; unsigned long flags; int err; dprintk(1,"dvb thread started\n"); - file = get_empty_filp(); - file->private_data = dev; - videobuf_read_start(file, &dev->dvbq); + videobuf_read_start(dev, &dev->dvbq); for (;;) { /* fetch next buffer */ @@ -118,7 +116,7 @@ static int dvb_thread(void *data) /* requeue buffer */ list_add_tail(&buf->stream,&dev->dvbq.stream); spin_lock_irqsave(dev->dvbq.irqlock,flags); - dev->dvbq.ops->buf_queue(file,buf); + dev->dvbq.ops->buf_queue(dev,buf); spin_unlock_irqrestore(dev->dvbq.irqlock,flags); /* log errors if any */ @@ -136,8 +134,7 @@ static int dvb_thread(void *data) } } - videobuf_read_stop(file, &dev->dvbq); - put_filp(file); + videobuf_read_stop(dev, &dev->dvbq); dprintk(1,"dvb thread stopped\n"); /* Hmm, linux becomes *very* unhappy without this ... */ @@ -212,9 +209,9 @@ static void dvb_unregister(struct cx8802_dev *dev) dev->demux.dmx.remove_frontend(&dev->demux.dmx, &dev->fe_hw); dvb_dmxdev_release(&dev->dmxdev); dvb_dmx_release(&dev->demux); - cx88_call_i2c_clients(dev->core, FE_UNREGISTER, dev->core->dvb_adapter); - dvb_unregister_adapter(dev->core->dvb_adapter); - dev->core->dvb_adapter = NULL; + if (dev->fe_handle) + dev->fe_release(dev->fe_handle); + dvb_unregister_adapter(dev->dvb_adapter); return; } @@ -222,15 +219,33 @@ static int dvb_register(struct cx8802_dev *dev) { int result; - result = dvb_register_adapter(&dev->core->dvb_adapter, dev->core->name, + /* adapter */ + result = dvb_register_adapter(&dev->dvb_adapter, dev->core->name, THIS_MODULE); if (result < 0) { printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", dev->core->name, result); goto fail1; } - cx88_call_i2c_clients(dev->core, FE_REGISTER, dev->core->dvb_adapter); + /* frontend */ + switch (dev->core->board) { + case CX88_BOARD_HAUPPAUGE_DVB_T1: + case CX88_BOARD_CONEXANT_DVB_T1: + dev->fe_handle = cx22702_create(&dev->core->i2c_adap, + dev->dvb_adapter, + dev->core->pll_addr, + dev->core->pll_type, + dev->core->demod_addr); + dev->fe_release = cx22702_destroy; + break; + default: + printk("%s: FIXME: frontend handing not here yet ...\n", + dev->core->name); + break; + } + + /* demux */ dev->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING; @@ -249,7 +264,7 @@ static int dvb_register(struct cx8802_dev *dev) dev->dmxdev.filternum = 256; dev->dmxdev.demux = &dev->demux.dmx; dev->dmxdev.capabilities = 0; - result = dvb_dmxdev_init(&dev->dmxdev, dev->core->dvb_adapter); + result = dvb_dmxdev_init(&dev->dmxdev, dev->dvb_adapter); if (result < 0) { printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", dev->core->name, result); @@ -279,7 +294,7 @@ static int dvb_register(struct cx8802_dev *dev) goto fail6; } - dvb_net_init(dev->core->dvb_adapter, &dev->dvbnet, &dev->demux.dmx); + dvb_net_init(dev->dvb_adapter, &dev->dvbnet, &dev->demux.dmx); return 0; fail6: @@ -291,8 +306,7 @@ fail4: fail3: dvb_dmx_release(&dev->demux); fail2: - cx88_call_i2c_clients(dev->core, FE_UNREGISTER, dev->core->dvb_adapter); - dvb_unregister_adapter(dev->core->dvb_adapter); + dvb_unregister_adapter(dev->dvb_adapter); fail1: return result; } diff --git a/linux/drivers/media/video/cx88/cx88-i2c.c b/linux/drivers/media/video/cx88/cx88-i2c.c index 64590c5cb..da49619c0 100644 --- a/linux/drivers/media/video/cx88/cx88-i2c.c +++ b/linux/drivers/media/video/cx88/cx88-i2c.c @@ -1,5 +1,5 @@ /* - $Id: cx88-i2c.c,v 1.13 2004/09/20 11:39:43 kraxel Exp $ + $Id: cx88-i2c.c,v 1.14 2004/09/23 13:58:19 kraxel Exp $ cx88-i2c.c -- all the i2c code is here @@ -88,7 +88,8 @@ static int attach_inform(struct i2c_client *client) { struct cx88_core *core = i2c_get_adapdata(client->adapter); - dprintk(1, "i2c attach [client=%s]\n", i2c_clientname(client)); + dprintk(1, "i2c attach [addr=0x%x,client=%s]\n", + client->addr, i2c_clientname(client)); if (!client->driver->command) return 0; @@ -96,9 +97,6 @@ static int attach_inform(struct i2c_client *client) client->driver->command(client, TUNER_SET_TYPE, &core->tuner_type); if (core->tda9887_conf) client->driver->command(client, TDA9887_SET_CONFIG, &core->tda9887_conf); - if (core->dvb_adapter) - client->driver->command(client, FE_REGISTER, core->dvb_adapter); - return 0; } @@ -106,17 +104,6 @@ static int detach_inform(struct i2c_client *client) { struct cx88_core *core = i2c_get_adapdata(client->adapter); -#if 0 - /* FIXME: should switch to cx88_call_i2c_clients */ - /* FIXME: drop FE_UNREGISTER altogether in favor of using - * i2c_driver->detach_client() ??? */ - if (core->dvb_adapter && client->driver->command) { - dprintk(1, "i2c detach [client=%s] dvb_adapter %p\n", - i2c_clientname(client), core->dvb_adapter); - return client->driver->command(client, FE_UNREGISTER, core->dvb_adapter); - } -#endif - dprintk(1, "i2c detach [client=%s]\n", i2c_clientname(client)); return 0; } diff --git a/linux/drivers/media/video/cx88/cx88-vbi.c b/linux/drivers/media/video/cx88/cx88-vbi.c index f7b791bc9..ca2d70e55 100644 --- a/linux/drivers/media/video/cx88/cx88-vbi.c +++ b/linux/drivers/media/video/cx88/cx88-vbi.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-vbi.c,v 1.9 2004/09/15 16:15:24 kraxel Exp $ + * $Id: cx88-vbi.c,v 1.10 2004/09/23 13:58:19 kraxel Exp $ */ #include <linux/kernel.h> #include <linux/module.h> @@ -127,7 +127,7 @@ void cx8800_vbi_timeout(unsigned long data) /* ------------------------------------------------------------------ */ static int -vbi_setup(struct file *file, unsigned int *count, unsigned int *size) +vbi_setup(void *priv, unsigned int *count, unsigned int *size) { *size = VBI_LINE_COUNT * VBI_LINE_LENGTH * 2; if (0 == *count) @@ -140,10 +140,10 @@ vbi_setup(struct file *file, unsigned int *count, unsigned int *size) } static int -vbi_prepare(struct file *file, struct videobuf_buffer *vb, +vbi_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { - struct cx8800_fh *fh = file->private_data; + struct cx8800_fh *fh = priv; struct cx8800_dev *dev = fh->dev; struct cx88_buffer *buf = (struct cx88_buffer*)vb; unsigned int size; @@ -176,11 +176,11 @@ vbi_prepare(struct file *file, struct videobuf_buffer *vb, } static void -vbi_queue(struct file *file, struct videobuf_buffer *vb) +vbi_queue(void *priv, struct videobuf_buffer *vb) { struct cx88_buffer *buf = (struct cx88_buffer*)vb; struct cx88_buffer *prev; - struct cx8800_fh *fh = file->private_data; + struct cx8800_fh *fh = priv; struct cx8800_dev *dev = fh->dev; struct cx88_dmaqueue *q = &dev->vbiq; @@ -208,10 +208,10 @@ vbi_queue(struct file *file, struct videobuf_buffer *vb) } } -static void vbi_release(struct file *file, struct videobuf_buffer *vb) +static void vbi_release(void *priv, struct videobuf_buffer *vb) { struct cx88_buffer *buf = (struct cx88_buffer*)vb; - struct cx8800_fh *fh = file->private_data; + struct cx8800_fh *fh = priv; cx88_free_buffer(fh->dev->pci,buf); } diff --git a/linux/drivers/media/video/cx88/cx88-video.c b/linux/drivers/media/video/cx88/cx88-video.c index f425d73f3..e775965f9 100644 --- a/linux/drivers/media/video/cx88/cx88-video.c +++ b/linux/drivers/media/video/cx88/cx88-video.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-video.c,v 1.34 2004/08/31 11:58:53 kraxel Exp $ + * $Id: cx88-video.c,v 1.35 2004/09/23 13:58:19 kraxel Exp $ * * device driver for Conexant 2388x based TV cards * video4linux video interface @@ -495,9 +495,9 @@ static int restart_video_queue(struct cx8800_dev *dev, /* ------------------------------------------------------------------ */ static int -buffer_setup(struct file *file, unsigned int *count, unsigned int *size) +buffer_setup(void *priv, unsigned int *count, unsigned int *size) { - struct cx8800_fh *fh = file->private_data; + struct cx8800_fh *fh = priv; *size = fh->fmt->depth*fh->width*fh->height >> 3; if (0 == *count) @@ -508,10 +508,10 @@ buffer_setup(struct file *file, unsigned int *count, unsigned int *size) } static int -buffer_prepare(struct file *file, struct videobuf_buffer *vb, +buffer_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { - struct cx8800_fh *fh = file->private_data; + struct cx8800_fh *fh = priv; struct cx8800_dev *dev = fh->dev; struct cx88_buffer *buf = (struct cx88_buffer*)vb; int rc, init_buffer = 0; @@ -592,11 +592,11 @@ buffer_prepare(struct file *file, struct videobuf_buffer *vb, } static void -buffer_queue(struct file *file, struct videobuf_buffer *vb) +buffer_queue(void *priv, struct videobuf_buffer *vb) { struct cx88_buffer *buf = (struct cx88_buffer*)vb; struct cx88_buffer *prev; - struct cx8800_fh *fh = file->private_data; + struct cx8800_fh *fh = priv; struct cx8800_dev *dev = fh->dev; struct cx88_dmaqueue *q = &dev->vidq; @@ -640,10 +640,10 @@ buffer_queue(struct file *file, struct videobuf_buffer *vb) } } -static void buffer_release(struct file *file, struct videobuf_buffer *vb) +static void buffer_release(void *priv, struct videobuf_buffer *vb) { struct cx88_buffer *buf = (struct cx88_buffer*)vb; - struct cx8800_fh *fh = file->private_data; + struct cx8800_fh *fh = priv; cx88_free_buffer(fh->dev->pci,buf); } @@ -994,11 +994,15 @@ video_read(struct file *file, char *data, size_t count, loff_t *ppos) case V4L2_BUF_TYPE_VIDEO_CAPTURE: if (res_locked(fh->dev,RESOURCE_VIDEO)) return -EBUSY; - return videobuf_read_one(file, &fh->vidq, data, count, ppos); + return videobuf_read_one(file->private_data, + &fh->vidq, data, count, ppos, + file->f_flags & O_NONBLOCK); case V4L2_BUF_TYPE_VBI_CAPTURE: if (!res_get(fh->dev,fh,RESOURCE_VBI)) return -EBUSY; - return videobuf_read_stream(file, &fh->vbiq, data, count, ppos, 1); + return videobuf_read_stream(file->private_data, + &fh->vbiq, data, count, ppos, 1, + file->f_flags & O_NONBLOCK); default: BUG(); return 0; @@ -1011,7 +1015,7 @@ video_poll(struct file *file, struct poll_table_struct *wait) struct cx8800_fh *fh = file->private_data; if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) - return videobuf_poll_stream(file, &fh->vbiq, wait); + return videobuf_poll_stream(file->private_data, &fh->vbiq, wait); /* FIXME */ return POLLERR; @@ -1030,20 +1034,20 @@ static int video_release(struct inode *inode, struct file *file) /* stop video capture */ if (res_check(fh, RESOURCE_VIDEO)) { - videobuf_queue_cancel(file,&fh->vidq); + videobuf_queue_cancel(file->private_data,&fh->vidq); res_free(dev,fh,RESOURCE_VIDEO); } if (fh->vidq.read_buf) { - buffer_release(file,fh->vidq.read_buf); + buffer_release(file->private_data,fh->vidq.read_buf); kfree(fh->vidq.read_buf); } /* stop vbi capture */ if (res_check(fh, RESOURCE_VBI)) { if (fh->vbiq.streaming) - videobuf_streamoff(file,&fh->vbiq); + videobuf_streamoff(file->private_data,&fh->vbiq); if (fh->vbiq.reading) - videobuf_read_stop(file,&fh->vbiq); + videobuf_read_stop(file->private_data,&fh->vbiq); res_free(dev,fh,RESOURCE_VBI); } @@ -1576,7 +1580,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file, req.type = q->type; req.count = 8; req.memory = V4L2_MEMORY_MMAP; - err = videobuf_reqbufs(file,q,&req); + err = videobuf_reqbufs(file->private_data,q,&req); if (err < 0) return err; memset(mbuf,0,sizeof(*mbuf)); @@ -1589,16 +1593,17 @@ static int video_do_ioctl(struct inode *inode, struct file *file, return 0; } case VIDIOC_REQBUFS: - return videobuf_reqbufs(file, get_queue(fh), arg); + return videobuf_reqbufs(file->private_data, get_queue(fh), arg); case VIDIOC_QUERYBUF: return videobuf_querybuf(get_queue(fh), arg); case VIDIOC_QBUF: - return videobuf_qbuf(file, get_queue(fh), arg); + return videobuf_qbuf(file->private_data, get_queue(fh), arg); case VIDIOC_DQBUF: - return videobuf_dqbuf(file, get_queue(fh), arg); + return videobuf_dqbuf(file->private_data, get_queue(fh), arg, + file->f_flags & O_NONBLOCK); case VIDIOC_STREAMON: { @@ -1606,13 +1611,13 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (!res_get(dev,fh,res)) return -EBUSY; - return videobuf_streamon(file, get_queue(fh)); + return videobuf_streamon(file->private_data, get_queue(fh)); } case VIDIOC_STREAMOFF: { int res = get_ressource(fh); - err = videobuf_streamoff(file, get_queue(fh)); + err = videobuf_streamoff(file->private_data, get_queue(fh)); if (err < 0) return err; res_free(dev,fh,res); diff --git a/linux/drivers/media/video/cx88/cx88.h b/linux/drivers/media/video/cx88/cx88.h index d20a2b44f..f14f2a715 100644 --- a/linux/drivers/media/video/cx88/cx88.h +++ b/linux/drivers/media/video/cx88/cx88.h @@ -1,5 +1,5 @@ /* - * $Id: cx88.h,v 1.34 2004/09/20 11:53:23 kraxel Exp $ + * $Id: cx88.h,v 1.35 2004/09/23 13:58:19 kraxel Exp $ * * v4l2 device driver for cx2388x based TV cards * @@ -60,12 +60,6 @@ #define CX88_MAXBOARDS 8 -/* temporary here until new dvb-kernel code is merged ... */ -#ifndef FE_REGISTER -# define FE_REGISTER _IO ('v', 84) -# define FE_UNREGISTER _IO ('v', 85) -#endif - /* ----------------------------------------------------------- */ /* defines and enums */ @@ -263,21 +257,23 @@ struct cx88_core { struct i2c_client i2c_client; u32 i2c_state, i2c_rc; - /* config info */ + /* config info -- analog */ unsigned int board; unsigned int tuner_type; unsigned int tda9887_conf; unsigned int has_radio; + /* config info -- dvb */ + unsigned int pll_type; + unsigned int pll_addr; + unsigned int demod_addr; + /* state info */ struct task_struct *kthread; struct cx88_tvnorm *tvnorm; u32 tvaudio; u32 input; u32 astat; - - /* used by cx88-dvb -- i2c code needs access to this for FE register */ - struct dvb_adapter *dvb_adapter; }; struct cx8800_dev; @@ -388,6 +384,7 @@ struct cx8802_dev { u32 mailbox; /* for dvb only */ + struct dvb_adapter *dvb_adapter; struct videobuf_queue dvbq; struct task_struct *dvb_thread; struct dvb_demux demux; @@ -396,6 +393,8 @@ struct cx8802_dev { struct dmx_frontend fe_mem; struct dvb_net dvbnet; int nfeeds; + void* fe_handle; + int (*fe_release)(void *handle); }; /* ----------------------------------------------------------- */ diff --git a/linux/drivers/media/video/saa7134/saa7134-ts.c b/linux/drivers/media/video/saa7134/saa7134-ts.c index 265ba86aa..2df96839a 100644 --- a/linux/drivers/media/video/saa7134/saa7134-ts.c +++ b/linux/drivers/media/video/saa7134/saa7134-ts.c @@ -1,5 +1,5 @@ /* - * $Id: saa7134-ts.c,v 1.7 2004/09/15 16:15:24 kraxel Exp $ + * $Id: saa7134-ts.c,v 1.8 2004/09/23 13:58:19 kraxel Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface @@ -94,10 +94,10 @@ static int buffer_activate(struct saa7134_dev *dev, return 0; } -static int buffer_prepare(struct file *file, struct videobuf_buffer *vb, +static int buffer_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { - struct saa7134_dev *dev = file->private_data; + struct saa7134_dev *dev = priv; struct saa7134_buf *buf = (struct saa7134_buf *)vb; unsigned int lines, llength, size; int err; @@ -142,7 +142,7 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb, } static int -buffer_setup(struct file *file, unsigned int *count, unsigned int *size) +buffer_setup(void *priv, unsigned int *count, unsigned int *size) { *size = TS_PACKET_SIZE * ts_nr_packets; if (0 == *count) @@ -151,17 +151,17 @@ buffer_setup(struct file *file, unsigned int *count, unsigned int *size) return 0; } -static void buffer_queue(struct file *file, struct videobuf_buffer *vb) +static void buffer_queue(void *priv, struct videobuf_buffer *vb) { - struct saa7134_dev *dev = file->private_data; + struct saa7134_dev *dev = priv; struct saa7134_buf *buf = (struct saa7134_buf *)vb; saa7134_buffer_queue(dev,&dev->ts_q,buf); } -static void buffer_release(struct file *file, struct videobuf_buffer *vb) +static void buffer_release(void *priv, struct videobuf_buffer *vb) { - struct saa7134_dev *dev = file->private_data; + struct saa7134_dev *dev = priv; struct saa7134_buf *buf = (struct saa7134_buf *)vb; saa7134_dma_free(dev,buf); @@ -231,10 +231,10 @@ static int ts_release(struct inode *inode, struct file *file) struct saa7134_dev *dev = file->private_data; if (dev->ts.ts.streaming) - videobuf_streamoff(file,&dev->ts.ts); + videobuf_streamoff(file->private_data,&dev->ts.ts); down(&dev->ts.ts.lock); if (dev->ts.ts.reading) - videobuf_read_stop(file,&dev->ts.ts); + videobuf_read_stop(file->private_data,&dev->ts.ts); dev->ts.users--; /* stop the encoder */ @@ -255,7 +255,9 @@ ts_read(struct file *file, char __user *data, size_t count, loff_t *ppos) dev->ts.started = 1; } - return videobuf_read_stream(file, &dev->ts.ts, data, count, ppos, 0); + return videobuf_read_stream(file->private_data, + &dev->ts.ts, data, count, ppos, 0, + file->f_flags & O_NONBLOCK); } static unsigned int @@ -263,7 +265,7 @@ ts_poll(struct file *file, struct poll_table_struct *wait) { struct saa7134_dev *dev = file->private_data; - return videobuf_poll_stream(file, &dev->ts.ts, wait); + return videobuf_poll_stream(file->private_data, &dev->ts.ts, wait); } @@ -392,22 +394,23 @@ static int ts_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_REQBUFS: - return videobuf_reqbufs(file,&dev->ts.ts,arg); + return videobuf_reqbufs(file->private_data,&dev->ts.ts,arg); case VIDIOC_QUERYBUF: return videobuf_querybuf(&dev->ts.ts,arg); case VIDIOC_QBUF: - return videobuf_qbuf(file,&dev->ts.ts,arg); + return videobuf_qbuf(file->private_data,&dev->ts.ts,arg); case VIDIOC_DQBUF: - return videobuf_dqbuf(file,&dev->ts.ts,arg); + return videobuf_dqbuf(file->private_data,&dev->ts.ts,arg, + file->f_flags & O_NONBLOCK); case VIDIOC_STREAMON: - return videobuf_streamon(file,&dev->ts.ts); + return videobuf_streamon(file->private_data,&dev->ts.ts); case VIDIOC_STREAMOFF: - return videobuf_streamoff(file,&dev->ts.ts); + return videobuf_streamoff(file->private_data,&dev->ts.ts); case VIDIOC_QUERYCTRL: case VIDIOC_G_CTRL: diff --git a/linux/drivers/media/video/saa7134/saa7134-vbi.c b/linux/drivers/media/video/saa7134/saa7134-vbi.c index 01f77e2cc..312da9bf7 100644 --- a/linux/drivers/media/video/saa7134/saa7134-vbi.c +++ b/linux/drivers/media/video/saa7134/saa7134-vbi.c @@ -1,5 +1,5 @@ /* - * $Id: saa7134-vbi.c,v 1.2 2004/09/15 16:15:24 kraxel Exp $ + * $Id: saa7134-vbi.c,v 1.3 2004/09/23 13:58:19 kraxel Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface @@ -115,10 +115,10 @@ static int buffer_activate(struct saa7134_dev *dev, return 0; } -static int buffer_prepare(struct file *file, struct videobuf_buffer *vb, +static int buffer_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { - struct saa7134_fh *fh = file->private_data; + struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; struct saa7134_buf *buf = (struct saa7134_buf *)vb; struct saa7134_tvnorm *norm = dev->tvnorm; @@ -169,9 +169,9 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb, } static int -buffer_setup(struct file *file, unsigned int *count, unsigned int *size) +buffer_setup(void *priv, unsigned int *count, unsigned int *size) { - struct saa7134_fh *fh = file->private_data; + struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; int llength,lines; @@ -190,18 +190,18 @@ buffer_setup(struct file *file, unsigned int *count, unsigned int *size) return 0; } -static void buffer_queue(struct file *file, struct videobuf_buffer *vb) +static void buffer_queue(void *priv, struct videobuf_buffer *vb) { - struct saa7134_fh *fh = file->private_data; + struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; struct saa7134_buf *buf = (struct saa7134_buf *)vb; saa7134_buffer_queue(dev,&dev->vbi_q,buf); } -static void buffer_release(struct file *file, struct videobuf_buffer *vb) +static void buffer_release(void *priv, struct videobuf_buffer *vb) { - struct saa7134_fh *fh = file->private_data; + struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; struct saa7134_buf *buf = (struct saa7134_buf *)vb; diff --git a/linux/drivers/media/video/saa7134/saa7134-video.c b/linux/drivers/media/video/saa7134/saa7134-video.c index 210836a92..14cfff8d7 100644 --- a/linux/drivers/media/video/saa7134/saa7134-video.c +++ b/linux/drivers/media/video/saa7134/saa7134-video.c @@ -1,5 +1,5 @@ /* - * $Id: saa7134-video.c,v 1.13 2004/09/15 16:15:24 kraxel Exp $ + * $Id: saa7134-video.c,v 1.14 2004/09/23 13:58:19 kraxel Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface @@ -918,10 +918,10 @@ static int buffer_activate(struct saa7134_dev *dev, return 0; } -static int buffer_prepare(struct file *file, struct videobuf_buffer *vb, +static int buffer_prepare(void *priv, struct videobuf_buffer *vb, enum v4l2_field field) { - struct saa7134_fh *fh = file->private_data; + struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; struct saa7134_buf *buf = (struct saa7134_buf *)vb; unsigned int size; @@ -980,9 +980,9 @@ static int buffer_prepare(struct file *file, struct videobuf_buffer *vb, } static int -buffer_setup(struct file *file, unsigned int *count, unsigned int *size) +buffer_setup(void *priv, unsigned int *count, unsigned int *size) { - struct saa7134_fh *fh = file->private_data; + struct saa7134_fh *fh = priv; *size = fh->fmt->depth * fh->width * fh->height >> 3; if (0 == *count) @@ -991,17 +991,17 @@ buffer_setup(struct file *file, unsigned int *count, unsigned int *size) return 0; } -static void buffer_queue(struct file *file, struct videobuf_buffer *vb) +static void buffer_queue(void *priv, struct videobuf_buffer *vb) { - struct saa7134_fh *fh = file->private_data; + struct saa7134_fh *fh = priv; struct saa7134_buf *buf = (struct saa7134_buf *)vb; saa7134_buffer_queue(fh->dev,&fh->dev->video_q,buf); } -static void buffer_release(struct file *file, struct videobuf_buffer *vb) +static void buffer_release(void *priv, struct videobuf_buffer *vb) { - struct saa7134_fh *fh = file->private_data; + struct saa7134_fh *fh = priv; struct saa7134_buf *buf = (struct saa7134_buf *)vb; saa7134_dma_free(fh->dev,buf); @@ -1271,13 +1271,15 @@ video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) case V4L2_BUF_TYPE_VIDEO_CAPTURE: if (res_locked(fh->dev,RESOURCE_VIDEO)) return -EBUSY; - return videobuf_read_one(file, saa7134_queue(fh), - data, count, ppos); + return videobuf_read_one(file->private_data, saa7134_queue(fh), + data, count, ppos, + file->f_flags & O_NONBLOCK); case V4L2_BUF_TYPE_VBI_CAPTURE: if (!res_get(fh->dev,fh,RESOURCE_VBI)) return -EBUSY; - return videobuf_read_stream(file, saa7134_queue(fh), - data, count, ppos, 1); + return videobuf_read_stream(file->private_data, saa7134_queue(fh), + data, count, ppos, 1, + file->f_flags & O_NONBLOCK); break; default: BUG(); @@ -1292,7 +1294,7 @@ video_poll(struct file *file, struct poll_table_struct *wait) struct videobuf_buffer *buf = NULL; if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) - return videobuf_poll_stream(file, &fh->vbi, wait); + return videobuf_poll_stream(file->private_data, &fh->vbi, wait); if (res_check(fh,RESOURCE_VIDEO)) { if (!list_empty(&fh->cap.stream)) @@ -1305,11 +1307,11 @@ video_poll(struct file *file, struct poll_table_struct *wait) up(&fh->cap.lock); return POLLERR; } - if (0 != fh->cap.ops->buf_prepare(file,fh->cap.read_buf,fh->cap.field)) { + if (0 != fh->cap.ops->buf_prepare(file->private_data,fh->cap.read_buf,fh->cap.field)) { up(&fh->cap.lock); return POLLERR; } - fh->cap.ops->buf_queue(file,fh->cap.read_buf); + fh->cap.ops->buf_queue(file->private_data,fh->cap.read_buf); fh->cap.read_off = 0; } up(&fh->cap.lock); @@ -1342,20 +1344,20 @@ static int video_release(struct inode *inode, struct file *file) /* stop video capture */ if (res_check(fh, RESOURCE_VIDEO)) { - videobuf_streamoff(file,&fh->cap); + videobuf_streamoff(file->private_data,&fh->cap); res_free(dev,fh,RESOURCE_VIDEO); } if (fh->cap.read_buf) { - buffer_release(file,fh->cap.read_buf); + buffer_release(file->private_data,fh->cap.read_buf); kfree(fh->cap.read_buf); } /* stop vbi capture */ if (res_check(fh, RESOURCE_VBI)) { if (fh->vbi.streaming) - videobuf_streamoff(file,&fh->vbi); + videobuf_streamoff(file->private_data,&fh->vbi); if (fh->vbi.reading) - videobuf_read_stop(file,&fh->vbi); + videobuf_read_stop(file->private_data,&fh->vbi); res_free(dev,fh,RESOURCE_VBI); } @@ -2031,7 +2033,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file, req.type = q->type; req.count = gbuffers; req.memory = V4L2_MEMORY_MMAP; - err = videobuf_reqbufs(file,q,&req); + err = videobuf_reqbufs(file->private_data,q,&req); if (err < 0) return err; memset(mbuf,0,sizeof(*mbuf)); @@ -2044,16 +2046,17 @@ static int video_do_ioctl(struct inode *inode, struct file *file, return 0; } case VIDIOC_REQBUFS: - return videobuf_reqbufs(file,saa7134_queue(fh),arg); + return videobuf_reqbufs(file->private_data,saa7134_queue(fh),arg); case VIDIOC_QUERYBUF: return videobuf_querybuf(saa7134_queue(fh),arg); case VIDIOC_QBUF: - return videobuf_qbuf(file,saa7134_queue(fh),arg); + return videobuf_qbuf(file->private_data,saa7134_queue(fh),arg); case VIDIOC_DQBUF: - return videobuf_dqbuf(file,saa7134_queue(fh),arg); + return videobuf_dqbuf(file->private_data,saa7134_queue(fh),arg, + file->f_flags & O_NONBLOCK); case VIDIOC_STREAMON: { @@ -2061,13 +2064,13 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (!res_get(dev,fh,res)) return -EBUSY; - return videobuf_streamon(file,saa7134_queue(fh)); + return videobuf_streamon(file->private_data,saa7134_queue(fh)); } case VIDIOC_STREAMOFF: { int res = saa7134_resource(fh); - err = videobuf_streamoff(file,saa7134_queue(fh)); + err = videobuf_streamoff(file->private_data,saa7134_queue(fh)); if (err < 0) return err; res_free(dev,fh,res); diff --git a/linux/drivers/media/video/video-buf.c b/linux/drivers/media/video/video-buf.c index f00a5b9a5..0758b1daf 100644 --- a/linux/drivers/media/video/video-buf.c +++ b/linux/drivers/media/video/video-buf.c @@ -1,5 +1,5 @@ /* - * $Id: video-buf.c,v 1.10 2004/09/15 16:15:24 kraxel Exp $ + * $Id: video-buf.c,v 1.11 2004/09/23 13:58:19 kraxel Exp $ * * generic helper functions for video4linux capture buffers, to handle * memory management and PCI DMA. Right now bttv + saa7134 use it. @@ -430,7 +430,7 @@ videobuf_queue_is_busy(struct videobuf_queue *q) } void -videobuf_queue_cancel(struct file *file, struct videobuf_queue *q) +videobuf_queue_cancel(void *priv, struct videobuf_queue *q) { unsigned long flags; int i; @@ -451,7 +451,7 @@ videobuf_queue_cancel(struct file *file, struct videobuf_queue *q) for (i = 0; i < VIDEO_MAX_FRAME; i++) { if (NULL == q->bufs[i]) continue; - q->ops->buf_release(file,q->bufs[i]); + q->ops->buf_release(priv,q->bufs[i]); } INIT_LIST_HEAD(&q->stream); } @@ -533,7 +533,7 @@ videobuf_status(struct v4l2_buffer *b, struct videobuf_buffer *vb, } int -videobuf_reqbufs(struct file *file, struct videobuf_queue *q, +videobuf_reqbufs(void *priv, struct videobuf_queue *q, struct v4l2_requestbuffers *req) { unsigned int size,count; @@ -558,12 +558,12 @@ videobuf_reqbufs(struct file *file, struct videobuf_queue *q, if (count > VIDEO_MAX_FRAME) count = VIDEO_MAX_FRAME; size = 0; - q->ops->buf_setup(file,&count,&size); + q->ops->buf_setup(priv,&count,&size); size = PAGE_ALIGN(size); dprintk(1,"reqbufs: bufs=%d, size=0x%x [%d pages total]\n", count, size, (count*size)>>PAGE_SHIFT); - retval = videobuf_mmap_setup(file,q,count,size,req->memory); + retval = videobuf_mmap_setup(priv,q,count,size,req->memory); if (retval < 0) goto done; @@ -588,7 +588,7 @@ videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) } int -videobuf_qbuf(struct file *file, struct videobuf_queue *q, +videobuf_qbuf(void *priv, struct videobuf_queue *q, struct v4l2_buffer *b) { struct videobuf_buffer *buf; @@ -632,7 +632,7 @@ videobuf_qbuf(struct file *file, struct videobuf_queue *q, if (b->length < buf->bsize) goto done; if (STATE_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr) - q->ops->buf_release(file,buf); + q->ops->buf_release(priv,buf); buf->baddr = b->m.userptr; break; case V4L2_MEMORY_OVERLAY: @@ -643,14 +643,14 @@ videobuf_qbuf(struct file *file, struct videobuf_queue *q, } field = videobuf_next_field(q); - retval = q->ops->buf_prepare(file,buf,field); + retval = q->ops->buf_prepare(priv,buf,field); if (0 != retval) goto done; list_add_tail(&buf->stream,&q->stream); if (q->streaming) { spin_lock_irqsave(q->irqlock,flags); - q->ops->buf_queue(file,buf); + q->ops->buf_queue(priv,buf); spin_unlock_irqrestore(q->irqlock,flags); } retval = 0; @@ -661,8 +661,8 @@ videobuf_qbuf(struct file *file, struct videobuf_queue *q, } int -videobuf_dqbuf(struct file *file, struct videobuf_queue *q, - struct v4l2_buffer *b) +videobuf_dqbuf(void *priv, struct videobuf_queue *q, + struct v4l2_buffer *b, int nonblocking) { struct videobuf_buffer *buf; int retval; @@ -677,7 +677,7 @@ videobuf_dqbuf(struct file *file, struct videobuf_queue *q, if (list_empty(&q->stream)) goto done; buf = list_entry(q->stream.next, struct videobuf_buffer, stream); - retval = videobuf_waiton(buf, file->f_flags & O_NONBLOCK, 1); + retval = videobuf_waiton(buf, nonblocking, 1); if (retval < 0) goto done; switch (buf->state) { @@ -701,7 +701,7 @@ videobuf_dqbuf(struct file *file, struct videobuf_queue *q, return retval; } -int videobuf_streamon(struct file *file, struct videobuf_queue *q) +int videobuf_streamon(void *priv, struct videobuf_queue *q) { struct videobuf_buffer *buf; struct list_head *list; @@ -720,7 +720,7 @@ int videobuf_streamon(struct file *file, struct videobuf_queue *q) list_for_each(list,&q->stream) { buf = list_entry(list, struct videobuf_buffer, stream); if (buf->state == STATE_PREPARED) - q->ops->buf_queue(file,buf); + q->ops->buf_queue(priv,buf); } spin_unlock_irqrestore(q->irqlock,flags); @@ -729,14 +729,14 @@ int videobuf_streamon(struct file *file, struct videobuf_queue *q) return retval; } -int videobuf_streamoff(struct file *file, struct videobuf_queue *q) +int videobuf_streamoff(void *priv, struct videobuf_queue *q) { int retval = -EINVAL; down(&q->lock); if (!q->streaming) goto done; - videobuf_queue_cancel(file,q); + videobuf_queue_cancel(priv,q); q->streaming = 0; retval = 0; @@ -746,7 +746,7 @@ int videobuf_streamoff(struct file *file, struct videobuf_queue *q) } static ssize_t -videobuf_read_zerocopy(struct file *file, struct videobuf_queue *q, +videobuf_read_zerocopy(void *priv, struct videobuf_queue *q, char __user *data, size_t count, loff_t *ppos) { enum v4l2_field field; @@ -763,13 +763,13 @@ videobuf_read_zerocopy(struct file *file, struct videobuf_queue *q, q->read_buf->baddr = (unsigned long)data; q->read_buf->bsize = count; field = videobuf_next_field(q); - retval = q->ops->buf_prepare(file,q->read_buf,field); + retval = q->ops->buf_prepare(priv,q->read_buf,field); if (0 != retval) goto done; /* start capture & wait */ spin_lock_irqsave(q->irqlock,flags); - q->ops->buf_queue(file,q->read_buf); + q->ops->buf_queue(priv,q->read_buf); spin_unlock_irqrestore(q->irqlock,flags); retval = videobuf_waiton(q->read_buf,0,0); if (0 == retval) { @@ -782,14 +782,15 @@ videobuf_read_zerocopy(struct file *file, struct videobuf_queue *q, done: /* cleanup */ - q->ops->buf_release(file,q->read_buf); + q->ops->buf_release(priv,q->read_buf); kfree(q->read_buf); q->read_buf = NULL; return retval; } -ssize_t videobuf_read_one(struct file *file, struct videobuf_queue *q, - char __user *data, size_t count, loff_t *ppos) +ssize_t videobuf_read_one(void *priv, struct videobuf_queue *q, + char __user *data, size_t count, loff_t *ppos, + int nonblocking) { enum v4l2_field field; unsigned long flags; @@ -799,11 +800,11 @@ ssize_t videobuf_read_one(struct file *file, struct videobuf_queue *q, down(&q->lock); nbufs = 1; size = 0; - q->ops->buf_setup(file,&nbufs,&size); + q->ops->buf_setup(priv,&nbufs,&size); if (NULL == q->read_buf && count >= size && - !(file->f_flags & O_NONBLOCK)) { - retval = videobuf_read_zerocopy(file,q,data,count,ppos); + !nonblocking) { + retval = videobuf_read_zerocopy(priv,q,data,count,ppos); if (retval >= 0 || retval == -EIO) /* ok, all done */ goto done; @@ -818,24 +819,24 @@ ssize_t videobuf_read_one(struct file *file, struct videobuf_queue *q, goto done; q->read_buf->memory = V4L2_MEMORY_USERPTR; field = videobuf_next_field(q); - retval = q->ops->buf_prepare(file,q->read_buf,field); + retval = q->ops->buf_prepare(priv,q->read_buf,field); if (0 != retval) goto done; spin_lock_irqsave(q->irqlock,flags); - q->ops->buf_queue(file,q->read_buf); + q->ops->buf_queue(priv,q->read_buf); spin_unlock_irqrestore(q->irqlock,flags); q->read_off = 0; } /* wait until capture is done */ - retval = videobuf_waiton(q->read_buf, file->f_flags & O_NONBLOCK, 1); + retval = videobuf_waiton(q->read_buf, nonblocking, 1); if (0 != retval) goto done; videobuf_dma_pci_sync(q->pci,&q->read_buf->dma); if (STATE_ERROR == q->read_buf->state) { /* catch I/O errors */ - q->ops->buf_release(file,q->read_buf); + q->ops->buf_release(priv,q->read_buf); kfree(q->read_buf); q->read_buf = NULL; retval = -EIO; @@ -854,7 +855,7 @@ ssize_t videobuf_read_one(struct file *file, struct videobuf_queue *q, q->read_off += bytes; if (q->read_off == q->read_buf->size) { /* all data copied, cleanup */ - q->ops->buf_release(file,q->read_buf); + q->ops->buf_release(priv,q->read_buf); kfree(q->read_buf); q->read_buf = NULL; } @@ -864,43 +865,43 @@ ssize_t videobuf_read_one(struct file *file, struct videobuf_queue *q, return retval; } -int videobuf_read_start(struct file *file, struct videobuf_queue *q) +int videobuf_read_start(void *priv, struct videobuf_queue *q) { enum v4l2_field field; unsigned long flags; int count = 0, size = 0; int err, i; - q->ops->buf_setup(file,&count,&size); + q->ops->buf_setup(priv,&count,&size); if (count < 2) count = 2; if (count > VIDEO_MAX_FRAME) count = VIDEO_MAX_FRAME; size = PAGE_ALIGN(size); - err = videobuf_mmap_setup(file, q, count, size, V4L2_MEMORY_USERPTR); + err = videobuf_mmap_setup(priv, q, count, size, V4L2_MEMORY_USERPTR); if (err) return err; for (i = 0; i < count; i++) { field = videobuf_next_field(q); - err = q->ops->buf_prepare(file,q->bufs[i],field); + err = q->ops->buf_prepare(priv,q->bufs[i],field); if (err) return err; list_add_tail(&q->bufs[i]->stream, &q->stream); } spin_lock_irqsave(q->irqlock,flags); for (i = 0; i < count; i++) - q->ops->buf_queue(file,q->bufs[i]); + q->ops->buf_queue(priv,q->bufs[i]); spin_unlock_irqrestore(q->irqlock,flags); q->reading = 1; return 0; } -void videobuf_read_stop(struct file *file, struct videobuf_queue *q) +void videobuf_read_stop(void *priv, struct videobuf_queue *q) { int i; - videobuf_queue_cancel(file,q); + videobuf_queue_cancel(priv,q); INIT_LIST_HEAD(&q->stream); for (i = 0; i < VIDEO_MAX_FRAME; i++) { if (NULL == q->bufs[i]) @@ -912,9 +913,9 @@ void videobuf_read_stop(struct file *file, struct videobuf_queue *q) q->reading = 0; } -ssize_t videobuf_read_stream(struct file *file, struct videobuf_queue *q, +ssize_t videobuf_read_stream(void *priv, struct videobuf_queue *q, char __user *data, size_t count, loff_t *ppos, - int vbihack) + int vbihack, int nonblocking) { unsigned int *fc, bytes; int err, retval; @@ -925,7 +926,7 @@ ssize_t videobuf_read_stream(struct file *file, struct videobuf_queue *q, if (q->streaming) goto done; if (!q->reading) { - retval = videobuf_read_start(file,q); + retval = videobuf_read_start(priv,q); if (retval < 0) goto done; } @@ -940,8 +941,7 @@ ssize_t videobuf_read_stream(struct file *file, struct videobuf_queue *q, list_del(&q->read_buf->stream); q->read_off = 0; } - err = videobuf_waiton(q->read_buf, - file->f_flags & O_NONBLOCK,1); + err = videobuf_waiton(q->read_buf, nonblocking, 1); if (err < 0) { if (0 == retval) retval = err; @@ -986,7 +986,7 @@ ssize_t videobuf_read_stream(struct file *file, struct videobuf_queue *q, list_add_tail(&q->read_buf->stream, &q->stream); spin_lock_irqsave(q->irqlock,flags); - q->ops->buf_queue(file,q->read_buf); + q->ops->buf_queue(priv,q->read_buf); spin_unlock_irqrestore(q->irqlock,flags); q->read_buf = NULL; } @@ -999,7 +999,7 @@ ssize_t videobuf_read_stream(struct file *file, struct videobuf_queue *q, return retval; } -unsigned int videobuf_poll_stream(struct file *file, +unsigned int videobuf_poll_stream(void *priv, struct videobuf_queue *q, poll_table *wait) { @@ -1013,7 +1013,7 @@ unsigned int videobuf_poll_stream(struct file *file, struct videobuf_buffer, stream); } else { if (!q->reading) - videobuf_read_start(file,q); + videobuf_read_start(priv,q); if (!q->reading) { rc = POLLERR; } else if (NULL == q->read_buf) { @@ -1029,7 +1029,7 @@ unsigned int videobuf_poll_stream(struct file *file, rc = POLLERR; if (0 == rc) { - poll_wait(file, &buf->done, wait); + poll_wait(priv, &buf->done, wait); if (buf->state == STATE_DONE || buf->state == STATE_ERROR) rc = POLLIN|POLLRDNORM; @@ -1123,14 +1123,14 @@ static struct vm_operations_struct videobuf_vm_ops = .nopage = videobuf_vm_nopage, }; -int videobuf_mmap_setup(struct file *file, struct videobuf_queue *q, +int videobuf_mmap_setup(void *priv, struct videobuf_queue *q, unsigned int bcount, unsigned int bsize, enum v4l2_memory memory) { unsigned int i; int err; - err = videobuf_mmap_free(file,q); + err = videobuf_mmap_free(priv,q); if (0 != err) return err; @@ -1155,7 +1155,7 @@ int videobuf_mmap_setup(struct file *file, struct videobuf_queue *q, return 0; } -int videobuf_mmap_free(struct file *file, struct videobuf_queue *q) +int videobuf_mmap_free(void *priv, struct videobuf_queue *q) { int i; @@ -1165,7 +1165,7 @@ int videobuf_mmap_free(struct file *file, struct videobuf_queue *q) for (i = 0; i < VIDEO_MAX_FRAME; i++) { if (NULL == q->bufs[i]) continue; - q->ops->buf_release(file,q->bufs[i]); + q->ops->buf_release(priv,q->bufs[i]); kfree(q->bufs[i]); q->bufs[i] = NULL; } diff --git a/linux/include/media/video-buf.h b/linux/include/media/video-buf.h index 8a1b8ff5a..26fcde3eb 100644 --- a/linux/include/media/video-buf.h +++ b/linux/include/media/video-buf.h @@ -1,5 +1,5 @@ /* - * $Id: video-buf.h,v 1.5 2004/09/15 16:15:24 kraxel Exp $ + * $Id: video-buf.h,v 1.6 2004/09/23 13:58:19 kraxel Exp $ * * generic helper functions for video4linux capture buffers, to handle * memory management and PCI DMA. Right now bttv + saa7134 use it. @@ -167,12 +167,12 @@ struct videobuf_buffer { }; struct videobuf_queue_ops { - int (*buf_setup)(struct file *file, + int (*buf_setup)(void *priv, unsigned int *count, unsigned int *size); - int (*buf_prepare)(struct file *file,struct videobuf_buffer *vb, + int (*buf_prepare)(void *priv,struct videobuf_buffer *vb, enum v4l2_field field); - void (*buf_queue)(struct file *file,struct videobuf_buffer *vb); - void (*buf_release)(struct file *file,struct videobuf_buffer *vb); + void (*buf_queue)(void *priv,struct videobuf_buffer *vb); + void (*buf_release)(void *priv,struct videobuf_buffer *vb); }; struct videobuf_queue { @@ -210,36 +210,37 @@ void videobuf_queue_init(struct videobuf_queue *q, enum v4l2_field field, unsigned int msize); int videobuf_queue_is_busy(struct videobuf_queue *q); -void videobuf_queue_cancel(struct file *file, struct videobuf_queue *q); +void videobuf_queue_cancel(void *priv, struct videobuf_queue *q); enum v4l2_field videobuf_next_field(struct videobuf_queue *q); void videobuf_status(struct v4l2_buffer *b, struct videobuf_buffer *vb, enum v4l2_buf_type type); -int videobuf_reqbufs(struct file *file, struct videobuf_queue *q, +int videobuf_reqbufs(void *priv, struct videobuf_queue *q, struct v4l2_requestbuffers *req); int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b); -int videobuf_qbuf(struct file *file, struct videobuf_queue *q, +int videobuf_qbuf(void *priv, struct videobuf_queue *q, struct v4l2_buffer *b); -int videobuf_dqbuf(struct file *file, struct videobuf_queue *q, - struct v4l2_buffer *b); -int videobuf_streamon(struct file *file, struct videobuf_queue *q); -int videobuf_streamoff(struct file *file, struct videobuf_queue *q); - -int videobuf_read_start(struct file *file, struct videobuf_queue *q); -void videobuf_read_stop(struct file *file, struct videobuf_queue *q); -ssize_t videobuf_read_stream(struct file *file, struct videobuf_queue *q, +int videobuf_dqbuf(void *priv, struct videobuf_queue *q, + struct v4l2_buffer *b, int nonblocking); +int videobuf_streamon(void *priv, struct videobuf_queue *q); +int videobuf_streamoff(void *priv, struct videobuf_queue *q); + +int videobuf_read_start(void *priv, struct videobuf_queue *q); +void videobuf_read_stop(void *priv, struct videobuf_queue *q); +ssize_t videobuf_read_stream(void *priv, struct videobuf_queue *q, char __user *data, size_t count, loff_t *ppos, - int vbihack); -ssize_t videobuf_read_one(struct file *file, struct videobuf_queue *q, - char __user *data, size_t count, loff_t *ppos); -unsigned int videobuf_poll_stream(struct file *file, + int vbihack, int nonblocking); +ssize_t videobuf_read_one(void *priv, struct videobuf_queue *q, + char __user *data, size_t count, loff_t *ppos, + int nonblocking); +unsigned int videobuf_poll_stream(void *priv, struct videobuf_queue *q, poll_table *wait); -int videobuf_mmap_setup(struct file *file, struct videobuf_queue *q, +int videobuf_mmap_setup(void *priv, struct videobuf_queue *q, unsigned int bcount, unsigned int bsize, enum v4l2_memory memory); -int videobuf_mmap_free(struct file *file, struct videobuf_queue *q); +int videobuf_mmap_free(void *priv, struct videobuf_queue *q); int videobuf_mmap_mapper(struct vm_area_struct *vma, struct videobuf_queue *q); |