From patchwork Tue Apr 18 23:48:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9686703 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 6EA7E602C2 for ; Tue, 18 Apr 2017 23:48:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F8702837F for ; Tue, 18 Apr 2017 23:48:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53A102839C; Tue, 18 Apr 2017 23:48:41 +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 0D4602837F for ; Tue, 18 Apr 2017 23:48:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 41B716E22F; Tue, 18 Apr 2017 23:48:40 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg0-x22b.google.com (mail-pg0-x22b.google.com [IPv6:2607:f8b0:400e:c05::22b]) by gabe.freedesktop.org (Postfix) with ESMTPS id BBE336E22B for ; Tue, 18 Apr 2017 23:48:39 +0000 (UTC) Received: by mail-pg0-x22b.google.com with SMTP id 63so3907012pgh.0 for ; Tue, 18 Apr 2017 16:48:39 -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=WtMSx8Qb2rr7vEcVtTdah9hnzzkykNtPbLGZWyEvg64=; b=uDKKCuJ+j+w11HZmXsdH0WI2f/rq2MDQqlk0azOq+8DRWSB6WckZ7FSOI+udoOdCHY D9VN6AbrURqYOkymrVe4Z+fyMNUY15Ukwdv101znGOspwt4vbWcMhh2CiGElGG8TLClI K6fzl4H9HBeIA904YuZAZDpP8Ae1C3Tv8/IAP7ai2lzlj0LPlazpW4fPgOQO/jNwgIzh yHEce8PpuqmolAEYFYhbv//kHrhwTS2cKkKfAT+79ND5hxZGpB5NpAavkBUCr9RScM3S CYNDPAER3GpJHyie0qrDhdg8h8pF1h3T/ZWDeCQKnoXNwnZN8roLEKyVFjhMFraMwaW4 7e5Q== 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=WtMSx8Qb2rr7vEcVtTdah9hnzzkykNtPbLGZWyEvg64=; b=EDkOsdltT40A1REPzaMN25TOURI4FQN441gcMlypQd2acmR/I2SRTuyTsYMLV+T+OJ q+6TZVHfYjKQa2ly4smB6dgsjApv1w5d+dT5R6/dXnt1C8NTF5MqRLkvGJq7SMtsJPmF PFh8wwY9JqyUl+Z9kEdU17sWhgv16NPSJCq5OLkD3ApzhaTRyVGu91xhxEgT6gxWmDsq l+zB3Wu05vrUzZ+PMv75+v3jkxBnil+PkAKG8oEbhaDt/AUA8qxFj31uPe6VEb9ctVa2 ZbzKmiM/C96Yd8vi34y+tj1TBHX8pQn34Kyh43fhJNcVEByXNcDcrdvrGt7rEa9v3xO9 wcjw== X-Gm-Message-State: AN3rC/6ROeZX85+k8v/k39c/LA0ME8oVyqKXU69b8O4pPSJNHvCRvDXv DFzNdL0OQO2QOT02 X-Received: by 10.84.225.129 with SMTP id u1mr18003plj.123.1492559319269; Tue, 18 Apr 2017 16:48:39 -0700 (PDT) Received: from puthik2.mtv.corp.google.com ([172.22.64.53]) by smtp.gmail.com with ESMTPSA id q85sm537286pfj.112.2017.04.18.16.48.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 16:48:38 -0700 (PDT) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id 8818211F8BE; Tue, 18 Apr 2017 16:48:37 -0700 (PDT) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org, Jani Nikula Date: Tue, 18 Apr 2017 16:48:20 -0700 Message-Id: <20170418234824.157355-3-puthik@chromium.org> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog In-Reply-To: <20170418234824.157355-1-puthik@chromium.org> References: <20170418234824.157355-1-puthik@chromium.org> Cc: Puthikorn Voravootivat Subject: [Intel-gfx] [PATCH RESEND v4 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 42f73d9a3ccf..f06c8381c74e 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)