From patchwork Thu Nov 19 10:29:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 7656231 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 51F9FBF90C for ; Thu, 19 Nov 2015 10:25:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 738092054D for ; Thu, 19 Nov 2015 10:25:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 900B520462 for ; Thu, 19 Nov 2015 10:25:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3DFC6E904; Thu, 19 Nov 2015 02:25:38 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id D81E26E905 for ; Thu, 19 Nov 2015 02:25:37 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 19 Nov 2015 02:25:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,317,1444719600"; d="scan'208";a="854686953" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.67]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2015 02:25:35 -0800 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Thu, 19 Nov 2015 12:29:36 +0200 Message-Id: <1447928976-4922-2-git-send-email-jani.nikula@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447928976-4922-1-git-send-email-jani.nikula@intel.com> References: <1447928976-4922-1-git-send-email-jani.nikula@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: jani.nikula@intel.com Subject: [Intel-gfx] [RFC PATCH 2/2] drm/i915: make intel_backlight sysfs interface have range 0..100 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-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Historically we have exposed the full backlight PWM duty cycle range from 0 to the PWM modulation frequency as the backlight range to the userspace. Since then, we have had to scale that to respect panel specific minimum duty cycles. Go for fully abstracting the PWM duty cycles and modulation frequencies from the userspace by exposing a fixed range 0..100 in the intel_backlight sysfs interface. In the code, this makes it more obvious that the sysfs max and the modulation frequency are not the same. It is more clear that we could change the modulation frequency on the fly (for example to increase frequency to reduce flickering), while we can't change the sysfs max on the fly. There are a few reasons for picking the fixed range 0..100. First, it's the range defined for Windows drivers in the Windows Hardware Compatibility Program Requirements. There is no reason to differ from that with some NIH agenda, especially when said requirements also tend to guide the choices made in hardware. Second, it's hard to produce more than that many user distinguishable brightness levels using PWM anyway. What is the point of supporting, say, 4882 brightness levels (the value on the laptop I'm writing this on) when you can't tell them apart? Also, we currently (and after this change too) expose a linear scale to the backlight PWM duty cycle. That is usually not the same as a linear scale of backlight luminance. It may be desirable to expose an API to allow the userspace to adjust that to a non-linear curve to reach a linear backlight luminance. It will be easier to do that with a fixed range. This change might cause bug reports due to assumptions that the scale never changes on a machine. However, the ABI is that the brightness is between 0..max_brightness. Not that the range cast in stone. Cc: Chris Wilson Cc: Clint Taylor Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/intel_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index 7ab63486adce..c155777bd142 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -1212,7 +1212,7 @@ static int intel_backlight_device_register(struct intel_connector *connector) * Note: Everything should work even if the backlight device max * presented to the userspace is arbitrarily chosen. */ - props.max_brightness = panel->backlight.max; + props.max_brightness = 100; props.brightness = scale_hw_to_user(connector, panel->backlight.level, props.max_brightness);