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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBF83C433EB for ; Sun, 19 Jul 2020 08:08:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E9A7207DF for ; Sun, 19 Jul 2020 08:08:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FAYHsxMf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E9A7207DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B763E89F8E; Sun, 19 Jul 2020 08:08:09 +0000 (UTC) Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 852E289F8E for ; Sun, 19 Jul 2020 08:08:07 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id h19so16992361ljg.13 for ; Sun, 19 Jul 2020 01:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O0SPsNNLLDKNzMQANE5E5Oyzv60rxxHp94XasELHeFk=; b=FAYHsxMfA7LSjuJ9SNKNKjT6muVZ086wH8lblSVm7uEVA5bk5/4XKprjx44PQ4ye9i CsDOprIILwui5Vv8gYUNzaF0SdJ7Xc0F+gCOL+DY9UQp3Jb1kMWB5QM1RivQJYzVJcRI I+bqt10R4kaJIfFsnJCWxjsVnflMHGid2KrBExd0MpMh+dD5+DzMgVi0mymN11+lp6J8 Nkh9Tk6xxJUJJivwKb6+5muH1s6LftMsbS8fPcpCuyrWuLrSH3nludTS3jsbEqiCykcR eHCpr3fyaFDN5rA8xPhRMY6+Ek1yB7N6TuGuWPOK+31tbzlkGeX+xL+6Ozi7rctl5rMm x5FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=O0SPsNNLLDKNzMQANE5E5Oyzv60rxxHp94XasELHeFk=; b=d3INwfZYOJi/xe+uc8eThluW41qMeJ008UiK+CC68EbYBX+c0xxR9o/s49gFod9L1+ +niNYkVRqBfkdq60TR48ilPhHb0fcqXX6rV+EjY9jhWBiiY5c+QolNxjLlGIjgHRnRhj G18veTybWf8kk4fsnAbz5sR0z2P5CgtktDrh+v+L5EdA5iMBI+65Mnv+yZeXN35FdOnY BvB2C/lVBCCp+YZIG2XDEj6PZ0qOd07TivqM9GbgIh3xOdQlDUQPSPm/CB2es+FKwIa6 gvyvtHdlAN+YPhlvTmJFtt64Ac4Zktt/I8JtVRJCyUSde2O5XhdPPMyydzjN35y2BYMP j50Q== X-Gm-Message-State: AOAM532kArmZ4J0ypxbXGpWsFfKxSP7fueVCbhw9O/u2bMluGqup7bI6 LX5cf9tDOg6tUAVClzdH3xTaXv5Znzw= X-Google-Smtp-Source: ABdhPJwrr27+mLQRzHwTEPcWxHY/5mguDpC10mIF1tbevGWDakKvIEcfc2iwgeOAYMGg04xNuXkK2A== X-Received: by 2002:a05:651c:88:: with SMTP id 8mr7335618ljq.136.1595146085762; Sun, 19 Jul 2020 01:08:05 -0700 (PDT) Received: from saturn.lan ([2a00:fd00:805f:db00:d5fe:fe9c:fc06:b74c]) by smtp.gmail.com with ESMTPSA id 72sm732407lfh.97.2020.07.19.01.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2020 01:08:05 -0700 (PDT) From: Sam Ravnborg To: dri-devel@lists.freedesktop.org, Jingoo Han , Lee Jones , Daniel Thompson Subject: [PATCH v5 02/19] backlight: add backlight_is_blank() Date: Sun, 19 Jul 2020 10:07:26 +0200 Message-Id: <20200719080743.8560-3-sam@ravnborg.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200719080743.8560-1-sam@ravnborg.org> References: <20200719080743.8560-1-sam@ravnborg.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Support Opensource , Michael Hennerich , Bartlomiej Zolnierkiewicz , David Airlie , Daniel Vetter , Tomi Valkeinen , Jonathan Corbet , Emil Velikov , Bjorn Andersson , Peter Ujfalusi , Andy Gross , Thierry Reding , Thomas Zimmermann , linux-arm-msm@vger.kernel.org, Uwe Kleine-Konig , Sam Ravnborg , patches@opensource.cirrus.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The backlight support has three properties that express the state: - power - state - fb_blank It is un-documented and easy to get wrong. Add backlight_is_blank() helper to make it simpler for drivers to get the check of the state correct. A lot of drivers also includes checks for fb_blank. This check is redundant when the state is checked and thus not needed in this helper function. But added anyway to avoid introducing subtle bugs due to the creative use of fb_blank in some drivers. Introducing this helper will for some drivers results in added support for fb_blank. This will be a change in functionality, which will improve the backlight driver. Rolling out this helper to all relevant backlight drivers will eliminate almost all accesses to fb_blank. v5: - Improved changelog, added fb_blank to properties that express state (Daniel) v4: - struct backlight_device * is now const v3: - Clarified that the fb_blank support in backlight_is_blank() may result in functionality changes for the users (Emil) v2: - Added fb_blank condition (Daniel) Signed-off-by: Sam Ravnborg Reviewed-by: Daniel Thompson Reviewed-by: Peter Ujfalusi Reviewed-by: Emil Velikov Reviewed-by: Daniel Vetter Cc: Emil Velikov Cc: Daniel Vetter Cc: Lee Jones Cc: Daniel Thompson Cc: Jingoo Han --- include/linux/backlight.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/backlight.h b/include/linux/backlight.h index 56e4580d4f55..56e51ebab740 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h @@ -175,6 +175,25 @@ static inline void backlight_put(struct backlight_device *bd) put_device(&bd->dev); } +/** + * backlight_is_blank - Return true if display is expected to be blank + * @bd: the backlight device + * + * Display is expected to be blank if any of these is true:: + * + * 1) if power in not UNBLANK + * 2) if fb_blank is not UNBLANK + * 3) if state indicate BLANK or SUSPENDED + * + * Returns true if display is expected to be blank, false otherwise. + */ +static inline bool backlight_is_blank(const struct backlight_device *bd) +{ + return bd->props.power != FB_BLANK_UNBLANK || + bd->props.fb_blank != FB_BLANK_UNBLANK || + bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); +} + extern struct backlight_device *backlight_device_register(const char *name, struct device *dev, void *devdata, const struct backlight_ops *ops, const struct backlight_properties *props); -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel