linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	kyungmin.park@samsung.com, b.zolnierkie@samsung.com,
	Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>
Subject: Re: [PATCH/RFC v4 06/21] leds: add API for setting torch brightness
Date: Thu, 07 Aug 2014 15:12:09 +0200	[thread overview]
Message-ID: <53E37B29.2080106@samsung.com> (raw)
In-Reply-To: <20140804125019.GA16460@valkosipuli.retiisi.org.uk>

Hi Sakari,

On 08/04/2014 02:50 PM, Sakari Ailus wrote:
> Hi Jacek,
>
> Thank you for your continued efforts on this!
>
> On Mon, Aug 04, 2014 at 02:35:26PM +0200, Jacek Anaszewski wrote:
>> On 07/16/2014 11:54 PM, Sakari Ailus wrote:
>>> Hi Jacek,
>>>
>>> Jacek Anaszewski wrote:
>>> ...
>>>> diff --git a/include/linux/leds.h b/include/linux/leds.h
>>>> index 1a130cc..9bea9e6 100644
>>>> --- a/include/linux/leds.h
>>>> +++ b/include/linux/leds.h
>>>> @@ -44,11 +44,21 @@ struct led_classdev {
>>>>   #define LED_BLINK_ONESHOT_STOP    (1 << 18)
>>>>   #define LED_BLINK_INVERT    (1 << 19)
>>>>   #define LED_SYSFS_LOCK        (1 << 20)
>>>> +#define LED_DEV_CAP_TORCH    (1 << 21)
>>>>
>>>>       /* Set LED brightness level */
>>>>       /* Must not sleep, use a workqueue if needed */
>>>>       void        (*brightness_set)(struct led_classdev *led_cdev,
>>>>                         enum led_brightness brightness);
>>>> +    /*
>>>> +     * Set LED brightness immediately - it is required for flash led
>>>> +     * devices as they require setting torch brightness to have
>>>> immediate
>>>> +     * effect. brightness_set op cannot be used for this purpose because
>>>> +     * the led drivers schedule a work queue task in it to allow for
>>>> +     * being called from led-triggers, i.e. from the timer irq context.
>>>> +     */
>>>
>>> Do we need to classify actual devices based on this? I think it's rather
>>> a different API behaviour between the LED and the V4L2 APIs.
>>>
>>> On devices that are slow to control, the behaviour should be asynchronous
>>> over the LED API and synchronous when accessed through the V4L2 API. How
>>> about implementing the work queue, as I have suggested, in the
>>> framework, so
>>> that individual drivers don't need to care about this and just implement
>>> the
>>> synchronous variant of this op? A flag could be added to distinguish
>>> devices
>>> that are fast so that the work queue isn't needed.
>>>
>>> It'd be nice to avoid individual drivers having to implement multiple
>>> ops to
>>> do the same thing, just for differing user space interfacs.
>>>
>>
>> It is not only the matter of a device controller speed. If a flash
>> device is to be made accessible from the LED subsystem, then it
>> should be also compatible with led-triggers. Some of led-triggers
>> call brightness_set op from the timer irq context and thus no
>> locking in the callback can occur. This requirement cannot be
>> met i.e. if i2c bus is to be used. This is probably the primary
>> reason for scheduling work queue tasks in brightness_set op.
>>
>> Having the above in mind, setting a brightness in a work queue
>> task must be possible for all LED Class Flash drivers, regardless
>> whether related devices have fast or slow controller.
>>
>> Let's recap the cost of possible solutions then:
>>
>> 1) Moving the work queues to the LED framework
>>
>>    - it would probably require extending led_set_brightness and
>>      __led_set_brightness functions by a parameter indicating whether it
>>      should call brightness_set op in the work queue task or directly;
>>    - all existing triggers would have to be updated accordingly;
>>    - work queues would have to be removed from all the LED drivers;
>>
>> 2) adding led_set_torch_brightness API
>>
>>    - no modifications in existing drivers and triggers would be required
>>    - instead, only the modifications from the discussed patch would
>>      be required
>>
>> Solution 1 looks cleaner but requires much more modifications.
>
> How about a combination of the two, i.e. option 1 with the old op remaining
> there for compatibility with the old drivers (with a comment telling it's
> deprecated)?
>
> This way new drivers will benefit from having to implement this just once,
> and modifications to the existing drivers could be left for later.

It's OK for me, but the opinion from the LED side guys is needed here
as well.

> The downside is that any old drivers wouldn't get V4L2 flash API but that's
> entirely acceptable in my opinion since these would hardly be needed in use
> cases that would benefit from V4L2 flash API.

