Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ivtv: devel

PVR150 Tinny/fuzzy audio w/ patch?

 

 

ivtv devel RSS feed   Index | Next | Previous | View Threaded


pthorn-ivtvd at styx2002

Nov 30, 2009, 10:18 AM

Post #1 of 18 (7414 views)
Permalink
PVR150 Tinny/fuzzy audio w/ patch?

Like many, I've been experiencing occassional tinny audio when
recording using a Hauppauge PVR150 since upgrading from kernel 2.6.22
to kernel 2.6.28.

After poking about, I found that if I selectively reversed part of a
particular checkin between 2.6.23 and 2.6.24
(git: 3562c43be8cfd6e300508d7c33acebf3369eacd3)
the issue disappeared for me. See patch below.

Using the patch attached below, I've been recording steadily for a
month or so with zero incidents of tinny audio, whereas before the
patch I was experiencing corruption approximately 1 in 10 recordings.

I have no idea why this section of code appears to be critical, so
any thoughts would be appreciated. At one point, I believed that
making the 300ms ivtv_msleep_timeout after the STREAMOFF function
uninterruptable might also fix the problem, but my cursory initial
attempts at changing the "intr" parameter to it still resulted in
occassional audio artifacts.

I'm hoping that this may assist in any ongoing ivtv debugging efforts
for the PVR150 cards.

- Argus

PATCH:
========================================================================
--- drivers/media/video/ivtv/ivtv-streams.c.original 2008-12-24 18:26:37.000000000 -0500
+++ drivers/media/video/ivtv/ivtv-streams.c 2009-10-28 13:46:10.000000000 -0400
@@ -575,15 +575,21 @@
ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);

clear_bit(IVTV_F_I_EOS, &itv->i_flags);

/* Initialize Digitizer for Capture */
+ if (itv->card->type != IVTV_CARD_PVR_150) {
itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
+ }
+
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
+
+ if (itv->card->type != IVTV_CARD_PVR_150) {
itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
+ }

