From patchwork Thu May 11 23:02:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9723221 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 66CA960236 for ; Thu, 11 May 2017 23:02:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E7C628738 for ; Thu, 11 May 2017 23:02:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5104A2873E; Thu, 11 May 2017 23:02:44 +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 D8B1428738 for ; Thu, 11 May 2017 23:02:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBFF16E5FA; Thu, 11 May 2017 23:02:42 +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 87E356E5F7 for ; Thu, 11 May 2017 23:02:39 +0000 (UTC) Received: by mail-pg0-x22b.google.com with SMTP id q125so1862288pgq.2 for ; Thu, 11 May 2017 16:02: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=oB/OHmSKpu4KeDJrJu+sDRVjCH0Qf01HmQZmC/3PHSU=; b=a5+ZMxI3hOlQj04DnWn7o7+/sySS+vvMdAHNmNdRBtJF1e6W/HE7s5L6gcQQLffNUv QXrh7QkCvHXtFmUyhrhRusdX1NBKRiaolvIhCn6Bg8u53WaDr/rrTyY1UmyrMKQD3hhz 97Y3UbztevKgTtQQsTdwAO+Crn31aiVqNHp2N4tNkBm/WUwjVNZaAC0Yk6gGpxUGXscF dGJg62jYmCuVCFt8berTqYGaFk0//F+CwUwHFGLI5nE0B+uZobmsuxSOTE4H0udFOk9D gXUCbSX0U3Q2txAkav2FP3Crsj3+AYnL2Lg2vUbjOeKVXIwedQnfpMwyDy4NA8Q+9KVU EbUA== 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=oB/OHmSKpu4KeDJrJu+sDRVjCH0Qf01HmQZmC/3PHSU=; b=efZsVS4zenjGOKjHZWoUjR/xpWnSFDIAcNI+xJSY0T8NBYguTdP/vGn5CARwMwv5N1 RpEuvY+j2MkpbIPLR5udrxAmDLV+lQx7SaU42+bJFDyrgLDj5lWG7/S1k6AYzrDyagHy whtFUGEdE2UuBe3RX78c8IuOON7o/5VO6WtN7s7ioMBaOCv44Xv3i8/oI3X0FpsC6V1z bbzO6Fx1bH8ujSPHWHGU3kGEHhel8vHOUUYyI7GZPwGedZsqga1ovkOALgWso830WH92 FTvF/vUiBMJ6s+GPr/VfH37pIiuQh2gHcolZfb3metZKjo9JERNONahTHgJyySTftYTk fo0w== X-Gm-Message-State: AODbwcBnUdRuwIyDqDrvSwf9uBQhXDZSmcqnIqJpIgCCajtK7/b/IsO6 lSKY37/3uGzyLe1h X-Received: by 10.99.160.68 with SMTP id u4mr979127pgn.39.1494543759017; Thu, 11 May 2017 16:02:39 -0700 (PDT) Received: from puthik2.mtv.corp.google.com ([172.22.64.53]) by smtp.gmail.com with ESMTPSA id s3sm2003011pgn.29.2017.05.11.16.02.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 16:02:38 -0700 (PDT) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id 8163811F87C; Thu, 11 May 2017 16:02:37 -0700 (PDT) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org, Dhinakaran Pandiyan Date: Thu, 11 May 2017 16:02:18 -0700 Message-Id: <20170511230225.142870-3-puthik@chromium.org> X-Mailer: git-send-email 2.13.0.rc2.291.g57267f2277-goog In-Reply-To: <20170511230225.142870-1-puthik@chromium.org> References: <20170511230225.142870-1-puthik@chromium.org> Cc: Puthikorn Voravootivat , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v7 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 341bf2cb0c25..870c03fc0f3a 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)