Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1274966ybl; Tue, 3 Dec 2019 04:41:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxnERsuSKonWdpt/u9JvhQ4t7vUsFjjaRypef15SqKg9dJVwhYnQ3OaTrS/i9d7VVM1k0Bi X-Received: by 2002:aca:c389:: with SMTP id t131mr3182434oif.102.1575376889403; Tue, 03 Dec 2019 04:41:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575376889; cv=none; d=google.com; s=arc-20160816; b=fbYW+Pqi5pp96D3qPMKy1AVCBlNeVjQpBaxQK7kUg+bsTzVz1DuDpEFwdSXJBoFkoe nGrjBL2lAvvOrdEEucvYI+A6TwA2AQ1V4B/YmMCkLmQc/Yb2ZdZXiltpbrytU6XIFKxI uOlGpNA71wwUZfc/s887trd7nEr9EPp+O2qzX16OsmEfePaBL5lywevljdNiAGZd8gSw vvbhJaXibR+8whlpHGSdfDiEjabYi88gAT++s/Z+C3RmL9tf27qq0xIlz73AREl0XpQt VK2RRBv2vExSM3phZ0n5r3MgJlrKwdYxsOYYd5MlC/IIq/pFf6qDZKDwF/O/kgOsMYc3 BGkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=cTmB3MybQ75DVg8OrbxPfCb44hyibdocPRFgo0JQchQ=; b=TN7GNNGc4k7AJCXuntOWT8i9TOxT97oZyj6d42hXu1Yjkekrtps9TZNSMg4jDwgpU8 JF1DByL1Lbhl4rg39q5mwJQog5yAvs16YBIZOyRAccBnZAWOmWwEBdtIEOJIVz15xp6n 0orRWd6uR1RAeLslTLX4rAeAC+HAV4qIhxJ+yP3UaDve/LUj3mqYD9wDO+zSGg0TWU7u f3Cak5nSuDnLTpcY7ZD0MNJ/zH2RceJtJmw0j3q5BzBBffilFloljgRmNVAScyI8ngP3 Dwf7Q7vEi4M3bmw/4SK/nP/flBlTPv29yIl0gNuH9MSfwVknI9zuHEj4jxYNfjoIZRCX 82kg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a26si1190085oto.199.2019.12.03.04.41.17; Tue, 03 Dec 2019 04:41:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726138AbfLCMk1 (ORCPT + 99 others); Tue, 3 Dec 2019 07:40:27 -0500 Received: from mga18.intel.com ([134.134.136.126]:30336 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbfLCMk1 (ORCPT ); Tue, 3 Dec 2019 07:40:27 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2019 04:40:26 -0800 X-IronPort-AV: E=Sophos;i="5.69,273,1571727600"; d="scan'208";a="204961932" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.161]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2019 04:40:21 -0800 From: Jani Nikula To: Lyude Paul , intel-gfx@lists.freedesktop.org Cc: Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Chris Wilson , Ville =?utf-8?B?U3lyasOkbMOk?= , Lee Shawn C , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/5] drm/i915: Assume 100% brightness when not in DPCD control mode In-Reply-To: <20191122231616.2574-3-lyude@redhat.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20191122231616.2574-1-lyude@redhat.com> <20191122231616.2574-3-lyude@redhat.com> Date: Tue, 03 Dec 2019 14:40:18 +0200 Message-ID: <87tv6hinv1.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Nov 2019, 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. > > Signed-off-by: Lyude Paul > --- > .../gpu/drm/i915/display/intel_dp_aux_backlight.c | 15 +++++++++++++++ > 1 file changed, 15 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..0bf8772bc7bb 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,23 @@ 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 control_reg; > u16 level = 0; > > + if (drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_DISPLAY_CONTROL_REGISTER, Shouldn't that be DP_EDP_BACKLIGHT_MODE_SET_REGISTER instead? > + &control_reg) != 1) { > + DRM_DEBUG_KMS("Failed to read the DPCD register 0x%x\n", > + DP_EDP_DISPLAY_CONTROL_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 (!(control_reg & DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD)) > + return connector->panel.backlight.max; It's not just a bit, I think you need to check (control_reg & mask) == value. BR, Jani. > + > 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", -- Jani Nikula, Intel Open Source Graphics Center