Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1688162ybh; Sun, 8 Mar 2020 10:23:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvK3N1Y+vS/moCEdA8LjVeSrRwHGYGdi3rsOHqnymxPldsnAJf+97vd5J5523/aLcFc1Ahx X-Received: by 2002:a05:6808:2c4:: with SMTP id a4mr9125025oid.79.1583688186569; Sun, 08 Mar 2020 10:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583688186; cv=none; d=google.com; s=arc-20160816; b=re7UcuY0NwNk8BtE5aLqKYMWrabUDXj9KMBHqpbMo6Cf1tgD+pAB3UVK6ttF7rE5CG KfsWEqEX569LZoNPe7MKAZQBomHrnysY/dzG1brqQ5VISUMT2dcKcBoqgw1ym+xfOP1e jTeeS9DsmdzJqToxrqWidxrIaBYqdtlrb4sRPcV4o35UENyBaDMLMxxIdxzUV/o0HqPA CVmMdmd28i1RLStmX8AHYRFhEbqQw9kwlucbYSAmZU+iEdtlo7zwRQ5zDzyxj/1jbvfR LVtod/T9Yy5+rR4K3yNI8EQ5BXsL+HoceU5KJXYr2Hh6JKINNk8hdGzxZ/Ib3g08mo+/ 3qNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=qzsxqhegd7VOxV+LmHb3kKEhWvUPEvJLG/AsAJYRHG0=; b=jXu/u9Ahfjgeahj1MeP5MRxRn16kgsHKa34DDbkWwZZPlJKYLP3SG2And2PRCwvpdG enizzNcwk0y2Bg64vCkNyO1TLVIS8yOntg3n7jaTx5lao9NpzDBaDmRoARqsZHnuPqEP QsgddTdRO3P3psjgau0W3sTeVPcfdIaPoynAAk/6oj3Qt6GIF2Sl9kpRbFAQFOgx1nkH rBzJ1nuLVyXaQVt2MdartwdgAnF1oqBlIDgRcQPu1poP42lj6wQ1iQtsLZtt93K+aWTD 5RU2VdbZc4j9CPYKc33T5QUU+TRs9H3B2Gq8LvQhynjlFc2ITTjfOMMV5epwRPRxM+Kk cUgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="MV4/0JIs"; 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 i18si5004988otk.245.2020.03.08.10.22.54; Sun, 08 Mar 2020 10:23:06 -0700 (PDT) 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="MV4/0JIs"; 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 S1726402AbgCHRVP (ORCPT + 99 others); Sun, 8 Mar 2020 13:21:15 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35857 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726322AbgCHRVO (ORCPT ); Sun, 8 Mar 2020 13:21:14 -0400 Received: by mail-wm1-f66.google.com with SMTP id g62so2840716wme.1; Sun, 08 Mar 2020 10:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qzsxqhegd7VOxV+LmHb3kKEhWvUPEvJLG/AsAJYRHG0=; b=MV4/0JIsQpDgpy+PUteYVcjSySw1KR1NEm/7AjMjS4OQbwYHuP1H3dk+pb4jHc/rhL 97rXzp+XrLrHY1sQOy28bqRCq8QbgA1EIhmZUEzQ11ORTwLQRvSu8DAY1IDJVJ2MtRGM N/Hzm+l3NyyPs3TUH16sVL+UtkvyHmCNPh+BxJRBhxziiGetAb/cdmFh3ExgNe+od7VV ukxjAakNqSyFWWZZQKiwed8B7p9pItKORr3+Of4n3FAF//LfTG0zJ5VPq9uR5YYt5SYR Ed70cCuJOXCKofwP8w+IDNgjl3OY0iJIPltU66PgjQBreCtCtZy7WxdR9yaSbjSyLujr goCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=qzsxqhegd7VOxV+LmHb3kKEhWvUPEvJLG/AsAJYRHG0=; b=rUGto0bqyaJd20y3KXh1uqTaNRLWkmiUoYs95rPg1uqm44W/JckWDuqRGGuPnWVx6O yGTrNPUR/wUFoE7cJouUbfUPkeFk/zgBI5SFbbIbKAsq2pmKcToK27xm/vGDiPNrwttR bMu5GW/ce0wNvtgyCmoLCWKJcXki4ZOHWV5SqkiHmmzWXuzE8ofzxaJ5WmLSWRGMce/O sNv3Wf27d5043tn8/sL87wzIcJtNU2gsX5Bi/qeTBAS82y5toKYR8ZcHZGM3IBZsS7kP wT6xpnhJ50vH238O3PJlc57ZEwhyxQp6kUW6+ldupgBq2EXOiVaWSQI2EK80qBNlPtN/ RgLA== X-Gm-Message-State: ANhLgQ3MnQKxCBeN7qWsYJbFmjmwk84Qoc/nK0riEXDsjpZhDUVGAbGQ lRxsnzodkIr3ZuerrjC2vKIvsIEq X-Received: by 2002:a1c:5457:: with SMTP id p23mr16141965wmi.45.1583688071539; Sun, 08 Mar 2020 10:21:11 -0700 (PDT) Received: from [192.168.1.23] (affz13.neoplus.adsl.tpnet.pl. [95.49.155.13]) by smtp.gmail.com with ESMTPSA id x9sm17472030wrx.0.2020.03.08.10.21.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Mar 2020 10:21:10 -0700 (PDT) Subject: Re: [RFC PATCH] leds: add sgm3140 driver To: Luca Weiss , linux-leds@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, Pavel Machek , Dan Murphy , linux-kernel@vger.kernel.org References: <20200227185015.212479-1-luca@z3ntu.xyz> <4539487.31r3eYUQgx@g550jk> <1832610.usQuhbGJ8B@g550jk> From: Jacek Anaszewski Autocrypt: addr=jacek.anaszewski@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFWjfaEBEADd66EQbd6yd8YjG0kbEDT2QIkx8C7BqMXR8AdmA1OMApbfSvEZFT1D/ECR eWFBS8XtApKQx1xAs1j5z70k3zebk2eeNs5ahxi6vM4Qh89vBM46biSKeeX5fLcv7asmGb/a FnHPAfQaKFyG/Bj9V+//ef67hpjJWR3s74C6LZCFLcbZM0z/wTH+baA5Jwcnqr4h/ygosvhP X3gkRzJLSFYekmEv+WHieeKXLrJdsUPUvPJTZtvi3ELUxHNOZwX2oRJStWpmL2QGMwPokRNQ 29GvnueQdQrIl2ylhul6TSrClMrKZqOajDFng7TLgvNfyVZE8WQwmrkTrdzBLfu3kScjE14Q Volq8OtQpTsw5570D4plVKh2ahlhrwXdneSot0STk9Dh1grEB/Jfw8dknvqkdjALUrrM45eF FM4FSMxIlNV8WxueHDss9vXRbCUxzGw37Ck9JWYo0EpcpcvwPf33yntYCbnt+RQRjv7vy3w5 osVwRR4hpbL/fWt1AnZ+RvbP4kYSptOCPQ+Pp1tCw16BOaPjtlqSTcrlD2fo2IbaB5D21SUa IsdZ/XkD+V2S9jCrN1yyK2iKgxtDoUkWiqlfRgH2Ep1tZtb4NLF/S0oCr7rNLO7WbqLZQh1q ShfZR16h7YW//1/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CaKIpKcFY8XCxk7Hbl5c 8hcPKWOy16NLO6Y66Ws4kMedXuNUHe4zBLVlRbcYUdgT9Brw8nxmxu3KhEVsJkwOpXLUDuzo hQNfg9em95lpAK+VOTocke8PSESy3GbEtmoMueW3caSeDHb5dRP6WrndaYhEOzAA/KjuPU7J LMXOABOMIq+R38y7e2B3TnVDCrccdZDseFPUWmH0cGCGihH/j2UZG+PImrSDCh3h5MedVHGo sI62tmWm0q6lrljwSZmMZ30w1QaGmdFpI3Q6V+nZ7TZldI3x Message-ID: <568b079a-0a42-4eed-d2d7-12f0feef35e6@gmail.com> Date: Sun, 8 Mar 2020 18:21:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <1832610.usQuhbGJ8B@g550jk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/8/20 5:55 PM, Luca Weiss wrote: > Hi Jacek, > > On Sonntag, 8. März 2020 17:47:17 CET Jacek Anaszewski wrote: >> Hi Luca, >> >> On 3/8/20 12:32 PM, Luca Weiss wrote: >>> Hi Jacek, >>> >>> Thanks for your review! Replies are inline below. >>> >>> I'm wondering if I should implement support for the flash-max-timeout-us >>> dt >>> property ("Maximum timeout in microseconds after which the flash LED is >>> turned off.") to configure the timeout to turn the flash off as I've >>> currently hardcoded 250ms but this might not be ideal for all uses of the >>> sgm3140. The datasheet> >>> states: >>>> Flash mode is usually used with a pulse of about 200 to 300 milliseconds >>>> to >>>> generate a high intensity Flash. >>> >>> so it might be useful to have this configurable in the devicetree. The >>> value of 250ms works fine for my use case. >> >> Yeah, I was to mentioned that. >> >>> Theoretically also the .timeout_set op could be implemented but I'm not >>> sure if this fits nicely into the existing "timeout" API and if it even >>> makes sense to implement that. >> >> Why wouldn't it fit? You can implement timeout_set op and cache flash >> timeout value in it. Then that cached value would be passed in >> strobe_set to mod_timer() in place of currently hard coded 250. >> > > I'll implement that then. > >>> Regards, >>> Luca >>> >>> On Donnerstag, 5. März 2020 22:09:16 CET Jacek Anaszewski wrote: >>>> Hi Luca, >>>> >>>> Thank you for the patch. >>>> >>>> On 2/27/20 7:50 PM, Luca Weiss wrote: >>>>> Add a driver for the SGMICRO SGM3140 Buck/Boost Charge Pump LED driver. >>>>> >>>>> This device is controller by two GPIO lines, one for enabling the LED >>>>> and the second one for switching between torch and flash mode. >>>>> >>>>> The device will automatically switch to torch mode after being in flash >>>>> mode for about 250-300ms, so after that time the driver will turn the >>>>> LED off again automatically. >>>>> >>>>> Signed-off-by: Luca Weiss >>>>> --- >>>>> Hi, this driver is controllable via sysfs and v4l2 APIs (as documented >>>>> in Documentation/leds/leds-class-flash.rst). >>>>> >>>>> The following is possible: >>>>> >>>>> # Torch on >>>>> echo 1 > /sys/class/leds/white\:flash/brightness >>>>> # Torch off >>>>> echo 0 > /sys/class/leds/white\:flash/brightness >>>>> # Activate flash >>>>> echo 1 > /sys/class/leds/white\:flash/flash_strobe >>>>> >>>>> # Torch on >>>>> v4l2-ctl -d /dev/video1 -c led_mode=2 >>>>> # Torch off >>>>> v4l2-ctl -d /dev/video1 -c led_mode=0 >>>>> # Activate flash >>>>> v4l2-ctl -d /dev/video1 -c strobe=1 >>>> >>>> What is /dev/video1 ? Did you register vl42 flash subdev >>>> in some v4l2 media controller device? >>> >>> On the Allwinner A64 SoC /dev/video0 is the node for cedrus (video >>> encoder/ >>> decoder), so the sun6i-csi driver gets to be /dev/video1 >>> >>> # v4l2-ctl --list-devices >>> >>> cedrus (platform:cedrus): >>> /dev/video0 >>> /dev/media0 >>> >>> sun6i-csi (platform:csi): >>> /dev/video1 >>> >>> Allwinner Video Capture Device (platform:sun6i-csi): >>> /dev/media1 >>> >>> Here's the relevant part from my dts: >>> >>> sgm3140 { >>> >>> compatible = "sgmicro,sgm3140"; >>> flash-gpios = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* FLASH_TRIGOUT: PD24 */ >>> enable-gpios = <&pio 2 3 GPIO_ACTIVE_HIGH>; /* FLASH_EN: PC3 */ >>> >>> sgm3140_flash: led { >>> >>> function = LED_FUNCTION_FLASH; >>> color = ; >>> >>> }; >>> >>> }; >> >> This needs to be documented in DT bindings for this driver. >> > > I have already written some yesterday, will post them with my v1 :) Good :-) > >>> /* as subnode of csi (compatible: allwinner,sun50i-a64-csi) */ >>> ov5640: rear-camera@4c { >>> >>> compatible = "ovti,ov5640"; >>> >>> flash-leds = <&sgm3140_flash>; >>> >>> }; >> >> And this in camera bindings. > > This is documented at > Documentation/devicetree/bindings/media/video-interfaces.txt: > > - flash-leds: An array of phandles, each referring to a flash LED, a sub-node > of the LED driver device node. > > Without referencing the flash device in a camera node, the v4l2 controls won't > even show up from what I saw. > The binding is apparently only used in omap3-n9 and omap3-n950 currently; only > phones have flash leds normally and the phones that are currently in mainline > Linux don't have camera support yet. I was rather thinking of mentioning this e.g. in Documentation/devicetree/bindings/media/i2c/ov5640.txt in the form like below (copied other occurrences thereof): - flash-leds: See ../video-interfaces.txt -- Best regards, Jacek Anaszewski