diff options
Diffstat (limited to 'linux/drivers/media/video/cx88/cx88-mpeg.c')
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-mpeg.c | 235 |
1 files changed, 18 insertions, 217 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-mpeg.c b/linux/drivers/media/video/cx88/cx88-mpeg.c index eca7b012a..d05e925c4 100644 --- a/linux/drivers/media/video/cx88/cx88-mpeg.c +++ b/linux/drivers/media/video/cx88/cx88-mpeg.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-mpeg.c,v 1.2 2004/07/30 11:14:05 kraxel Exp $ + * $Id: cx88-mpeg.c,v 1.3 2004/07/30 13:43:39 kraxel Exp $ * * Support for the mpeg transport stream transfers * PCI function #2 of the cx2388x. @@ -36,7 +36,7 @@ /* ------------------------------------------------------------------ */ -MODULE_DESCRIPTION("mpeg driver module for cx2388x based TV cards"); +MODULE_DESCRIPTION("mpeg driver for cx2388x based TV cards"); MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>"); MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); MODULE_LICENSE("GPL"); @@ -52,7 +52,7 @@ MODULE_PARM_DESC(mpeg_debug,"enable debug messages [mpeg]"); #define dprintk(level,fmt, arg...) if (mpeg_debug >= level) \ printk(KERN_DEBUG "%s/2: " fmt, dev->core->name , ## arg) -static LIST_HEAD(cx8802_devlist); +LIST_HEAD(cx8802_devlist); /* ------------------------------------------------------------------ */ @@ -68,21 +68,25 @@ int cx8802_start_dma(struct cx8802_dev *dev, cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], PACKET_SIZE, buf->risc.dma); - //cx_set(VID_CAPTURE_CONTROL,0x0); /* should this??? */ - /* enable capture */ +#if 0 /* from DVB -- for transport streams only? */ + /* Setup TS portion of chip */ + cx_write(TS_GEN_CNTRL, 0x0c); + + /* write TS length to chip */ + cx_write(MO_TS_LNGTH, buf->bpl); +#endif /* reset counter */ - cx_write(MO_TS_GPCNTRL,0x3); /* general purpose counter for risc program (?) */ + cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET); q->count = 1; /* enable irqs */ - cx_set(MO_PCI_INTMSK, 0x4); /* enable ts_int */ - cx_set(MO_TS_INTMSK, 0x1f1101); /* all except the irq2 bit */ + cx_set(MO_PCI_INTMSK, 0x00fc04); + cx_set(MO_TS_INTMSK, 0x1f0011); /* start dma */ - cx_set(MO_DEV_CNTRL2, (1<<5)); /* enable the risc controller */ - cx_set(MO_TS_DMACNTRL, 0x11); /* enable TS RISC and FIFO */ - + cx_set(MO_DEV_CNTRL2, (1<<5)); + cx_set(MO_TS_DMACNTRL, 0x11); return 0; } @@ -167,7 +171,7 @@ mpeg_buf_queue(struct file *file, struct videobuf_buffer *vb) struct cx88_dmaqueue *q = &dev->mpegq; /* add jump to stopper */ - buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | 0x10000); + buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); if (list_empty(&q->active)) { @@ -212,186 +216,6 @@ struct videobuf_queue_ops cx8802_mpeg_qops = { .buf_release = mpeg_buf_release, }; -/* ------------------------------------------------------------------ */ - -static int mpeg_do_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, void *arg) -{ - struct cx8802_fh *fh = file->private_data; - struct cx8802_dev *dev = fh->dev; - - if (mpeg_debug > 1) - cx88_print_ioctl(dev->core->name,cmd); - - switch (cmd) { - - /* --- capture ioctls ---------------------------------------- */ - case VIDIOC_ENUM_FMT: - { - struct v4l2_fmtdesc *f = arg; - int index; - - index = f->index; - if (index != 0) - return -EINVAL; - - memset(f,0,sizeof(*f)); - f->index = index; - strlcpy(f->description, "MPEG TS", sizeof(f->description)); - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - f->pixelformat = V4L2_PIX_FMT_MPEG; - return 0; - } - case VIDIOC_G_FMT: - case VIDIOC_S_FMT: - case VIDIOC_TRY_FMT: - { - /* FIXME -- quick'n'dirty for exactly one size ... */ - struct v4l2_format *f = arg; - - memset(f,0,sizeof(*f)); - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - f->fmt.pix.width = 720; - f->fmt.pix.height = 576; - f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; - f->fmt.pix.sizeimage = BUFFER_SIZE; - } - - /* --- streaming capture ------------------------------------- */ - case VIDIOC_REQBUFS: - return videobuf_reqbufs(file, &fh->mpegq, arg); - - case VIDIOC_QUERYBUF: - return videobuf_querybuf(&fh->mpegq, arg); - - case VIDIOC_QBUF: - return videobuf_qbuf(file, &fh->mpegq, arg); - - case VIDIOC_DQBUF: - return videobuf_dqbuf(file, &fh->mpegq, arg); - - case VIDIOC_STREAMON: - return videobuf_streamon(file, &fh->mpegq); - - case VIDIOC_STREAMOFF: - return videobuf_streamoff(file, &fh->mpegq); - - default: - return -EINVAL; - } - return 0; -} - -static int mpeg_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - return video_usercopy(inode, file, cmd, arg, mpeg_do_ioctl); -} - -static int mpeg_open(struct inode *inode, struct file *file) -{ - int minor = iminor(inode); - struct cx8802_dev *h,*dev = NULL; - struct cx8802_fh *fh; - struct list_head *list; - - list_for_each(list,&cx8802_devlist) { - h = list_entry(list, struct cx8802_dev, devlist); - if (h->mpeg_dev->minor == minor) - dev = h; - } - if (NULL == dev) - return -ENODEV; - -#if 0 /* FIXME */ - if (mpegport_initialize_codec(dev) < 0) - return -EINVAL; -#endif - - dprintk(1,"open minor=%d\n",minor); - - /* allocate + initialize per filehandle data */ - fh = kmalloc(sizeof(*fh),GFP_KERNEL); - if (NULL == fh) - return -ENOMEM; - memset(fh,0,sizeof(*fh)); - file->private_data = fh; - fh->dev = dev; - - videobuf_queue_init(&fh->mpegq, &cx8802_mpeg_qops, - dev->pci, &dev->slock, - V4L2_BUF_TYPE_VIDEO_CAPTURE, - V4L2_FIELD_TOP, - sizeof(struct cx88_buffer)); - init_MUTEX(&fh->mpegq.lock); - - return 0; -} - -static int mpeg_release(struct inode *inode, struct file *file) -{ - struct cx8802_fh *fh = file->private_data; - -#if 0 /* FIXME */ - mpegport_api_cmd(fh->dev, IVTV_API_END_CAPTURE, 3, 0, 1, 0, 0x13); -#endif - - /* stop mpeg capture */ - if (fh->mpegq.streaming) - videobuf_streamoff(file,&fh->mpegq); - if (fh->mpegq.reading) - videobuf_read_stop(file,&fh->mpegq); - - file->private_data = NULL; - kfree(fh); - return 0; -} - -static ssize_t -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); -} - -static unsigned int -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); -} - -static int -mpeg_mmap(struct file *file, struct vm_area_struct * vma) -{ - struct cx8802_fh *fh = file->private_data; - - return videobuf_mmap_mapper(vma, &fh->mpegq); -} - -static struct file_operations mpeg_fops = -{ - .owner = THIS_MODULE, - .open = mpeg_open, - .release = mpeg_release, - .read = mpeg_read, - .poll = mpeg_poll, - .mmap = mpeg_mmap, - .ioctl = mpeg_ioctl, - .llseek = no_llseek, -}; - -static struct video_device cx8802_mpeg_template = -{ - .name = "cx8802", - .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES|VID_TYPE_MPEG_ENCODER, - .hardware = 0, - .fops = &mpeg_fops, - .minor = -1, -}; - /* ----------------------------------------------------------- */ /* exported stuff */ @@ -496,17 +320,6 @@ static irqreturn_t cx8802_irq(int irq, void *dev_id, struct pt_regs *regs) /* ----------------------------------------------------------- */ -static void cx8802_unregister_video(struct cx8802_dev *dev) -{ - if (dev->mpeg_dev) { - if (-1 != dev->mpeg_dev->minor) - video_unregister_device(dev->mpeg_dev); - else - video_device_release(dev->mpeg_dev); - dev->mpeg_dev = NULL; - } -} - static int __devinit cx8802_initdev(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) { @@ -551,11 +364,11 @@ static int __devinit cx8802_initdev(struct pci_dev *pci_dev, if (cx88_boards[core->board].blackbird) { printk("%s/2: cx23416 based mpeg encoder (blackbird design)\n", core->name); - /* todo */ + /* todo: register v4l device, init cx23416 encoder */ } else if (cx88_boards[core->board].dvb) { printk("%s/2: has DVB support\n", core->name); - /* todo */ + /* todo: register dvb device */ } else { printk("%s/2: don't what the mpeg port on this card is used for\n" "%s/2: going to ignore it, sorry\n", @@ -596,17 +409,6 @@ static int __devinit cx8802_initdev(struct pci_dev *pci_dev, cx88_card_setup(dev); #endif - /* register v4l devices */ - dev->mpeg_dev = cx88_vdev_init(core,dev->pci,&cx8802_mpeg_template,"mpeg"); - err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1); - if (err < 0) { - printk(KERN_INFO "%s/2: can't register mpeg device\n", - core->name); - return err; - } - printk(KERN_INFO "%s/2: registered device video%d [mpeg]\n", - core->name,dev->mpeg_dev->minor & 0x1f); - /* everything worked */ list_add_tail(&dev->devlist,&cx8802_devlist); pci_set_drvdata(pci_dev,dev); @@ -630,7 +432,6 @@ static void __devexit cx8802_finidev(struct pci_dev *pci_dev) /* unregister stuff */ free_irq(pci_dev->irq, dev); - cx8802_unregister_video(dev); pci_set_drvdata(pci_dev, NULL); /* free memory */ |