From patchwork Wed Mar 15 23:41:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9626851 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 BF291604A9 for ; Wed, 15 Mar 2017 23:41:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0EA6285ED for ; Wed, 15 Mar 2017 23:41:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5D4C28610; Wed, 15 Mar 2017 23:41:23 +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 5E065285ED for ; Wed, 15 Mar 2017 23:41:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C9A836E97D; Wed, 15 Mar 2017 23:41:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg0-x234.google.com (mail-pg0-x234.google.com [IPv6:2607:f8b0:400e:c05::234]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6AAB06E97D for ; Wed, 15 Mar 2017 23:41:18 +0000 (UTC) Received: by mail-pg0-x234.google.com with SMTP id b129so15949712pgc.2 for ; Wed, 15 Mar 2017 16:41:18 -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=XeCBTrWYRnBBnxdxQXWMqy3VzhJnGkOf7blIGahExOA=; b=jIXXoUR3AIcgD+Bo12xPFmEMB8Rc157dLdmjctwZnS6dhy7yfMOLzEyTj2Hm1AuSql eHM7xFpyGVxHxCCNh+VvZolJcXP+4v0xR7mo7U2u5ztIoJM+rru0QDkFkhNqzaEXBqR3 iPRAP6gEkoTTQvroUEw+S26GMVo79DlSKWDu7p9kMl9TfTsbf75HcXzts/u0hM6TR+6U RseKgA7vJuEAdSZp5X/uRYQ8KVuge3KGilhaxzFUn+Cmzz8APujFhAuVYNmesgyvqCbq Xxe9AERYRCE47Ei6AiaQJjQjmX0I0lmOG4k8WuRbZUyC+NNwrnUEZY4157/JJCzYoabm 321w== 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=XeCBTrWYRnBBnxdxQXWMqy3VzhJnGkOf7blIGahExOA=; b=OQG5e/7fz30jU2LRib1C0w37o0UA9JWBSZrwdNtzUC2YnOU15jkdn24OJC+A01Q692 woBCsJ3jCq8t7iaWK+oPInWe/CG3quivx9TQi7nUEJH6rCZ+WuS6xjw0Gd3j86Xv+NsG k2dM/wnnKOaWTVIC3It1Xc4worG+b0sM6IOvBPAlaYGRz9mn35gU5pWU9NicSx5NGrDj M6Q2I/m7GprhK5gYRitGet5ijFAaWS0KRzQfZzJcKFIReqs6MkhKcrFv/NoyYBl5zGCf V4tY/IzfpzXWKPXwfH1i8ZTXJ2AfV8TPr1h1EedjDZAL3Vk3+BA0wm4QbqEoEaDR6G/s D8QA== X-Gm-Message-State: AFeK/H1YO6wiqcndn6IEhFq8FEpAXLCupB1dGNrJbMWU5b9TPV6yDbegLy4lFbHsHzC15koK X-Received: by 10.84.140.36 with SMTP id 33mr8190665pls.136.1489621277865; Wed, 15 Mar 2017 16:41:17 -0700 (PDT) Received: from puthik2.mtv.corp.google.com ([172.22.64.53]) by smtp.gmail.com with ESMTPSA id k76sm6288315pfg.42.2017.03.15.16.41.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 16:41:17 -0700 (PDT) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id 0460E11F9EA; Wed, 15 Mar 2017 16:41:15 -0700 (PDT) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org, Jani Nikula Date: Wed, 15 Mar 2017 16:41:07 -0700 Message-Id: <20170315234111.57204-3-puthik@chromium.org> X-Mailer: git-send-email 2.12.0.367.g23dc2f6d3c-goog In-Reply-To: <20170315234111.57204-1-puthik@chromium.org> References: <20170315234111.57204-1-puthik@chromium.org> Cc: Puthikorn Voravootivat Subject: [Intel-gfx] [PATCH v3 2/6] 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. 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)