Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6098272ybl; Sun, 22 Dec 2019 23:19:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzMnAsU4ysQAxSmam+QJ31Me4e6z3gj8VXMlZXuA7cvBxrrGsm3383f5cNG1So3wR/5QHej X-Received: by 2002:a05:6830:20c6:: with SMTP id z6mr29494064otq.272.1577085557765; Sun, 22 Dec 2019 23:19:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577085557; cv=none; d=google.com; s=arc-20160816; b=EA4X8pYz7HHEJMqSmt9w3KbQ3pTQgy4E/aZIRMxZoRNj44G5xwjxz4Ad3TAO8KqpKF kHqG4BbjsvE5VKGW6cC/FsRGwfKyZAq+6/IioJjF2P7Unf4t65Z0oZ40W0u6Je3gW/x1 hyxoSoY30Y3shKc/ZSnbQCPkTUMcf+H1y02k+ovxwFgq0wq2ngXL1hfvbikMJvWAKlYE jD1ynHh/jsNXwmsDOELniDuAS2yGKayFZ48NEn0A3U2IMxpg1Y64qovBnyI/Y/wpuykG NapuYEvDxGFC+oK54g7wQ1VX8ZOSspdQdZjpNlEryZ3L9OaUWAKcN+lJtyurY25H+3LQ bhjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=XrZFkYYJptZsmxyAq9UkEXBJmk/eEjdSUd1aUCGeQuQ=; b=aIvJVyOF3Y8jlTlTfI+QWO5m2jtdQLe9u6w3AuZe/bO58XtrZRTloapUfaNCFTuepx jfi4zFEGwtO0qi8hBpcpZ9L6Sg2rCteAV7VM1qwzPYdJjSxw5xY6Cduf2RfUSaSDdQ1U GkW9fFoAkJ3isDdRtik9jsvjeUPc5d8oBWeYIiBnBjbedl+NvjmhvVypoz0VKlq6UvR1 ayB1epatRNAhrgAx1TwnshfINrD3xPOa/JE/p6432/rXF05i/5Zl7nzYF5JS9OuGoMD6 HIFLX2LZBYoGRHn90sriCxW0k5BX9z7p8ddSLUeeyJ6uC3+lHfBXq6oyHmcVIUfFyZky JJ1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NznDysF8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d188si4677185oib.273.2019.12.22.23.19.06; Sun, 22 Dec 2019 23:19:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NznDysF8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726032AbfLWHSM (ORCPT + 99 others); Mon, 23 Dec 2019 02:18:12 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23564 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725810AbfLWHSL (ORCPT ); Mon, 23 Dec 2019 02:18:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577085489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XrZFkYYJptZsmxyAq9UkEXBJmk/eEjdSUd1aUCGeQuQ=; b=NznDysF8lg6ySf+hroxoS/r8n5IEpLTaTjZc2OUcmkB3F4HkoGUeje3rjhAXKVnTmghgyJ k5qETkO2zq/m+J81sIpUIGmlhyhaWK9zsqfSiBJAaI/Mf23Lh2DAIkC7X2VDOiYjXZsfB4 VTJVZkSbvFmj0qFbIt2wvXBFT1dUHiA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-rUqu22B6OWmAb62Zm5x5DA-1; Mon, 23 Dec 2019 02:18:06 -0500 X-MC-Unique: rUqu22B6OWmAb62Zm5x5DA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B034800C7F; Mon, 23 Dec 2019 07:18:05 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-202.pek2.redhat.com [10.72.12.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7452775754; Mon, 23 Dec 2019 07:17:56 +0000 (UTC) Subject: Re: [v2] drm/i915: Assume 100% brightness when not in DPCD control mode To: Lyude Paul , intel-gfx@lists.freedesktop.org Cc: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20191203224236.230930-1-lyude@redhat.com> From: Perr Yuan Message-ID: <690de0cf-362b-c826-e607-e12fc403aca9@redhat.com> Date: Mon, 23 Dec 2019 02:17:54 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20191203224236.230930-1-lyude@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/3/19 5:42 PM, Lyude Paul wrote: > Currently we always determine the initial panel brightness level by > simply reading the value from DP_EDP_BACKLIGHT_BRIGHTNESS_MSB/LSB. This > seems wrong though, because if the panel is not currently in DPCD > control mode there's not really any reason why there would be any > brightness value programmed in the first place. > > This appears to be the case on the Lenovo ThinkPad X1 Extreme 2nd > Generation, where the default value in these registers is always 0 on > boot despite the fact the panel runs at max brightness by default. > Getting the initial brightness value correct here is important as well, > since the panel on this laptop doesn't behave well if it's ever put into > DPCD control mode while the brightness level is programmed to 0. > > So, let's fix this by checking what the current backlight control mode > is before reading the brightness level. If it's in DPCD control mode, we > return the programmed brightness level. Otherwise we assume 100% > brightness and return the highest possible brightness level. This also > prevents us from accidentally programming a brightness level of 0. > > This is one of the many fixes that gets backlight controls working on > the ThinkPad X1 Extreme 2nd Generation with optional 4K AMOLED screen. > > Changes since v1: > * s/DP_EDP_DISPLAY_CONTROL_REGISTER/DP_EDP_BACKLIGHT_MODE_SET_REGISTER/ > - Jani > > Signed-off-by: Lyude Paul > --- > .../drm/i915/display/intel_dp_aux_backlight.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > index fad470553cf9..4d467e7d29eb 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > +++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > @@ -59,8 +59,25 @@ static u32 intel_dp_aux_get_backlight(struct intel_connector *connector) > { > struct intel_dp *intel_dp = enc_to_intel_dp(&connector->encoder->base); > u8 read_val[2] = { 0x0 }; > + u8 mode_reg; > u16 level = 0; > > + if (drm_dp_dpcd_readb(&intel_dp->aux, > + DP_EDP_BACKLIGHT_MODE_SET_REGISTER, > + &mode_reg) != 1) { > + DRM_DEBUG_KMS("Failed to read the DPCD register 0x%x\n", > + DP_EDP_BACKLIGHT_MODE_SET_REGISTER); > + return 0; > + } > + > + /* > + * If we're not in DPCD control mode yet, the programmed brightness > + * value is meaningless and we should assume max brightness > + */ > + if ((mode_reg & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK) != > + DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD) > + return connector->panel.backlight.max; > + > if (drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, > &read_val, sizeof(read_val)) < 0) { > DRM_DEBUG_KMS("Failed to read DPCD register 0x%x\n", > Tested-by:Perry Yuan