From: Sakari Ailus <sakari.ailus@iki.fi>
To: Jacek Anaszewski <j.anaszewski81@gmail.com>
Cc: linux-leds@vger.kernel.org, linux-media@vger.kernel.org,
kyungmin.park@samsung.com, pavel@ucw.cz, cooloney@gmail.com,
rpurdie@rpsys.net, s.nawrocki@samsung.com,
Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCH v5 06/10] media: Add registration helpers for V4L2 flash sub-devices
Date: Fri, 24 Apr 2015 00:52:12 +0300 [thread overview]
Message-ID: <5539698C.5030707@iki.fi> (raw)
In-Reply-To: <20150423171026.099b9ea1@ja.home>
Hi Jacek,
Jacek Anaszewski wrote:
...
>>> +#define call_flash_op(v4l2_flash, op, arg) \
>>> + (has_flash_op(v4l2_flash,
>>> op) ? \
>>> + v4l2_flash->ops->op(v4l2_flash,
>>> arg) : \
>>> + -EINVAL)
>>> +
>>> +static enum led_brightness __intensity_to_led_brightness(
>>> + struct v4l2_ctrl *ctrl,
>>> + s32 intensity)
>>
>> Fits on previous line.
>>
>>> +{
>>> + s64 intensity64 = intensity - ctrl->minimum;
>>
>> intensity, ctrl->step and ctrl->minimum are 32-bit signed integers.
>> Do you need a 64-bit integer here?
>
> step is u64.
Nevertheless integer controls will not have values outside the s32
range, using a step value that's outside the range makes no sense
either. I think you should use s32 instead.
>
>>
>>> +
>>> + do_div(intensity64, ctrl->step);
>>> +
>>> + /*
>>> + * Indicator LEDs, unlike torch LEDs, are turned on/off
>>> basing on
>>> + * the state of V4L2_CID_FLASH_INDICATOR_INTENSITY control
>>> only.
>>> + * Therefore it must be possible to set it to 0 level
>>> which in
>>> + * the LED subsystem reflects LED_OFF state.
>>> + */
>>> + if (ctrl->id != V4L2_CID_FLASH_INDICATOR_INTENSITY)
>>> + ++intensity64;
>>
>> I think the condition could simply be ctrl->minimum instead, that way
>> I find it easier to understand what's happening here. I'd expect the
>> minimum for non-intensity controls always to be non-zero, though, so
>> the end result is the same. Up to you.
>
> Minimum for indicator control must be 0 to make possible
> turning the indicator LED off only with this control.
Would torch be still on if the minimum torch current was 0 mA? I'd say no.
Although in that case I'd expect the driver to use a different range,
and selecting the off mode would then turn it off, I still think that's
a better condition than relying on the control id.
...
>>> +static int v4l2_flash_g_volatile_ctrl(struct v4l2_ctrl *c)
>>> +{
>>> + struct v4l2_flash *v4l2_flash = v4l2_ctrl_to_v4l2_flash(c);
>>> + struct led_classdev_flash *fled_cdev =
>>> v4l2_flash->fled_cdev;
>>> + bool is_strobing;
>>> + int ret;
>>> +
>>> + switch (c->id) {
>>> + case V4L2_CID_FLASH_TORCH_INTENSITY:
>>> + case V4L2_CID_FLASH_INDICATOR_INTENSITY:
>>> + return
>>> v4l2_flash_update_led_brightness(v4l2_flash, c);
>>> + case V4L2_CID_FLASH_INTENSITY:
>>> + ret = led_update_flash_brightness(fled_cdev);
>>> + if (ret < 0)
>>> + return ret;
>>> + /* no conversion is needed */
>>
>> Maybe a stupid question, but why is it not needed?
>
> Because LED Flash class also uses microamperes.
Right, I had missed that. It'd be nice if that was said in the comment,
it might not be obvious to others either.
--
Kind regards,
Sakari Ailus
sakari.ailus@iki.fi
next prev parent reply other threads:[~2015-04-23 21:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-15 6:48 [PATCH v5 00/10] LED / flash API integration Jacek Anaszewski
2015-04-15 6:48 ` [PATCH v5 01/10] leds: unify the location of led-trigger API Jacek Anaszewski
2015-04-15 8:32 ` Sakari Ailus
[not found] ` <1429080520-10687-1-git-send-email-j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-04-15 6:48 ` [PATCH v5 02/10] DT: Add documentation for the mfd Maxim max77693 Jacek Anaszewski
2015-04-15 8:33 ` Sakari Ailus
2015-04-29 12:34 ` Lee Jones
2015-04-29 12:59 ` Jacek Anaszewski
2015-04-29 13:16 ` Lee Jones
2015-04-15 6:48 ` [PATCH v5 03/10] leds: Add support for max77693 mfd flash cell Jacek Anaszewski
2015-04-15 9:30 ` Sakari Ailus
2015-04-15 14:07 ` Jacek Anaszewski
2015-04-15 6:48 ` [PATCH v5 04/10] DT: Add documentation for the Skyworks AAT1290 Jacek Anaszewski
[not found] ` <1429080520-10687-5-git-send-email-j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-04-19 12:05 ` Sakari Ailus
2015-04-15 6:48 ` [PATCH v5 05/10] leds: Add driver for AAT1290 flash LED controller Jacek Anaszewski
2015-04-15 6:48 ` [PATCH v5 06/10] media: Add registration helpers for V4L2 flash sub-devices Jacek Anaszewski
2015-04-23 7:40 ` Sakari Ailus
2015-04-23 15:10 ` Jacek Anaszewski
2015-04-23 21:52 ` Sakari Ailus [this message]
2015-04-24 10:29 ` Jacek Anaszewski
2015-04-24 11:56 ` Sakari Ailus
2015-04-15 6:48 ` [PATCH v5 07/10] Documentation: leds: Add description of v4l2-flash sub-device Jacek Anaszewski
2015-04-15 6:48 ` [PATCH v5 08/10] leds: max77693: add support for V4L2 Flash sub-device Jacek Anaszewski
2015-04-15 6:48 ` [PATCH v5 09/10] DT: aat1290: Document handling external strobe sources Jacek Anaszewski
2015-04-15 6:48 ` [PATCH v5 10/10] leds: aat1290: add support for V4L2 Flash sub-device Jacek Anaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5539698C.5030707@iki.fi \
--to=sakari.ailus@iki.fi \
--cc=cooloney@gmail.com \
--cc=hans.verkuil@cisco.com \
--cc=j.anaszewski81@gmail.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-leds@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rpurdie@rpsys.net \
--cc=s.nawrocki@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).