From patchwork Thu Aug 1 13:52:46 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: 11070715 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 307CD746 for ; Thu, 1 Aug 2019 13:53:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2307D2864F for ; Thu, 1 Aug 2019 13:53:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17D4328698; Thu, 1 Aug 2019 13:53:11 +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 9EB002864B for ; Thu, 1 Aug 2019 13:53:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 111116E611; Thu, 1 Aug 2019 13:53:08 +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 7D3EA6E610 for ; Thu, 1 Aug 2019 13:53:06 +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 1htBVw-0000ZK-J2; Thu, 01 Aug 2019 15:53:04 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/4] drm/mipi-dbi: Support command mode panel drivers Date: Thu, 1 Aug 2019 15:52:46 +0200 Message-Id: <20190801135249.28803-2-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=X7htPHlp6VRHKQ4vz7sSWmfuQnKNZh6hHNPQ/QygjhE=; b=EVbeiyTVt6+gPze6nkN0tnTG9PZd+H9nWk1QQFaOcokoCTOClG0IjnjSp/NBWv5jMfde26frH2tAX6H1Xa8fQPbLKLoCUlwokjSGJzJJ2UsHZMnZP8PiQql96dcRcbAmFbiFoICvnbEeWttIE5so9bEj+ZgumjfEDUD9qjQ6E243fOZcvFeJixBUjaCr9MyutiiEemzJPiz0GNTwNHB2YyHZgB6/xc8og9k4CWgb429xHXxgtyaGnhpfpTmh2A9vjJX3uD2hFLBy0gCpJGSIHUJpct4+u9Rtw9I+qL9OWygJkZwyGeccgyn3EnH+SaNZ8u9j+1DSmewB1+pbCHEaiA==; 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 This adds a function that registers a DRM driver for use with MIPI DBI panels in command mode. That is, framebuffer upload over DBI. Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/drm_mipi_dbi.c | 92 ++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dbi.h | 34 +++++++++++++ 2 files changed, 126 insertions(+) diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c index 1961f713aaab..797a20e3a017 100644 --- a/drivers/gpu/drm/drm_mipi_dbi.c +++ b/drivers/gpu/drm/drm_mipi_dbi.c @@ -17,11 +17,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -597,6 +599,96 @@ void mipi_dbi_release(struct drm_device *drm) } EXPORT_SYMBOL(mipi_dbi_release); +static void drm_mipi_dbi_panel_pipe_enable(struct drm_simple_display_pipe *pipe, + struct drm_crtc_state *crtc_state, + struct drm_plane_state *plane_state) +{ + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); + struct drm_panel *panel = dbidev->panel; + int ret, idx; + + if (!drm_dev_enter(pipe->crtc.dev, &idx)) + return; + + DRM_DEBUG_KMS("\n"); + + ret = drm_panel_prepare(panel); + if (ret) + goto out_exit; + + mipi_dbi_enable_flush(dbidev, crtc_state, plane_state); + + drm_panel_enable(panel); +out_exit: + drm_dev_exit(idx); +} + +static void drm_mipi_dbi_panel_pipe_disable(struct drm_simple_display_pipe *pipe) +{ + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); + struct drm_panel *panel = dbidev->panel; + + if (!dbidev->enabled) + return; + + DRM_DEBUG_KMS("\n"); + + dbidev->enabled = false; + drm_panel_disable(panel); + drm_panel_unprepare(panel); +} + +static const struct drm_simple_display_pipe_funcs drm_mipi_dbi_pipe_funcs = { + .enable = drm_mipi_dbi_panel_pipe_enable, + .disable = drm_mipi_dbi_panel_pipe_disable, + .update = mipi_dbi_pipe_update, + .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, +}; + +/** + * drm_mipi_dbi_panel_register - Register a MIPI DBI DRM driver + * @panel: DRM Panel + * @dbidev: MIPI DBI device structure to initialize + * @mode: Display mode + * + * This function registeres a DRM driver with @panel attached. + * + * Returns: + * Zero on success, negative error code on failure. + */ +int drm_mipi_dbi_panel_register(struct drm_panel *panel, struct mipi_dbi_dev *dbidev, + struct drm_driver *driver, const struct drm_display_mode *mode, + u32 rotation) +{ + struct device *dev = panel->dev; + struct drm_device *drm; + int ret; + + dbidev->panel = panel; + + drm = &dbidev->drm; + ret = devm_drm_dev_init(dev, drm, driver); + if (ret) { + kfree(dbidev); + return ret; + } + + drm_mode_config_init(drm); + + ret = mipi_dbi_dev_init(dbidev, &drm_mipi_dbi_pipe_funcs, mode, rotation); + + drm_mode_config_reset(drm); + + ret = drm_dev_register(drm, 0); + if (ret) + return ret; + + drm_fbdev_generic_setup(drm, 16); + + return 0; +} +EXPORT_SYMBOL(drm_mipi_dbi_panel_register); + /** * mipi_dbi_hw_reset - Hardware reset of controller * @dbi: MIPI DBI structure diff --git a/include/drm/drm_mipi_dbi.h b/include/drm/drm_mipi_dbi.h index 67c66f5ee591..f41ee0d31871 100644 --- a/include/drm/drm_mipi_dbi.h +++ b/include/drm/drm_mipi_dbi.h @@ -12,6 +12,7 @@ #include #include +struct drm_panel; struct drm_rect; struct spi_device; struct gpio_desc; @@ -123,6 +124,11 @@ struct mipi_dbi_dev { * @dbi: MIPI DBI interface */ struct mipi_dbi dbi; + + /** + * @panel: Attached DRM panel. See drm_mipi_dbi_panel_register(). + */ + struct drm_panel *panel; }; static inline struct mipi_dbi_dev *drm_to_mipi_dbi_dev(struct drm_device *drm) @@ -140,6 +146,34 @@ int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev, int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev, const struct drm_simple_display_pipe_funcs *funcs, const struct drm_display_mode *mode, unsigned int rotation); + +/** + * DEFINE_DRM_MIPI_DBI_PANEL_DRIVER - Define a DRM driver structure + * @_name: Name + * @_desc: Description + * @_date: Date + * + * This macro defines a &drm_driver for MIPI DBI panel drivers. + */ +#define DEFINE_DRM_MIPI_DBI_PANEL_DRIVER(_name, _desc, _date) \ + DEFINE_DRM_GEM_CMA_FOPS(_name ## _fops); \ + static struct drm_driver _name ## _drm_driver = { \ + .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, \ + .fops = & _name ## _fops, \ + .release = mipi_dbi_release, \ + DRM_GEM_CMA_VMAP_DRIVER_OPS, \ + .debugfs_init = mipi_dbi_debugfs_init, \ + .name = #_name, \ + .desc = _desc, \ + .date = _date, \ + .major = 1, \ + .minor = 0, \ + } + +int drm_mipi_dbi_panel_register(struct drm_panel *panel, struct mipi_dbi_dev *dbidev, + struct drm_driver *driver, const struct drm_display_mode *mode, + u32 rotation); + void mipi_dbi_release(struct drm_device *drm); void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *old_state); From patchwork Thu Aug 1 13:52:47 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: 11070717 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 C269C746 for ; Thu, 1 Aug 2019 13:53:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B282F285D6 for ; Thu, 1 Aug 2019 13:53:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5D162864F; Thu, 1 Aug 2019 13:53:13 +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 B8ED3285EE for ; Thu, 1 Aug 2019 13:53:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4DD16E610; Thu, 1 Aug 2019 13:53:09 +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 A3CBD6E610 for ; Thu, 1 Aug 2019 13:53:07 +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 1htBVx-0000ZK-Lg; Thu, 01 Aug 2019 15:53:05 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm/tiny/ili9341: Move driver to drm/panel Date: Thu, 1 Aug 2019 15:52:47 +0200 Message-Id: <20190801135249.28803-3-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=WqKqPCc2un4AFD9qwWq+K9xbeTBI0Vbkg0KcS0KlsKI=; b=DDHBpq7mKcSM/EVUwwZGv3bcLf2+yvA4AePuprBfxaIVFvpYz6D53HalgnAvfhY9xs+8S1ZZ1NnAQAeu1vT1okpUbizPGimTj69mEq9xPTAxxSKcDHcs0P9LN1bwt6umUQLIqSgY8fkxx/hqagMjKyqW82nVs2aHtlTJxPXfiGBNe/tTIxl/C6MFtiiGvzU9xl/FtmWONSmGMUlWUYaFlBJE7oNLfZbq37uJ9079XD1ZsPxpkUyw85B3Mf0XMx01jwSwB0OkKqpFq7o4W1mjnaWBfVA0uJoqzV+6yv1A1wn5b+gHXTrNFoPtVKfVJDBYRcj9udBpjZgjSPHz5kIB/w==; 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: David Lechner , 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 Move the driver to drm/panel and take advantage of the new panel support in drm_mipi_dbi. Change the file name to match the naming standard in drm/panel. The DRM driver name is kept since it is ABI. Add missing MAINTAINERS entry. Cc: David Lechner Signed-off-by: Noralf Trønnes Reviewed-by: David Lechner --- MAINTAINERS | 7 + drivers/gpu/drm/panel/Kconfig | 12 ++ drivers/gpu/drm/panel/Makefile | 1 + .../panel-ilitek-ili9341.c} | 174 ++++++++++-------- drivers/gpu/drm/tiny/Kconfig | 13 -- drivers/gpu/drm/tiny/Makefile | 1 - 6 files changed, 113 insertions(+), 95 deletions(-) rename drivers/gpu/drm/{tiny/ili9341.c => panel/panel-ilitek-ili9341.c} (66%) diff --git a/MAINTAINERS b/MAINTAINERS index 6fe3462a1f7a..66b3893a100f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5108,6 +5108,13 @@ S: Maintained F: drivers/gpu/drm/tiny/ili9225.c F: Documentation/devicetree/bindings/display/ilitek,ili9225.txt +DRM DRIVER FOR ILITEK ILI9341 PANELS +M: David Lechner +T: git git://anongit.freedesktop.org/drm/drm-misc +S: Maintained +F: drivers/gpu/drm/panel/panel-ilitek-ili9341.c +F: Documentation/devicetree/bindings/display/ilitek,ili9341.txt + DRM DRIVER FOR HX8357D PANELS M: Eric Anholt T: git git://anongit.freedesktop.org/drm/drm-misc diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index eaecd40cc32e..a24953ec2d40 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -56,6 +56,18 @@ config DRM_PANEL_ILITEK_IL9322 Say Y here if you want to enable support for Ilitek IL9322 QVGA (320x240) RGB, YUV and ITU-T BT.656 panels. +config DRM_PANEL_ILITEK_ILI9341 + tristate "Ilitek ILI9341 display panels" + depends on SPI + depends on BACKLIGHT_CLASS_DEVICE + select DRM_KMS_CMA_HELPER + select DRM_MIPI_DBI + help + DRM driver for the following Ilitek ILI9341 panels: + * YX240QV29-T 2.4" 240x320 TFT (Adafruit 2.4") + + If M is selected the module will be called panel-ilitek-ili9341. + config DRM_PANEL_ILITEK_ILI9881C tristate "Ilitek ILI9881C-based panels" depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index 62dae45f8f74..ba4a303c1a66 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += panel-feiyang-fy07024di26a30d.o obj-$(CONFIG_DRM_PANEL_ILITEK_IL9322) += panel-ilitek-ili9322.o +obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9341) += panel-ilitek-ili9341.o obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9881C) += panel-ilitek-ili9881c.o obj-$(CONFIG_DRM_PANEL_INNOLUX_P079ZCA) += panel-innolux-p079zca.o obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o diff --git a/drivers/gpu/drm/tiny/ili9341.c b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c similarity index 66% rename from drivers/gpu/drm/tiny/ili9341.c rename to drivers/gpu/drm/panel/panel-ilitek-ili9341.c index 33b51dc7faa8..f8df737018d3 100644 --- a/drivers/gpu/drm/tiny/ili9341.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c @@ -12,17 +12,17 @@ #include #include #include +#include #include #include +#include