From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FEFDC433EF for ; Tue, 26 Jul 2022 12:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P0CbVM7bzH9TA1LLYXQo4hHdlAs0KC0zhw24YWSk66s=; b=hTdyj+LD3n2GCH bC6ryzysa8mpn9y01gkcFaVH1ZRHsmtPdl+Pl5Voipn83QrPzdQmxhXghDG5FsTm9v90zQaqfELA/ wHYgeTOpRC0BUiV06cx362zf8i0HiDXAwO5mlot8GMXxdX1Jno5wIEIkK/2Vs+xxZy0kuqrfe4LUm /iPUFEg6GY7LPCOL5mRPmsr3BE3bd85m70S+pr9A2rDiQC5IcAoyoAT/Gg0oVRCYbanHsqwcpvaku wEiwLbD7KRynN5ygkC423KvMFkyBgxcZx558hdS9m/PkLCAMLfvJSCPp7ElRBh4r+bBW8jhJW43yS aqW1NwzRw16X8vaTx2tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGJFd-00GaRl-FV; Tue, 26 Jul 2022 12:01:25 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGJEG-00GZ0r-PY for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2022 12:00:03 +0000 Received: by mail-wr1-x42f.google.com with SMTP id u5so19829711wrm.4 for ; Tue, 26 Jul 2022 04:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FeVAQTj8/mAfkMvlMLcvvaBxhrv6NPtimQHZr0slSEU=; b=xGMvXn3lMLClPC6eYxENOclGIczqTe4up2YIXe+hB4oiUuGwxnYbUcVPOjQ6uneBOn qF0JJhM66ZwzVuCuaD7h9ruyKVimYkfqcqQ4Kis3hhGc6TDEmPdt9pvCx2Q/ZtTFFx7/ RxQQz5GA+s0dhVW4w4r7ML655as4ZXTF5j/m2lzozaDmwFuFXQ4lqKSN8sMMdxCI/075 EWmE3VOrwt0RYvxBgte5TLjVz2Oaxglc4K/5fpz76xOLgwZrsFKVQt2JZRFWNVwF+Ble KiAB1b+a9gGWGvWz9lI4jQ8rsd/MCa4vLoay1yTaFYPW+XO+7sLz7zjt1JKcROEGLX+Z CX+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FeVAQTj8/mAfkMvlMLcvvaBxhrv6NPtimQHZr0slSEU=; b=UJfPheTaP57aBmWYNP9F42hlEQb+d/Ggu8Z1Be6G6l3OvuUJY3mPpuK2VioyzRdkab vyldTHizFAHwKcIu/Ioxld5635k+eKGMoTW2q2vlztbSAPvrbaxE2eFuYwjuX/i+U3aK wklA8u/DjDBv9fH6JYY1Yw+PdkgafUqWm+QDkujGmcAWKyoY4sCW0s2CB6gYTD/gCc7P ZThZXTvgBeA5Q0ePIyUFxN4q5VaJOjy6CGlhLue4dmf5/hUKDjJPfbtilO98TjMmsHO8 CUpbbO6Eg1ug2HUM9T6Y7mIffKwUSn6lxyt/bVJfO5zNQqDUUIiVSZPWIswxcGFYH2W8 lZNA== X-Gm-Message-State: AJIora8f9ipGTa6kjjfNCYiii0EY+HNG2YH/4JUxzuNZbGzndYI8ViHN +RPlo1jQWip2yqdumC1HCyu6mQ== X-Google-Smtp-Source: AGRyM1uehfvDpwjgQ4OdVhAkG8XtMk/rrGDztYqeesidU3gudI8NvtnBD1+DZaV4TdshdsyfIFIYLQ== X-Received: by 2002:a5d:6d0b:0:b0:21d:9f26:f84a with SMTP id e11-20020a5d6d0b000000b0021d9f26f84amr10703197wrq.155.1658836797777; Tue, 26 Jul 2022 04:59:57 -0700 (PDT) Received: from maple.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id bn20-20020a056000061400b0021e86504736sm6131350wrb.16.2022.07.26.04.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 04:59:57 -0700 (PDT) Date: Tue, 26 Jul 2022 12:59:54 +0100 From: Daniel Thompson To: ChiaEn Wu Cc: Lee Jones , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Sebastian Reichel , Chunfeng Yun , Greg Kroah-Hartman , Jonathan Cameron , Lars-Peter Clausen , Liam Girdwood , Mark Brown , Guenter Roeck , "Krogerus, Heikki" , Helge Deller , Andy Shevchenko , ChiaEn Wu , Alice Chen , ChiYuan Huang , dri-devel , Linux LED Subsystem , devicetree , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , Linux Kernel Mailing List , Linux PM , USB , linux-iio , "open list:FRAMEBUFFER LAYER" , szuni chen Subject: Re: [PATCH v6 13/13] video: backlight: mt6370: Add MediaTek MT6370 support Message-ID: <20220726115954.kpkmidrk3zo3dpbq@maple.lan> References: <20220722102407.2205-1-peterwu.pub@gmail.com> <20220722102407.2205-14-peterwu.pub@gmail.com> <20220725103128.xtaw2c4y5fobowg7@maple.lan> <20220726093058.2fz2p2vg7xpfsnfe@maple.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220726_050000_964710_051914FD X-CRM114-Status: GOOD ( 57.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jul 26, 2022 at 07:28:48PM +0800, ChiaEn Wu wrote: > On Tue, Jul 26, 2022 at 5:31 PM Daniel Thompson > wrote: > ... > > > > Does the MT6372 support more steps than this? In other words does it use > > > > a fourteen bit scale or does it use an 11-bit scale at a different > > > > register location? > > > > > > Hi Daniel, > > > > > > Thanks for your reply. > > > Yes, MT6372 can support 16384 steps and uses a 14-bit scale register > > > location. But the maximum current of each > > > channel of MT6372 is the same as MT6370 and MT6371, both 30mA. > > > The main reason why MT6372 is designed this way is that one of the > > > customers asked for a more delicate > > > adjustment of the backlight brightness. But other customers actually > > > do not have such requirements. > > > Therefore, we designed it this way for maximum compatibility in software. > > Sorry for I used of the wrong word, I mean is 'driver', not > higher-level software > > > > > I don't think that is an acceptable approach for the upstream kernel. > > > > To be "compatible" with (broken) software this driver ends up reducing > > the capability of the upstream kernel to the point it becomes unable to > > meet requirements for delicate adjustment (requirements that were > > sufficiently important to change the hardware design so you could meet > > them). > > Originally, we just wanted to use one version of the driver to cover > all the SubPMIC of the 6370 series(6370~6372). > And, the users who use this series SubPMIC can directly apply this > driver to drive the backlight device without knowing the underlying > hardware. > To achieve this goal, we have designed it to look like this. You don't need a second driver to support two different values for max-brightness. The same driver can support both ranges with nothing but a small tweak during the driver probe function. > ... > > > > > + > > > > > + if (brightness) { > > > > > + brightness_val[0] = (brightness - 1) & MT6370_BL_DIM2_MASK; > > > > > + brightness_val[1] = (brightness - 1) >> fls(MT6370_BL_DIM2_MASK); > > > > > + > > > > > + /* > > > > > + * To make MT6372 using 14 bits to control the brightness > > > > > + * backward compatible with 11 bits brightness control > > > > > + * (like MT6370 and MT6371 do), we left shift the value > > > > > + * and pad with 1 to remaining bits. Hence, the MT6372's > > > > > + * backlight brightness will be almost the same as MT6370's > > > > > + * and MT6371's. > > > > > + */ > > > > > + if (priv->vid_type == MT6370_VID_6372) { > > > > > + brightness_val[0] <<= MT6370_BL_DIM2_6372_SHIFT; > > > > > + brightness_val[0] |= MT6370_BL_DUMMY_6372_MASK; > > > > > + } > > > > > > > > This somewhat depends on the answer to the first question above, but > > > > what is the point of this shifting? If the range is 14-bit then the > > > > driver should set max_brightness to 16384 and present the full range of > > > > the MT6372 to the user. > > > > > > So should we make all 16384 steps of MT6372 available to users? > > > > Yes. > > > > > > > Does that mean the DTS needs to be modified as well? > > > > Yes... the property to set initial brightness needs a 14-bit range. > > > > It would also be a good idea to discuss with the DT maintainers whether > > you should introduce a second compatible string (ending 6372) in order > > to allow the DT validation checks to detect accidental use of MT6372 > > ranges on MT6370 hardware. > > hmmm... I have just thought about it, > maybe I can just modify the maximum value of default-brightness and > max-brightness in DT to 16384, > modify the description and add some comments. What for? All the other backlight drivers (there are >130 of them) expose the hardware range[1]. Most userspaces will already know how to handle that (by reading the max_brightness and, if it is recent enough, also the scale properties in sysfs). I'm still don't understand why one should fix a bug in the userspace by implementing a hack in the driver. [1] Well almost. The PWM backlight driver does contain support for dead-spot avoidance and to allow the adoption of exponential scale. However this purpose of these is based on how PWM backlights work > And then on the driver side, > we can use mt6370_check_vendor_info( ) to determine whether it is MT6372. > If no, then in mt6370_bl_update_status(), first brightness_val / 8 and then set. > In mt6370_bl_get_brightness(), first brightness_val * 8 and then return; > > If I do this change, does this meet your requirements? Not really. It's still misleading a sophisticated userspace, which may make bad rounding decisions for backlight animation, in order to support a broken one. > > > Or, for the reasons, I have just explained (just one customer has this > > > requirement), then we do not make any changes for compatibility > > > reasons? > > > > I'd be curious what the compatiblity reasons are. In other words what > > software breaks? > > The reason is as above. We just hope the users who use this series SubPMIC can > directly apply this driver to drive the backlight device without > knowing the underlying hardware. > Not software breaks. As above, ignoring the max_brightness property is a bug in the userspace. I'm still unclear why sending faked ranges to userspace it a better solution than fixing the userspace. Daniel. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel