From patchwork Wed Mar 8 21:30:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9612001 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 351D76016C for ; Wed, 8 Mar 2017 21:31:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2838E2863F for ; Wed, 8 Mar 2017 21:31:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D47028642; Wed, 8 Mar 2017 21:31:08 +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 D76492863F for ; Wed, 8 Mar 2017 21:31:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 09E456EA56; Wed, 8 Mar 2017 21:31:07 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg0-x22e.google.com (mail-pg0-x22e.google.com [IPv6:2607:f8b0:400e:c05::22e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7D5738926E for ; Wed, 8 Mar 2017 21:31:01 +0000 (UTC) Received: by mail-pg0-x22e.google.com with SMTP id 77so17619205pgc.1 for ; Wed, 08 Mar 2017 13:31:01 -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=pEduStqP0ki4oX3+pbTBnPWIbOe7lsP6UezWPleBIms=; b=NsAmH9MyCVodHqTGAf0gSNtFakM8tUYbem3j2iJFYuywVGe22wqjiyMHaldshLsD/d Sjx1ZiNjmOaoA/ZHotqiC+nOzmmbntOVx9lE0/8j866bQQCzyNzElgX1caetlKQ1g/Ta ssk6cpcoFAxJwVFEBKrPgwLF96Y4IDXEmeb/MHOuShS4I3aOt4aP6ZRju+hAL1IxiYVq 6HTGZhHaUD0VTfA613y2+gardocQ1CqoVJXOG5NFQZckxFlqb6VkMlAUwd4q6+6eadfG rEVjbaTa2e2etEWUkLUqeMeAJxFOMm6zbPnixmLqG71TvH32XNsmr4rfckFthIOrtrVc J6bA== 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=pEduStqP0ki4oX3+pbTBnPWIbOe7lsP6UezWPleBIms=; b=R6UBVTwWFAHh9Lth3jOl7oW198wGDnrS741zlF0FVMAHQSWjaT/+Y/EDTs/YA0f+MH Ae2ctmNhrbf7wF9LLjP446VYI6lnZofz6w+QKS8y1bEl2t7dJczU3u8dGwqO6h48RURi lMrYRh/DRYIBBMB/TJVbYlnVJItycCDwMk/ZEMeoArJqzGd6UqAWTOTl2VhoJPoho73o BwBtS3hAW7d/XLDTdrubVPio+/gB0c1udvhr7Bu4v5kQMTLPhwI2Xx9t19XC0nTlVYhY e9bT3kqd+plMAicgDGCZexf1s2MkZIhecK5nB+06uA0wox4n8C7+HHnvgLGtoxhshJFx nfcw== X-Gm-Message-State: AMke39nKrIIdxa5wKTjivsLxPQj3Wif6Tlo7uQUhDX/5jsQfM5jB5Gu+cuHN6c0HL6UoQZDU X-Received: by 10.99.95.69 with SMTP id t66mr9695600pgb.0.1489008660929; Wed, 08 Mar 2017 13:31:00 -0800 (PST) Received: from puthik2.mtv.corp.google.com ([172.22.64.53]) by smtp.gmail.com with ESMTPSA id z68sm8033912pgz.11.2017.03.08.13.30.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Mar 2017 13:30:59 -0800 (PST) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id F07EA120DF4; Wed, 8 Mar 2017 13:30:57 -0800 (PST) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org Date: Wed, 8 Mar 2017 13:30:50 -0800 Message-Id: <20170308213053.194062-3-puthik@chromium.org> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170308213053.194062-1-puthik@chromium.org> References: <20170308213053.194062-1-puthik@chromium.org> Cc: Puthikorn Voravootivat Subject: [Intel-gfx] [PATCH 2/5] 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 abfb09c1269f..16cd1265d264 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: + 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 in these cases */ + case DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD: + case DP_EDP_BACKLIGHT_CONTROL_MODE_PRODUCT: + default: + break; + } } static void intel_dp_aux_disable_backlight(struct intel_connector *connector)