Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp363624imw; Thu, 14 Jul 2022 02:49:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1utktTk9ILkTJ3RvovN4PNCmK2rhID8VG5KBqYbJ5zJT5mEJuju4Iwr/A8/1Rb3nuKhzas+ X-Received: by 2002:a17:90b:1094:b0:1ef:ab92:2af2 with SMTP id gj20-20020a17090b109400b001efab922af2mr9025676pjb.227.1657792147876; Thu, 14 Jul 2022 02:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657792147; cv=none; d=google.com; s=arc-20160816; b=uPYpZYCf9Ow9hZhEIYSJFP2cWkRbwlOeslLHymeg3DQ7VrIJFvMwF6PxpOs/i4ISb7 JFrgmH+rqd7cRUafGnh9tgQhG3ByKmUqpuYP/xXfsNkffarn1gNAdS3OSqSsrCk+S2PH HpO/ySL/cxvK8VUhoJNhY9S4edqZoWqn1nXTaEGTYipeZFWctbp9zEc2Ys8BfUxMarFk /dUARc2YqQLK/oMxGDh9LjU+Dd+1bIjWrf45D7CQ5rWzO/AvLKNcNpVc+tpCmExGiCvx ihQxq73GQhXLKhBXwseDf/x4Et+1FD9XZ6Qym15U30dbntWkdpuEgUWlaq7qiWuMYncU VX3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zQfNaPBMj9qupXp4mDqBN3FvXkuDRylRWUn+zvSSLGM=; b=j6eU4wn0OaMi2y3Fb1vhXlVTSgjKjZPbKjfl8zldWfwrIW8l9YJ08LTqNc+wlUnJXa WYJhjyZAQALzMDxSzoSa9dpzICauGijTJfDJosjBJPwgZ1BLPNXYTUKmeVAAM9BjDXbk vgBhIRmpFwEUNPxVog7XSg80YZbyIMdUc5mkwaP8IhODIAiSJBsVlzb40427YIiAdChx JaL1axPcdcp6Q/UzxKMS/+LhQQ8I12HSO9pzMh2dmox2ZT2d1pK3H8H38eZcoOEqdcEn LGaj7RSPphYirTqgUCfZnHJwfxtvd6XpvjgRc1a9UuyYq4VgfMjsJTqDT71g8ADsCqth rADA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oUdjAR6p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a170902c40100b0016786f2d1d8si1600292plk.475.2022.07.14.02.48.56; Thu, 14 Jul 2022 02:49:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oUdjAR6p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238421AbiGNJoe (ORCPT + 99 others); Thu, 14 Jul 2022 05:44:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238243AbiGNJoZ (ORCPT ); Thu, 14 Jul 2022 05:44:25 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E96211A0F; Thu, 14 Jul 2022 02:44:24 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-2ef5380669cso11207607b3.9; Thu, 14 Jul 2022 02:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zQfNaPBMj9qupXp4mDqBN3FvXkuDRylRWUn+zvSSLGM=; b=oUdjAR6phW8mBTe5eDzj0QeWXcrYu1dSSLOGdISEQbBbC80E3nnO2FEXxGYAf5RiXM qwCt3mFNhcwCVxxKFv95OoQ0lQSZxF92XMKvQIcmRpKoj31iWTGkf6owEnJ4SKyFwH0k JauEuOFAu1eKjoPKsewxkkdItYHKrSID6UH/riAytvkcYOvK7wJWfdXGd7YOn2ZlGDPx UknY6TlQhPMD62NXaNa84SFcZnW0ErJAIVlOFo4CQxO3vJ5UK7w+Chs6Xo+IjKurYNSH WqV07lOMcczIHACgOGIOzTx9kcVs99te0vmj/tlI8+bxgqMwN7h4K7I2B72mfGLzkJ4i gQ2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=zQfNaPBMj9qupXp4mDqBN3FvXkuDRylRWUn+zvSSLGM=; b=2IDATPUV3G1XUlJtbtTM/xKl0j703c9YOSnfV3GKddxJ4lPihMz21mMbCrTnI7cVUt PlvTJ5i8etYQnPm9iJL1QCZwmpJwmQ9bXR1WN374T3YNLpc3qt5/ve/mnn2rPHnZMgEl Cw7U5xNraEMtyLdYa0YuEkXpkbCS4HVKLnqiwkzsA+Ko79/ZYWHExD1I89xHL40s4+ln MEsvOgsd+J1yAhvgcrfcP4xAdocH4Cm4u7au8wU66lAC089+TDhnE23KDVvfIQJtJiFb NA2ACoBkfJSRr4/5veO5SADFDogaH5k1B13iOS3G+TfXLa7TraLCkweEExxVH4e6oPem Y/+Q== X-Gm-Message-State: AJIora94Q2UfK832rlallO3kczk0rIDqvHwZch5lVcEWV/Ig1/AyRdTf KTAp/dW4h3mDmodhEmdwj1QKj+Pf18CBY4WIE7A= X-Received: by 2002:a81:4986:0:b0:31d:388b:d08d with SMTP id w128-20020a814986000000b0031d388bd08dmr8542894ywa.185.1657791863639; Thu, 14 Jul 2022 02:44:23 -0700 (PDT) MIME-Version: 1.0 References: <20220704053901.728-1-peterwu.pub@gmail.com> <20220704053901.728-14-peterwu.pub@gmail.com> In-Reply-To: From: Andy Shevchenko Date: Thu, 14 Jul 2022 11:43:46 +0200 Message-ID: Subject: Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support To: ChiaEn Wu Cc: Lee Jones , Daniel Thompson , 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 , ChiaEn Wu , Alice Chen , cy_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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 14, 2022 at 11:27 AM Andy Shevchenko wrote: > > On Thu, Jul 14, 2022 at 9:13 AM ChiaEn Wu wrote: > > Andy Shevchenko =E6=96=BC 2022=E5=B9=B47=E6= =9C=8813=E6=97=A5 =E9=80=B1=E4=B8=89 =E6=99=9A=E4=B8=8A8:07=E5=AF=AB=E9=81= =93=EF=BC=9A ... > > I have tried two methods so far, as follows > > ------------------------------------------------------------- > > /* > > * prop_val =3D 1 --> 1 steps --> b'00 > > * prop_val =3D 2 ~ 4 --> 4 steps --> b'01 > > * prop_val =3D 5 ~ 16 --> 16 steps --> b'10 > > * prop_val =3D 17 ~ 64 --> 64 steps --> b'11 > > */ > > So, for 1 --> 0, for 2 --> 1, for 5 --> 2, and for 17 --> 3. > Now, consider x - 1: > 0 ( 0 ) --> 0 > 1 (2^0) --> 1 > 4 (2^2) --> 2 > 16 (2^4) --> 3 > 64 (2^6) --> ? (but let's consider that the range has been checked alread= y) > > Since we take the lower limit, it means ffs(): > > y =3D (ffs(x - 1) + 1) / 2; > > Does it work for you? It wouldn't, because we need to use fls() against it actually. So, 0..1 (-1..0) --> 0 2..4 (1..3) --> 1 5..16 (4..15) --> 2 17..64 (16..63) --> 3 y =3D x ? ((fls(x - 1) + 1) / 2 : 0; --=20 With Best Regards, Andy Shevchenko