All of lore.kernel.org
 help / color / mirror / Atom feed
* Switching input during capture
@ 2011-10-28  1:31 Gilles Gigan
  2011-10-28 12:42 ` Laurent Pinchart
  0 siblings, 1 reply; 6+ messages in thread
From: Gilles Gigan @ 2011-10-28  1:31 UTC (permalink / raw)
  To: Linux Media Mailing List

Hi,
I would like to know what is the correct way to switch the current
video input during capture on a card with a single BT878 chip and 4
inputs (http://store.bluecherry.net/products/PV%252d143-%252d-4-port-video-capture-card-%2830FPS%29-%252d-OEM.html).
I tried doing it in two ways:
- using VIDIOC_S_INPUT to change the current input. While this works,
the next captured frame shows video from the old input in its top half
and video from the new input in the bottom half.
- I tried setting the input field to the new input and flags to
V4L2_BUF_FLAG_INPUT in the struct v4l2_buffer passed to VIDIOC_QBUF
when enqueuing buffers. However, when doing so, the ioctl fails
altogether, and I cannot enqueue any buffers with the
V4L2_BUF_FLAG_INPUT flag set.
Is there another way of doing it ? or is there a way to synchronise
the input change (when using VIDIOC_S_INPUT) so it happens in between
2 frames and produces a clean switch ?
Thanks
Gilles

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Switching input during capture
  2011-10-28  1:31 Switching input during capture Gilles Gigan
@ 2011-10-28 12:42 ` Laurent Pinchart
  2011-10-28 22:30   ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2011-10-28 12:42 UTC (permalink / raw)
  To: Gilles Gigan; +Cc: Linux Media Mailing List

Hi Gilles,

On Friday 28 October 2011 03:31:53 Gilles Gigan wrote:
> Hi,
> I would like to know what is the correct way to switch the current
> video input during capture on a card with a single BT878 chip and 4
> inputs
> (http://store.bluecherry.net/products/PV%252d143-%252d-4-port-video-captur
> e-card-%2830FPS%29-%252d-OEM.html). I tried doing it in two ways:
> - using VIDIOC_S_INPUT to change the current input. While this works,
> the next captured frame shows video from the old input in its top half
> and video from the new input in the bottom half.
> - I tried setting the input field to the new input and flags to
> V4L2_BUF_FLAG_INPUT in the struct v4l2_buffer passed to VIDIOC_QBUF
> when enqueuing buffers. However, when doing so, the ioctl fails
> altogether, and I cannot enqueue any buffers with the
> V4L2_BUF_FLAG_INPUT flag set.

V4L2_BUF_FLAG_INPUT is (or at least should be) deprecated. It isn't supported 
by mainline drivers and was a mistake in the first place.

> Is there another way of doing it ? or is there a way to synchronise
> the input change (when using VIDIOC_S_INPUT) so it happens in between
> 2 frames and produces a clean switch ?

You will need hardware support for that.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Switching input during capture
  2011-10-28 12:42 ` Laurent Pinchart
@ 2011-10-28 22:30   ` Mauro Carvalho Chehab
  2011-10-29  7:52     ` Laurent Pinchart
  0 siblings, 1 reply; 6+ messages in thread
From: Mauro Carvalho Chehab @ 2011-10-28 22:30 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Gilles Gigan, Linux Media Mailing List

Em 28-10-2011 14:42, Laurent Pinchart escreveu:
> Hi Gilles,
> 
> On Friday 28 October 2011 03:31:53 Gilles Gigan wrote:
>> Hi,
>> I would like to know what is the correct way to switch the current
>> video input during capture on a card with a single BT878 chip and 4
>> inputs
>> (http://store.bluecherry.net/products/PV%252d143-%252d-4-port-video-captur
>> e-card-%2830FPS%29-%252d-OEM.html). I tried doing it in two ways:
>> - using VIDIOC_S_INPUT to change the current input. While this works,
>> the next captured frame shows video from the old input in its top half
>> and video from the new input in the bottom half.

This is is likely easy to fix. The driver has already a logic to prevent changing
the buffer while in the middle of a buffer filling. I suspect that the BKL removal
patches might have broken it somewhat, allowing things like that. basically, it
should be as simple as not allowing changing the input at the top half.

Please try the enclosed patch.

Regards,
Mauro

-

bttv: Avoid switching the video input at the top half.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 3dd0660..6a3be6f 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -3978,7 +3978,7 @@ bttv_irq_switch_video(struct bttv *btv)
 	bttv_set_dma(btv, 0);
 
 	/* switch input */
-	if (UNSET != btv->new_input) {
+	if (! btv->curr.top && UNSET != btv->new_input) {
 		video_mux(btv,btv->new_input);
 		btv->new_input = UNSET;
 	}

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Switching input during capture
  2011-10-28 22:30   ` Mauro Carvalho Chehab
