From patchwork Thu Aug 1 13:52:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 11070721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 326A113AC for ; Thu, 1 Aug 2019 13:53:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2306628689 for ; Thu, 1 Aug 2019 13:53:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17B6C28606; Thu, 1 Aug 2019 13:53:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A74E0285BD for ; Thu, 1 Aug 2019 13:53:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4452F6E618; Thu, 1 Aug 2019 13:53:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 81DB56E618 for ; Thu, 1 Aug 2019 13:53:08 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:56446 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1htBVy-0000ZK-JU; Thu, 01 Aug 2019 15:53:06 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/panel/ili9341: Support DPI panels Date: Thu, 1 Aug 2019 15:52:49 +0200 Message-Id: <20190801135249.28803-5-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190801135249.28803-1-noralf@tronnes.org> References: <20190801135249.28803-1-noralf@tronnes.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org; s=ds201810; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=gmNv3MGp0f0mCb3B+cZpPezOqz8w6ZQEmrcOgN1/3Xg=; b=t9XHvfu/KvBSM98t8fE3zi3QiNFi65RgNiIDw3LsbCP0wv5R9wrZVTh6HzDgfE8h6lsCRDRo+fHgPgk+r9b1W/3N7YAvXN8vDlFs1BwpuCfjmxVGAgQjzpJrhVCJrpx4Vt3Za4F15VtAXdtdqlvI8XQ4qtANmg2zfVcLNXadCgskIh8ILjMi4CcC0u2+1j3sSsQEQPQOJl8B2Ke4CcLFqmJE5eDrqTFuyznPFao9DaHeRAPj37B8UdZ1WVJ4pCbw99AjXcBHgwXoY9M0OGVFNb0oIFY5QmjdIpQCD6TAVWhgWoQhhQdNKD/1WtFEBM0qjO/UFxY7jXXYNylBT0j+2Q==; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, emil.l.velikov@gmail.com, josef@lusticky.cz, thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com, sam@ravnborg.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for panels that use the DPI interface. ILI9341 has onboard RAM so the assumption made here is that all such panels support pixel upload over DBI. The presence/absense of the Device Tree 'port' node decides which interface is used for pixel transfer. Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 56 ++++++++++++++++---- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c index f6082fa2a389..7cbfd739c7fd 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -53,11 +54,13 @@ struct ili9341_config { const struct drm_panel_funcs *funcs; const struct drm_display_mode *mode; + bool no_dpi; }; struct ili9341 { struct mipi_dbi_dev dbidev; /* This must be the first entry */ struct drm_panel panel; + bool use_dpi; struct regulator *regulator; struct backlight_device *backlight; const struct ili9341_config *conf; @@ -174,6 +177,7 @@ static const struct drm_display_mode yx240qv29_mode = { static const struct ili9341_config yx240qv29_data = { .funcs = &yx240qv29_funcs, .mode = &yx240qv29_mode, + .no_dpi = true, }; static int mi0283qt_prepare(struct drm_panel *panel) @@ -291,6 +295,7 @@ static const struct drm_display_mode mi0283qt_mode = { static const struct ili9341_config mi0283qt_data = { .funcs = &mi0283qt_drm_funcs, .mode = &mi0283qt_mode, + .no_dpi = true, }; /* Legacy, DRM driver name is ABI */ @@ -303,6 +308,7 @@ static int ili9341_probe(struct spi_device *spi) const struct spi_device_id *spi_id; struct device *dev = &spi->dev; struct drm_driver *driver; + struct device_node *port; struct mipi_dbi *dbi; struct gpio_desc *dc; struct ili9341 *ili; @@ -357,21 +363,44 @@ static int ili9341_probe(struct spi_device *spi) ili->panel.dev = dev; ili->panel.funcs = ili->conf->funcs; - if (ili->conf == &mi0283qt_data) - driver = &mi0283qt_drm_driver; - else - driver = &ili9341_drm_driver; - return drm_mipi_dbi_panel_register(&ili->panel, &ili->dbidev, driver, - ili->conf->mode, rotation); + port = of_get_child_by_name(dev->of_node, "port"); + if (port) { + of_node_put(port); + ili->use_dpi = true; + } + + if (ili->conf->no_dpi) + ili->use_dpi = false; + + if (ili->use_dpi) { + ret = drm_panel_add(&ili->panel); + } else { + if (ili->conf == &mi0283qt_data) + driver = &mi0283qt_drm_driver; + else + driver = &ili9341_drm_driver; + + ret = drm_mipi_dbi_panel_register(&ili->panel, &ili->dbidev, driver, + ili->conf->mode, rotation); + } + + return ret; } static int ili9341_remove(struct spi_device *spi) { struct ili9341 *ili = spi_get_drvdata(spi); - drm_dev_unplug(&ili->dbidev.drm); - drm_atomic_helper_shutdown(&ili->dbidev.drm); + if (ili->use_dpi) { + drm_panel_remove(&ili->panel); + drm_panel_disable(&ili->panel); + drm_panel_unprepare(&ili->panel); + kfree(ili); + } else { + drm_dev_unplug(&ili->dbidev.drm); + drm_atomic_helper_shutdown(&ili->dbidev.drm); + } return 0; } @@ -380,21 +409,26 @@ static void ili9341_shutdown(struct spi_device *spi) { struct ili9341 *ili = spi_get_drvdata(spi); - drm_atomic_helper_shutdown(&ili->dbidev.drm); + if (!ili->use_dpi) + drm_atomic_helper_shutdown(&ili->dbidev.drm); } static int __maybe_unused ili9341_pm_suspend(struct device *dev) { struct ili9341 *ili = dev_get_drvdata(dev); - return drm_mode_config_helper_suspend(&ili->dbidev.drm); + if (!ili->use_dpi) + return drm_mode_config_helper_suspend(&ili->dbidev.drm); + + return 0; } static int __maybe_unused ili9341_pm_resume(struct device *dev) { struct ili9341 *ili = dev_get_drvdata(dev); - drm_mode_config_helper_resume(&ili->dbidev.drm); + if (!ili->use_dpi) + drm_mode_config_helper_resume(&ili->dbidev.drm); return 0; }