From patchwork Wed Mar 22 22:54:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9640231 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 4C1C460328 for ; Wed, 22 Mar 2017 22:54:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EF2E284DC for ; Wed, 22 Mar 2017 22:54:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33CFF284F0; Wed, 22 Mar 2017 22:54:55 +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 3C2C2284DC for ; Wed, 22 Mar 2017 22:54:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD3C46E9D4; Wed, 22 Mar 2017 22:54:50 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x22d.google.com (mail-pf0-x22d.google.com [IPv6:2607:f8b0:400e:c00::22d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5DF4A6E990 for ; Wed, 22 Mar 2017 22:54:49 +0000 (UTC) Received: by mail-pf0-x22d.google.com with SMTP id o190so15577023pfo.0 for ; Wed, 22 Mar 2017 15:54:49 -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=Tnet3GAEfogjIWRVFeSpU1RFM2UaxYq5PPdR6vPS1Ao=; b=MavrLxCFTuIBWDCHE/wRKgY+S1oJ7TWUmPm4q6fDEfSDE0epumorZ1mwWiLVHPvPV0 RbM35h1TpAkA8W9LndI5vWy4cp8suUc2suuTR4L566m1ozogA3sU80ntPsAJunXPp59x fD36gqqoRNk9l0RkTXMNNR+0MyPCbIRDL52tfVOSTFiHhcE06scKIIvq5LL1TKZ5DwPS CB91q8D0xe9VUggGVXJ+rU9Axf+LnDn0einbb/e26x9ZCiPh14+BlqOgRHsmC6R5CrQM ZxnbpyC1eMJkSD0BA5I2GBpSmo/LfRJdUkHa8m8FKTZsF3uVtGRlCl4Iv9aq61pDdo7D YuEg== 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=Tnet3GAEfogjIWRVFeSpU1RFM2UaxYq5PPdR6vPS1Ao=; b=YyN3oC6MyxmIh/UGSEDaN8HxnpJRQfiKqXMJC7b3mAcRQi7BcbOxBWRPm+OwA2hX8U DpMO08U/udpQOLFUHnhusWYTA+vBnnqK/TyA75oxOOe8bLwGjKvQYopCDRtdIH3TLMQK KCwlh5GicbDUcyuwQvmgkKtrZXWeSHmGw6Yp3/7ME5wBSN7/ACCJ4wC1bvbfMw7fy33L p608NW/qCOwnI3Pevam7bthm5H/bXMSu1sY6q/OOytsSTZ+/2VFIBle2Ngq9xSD3F5BR YDetYaFhZ1N/qM8FTTbDF0JQco9QhbrWyuTKZUohNkKoNSCoxBjZDhUNWKFkIRf9Omhm VxBQ== X-Gm-Message-State: AFeK/H0QWK+1hDvVZkl3hnKe8VAgUs7JMNpw7tdV5GT3bEpO9c6+z93bbW9cEYocMc7km0Zn X-Received: by 10.84.130.106 with SMTP id 97mr1009873plc.132.1490223288849; Wed, 22 Mar 2017 15:54:48 -0700 (PDT) Received: from puthik2.mtv.corp.google.com ([172.22.64.53]) by smtp.gmail.com with ESMTPSA id r67sm5856822pfb.125.2017.03.22.15.54.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 15:54:48 -0700 (PDT) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id B757911F90B; Wed, 22 Mar 2017 15:54:46 -0700 (PDT) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org, Jani Nikula Date: Wed, 22 Mar 2017 15:54:39 -0700 Message-Id: <20170322225443.79343-3-puthik@chromium.org> X-Mailer: git-send-email 2.12.1.500.gab5fba24ee-goog In-Reply-To: <20170322225443.79343-1-puthik@chromium.org> References: <20170322225443.79343-1-puthik@chromium.org> Cc: Puthikorn Voravootivat Subject: [Intel-gfx] [PATCH 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. Cc: Jani Nikula 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)