From patchwork Mon Aug 17 07:56:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenyu Wang X-Patchwork-Id: 41945 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7H7usq3008440 for ; Mon, 17 Aug 2009 07:56:54 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E02569EDC6; Mon, 17 Aug 2009 00:56:53 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fmsmga101.fm.intel.com (mga05.intel.com [192.55.52.89]) by gabe.freedesktop.org (Postfix) with ESMTP id 327059EDC6 for ; Mon, 17 Aug 2009 00:56:51 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 17 Aug 2009 00:54:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.43,394,1246863600"; d="asc'?scan'208";a="484098016" Received: from zhen-devel.sh.intel.com (HELO zhen-devel) ([10.239.13.48]) by fmsmga002.fm.intel.com with ESMTP; 17 Aug 2009 00:49:36 -0700 Date: Mon, 17 Aug 2009 15:56:50 +0800 From: Zhenyu Wang To: Matthias Hopf Message-ID: <20090817075650.GA8024@zhen-devel.sh.intel.com> Mail-Followup-To: Matthias Hopf , intel-gfx@lists.freedesktop.org References: <20090814175405.GA31971@suse.de> MIME-Version: 1.0 In-Reply-To: <20090814175405.GA31971@suse.de> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: intel-gfx@lists.freedesktop.org Subject: Re: [Intel-gfx] Legacy backlight control with KMS and BACKLIGHT property X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: Zhenyu Wang List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org On 2009.08.14 19:54:05 +0200, Matthias Hopf wrote: > What we're supposing is > > - a kernel driver for the /sys/class/backlight/ api for the legacy method yeah, I think /sys/class/backlight/ should be the only backlight interface for any user space apps or X RandR property creation. So we need to add backlight device inside i915 KMS driver, when !acpi_video_backlight_support(). Current KMS driver like LVDS only do PWM operation, maybe combo will be better if it's supposed to be, Jesse? > - support in the driver to actually open this one (trivial) yeah. > - support for the BACKLIGHT property in KMS case, *only* using the > kernel api method for now (will need some abstraction) Current x-v-i driver in KMS could setup any property for all connectors, like attached testing patch which will hook the property up. But if we just go with opening /sys/class/backlight/ in xorg driver, we simply don't need it... So for X BACKLIGHT property creation, we'll have a checklist for acpi_video, platform_driver, and new backlight device maybe like 'intel_lvds'. diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index 3f445a8..e1affea 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c @@ -53,6 +53,7 @@ struct intel_lvds_priv { int fitting_mode; u32 pfit_control; u32 pfit_pgm_ratios; + struct drm_property *backlight; }; /** @@ -75,6 +76,20 @@ static void intel_lvds_set_backlight(struct drm_device *dev, int level) (level << BACKLIGHT_DUTY_CYCLE_SHIFT))); } +static u32 intel_lvds_get_backlight(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + u32 blc_pwm_ctl, reg; + + if (IS_IGDNG(dev)) + reg = BLC_PWM_CPU_CTL; + else + reg = BLC_PWM_CTL; + + blc_pwm_ctl = I915_READ(reg) & BACKLIGHT_DUTY_CYCLE_MASK; + return blc_pwm_ctl; +} + /** * Returns the maximum level of the backlight duty cycle field. */ @@ -667,6 +682,7 @@ static int intel_lvds_set_property(struct drm_connector *connector, struct drm_device *dev = connector->dev; struct intel_output *intel_output = to_intel_output(connector); + struct intel_lvds_priv *lvds_priv = intel_output->dev_priv; if (property == dev->mode_config.scaling_mode_property && connector->encoder) { @@ -690,6 +706,8 @@ static int intel_lvds_set_property(struct drm_connector *connector, drm_crtc_helper_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, crtc->fb); } + } else if (property == lvds_priv->backlight) { + intel_lvds_set_backlight(dev, value); } return 0; @@ -1009,7 +1028,17 @@ void intel_lvds_init(struct drm_device *dev) if (!dev_priv->panel_fixed_mode) goto failed; + out: + /* backlight property */ + lvds_priv->backlight = drm_property_create(dev, DRM_MODE_PROP_RANGE, + "BACKLIGHT", 2); + lvds_priv->backlight->values[0] = 0; + lvds_priv->backlight->values[1] = intel_lvds_get_max_backlight(dev); + drm_connector_attach_property(&intel_output->base, + lvds_priv->backlight, + (uint64_t)intel_lvds_get_backlight(dev)); + if (IS_IGDNG(dev)) { u32 pwm; /* make sure PWM is enabled */