/* begin_capture */
if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype))
{
IVTV_DEBUG_WARN( "Error starting capture!\n");


========================================================================



_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


awalls at radix

Nov 30, 2009, 5:03 PM

Post #2 of 18 (7297 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Mon, 2009-11-30 at 13:18 -0500, Argus wrote:
> Like many, I've been experiencing occassional tinny audio when
> recording using a Hauppauge PVR150 since upgrading from kernel 2.6.22
> to kernel 2.6.28.
>
> After poking about, I found that if I selectively reversed part of a
> particular checkin between 2.6.23 and 2.6.24
> (git: 3562c43be8cfd6e300508d7c33acebf3369eacd3)
> the issue disappeared for me. See patch below.
>
> Using the patch attached below, I've been recording steadily for a
> month or so with zero incidents of tinny audio, whereas before the
> patch I was experiencing corruption approximately 1 in 10 recordings.
>
> I have no idea why this section of code appears to be critical, so
> any thoughts would be appreciated. At one point, I believed that
> making the 300ms ivtv_msleep_timeout after the STREAMOFF function
> uninterruptable might also fix the problem, but my cursory initial
> attempts at changing the "intr" parameter to it still resulted in
> occassional audio artifacts.
>
> I'm hoping that this may assist in any ongoing ivtv debugging efforts
> for the PVR150 cards.
>
> - Argus
>
> PATCH:
> ========================================================================
> --- drivers/media/video/ivtv/ivtv-streams.c.original 2008-12-24 18:26:37.000000000 -0500
> +++ drivers/media/video/ivtv/ivtv-streams.c 2009-10-28 13:46:10.000000000 -0400
> @@ -575,15 +575,21 @@
> ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
>
> clear_bit(IVTV_F_I_EOS, &itv->i_flags);
>
> /* Initialize Digitizer for Capture */
> + if (itv->card->type != IVTV_CARD_PVR_150) {
> itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
> ivtv_msleep_timeout(300, 1);
> + }
> +
> ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
> +
> + if (itv->card->type != IVTV_CARD_PVR_150) {
> itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
> }
> + }
>
> /* begin_capture */
> if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype))
> {
> IVTV_DEBUG_WARN( "Error starting capture!\n");
>
>
> ========================================================================

Wow. Just bizarre. One that you found it; two that we're actually
chaning IO pins to be disabled and float on the CX25843 when setting up
a capture.

The above function calls to VIDIOC_STREAMON/OFF are actually now calls
to linux/drivers/media/video/cx25840/cx25840-core.c:cx25840_s_stream()
in the latest version of the driver. This function disables or enables
(mostly) audio, audio clock, and video clock related pins on the
CX25843. These pins likely feed into the CX23416 MPEG encoder chip.

I suspect that these signals floating cause the CX23416 to make some bad
guesses about audio sample rate when CX2341X_ENC_INTIALIZE_INPUT is
called. The only note I have about INITIALIZE_INPUT is that it is for
video input initialization.

I don't know the history here, but on the surface your patch looks
plausible that it would solve the problem. I just don't know about the
applicability to other CX2584x/CX23416 boards other then the PVR-150;
the patch might apply to them too.

Regards,
Andy


_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


ivtv at moasat

Dec 1, 2009, 6:23 AM

Post #3 of 18 (7289 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

> -----Original Message-----
> From: ivtv-devel-bounces [at] ivtvdriver
> [mailto:ivtv-devel-bounces [at] ivtvdriver] On Behalf Of Andy Walls
> Sent: Monday, November 30, 2009 7:03 PM
> To: Discussion list for development of the IVTV driver
> Subject: Re: [ivtv-devel] PVR150 Tinny/fuzzy audio w/ patch?
>
> Wow. Just bizarre. One that you found it; two that we're
> actually chaning IO pins to be disabled and float on the
> CX25843 when setting up a capture.
>
> The above function calls to VIDIOC_STREAMON/OFF are actually
> now calls to
> linux/drivers/media/video/cx25840/cx25840-core.c:cx25840_s_stream()
> in the latest version of the driver. This function disables
> or enables
> (mostly) audio, audio clock, and video clock related pins on
> the CX25843. These pins likely feed into the CX23416 MPEG
> encoder chip.
>
> I suspect that these signals floating cause the CX23416 to
> make some bad guesses about audio sample rate when
> CX2341X_ENC_INTIALIZE_INPUT is called. The only note I have
> about INITIALIZE_INPUT is that it is for video input initialization.
>
> I don't know the history here, but on the surface your patch
> looks plausible that it would solve the problem. I just
> don't know about the applicability to other CX2584x/CX23416
> boards other then the PVR-150; the patch might apply to them too.
>
> Regards,
> Andy
>

I have both a PVR-150 and a PVR-350. Both seem to exhibit the tinny audio
behaviour. If this patch can be made to work for both cards, I'd be willing
to try it out. I'm currently running 2.6.30 but am going to be upgrading to
2.6.31 soon. I normally have to run a script that sets the audio-in on both
cards to line-in (or something, I forget) to get them to reset the audio. I
usually do this about every 10 seconds but have since backed that off. I
never got the timing right to do it after a Myth channel change like I
wanted to.



_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


srey0123+ivtv at gmail

Dec 1, 2009, 10:48 AM

Post #4 of 18 (7290 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Tue, Dec 1, 2009 at 8:23 AM, Moasat <ivtv [at] moasat> wrote:


> I normally have to run a script that sets the audio-in on both
> cards to line-in (or something, I forget) to get them to reset the audio.
> I
> usually do this about every 10 seconds but have since backed that off. I
> never got the timing right to do it after a Myth channel change like I
> wanted to.


Since I'm using the IR blaster to change channels on my setup, it was fairly
trivial to add this in the channel change script that I use. Perhaps you
could use a script to change channels directly on the card, instead, and
then reset the audio input. You'd need to create a script for each tuner, of
course.

So as not to cause excessive delay for the MythTV backend, I backgrounded
the reset task. Here's the last line of my channel change script:

nohup sh -c "sleep 2.5; /usr/local/bin/v4l2-ctl -d ${VIDEODEV}
--set-audio-input=1" </dev/null >/dev/null 2>&1 &

--scott


pthorn-ivtvd at styx2002

Dec 1, 2009, 12:29 PM

Post #5 of 18 (7287 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Tue, 1 Dec 2009, Moasat wrote:

>> -----Original Message-----
>> From: ivtv-devel-bounces [at] ivtvdriver
>> [mailto:ivtv-devel-bounces [at] ivtvdriver] On Behalf Of Andy Walls
>> Sent: Monday, November 30, 2009 7:03 PM
>> To: Discussion list for development of the IVTV driver
>> Subject: Re: [ivtv-devel] PVR150 Tinny/fuzzy audio w/ patch?
>>
> I have both a PVR-150 and a PVR-350. Both seem to exhibit the tinny audio
> behaviour. If this patch can be made to work for both cards, I'd be willing
> to try it out. I'm currently running 2.6.30 but am going to be upgrading to
> 2.6.31 soon. I normally have to run a script that sets the audio-in on both
> cards to line-in (or something, I forget) to get them to reset the audio. I
> usually do this about every 10 seconds but have since backed that off. I
> never got the timing right to do it after a Myth channel change like I
> wanted to.
>

Moasat,

I haven't tried this, but it should extend the hack to include 350 cards
as well as 150/500 cards. I wasn't aware that the tinny audio afflicts
other Hauppauge models (does this happen on 250's, too?) I only own
150's, so that is where I was concentrating my debugging efforts.

I've found that setting the audio-in wasn't very effective in my
setup. I still had the occassional recording corruption. Better to
fix it at the driver level anyway, I think (hope). We shouldn't need
external workarounds ...

If you get a chance, please give it a try. I'd be curious if it works.
I assume Andy/Hans would be interested, too ...

PATCH w/350:
========================================================================
--- drivers/media/video/ivtv/ivtv-streams.c.original 2008-12-24 18:26:37.000000000 -0500
+++ drivers/media/video/ivtv/ivtv-streams.c 2009-12-01 15:16:11.795973690 -0500
@@ -575,15 +575,23 @@
ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);

clear_bit(IVTV_F_I_EOS, &itv->i_flags);

/* Initialize Digitizer for Capture */
+ if (itv->card->type != IVTV_CARD_PVR_150 &&
+ itv->card->type != IVTV_CARD_PVR_350) {
itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
+ }
+
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
+
+ if (itv->card->type != IVTV_CARD_PVR_150 &&
+ itv->card->type != IVTV_CARD_PVR_350) {
itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
+ }

/* begin_capture */
if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype))
{
IVTV_DEBUG_WARN( "Error starting capture!\n");

========================================================================

- Argus


_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


awalls at radix

Dec 1, 2009, 4:43 PM

Post #6 of 18 (7274 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Tue, 2009-12-01 at 15:29 -0500, Argus wrote:
> On Tue, 1 Dec 2009, Moasat wrote:
>

> Moasat,
>
> I haven't tried this, but it should extend the hack to include 350 cards
> as well as 150/500 cards. I wasn't aware that the tinny audio afflicts
> other Hauppauge models (does this happen on 250's, too?) I only own
> 150's, so that is where I was concentrating my debugging efforts.

The PVR-250 and PVR-350 are different. They have a SAA7115 for video
and an MSP34xx (IIRC) for audio and not a CX2584x. However, it appears
the saa7115_s_stream() function in saa7115.c enables/disables the video
clock. The msp3400-driver.c doesn't seem to have any s_stream()
function, so it shouldn't matter.


> I've found that setting the audio-in wasn't very effective in my
> setup. I still had the occassional recording corruption. Better to
> fix it at the driver level anyway, I think (hope). We shouldn't need
> external workarounds ...
>
> If you get a chance, please give it a try. I'd be curious if it works.
> I assume Andy/Hans would be interested, too ...

I am interested. I was hoping Hans, Chris. or Tyler had some insight
into the history of why floating the digitizer outputs was thought to be
needed for the CX25843 at one point in history.

Regards,
Andy

> PATCH w/350:
> ========================================================================
> --- drivers/media/video/ivtv/ivtv-streams.c.original 2008-12-24 18:26:37.000000000 -0500
> +++ drivers/media/video/ivtv/ivtv-streams.c 2009-12-01 15:16:11.795973690 -0500
> @@ -575,15 +575,23 @@
> ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
>
> clear_bit(IVTV_F_I_EOS, &itv->i_flags);
>
> /* Initialize Digitizer for Capture */
> + if (itv->card->type != IVTV_CARD_PVR_150 &&
> + itv->card->type != IVTV_CARD_PVR_350) {
> itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
> ivtv_msleep_timeout(300, 1);
> + }
> +
> ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
> +
> + if (itv->card->type != IVTV_CARD_PVR_150 &&
> + itv->card->type != IVTV_CARD_PVR_350) {
> itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
> }
> + }
>
> /* begin_capture */
> if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype))
> {
> IVTV_DEBUG_WARN( "Error starting capture!\n");
>
> ========================================================================
>
> - Argus
>
>
> _______________________________________________
> ivtv-devel mailing list
> ivtv-devel [at] ivtvdriver
> http://ivtvdriver.org/mailman/listinfo/ivtv-devel
>


_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


ivtv at groovy

Dec 1, 2009, 5:21 PM

Post #7 of 18 (7280 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Tue, Dec 01, 2009 at 07:43:18PM -0500, Andy Walls wrote:
> On Tue, 2009-12-01 at 15:29 -0500, Argus wrote:
> > On Tue, 1 Dec 2009, Moasat wrote:
> >
>
> > Moasat,
> >
> > I haven't tried this, but it should extend the hack to include 350 cards
> > as well as 150/500 cards. I wasn't aware that the tinny audio afflicts
> > other Hauppauge models (does this happen on 250's, too?) I only own
> > 150's, so that is where I was concentrating my debugging efforts.
>
> The PVR-250 and PVR-350 are different. They have a SAA7115 for video
> and an MSP34xx (IIRC) for audio and not a CX2584x. However, it appears
> the saa7115_s_stream() function in saa7115.c enables/disables the video
> clock. The msp3400-driver.c doesn't seem to have any s_stream()
> function, so it shouldn't matter.
>
>
> > I've found that setting the audio-in wasn't very effective in my
> > setup. I still had the occassional recording corruption. Better to
> > fix it at the driver level anyway, I think (hope). We shouldn't need
> > external workarounds ...
> >
> > If you get a chance, please give it a try. I'd be curious if it works.
> > I assume Andy/Hans would be interested, too ...
>
> I am interested. I was hoping Hans, Chris. or Tyler had some insight
> into the history of why floating the digitizer outputs was thought to be
> needed for the CX25843 at one point in history.

I think it's a throw back to the SAA711X chips needing this when running
the firmware command to re-init the video input. This is the proper
procedure for the older digitizers, I've always wondered about the
newer cx25843 since there's no information available on it interacting
with the cx23416 chips re-init video input firmware command. It's
either completely unnecessary now or we may be doing it completely
wrong, we never did anything to the separate msp audio chips like
this but since now it's bundled together and may affect the audio. Also
the pvr350 is a cx23415 chip which has a completely different need
here compared to the cx23416, so that complicates matters and could
explain why it has audio problems too. Most of that information
between the cx23416 and cx23415 is not very clear, and definitely
not publically available. I don't think there ever was any information
on the cx23416 and cx25843 interaction, so who knows, it was just
a guess on how to deal with the re-init firmware command by ivtv
developers. I don't know if the i2c dumps of the Windows driver
might have been a clear way to tell, or if the exact procedure at
that point in the start_capture timeline were duplicated.

Thanks,
Chris


>
> Regards,
> Andy
>
> > PATCH w/350:
> > ========================================================================
> > --- drivers/media/video/ivtv/ivtv-streams.c.original 2008-12-24 18:26:37.000000000 -0500
> > +++ drivers/media/video/ivtv/ivtv-streams.c 2009-12-01 15:16:11.795973690 -0500
> > @@ -575,15 +575,23 @@
> > ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
> >
> > clear_bit(IVTV_F_I_EOS, &itv->i_flags);
> >
> > /* Initialize Digitizer for Capture */
> > + if (itv->card->type != IVTV_CARD_PVR_150 &&
> > + itv->card->type != IVTV_CARD_PVR_350) {
> > itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
> > ivtv_msleep_timeout(300, 1);
> > + }
> > +
> > ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
> > +
> > + if (itv->card->type != IVTV_CARD_PVR_150 &&
> > + itv->card->type != IVTV_CARD_PVR_350) {
> > itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
> > }
> > + }
> >
> > /* begin_capture */
> > if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype))
> > {
> > IVTV_DEBUG_WARN( "Error starting capture!\n");
> >
> > ========================================================================
> >
> > - Argus
> >
> >
> > _______________________________________________
> > ivtv-devel mailing list
> > ivtv-devel [at] ivtvdriver
> > http://ivtvdriver.org/mailman/listinfo/ivtv-devel
> >
>
>
> _______________________________________________
> ivtv-devel mailing list
> ivtv-devel [at] ivtvdriver
> http://ivtvdriver.org/mailman/listinfo/ivtv-devel
>

--
Chris Kennedy
c [at] groovy

_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


martin.dauskardt at gmx

Dec 2, 2009, 9:47 AM

Post #8 of 18 (7263 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

> Date: Mon, 30 Nov 2009 20:03:02 -0500
> From: Andy Walls <awalls [at] radix>


> I suspect that these signals floating cause the CX23416 to make some bad
> guesses about audio sample rate when CX2341X_ENC_INTIALIZE_INPUT is
> called. The only note I have about INITIALIZE_INPUT is that it is for
> video input initialization.
>
> I don't know the history here, but on the surface your patch looks
> plausible that it would solve the problem. I just don't know about the
> applicability to other CX2584x/CX23416 boards other then the PVR-150;
> the patch might apply to them too.
>

This area around CX2341X_ENC_INTIALIZE_INPUT is critical code which Hans made
stable after a lot of testing:

http://www.gossamer-threads.com/lists/ivtv/devel/36272
http://linuxtv.org/hg/v4l-dvb/rev/904736fc862a

Summary:
The CX2341X_ENC_INITIALIZE_INPUT firmware call should be made whenever the
digitizer (saa7115 or cx25840) has changed, either because the TV standard was
changed, another input was chosen (or opening the radio device) or the video
format changes (e.g. capture size, VBI settings). But it turned out that the
digitizer has to be turned off before calling this API and turned on
afterwards. This is definitely the case for the saa7115, the cx25840 seems to
be more forgiving.

I remember that the 300ms ivtv_msleep_timeout was absolutely necessary to
avoid occasionally black video after starting the capture. (I don't know if
this is related to the digitizer calls or if we simply need this time to allow
execution of the previous encoder commands before calling
CX2341X_ENC_INITIALIZE_INPUT.)

@ ivtv at moasat:
This is the first time that I read about tinny audio with a PVR350. Are you
sure that this card has the same problem?

If it comes out that the tinny audio is related to cx25840 only, and that
these digitizer does not need to be turned off, than a modified code should
check for itv->hw_flags & IVTV_HW_CX25840 instead of board names.

BTW: For the pvrinput vdr plugin I am using the encoder stop/start ioctls for
every channel switch (to clear the encoder). While the whole process of
stopping, tuning and starting is very fast with a PVR250/350, it takes nearly
a second longer with PVR150. Maybe turning the cx25840 off and on takes longer
than with saa7115.

Greets,
Martin

_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


ivtv at moasat

Dec 2, 2009, 4:12 PM

Post #9 of 18 (7301 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

> @ ivtv at moasat:
> This is the first time that I read about tinny audio with a
> PVR350. Are you sure that this card has the same problem?

I've had the 350 and 150 for almost the same length of time and I seem to
recall having the problem on both cards. It is intermittent enough to be
really hard to test for but often enough to really be a nuisance.

Your comment about checking for hw flags instead of board names seems to
make more sense. Is there enough info from everyone involved to make
changes to the current patch? Or is it sasafe to use as is?



_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


awalls at radix

Dec 2, 2009, 5:48 PM

Post #10 of 18 (7250 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Wed, 2009-12-02 at 18:47 +0100, Martin Dauskardt wrote:
> > Date: Mon, 30 Nov 2009 20:03:02 -0500
> > From: Andy Walls <awalls [at] radix>
>
>
> > I suspect that these signals floating cause the CX23416 to make some bad
> > guesses about audio sample rate when CX2341X_ENC_INTIALIZE_INPUT is
> > called. The only note I have about INITIALIZE_INPUT is that it is for
> > video input initialization.
> >
> > I don't know the history here, but on the surface your patch looks
> > plausible that it would solve the problem. I just don't know about the
> > applicability to other CX2584x/CX23416 boards other then the PVR-150;
> > the patch might apply to them too.
> >
>
> This area around CX2341X_ENC_INTIALIZE_INPUT is critical code which Hans made
> stable after a lot of testing:
>
> http://www.gossamer-threads.com/lists/ivtv/devel/36272
> http://linuxtv.org/hg/v4l-dvb/rev/904736fc862a
>
> Summary:
> The CX2341X_ENC_INITIALIZE_INPUT firmware call should be made whenever the
> digitizer (saa7115 or cx25840) has changed, either because the TV standard was
> changed, another input was chosen (or opening the radio device) or the video
> format changes (e.g. capture size, VBI settings). But it turned out that the
> digitizer has to be turned off before calling this API and turned on
> afterwards. This is definitely the case for the saa7115, the cx25840 seems to
> be more forgiving.


Martin,

Thanks for the pointer to the messages.

So this is a tough choice.

1. The fix to leave the CX2584x pins enabled *may occasionally* hang
people's machines, according to those results of Hans. :(

or

2. Floating CX2584x -> CX23416 clock pins will almost certainly result
in tinny audio.



> I remember that the 300ms ivtv_msleep_timeout was absolutely necessary to
> avoid occasionally black video after starting the capture. (I don't know if
> this is related to the digitizer calls or if we simply need this time to allow
> execution of the previous encoder commands before calling
> CX2341X_ENC_INITIALIZE_INPUT.)

It is probably needed for the clock output of the digitizer to
stabilize.


Argus,

Here's the patch I'm ready to apply to the latest ivtv driver, but could
you do more extensive testing - starting and stopping captures - to make
sure your machine never hangs with your fix.


diff -r e0cd9a337600 linux/drivers/media/video/ivtv/ivtv-streams.c
--- a/linux/drivers/media/video/ivtv/ivtv-streams.c Sun Nov 29 12:08:02 2009 -0200
+++ b/linux/drivers/media/video/ivtv/ivtv-streams.c Wed Dec 02 20:31:43 2009 -0500
@@ -576,10 +576,16 @@
clear_bit(IVTV_F_I_EOS, &itv->i_flags);

/* Initialize Digitizer for Capture */
- v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
+ if (itv->sd_video->grp_id & IVTV_HW_CX25840)
+ v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
+ else
+ v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
ivtv_msleep_timeout(300, 1);
+
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
- v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
+
+ if (!(itv->sd_video->grp_id & IVTV_HW_CX25840))
+ v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
}

