Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp501254imj; Sat, 16 Feb 2019 05:13:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IaqCAWTdOdFDfSE6x4DlZVwG/4K1c2FQu/g7yDYHcyiSDt4gZdzBSmjo9KK4nrGr4/JH+ec X-Received: by 2002:a62:8d4f:: with SMTP id z76mr15247786pfd.2.1550322813958; Sat, 16 Feb 2019 05:13:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550322813; cv=none; d=google.com; s=arc-20160816; b=VtOq4mKCXXi++LotAji5CsFEK4WjUofjDdSuwFm0J2PGrHqu+vpBeeTFBCYFG3/58S x6MqIL8ZUU0Nd8hg3U+xnUKFSLKGFmu9QCoz+xmbXseNRWJCpk5KFZG00kDPC4bevW+7 C6fc/XQDuELSUuqxaxipEmGbXAeDgefeTnY15dVehI4hp+wcW/nimvF8lV6ybX5K+Qzf BMpZIlOoonMenWdUK79eNSmMbKKPCtsz/tJXeiFpjxcTrkUTIAmhIe09yreynSCjObrl JZexe7eLfrsoCQR8OjvH5mde7XY42aWSbeYes3Gvl8kVFyqAGsJQy5ctV+tZ50+pS0yv y+yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Mws+xaLF9V9qnzi9/nLwSnVpo535FW6n67Lb6f1fLds=; b=oinc8aKL2mTF3SwxC2O+x4ZbBD+q/TfrdDsXEoC2A4ybFV8kCNY3hPuPQDgDDDuai+ 21Q6rw9sbq1e72Bc4l47fyGW1w0HGRuCC5yc30eEcEv6bb66CMEXf+RFmTYJLtSp0oLi 6lDqD/nyjtl2Yq0OLBkHevtyhJgT09+rAkRrABrBBzAMhswimCnsQRRx1wePkqbRKIKC zck1SLnkTNWab+c1z2NsQjGmIsPYHyVd5cmgH9/6cJrSMave7HXi+oK58SLKZiAKIWQW K+0TfCAVPMYbn95wgB19aZVz1p8c0WS+5X9LXR43/6adjK7tAMhIQmf0hzvMy/v4rHa6 3tYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Xl4T60GM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si8502135ple.389.2019.02.16.05.13.17; Sat, 16 Feb 2019 05:13:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Xl4T60GM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726992AbfBPL0S (ORCPT + 99 others); Sat, 16 Feb 2019 06:26:18 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:33297 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbfBPL0R (ORCPT ); Sat, 16 Feb 2019 06:26:17 -0500 Received: by mail-wm1-f68.google.com with SMTP id h22so8480092wmb.0; Sat, 16 Feb 2019 03:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=Mws+xaLF9V9qnzi9/nLwSnVpo535FW6n67Lb6f1fLds=; b=Xl4T60GMBrzoIl6n2jy+/wAGdOONoVZ/aacF2rs1DG8yFHCs3RIfv1AxlHsIZgZvFj dL4vwwTPlB0+lJktCKsMORZxnRhPZHhH64T8oskuz0GdhM+JBQDu8XTNUN7N6M6W4O5G 1ngCmixyvRwNX76Ftk0euqAdmq4NfAFRPo31lynZDVrAcnFDKK4MyhiUsPKUXrnf1wrI Xf+F9UfiQdP1zFw7CzpiHJrjLhrNVKjd8SdgAdDZhAkuTkQKu8v6iozaYRpnfD5DobxH Z8dey8anO3agmuBnZPXlP6N/VtVBuFfLVlHdwBWyJZBa7djBxOgDF5UlVkiJEWa9IgWr QS/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Mws+xaLF9V9qnzi9/nLwSnVpo535FW6n67Lb6f1fLds=; b=rCj3miks8rZ4xZnR/z/S0pd3rZ0X1fPJ6+Ah5fw5MQNgqffj9UL3oyZ6ODuXpmB02J gUqFpXvql/Pq51rvgmqgumi6FtTvBYwKEEp73/uJh5XrZ7+6soBWgsf2GNd/K6eC9B3c gXRiTzZXpDBfrz3l5RiP7t6dliIFDB6yD4ulTuZlT45xSQndjweKVlUiPLke5NGv0+j8 uXJlNztkU6Mgr+2VeQqK5XRGdKG9S0PgohjKFry2vh5VVdqj0FYKWTutvJCvRtXBXfjY V9/Ou7l2acVhbsA6KPBH4CmixSPx8YyXAds6W4bV3J9bkE8tMfr/Q5BdagSooEHihNnp z3Ew== X-Gm-Message-State: AHQUAuYoBTa4AzBc3AsVSK/bd1UhgJSIUW8kCdrLq1Z/tQzb36MxmYLk KfKu+Yyi4+5+8GsHJgzfQDQ= X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr9955821wmh.40.1550316375281; Sat, 16 Feb 2019 03:26:15 -0800 (PST) Received: from localhost.localdomain ([46.216.153.34]) by smtp.gmail.com with ESMTPSA id f134sm11042510wme.31.2019.02.16.03.26.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Feb 2019 03:26:13 -0800 (PST) Received: from [127.0.0.1] (helo=jeknote.loshitsa1.net) by localhost.localdomain with esmtp (Exim 4.92-RC4) (envelope-from ) id 1guy6l-0005LK-V0; Sat, 16 Feb 2019 14:26:12 +0300 Date: Sat, 16 Feb 2019 14:26:11 +0300 From: Yauhen Kharuzhy To: Jacek Anaszewski Cc: Pavel Machek , Hans de Goede , 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 Message-ID: <20190216112611.GA11750@jeknote.loshitsa1.net> References: <20190213230731.GA8557@amd> <42078a81-e32e-81b7-528f-d1adb60d31c3@redhat.com> <20190213233806.GA11867@amd> <562e2acd-a60a-2aea-4050-6d9414d23a4e@redhat.com> <20190214111423.GE6132@amd> <92cf09b8-726d-4f1b-94ba-368a66af2246@redhat.com> <2b6faaa5-b21e-a512-de7d-ca21be5045fc@gmail.com> <20190214230307.GA17358@amd> <20190215072709.GD30250@jeknote.loshitsa1.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 15, 2019 at 10:43:17PM +0100, Jacek Anaszewski wrote: > Hi Yauhen, > > On 2/15/19 8:27 AM, Yauhen Kharuzhy wrote: > > On Fri, Feb 15, 2019 at 12:03:07AM +0100, 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. > > > > But there are two kinds of 'hardware control' here in discussion: > > 1: > > a) PMIC switching LED off/on/breathing/blinking reflected the charging > > state (charger is controlled by PMIC entirely without of > > software intervention) – 'hw controlled' mode > > Can we detect when charging is activated? Depends on PMIC and charger configuration. Seems there are no common way working for all configurations exists. > > > b) Software controls when LED is on/off/breathing/blinking but > > patterns are generated by PMIC – 'sw controlled' mode. > > > > 2: > > a) parameters of lighting (continuous/blinking/breathing) are > > set in the PMIC and the PMIC generates patterns > > b) blinking/breathing patterns are generated by the software > > entirely. > > > > It seems that we sometimes confuse this two kinds of hw control definitions > > in the discussion. > > > > > > The simple use case question: with this hardware and existing LED class > > API, what user/app should to do to make LED breathing with hw-generated > > pattern? > > > > As I see, user should activate 'pattern' trigger and write to its hw_pattern attribute... > > hm... big pattern which describes every step of breathing? Some > > simplified pattern which should be interpreted as 'enable the breathing > > an set its frequency' by driver? Which level of simplification will be > > suitable? Which criteria of pattern rejection should be? > > Please see my reply to Hans. We need some simplified device specific > syntax of hw_pattern for this device, similarly like in: > Documentation/ABI/testing/sysfs-class-led-driver-sc27xx Thanks, this approach seems easy to implement. > > -- > Best regards, > Jacek Anaszewski -- Yauhen Kharuzhy