@ 2011-10-29  7:52     ` Laurent Pinchart
  2011-11-07 14:50       ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2011-10-29  7:52 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Gilles Gigan, Linux Media Mailing List

Hi Mauro,

On Saturday 29 October 2011 00:30:12 Mauro Carvalho Chehab wrote:
> Em 28-10-2011 14:42, Laurent Pinchart escreveu:
> > On Friday 28 October 2011 03:31:53 Gilles Gigan wrote:
> >> Hi,
> >> I would like to know what is the correct way to switch the current
> >> video input during capture on a card with a single BT878 chip and 4
> >> inputs
> >> (http://store.bluecherry.net/products/PV%252d143-%252d-4-port-video-capt
> >> ur e-card-%2830FPS%29-%252d-OEM.html). I tried doing it in two ways: -
> >> using VIDIOC_S_INPUT to change the current input. While this works, the
> >> next captured frame shows video from the old input in its top half and
> >> video from the new input in the bottom half.
> 
> This is is likely easy to fix. The driver has already a logic to prevent
> changing the buffer while in the middle of a buffer filling. I suspect
> that the BKL removal patches might have broken it somewhat, allowing
> things like that. basically, it should be as simple as not allowing
> changing the input at the top half.

This will work optimally only if the input analog signals are synchronized, 
right ? If we switch to a new input right when the frame start, can the first 
frame captured on the new input be corrupted ?

> Please try the enclosed patch.
> 
> Regards,
> Mauro
> 
> -
> 
> bttv: Avoid switching the video input at the top half.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> 
> diff --git a/drivers/media/video/bt8xx/bttv-driver.c
> b/drivers/media/video/bt8xx/bttv-driver.c index 3dd0660..6a3be6f 100644
> --- a/drivers/media/video/bt8xx/bttv-driver.c
> +++ b/drivers/media/video/bt8xx/bttv-driver.c
> @@ -3978,7 +3978,7 @@ bttv_irq_switch_video(struct bttv *btv)
>  	bttv_set_dma(btv, 0);
> 
>  	/* switch input */
> -	if (UNSET != btv->new_input) {
> +	if (! btv->curr.top && UNSET != btv->new_input) {
>  		video_mux(btv,btv->new_input);
>  		btv->new_input = UNSET;
>  	}

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Switching input during capture
  2011-10-29  7:52     ` Laurent Pinchart
@ 2011-11-07 14:50       ` Mauro Carvalho Chehab
  2011-11-07 22:19         ` Gilles Gigan
  0 siblings, 1 reply; 6+ messages in thread
From: Mauro Carvalho Chehab @ 2011-11-07 14:50 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Gilles Gigan, Linux Media Mailing List

Em 29-10-2011 05:52, Laurent Pinchart escreveu:
> Hi Mauro,
> 
> On Saturday 29 October 2011 00:30:12 Mauro Carvalho Chehab wrote:
>> Em 28-10-2011 14:42, Laurent Pinchart escreveu:
>>> On Friday 28 October 2011 03:31:53 Gilles Gigan wrote:
>>>> Hi,
>>>> I would like to know what is the correct way to switch the current
>>>> video input during capture on a card with a single BT878 chip and 4
>>>> inputs
>>>> (http://store.bluecherry.net/products/PV%252d143-%252d-4-port-video-capt
>>>> ur e-card-%2830FPS%29-%252d-OEM.html). I tried doing it in two ways: -
>>>> using VIDIOC_S_INPUT to change the current input. While this works, the
>>>> next captured frame shows video from the old input in its top half and
>>>> video from the new input in the bottom half.
>>
>> This is is likely easy to fix. The driver has already a logic to prevent
>> changing the buffer while in the middle of a buffer filling. I suspect
>> that the BKL removal patches might have broken it somewhat, allowing
>> things like that. basically, it should be as simple as not allowing
>> changing the input at the top half.
> 
> This will work optimally only if the input analog signals are synchronized, 
> right ? If we switch to a new input right when the frame start, can the first 
> frame captured on the new input be corrupted ?

That's a good question. I'm not sure how those bttv cards solve it, but as
they're widely used on such configurations, I suspect that the hardware used
on those CCTV boards have some logic to keep them in sync.

