From patchwork Fri Mar 10 22:33:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9618071 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 4BB7C604DD for ; Fri, 10 Mar 2017 22:33:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44CD3287B2 for ; Fri, 10 Mar 2017 22:33:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3978E287B4; Fri, 10 Mar 2017 22:33:48 +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 F0B31287B2 for ; Fri, 10 Mar 2017 22:33:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0FDE26EE95; Fri, 10 Mar 2017 22:33:44 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x233.google.com (mail-pf0-x233.google.com [IPv6:2607:f8b0:400e:c00::233]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85CE16E2F5 for ; Fri, 10 Mar 2017 22:33:42 +0000 (UTC) Received: by mail-pf0-x233.google.com with SMTP id v190so46751265pfb.1 for ; Fri, 10 Mar 2017 14:33:42 -0800 (PST) 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=ix47w63l16FnD/uj8nnxCOvR69uhD1LtIdQFt2lfBPo=; b=CpyqDMrhJd/A+6lVZRf6UfveW1YxhVDQraDB3KUPVHwb9SwAwrkG1JBGu8XiVNPalP VfXTBL2GGC/QY44lllSA3155RbTq+uuzLZAYEXtkN0lv/ehFwsXtkzVj0St+/15k6x49 MdqhnFvdbIQQgLPl8rtSv8PrsP2P6chY9OazE+9xf02DILAIB1fX88HtyctWRSytl1BE 7ZiBzhdNb/Y+O2idvzQ8rmmmUWY+MNfR4ajPZOUrGF7KtRXSAucaLRdHqp9xYHcJZBOU aK0bXPBVWidoWuFoyL+aIpaN0OXKgb6UKpa3GIqMO4Dqd9o8VLt62ezvxC55me+V/rej z3zg== 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=ix47w63l16FnD/uj8nnxCOvR69uhD1LtIdQFt2lfBPo=; b=dBo7T95u9DJlAGORPdIIHmBZVWdpNGzwMMjPe6PS1/lA6CDxwNX62iP7+dFAz4K+Do 9Qr15G5fvZHbGCMVK2RDH6z1vZZ5gLGEqm1IDJmaGWsaryQxopIcPVsry/iwQ4L0wb1S jsxkUvN/s48pzZSHZo9OsqUW/p1doykU+wRy1X/Aksk9bILmkNNLwk7/wadDEOoyagm8 P8yuGlRhUB7DQYzpImlD2CoIMnb/LBjS36ffIF8rN3Q0R9/HOacn/dGMBrjQ3UMxXEdz IFcw1n4grjyJRc81evSbNuQ4ORaf5Wmtz1T+5IbJRsCOH0/hm+vO9xrLBX3A8Qqb+Dgq uVCA== X-Gm-Message-State: AMke39n+UUvcHkN7rpB28lSdnLThYJF1lp74cYmbAqYrVJnBYFS9JFbvXF1JZ1+63s59PF9u X-Received: by 10.98.93.150 with SMTP id n22mr24051189pfj.103.1489185222023; Fri, 10 Mar 2017 14:33:42 -0800 (PST) Received: from puthik2.mtv.corp.google.com ([2620:0:1000:1301:c556:1c14:f921:6e24]) by smtp.gmail.com with ESMTPSA id u75sm20638594pgc.31.2017.03.10.14.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Mar 2017 14:33:41 -0800 (PST) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id 443E211F9F4; Fri, 10 Mar 2017 14:33:39 -0800 (PST) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org, Jani Nikula Date: Fri, 10 Mar 2017 14:33:33 -0800 Message-Id: <20170310223335.46635-3-puthik@chromium.org> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170310223335.46635-1-puthik@chromium.org> References: <20170310223335.46635-1-puthik@chromium.org> Cc: Puthikorn Voravootivat Subject: [Intel-gfx] [PATCH v2 2/4] drm/i915: Correctly enable blacklight 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. Change-Id: Ic6ee6508d7c4a564bd879f36c9d2b971c49e64bc Signed-off-by: Puthikorn Voravootivat --- drivers/gpu/drm/i915/intel_dp_aux_backlight.c | 29 +++++++++++++++++++++------ 1 file changed, 23 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 da69f01a6a83..532176f1108a 100644 --- a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c +++ b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c @@ -101,15 +101,32 @@ 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)) { + 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; + drm_dp_dpcd_writeb(&intel_dp->aux, + DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf); + 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)