> Hi!
>
> I increased the amount of enc_yuv_buffers to 4MB and changed the thread
> priority. Works perfect now. Thanks for the hint!
> One problem is remaining, related to DMA TIMEOUT. Changing pci latency did
> not help. Default all devices are running on a latency of 64. I set the
> latency for the pvr to 96 but the problem still remains. What happens is
> that when using VBI together with the YUV and PCM encoders (MPEG encoder
> is
> not used on ivtv0), the driver stops delivering data. Reinsert of the
> modules does not work and the 30 seconds cold start is necessary.
>
> Might it be that there is some problem in the driver when a VBI and a PCM
> DMA are together in progress ?
Please apply the attached patch to the kernel 2.6.22, I fixed a problem
when multiple streams (e.g. VBI and YUV) were opened at the same time. (I
hope it applies cleanly, BTW. I didn't check that). Alternatively,
checkout the v4l-dvb repository from www.linuxtv.org and use that.
I'm not certain whether this will fix your specific problem, but it's good
to try that first.
If it doesn't help, then I need some additional information: does it only
happen with VBI+PCM+YUV capture, or also with some other combination of
streams? (e.g. VBI only, VBI+YUV, PCM+YUV, etc). And does it always stop
so quickly? From the log it looks like it stalls within a second.
The VBI+YUV+PCM combination is quite unusual and rarely (if ever) tested,
so there just might be some race condition here. Normally DMA timeouts
indicate the dreaded DMA engine crash of the card about which I cannot do
anything, but in this case I can't rule out a driver problem.
Regards,
Hans
>
> It is easy to reproduce the situation so I enabled the debug on 511 and
> see
> below:
>
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC START VBI CAP
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder VBI: 0x0000ccc0 bytes
> at
> 0x003183b0
> Jul 17 22:19:12 www kernel: ivtv0 dma: start DMA for encoder VBI
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC DMA COMPLETE 3 2
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder VBI completed (3183b0)
> Jul 17 22:19:12 www kernel: ivtv0 ioctl: read 51840 bytes from encoder VBI
> Jul 17 22:19:12 www kernel: ivtv0 info: read 51840 from encoder VBI, got
> 51840
> Jul 17 22:19:12 www kernel: ivtv1 irq: ENC START CAP 1: 004c4b00 00065400
> Jul 17 22:19:12 www kernel: ivtv1 dma: DMA encoder YUV: 0x00097e00 bytes
> at
> 0x004c4b00
> Jul 17 22:19:12 www kernel: ivtv1 dma: start DMA for encoder YUV
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC START CAP 2: 0005f664 0000120c
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder PCM audio: 0x00001200
> bytes at 0x0005f670
> Jul 17 22:19:12 www kernel: ivtv0 dma: start DMA for encoder PCM audio
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC DMA COMPLETE 3 2
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder PCM audio completed
> (5f670)
> Jul 17 22:19:12 www kernel: ivtv0 info: read 1024 from encoder PCM audio,
> got 1024
> Jul 17 22:19:12 www kernel: ivtv0 ioctl: read 1024 bytes from encoder PCM
> audio
> Jul 17 22:19:12 www kernel: ivtv0 info: read 1024 from encoder PCM audio,
> got 1024
> Jul 17 22:19:12 www kernel: ivtv0 ioctl: read 1024 bytes from encoder PCM
> audio
> Jul 17 22:19:12 www kernel: ivtv0 info: read 1024 from encoder PCM audio,
> got 1024
> Jul 17 22:19:12 www kernel: ivtv0 ioctl: read 1024 bytes from encoder PCM
> audio
> Jul 17 22:19:12 www kernel: ivtv0 info: read 1024 from encoder PCM audio,
> got 1024
> Jul 17 22:19:12 www kernel: ivtv0 ioctl: read 1024 bytes from encoder PCM
> audio
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC START CAP 1: 0055f700 00065400
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder YUV: 0x00097e00 bytes
> at
> 0x0055f700
> Jul 17 22:19:12 www kernel: ivtv0 dma: start DMA for encoder YUV
> Jul 17 22:19:12 www kernel: ivtv1 irq: ENC DMA COMPLETE 3 1
> Jul 17 22:19:12 www kernel: ivtv1 dma: DMA encoder YUV completed (4c4b00)
> Jul 17 22:19:12 www kernel: ivtv1 info: read 414720 from encoder YUV, got
> 414720
> Jul 17 22:19:12 www kernel: ivtv1 ioctl: read 207360 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv1 info: read 207360 from encoder YUV, got
> 207360
> Jul 17 22:19:12 www kernel: ivtv1 ioctl: read 414720 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC DMA COMPLETE 3 1
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder YUV completed (55f700)
> Jul 17 22:19:12 www kernel: ivtv0 ioctl: read 414720 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv0 info: read 414720 from encoder YUV, got
> 414720
> Jul 17 22:19:12 www kernel: ivtv0 ioctl: read 207360 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv0 info: read 207360 from encoder YUV, got
> 207360
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC START VBI CAP
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder VBI: 0x0000ccc0 bytes
> at
> 0x00325080
> Jul 17 22:19:12 www kernel: ivtv0 dma: start DMA for encoder VBI
> (What
> happened whit this one?)
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC START CAP 2: 00060880 0000120c
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder PCM audio: 0x00001200
> bytes at 0x0006088c
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC DMA COMPLETE 3 2
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder PCM audio completed
> (6088c)
> Jul 17 22:19:12 www kernel: ivtv0 dma: start DMA for encoder PCM audio
> Jul 17 22:19:12 www kernel: ivtv1 irq: ENC START CAP 1: 0055f700 00065400
> Jul 17 22:19:12 www kernel: ivtv1 dma: DMA encoder YUV: 0x00097e00 bytes
> at
> 0x0055f700
> Jul 17 22:19:12 www kernel: ivtv1 dma: start DMA for encoder YUV
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC START CAP 1: 005fa300 00065400
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder YUV: 0x00097e00 bytes
> at
> 0x005fa300
> Jul 17 22:19:12 www kernel: ivtv1 irq: ENC DMA COMPLETE 3 1
> Jul 17 22:19:12 www kernel: ivtv1 dma: DMA encoder YUV completed (55f700)
> Jul 17 22:19:12 www kernel: ivtv1 info: read 414720 from encoder YUV, got
> 414720
> Jul 17 22:19:12 www kernel: ivtv1 ioctl: read 207360 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv1 info: read 207360 from encoder YUV, got
> 207360
> Jul 17 22:19:12 www kernel: ivtv1 ioctl: read 414720 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv0 ioctl: read 414720 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC START VBI CAP
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder VBI: 0x0000ccc0 bytes
> at
> 0x002fea10
> Jul 17 22:19:12 www kernel: ivtv1 irq: ENC START CAP 1: 005fa300 00065400
> Jul 17 22:19:12 www kernel: ivtv1 dma: DMA encoder YUV: 0x00097e00 bytes
> at
> 0x005fa300
> Jul 17 22:19:12 www kernel: ivtv1 dma: start DMA for encoder YUV
> Jul 17 22:19:12 www kernel: ivtv1 irq: ENC DMA COMPLETE 3 1
> Jul 17 22:19:12 www kernel: ivtv1 dma: DMA encoder YUV completed (5fa300)
> Jul 17 22:19:12 www kernel: ivtv1 info: read 414720 from encoder YUV, got
> 414720
> Jul 17 22:19:12 www kernel: ivtv1 ioctl: read 207360 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv1 info: read 207360 from encoder YUV, got
> 207360
> Jul 17 22:19:12 www kernel: ivtv1 ioctl: read 414720 bytes from encoder
> YUV
> Jul 17 22:19:12 www kernel: ivtv0 irq: ENC START VBI CAP
> Jul 17 22:19:12 www kernel: ivtv0 dma: DMA encoder VBI: 0x0000ccc0 bytes
> at
> 0x0030b6e0
> Jul 17 22:19:12 www kernel: ivtv1 irq: ENC START CAP 1: 00694f00 00065400
> Jul 17 22:19:12 www kernel: ivtv1 dma: DMA encoder YUV: 0x00097e00 bytes
> at
> 0x00694f00
> Jul 17 22:19:12 www kernel: ivtv1 dma: start DMA for encoder YUV
> Jul 17 22:19:12 www kernel: ivtv0: DMA TIMEOUT 00000001 3
>
> Best regards!
>
>
> On 7/17/07, Hans Verkuil <[EMAIL PROTECTED]> wrote:
>>
>> > Hello!
>> >
>> > A couple of days I exchanged my old TV capture card with a PVR-500 and
>> the
>> > first results are quite promising! I am using kernel 2.6.22.1 with the
>> > integrated ivtv driver and have only one PVR-500 card installed
>> > ([EMAIL PROTECTED] 512MB).
>> >
>> > I read from /dev/video32 and perform a HM12 to YUV decoding (didn't
>> get
>> > yuv-fixup parameter to work. I do it in the application).
>>
>> yuv-fixup no longer exists: you should always do it in the application.
>>
>> But why are you capturing /dev/video32? Why not the MPEG stream from
>> /dev/video0? It's an MPEG card after all.
>
>
> I am using ivtv0 for watching TV and want to have the quality before
> the MPEG compression takes place. Ivtv1 is used for Picture-In-Picture
> and MPEG capture in my application.
>
>> Sometimes shows
>> > "YUV stream buffers are full" up in the kernel log file. There is a
>> single
>> > thread reading the RAW video and it happens often when another thread
>> is
>> > changing the frequency of the tuner. How can I detect this situation
>> and
>> > recover (that it happens is another problem...)?
>>
>> The number of buffers allocated for raw YUV is limited, so even if your
>> reader thread is blocked for just a few frames you will get this
>> message.
>> One solution is to increase the buffers allocated for YUV capture (run
>> modinfo ivtv to see help on the module options), another is to increase
>> the priority of the reader thread.
>>
>> At the moment there is no way to detect this particular error, I'll see
>> if
>> that can be improved. Basically when the buffers are full the driver
>> should throw away a full YUV frame, not a partial YUV frame. That way
>> you
>> would just get dropped frames.
>>
>> Regards,
>>
>> Hans
>>
>> > The read on /dev/video32
>> > does not return an error for this and the RAW video data returned from
>> the
>> > read does not continue at the pixel/plane coordinate before the error
>> > appeared. When this happens the HM12 to YUV decoding produces garbage
>> as
>> > the
>> > data decoded is received in the wrong planes (assuming data
>> corresponds
>> to
>> > Y, but receiving UV,etc...)
>> >
>> > Best regards!
>> > _______________________________________________
>> > ivtv-users mailing list
>> > [email protected]
>> > http://ivtvdriver.org/mailman/listinfo/ivtv-users
>>
>>
>>
>> _______________________________________________
>> ivtv-users mailing list
>> [email protected]
>> http://ivtvdriver.org/mailman/listinfo/ivtv-users
>>
> _______________________________________________
> ivtv-users mailing list
> [email protected]
> http://ivtvdriver.org/mailman/listinfo/ivtv-users
diff -r bc14a43867c4 -r cc3cc5a2ed5e linux/drivers/media/video/ivtv/ivtv-driver.c
--- a/linux/drivers/media/video/ivtv/ivtv-driver.c Tue Jul 10 19:51:33 2007 +0200
+++ b/linux/drivers/media/video/ivtv/ivtv-driver.c Tue Jul 10 19:58:33 2007 +0200
@@ -623,6 +623,7 @@ static int __devinit ivtv_init_struct1(s
itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */
itv->dec_mbox.max_mbox = 1; /* the decoder has 2 mailboxes (0-1) */
+ mutex_init(&itv->serialize_lock);
mutex_init(&itv->i2c_bus_lock);
mutex_init(&itv->udma.lock);
diff -r bc14a43867c4 -r cc3cc5a2ed5e linux/drivers/media/video/ivtv/ivtv-driver.h
--- a/linux/drivers/media/video/ivtv/ivtv-driver.h Tue Jul 10 19:51:33 2007 +0200
+++ b/linux/drivers/media/video/ivtv/ivtv-driver.h Tue Jul 10 19:58:33 2007 +0200
@@ -729,6 +729,7 @@ struct ivtv {
int search_pack_header;
spinlock_t dma_reg_lock; /* lock access to DMA engine registers */
+ struct mutex serialize_lock; /* lock used to serialize starting streams */
/* User based DMA for OSD */
struct ivtv_user_dma udma;
diff -r bc14a43867c4 -r cc3cc5a2ed5e linux/drivers/media/video/ivtv/ivtv-streams.c
--- a/linux/drivers/media/video/ivtv/ivtv-streams.c Tue Jul 10 19:51:33 2007 +0200
+++ b/linux/drivers/media/video/ivtv/ivtv-streams.c Tue Jul 10 19:58:33 2007 +0200
@@ -446,6 +446,9 @@ int ivtv_start_v4l2_encode_stream(struct
if (s->v4l2dev == NULL)
return -EINVAL;
+ /* Big serialization lock to ensure no two streams are started
+ simultaneously: that can give all sorts of weird results. */
+ mutex_lock(&itv->serialize_lock);
IVTV_DEBUG_INFO("Start encoder stream %s\n", s->name);
switch (s->type) {
@@ -487,6 +490,7 @@ int ivtv_start_v4l2_encode_stream(struct
0, sizeof(itv->vbi.sliced_mpeg_size));
break;
default:
+ mutex_unlock(&itv->serialize_lock);
return -EINVAL;
}
s->subtype = subtype;
@@ -568,6 +572,7 @@ int ivtv_start_v4l2_encode_stream(struct
if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype))
{
IVTV_DEBUG_WARN( "Error starting capture!\n");
+ mutex_unlock(&itv->serialize_lock);
return -EINVAL;
}
@@ -583,6 +588,7 @@ int ivtv_start_v4l2_encode_stream(struct
/* you're live! sit back and await interrupts :) */
atomic_inc(&itv->capturing);
+ mutex_unlock(&itv->serialize_lock);
return 0;
}
@@ -761,17 +767,6 @@ int ivtv_stop_v4l2_encode_stream(struct
/* end_capture */
/* when: 0 = end of GOP 1 = NOW!, type: 0 = mpeg, subtype: 3 = video+audio */
ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, stopmode, cap_type, s->subtype);
-
- /* only run these if we're shutting down the last cap */
- if (atomic_read(&itv->capturing) - 1 == 0) {
- /* event notification (off) */
- if (test_and_clear_bit(IVTV_F_I_DIG_RST, &itv->i_flags)) {
- /* type: 0 = refresh */
- /* on/off: 0 = off, intr: 0x10000000, mbox_id: -1: none */
- ivtv_vapi(itv, CX2341X_ENC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_ENC_VIM_RST, -1);
- ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VIM_RST);
- }
- }
then = jiffies;
@@ -840,17 +835,30 @@ int ivtv_stop_v4l2_encode_stream(struct
/* Clear capture and no-read bits */
clear_bit(IVTV_F_S_STREAMING, &s->s_flags);
+ /* ensure these global cleanup actions are done only once */
+ mutex_lock(&itv->serialize_lock);
+
if (s->type == IVTV_ENC_STREAM_TYPE_VBI)
ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VBI_CAP);
if (atomic_read(&itv->capturing) > 0) {
+ mutex_unlock(&itv->serialize_lock);
return 0;
}
/* Set the following Interrupt mask bits for capture */
ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
+ /* event notification (off) */
+ if (test_and_clear_bit(IVTV_F_I_DIG_RST, &itv->i_flags)) {
+ /* type: 0 = refresh */
+ /* on/off: 0 = off, intr: 0x10000000, mbox_id: -1: none */
+ ivtv_vapi(itv, CX2341X_ENC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_ENC_VIM_RST, -1);
+ ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VIM_RST);
+ }
+
wake_up(&s->waitq);
+ mutex_unlock(&itv->serialize_lock);
return 0;
}_______________________________________________
ivtv-users mailing list
[email protected]
http://ivtvdriver.org/mailman/listinfo/ivtv-users