summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2003-10-06 18:55:09 +0000
committerMichael Hunold <devnull@localhost>2003-10-06 18:55:09 +0000
commit790720cf4b0284baba3bd526b38c70a324a4c3b9 (patch)
treef54e13dc50a828d347ced9d75959aa7bd52677da /linux/drivers/media
parent03ddbdd9a49da4a2b8cf45cd1fb8ddca61da98ea (diff)
downloadmediapointer-dvb-s2-790720cf4b0284baba3bd526b38c70a324a4c3b9.tar.gz
mediapointer-dvb-s2-790720cf4b0284baba3bd526b38c70a324a4c3b9.tar.bz2
- add some debug and safety checks for video/vbi capture buffer handling
- fix init/exit of vbi capable devices - add new flag SAA7146_USE_PORT_B_FOR_VBI, so we can distinguish on which video port to apply the vbi workaround - add del_timer(...) for vbi capture queue and vbi_read timers, otherwise the kernel timer schedule oopses - add vbi device handling for dvb-c cards with analog module (does not work yet, have to setup the saa7113 decoder differently)
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/common/saa7146_fops.c26
-rw-r--r--linux/drivers/media/common/saa7146_vbi.c22
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110.c80
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110.h2
4 files changed, 85 insertions, 45 deletions
diff --git a/linux/drivers/media/common/saa7146_fops.c b/linux/drivers/media/common/saa7146_fops.c
index b9d320250..067a27c82 100644
--- a/linux/drivers/media/common/saa7146_fops.c
+++ b/linux/drivers/media/common/saa7146_fops.c
@@ -61,8 +61,14 @@ void saa7146_buffer_finish(struct saa7146_dev *dev,
}
DEB_EE(("dev:%p, dmaq:%p, state:%d\n", dev, q, state));
+ DEB_EE(("q->curr:%p\n",q->curr));
/* finish current buffer */
+ if (NULL == q->curr) {
+ DEB_D(("aiii. no current buffer\n"));
+ return;
+ }
+
q->curr->vb.state = state;
do_gettimeofday(&q->curr->vb.ts);
wake_up(&q->curr->vb.done);
@@ -221,9 +227,12 @@ static int fops_open(struct inode *inode, struct file *file)
fh->dev = dev;
fh->type = type;
- saa7146_video_uops.open(dev,fh);
- if( 0 != BOARD_CAN_DO_VBI(dev) ) {
+ if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
+ DEB_S(("initializing vbi...\n"));
saa7146_vbi_uops.open(dev,fh);
+ } else {
+ DEB_S(("initializing video...\n"));
+ saa7146_video_uops.open(dev,fh);
}
result = 0;
@@ -245,9 +254,10 @@ static int fops_release(struct inode *inode, struct file *file)
if (down_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS;
- saa7146_video_uops.release(dev,fh,file);
- if( 0 != BOARD_CAN_DO_VBI(dev) ) {
+ if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
saa7146_vbi_uops.release(dev,fh,file);
+ } else {
+ saa7146_video_uops.release(dev,fh,file);
}
module_put(dev->ext->module);
@@ -332,11 +342,11 @@ static ssize_t fops_read(struct file *file, char *data, size_t count, loff_t *pp
switch (fh->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
- DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, data:%p, count:%lun", file, data, (unsigned long)count));
+// DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, data:%p, count:%lun", file, data, (unsigned long)count));
return saa7146_video_uops.read(file,data,count,ppos);
}
case V4L2_BUF_TYPE_VBI_CAPTURE: {
- DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", file, data, (unsigned long)count));
+// DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", file, data, (unsigned long)count));
return saa7146_vbi_uops.read(file,data,count,ppos);
}
break;
@@ -443,7 +453,7 @@ int saa7146_register_device(struct video_device *vid, struct saa7146_dev* dev, c
{
struct saa7146_vv *vv = dev->vv_data;
- DEB_EE(("dev:%p, name:'%s'\n",dev,name));
+ DEB_EE(("dev:%p, name:'%s', type:%d\n",dev,name,type));
*vid = device_template;
strlcpy(vid->name, name, sizeof(vid->name));
@@ -451,7 +461,7 @@ int saa7146_register_device(struct video_device *vid, struct saa7146_dev* dev, c
// fixme: -1 should be an insmod parameter *for the extension* (like "video_nr");
if (video_register_device(vid,type,-1) < 0) {
- ERR(("cannot register vbi v4l2 device. skipping.\n"));
+ ERR(("cannot register v4l2 device. skipping.\n"));
return -1;
}
diff --git a/linux/drivers/media/common/saa7146_vbi.c b/linux/drivers/media/common/saa7146_vbi.c
index 48893bf37..5538ad633 100644
--- a/linux/drivers/media/common/saa7146_vbi.c
+++ b/linux/drivers/media/common/saa7146_vbi.c
@@ -38,8 +38,14 @@ static int vbi_workaround(struct saa7146_dev *dev)
WRITE_RPS1(CMD_WR_REG | (1 << 8) | (BRS_CTRL/4));
/* BXO = 1h, BRS to outbound */
WRITE_RPS1(0xc000008c);
- /* wait for vbi_a */
- WRITE_RPS1(CMD_PAUSE | MASK_10);
+ /* wait for vbi_a or vbi_b*/
+ if ( 0 != (SAA7146_USE_PORT_B_FOR_VBI & dev->ext_vv_data->flags)) {
+ DEB_D(("...using port b\n"));
+ WRITE_RPS1(CMD_PAUSE | MASK_09);
+ } else {
+ DEB_D(("...using port a\n"));
+ WRITE_RPS1(CMD_PAUSE | MASK_10);
+ }
/* upload brs */
WRITE_RPS1(CMD_UPLOAD | MASK_08);
/* load brs-control register */
@@ -106,7 +112,7 @@ static int vbi_workaround(struct saa7146_dev *dev)
if(signal_pending(current)) {
- DEB_VBI(("aborted.\n"));
+ DEB_VBI(("aborted (rps:0x%08x).\n",saa7146_read(dev,RPS_ADDR1)));
/* stop rps1 for sure */
saa7146_write(dev, MC1, MASK_29);
@@ -316,6 +322,11 @@ static void vbi_stop(struct saa7146_fh *fh)
saa7146_write(dev, MC1, MASK_20);
vv->vbi_streaming = NULL;
+
+ del_timer(&vv->vbi_q.timeout);
+ del_timer(&fh->vbi_read_timeout);
+
+ DEB_VBI(("out\n"));
spin_unlock_irqrestore(&dev->slock, flags);
}
@@ -371,7 +382,10 @@ static void vbi_open(struct saa7146_dev *dev, struct saa7146_fh *fh)
fh->vbi_read_timeout.function = vbi_read_timeout;
fh->vbi_read_timeout.data = (unsigned long)fh;
+ /* fixme! */
+/*
vbi_workaround(dev);
+*/
}
static void vbi_close(struct saa7146_dev *dev, struct saa7146_fh *fh, struct file *file)
@@ -410,7 +424,7 @@ static ssize_t vbi_read(struct file *file, char *data, size_t count, loff_t *ppo
struct saa7146_vv *vv = dev->vv_data;
ssize_t ret = 0;
- DEB_VBI(("dev:%p, fh:%p\n",dev,fh));
+// DEB_VBI(("dev:%p, fh:%p\n",dev,fh));
if( NULL == vv->vbi_streaming ) {
// fixme: check if dma3 is available
diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c
index 2431dec94..c92f7efa9 100644
--- a/linux/drivers/media/dvb/ttpci/av7110.c
+++ b/linux/drivers/media/dvb/ttpci/av7110.c
@@ -4526,28 +4526,6 @@ static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_
DEB_EE(("dev: %p, av7110: %p\n",dev,av7110));
- /* special case DVB-C: these cards have an analog tuner
- plus need some special handling, so we have separate
- saa7146_ext_vv data for these... */
- if (0 != av7110->has_analog_tuner) {
- ret = saa7146_vv_init(dev, &av7110_vv_data_c);
- } else {
- ret = saa7146_vv_init(dev, &av7110_vv_data_st);
- }
-
- if ( 0 != ret) {
- ERR(("cannot init capture device. skipping.\n"));
- kfree(av7110);
- return -1;
- }
-
- if (saa7146_register_device(&av7110->v4l_dev, dev, "av7110", VFL_TYPE_GRABBER)) {
- ERR(("cannot register capture device. skipping.\n"));
- saa7146_vv_release(dev);
- kfree(av7110);
- return -1;
- }
-
av7110->dev=(struct saa7146_dev *)dev;
dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name);
@@ -4561,8 +4539,6 @@ static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_
av7110->dvb_adapter, 0);
if (!av7110->i2c_bus) {
- saa7146_unregister_device(&av7110->v4l_dev, dev);
- saa7146_vv_release(dev);
dvb_unregister_adapter (av7110->dvb_adapter);
kfree(av7110);
return -ENOMEM;
@@ -4760,18 +4736,53 @@ static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_
av7110_setup_irc_config (av7110, 0);
av7110_register(av7110);
+ /* special case DVB-C: these cards have an analog tuner
+ plus need some special handling, so we have separate
+ saa7146_ext_vv data for these... */
+ if (0 != av7110->has_analog_tuner) {
+ ret = saa7146_vv_init(dev, &av7110_vv_data_c);
+ } else {
+ ret = saa7146_vv_init(dev, &av7110_vv_data_st);
+ }
+
+ if ( 0 != ret) {
+ ERR(("cannot init capture device. skipping.\n"));
+ ret = -ENODEV;
+ goto err;
+ }
+
+ if (saa7146_register_device(&av7110->v4l_dev, dev, "av7110", VFL_TYPE_GRABBER)) {
+ ERR(("cannot register capture device. skipping.\n"));
+ ret = -ENODEV;
+ goto video_err;
+ }
+
+ if (0 != av7110->has_analog_tuner) {
+ if( 0 != saa7146_register_device(&av7110->vbi_dev, dev, "av7110", VFL_TYPE_VBI)) {
+ ERR(("cannot register vbi v4l2 device. skipping.\n"));
+ }
+ /* we use this to remember that this dvb-c card cannot do vbi */
+ av7110->has_analog_tuner = 2;
+ }
+
printk(KERN_INFO "av7110: found av7110-%d.\n",av7110_num);
av7110_num++;
return 0;
-err:
- if (av7110 )
- kfree(av7110);
-
- /* FIXME: error handling is pretty bogus: memory does not get freed...*/
- saa7146_unregister_device(&av7110->v4l_dev, dev);
+video_err:
saa7146_vv_release(dev);
+err:
+ if (NULL != av7110 ) {
+ kfree(av7110);
+ }
+ if (NULL != av7110->debi_virt) {
+ pci_free_consistent(dev->pci, 8192, av7110->debi_virt, av7110->debi_bus);
+ }
+ if (NULL != av7110->iobuf) {
+ vfree(av7110->iobuf);
+ }
+
dvb_unregister_i2c_bus (master_xfer,av7110->i2c_bus->adapter,
av7110->i2c_bus->id);
@@ -4786,6 +4797,9 @@ static int av7110_detach (struct saa7146_dev* saa)
DEB_EE(("av7110: %p\n",av7110));
saa7146_unregister_device(&av7110->v4l_dev, saa);
+ if (2 == av7110->has_analog_tuner) {
+ saa7146_unregister_device(&av7110->vbi_dev, saa);
+ }
av7110->arm_rmmod=1;
wake_up_interruptible(&av7110->arm_wait);
@@ -4853,7 +4867,7 @@ static struct saa7146_standard standard[] = {
static struct saa7146_standard analog_standard[] = {
{
.name = "PAL", .id = V4L2_STD_PAL_BG,
- .v_offset = 0x18, .v_field = 288, .v_calc = 576,
+ .v_offset = 0 /* 0x18 */ , .v_field = 288, .v_calc = 576,
.h_offset = 0x08, .h_pixels = 708, .h_calc = 709,
.v_max_out = 576, .h_max_out = 768,
}, {
@@ -4954,8 +4968,8 @@ static struct saa7146_ext_vv av7110_vv_data_st = {
static struct saa7146_ext_vv av7110_vv_data_c = {
.inputs = 1,
.audios = 1,
- .capabilities = V4L2_CAP_TUNER,
- .flags = 0,
+ .capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE,
+ .flags = SAA7146_USE_PORT_B_FOR_VBI,
.stds = &standard[0],
.num_stds = sizeof(standard)/sizeof(struct saa7146_standard),
diff --git a/linux/drivers/media/dvb/ttpci/av7110.h b/linux/drivers/media/dvb/ttpci/av7110.h
index 46bf8acd2..c052847ac 100644
--- a/linux/drivers/media/dvb/ttpci/av7110.h
+++ b/linux/drivers/media/dvb/ttpci/av7110.h
@@ -399,7 +399,9 @@ struct av7110 {
struct dvb_device dvb_dev;
struct dvb_net dvb_net;
+
struct video_device v4l_dev;
+ struct video_device vbi_dev;
struct saa7146_dev *dev;