/* begin_capture */




> @ ivtv at moasat:
> This is the first time that I read about tinny audio with a PVR350. Are you
> sure that this card has the same problem?
>
> If it comes out that the tinny audio is related to cx25840 only, and that
> these digitizer does not need to be turned off, than a modified code should
> check for itv->hw_flags & IVTV_HW_CX25840 instead of board names.
>
> BTW: For the pvrinput vdr plugin I am using the encoder stop/start ioctls for
> every channel switch (to clear the encoder). While the whole process of
> stopping, tuning and starting is very fast with a PVR250/350, it takes nearly
> a second longer with PVR150. Maybe turning the cx25840 off and on takes longer
> than with saa7115.

There are 2 I2C register wrties to the CX2584x, for every 1 I2C register
write to the SAA7115.

Regards,
Andy


_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


pthorn-ivtvd at styx2002

Dec 2, 2009, 8:54 PM

Post #11 of 18 (7242 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Wed, 2 Dec 2009, Andy Walls wrote:

> On Wed, 2009-12-02 at 18:47 +0100, Martin Dauskardt wrote:
>>> Date: Mon, 30 Nov 2009 20:03:02 -0500
>>> From: Andy Walls <awalls [at] radix>
>>
> Argus,
>
> Here's the patch I'm ready to apply to the latest ivtv driver, but could
> you do more extensive testing - starting and stopping captures - to make
> sure your machine never hangs with your fix.

