From patchwork Wed Mar 30 20:04:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 8704671 Return-Path: X-Original-To: patchwork-linux-arm@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 A7D69C0554 for ; Wed, 30 Mar 2016 20:20:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B25532038D for ; Wed, 30 Mar 2016 20:20:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 398012038A for ; Wed, 30 Mar 2016 20:20:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1alMZz-0004kw-RF; Wed, 30 Mar 2016 20:19:03 +0000 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1alMNy-0006i8-R5; Wed, 30 Mar 2016 20:06:45 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 040E026D; Wed, 30 Mar 2016 22:06:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (LFbn-1-2159-240.w90-76.abo.wanadoo.fr [90.76.216.240]) by mail.free-electrons.com (Postfix) with ESMTPSA id 5244B187D; Wed, 30 Mar 2016 22:05:37 +0200 (CEST) From: Boris Brezillon To: Thierry Reding , linux-pwm@vger.kernel.org Subject: [PATCH v5 45/46] drm: i915: switch to the atomic PWM API Date: Wed, 30 Mar 2016 22:04:08 +0200 Message-Id: <1459368249-13241-46-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> References: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160330_130639_627989_3CF49640 X-CRM114-Status: GOOD ( 15.69 ) X-Spam-Score: -2.9 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Milo Kim , Kamil Debski , Heiko Stuebner , linux-doc@vger.kernel.org, David Airlie , Mike Turquette , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Alexandre Belloni , Daniel Vetter , Lee Jones , linux-clk@vger.kernel.org, linux-leds@vger.kernel.org, Boris Brezillon , Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, Alexander Shiyan , Jonathan Corbet , Robert Jarzmik , lm-sensors@lm-sensors.org, linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Tomi Valkeinen , linux-input@vger.kernel.org, Jean-Christophe Plagniol-Villard , intel-gfx@lists.freedesktop.org, Guenter Roeck , Jean Delvare , Joachim Eastwood , Bryan Wu , Jani Nikula , Mark Brown , Jacek Anaszewski , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Ryan Mallon , Jingoo Han , Dmitry Torokhov , Stephen Boyd , Liam Girdwood , Hartley Sweeten , Richard Purdie , Kukjin Kim , Daniel Vetter , Maxime Ripard MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP pwm_config/enable/disable() have been deprecated and should be replaced by pwm_apply_state(). Signed-off-by: Boris Brezillon --- drivers/gpu/drm/i915/intel_panel.c | 39 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index 21ee647..b86bd20 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -538,10 +538,10 @@ static u32 bxt_get_backlight(struct intel_connector *connector) static u32 pwm_get_backlight(struct intel_connector *connector) { struct intel_panel *panel = &connector->panel; - int duty_ns; + struct pwm_state pstate; - duty_ns = pwm_get_duty_cycle(panel->backlight.pwm); - return DIV_ROUND_UP(duty_ns * 100, CRC_PMIC_PWM_PERIOD_NS); + pwm_get_state(panel->backlight.pwm, &pstate); + return DIV_ROUND_UP(pstate.duty_cycle * 100, CRC_PMIC_PWM_PERIOD_NS); } static u32 intel_panel_get_backlight(struct intel_connector *connector) @@ -630,9 +630,12 @@ static void bxt_set_backlight(struct intel_connector *connector, u32 level) static void pwm_set_backlight(struct intel_connector *connector, u32 level) { struct intel_panel *panel = &connector->panel; - int duty_ns = DIV_ROUND_UP(level * CRC_PMIC_PWM_PERIOD_NS, 100); + struct pwm_state pstate; - pwm_config(panel->backlight.pwm, duty_ns, CRC_PMIC_PWM_PERIOD_NS); + pwm_get_state(panel->backlight.pwm, &pstate); + pstate.duty_cycle = DIV_ROUND_UP(level * CRC_PMIC_PWM_PERIOD_NS, 100); + pstate.period = CRC_PMIC_PWM_PERIOD_NS; + pwm_apply_state(panel->backlight.pwm, &pstate); } static void @@ -801,11 +804,15 @@ static void bxt_disable_backlight(struct intel_connector *connector) static void pwm_disable_backlight(struct intel_connector *connector) { struct intel_panel *panel = &connector->panel; + struct pwm_state pstate; /* Disable the backlight */ - pwm_config(panel->backlight.pwm, 0, CRC_PMIC_PWM_PERIOD_NS); + pwm_get_state(panel->backlight.pwm, &pstate); + pstate.duty_cycle = 0; + pwm_apply_state(panel->backlight.pwm, &pstate); usleep_range(2000, 3000); - pwm_disable(panel->backlight.pwm); + pstate.enabled = false; + pwm_apply_state(panel->backlight.pwm, &pstate); } void intel_panel_disable_backlight(struct intel_connector *connector) @@ -1068,8 +1075,11 @@ static void bxt_enable_backlight(struct intel_connector *connector) static void pwm_enable_backlight(struct intel_connector *connector) { struct intel_panel *panel = &connector->panel; + struct pwm_state pstate; - pwm_enable(panel->backlight.pwm); + pwm_get_state(panel->backlight.pwm, &pstate); + pstate.enabled = true; + pwm_apply_state(panel->backlight.pwm, &pstate); intel_panel_actually_set_backlight(connector, panel->backlight.level); } @@ -1630,6 +1640,7 @@ static int pwm_setup_backlight(struct intel_connector *connector, { struct drm_device *dev = connector->base.dev; struct intel_panel *panel = &connector->panel; + struct pwm_state pstate; int retval; /* Get the PWM chip for backlight control */ @@ -1640,8 +1651,10 @@ static int pwm_setup_backlight(struct intel_connector *connector, return -ENODEV; } - retval = pwm_config(panel->backlight.pwm, CRC_PMIC_PWM_PERIOD_NS, - CRC_PMIC_PWM_PERIOD_NS); + pwm_get_state(panel->backlight.pwm, &pstate); + pstate.period = CRC_PMIC_PWM_PERIOD_NS; + pstate.duty_cycle = CRC_PMIC_PWM_PERIOD_NS; + retval = pwm_apply_state(panel->backlight.pwm, &pstate); if (retval < 0) { DRM_ERROR("Failed to configure the pwm chip\n"); pwm_put(panel->backlight.pwm); @@ -1651,9 +1664,9 @@ static int pwm_setup_backlight(struct intel_connector *connector, panel->backlight.min = 0; /* 0% */ panel->backlight.max = 100; /* 100% */ - panel->backlight.level = DIV_ROUND_UP( - pwm_get_duty_cycle(panel->backlight.pwm) * 100, - CRC_PMIC_PWM_PERIOD_NS); + pwm_get_state(panel->backlight.pwm, &pstate); + panel->backlight.level = DIV_ROUND_UP(pstate.duty_cycle * 100, + pstate.period); panel->backlight.enabled = panel->backlight.level != 0; return 0;