Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3521865pxf; Mon, 15 Mar 2021 11:25:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMoyVa+TsqX4YigRvt4PVfvEsv4X/PQAKz+MH0xa92hUmJV/+Y7smLL0AIYurHTcDF0tp6 X-Received: by 2002:a17:906:4e17:: with SMTP id z23mr25405010eju.439.1615832711681; Mon, 15 Mar 2021 11:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832711; cv=none; d=google.com; s=arc-20160816; b=PbuNnLGESDx3HroVY/IL/OCGd1Jyqut3P4xDIImbEMxupc2PIHaIA0pnK9d1+DxTrb c3fFsjx3JsN78z0CdEWJpskNfP/1fZ0hbFFglh7Iap4fZsKczSLtnnzr2RVqiWIo7eT0 BgT5f7LQlumvpRlJo7Hb6eqX8m7z0hjamCrvy1k1Edd83835IhMV2kzwaci8tXzPqdc+ +OxniRSR7RjM1kh96BsGS05h0LRSZi16CRkA0y6AAzOvZKomrFUJPbLlpbv5dwYwzLUZ rpDz+sDBT88O8cuWsFGMSpahcad5A46h/SBzlpyY46JpzSjhb5GYFZg/SLUwFqIttRae IYkw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7uw2MqCj1eISIHtQtQFIp2lezHiBLR9a95jIqwpMTZQ=; b=RanQXACcs8VoTARCRe5CT7yAv16TYE43jrBQMdy/sY4czh7oOgNLhN1Uy0G1PxVFwZ mKla7IkPyMa1CyO+iKPznPl9CF9HTKvJxCDKHxIGvo089vikGIq91KcwKZAe9baUxxGX VZcRImu1pi54pQQbX00MG7DFokBWfVYGZiGGzjxRGexHA+FKQOUjqGLLQm1eft7kiOus u1j76UsRHWDwLkTcxB6qdOa4iyvVigpnTkICkTyQhiYdBch1lYHI8JLog22+OKyLeJad XEBQAPzsgzDFs5Fwcq+SH6H5b1drBbnjhsKROw9WBRP50HMdhnrLCOfuvDTp92CdS+kZ f6wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g44IHujY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si11651273ejm.408.2021.03.15.11.24.49; Mon, 15 Mar 2021 11:25:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g44IHujY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234234AbhCOOYx (ORCPT + 99 others); Mon, 15 Mar 2021 10:24:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232682AbhCON73 (ORCPT ); Mon, 15 Mar 2021 09:59:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8FDEE64F16; Mon, 15 Mar 2021 13:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816747; bh=UWwf6mHVLs6wGSUeMLjotUEF1oBPx5mwMHImwqMUhF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g44IHujYxePsdvCPVTIu+75Raix2NlFepBCO5gDm41WalR4nnlAKS8GbgpzyV3OpH k4miZ05Kj15iEG6lhmoVE14JjQWMksUpCxUpewuEojhev8aVS9UZATExTyJUoSjJr4 rd42ieDiNuIGyiRhK9+gY14vAAGDNnqGvLgHY+ck= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Kazlauskas , Alex Deucher Subject: [PATCH 5.10 091/290] drm/amdgpu/display: handle aux backlight in backlight_get_brightness Date: Mon, 15 Mar 2021 14:53:04 +0100 Message-Id: <20210315135544.988823073@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Alex Deucher commit 0ad3e64eb46d8c47de3af552e282894e3893e973 upstream. Need to fetch it via aux. Reviewed-by: Nicholas Kazlauskas Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -3116,11 +3116,27 @@ static int amdgpu_dm_backlight_update_st static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd) { struct amdgpu_display_manager *dm = bl_get_data(bd); - int ret = dc_link_get_backlight_level(dm->backlight_link); + struct amdgpu_dm_backlight_caps caps; - if (ret == DC_ERROR_UNEXPECTED) - return bd->props.brightness; - return convert_brightness_to_user(&dm->backlight_caps, ret); + amdgpu_dm_update_backlight_caps(dm); + caps = dm->backlight_caps; + + if (caps.aux_support) { + struct dc_link *link = (struct dc_link *)dm->backlight_link; + u32 avg, peak; + bool rc; + + rc = dc_link_get_backlight_level_nits(link, &avg, &peak); + if (!rc) + return bd->props.brightness; + return convert_brightness_to_user(&caps, avg); + } else { + int ret = dc_link_get_backlight_level(dm->backlight_link); + + if (ret == DC_ERROR_UNEXPECTED) + return bd->props.brightness; + return convert_brightness_to_user(&caps, ret); + } } static const struct backlight_ops amdgpu_dm_backlight_ops = {