Andy,

I'm not sure if you meant for me to exercise your latest patch
below, or if you meant for me to exercise my original patch.

The trouble is: I am not running a latest kernel anywhere to
test your patch below. I was making my patches against a 2.6.28
kernel (older, I know, but the machine that holds the 150s is
remote and not easily upgraded). Can I compile just the latest
ivtv driver and install it over the 2.6.28 module? I'm guessing
not ...

Having said that, the uptime on my backend machine is sitting at
24 days and it averages 5 or so recordings per day -- with my original
patch installed. Seems reasonably stable after 100 or so recordings.

Cheers,
- Argus


> diff -r e0cd9a337600 linux/drivers/media/video/ivtv/ivtv-streams.c
> --- a/linux/drivers/media/video/ivtv/ivtv-streams.c Sun Nov 29 12:08:02 2009 -0200
> +++ b/linux/drivers/media/video/ivtv/ivtv-streams.c Wed Dec 02 20:31:43 2009 -0500
> @@ -576,10 +576,16 @@
> clear_bit(IVTV_F_I_EOS, &itv->i_flags);
>
> /* Initialize Digitizer for Capture */
> - v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
> + if (itv->sd_video->grp_id & IVTV_HW_CX25840)
> + v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> + else
> + v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
> ivtv_msleep_timeout(300, 1);
> +
> ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
> - v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> +
> + if (!(itv->sd_video->grp_id & IVTV_HW_CX25840))
> + v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> }
>
> /* begin_capture */
>
>

