From patchwork Mon Dec 2 19:32:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Ravnborg X-Patchwork-Id: 11269531 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D27B11593 for ; Mon, 2 Dec 2019 19:33:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A66CF217F9 for ; Mon, 2 Dec 2019 19:33:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EgYXvkPF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728107AbfLBTdM (ORCPT ); Mon, 2 Dec 2019 14:33:12 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40904 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728031AbfLBTdM (ORCPT ); Mon, 2 Dec 2019 14:33:12 -0500 Received: by mail-lf1-f68.google.com with SMTP id y5so777554lfy.7; Mon, 02 Dec 2019 11:33:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V7Sk0vtzr45wZ8IS1NkDSiSilaqDlsnOxAQYOrMwYkQ=; b=EgYXvkPFPix9mbJArMrY8NeAkHpQ9d4jaCKh0z+eSI2RmTfxI6tH0nxQoT6w+sfmnc fEtWvBZZpb/e0PdKql1qA648r08sAQTI7p2ddc2eh7wyiuAkat9URK0IBltoqyZR1HrI 2KYqXQ6I4wfNDDRDfRQx1XAA9+rZyRAOBAcGnrcvpdMy1FIKVzTaq3NQs0tQtVOBd13a AlUvXyOntqtmiTqGA/9lTfjOA9eBIqXjLki2aaZnLSK0VMZiXajnqwTmh8DW9W2HgIMK O9MnTorcTW8e095CaKaVXszFUwz1gLMc2cA+nfXuOn523h4SJyoz4OjTmZcynePZ5Cmv +OyQ== 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:mime-version:content-transfer-encoding; bh=V7Sk0vtzr45wZ8IS1NkDSiSilaqDlsnOxAQYOrMwYkQ=; b=ZV9EkMAJONiFENCgp5fbHcmKm17QfhrwFi0v9qDyUEzJ93g6ukf+ijoy2c+cSJ1IaF 3qXczWtPLUrDIvqzCdIY8Vh65unfAOuQQgdg3CUvax4rB+M9y2BkBoHbFE9BL5GVWiQw lbmQfiX9sZUvtHnyHMTGivLezo0pjvYL0f9jHCQYQt5A1+MjFNuJrRc66RXZ3idI+Jpd I7Bg24zp5PyFOsh+s6Lo13GENg0HL0qap4tmIl0R+M0nLtmO4wxnhZadRaji0eOxx/NR UZCDEmEiput/GgiHiMvMtiZwKwZ0941ZFgWBw5CW8Hki/yGVOvz6zYZvVbSha8ud5Kyv WPwQ== X-Gm-Message-State: APjAAAW3HEGh32b1d31Sl74rixqO/wAg85JaZuNW1D11tYdI0pnfkD/3 /G507Fdw7RMv0LFBJLM48zI= X-Google-Smtp-Source: APXvYqyFg/v6//X8iyL25Oa8adNguLHzFky+6g9PTX8HCXsO+nj0VFmTRx6UWZsUGh8DbeL+sZm8kg== X-Received: by 2002:ac2:5388:: with SMTP id g8mr410915lfh.43.1575315189008; Mon, 02 Dec 2019 11:33:09 -0800 (PST) Received: from saturn.lan (18.158-248-194.customer.lyse.net. [158.248.194.18]) by smtp.gmail.com with ESMTPSA id g13sm79482lfb.74.2019.12.02.11.33.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 11:33:08 -0800 (PST) From: Sam Ravnborg To: dri-devel@lists.freedesktop.org, Thierry Reding , Laurent Pinchart Cc: Abhinav Kumar , Andrzej Hajda , Benjamin Gaignard , Boris Brezillon , Daniel Vetter , David Airlie , Jagan Teki , Jitao Shi , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, Maarten Lankhorst , Maxime Ripard , Neil Armstrong , NXP Linux Team , Pengutronix Kernel Team , Purism Kernel Team , Sean Paul , Stefan Agner , Tomi Valkeinen , Sam Ravnborg Subject: [PATCH v1 03/26] drm/panel: simple: use drm_panel backlight support Date: Mon, 2 Dec 2019 20:32:07 +0100 Message-Id: <20191202193230.21310-4-sam@ravnborg.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191202193230.21310-1-sam@ravnborg.org> References: <20191202193230.21310-1-sam@ravnborg.org> MIME-Version: 1.0 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Use drm_panel infrastructure for backlight. Replace direct calls with drm_panel_*() calls to utilize the drm_panel support. Signed-off-by: Sam Ravnborg cc: Laurent Pinchart Cc: Thierry Reding Cc: Sam Ravnborg Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/panel/panel-simple.c | 50 ++++++---------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 72f69709f349..a5df6d6dd455 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -21,7 +21,6 @@ * DEALINGS IN THE SOFTWARE. */ -#include #include #include #include @@ -105,7 +104,6 @@ struct panel_simple { const struct panel_desc *desc; - struct backlight_device *backlight; struct regulator *supply; struct i2c_adapter *ddc; @@ -236,12 +234,6 @@ static int panel_simple_disable(struct drm_panel *panel) if (!p->enabled) return 0; - if (p->backlight) { - p->backlight->props.power = FB_BLANK_POWERDOWN; - p->backlight->props.state |= BL_CORE_FBBLANK; - backlight_update_status(p->backlight); - } - if (p->desc->delay.disable) msleep(p->desc->delay.disable); @@ -307,12 +299,6 @@ static int panel_simple_enable(struct drm_panel *panel) if (p->desc->delay.enable) msleep(p->desc->delay.enable); - if (p->backlight) { - p->backlight->props.state &= ~BL_CORE_FBBLANK; - p->backlight->props.power = FB_BLANK_UNBLANK; - backlight_update_status(p->backlight); - } - p->enabled = true; return 0; @@ -414,9 +400,9 @@ static void panel_simple_parse_panel_timing_node(struct device *dev, static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) { - struct device_node *backlight, *ddc; struct panel_simple *panel; struct display_timing dt; + struct device_node *ddc; int err; panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); @@ -442,24 +428,13 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) return err; } - backlight = of_parse_phandle(dev->of_node, "backlight", 0); - if (backlight) { - panel->backlight = of_find_backlight_by_node(backlight); - of_node_put(backlight); - - if (!panel->backlight) - return -EPROBE_DEFER; - } - ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0); if (ddc) { panel->ddc = of_find_i2c_adapter_by_node(ddc); of_node_put(ddc); - if (!panel->ddc) { - err = -EPROBE_DEFER; - goto free_backlight; - } + if (!panel->ddc) + return -EPROBE_DEFER; } if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) @@ -468,6 +443,10 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) drm_panel_init(&panel->base, dev, &panel_simple_funcs, desc->connector_type); + err = drm_panel_of_backlight(&panel->base); + if (err) + goto free_ddc; + err = drm_panel_add(&panel->base); if (err < 0) goto free_ddc; @@ -479,9 +458,6 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) free_ddc: if (panel->ddc) put_device(&panel->ddc->dev); -free_backlight: - if (panel->backlight) - put_device(&panel->backlight->dev); return err; } @@ -491,16 +467,12 @@ static int panel_simple_remove(struct device *dev) struct panel_simple *panel = dev_get_drvdata(dev); drm_panel_remove(&panel->base); - - panel_simple_disable(&panel->base); - panel_simple_unprepare(&panel->base); + drm_panel_disable(&panel->base); + drm_panel_unprepare(&panel->base); if (panel->ddc) put_device(&panel->ddc->dev); - if (panel->backlight) - put_device(&panel->backlight->dev); - return 0; } @@ -508,8 +480,8 @@ static void panel_simple_shutdown(struct device *dev) { struct panel_simple *panel = dev_get_drvdata(dev); - panel_simple_disable(&panel->base); - panel_simple_unprepare(&panel->base); + drm_panel_disable(&panel->base); + drm_panel_unprepare(&panel->base); } static const struct drm_display_mode ampire_am_480272h3tmqw_t01h_mode = {