> 
>> Please try the enclosed patch.
>>
>> Regards,
>> Mauro
>>
>> -
>>
>> bttv: Avoid switching the video input at the top half.
>>
>> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
>>
>> diff --git a/drivers/media/video/bt8xx/bttv-driver.c
>> b/drivers/media/video/bt8xx/bttv-driver.c index 3dd0660..6a3be6f 100644
>> --- a/drivers/media/video/bt8xx/bttv-driver.c
>> +++ b/drivers/media/video/bt8xx/bttv-driver.c
>> @@ -3978,7 +3978,7 @@ bttv_irq_switch_video(struct bttv *btv)
>>  	bttv_set_dma(btv, 0);
>>
>>  	/* switch input */
>> -	if (UNSET != btv->new_input) {
>> +	if (! btv->curr.top && UNSET != btv->new_input) {
>>  		video_mux(btv,btv->new_input);
>>  		btv->new_input = UNSET;
>>  	}
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Switching input during capture
  2011-11-07 14:50       ` Mauro Carvalho Chehab
@ 2011-11-07 22:19         ` Gilles Gigan
  0 siblings, 0 replies; 6+ messages in thread
From: Gilles Gigan @ 2011-11-07 22:19 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Laurent Pinchart, Linux Media Mailing List

Hi all,

On Tue, Nov 8, 2011 at 1:50 AM, Mauro Carvalho Chehab
<mchehab@redhat.com> wrote:
> Em 29-10-2011 05:52, Laurent Pinchart escreveu:
>> Hi Mauro,
>>
>> On Saturday 29 October 2011 00:30:12 Mauro Carvalho Chehab wrote:
>>> Em 28-10-2011 14:42, Laurent Pinchart escreveu:
>>>> On Friday 28 October 2011 03:31:53 Gilles Gigan wrote:
>>>>> Hi,
>>>>> I would like to know what is the correct way to switch the current
>>>>> video input during capture on a card with a single BT878 chip and 4
>>>>> inputs
>>>>> (http://store.bluecherry.net/products/PV%252d143-%252d-4-port-video-capt
>>>>> ur e-card-%2830FPS%29-%252d-OEM.html). I tried doing it in two ways: -
>>>>> using VIDIOC_S_INPUT to change the current input. While this works, the
>>>>> next captured frame shows video from the old input in its top half and
>>>>> video from the new input in the bottom half.
>>>
>>> This is is likely easy to fix. The driver has already a logic to prevent
>>> changing the buffer while in the middle of a buffer filling. I suspect
>>> that the BKL removal patches might have broken it somewhat, allowing
>>> things like that. basically, it should be as simple as not allowing
>>> changing the input at the top half.
>>
>> This will work optimally only if the input analog signals are synchronized,
>> right ? If we switch to a new input right when the frame start, can the first
>> frame captured on the new input be corrupted ?
>
> That's a good question. I'm not sure how those bttv cards solve it, but as
> they're widely used on such configurations, I suspect that the hardware used
> on those CCTV boards have some logic to keep them in sync.
>
>>
>>> Please try the enclosed patch.
>>>
>>> Regards,
>>> Mauro
>>>
>>> -
>>>
>>> bttv: Avoid switching the video input at the top half.
>>>
>>> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
>>>
>>> diff --git a/drivers/media/video/bt8xx/bttv-driver.c
>>> b/drivers/media/video/bt8xx/bttv-driver.c index 3dd0660..6a3be6f 100644
>>> --- a/drivers/media/video/bt8xx/bttv-driver.c
>>> +++ b/drivers/media/video/bt8xx/bttv-driver.c
>>> @@ -3978,7 +3978,7 @@ bttv_irq_switch_video(struct bttv *btv)
>>>      bttv_set_dma(btv, 0);
>>>
>>>      /* switch input */
>>> -    if (UNSET != btv->new_input) {
>>> +    if (! btv->curr.top && UNSET != btv->new_input) {
>>>              video_mux(btv,btv->new_input);
>>>              btv->new_input = UNSET;
>>>      }
>>
>
>

I am yet to try the above patch myself, but I have received feedback
from another user and it seems it does not solve the issue.
Will keep you posted as soon as I got around to testing it.
Thanks
Gilles

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-07 22:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-28  1:31 Switching input during capture Gilles Gigan
2011-10-28 12:42 ` Laurent Pinchart
2011-10-28 22:30   ` Mauro Carvalho Chehab
2011-10-29  7:52     ` Laurent Pinchart
2011-11-07 14:50       ` Mauro Carvalho Chehab
2011-11-07 22:19         ` Gilles Gigan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.