_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


martin.dauskardt at gmx

Dec 4, 2009, 12:46 AM

Post #12 of 18 (7206 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

> Here's the patch I'm ready to apply to the latest ivtv driver, but could
> you do more extensive testing - starting and stopping captures - to make
> sure your machine never hangs with your fix.
>
>
> diff -r e0cd9a337600 linux/drivers/media/video/ivtv/ivtv-streams.c
> --- a/linux/drivers/media/video/ivtv/ivtv-streams.c Sun Nov 29 12:08:02
> 2009 -0200 +++ b/linux/drivers/media/video/ivtv/ivtv-streams.c Wed Dec 02
> 20:31:43 2009 -0500 @@ -576,10 +576,16 @@
> clear_bit(IVTV_F_I_EOS, &itv->i_flags);
>
> /* Initialize Digitizer for Capture */
> - v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
> + if (itv->sd_video->grp_id & IVTV_HW_CX25840)
> + v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> + else
> + v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
> ivtv_msleep_timeout(300, 1);
> +
> ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
> - v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> +
> + if (!(itv->sd_video->grp_id & IVTV_HW_CX25840))
> + v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> }
>
> /* begin_capture */


why this:
> + if (itv->sd_video->grp_id & IVTV_HW_CX25840)
> + v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
we never turned off the cx25840 digitizer before, so there should be no need
to turn it on.

Why do you suggest

(itv->sd_video->grp_id & IVTV_HW_CX25840)

instead of

(itv->hw_flags & IVTV_HW_CX25840)

? What is the difference?

My idea is to do it this way (whole code block):

if (atomic_read(&itv->capturing) == 0) {
/* Clear all Pending Interrupts */
ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);

clear_bit(IVTV_F_I_EOS, &itv->i_flags);

/* Initialize Digitizer for Capture */
if (!itv->hw_flags & IVTV_HW_CX25840) {
v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
ivtv_msleep_timeout(300, 1);
}
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
if (!itv->hw_flags & IVTV_HW_CX25840) {
v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
}
}

In this version I assume that the 300ms sleep is only necessary when the
digitizer was turned off, which only happens for non-cx25840 cards.
For saa7115-based cards like PVR350 the code remains unchanged. I have two
PVR350 cards and never had any audio problems.

I am only a hobbyist, so please forgive me if there is an error ...

> From: Argus <pthorn-ivtvd [at] styx2002>
>
> The trouble is: I am not running a latest kernel anywhere to
> test your patch below. I was making my patches against a 2.6.28
> kernel (older, I know, but the machine that holds the 150s is
> remote and not easily upgraded). Can I compile just the latest
> ivtv driver and install it over the 2.6.28 module? I'm guessing
> not ...

I think you need to replace
v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
with
itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);

and
v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
with
itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);

@ Andy:
Is this only a different cody style, or does a subdev_call effect other things
than the VIDIOC_STREAMOFF/ON ioctls?

Greets,
Martin

_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


awalls at radix

Dec 4, 2009, 3:23 AM

Post #13 of 18 (7200 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Fri, 2009-12-04 at 09:46 +0100, Martin Dauskardt wrote:
> > Here's the patch I'm ready to apply to the latest ivtv driver, but could
> > you do more extensive testing - starting and stopping captures - to make
> > sure your machine never hangs with your fix.
> >
> >
> > diff -r e0cd9a337600 linux/drivers/media/video/ivtv/ivtv-streams.c
> > --- a/linux/drivers/media/video/ivtv/ivtv-streams.c Sun Nov 29 12:08:02
> > 2009 -0200 +++ b/linux/drivers/media/video/ivtv/ivtv-streams.c Wed Dec 02
> > 20:31:43 2009 -0500 @@ -576,10 +576,16 @@
> > clear_bit(IVTV_F_I_EOS, &itv->i_flags);
> >
> > /* Initialize Digitizer for Capture */
> > - v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
> > + if (itv->sd_video->grp_id & IVTV_HW_CX25840)
> > + v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> > + else
> > + v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
> > ivtv_msleep_timeout(300, 1);
> > +
> > ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
> > - v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> > +
> > + if (!(itv->sd_video->grp_id & IVTV_HW_CX25840))
> > + v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> > }
> >
> > /* begin_capture */
>
>
> why this:
> > + if (itv->sd_video->grp_id & IVTV_HW_CX25840)
> > + v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> we never turned off the cx25840 digitizer before, so there should be no need
> to turn it on.