In the version 4 of the patch set I changed the implementation, so that
a flash led driver must call led_classdev_flash_register to get
registered as a LED Flash Class device and v4l2_flash_init to get
V4L2 Flash API. In effect old drivers will have no chance to get V4L2
Flash API either way.

Best Regards,
Jacek Anaszewski

  reply	other threads:[~2014-08-07 13:12 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11 14:04 [PATCH/RFC v4 00/21] LED / flash API integration Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 01/21] leds: make brightness type consistent across whole subsystem Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 02/21] leds: implement sysfs interface locking mechanism Jacek Anaszewski
2014-07-16 15:35   ` Sakari Ailus
2014-07-11 14:04 ` [PATCH/RFC v4 03/21] leds: Improve and export led_update_brightness Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 04/21] leds: Reorder include directives Jacek Anaszewski
2014-07-16 15:42   ` Sakari Ailus
2014-07-11 14:04 ` [PATCH/RFC v4 05/21] leds: avoid using deprecated DEVICE_ATTR macro Jacek Anaszewski
2014-07-16 15:46   ` Sakari Ailus
2014-07-11 14:04 ` [PATCH/RFC v4 06/21] leds: add API for setting torch brightness Jacek Anaszewski
2014-07-16 21:54   ` Sakari Ailus
2014-08-04 12:35     ` Jacek Anaszewski
2014-08-04 12:50       ` Sakari Ailus
2014-08-07 13:12         ` Jacek Anaszewski [this message]
2014-08-14  4:39           ` Sakari Ailus
2014-08-18 19:55             ` Richard Purdie
2014-08-18 20:06               ` Sakari Ailus
2014-07-11 14:04 ` [PATCH/RFC v4 07/21] of: add of_node_ncmp wrapper Jacek Anaszewski
2014-07-16 22:00   ` Sakari Ailus
2014-07-28 13:41   ` Grant Likely
2014-07-11 14:04 ` [PATCH/RFC v4 08/21] leds: Add sysfs and kernel internal API for flash LEDs Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 09/21] Documentation: leds: Add description of LED Flash Class extension Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 10/21] Documentation: leds: add exemplary asynchronous mux driver Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 11/21] DT: leds: Add flash led devices related properties Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 12/21] DT: Add documentation for LED Class Flash Manger Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 13/21] v4l2-device: add v4l2_device_register_subdev_node API Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 14/21] v4l2-ctrls: add control for flash strobe signal providers Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 15/21] media: Add registration helpers for V4L2 flash Jacek Anaszewski
2014-07-21 11:12   ` Sakari Ailus
2014-08-04 14:43     ` Jacek Anaszewski
2014-08-11 12:26       ` Sakari Ailus
2014-08-11 13:27         ` Jacek Anaszewski
2014-08-11 13:45           ` Jacek Anaszewski
2014-08-14  4:34           ` Sakari Ailus
2014-08-14  8:25             ` Jacek Anaszewski
2014-08-20 14:41               ` Sakari Ailus
2014-08-21  8:38                 ` Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 16/21] leds: Add support for max77693 mfd flash cell Jacek Anaszewski
2014-07-21 14:12   ` Sakari Ailus
2014-07-11 14:04 ` [PATCH/RFC v4 17/21] DT: Add documentation for the mfd Maxim max77693 Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 18/21] leds: Add driver for AAT1290 current regulator Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 19/21] of: Add Skyworks Solutions, Inc. vendor prefix Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 20/21] DT: Add documentation for the Skyworks AAT1290 Jacek Anaszewski
2014-07-11 14:04 ` [PATCH/RFC v4 21/21] ARM: dts: add aat1290 current regulator device node Jacek Anaszewski
2014-07-16 17:19 ` [PATCH/RFC v4 00/21] LED / flash API integration Bryan Wu
2014-07-16 17:21   ` Bryan Wu
2014-08-08  6:43     ` Jacek Anaszewski
2014-08-08 16:59       ` Bryan Wu
2014-08-11 14:24         ` Jacek Anaszewski
2014-08-06  6:53 ` Sakari Ailus
2014-08-07  8:21   ` Jacek Anaszewski
2014-08-07  8:31     ` Jacek Anaszewski
2014-08-14  5:03     ` Sakari Ailus
2014-08-14 10:35       ` Jacek Anaszewski
2014-08-15  4:48         ` Sakari Ailus

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=53E37B29.2080106@samsung.com \
    --to=j.anaszewski@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=cooloney@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    --cc=sakari.ailus@iki.fi \
    /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).