Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3518403pxf; Mon, 15 Mar 2021 11:19:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnB6ItuQftH8oBNcrUxuKvP1HMpPBhrLtnJBOEnl8fg11vvAzW+G0rcr8M0FT4shre3j3j X-Received: by 2002:a05:6402:b48:: with SMTP id bx8mr32587564edb.162.1615832388833; Mon, 15 Mar 2021 11:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832388; cv=none; d=google.com; s=arc-20160816; b=lmeUkZRuCun1ks8iOzmpRgN4DbHXQA0z5y8vlqYwVumYJzkXU58q2KMFHZaEaClpvN vh8ZBrZ8mlJTWg5C0ocgSsBh/UoLRbXzDAebFqvUtIdWuOB3jHo2ZSpNr/rBeqJogO3s 9wnrJ4Dlhh1Y5805IGCz8a3pKGAL8IHT77EBh+ULPOdab3XXU9DtCAgRM14RpDt6ejP/ NpnZM0G6IIS+gaiv4Zkh0Hmk1GJ1B4IHU9bnaBJ0h8bVLiZKNi2wHAUbf6MuKP4crDlH 82+blXiSTCPIDyJpOxGFmpTJgz9K/3RTAAgp7rmjXWzkFe/h7p9jwtlkVT9eQ+xsrLV2 Bjsg== 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=I3iIuX4fXf1InNy3WdyR1hZwUIo4f3Ee0Jgr9GAVI7c=; b=mfYRU3rf1qY8A5I6iu6sCmlfkDo1coBbSH8WQcfnLI5GzX+q3hmbyCwWtarSLkV30p hx53j3W5dYmjnP4iLGYmjZhaAE6IYZ+HKdOV4si7GEVdcpI1mM3ww0UXm13ZKyw7gg3N 7ZRcJsHP/UwvbziCMwsm1NXawmiAhRF7XMLh9omCMIUGdeNQyO6N6b9tyKZNcxm9pOct 2oz50i1TfA1soMkJp9NTOAI8lMoBSzdYNi5fuOIvJbdrVu6mxQarvbi+pMl4hQdsgFAY dAF6gyjI4tqg4c4L7yJ6YOjJvYpJEzBSZTTbcSOfBb5kaLwl17pq867dHgMlOsqP4C8q RC0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VtgYnizF; 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 d22si12132455ejk.139.2021.03.15.11.19.26; Mon, 15 Mar 2021 11:19:48 -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=VtgYnizF; 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 S232707AbhCOOSH (ORCPT + 99 others); Mon, 15 Mar 2021 10:18:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:35446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbhCON7e (ORCPT ); Mon, 15 Mar 2021 09:59:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0E41964F4C; Mon, 15 Mar 2021 13:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816753; bh=Pmr1MakgUo1gYo4IEFzoSGPbCwc3U9Byp15n0/6LM0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VtgYnizFO/SF84lf43QGTC2Vrti+9mTke1pXgLGqwOvmO+r7PZfNXZwz7mJRFyzSh ejIw37nzaBcdEWKMm2Tv464RjW3eyyyWjxzPh0BaETyf/Z50rTbVNPCC36ddqM/kL1 ST5kNAgYQ0KjZQbrj2KPPaM34tkNASnrcUpsLICA= 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.11 104/306] drm/amdgpu/display: handle aux backlight in backlight_get_brightness Date: Mon, 15 Mar 2021 14:52:47 +0100 Message-Id: <20210315135511.159889712@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 @@ -3205,11 +3205,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 = {