From patchwork Thu May 4 00:28:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9710659 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 EDA5B60385 for ; Thu, 4 May 2017 00:29:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFD2028648 for ; Thu, 4 May 2017 00:29:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4B522867A; Thu, 4 May 2017 00:29:00 +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 9958328648 for ; Thu, 4 May 2017 00:29:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2CA1F6E3E7; Thu, 4 May 2017 00:28:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x229.google.com (mail-pf0-x229.google.com [IPv6:2607:f8b0:400e:c00::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE3E76E3C8 for ; Thu, 4 May 2017 00:28:49 +0000 (UTC) Received: by mail-pf0-x229.google.com with SMTP id q66so2472080pfi.3 for ; Wed, 03 May 2017 17:28:49 -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=Nj8/qT/eP1Ix+FD17qFjj9RUfbzus8MmN6pUkffOqqg=; b=ts2DmyCyucrPIICRqz7Cj74qfygnTPbormWd3VVPb+/BtygQlZEHywYtHIw0Iumalv AXEpc2lmp5GbXzSE+ZD7XaGBUwUajh2lQrOhZYdRBBf+2ANa5TGLy/brWivw22SBzARC mXiC5/zOwYwgDrTyC+VqkKHs7//nvkieAwEzjPmuhHZFCr3J8ky+aHeXp2UBPjwUnYQ1 YMsIH791+loS6UZVaOIhs43gjlKIqE1tKrIXPY3fF9eQvZmkIYsOrclE91sawZ+3Dy+t +MyWpnBCLnhddfXk5NtjuaTg8qSbxT3mb2WssiSMBtzV3qekxDBegA3QIyTUHo+XJZ7I 99rQ== 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=Nj8/qT/eP1Ix+FD17qFjj9RUfbzus8MmN6pUkffOqqg=; b=iJ/YIydpktobCcyzVZrZO9G8+phjw3izL3e+HwDyLJ+i4goA2a4wzJFwTfzUIDoyTR 00899Byxq/N3iQGcsr1vwW1EHaMa9wYoD20RjTkLWo6wJlMNVfMkjO51bd2lsfHVyXQV 7lIbXpE/sWX5P47StCT676W6ezdrM8SiwDR3Mov83byqO987QrOSoNPewTg0g+A9Ov5t Uge+edm/bW/sMXhiZFuflmDkIoOkRwfpvhJIkmjZZVr+DDq5H7sb5JZHMAIrDUolWgFb EuIuhjuYU+0hTZN0LWuVV98Zm5hYkrCS+VrGcx+RzLSfOgI0rnHl5WuV0aXeK+j6y3ki axMw== X-Gm-Message-State: AN3rC/6IRm+sUEc0lZ4VgDGWsR0XMXgvDGQZV8pGBFgMo6EeYGqt8ouM ovwOafx3dl+1+/hS X-Received: by 10.99.113.75 with SMTP id b11mr41613707pgn.173.1493857729183; Wed, 03 May 2017 17:28:49 -0700 (PDT) Received: from puthik2.mtv.corp.google.com ([172.22.64.53]) by smtp.gmail.com with ESMTPSA id 130sm466544pga.7.2017.05.03.17.28.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 May 2017 17:28:48 -0700 (PDT) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id 47E0411F8C6; Wed, 3 May 2017 17:28:45 -0700 (PDT) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org Date: Wed, 3 May 2017 17:28:29 -0700 Message-Id: <20170504002836.120988-3-puthik@chromium.org> X-Mailer: git-send-email 2.13.0.rc1.294.g07d810a77f-goog In-Reply-To: <20170504002836.120988-1-puthik@chromium.org> References: <20170504002836.120988-1-puthik@chromium.org> Cc: dri-devel@lists.freedesktop.org, Puthikorn Voravootivat , Dhinakaran Pandiyan Subject: [Intel-gfx] [PATCH v5 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 24a905d1a74b..ad8560c5f689 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)