Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1898833iof; Tue, 7 Jun 2022 13:54:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCz1YCsDG03mrwSPXYNvq1MEYF6F7wZ8oJ12m6gDVAWn9cmkaG+g+gakSilQdU6zN6kJ+E X-Received: by 2002:a05:6402:ca5:b0:42d:dba5:b2a0 with SMTP id cn5-20020a0564020ca500b0042ddba5b2a0mr35941774edb.197.1654635257871; Tue, 07 Jun 2022 13:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654635257; cv=none; d=google.com; s=arc-20160816; b=EprN8qAu8JRDxB7Y1rh3nhgSMuLknx92gwq72idw30wRVBgTJwyM5ZWF3cU4PaQ39i xXDxw80KlxI+dS180IwtGA+cd7OjoTJdogzHLfLbGRWe5Ty1aWXSgTszbOSZb8xPpmnN nOHdgT9BDtZfDez+QBdGC5ccSTSX08JE0Xdy+i4Mn1duKc6erGBuZR6F29Dx8QKNQ9qz 25cje3vPKhqRwI9rOIqCNw+LyiWevXXnLTjOA76cGsBSp6LimywaN4/Pb2eA4Vq7uxi2 3KjSpz/bTvIRyLYmMXrT3AOAAs02bdoRNPw0e3PI5NENaEBQP/xj6f2B89v0bghRRmbO h0Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zhEU5DICK+d3oPA9IDL8j/+0pd3DEAiriK4DFPeOhvY=; b=yutXCr/990f5IUlEHbHMP0KQYiy7BO/XK2PL3Py86XRU5ZeBA6FjbVUE0xSRZAbWdy Je2BhNknk05cYGp3xuQoodbiXms999c0+0wZH+k4MoDBZjAMWJF/4xcXA3hR6xbSRwL7 qxkoPJoO3qAMLzvHMTVu205yQHYTxdkauWpRs/rFG4xJO1uOqrl/zf5KBjGBqDdOCWDs 00YAO7bs58po6owRTCzbsBPiDk8fr5kbU2xPjd8+b/9mY6lL2O96RkjYcCX5Hi2GQxS3 BgHSbBEL1BHYWeQ2mYpmWQ7qd2ZZMKynW+6yC0fgRwXLbqjyYt//hChUMkBOZ0aO5jdg M7aw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p7-20020a17090653c700b00711ad88fde8si9946836ejo.369.2022.06.07.13.53.49; Tue, 07 Jun 2022 13:54:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378462AbiFGUwI (ORCPT + 99 others); Tue, 7 Jun 2022 16:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358594AbiFGTwo (ORCPT ); Tue, 7 Jun 2022 15:52:44 -0400 X-Greylist: delayed 179 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 07 Jun 2022 11:21:13 PDT Received: from 9.mo576.mail-out.ovh.net (9.mo576.mail-out.ovh.net [46.105.56.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED7625DA for ; Tue, 7 Jun 2022 11:21:13 -0700 (PDT) Received: from player728.ha.ovh.net (unknown [10.111.172.36]) by mo576.mail-out.ovh.net (Postfix) with ESMTP id CD860241BC for ; Tue, 7 Jun 2022 18:21:11 +0000 (UTC) Received: from sk2.org (82-65-25-201.subs.proxad.net [82.65.25.201]) (Authenticated sender: steve@sk2.org) by player728.ha.ovh.net (Postfix) with ESMTPSA id 83A8D2B3FFBBD; Tue, 7 Jun 2022 18:21:03 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-103G005c1a5820f-bbd6-4097-a39f-86f090581fe2, 38FB55E0ED6224772C245AF554E1AE62085133ED) smtp.auth=steve@sk2.org X-OVh-ClientIp: 82.65.25.201 From: Stephen Kitt To: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Stephen Kitt Subject: [PATCH 2/3] drm/panel: panel-dsi-cm: Use backlight helpers Date: Tue, 7 Jun 2022 20:20:25 +0200 Message-Id: <20220607182026.1121992-3-steve@sk2.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220607182026.1121992-1-steve@sk2.org> References: <20220607182026.1121992-1-steve@sk2.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 10887170627632334470 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedruddthedguddvgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuthgvphhhvghnucfmihhtthcuoehsthgvvhgvsehskhdvrdhorhhgqeenucggtffrrghtthgvrhhnpeeghffhleeigffhteeiffelveefhfeiudehkedtgefhgedvleffgfejgfdtveeigeenucfkpheptddrtddrtddrtddpkedvrdeihedrvdehrddvtddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopehplhgrhigvrhejvdekrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepshhtvghvvgesshhkvddrohhrghdpnhgspghrtghpthhtohepuddprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhoheejie X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 Instead of retrieving the backlight brightness in struct backlight_properties manually, and then checking whether the backlight should be on at all, use backlight_get_brightness() which does all this and insulates this from future changes. Instead of setting the power state by manually updating fields in struct backlight_properties, use backlight_enable() and backlight_disable(). These also call backlight_update_status() so the separate call is no longer needed. Signed-off-by: Stephen Kitt Cc: Thierry Reding Cc: Sam Ravnborg Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/panel/panel-dsi-cm.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c index b58cb064975f..aa36dc6cedd3 100644 --- a/drivers/gpu/drm/panel/panel-dsi-cm.c +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c @@ -86,16 +86,10 @@ static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable) return; if (enable) { - backlight->props.fb_blank = FB_BLANK_UNBLANK; - backlight->props.state = ~(BL_CORE_FBBLANK | BL_CORE_SUSPENDED); - backlight->props.power = FB_BLANK_UNBLANK; + backlight_enable(backlight); } else { - backlight->props.fb_blank = FB_BLANK_NORMAL; - backlight->props.power = FB_BLANK_POWERDOWN; - backlight->props.state |= BL_CORE_FBBLANK | BL_CORE_SUSPENDED; + backlight_disable(backlight); } - - backlight_update_status(backlight); } static void hw_guard_start(struct panel_drv_data *ddata, int guard_msec) @@ -196,13 +190,7 @@ static int dsicm_bl_update_status(struct backlight_device *dev) { struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev); int r = 0; - int level; - - if (dev->props.fb_blank == FB_BLANK_UNBLANK && - dev->props.power == FB_BLANK_UNBLANK) - level = dev->props.brightness; - else - level = 0; + int level = backlight_get_brightness(dev); dev_dbg(&ddata->dsi->dev, "update brightness to %d\n", level); @@ -219,11 +207,7 @@ static int dsicm_bl_update_status(struct backlight_device *dev) static int dsicm_bl_get_intensity(struct backlight_device *dev) { - if (dev->props.fb_blank == FB_BLANK_UNBLANK && - dev->props.power == FB_BLANK_UNBLANK) - return dev->props.brightness; - - return 0; + return backlight_get_brightness(dev); } static const struct backlight_ops dsicm_bl_ops = { -- 2.30.2