Martin,

It is not "turning the digitizer on/off" but really "enable/disable the
clock output pins of the digitizer". The cause of the tinny audio is
likely that the clock pins from the CX2584x are floating.

This call makes sure the clock output enables are turned on and the pins
are not floating. I suspect no where else are they explciity enabled in
the driver before the first capture (I can go back and verify).



> Why do you suggest
>
> (itv->sd_video->grp_id & IVTV_HW_CX25840)
>
> instead of
>
> (itv->hw_flags & IVTV_HW_CX25840)
>
> ? What is the difference?

Nothing. They are equivalent. We could use either. I chose to
dereference from itv->sd_video because it was right there in the code.


> My idea is to do it this way (whole code block):
>
> if (atomic_read(&itv->capturing) == 0) {
> /* Clear all Pending Interrupts */
> ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
>
> clear_bit(IVTV_F_I_EOS, &itv->i_flags);
>
> /* Initialize Digitizer for Capture */
> if (!itv->hw_flags & IVTV_HW_CX25840) {
> v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
> ivtv_msleep_timeout(300, 1);
> }
> ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
> if (!itv->hw_flags & IVTV_HW_CX25840) {
> v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> }
> }
>
> In this version I assume that the 300ms sleep is only necessary when the
> digitizer was turned off, which only happens for non-cx25840 cards.
> For saa7115-based cards like PVR350 the code remains unchanged. I have two
> PVR350 cards and never had any audio problems.
>
> I am only a hobbyist, so please forgive me if there is an error ...

No that's fine too; as long as *somewhere* in the ivtv driver we turn on
the CX2584x's output enables before the first capture.

Since Hans had reported that this particular
CX2341X_ENC_INITIALIZE_INPUT call can hang a machine, it may be woth
adding a module option to let users who have a problem with a PCI bus
hang to live with fuzzy audio.


> > From: Argus <pthorn-ivtvd [at] styx2002>
> >
> > The trouble is: I am not running a latest kernel anywhere to
> > test your patch below. I was making my patches against a 2.6.28
> > kernel (older, I know, but the machine that holds the 150s is
> > remote and not easily upgraded). Can I compile just the latest
> > ivtv driver and install it over the 2.6.28 module? I'm guessing
> > not ...
>
> I think you need to replace
> v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
> with
> itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
>
> and
> v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
> with
> itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
>
> @ Andy:
> Is this only a different cody style, or does a subdev_call effect other things
> than the VIDIOC_STREAMOFF/ON ioctls?

Generally, there should be no difference, but it may be slightly
different. The newer subdev version strictly targets the analog video
decoder. (Since the CX2584x is both video and audio decoder, s_stream
affects both audio and video clocks). I haven't looked to see if the
legacy code avoided touching the MSP34xx output.

Regards,
Andy

> Greets,
> Martin



_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


martin.dauskardt at gmx

Dec 6, 2009, 10:44 AM

Post #14 of 18 (7072 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

> From: Andy Walls <awalls [at] radix>
> Martin,
>
> It is not "turning the digitizer on/off" but really "enable/disable the
> clock output pins of the digitizer". The cause of the tinny audio is
> likely that the clock pins from the CX2584x are floating.
>
> This call makes sure the clock output enables are turned on and the pins
> are not floating. I suspect no where else are they explciity enabled in
> the driver before the first capture (I can go back and verify).
>
> > I am only a hobbyist, so please forgive me if there is an error ...
>
> No that's fine too; as long as *somewhere* in the ivtv driver we turn on
> the CX2584x's output enables before the first capture.
>

It really seems that no where else the clock output pins are enabled. I did
not find another s_stream call to the digitizer. But amazing: Even I comment
out the line
v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
the stream starts most of the time (but fails occasionally).

You wrote "I suspect that these signals floating cause the CX23416 to make
some bad guesses about audio sample rate when CX2341X_ENC_INTIALIZE_INPUT is
called. "
Then we have to enable the digitizer before CX2341X_ENC_INTIALIZE_INPUT.

But the first patch from Argus -which helped him to solve the problem- does
not enable the output. So this is either not necessary or the real problem is
something else. (I made a lot of testing with a PVR150 and an unpatched driver
and had never any audio problems)

Unfortunately there was a mistake in my last code. The if-statement has to be
in additionally brackets, otherwise it is never true and the digitizer is not
disabled for saa7115-based card.

I tested this code now with PVR150 and PVR350:

if (atomic_read(&itv->capturing) == 0) {
/* Clear all Pending Interrupts */
ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);

clear_bit(IVTV_F_I_EOS, &itv->i_flags);

/* Turn off non-cx25840 digitizer to avoid flickering */
if (!(itv->sd_video->grp_id & IVTV_HW_CX25840)) {
v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
}
else {
/* make sure the cx25840 clock output pins are enabled and not
floating */
v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
}

ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);

/* Turn on non-cx25840 digitizer and allow clock
output of the digitizer to stabilize before starting
capture */
if (!(itv->sd_video->grp_id & IVTV_HW_CX25840)) {
v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
ivtv_msleep_timeout(300, 1);
}
}

You mentioned that the 300ms sleep is probably needed for the clock output of
the digitizer to stabilize. For me it seems more logical if this is done
after ***enabling*** the digitizer output, so I moved this. It seems to work
fine.

I made a similar test with the pvrusb2 driver (which has a black video problem
and currently no timeout sleep after the digitizer switches). There it works
better when we place the sleep after re-enabling the digitizer. So I think the
above solution should be right.

I also tested if we can avoid disabling the digitizer for saa7115. Both
pvrusb2 (old model 29xxx) and PVR350 show disturbance (sync problems) when
stopping/starting a stream. This leads to flickering with cx23415 (PVR350).
The cx23416 has no flickering problem, but it is annoying to see sync problems
during channel switches.
The cx25840 devices (PVR150 and the pvrusb2-based HVR1900) do not show these
problems. The connection to the cx23416 must be different - the new stream
appears always without any snc issues.

