From patchwork Sat Jun 3 02:04:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9763757 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 0421560351 for ; Sat, 3 Jun 2017 02:05:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8CA528618 for ; Sat, 3 Jun 2017 02:05:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD84A2861A; Sat, 3 Jun 2017 02:05: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 4BC8D28618 for ; Sat, 3 Jun 2017 02:05:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0409A6E56B; Sat, 3 Jun 2017 02:05:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg0-x22a.google.com (mail-pg0-x22a.google.com [IPv6:2607:f8b0:400e:c05::22a]) by gabe.freedesktop.org (Postfix) with ESMTPS id A3AEA6E565 for ; Sat, 3 Jun 2017 02:05:02 +0000 (UTC) Received: by mail-pg0-x22a.google.com with SMTP id u13so4654338pgb.0 for ; Fri, 02 Jun 2017 19:05:02 -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=Hy8iLQcsd1llBveF2fGWjfqSlYsZCEo/u8Tmy45zwg8=; b=ECkk13314OPkwHS4tGyxMbqQ2GaRhIBLq9uy75RX7bjXjsJGJodovJ7zjLlKN2YcBg 2hUYTYHJoOWnAAamHNHVFOfNtrqbd3hs0ONs7wVruTcEH9BblO174PRFh1HNyGYKUaUE rIeLHHhB4k2DCSCLvgWPenrpQmjQdQQFLAlMepaCms1eRtn+0jKcJFPYRkFcHf5wvpQD 1AgDo2VirCxTn+NlZgQ55E6ZyqUNHz3l034eZikYwLBcIHaEpGrkXtoqXX7FIhcFE1uN 8NtisT4FCUw41rHUdFS59+mWDWt1SrebPBQsjYveWEhEn49BDpDOLlCw7Ef5+ohjATCy j1Zw== 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=Hy8iLQcsd1llBveF2fGWjfqSlYsZCEo/u8Tmy45zwg8=; b=d/iaV3pQfxAGehza+IhQBAOSChnSr2gmVzvkEX9CpAyhUEL6NFuQHHlbbw5vJU/LCK iH53ABxBTAVZHDY9X5S+4kkHR7/Vsh8h9FGV+cth0YARW7ZmV0Ph/IJMpummhwXq6rv0 jO1JJfgGmYjOFyF9eG8dxpH6qCLKPXowYYIudvMauEASeHULU4FKAoynP2FrmRB6vLoJ Ytbsms5fuyVGOcbWB9F+1Llw/QcdI72BrveKMBpbrYv3hd94QaVPeBV4fH5Jl+5afKk6 wINt9S1IeyeSS8wWSXcU1ZoJUEZm6kX7ilaVNT8ZyHPuTZd6L4ExqgzqUXepRt9yN5V8 0a3Q== X-Gm-Message-State: AODbwcDiuvGb1/RsjJgezCXQebfHibvHIRqatyFA1ghC+gT56aALqQgI ih8nn0UbTHncWsTq X-Received: by 10.84.164.162 with SMTP id w31mr2903789pla.174.1496455501997; Fri, 02 Jun 2017 19:05:01 -0700 (PDT) Received: from puthik2.mtv.corp.google.com ([2620:0:1000:1301:f185:8f31:f67:22bb]) by smtp.gmail.com with ESMTPSA id k9sm43653782pga.40.2017.06.02.19.05.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 19:05:01 -0700 (PDT) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id 3D95811F8BE; Fri, 2 Jun 2017 19:04:59 -0700 (PDT) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org, Dhinakaran Pandiyan , Jani Nikula , Daniel Vetter Date: Fri, 2 Jun 2017 19:04:58 -0700 Message-Id: <20170603020458.64929-4-puthik@chromium.org> X-Mailer: git-send-email 2.13.0.506.g27d5fe0cd-goog In-Reply-To: <20170603020458.64929-1-puthik@chromium.org> References: <20170603020458.64929-1-puthik@chromium.org> Cc: Puthikorn Voravootivat , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v11 3/3] drm/i915: Add option to support dynamic backlight 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 This patch adds option to enable dynamic backlight for eDP panel that supports this feature via DPCD register and set minimum / maximum brightness to 0% and 100% of the normal brightness. Change-Id: I52f04b814bb4cd9df570ab59094ae974b9baec5b Signed-off-by: Puthikorn Voravootivat Reviewed-by: Dhinakaran Pandiyan for --- drivers/gpu/drm/i915/i915_params.c | 5 +++++ drivers/gpu/drm/i915/i915_params.h | 3 ++- drivers/gpu/drm/i915/intel_dp_aux_backlight.c | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index 3758ae1f11b4..d84042ddf1fc 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -65,6 +65,7 @@ struct i915_params i915 __read_mostly = { .inject_load_failure = 0, .enable_dpcd_backlight = -1, .enable_gvt = false, + .enable_dbc = true, }; module_param_named(modeset, i915.modeset, int, 0400); @@ -254,3 +255,7 @@ MODULE_PARM_DESC(enable_dpcd_backlight, module_param_named(enable_gvt, i915.enable_gvt, bool, 0400); MODULE_PARM_DESC(enable_gvt, "Enable support for Intel GVT-g graphics virtualization host support(default:false)"); + +module_param_named_unsafe(enable_dbc, i915.enable_dbc, bool, 0600); +MODULE_PARM_DESC(enable_dbc, + "Enable support for dynamic backlight control (default:true)"); diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h index 643dfaf41c1f..99f68d853c18 100644 --- a/drivers/gpu/drm/i915/i915_params.h +++ b/drivers/gpu/drm/i915/i915_params.h @@ -67,7 +67,8 @@ func(bool, verbose_state_checks); \ func(bool, nuclear_pageflip); \ func(bool, enable_dp_mst); \ - func(bool, enable_gvt) + func(bool, enable_gvt); \ + func(bool, enable_dbc) #define MEMBER(T, member) T member struct i915_params { diff --git a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c index b73b3d431a82..b2f4cc975a3e 100644 --- a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c +++ b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c @@ -172,6 +172,24 @@ static bool intel_dp_aux_set_pwm_freq(struct intel_connector *connector) return true; } +/* +* Set minimum / maximum dynamic brightness percentage. This value is expressed +* as the percentage of normal brightness in 5% increments. +*/ +static bool +intel_dp_aux_set_dynamic_backlight_percent(struct intel_dp *intel_dp, + u32 min, u32 max) +{ + u8 dbc[] = { DIV_ROUND_CLOSEST(min, 5), DIV_ROUND_CLOSEST(max, 5) }; + + if (drm_dp_dpcd_write(&intel_dp->aux, DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, + dbc, sizeof(dbc)) < 0) { + DRM_DEBUG_KMS("Failed to write aux DBC brightness level\n"); + return false; + } + return true; +} + static void intel_dp_aux_enable_backlight(struct intel_connector *connector) { struct intel_dp *intel_dp = enc_to_intel_dp(&connector->encoder->base); @@ -205,6 +223,14 @@ static void intel_dp_aux_enable_backlight(struct intel_connector *connector) if (intel_dp_aux_set_pwm_freq(connector)) new_dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE; + if (i915.enable_dbc && + (intel_dp->edp_dpcd[2] & DP_EDP_DYNAMIC_BACKLIGHT_CAP)) { + if(intel_dp_aux_set_dynamic_backlight_percent(intel_dp, 0, 100)) { + new_dpcd_buf |= DP_EDP_DYNAMIC_BACKLIGHT_ENABLE; + DRM_DEBUG_KMS("Enable dynamic brightness.\n"); + } + } + if (new_dpcd_buf != dpcd_buf) { if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, new_dpcd_buf) < 0) {