From patchwork Mon Jul 4 08:57:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 941892 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p648v9T4003199 for ; Mon, 4 Jul 2011 08:57:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756778Ab1GDI5I (ORCPT ); Mon, 4 Jul 2011 04:57:08 -0400 Received: from mga09.intel.com ([134.134.136.24]:57841 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756689Ab1GDI5F (ORCPT ); Mon, 4 Jul 2011 04:57:05 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 04 Jul 2011 01:57:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,471,1304319600"; d="scan'208";a="23156022" Received: from rui.sh.intel.com (HELO [10.239.36.58]) ([10.239.36.58]) by orsmga001.jf.intel.com with ESMTP; 04 Jul 2011 01:57:03 -0700 Subject: Re: Need help debugging Sony Vaio VPCY2 backlight control problem From: Zhang Rui To: Michel Alexandre Salim Cc: Marco Chiappero , "linux-acpi@vger.kernel.org" , platform-driver-x86 , Mattia Dongili In-Reply-To: <4E117E61.2050808@sylvestre.me> References: <4E0E2155.4070508@fedoraproject.org> <4E0E4637.7000902@absence.it> <4E117DF7.2000602@fedoraproject.org> <4E117E61.2050808@sylvestre.me> Date: Mon, 04 Jul 2011 16:57:44 +0800 Message-ID: <1309769864.1896.113.camel@rui> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 04 Jul 2011 08:57:09 +0000 (UTC) Hi, Michael, please check if the two patches attached help. thanks, rui On Mon, 2011-07-04 at 16:48 +0800, Michel Alexandre Salim wrote: > On 07/04/2011 10:46 AM, Michel Alexandre Salim wrote: > > Here are the ectool dumps, before setting any brightness (backlight=0), > > after setting it to 5, and after setting it to 3, plus the typescript > > log of the commands issued and the sysfs readings. > > > > I then set brightness back to 0 (ec-after3.txt) -- didn't log the > > keyboard interactions because it's the same (value for brightness > > concurs with what is set, but actual_brightness is still -1) > > > > Let me know if you need anything else. Once we can at least pinpoint the > > problem to the right subsystem, I'll add these attachments to the > > correct bug report. > > > > Thanks, > > > And here's the last dump file, forgot to attach it earlier. > > Thanks, > >From d957b0a6ca265797cce4296dfc3cfda625dfd96f Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Wed, 18 May 2011 17:15:48 -0400 Subject: [PATCH 2/2] i915: Add GPU backlight interface Not all systems provide a firmware or platform interface to backlight control. We should expose a gpu-level backlight interface to handle that case. Signed-off-by: Matthew Garrett --- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/intel_display.c | 2 - drivers/gpu/drm/i915/intel_dp.c | 6 +++ drivers/gpu/drm/i915/intel_drv.h | 3 +- drivers/gpu/drm/i915/intel_lvds.c | 6 +++ drivers/gpu/drm/i915/intel_panel.c | 78 ++++++++++++++++++++++++++++++---- 6 files changed, 86 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 9b2b94a..68e8869 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -33,6 +33,7 @@ #include "i915_reg.h" #include "intel_bios.h" #include "intel_ringbuffer.h" +#include #include #include #include @@ -667,6 +668,7 @@ typedef struct drm_i915_private { int child_dev_num; struct child_device_config *child_dev; struct drm_connector *int_lvds_connector; + struct backlight_device *backlight; bool mchbar_need_disable; diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 03726a5..7ffb851 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6752,8 +6752,6 @@ static void intel_setup_outputs(struct drm_device *dev) intel_encoder_clones(dev, encoder->clone_mask); } - intel_panel_setup_backlight(dev); - /* disable all the possible outputs/crtcs before entering KMS mode */ drm_helper_disable_unused_functions(dev); } diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index a4d8031..c262378 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -1747,6 +1747,11 @@ done: static void intel_dp_destroy (struct drm_connector *connector) { + struct intel_dp *intel_dp = intel_attached_dp(connector); + + if (is_edp(intel_dp)) + intel_panel_destroy_backlight(connector); + drm_sysfs_connector_remove(connector); drm_connector_cleanup(connector); kfree(connector); @@ -1989,6 +1994,7 @@ intel_dp_init(struct drm_device *dev, int output_reg) DRM_MODE_TYPE_PREFERRED; } } + intel_panel_setup_backlight(connector); } intel_dp_add_properties(intel_dp, connector); diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 831d7a4..c2b5c11 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -265,7 +265,8 @@ extern void intel_pch_panel_fitting(struct drm_device *dev, extern u32 intel_panel_get_max_backlight(struct drm_device *dev); extern u32 intel_panel_get_backlight(struct drm_device *dev); extern void intel_panel_set_backlight(struct drm_device *dev, u32 level); -extern void intel_panel_setup_backlight(struct drm_device *dev); +extern int intel_panel_setup_backlight(struct drm_connector *dev); +extern void intel_panel_destroy_backlight(struct drm_connector *dev); extern void intel_panel_enable_backlight(struct drm_device *dev); extern void intel_panel_disable_backlight(struct drm_device *dev); extern enum drm_connector_status intel_panel_detect(struct drm_device *dev); diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index 3b90e68..38047b6 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c @@ -584,6 +584,9 @@ static void intel_lvds_destroy(struct drm_connector *connector) if (dev_priv->lid_notifier.notifier_call) acpi_lid_notifier_unregister(&dev_priv->lid_notifier); + + intel_panel_destroy_backlight(connector); + drm_sysfs_connector_remove(connector); drm_connector_cleanup(connector); kfree(connector); @@ -1033,6 +1036,9 @@ out: /* keep the LVDS connector */ dev_priv->int_lvds_connector = connector; drm_sysfs_connector_add(connector); + + intel_panel_setup_backlight(connector); + return true; failed: diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index f893ff0..1be17b5 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -250,6 +250,76 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level) I915_WRITE(BLC_PWM_CTL, tmp | level); } +#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE +static int intel_panel_update_brightness(struct backlight_device *bd) +{ + struct drm_device *dev = bl_get_data(bd); + + intel_panel_set_backlight(dev, bd->props.brightness); + return 0; +} + +static int intel_panel_get_brightness(struct backlight_device *bd) +{ + struct drm_device *dev = bl_get_data(bd); + + return intel_panel_get_backlight(dev); +} + +static const struct backlight_ops intel_panel_bl_ops = { + .update_status = intel_panel_update_brightness, + .get_brightness = intel_panel_get_brightness, +}; + +int intel_panel_setup_backlight(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + struct backlight_properties props; + + dev_priv->backlight_level = intel_panel_get_backlight(dev); + dev_priv->backlight_enabled = dev_priv->backlight_level != 0; + + props.max_brightness = intel_panel_get_max_backlight(dev); + props.type = BACKLIGHT_RAW; + dev_priv->backlight = backlight_device_register("intel_backlight", + &connector->kdev, dev, &intel_panel_bl_ops, &props); + + if (IS_ERR(dev_priv->backlight)) { + DRM_ERROR("Failed to register backlight: %ld\n", + PTR_ERR(dev_priv->backlight)); + dev_priv->backlight = NULL; + return -ENODEV; + } + + dev_priv->backlight->props.brightness = intel_panel_get_backlight(dev); + return 0; +} + +void intel_panel_destroy_backlight(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + + if (dev_priv->backlight) + backlight_device_unregister(dev_priv->backlight); +} +#else +int intel_panel_setup_backlight(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + + dev_priv->backlight_level = intel_panel_get_backlight(dev); + dev_priv->backlight_enabled = dev_priv->backlight_level != 0; +} + +void intel_panel_destroy_backlight(struct drm_connector *connector) +{ + return; +} +#endif + void intel_panel_disable_backlight(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -273,14 +343,6 @@ void intel_panel_enable_backlight(struct drm_device *dev) dev_priv->backlight_enabled = true; } -void intel_panel_setup_backlight(struct drm_device *dev) -{ - struct drm_i915_private *dev_priv = dev->dev_private; - - dev_priv->backlight_level = intel_panel_get_backlight(dev); - dev_priv->backlight_enabled = dev_priv->backlight_level != 0; -} - enum drm_connector_status intel_panel_detect(struct drm_device *dev) { -- 1.7.5