[3/3,media] cobalt: Use v4l2_calc_timeperframe helper

Message ID 070c9e71b359c0f6da7410b5ab9207210925549a.1490095965.git.joabreu@synopsys.com (mailing list archive)
State Superseded, archived
Delegated to: Hans Verkuil
Headers

Commit Message

Jose Abreu March 21, 2017, 11:49 a.m. UTC
  Currently, cobalt driver always returns 60fps in g_parm.
This patch uses the new v4l2_calc_timeperframe helper to
calculate the time per frame value.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: Carlos Palminha <palminha@synopsys.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: linux-media@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/media/pci/cobalt/cobalt-v4l2.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
  

Comments

Hans Verkuil March 30, 2017, 1:42 p.m. UTC | #1
Hi Jose,

On 21/03/17 12:49, Jose Abreu wrote:
> Currently, cobalt driver always returns 60fps in g_parm.
> This patch uses the new v4l2_calc_timeperframe helper to
> calculate the time per frame value.

I can verify that g_parm works, so:

Tested-by: Hans Verkuil <hans.verkuil@cisco.com>

However, the adv7604 pixelclock detection resolution is only 0.25 MHz, so it
can't tell the difference between 24 and 23.97 Hz. I can't set the new
V4L2_DV_FL_CAN_DETECT_REDUCED_FPS flag there.

It might be possible to implement this for the adv7842 receiver, I think that
that hardware is much more precise.

I would have to try this, but that will have to wait until Friday next week.

Regards,

	Hans

> 
> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> Cc: Carlos Palminha <palminha@synopsys.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: linux-media@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/media/pci/cobalt/cobalt-v4l2.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c
> index def4a3b..25532ae 100644
> --- a/drivers/media/pci/cobalt/cobalt-v4l2.c
> +++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
> @@ -1076,10 +1076,15 @@ static int cobalt_subscribe_event(struct v4l2_fh *fh,
>  
>  static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
>  {
> +	struct cobalt_stream *s = video_drvdata(file);
> +	struct v4l2_fract fps;
> +
>  	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
>  		return -EINVAL;
> -	a->parm.capture.timeperframe.numerator = 1;
> -	a->parm.capture.timeperframe.denominator = 60;
> +
> +	fps = v4l2_calc_timeperframe(&s->timings);
> +	a->parm.capture.timeperframe.numerator = fps.numerator;
> +	a->parm.capture.timeperframe.denominator = fps.denominator;
>  	a->parm.capture.readbuffers = 3;
>  	return 0;
>  }
>
  
Jose Abreu March 31, 2017, 8:59 a.m. UTC | #2
Hi Hans,


On 30-03-2017 14:42, Hans Verkuil wrote:
> Hi Jose,
>
> On 21/03/17 12:49, Jose Abreu wrote:
>> Currently, cobalt driver always returns 60fps in g_parm.
>> This patch uses the new v4l2_calc_timeperframe helper to
>> calculate the time per frame value.
> I can verify that g_parm works, so:
>
> Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
>
> However, the adv7604 pixelclock detection resolution is only 0.25 MHz, so it
> can't tell the difference between 24 and 23.97 Hz. I can't set the new
> V4L2_DV_FL_CAN_DETECT_REDUCED_FPS flag there.
>
> It might be possible to implement this for the adv7842 receiver, I think that
> that hardware is much more precise.
>
> I would have to try this, but that will have to wait until Friday next week.

Thanks! Yes, maybe its better to test with a different receiver,
if it has more precision then its great. Let me know if you need
any help :)

Best regards,
Jose Miguel Abreu

