All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vivid: fix gain when autogain is on
@ 2018-06-29  9:40 Hans Verkuil
  2018-07-04 12:16 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Verkuil @ 2018-06-29  9:40 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Hugues FRUCHET

In the vivid driver you want gain to continuous change while autogain
is on. However, dev->jiffies_vid_cap doesn't actually change. It probably
did in the past, but changes in the code caused this to be a fixed value
that is only set when you start streaming.

Replace it by jiffies, which is always changing.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
index 6b0bfa091592..6eb8ad7fb12c 100644
--- a/drivers/media/platform/vivid/vivid-ctrls.c
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -295,7 +295,7 @@ static int vivid_user_vid_g_volatile_ctrl(struct v4l2_ctrl *ctrl)

 	switch (ctrl->id) {
 	case V4L2_CID_AUTOGAIN:
-		dev->gain->val = dev->jiffies_vid_cap & 0xff;
+		dev->gain->val = (jiffies / HZ) & 0xff;
 		break;
 	}
 	return 0;

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

* Re: [PATCH] vivid: fix gain when autogain is on
  2018-06-29  9:40 [PATCH] vivid: fix gain when autogain is on Hans Verkuil
@ 2018-07-04 12:16 ` Mauro Carvalho Chehab
  2018-07-04 12:31   ` Hans Verkuil
  0 siblings, 1 reply; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2018-07-04 12:16 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List, Hugues FRUCHET

Em Fri, 29 Jun 2018 11:40:41 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> In the vivid driver you want gain to continuous change while autogain
> is on. However, dev->jiffies_vid_cap doesn't actually change. It probably
> did in the past, but changes in the code caused this to be a fixed value
> that is only set when you start streaming.
> 
> Replace it by jiffies, which is always changing.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
> diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
> index 6b0bfa091592..6eb8ad7fb12c 100644
> --- a/drivers/media/platform/vivid/vivid-ctrls.c
> +++ b/drivers/media/platform/vivid/vivid-ctrls.c
> @@ -295,7 +295,7 @@ static int vivid_user_vid_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
> 
>  	switch (ctrl->id) {
>  	case V4L2_CID_AUTOGAIN:
> -		dev->gain->val = dev->jiffies_vid_cap & 0xff;
> +		dev->gain->val = (jiffies / HZ) & 0xff;

Manipulating jiffies directly like the above is not a good idea.

Better to use, instead:

	dev->gain->val = (jiffies_to_msecs(jiffies) / 1000) & 0xff;

I'll change the code when applying the patch.


Thanks,
Mauro

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

* Re: [PATCH] vivid: fix gain when autogain is on
  2018-07-04 12:16 ` Mauro Carvalho Chehab
@ 2018-07-04 12:31   ` Hans Verkuil
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2018-07-04 12:31 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Hugues FRUCHET

On 04/07/18 14:16, Mauro Carvalho Chehab wrote:
> Em Fri, 29 Jun 2018 11:40:41 +0200
> Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> 
>> In the vivid driver you want gain to continuous change while autogain
>> is on. However, dev->jiffies_vid_cap doesn't actually change. It probably
>> did in the past, but changes in the code caused this to be a fixed value
>> that is only set when you start streaming.
>>
>> Replace it by jiffies, which is always changing.
>>
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>> ---
>> diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
>> index 6b0bfa091592..6eb8ad7fb12c 100644
>> --- a/drivers/media/platform/vivid/vivid-ctrls.c
>> +++ b/drivers/media/platform/vivid/vivid-ctrls.c
>> @@ -295,7 +295,7 @@ static int vivid_user_vid_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
>>
>>  	switch (ctrl->id) {
>>  	case V4L2_CID_AUTOGAIN:
>> -		dev->gain->val = dev->jiffies_vid_cap & 0xff;
>> +		dev->gain->val = (jiffies / HZ) & 0xff;
> 
> Manipulating jiffies directly like the above is not a good idea.

Why not? There are HZ jiffies in one second, so this changes the
gain value once a second.

Regards,

	Hans

> 
> Better to use, instead:
> 
> 	dev->gain->val = (jiffies_to_msecs(jiffies) / 1000) & 0xff;
> 
> I'll change the code when applying the patch.
> 
> 
> Thanks,
> Mauro
> 

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

end of thread, other threads:[~2018-07-04 12:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-29  9:40 [PATCH] vivid: fix gain when autogain is on Hans Verkuil
2018-07-04 12:16 ` Mauro Carvalho Chehab
2018-07-04 12:31   ` Hans Verkuil

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.