All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Linux LED Subsystem <linux-leds@vger.kernel.org>,
	Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	linux-media@vger.kernel.org
Subject: Re: "LED / flash API integration" related improvements
Date: Mon, 16 Jun 2014 11:53:22 +0300	[thread overview]
Message-ID: <20140616085321.GP2073@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <536CE61C.8010205@samsung.com>

Hi Jacek and others,

Comments from the LED API folks would be highly appreciated.

(Cc linux-media as well.)

My comments below.

On Fri, May 09, 2014 at 04:28:44PM +0200, Jacek Anaszewski wrote:
> During review of "LED / flash API integration" patch sets two issues
> requiring modifications in the LED subsystem core emerged.
> I would like to consult possible ways of solving them:
> 
> 1.
> ==================================================================
> 
> Some LED devices allow to control multiple LEDs independently.
> Currently there is no direct support for this in the LED subsystem
> and existing drivers register separate devices for each LED.
> 
> LED / flash API integration effort is a good opportunity to provide
> support for exposing multiple LEDs by a single LED class device.
> 
> I would like to add following API:
> 
> /**
>  * led_get_sub_leds_number - get the number of exposed LEDs
>  * @led_cdev: the LED to query
>  * @num_leds: number of exposed leds
>  *
>  * Get the number of leds exposed by the device.
>  *
>  * Returns: 0 on success or negative error value on failure
>  */
> int led_get_sub_leds_number(struct led_classdev *led_cdev,
>                         int *num_leds);
> 
> /**
>  * led_select_sub_led - select sub led to control
>  * @led_cdev: the LED to set
>  * @led_id: id of the sub led to control
>  *
>  * Set the sub led to be the target of the LED class API calls.
>  * Maximum led_id equals num_leds - 1.
>  *
>  * Returns: 0 on success or negative error value on failure
>  */
> int led_select_sub_led(struct led_classdev *led_cdev,
>                     int led_id);

Instead of this, how about using an array indexed by LED for the other
functions?

The problem with this is that often the registers to control LED specific
properties contain the same configuration for another LED. The driver should
thus cache the information until it needs to be applied, and I don't think
configuring everything for every LED separately makes sense for either the
user nor the driver.

Caching the configuration before applying it should still be done since this
way extra register accesses can be avoided: registers often share different
kind of configurations such as timeout and current as well. The
configuration should be applied once an apply fonction is called.

> /**
>  * led_get_sub_led - get currently selected sub led
>  * @led_cdev: the LED to set
>  * @led_id: id of currently selected sub led
>  *
>  * Get id of the sub led chosen as the target of LED class
>  * API calls. Maximum led_id equals num_leds - 1.
>  *
>  * Returns: 0 on success or negative error value on failure
>  */
> int led_get_target_led(struct led_classdev *led_cdev,
>                         int* led_id);
> 
> The functions functions would be mapped on the sysfs attributes:
> - available_leds - RO
> - sub_led_id - RW

This kind of interface isn't going to be compatible with existing
applications. If you want to keep the compatibility, the LEDs would probably
need to be exposed as separate devices. If that's not a requirement, I'd use
an array here as well.

The V4L2 driver would still expose the device as a single sub-device.
Controls that apply to individual LEDs would be array controls.

> The attributes would be created only if the related callbacks
> are registered by the driver.
> 
> 2.
> ==================================================================
> 
> The second issue, refers to the work queues being used in the
> brightness_set callbacks of the LED subsystem drivers. It interferes
> with the way how V4L2 Flash controls work, which expect that setting
> flash brightness has immediate effect.
> 
> Proposed solutions:
> - move work queues out from the drivers to the LED core.
> - add brightness_set_now callback to be registered by
>   the LED drivers and intended for call by v4l2-flash driver;
>   it wouldn't schedule a work but do the job immediately

I favour the former, but the latter could be used to leave the existing
callback as a compatibility means until all drivers are converted. This
would probably be more work in total though than doing everything in a
single patchset.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

  reply	other threads:[~2014-06-16  8:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-09 14:28 "LED / flash API integration" related improvements Jacek Anaszewski
2014-06-16  8:53 ` Sakari Ailus [this message]
2014-06-16 11:34   ` Jacek Anaszewski
2014-07-07 16:03     ` 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=20140616085321.GP2073@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=b.zolnierkie@samsung.com \
    --cc=cooloney@gmail.com \
    --cc=j.anaszewski@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --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 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.