Suggestion:
We need more testers to see if a driver change like above is safe for
everybody. Even if it turns out that it is no reliable fix against tinny
audio, it improves the speed for encoder stop/start on cx25840 devices.
I don't know if Myth is stopping/starting the stream for every channel switch,
but for vdr (pvrinput-plugin) we are doing this. And there I recognize that
channel switching is faster now with cx25840 devices.

And we shouldn't do anything without hearing Hans.... Hans, where are you?

Greets,
Martin


_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


martin.dauskardt at gmx

Dec 31, 2009, 9:15 AM

Post #15 of 18 (6272 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

Hi everybody,

first test results from me:

As expected, the double "ivtv_msleep_timeout(300, 1);" in ivtv-streams.c
increases the time for stopping/starting a stream. I removed the first call
and it still works fine.

@ Mike:
Previously I suggested to add a msleep(300) in state_eval_decoder_run
(pvrusb2-hdw.c), after calling pvr2_decoder_enable(hdw,!0).

With the change from Andy I now have again sporadic black screens with my
saa7115-based PVRUSB2. So I moved the sleep directly into "static int
pvr2_decoder_enable":

--- v4l-dvb-bugfix-7753cdcebd28-orig/v4l-dvb-
bugfix-7753cdcebd28/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c 2009-12-24
17:06:08.000000000 +0100
+++ v4l-dvb-bugfix-7753cdcebd28-patched/v4l-dvb-
bugfix-7753cdcebd28/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c 2009-12-31
17:19:22.836251706 +0100
@@ -1716,6 +1716,7 @@
(enablefl ? "on" : "off"));
v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_stream, enablefl);
v4l2_device_call_all(&hdw->v4l2_dev, 0, audio, s_stream, enablefl);
+ if (enablefl != 0) msleep(300);
if (hdw->decoder_client_id) {
/* We get here if the encoder has been noticed. Otherwise
we'll issue a warning to the user (which should

Funny- this seems to work, no more black screens appeared.


The remaining questions are in my opinion:

1.)
What is Hans opinion about the changes, especially the move of the 300ms sleep
from "after disabling the digitizer" to "after enabling it" ?

2.)
Do we want to keep disabling the digitizer during the
CX2341X_ENC_INITIALIZE_INPUT call in case the digitizer is a cx25840x ?
It seems to be necessary only for the saa7115.
Note: The cx88-blackbird-driver does also no disabling/enabling of the
digitizer (cx2388x) when doing this firmware call.

3.)
Does Andys Patch solve the tinny audio problem for Argus (who originally
posted the problem and a different solution in the ivtv-devel list). I add him
in cc.

Greets and Happy New Year

Martin

PS:
Readers on the ivtv-devel ML list will miss previous postings (the list was
down a few days). Please have a look in
http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/14151
and
http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/14155

_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


awalls at radix

Dec 31, 2009, 11:26 AM

Post #16 of 18 (6275 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Thu, 2009-12-31 at 18:15 +0100, Martin Dauskardt wrote:
> Hi everybody,
>
> first test results from me:
>
> As expected, the double "ivtv_msleep_timeout(300, 1);" in ivtv-streams.c
> increases the time for stopping/starting a stream. I removed the first call
> and it still works fine.

Yes, I knew the initial 300 ms delay before the call to
CX2341X_ENC_INITIALIZE_INPUT was lame, but it should always be safe. I
really want to avoid a video signal from the saa7115 causing the
CX2341[56] to hang the PCI bus.

I was hoping you could find a small number empirically that was safe. I
was thinking at *most* 10 ms for lines to settle: time for audio clocks
to come up to avoid tinny audio and time for video clocks to stop to
avoid PCI bus hangs. It sounds like you determined 0 ms is OK. I
suspect then, that the time to set up and send the
CX2341X_ENC_INITIALIZE_INPUT command to the encoder provides enough
delay.


> @ Mike:
> Previously I suggested to add a msleep(300) in state_eval_decoder_run
> (pvrusb2-hdw.c), after calling pvr2_decoder_enable(hdw,!0).
>
> With the change from Andy I now have again sporadic black screens with my
> saa7115-based PVRUSB2.

Hmmm. That's odd. All I did was separate out video and audio clock
enable/disable into two seperate steps for CX2584x units, or add a small
delay for SAA7115 units.

> So I moved the sleep directly into "static int
> pvr2_decoder_enable":
>
> --- v4l-dvb-bugfix-7753cdcebd28-orig/v4l-dvb-
> bugfix-7753cdcebd28/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c 2009-12-24
> 17:06:08.000000000 +0100
> +++ v4l-dvb-bugfix-7753cdcebd28-patched/v4l-dvb-
> bugfix-7753cdcebd28/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c 2009-12-31
> 17:19:22.836251706 +0100
> @@ -1716,6 +1716,7 @@
> (enablefl ? "on" : "off"));
> v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_stream, enablefl);
> v4l2_device_call_all(&hdw->v4l2_dev, 0, audio, s_stream, enablefl);
> + if (enablefl != 0) msleep(300);
> if (hdw->decoder_client_id) {
> /* We get here if the encoder has been noticed. Otherwise
> we'll issue a warning to the user (which should
>
> Funny- this seems to work, no more black screens appeared.
>
>
> The remaining questions are in my opinion:
>
> 1.)
> What is Hans opinion about the changes, especially the move of the 300ms sleep
> from "after disabling the digitizer" to "after enabling it" ?

My opinion is to use as short a delay as needed before the call to
CX2341X_ENC_INITIALIZE_INPUT, to avoid tinny audio and avoid PCI bus
hangs.

If you found 0 ms delay was fine, then perhaps I'll just remove that
delay or use something like 1 ms, OK?


For the delay after the CX2341X_ENC_INITIALIZE_INPUT, I think it is
good, as there are probably a few things going on:

a. The digitizer clock lines stabilizing as mentioned earlier

b. The CX2341X_ENC_INITIALIZE_INPUT call may still be executing on the
CX23416, when the ivtv_vapi() returns (I haven't disassembeld the
firmware to check if that is the actually case and how long it might
take).

c. before the call to CX2341X_ENC_START_CAPTURE to start the *first*
capture, the CX2341[56] may need a few valid rasters from the digitizer
stored in its memory.

So the delay after enabling the digitzer makes sure at least a few
rasters are available for the CX2341[56] to operate on. A 300 ms delay
is 15 fields for PAL and 18 fields for NTSC. A wait of 100 ms would be
5 fields for PAL and 6 fields for NTSC, and probably enough.

I think this hypothesis is consistent with the pvrusb2 and ivtv hardware
behavior you noticed.


> 2.)
> Do we want to keep disabling the digitizer during the
> CX2341X_ENC_INITIALIZE_INPUT call in case the digitizer is a cx25840x ?
> It seems to be necessary only for the saa7115.
> Note: The cx88-blackbird-driver does also no disabling/enabling of the
> digitizer (cx2388x) when doing this firmware call.

I would want to do so.

It is my understanding that, notwithstanding any firmware bugs, the
machines in the CX2341[56] chips have some hardware bugs. I want to
avoid tripping over those bugs and locking up someone's machine
intermittently.


The CX2388[0123] is a differnent type of machine internally, not subject
to the same of hardware bugs that the CX2341[56] have that may hang the
machine/PCI bus. The CX2388x should be providing the DMA engines and
the PCI bus connection. I do not know the full details of the Blackbird
board design, but I assume the CX23416 does not interface directly to
the PCI bus along with the CX2388x (which would require a PCI bridge
chip on the card much like a PVR-500).


However, yes it could be the case the Conexant digitizer (CX2584x and
CX2388x internal) output VIP/BT.656 data in a form that at all times
never causes the CX23416 any problems. I really just don't know what
conditions cause the CX23416 to intermittently hang a machine, so I'd
prefer want to avoid any potential causes of hangs.


> 3.)
> Does Andys Patch solve the tinny audio problem for Argus (who originally
> posted the problem and a different solution in the ivtv-devel list). I add him
> in cc.

Yes, that's a question I had.



My preferences in summary, is that not matter what the digitizer chip:

a. I'd like to keep the audio clocks always up to avoid tinny audio.

b. I'd also like to inhibit the video clock and add the delay after
re-enabling the digitizer to avoid the *potential* for a hung machine.

c. I do not care to much about the delay after disbaling the video
clock, only that it is empirically "long enough".

Thanks for taking the time to test and comment.

Regards,
Andy

> Greets and Happy New Year
>
> Martin
>
> PS:
> Readers on the ivtv-devel ML list will miss previous postings (the list was
> down a few days). Please have a look in
> http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/14151
> and
> http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/14155



_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


awalls at radix

Dec 31, 2009, 11:40 AM

Post #17 of 18 (6259 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

On Thu, 2009-12-31 at 14:26 -0500, Andy Walls wrote:
> On Thu, 2009-12-31 at 18:15 +0100, Martin Dauskardt wrote:

Some corrections to errors:

> My preferences in summary, is that not matter what the digitizer chip:

My preferences are, in summary, that no matter what the digitizer chip:

> a. I'd like to keep the audio clocks always up to avoid tinny audio.
>
> b. I'd also like to inhibit the video clock and add the delay after
^^^
refine
> re-enabling the digitizer to avoid the *potential* for a hung machine.
A value smaller than 300 ms should work, but a value smaller than 40 ms
may not work, if my hypothesis is correct.


>
> c. I do not care to much about the delay after disbaling the video
> clock, only that it is empirically "long enough".
>
> Thanks for taking the time to test and comment.
>
> Regards,
> Andy

Regards,
Andy

> > Greets and Happy New Year
> >
> > Martin
> >
> > PS:
> > Readers on the ivtv-devel ML list will miss previous postings (the list was
> > down a few days). Please have a look in
> > http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/14151
> > and
> > http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/14155



_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel


martin.dauskardt at gmx

Jan 3, 2010, 3:29 PM

Post #18 of 18 (6177 views)
Permalink
Re: PVR150 Tinny/fuzzy audio w/ patch? [In reply to]

Am Donnerstag, 31. Dezember 2009 20:40:15 schrieb Andy Walls:
> On Thu, 2009-12-31 at 14:26 -0500, Andy Walls wrote:
> > On Thu, 2009-12-31 at 18:15 +0100, Martin Dauskardt wrote:
>
> Some corrections to errors:
> > My preferences in summary, is that not matter what the digitizer chip:
>
> My preferences are, in summary, that no matter what the digitizer chip:
> > a. I'd like to keep the audio clocks always up to avoid tinny audio.
> >
> > b. I'd also like to inhibit the video clock and add the delay after
>
> ^^^
> refine
>
> > re-enabling the digitizer to avoid the *potential* for a hung machine.
>
> A value smaller than 300 ms should work, but a value smaller than 40 ms
> may not work, if my hypothesis is correct.
>
> > c. I do not care to much about the delay after disbaling the video
> > clock, only that it is empirically "long enough".
> >
> > Thanks for taking the time to test and comment.
> >
> > Regards,
> > Andy
>
> Regards,
> Andy

I tested various sleep values:
http://home.arcor-online.de/martin.dauskardt/digitizer_msleep.xls

It seems that we only need a total delay of 300ms between the previous actions
in ivtv-streams.c and the start of the capture.

This also secures that we don't see disturbance from a previous frequency
switch. This happens with smaller sleep values:
http://home.arcor-online.de/martin.dauskardt/channelswitch.mpg
and can lead to the infamous flickering problem (http://www.gossamer-
threads.com/lists/ivtv/devel/32970) . The current driver has this problem only
with cx23415 (PVR350), not cx23416.

My preference is:
-let it how it is (300 ms sleep before the firmware call)
or
-split the 300ms to 150 and 150

Greets,
Martin

_______________________________________________
ivtv-devel mailing list
ivtv-devel [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-devel

ivtv devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.