>
> Regards,
>
> 	Hans
>
>> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
>> Cc: Carlos Palminha <palminha@synopsys.com>
>> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
>> Cc: Hans Verkuil <hans.verkuil@cisco.com>
>> Cc: linux-media@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>>  drivers/media/pci/cobalt/cobalt-v4l2.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c
>> index def4a3b..25532ae 100644
>> --- a/drivers/media/pci/cobalt/cobalt-v4l2.c
>> +++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
>> @@ -1076,10 +1076,15 @@ static int cobalt_subscribe_event(struct v4l2_fh *fh,
>>  
>>  static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
>>  {
>> +	struct cobalt_stream *s = video_drvdata(file);
>> +	struct v4l2_fract fps;
>> +
>>  	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
>>  		return -EINVAL;
>> -	a->parm.capture.timeperframe.numerator = 1;
>> -	a->parm.capture.timeperframe.denominator = 60;
>> +
>> +	fps = v4l2_calc_timeperframe(&s->timings);
>> +	a->parm.capture.timeperframe.numerator = fps.numerator;
>> +	a->parm.capture.timeperframe.denominator = fps.denominator;
>>  	a->parm.capture.readbuffers = 3;
>>  	return 0;
>>  }
>>
  
Jose Abreu April 19, 2017, 10:32 a.m. UTC | #3
Hi Hans,


On 31-03-2017 09:59, Jose Abreu wrote:
> Hi Hans,
>
>
> On 30-03-2017 14:42, Hans Verkuil wrote:
>> Hi Jose,
>>
>> On 21/03/17 12:49, Jose Abreu wrote:
>>> Currently, cobalt driver always returns 60fps in g_parm.
>>> This patch uses the new v4l2_calc_timeperframe helper to
>>> calculate the time per frame value.
>> I can verify that g_parm works, so:
>>
>> Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> However, the adv7604 pixelclock detection resolution is only 0.25 MHz, so it
>> can't tell the difference between 24 and 23.97 Hz. I can't set the new
>> V4L2_DV_FL_CAN_DETECT_REDUCED_FPS flag there.
>>
>> It might be possible to implement this for the adv7842 receiver, I think that
>> that hardware is much more precise.
>>
>> I would have to try this, but that will have to wait until Friday next week.
> Thanks! Yes, maybe its better to test with a different receiver,
> if it has more precision then its great. Let me know if you need
> any help :)

Any news regarding this?

Best regards,
Jose Miguel Abreu

>
> Best regards,
> Jose Miguel Abreu
>
>> Regards,
>>
>> 	Hans
>>
>>> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
>>> Cc: Carlos Palminha <palminha@synopsys.com>
>>> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
>>> Cc: Hans Verkuil <hans.verkuil@cisco.com>
>>> Cc: linux-media@vger.kernel.org
>>> Cc: linux-kernel@vger.kernel.org
>>> ---
>>>  drivers/media/pci/cobalt/cobalt-v4l2.c | 9 +++++++--
>>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c
>>> index def4a3b..25532ae 100644
>>> --- a/drivers/media/pci/cobalt/cobalt-v4l2.c
>>> +++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
>>> @@ -1076,10 +1076,15 @@ static int cobalt_subscribe_event(struct v4l2_fh *fh,
>>>  
>>>  static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
>>>  {
>>> +	struct cobalt_stream *s = video_drvdata(file);
>>> +	struct v4l2_fract fps;
>>> +
>>>  	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
>>>  		return -EINVAL;
>>> -	a->parm.capture.timeperframe.numerator = 1;
>>> -	a->parm.capture.timeperframe.denominator = 60;
>>> +
>>> +	fps = v4l2_calc_timeperframe(&s->timings);
>>> +	a->parm.capture.timeperframe.numerator = fps.numerator;
>>> +	a->parm.capture.timeperframe.denominator = fps.denominator;
>>>  	a->parm.capture.readbuffers = 3;
>>>  	return 0;
>>>  }
>>>
  

Patch

diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c
index def4a3b..25532ae 100644
--- a/drivers/media/pci/cobalt/cobalt-v4l2.c
+++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
@@ -1076,10 +1076,15 @@  static int cobalt_subscribe_event(struct v4l2_fh *fh,
 
 static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
 {
+	struct cobalt_stream *s = video_drvdata(file);
+	struct v4l2_fract fps;
+
 	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 		return -EINVAL;
-	a->parm.capture.timeperframe.numerator = 1;
-	a->parm.capture.timeperframe.denominator = 60;
+
+	fps = v4l2_calc_timeperframe(&s->timings);
+	a->parm.capture.timeperframe.numerator = fps.numerator;
+	a->parm.capture.timeperframe.denominator = fps.denominator;
 	a->parm.capture.readbuffers = 3;
 	return 0;
 }