From patchwork Mon Oct 31 16:32:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Gomes X-Patchwork-Id: 13344 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2416843wru; Mon, 31 Oct 2022 09:40:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4B+YECuXuZv4wugiq23dmIWLlEhY0LI12+JieJA+xTBJjSMZx1hCyHpe93P4f3di46d/II X-Received: by 2002:a17:907:97ca:b0:791:644c:491e with SMTP id js10-20020a17090797ca00b00791644c491emr13883529ejc.555.1667234442659; Mon, 31 Oct 2022 09:40:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667234442; cv=none; d=google.com; s=arc-20160816; b=JQTfFpVQIXVbaDpKx69UpTEQL0oIz3XB1GglSeH1kaL1D9EGugyhDyxtc5iYeF9W7I fQWgp8spbnRI5tQi7yHFDgR0amiJ02Wesp3yyB20xWLsyQh6Hv9paw2FSY/wkBCSL3Fo S7vcQvmPkTY29Y3f7IWXzzfM3c/xyAPuN4B4QU/NpvalUf+8YEzMOPqfSZd9fAzP5Rck 3NxEoRxpffrHjWAa1xlCoTEDZniM8uFbu5GAcKx2AjSzkOfULIzrf/0koe4uYzATOxd4 AZ3f3mB6cW64yoVbBvIRt9qc5lYcuUD/UgI6avc9i1ftlj/KOSxi69pHYWzKY4+NuD5k CKBQ== 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 :dkim-signature; bh=Wt/WR1Gmjk2D9GnfY1ZcaSEw9Q+GFqctU1oYIXCvdkk=; b=pERIxeJ9RWnvOYKyXjM/4IvzxdeFvY4ATeMD3fPSApPy/sOs9jC7cu8swhOCGkWotm Q8tyZyTsL+uUcPu8xEURPM2ZviWpHgh71Dtw5mS7i9EYw02JspjGrrvu7qdY/Mfp6Kxt itw/m1pwcQHgc/31CD2DYZzWcttLLdUKKWvlmkp37oc9TPC+LSEH7JydkqpARqlbD3SZ bvmwN8CDz5gv5Yto4cySd616hJMTcg+htWg1I/ac+zw58ry7wAzQ1x7ayUqvh6CgZSHY 9BUwVs3RygCBwag2WvIzS7q1dFwsCv6BdCA6ROVWInJuKINFf988Y5VFwKc7qGy7G5+m 3qeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QUWIYope; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l29-20020a50d6dd000000b00456eaa4fb1fsi7640252edj.223.2022.10.31.09.40.11; Mon, 31 Oct 2022 09:40:42 -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=QUWIYope; 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 S231751AbiJaQc1 (ORCPT + 99 others); Mon, 31 Oct 2022 12:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231556AbiJaQcZ (ORCPT ); Mon, 31 Oct 2022 12:32:25 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1211312761 for ; Mon, 31 Oct 2022 09:32:25 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id l5so13304818oif.7 for ; Mon, 31 Oct 2022 09:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wt/WR1Gmjk2D9GnfY1ZcaSEw9Q+GFqctU1oYIXCvdkk=; b=QUWIYopeB0UZaW/Dv5KZ2rxinkrGWUERLDC9wEH1krFqq/rXZu+Kj+MAQPmS/sHcq9 WDgyMC7MgQBzSlm10f8WQ3MtxpthmTHe0DwIlueWPM1HQbPCtuz+mou7XsDwyL2P0Mnz D0jx9ZgP/J+OjSijEVyG6du7VE4eI6Gr97Pu8eIKUxw0p+aPhfMLAaAhV+NTXPsHEG9W SDYp2Hi7K+Oa6TVJyTP+vWDJ0nNH91JSgUWSNBhwrUrdGc4P/0oNEKeEZGvBFrxuL9YH lpzxS7wT/StIJImvUJZ2rfylv0C/yrd7X2ir7umu1HtCMtgWP2Q0fLevcAqTfg6J81va di+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wt/WR1Gmjk2D9GnfY1ZcaSEw9Q+GFqctU1oYIXCvdkk=; b=X1xF3fR6s0IxCeW1Jz8Xldpd+FQitRCnjDtkVZle5vHcMTyGjQpP4Q/8SdRY77QEm/ f7jt3YgrPUQE0v6qR3oPL4ZtPOYGRDCSblCQoYvNuAkXmsuco9Pb9yHkywNMpNWPACLy EXkNtvfnduiFx2re4JxPKxBEtbeJEbzTmPJQrm2EDxSgIcx8aTf//7OqxabdUpyyPKwl pD1wdDMM3ibA5cVZFHE94+nnMwAo9dyvpU+6FfF2ktYCPefe4FIFhROhBb2RsliNMh2o Y6mdboGZdMbm//jvPrFSe/5Pkk5ZpRgK2NrvjOA8B2lmsYnA7LjYGY68ieNFHdoCZ0j3 afyg== X-Gm-Message-State: ACrzQf0Ip9neEZiQjbMaJudq33gMTzzmVOZSu8vnlU23lvKMg4vcfpSB QoAfRtRjzQSSa1MGMjm9pPofNqhebEAvLDX9 X-Received: by 2002:a05:6808:171b:b0:34d:444a:fc1e with SMTP id bc27-20020a056808171b00b0034d444afc1emr15366187oib.85.1667233944276; Mon, 31 Oct 2022 09:32:24 -0700 (PDT) Received: from antonio-Lenovo-Legion-5-15IMH05H.multilaserwifi.com.br ([45.163.246.1]) by smtp.googlemail.com with ESMTPSA id x6-20020a05680801c600b00359ad661d3csm2477558oic.30.2022.10.31.09.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 09:32:23 -0700 (PDT) From: antoniospg To: linux-kernel@vger.kernel.org Cc: bagasdotme@gmail.com, sam@ravnborg.org, antoniospg , Ben Skeggs , Karol Herbst , Lyude Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: [PATCH] drm/nouveau: Add support to control backlight using bl_power for nva3. Date: Mon, 31 Oct 2022 13:32:11 -0300 Message-Id: <20221031163211.13228-1-antoniospg100@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221029184851.25340-1-antoniospg100@gmail.com> References: <20221029184851.25340-1-antoniospg100@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748222022579462763?= X-GMAIL-MSGID: =?utf-8?q?1748222022579462763?= Summary: * Add support to turn on/off backlight when changing values in bl_power file. This is achieved by using function backlight_get_brightness() in nva3_set_intensity to get current brightness. Test plan: * Turn off: echo 1 > /sys/class/backlight/nv_backlight/bl_power * Turn on: echo 0 > /sys/class/backlight/nv_backlight/bl_power Signed-off-by: antoniospg --- drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c index a2141d3d9b1d..5c82f5189b79 100644 --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c @@ -263,7 +263,11 @@ nva3_set_intensity(struct backlight_device *bd) u32 div, val; div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or)); - val = (bd->props.brightness * div) / 100; + + val = backlight_get_brightness(bd); + if (val) + val = (val * div) / 100; + if (div) { nvif_wr32(device, NV50_PDISP_SOR_PWM_CTL(or), val |