From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>, Pavel Machek <pavel@ucw.cz>
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 23:31:25 +0100 [thread overview]
Message-ID: <80971bc3-1193-83ed-913a-12f6217016c8@gmail.com> (raw)
In-Reply-To: <87a21c4e-8e5e-c180-2ff3-eb8170746e71@redhat.com>
On 2/15/19 11:26 PM, Hans de Goede wrote:
> Hi,
>
> On 2/15/19 10:42 PM, Jacek Anaszewski wrote:
>> Hi all,
>>
>> On 2/15/19 12:27 PM, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 15-02-19 00:03, Pavel Machek wrote:
>>>> Hi!
>>>>
>>>>>>>> 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:
>>>>>>
>>>>>> 1) Add a:
>>>>>>
>>>>>> hw_control_set(struct led_classdev *led_cdev, bool
>>>>>> enable_hw_control);
>>>>>
>>>>> Please note that we have support for hw patterns in the pattern
>>>>> trigger.
>>>>> (see how drivers/leds/leds-sc27xx-bltc.c makes use of it for its
>>>>> breathing pattern).
>>>>> We have also support for hw blinking in timer trigger via blink_set
>>>>> op.
>>>>>
>>>>> In addition to that there is brightness_hw_changed sysfs attribute
>>>>> with led_classdev_notify_brightness_hw_changed() LED API.
>>>>>
>>>>> Couldn't they be used in concert to support the specific features
>>>>> of the device in question?
>>>>
>>>> I believe main issue here is this:
>>>>
>>>> Hardware can automatically control the LED according to the charging
>>>> status, or it can be used as normal software-controlled LED.
>>>>
>>>> I believe we should use trigger to select if hardware controls it or
>>>> not (and then add driver-specific files to describe the
>>>> details). Other proposal is in the mail thread, too.
>>>
>>> Right, so there are really 2 orthogonal issues here:
>>>
>>> 1) With this hardware the LED is either turned on/off automatically
>>> by the PMIC based on charging state; or it is under user control.
>>>
>>> This is different from the led_classdev_notify_brightness_hw_changed
>>> case, where the hardware may update the state underneath the driver,
>>> but the driver can still always update the state itself. In this case
>>> if the LED is in hw-control mode then the driver cannot turn it on/off.
>>>
>>> Pavel suggested modeling this with a new "hardware' trigger, where
>>> setting the trigger to this trigger will enable the hw-controlled
>>> mode and setting any other trigger will switch thing to the
>>> user-controlled
>>> mode.
>>
>> We already do have hw_pattern file exposed by pattern trigger.
>> It can be used to set hw breathing mode using some device specific
>> syntax semantics, documented in dedicated ABI documentation.
>> It was introduced for similar case, see
>> Documentation/ABI/testing/sysfs-class-led-driver-sc27xx.
>
> Ah I see, yes that could be used, the pattern would just be a single
> integer specifying the cycle time in milliseconds, as nothing
> else is configurable.
I depends on how the pattern looks like. If it is breathing then
we'd need more than one value.
> I think that should work fine, which means that we can use the timer and
> pattern trigger support for the blinking and breathing modes.
>
> That still leaves the switching between user and hw-control modes,
> as discussed the hw-controlled mode could be modelled as a new "hardware"
> trigger, but then we cannot choose between on/blink/breathing when
> in hw-controlled mode. As Pavel mentioned, that would require some
> sort of composed trigger, where we have both the hardware and
> timer triggers active for example.
>
> I think it might be easier to just allow turning on/off the hardware
> control mode through a special "hardware_control" sysfs attribute and
> then use the existing timer and pattern triggers for blinking / breathing.
Pattern trigger exposes pattern file by default and hw_pattern if
pattern_set/get ops are provided. Writing them enables software and
hardware pattern respectively.
--
Best regards,
Jacek Anaszewski
next prev parent reply other threads:[~2019-02-15 22:31 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
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 [this message]
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=80971bc3-1193-83ed-913a-12f6217016c8@gmail.com \
--to=jacek.anaszewski@gmail.com \
--cc=hdegoede@redhat.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
Powered by JetHome