From patchwork Tue May 23 22:38:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puthikorn Voravootivat X-Patchwork-Id: 9744393 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 9CCBF6032B for ; Tue, 23 May 2017 22:38:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 908A028818 for ; Tue, 23 May 2017 22:38:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 857412885E; Tue, 23 May 2017 22:38:24 +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 29E6628818 for ; Tue, 23 May 2017 22:38:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 811526E39D; Tue, 23 May 2017 22:38:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x22c.google.com (mail-pf0-x22c.google.com [IPv6:2607:f8b0:400e:c00::22c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 91BF96E396 for ; Tue, 23 May 2017 22:38:15 +0000 (UTC) Received: by mail-pf0-x22c.google.com with SMTP id m17so127595767pfg.3 for ; Tue, 23 May 2017 15:38:15 -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=C4ygTS/RVgW1nuJPHOHQJ0iHrOzJBoTmT9cWRbTXHGY=; b=ss/q0vWR+Bv2gpjWmc9PsXjw3N/27zI1V9JscmCt6i8NioqvDl67bx8xzDaA/oIDt1 3rGrZl0E2lkeBhZ3XnxmXXznSMznLkBmk3YlvgnOgbnJvpVs1d+Srr+goC6GXie3X1zq wIBYtmL8YiqypSFdTE9TDlJ9IzyjC01n2zG1rR51djFmBl9ct2tWYW/UZB7YfV8ZqbZ0 10eRDzI6CbOAf6ja3oQvkAgYQCf2PQGk+Wo+7qnkMb30fIgG9qZqB1sBE3dJu568fUKP oEQaHmF/OHZBuDJc/K4POfatn27jigJlwuJDNeIJUqlWdb+u3eDC+8L2gozeP2U5VIhm TKbg== 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=C4ygTS/RVgW1nuJPHOHQJ0iHrOzJBoTmT9cWRbTXHGY=; b=H8JKcO7xaTH8FGlhGMWpkSgpu9I2pG3xu1yEE+u+ONmxMCRk9jgxYVRfacY0JyutzE 556XifHsUQPXwqPV2IZb3I+0PvmWNtOsEtUuiCSxPHz0xYCDNH9ohAd1b18L8/csbQvI idT4upfNrLFOu+83HHAfteC+dD+aI1cH+UfQGlW8h4bbg4G5NS0FG9w8IRY2laNNx3ek HMZieyomgslpIMB9Pt735aLgAxE5wwY2so1nOA/lN5vKx9MfaewZ78hhsBazbKLqdNQX z5BVP1Uh3huGTEeMh1vEVCDwHwTHsm+EkLeoVBHHkoiSRL8RDvpSFNpEtgLUIFEa2KaS M6ww== X-Gm-Message-State: AODbwcC7+1plEXWy2JbELfiYzV1ExcO5v8XVNM7GhihXs/rSLBGf5vz4 S1BbDBFsc4+mdE++ X-Received: by 10.98.204.130 with SMTP id j2mr34672938pfk.107.1495579095039; Tue, 23 May 2017 15:38:15 -0700 (PDT) Received: from puthik2.mtv.corp.google.com ([2620:0:1000:1301:1057:ae23:f7e3:c8c7]) by smtp.gmail.com with ESMTPSA id l85sm3289647pfj.130.2017.05.23.15.38.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2017 15:38:14 -0700 (PDT) Received: by puthik2.mtv.corp.google.com (Postfix, from userid 218808) id 7B53911F931; Tue, 23 May 2017 15:38:12 -0700 (PDT) From: Puthikorn Voravootivat To: intel-gfx@lists.freedesktop.org, Dhinakaran Pandiyan , Jani Nikula Date: Tue, 23 May 2017 15:38:02 -0700 Message-Id: <20170523223805.46372-3-puthik@chromium.org> X-Mailer: git-send-email 2.13.0.219.gdb65acc882-goog In-Reply-To: <20170523223805.46372-1-puthik@chromium.org> References: <20170523223805.46372-1-puthik@chromium.org> Cc: Puthikorn Voravootivat , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v9 2/5] drm/i915: Allow choosing how to adjust brightness if both supported 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 Add option to allow choosing how to adjust brightness if panel supports both PWM pin and AUX channel. Signed-off-by: Puthikorn Voravootivat --- drivers/gpu/drm/i915/i915_params.c | 8 +++++--- drivers/gpu/drm/i915/i915_params.h | 2 +- drivers/gpu/drm/i915/intel_dp_aux_backlight.c | 26 ++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index b6a7e363d076..13cf3f1572ab 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -63,7 +63,7 @@ struct i915_params i915 __read_mostly = { .huc_firmware_path = NULL, .enable_dp_mst = true, .inject_load_failure = 0, - .enable_dpcd_backlight = false, + .enable_dpcd_backlight = -1, .enable_gvt = false, }; @@ -246,9 +246,11 @@ MODULE_PARM_DESC(enable_dp_mst, module_param_named_unsafe(inject_load_failure, i915.inject_load_failure, uint, 0400); MODULE_PARM_DESC(inject_load_failure, "Force an error after a number of failure check points (0:disabled (default), N:force failure at the Nth failure check point)"); -module_param_named(enable_dpcd_backlight, i915.enable_dpcd_backlight, bool, 0600); +module_param_named(enable_dpcd_backlight, i915.enable_dpcd_backlight, int, 0600); MODULE_PARM_DESC(enable_dpcd_backlight, - "Enable support for DPCD backlight control (default:false)"); + "Enable support for DPCD backlight control " + "(-1:disable (default), 0:Use PWM pin if both supported, " + "1:Use DPCD if both supported"); module_param_named(enable_gvt, i915.enable_gvt, bool, 0400); MODULE_PARM_DESC(enable_gvt, diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h index 34148cc8637c..ac02efce6e22 100644 --- a/drivers/gpu/drm/i915/i915_params.h +++ b/drivers/gpu/drm/i915/i915_params.h @@ -66,7 +66,7 @@ func(bool, verbose_state_checks); \ func(bool, nuclear_pageflip); \ func(bool, enable_dp_mst); \ - func(bool, enable_dpcd_backlight); \ + func(int, enable_dpcd_backlight); \ func(bool, enable_gvt) #define MEMBER(T, member) T member diff --git a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c index a0995c00fc84..16ba1924308d 100644 --- a/drivers/gpu/drm/i915/intel_dp_aux_backlight.c +++ b/drivers/gpu/drm/i915/intel_dp_aux_backlight.c @@ -43,6 +43,9 @@ static void set_aux_backlight_enable(struct intel_dp *intel_dp, bool enable) else reg_val &= ~(DP_EDP_BACKLIGHT_ENABLE); + /* TODO: If the panel also support enabling backlight via BL_ENABLE pin, + * the backlight will be enabled again in _intel_edp_backlight_on() + */ if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_DISPLAY_CONTROL_REGISTER, reg_val) != 1) { DRM_DEBUG_KMS("Failed to %s aux backlight\n", @@ -168,20 +171,35 @@ intel_dp_aux_display_control_capable(struct intel_connector *connector) /* Check the eDP Display control capabilities registers to determine if * the panel can support backlight control over the aux channel */ - if (intel_dp->edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP && - (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP) && - !(intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP)) { + if ((intel_dp->edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP) && + (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP)) { DRM_DEBUG_KMS("AUX Backlight Control Supported!\n"); return true; } return false; } +static bool +intel_dp_pwm_pin_display_control_capable(struct intel_connector *connector) +{ + struct intel_dp *intel_dp = enc_to_intel_dp(&connector->encoder->base); + + /* Check the eDP Display control capabilities registers to determine if + * the panel can support backlight control via BL_PWM_DIM eDP pin + */ + return (intel_dp->edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP) && + (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP); +} + int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector) { struct intel_panel *panel = &intel_connector->panel; - if (!i915.enable_dpcd_backlight) + if (i915.enable_dpcd_backlight == -1) + return -ENODEV; + + if (i915.enable_dpcd_backlight == 0 && + intel_dp_pwm_pin_display_control_capable(intel_connector)) return -ENODEV; if (!intel_dp_aux_display_control_capable(intel_connector))