From nobody Wed Oct 13 09:19:21 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DAFE81800745; Wed, 13 Oct 2021 09:19:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTn6M4qcFz4sbl; Wed, 13 Oct 2021 09:19:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4143E25408; Wed, 13 Oct 2021 09:19:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19D9JLXO057457; Wed, 13 Oct 2021 09:19:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JL5n057456; Wed, 13 Oct 2021 09:19:21 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:21 GMT Message-Id: <202110130919.19D9JL5n057456@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9441d948aa3b - stable/13 - LinuxKPI: Implement backlight_enable and backlight_disable functions List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9441d948aa3bdf4a4d04c15131d385ae951cd9de Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9441d948aa3bdf4a4d04c15131d385ae951cd9de commit 9441d948aa3bdf4a4d04c15131d385ae951cd9de Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:15:12 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:06:51 +0000 LinuxKPI: Implement backlight_enable and backlight_disable functions For now, disable backlight if brightness level is set to 0. In the future we may implement separate knob in backlight(8). Required by drm-kmod v5.6 Reviewed by: hselasky, manu Differential revision: https://reviews.freebsd.org/D32165 (cherry picked from commit b52e36384091c5f80b06b79f5889492eac074426) --- .../linuxkpi/common/include/linux/backlight.h | 22 ++++++++++++++++++++-- sys/compat/linuxkpi/common/src/linux_pci.c | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/backlight.h b/sys/compat/linuxkpi/common/include/linux/backlight.h index 1d2224811124..b3a07c4cdcaa 100644 --- a/sys/compat/linuxkpi/common/include/linux/backlight.h +++ b/sys/compat/linuxkpi/common/include/linux/backlight.h @@ -79,10 +79,10 @@ void linux_backlight_device_unregister(struct backlight_device *bd); linux_backlight_device_register(name, dev, data, ops, props) #define backlight_device_unregister(bd) linux_backlight_device_unregister(bd) -static inline void +static inline int backlight_update_status(struct backlight_device *bd) { - bd->ops->update_status(bd); + return (bd->ops->update_status(bd)); } static inline void @@ -91,4 +91,22 @@ backlight_force_update(struct backlight_device *bd, int reason) bd->props.brightness = bd->ops->get_brightness(bd); } +static inline int +backlight_enable(struct backlight_device *bd) +{ + if (bd == NULL) + return (0); + bd->props.power = 0/* FB_BLANK_UNBLANK */; + return (backlight_update_status(bd)); +} + +static inline int +backlight_disable(struct backlight_device *bd) +{ + if (bd == NULL) + return (0); + bd->props.power = 4/* FB_BLANK_POWERDOWN */; + return (backlight_update_status(bd)); +} + #endif /* _LINUX_BACKLIGHT_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index ae45df9c6514..b5bb87b5f2ae 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -1159,6 +1159,8 @@ linux_backlight_update_status(device_t dev, struct backlight_props *props) pdev->dev.bd->props.brightness = pdev->dev.bd->props.max_brightness * props->brightness / 100; + pdev->dev.bd->props.power = props->brightness == 0 ? + 4/* FB_BLANK_POWERDOWN */ : 0/* FB_BLANK_UNBLANK */; return (pdev->dev.bd->ops->update_status(pdev->dev.bd)); }