linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Pavel Machek <pavel@ucw.cz>, Hans de Goede <hdegoede@redhat.com>,
	Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Yauhen Kharuzhy <jekhor@gmail.com>,
	linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH v2 1/2] leds: Add Intel Cherry Trail Whiskey Cove PMIC LEDs
Date: Fri, 15 Feb 2019 22:41:31 +0100	[thread overview]
Message-ID: <6beed61c-1fc6-6525-e873-a8978f5fbffb@gmail.com> (raw)
In-Reply-To: <20190214122840.GA21860@amd>

Hi Pavel,

On 2/14/19 1:28 PM, Pavel Machek wrote:
> Hi!
> 
> Jacek, could we get you to comment here? I'd prefer "hardware" trigger...

What prevents use from using pattern trigger with its hw_pattern file?

Do you remember drivers/leds/leds-sc27xx-bltc.c and its breathing mode,
for which pattern trigger was introduced?

>>>> That assumes that breathing is the default setting on all hardware
>>>> and again I don't see why not to export this functionality to
>>>
>>> Save the status on boot, then restore it on rmmod/reboot/poweroff? :-).
>>
>> Which works until the system freezes one time. I believe that
>> if we are going to do a LED driver for the charging LED on these
>> devices, we MUST offer a way to put it back in its original
>> state, even if the state is foo-barred at bootup.
>>
>>>> userspace. Just because something does not fit in the existing
>>>> API is IMHO not a good reason to not expose it to userspace.
>>>>
>>>> I suggest that we deal with this special case by adding 3 custom
>>>> sysfs attributes:
>>>>
>>>> 1) "mode" which when read, prints, e.g. :
>>>> manual [on-when-charging]
>>>
>>> While this allows _user on console_ to control everything using echo,
>>> it is not suitable for applications trying to control LEDs.
>>>
>>> As there's nothing special about the case here, I believe we should
>>> have generic solution here.
>>>
>>> My preffered solution would be "hardware" trigger that leaves the LED
>>> in hardware control.
>>
>> As you explained in the parts which I snipped, there are many
>> devices which have a similar choice for a LED being under hw or
>> user control. I can see how this looks like a trigger and how we
>> could use the trigger API for this.
>>
>> I believe though, that if we implement a "virtual" (for lack of
>> a better word) trigger for this, that this should be done in the
>> LED core. I can envision this working like this:
> 
> Agreed about the LED core.
> 
>> 1) Add a:
>>
>> hw_control_set(struct led_classdev *led_cdev, bool enable_hw_control);
>>
>> Callback to struct led_classdev which when implemented by a driver
>> like the current PMIC LED controller would do what it says.
>>
>> 2) Have the core create and register a virtual hardware trigger the
>> first time a LED cdev which has this callback gets registered.
>>
>> When configured as the trigger for this LED device this trigger calls
>> hw_control_set(cdev, true) and when unregistered calls
>> hw_control_set(cdev, false)
>>
>> Taking a quick look at the trigger code, a problem with this is
>> that normally any trigger can work with any led device, so this
>> "hardware" trigger will show up in the list of possible
>> triggers for each device.
>>
>> This problem can be solved by making the activate method for the
>> hardware trigger check the classdev has a hw_control_set callback
>> and if not return -EINVAL, or maybe -ENXIO but still this is somewhat
>> inconsistent with other triggers, which AFAIK work with any LED.
> 
> I guess other option is to modify core so that it does not list
> "hardware" trigger for leds that don't support it.

Pattern trigger will not show hw_pattern file if pattern_set/get ops
are not provided.

>>> Alternatively I could imagine "hardware" sysfs attribute, containing
>>> 0/1, with 0==software controlled, 1==hardware controlled.
>>
>> Hmm, maybe call it "hardware_controlled" instead ? Otherwise this
>> would work for me and I would personally prefer this solution. This
>> could even be done in the LED core using the hw_control_set callback
>> I proposed, to make sure it is handled consistently between devices.
> 
> This should be in LED core, yes.
> 
>>> The rest of attributes would have to be Cove-specific, yes (but still
>>> should fit with the rest of LED subsystem).
>>
>> Right, I see that the triggers attribute already uses the fmt where
>> on "cat" all options are listed and the current active one has [] around it,
>> so I think the pattern and frequency attributes I proposed should work
>> well, although thinking more about this I believe the freq. attribute should
>> be called pattern_freq to make clear it applies to blinking / breathing
>> set through the pattern attribute.
> 
> Take a look at blinking trigger. It can already do hardware
> acceleration, but uses different format than what you proposed.
> 
> Best regards,
> 									Pavel
> 

-- 
Best regards,
Jacek Anaszewski

  reply	other threads:[~2019-02-15 21:41 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 20:58 [PATCH v2 0/2] Intel Cherry Trail Whiskey Cove LEDs support Yauhen Kharuzhy
2019-02-12 20:59 ` [PATCH v2 1/2] leds: Add Intel Cherry Trail Whiskey Cove PMIC LEDs Yauhen Kharuzhy
2019-02-13 22:43   ` Hans de Goede
2019-02-13 23:07     ` Pavel Machek
2019-02-13 23:25       ` Hans de Goede
2019-02-13 23:38         ` Pavel Machek
2019-02-14  9:57           ` Hans de Goede
2019-02-14 11:14             ` Pavel Machek
2019-02-14 11:31               ` Hans de Goede
2019-02-14 12:28                 ` Pavel Machek
2019-02-15 21:41                   ` Jacek Anaszewski [this message]
2019-02-15 23:26                     ` Pavel Machek
2019-02-14 21:46                 ` Jacek Anaszewski
2019-02-14 23:03                   ` Pavel Machek
2019-02-15  7:27                     ` Yauhen Kharuzhy
2019-02-15 21:43                       ` Jacek Anaszewski
2019-02-16 11:26                         ` Yauhen Kharuzhy
2019-02-15 11:27                     ` Hans de Goede
2019-02-15 13:02                       ` Pavel Machek
2019-02-15 21:42                       ` Jacek Anaszewski
2019-02-15 22:26                         ` Hans de Goede
2019-02-15 22:31                           ` Jacek Anaszewski
2019-02-15 23:14                             ` Hans de Goede
2019-02-16 17:02                               ` Jacek Anaszewski
2019-02-16 19:01                                 ` Hans de Goede
2019-02-16 19:37                                   ` Pavel Machek
2019-02-16 20:55                                     ` Hans de Goede
2019-02-17  0:08                                       ` Pavel Machek
2019-02-17 14:10                                         ` Hans de Goede
2019-02-17 17:45                                           ` Pavel Machek
2019-02-18 11:12                                             ` Hans de Goede
2019-02-18 21:59                                               ` Jacek Anaszewski
2019-02-16 21:54                                     ` Jacek Anaszewski
2019-02-16 22:03                                       ` Hans de Goede
2019-02-17 12:40                                         ` Jacek Anaszewski
2019-02-14 11:28             ` Pavel Machek
2019-02-14 21:34             ` Yauhen Kharuzhy
2019-02-14  6:55     ` Yauhen Kharuzhy
2019-02-14 10:04     ` Hans de Goede
2019-02-12 20:59 ` [PATCH v2 2/2] mfd: Add leds MFD cell for intel_soc_pmic_chtwc Yauhen Kharuzhy
2019-02-13 21:24   ` Jacek Anaszewski
2019-03-20  9:56   ` Lee Jones
2019-03-20  9:57     ` Lee Jones
2019-04-21 19:28 ` [PATCH v2 0/2] Intel Cherry Trail Whiskey Cove LEDs support Hans de Goede
2019-04-24 18:32   ` Yauhen Kharuzhy

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=6beed61c-1fc6-6525-e873-a8978f5fbffb@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=j.anaszewski@samsung.com \
    --cc=jekhor@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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).