From patchwork Tue May 9 23:40:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9719021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F8856035D for ; Tue, 9 May 2017 23:41:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FA6828458 for ; Tue, 9 May 2017 23:41:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 747562847D; Tue, 9 May 2017 23:41:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 27F8828458 for ; Tue, 9 May 2017 23:41:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 303DB89DFB; Tue, 9 May 2017 23:41:05 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x231.google.com (mail-pf0-x231.google.com [IPv6:2607:f8b0:400e:c00::231]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C7F589DE5 for ; Tue, 9 May 2017 23:41:04 +0000 (UTC) Received: by mail-pf0-x231.google.com with SMTP id v14so7163010pfd.2 for ; Tue, 09 May 2017 16:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=oB/OHmSKpu4KeDJrJu+sDRVjCH0Qf01HmQZmC/3PHSU=; b=nalA5F1dmorOsR/8XDq047j3X8ilKBO/r3NNR1fDKVYqv72t1kRlNloeP9WZPbrJMI JMo35G4m1L+fST3FHOGrIAivcIEPg2PWSj2yWYZ1vNkv3mtMDjJQYmrNUHaw19MDy67H 8OLoSSQpIvrqtA8530wQZXonjLgD9pcTG05SAtlxBdHCfefjfJ+TdMkdkMK6/SF8aANW WHzklX1JmBrl2CTjnfoFcSR+muZtlHJQsY2ykmsCHPPOdE0PaFRcvAv9xWU0FMtbKifs b/aCItExtHwt/N9OEkEWQSzXdqjP6rXyJSfv3PM/olJ1cx4I1FuMB373jdQ4rBdqWqa5 4bzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=oB/OHmSKpu4KeDJrJu+sDRVjCH0Qf01HmQZmC/3PHSU=; b=KdbYqMKsECZzd1MhRkymph02AYjRcbmemMReh/XLVvkBeyf7vtCdNPpQ0Dg2dm96Kg TvGHZRPXbYaq4TiB0P9rLA4CNwUmgdx5wP8iv+Ap7AynGViy7luTrgkBHvu6ZKRY96NF 0xi/IVSG0DqqsD0REFIf/F3U0gZMgn62dmPOf7rFSg/UAbJyhtxcb/YbdKqsqjFm7bGB MDuT/Hj5hTGuZh2122oa4KQLqNHGxM3uujLa+kTzJdZQc1w7FjM6OA9GL9n5Hd/TW/Gw yi5Jdo1kzWNKp4fwgIo2dopxZ+hpS0ZNkczheOw1yymXipWjLZi3iHXtWNHjz8HnS8RL QV/Q== X-Gm-Message-State: AODbwcDMevrOhvO2HBAjDcaEDUz3LKXIdBL1QNn1LWsvz1OOgpu7f9Ua sX4YnvObL/cHVzWh X-Received: by 10.99.164.2 with SMTP id c2mr3066060pgf.73.1494373263392; Tue, 09 May 2017 16:41:03 -0700 (PDT) Received: from puthik2.mtv.corp.google.com ([172.22.64.53]) by smtp.gmail.com with ESMTPSA id x4sm1611453pgc.65.2017.05.09.16.41.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 16:41:03 -0700 (PDT) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id F2BAA11F8F2; Tue, 9 May 2017 16:40:59 -0700 (PDT) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org, Dhinakaran Pandiyan Date: Tue, 9 May 2017 16:40:45 -0700 Message-Id: <20170509234052.189575-3-puthik@chromium.org> X-Mailer: git-send-email 2.13.0.rc2.291.g57267f2277-goog In-Reply-To: <20170509234052.189575-1-puthik@chromium.org> References: <20170509234052.189575-1-puthik@chromium.org> Cc: Puthikorn Voravootivat , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v6 2/9] drm/i915: Correctly enable backlight brightness adjustment via DPCD X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP intel_dp_aux_enable_backlight() assumed that the register BACKLIGHT_BRIGHTNESS_CONTROL_MODE can only has value 01 (DP_EDP_BACKLIGHT_CONTROL_MODE_PRESET) when initialize. This patch fixed that by handling all cases of that register. Signed-off-by: Puthikorn Voravootivat Reviewed-by: Dhinakaran Pandiyan --- drivers/gpu/drm/i915/intel_dp_aux_backlight.c | 33 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c index 341bf2cb0c25..870c03fc0f3a 100644 --- a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c +++ b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c @@ -97,15 +97,36 @@ static void intel_dp_aux_enable_backlight(struct intel_connector *connector) { struct intel_dp *intel_dp = enc_to_intel_dp(&connector->encoder->base); uint8_t dpcd_buf = 0; + uint8_t edp_backlight_mode = 0; set_aux_backlight_enable(intel_dp, true); - if ((drm_dp_dpcd_readb(&intel_dp->aux, - DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &dpcd_buf) == 1) && - ((dpcd_buf & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK) == - DP_EDP_BACKLIGHT_CONTROL_MODE_PRESET)) - drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, - (dpcd_buf | DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD)); + if (drm_dp_dpcd_readb(&intel_dp->aux, + DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &dpcd_buf) != 1) { + DRM_DEBUG_KMS("Failed to read DPCD register 0x%x\n", + DP_EDP_BACKLIGHT_MODE_SET_REGISTER); + return; + } + + edp_backlight_mode = dpcd_buf & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK; + + switch (edp_backlight_mode) { + case DP_EDP_BACKLIGHT_CONTROL_MODE_PWM: + case DP_EDP_BACKLIGHT_CONTROL_MODE_PRESET: + case DP_EDP_BACKLIGHT_CONTROL_MODE_PRODUCT: + dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK; + dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD; + if (drm_dp_dpcd_writeb(&intel_dp->aux, + DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf) < 0) { + DRM_DEBUG_KMS("Failed to write aux backlight mode\n"); + } + break; + + /* Do nothing when it is already DPCD mode */ + case DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD: + default: + break; + } } static void intel_dp_aux_disable_backlight(struct intel_connector *connector)