From patchwork Mon Jul 22 10:43:04 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: 11052123 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 0EB52112C for ; Mon, 22 Jul 2019 10:43:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F057428500 for ; Mon, 22 Jul 2019 10:43:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E43CA2851B; Mon, 22 Jul 2019 10:43:29 +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 5433A28500 for ; Mon, 22 Jul 2019 10:43:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F0FA78979F; Mon, 22 Jul 2019 10:43:26 +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 918EA89A61 for ; Mon, 22 Jul 2019 10:43:25 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:55388 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 1hpVmt-0001lD-Nd; Mon, 22 Jul 2019 12:43:23 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/9] drm/tinydrm/mipi-dbi: Move cmdlock mutex init Date: Mon, 22 Jul 2019 12:43:04 +0200 Message-Id: <20190722104312.16184-2-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722104312.16184-1-noralf@tronnes.org> References: <20190722104312.16184-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=1UIi3LFAJ0z87Iki0W3LMC7oy/x16zToVygXpno5g/w=; b=LpJQRr88BCCm1AghEbtecK9Ru/SwlLKk9fyljJ8rKApsrSyMu5dND6OHOAyKumZjWP1J0YQ1Bg0YIK4iX/YL+zaDAY1SKk8JmbcX9qsNyRFVU0vfZtkDIPqs7/vzdZFmozXKkEuEmVE4Dg8EMFozxVo0oHyRU3OEJlTlLj/6kR9KzWqEp6pfqElXeuMinig0/J6x9hKnkaAUfZgTqDlIwnkQkBy0UsYgS7u97l81tv69Ssdr3H3oqRwCpFkDCCPcLhKydX2fAgJ576WLfSzsL76xosXAbDvCPFjT9n/hb/9c+GZHW3qhji+/ysClP9aV8sQNHRDyGmzH0AFhRznayQ==; 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: sam@ravnborg.org, david@lechnology.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP cmdlock protects command execution so put it in mipi_dbi_spi_init() where it conceptually belongs. This is prep work for the splitting of struct mipi_dbi. Reviewed-by: Sam Ravnborg Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/tinydrm/mipi-dbi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index 42465228129c..37a73b4c0f85 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -506,8 +506,6 @@ int mipi_dbi_init_with_formats(struct mipi_dbi *mipi, if (!mipi->command) return -EINVAL; - mutex_init(&mipi->cmdlock); - mipi->tx_buf = devm_kmalloc(drm->dev, tx_buf_size, GFP_KERNEL); if (!mipi->tx_buf) return -ENOMEM; @@ -1120,6 +1118,8 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi, return -ENOMEM; } + mutex_init(&mipi->cmdlock); + DRM_DEBUG_DRIVER("SPI speed: %uMHz\n", spi->max_speed_hz / 1000000); return 0; From patchwork Mon Jul 22 10:43:05 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: 11052133 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 528E4138D for ; Mon, 22 Jul 2019 10:43:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C55D28500 for ; Mon, 22 Jul 2019 10:43:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3080F28514; Mon, 22 Jul 2019 10:43:42 +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 BB9B928524 for ; Mon, 22 Jul 2019 10:43:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61BAB89BF6; Mon, 22 Jul 2019 10:43:29 +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 575FC8979F for ; Mon, 22 Jul 2019 10:43:26 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:55388 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 1hpVmu-0001lD-BZ; Mon, 22 Jul 2019 12:43:24 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/9] drm/tinydrm: Rename variable mipi -> dbi Date: Mon, 22 Jul 2019 12:43:05 +0200 Message-Id: <20190722104312.16184-3-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722104312.16184-1-noralf@tronnes.org> References: <20190722104312.16184-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=Fz1NOC9fgIlQfiebTJ4UWRAG1viyVc5VtNPDcIh1kCE=; b=fxvcPXxTkeHdke6gYkCv3vQ1SNDmulb26ti/LSVw9TzRIY6v/EhkYPiLAHx48gK5dJ6+hAcWgc+7fShs7bzLo69jhXeEyGKiArT3gKz+R/eYmckHBzCcAG6MskpIgIuoqZJVOtoycRq5ykmHLNI2w1aMOxtZ9OFG2ezomtJzSJHB/rcfgKrlSg03z4k1B9gJk3mA6yHLMG78eMJa4XaCU8XyPnhjmvNbCI3Uu4ZMyJIwA4wuExHNhVDj8dIJ1ZA1GtmnQibzG4SR8NmbXtWo99uzMPf80Qu5weEjXeZ1O3vadO3XaM5ZbnVntFXs69t6oL7MHbjpmKv0Qw9N33oF6w==; 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: sam@ravnborg.org, david@lechnology.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP struct mipi_dbi is going to be split into an interface part and a display pipeline part. The interface part can be used by drivers that need to initialize the controller, but that won't upload the framebuffer over this interface. tinydrm uses the variable name 'mipi' but this is not a good name since MIPI refers to a lot of standards. This patch changes the variable name to 'dbi' where it refers to the interface part of struct mipi_dbi. Functions that use both future parts will have both variables temporarily pointing to the same structure. Cc: Eric Anholt Cc: David Lechner Reviewed-by: Sam Ravnborg Signed-off-by: Noralf Trønnes Acked-by: David Lechner --- drivers/gpu/drm/tinydrm/hx8357d.c | 31 +++--- drivers/gpu/drm/tinydrm/ili9225.c | 135 +++++++++++++------------ drivers/gpu/drm/tinydrm/ili9341.c | 55 ++++++----- drivers/gpu/drm/tinydrm/mi0283qt.c | 55 ++++++----- drivers/gpu/drm/tinydrm/mipi-dbi.c | 153 +++++++++++++++-------------- drivers/gpu/drm/tinydrm/st7586.c | 62 ++++++------ drivers/gpu/drm/tinydrm/st7735r.c | 49 ++++----- include/drm/tinydrm/mipi-dbi.h | 20 ++-- 8 files changed, 291 insertions(+), 269 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c b/drivers/gpu/drm/tinydrm/hx8357d.c index 7d2dfa92b661..f503d14aa36b 100644 --- a/drivers/gpu/drm/tinydrm/hx8357d.c +++ b/drivers/gpu/drm/tinydrm/hx8357d.c @@ -48,6 +48,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, struct drm_plane_state *plane_state) { struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = mipi; u8 addr_mode; int ret, idx; @@ -63,22 +64,22 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, goto out_enable; /* setextc */ - mipi_dbi_command(mipi, HX8357D_SETEXTC, 0xFF, 0x83, 0x57); + mipi_dbi_command(dbi, HX8357D_SETEXTC, 0xFF, 0x83, 0x57); msleep(150); /* setRGB which also enables SDO */ - mipi_dbi_command(mipi, HX8357D_SETRGB, 0x00, 0x00, 0x06, 0x06); + mipi_dbi_command(dbi, HX8357D_SETRGB, 0x00, 0x00, 0x06, 0x06); /* -1.52V */ - mipi_dbi_command(mipi, HX8357D_SETCOM, 0x25); + mipi_dbi_command(dbi, HX8357D_SETCOM, 0x25); /* Normal mode 70Hz, Idle mode 55 Hz */ - mipi_dbi_command(mipi, HX8357D_SETOSC, 0x68); + mipi_dbi_command(dbi, HX8357D_SETOSC, 0x68); /* Set Panel - BGR, Gate direction swapped */ - mipi_dbi_command(mipi, HX8357D_SETPANEL, 0x05); + mipi_dbi_command(dbi, HX8357D_SETPANEL, 0x05); - mipi_dbi_command(mipi, HX8357D_SETPOWER, + mipi_dbi_command(dbi, HX8357D_SETPOWER, 0x00, /* Not deep standby */ 0x15, /* BT */ 0x1C, /* VSPR */ @@ -86,7 +87,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, 0x83, /* AP */ 0xAA); /* FS */ - mipi_dbi_command(mipi, HX8357D_SETSTBA, + mipi_dbi_command(dbi, HX8357D_SETSTBA, 0x50, /* OPON normal */ 0x50, /* OPON idle */ 0x01, /* STBA */ @@ -94,7 +95,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, 0x1E, /* STBA */ 0x08); /* GEN */ - mipi_dbi_command(mipi, HX8357D_SETCYC, + mipi_dbi_command(dbi, HX8357D_SETCYC, 0x02, /* NW 0x02 */ 0x40, /* RTN */ 0x00, /* DIV */ @@ -103,7 +104,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, 0x0D, /* GDON */ 0x78); /* GDOFF */ - mipi_dbi_command(mipi, HX8357D_SETGAMMA, + mipi_dbi_command(dbi, HX8357D_SETGAMMA, 0x02, 0x0A, 0x11, @@ -140,21 +141,21 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, 0x01); /* 16 bit */ - mipi_dbi_command(mipi, MIPI_DCS_SET_PIXEL_FORMAT, + mipi_dbi_command(dbi, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT); /* TE off */ - mipi_dbi_command(mipi, MIPI_DCS_SET_TEAR_ON, 0x00); + mipi_dbi_command(dbi, MIPI_DCS_SET_TEAR_ON, 0x00); /* tear line */ - mipi_dbi_command(mipi, MIPI_DCS_SET_TEAR_SCANLINE, 0x00, 0x02); + mipi_dbi_command(dbi, MIPI_DCS_SET_TEAR_SCANLINE, 0x00, 0x02); /* Exit Sleep */ - mipi_dbi_command(mipi, MIPI_DCS_EXIT_SLEEP_MODE); + mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); msleep(150); /* display on */ - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON); + mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); usleep_range(5000, 7000); out_enable: @@ -172,7 +173,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, addr_mode = HX8357D_MADCTL_MV | HX8357D_MADCTL_MX; break; } - mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); + mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); mipi_dbi_enable_flush(mipi, crtc_state, plane_state); out_exit: drm_dev_exit(idx); diff --git a/drivers/gpu/drm/tinydrm/ili9225.c b/drivers/gpu/drm/tinydrm/ili9225.c index 62f29b2faf74..c837d1423362 100644 --- a/drivers/gpu/drm/tinydrm/ili9225.c +++ b/drivers/gpu/drm/tinydrm/ili9225.c @@ -68,11 +68,11 @@ #define ILI9225_GAMMA_CONTROL_9 0x58 #define ILI9225_GAMMA_CONTROL_10 0x59 -static inline int ili9225_command(struct mipi_dbi *mipi, u8 cmd, u16 data) +static inline int ili9225_command(struct mipi_dbi *dbi, u8 cmd, u16 data) { u8 par[2] = { data >> 8, data & 0xff }; - return mipi_dbi_command_buf(mipi, cmd, par, 2); + return mipi_dbi_command_buf(dbi, cmd, par, 2); } static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) @@ -81,7 +81,8 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) struct mipi_dbi *mipi = drm_to_mipi_dbi(fb->dev); unsigned int height = rect->y2 - rect->y1; unsigned int width = rect->x2 - rect->x1; - bool swap = mipi->swap_bytes; + struct mipi_dbi *dbi = mipi; + bool swap = dbi->swap_bytes; u16 x_start, y_start; u16 x1, x2, y1, y2; int idx, ret = 0; @@ -98,7 +99,7 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, DRM_RECT_ARG(rect)); - if (!mipi->dc || !full || swap || + if (!dbi->dc || !full || swap || fb->format->format == DRM_FORMAT_XRGB8888) { tr = mipi->tx_buf; ret = mipi_dbi_buf_copy(mipi->tx_buf, fb, rect, swap); @@ -143,15 +144,15 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) break; } - ili9225_command(mipi, ILI9225_HORIZ_WINDOW_ADDR_1, x2); - ili9225_command(mipi, ILI9225_HORIZ_WINDOW_ADDR_2, x1); - ili9225_command(mipi, ILI9225_VERT_WINDOW_ADDR_1, y2); - ili9225_command(mipi, ILI9225_VERT_WINDOW_ADDR_2, y1); + ili9225_command(dbi, ILI9225_HORIZ_WINDOW_ADDR_1, x2); + ili9225_command(dbi, ILI9225_HORIZ_WINDOW_ADDR_2, x1); + ili9225_command(dbi, ILI9225_VERT_WINDOW_ADDR_1, y2); + ili9225_command(dbi, ILI9225_VERT_WINDOW_ADDR_2, y1); - ili9225_command(mipi, ILI9225_RAM_ADDRESS_SET_1, x_start); - ili9225_command(mipi, ILI9225_RAM_ADDRESS_SET_2, y_start); + ili9225_command(dbi, ILI9225_RAM_ADDRESS_SET_1, x_start); + ili9225_command(dbi, ILI9225_RAM_ADDRESS_SET_2, y_start); - ret = mipi_dbi_command_buf(mipi, ILI9225_WRITE_DATA_TO_GRAM, tr, + ret = mipi_dbi_command_buf(dbi, ILI9225_WRITE_DATA_TO_GRAM, tr, width * height * 2); err_msg: if (ret) @@ -185,6 +186,7 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); struct drm_framebuffer *fb = plane_state->fb; struct device *dev = pipe->crtc.dev->dev; + struct mipi_dbi *dbi = mipi; struct drm_rect rect = { .x1 = 0, .x2 = fb->width, @@ -199,7 +201,7 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, DRM_DEBUG_KMS("\n"); - mipi_dbi_hw_reset(mipi); + mipi_dbi_hw_reset(dbi); /* * There don't seem to be two example init sequences that match, so @@ -207,27 +209,27 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, * https://github.com/Nkawu/TFT_22_ILI9225/blob/master/src/TFT_22_ILI9225.cpp */ - ret = ili9225_command(mipi, ILI9225_POWER_CONTROL_1, 0x0000); + ret = ili9225_command(dbi, ILI9225_POWER_CONTROL_1, 0x0000); if (ret) { DRM_DEV_ERROR(dev, "Error sending command %d\n", ret); goto out_exit; } - ili9225_command(mipi, ILI9225_POWER_CONTROL_2, 0x0000); - ili9225_command(mipi, ILI9225_POWER_CONTROL_3, 0x0000); - ili9225_command(mipi, ILI9225_POWER_CONTROL_4, 0x0000); - ili9225_command(mipi, ILI9225_POWER_CONTROL_5, 0x0000); + ili9225_command(dbi, ILI9225_POWER_CONTROL_2, 0x0000); + ili9225_command(dbi, ILI9225_POWER_CONTROL_3, 0x0000); + ili9225_command(dbi, ILI9225_POWER_CONTROL_4, 0x0000); + ili9225_command(dbi, ILI9225_POWER_CONTROL_5, 0x0000); msleep(40); - ili9225_command(mipi, ILI9225_POWER_CONTROL_2, 0x0018); - ili9225_command(mipi, ILI9225_POWER_CONTROL_3, 0x6121); - ili9225_command(mipi, ILI9225_POWER_CONTROL_4, 0x006f); - ili9225_command(mipi, ILI9225_POWER_CONTROL_5, 0x495f); - ili9225_command(mipi, ILI9225_POWER_CONTROL_1, 0x0800); + ili9225_command(dbi, ILI9225_POWER_CONTROL_2, 0x0018); + ili9225_command(dbi, ILI9225_POWER_CONTROL_3, 0x6121); + ili9225_command(dbi, ILI9225_POWER_CONTROL_4, 0x006f); + ili9225_command(dbi, ILI9225_POWER_CONTROL_5, 0x495f); + ili9225_command(dbi, ILI9225_POWER_CONTROL_1, 0x0800); msleep(10); - ili9225_command(mipi, ILI9225_POWER_CONTROL_2, 0x103b); + ili9225_command(dbi, ILI9225_POWER_CONTROL_2, 0x103b); msleep(50); @@ -245,41 +247,41 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, am_id = 0x28; break; } - ili9225_command(mipi, ILI9225_DRIVER_OUTPUT_CONTROL, 0x011c); - ili9225_command(mipi, ILI9225_LCD_AC_DRIVING_CONTROL, 0x0100); - ili9225_command(mipi, ILI9225_ENTRY_MODE, 0x1000 | am_id); - ili9225_command(mipi, ILI9225_DISPLAY_CONTROL_1, 0x0000); - ili9225_command(mipi, ILI9225_BLANK_PERIOD_CONTROL_1, 0x0808); - ili9225_command(mipi, ILI9225_FRAME_CYCLE_CONTROL, 0x1100); - ili9225_command(mipi, ILI9225_INTERFACE_CONTROL, 0x0000); - ili9225_command(mipi, ILI9225_OSCILLATION_CONTROL, 0x0d01); - ili9225_command(mipi, ILI9225_VCI_RECYCLING, 0x0020); - ili9225_command(mipi, ILI9225_RAM_ADDRESS_SET_1, 0x0000); - ili9225_command(mipi, ILI9225_RAM_ADDRESS_SET_2, 0x0000); + ili9225_command(dbi, ILI9225_DRIVER_OUTPUT_CONTROL, 0x011c); + ili9225_command(dbi, ILI9225_LCD_AC_DRIVING_CONTROL, 0x0100); + ili9225_command(dbi, ILI9225_ENTRY_MODE, 0x1000 | am_id); + ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x0000); + ili9225_command(dbi, ILI9225_BLANK_PERIOD_CONTROL_1, 0x0808); + ili9225_command(dbi, ILI9225_FRAME_CYCLE_CONTROL, 0x1100); + ili9225_command(dbi, ILI9225_INTERFACE_CONTROL, 0x0000); + ili9225_command(dbi, ILI9225_OSCILLATION_CONTROL, 0x0d01); + ili9225_command(dbi, ILI9225_VCI_RECYCLING, 0x0020); + ili9225_command(dbi, ILI9225_RAM_ADDRESS_SET_1, 0x0000); + ili9225_command(dbi, ILI9225_RAM_ADDRESS_SET_2, 0x0000); - ili9225_command(mipi, ILI9225_GATE_SCAN_CONTROL, 0x0000); - ili9225_command(mipi, ILI9225_VERTICAL_SCROLL_1, 0x00db); - ili9225_command(mipi, ILI9225_VERTICAL_SCROLL_2, 0x0000); - ili9225_command(mipi, ILI9225_VERTICAL_SCROLL_3, 0x0000); - ili9225_command(mipi, ILI9225_PARTIAL_DRIVING_POS_1, 0x00db); - ili9225_command(mipi, ILI9225_PARTIAL_DRIVING_POS_2, 0x0000); + ili9225_command(dbi, ILI9225_GATE_SCAN_CONTROL, 0x0000); + ili9225_command(dbi, ILI9225_VERTICAL_SCROLL_1, 0x00db); + ili9225_command(dbi, ILI9225_VERTICAL_SCROLL_2, 0x0000); + ili9225_command(dbi, ILI9225_VERTICAL_SCROLL_3, 0x0000); + ili9225_command(dbi, ILI9225_PARTIAL_DRIVING_POS_1, 0x00db); + ili9225_command(dbi, ILI9225_PARTIAL_DRIVING_POS_2, 0x0000); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_1, 0x0000); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_2, 0x0808); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_3, 0x080a); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_4, 0x000a); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_5, 0x0a08); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_6, 0x0808); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_7, 0x0000); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_8, 0x0a00); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_9, 0x0710); - ili9225_command(mipi, ILI9225_GAMMA_CONTROL_10, 0x0710); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_1, 0x0000); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_2, 0x0808); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_3, 0x080a); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_4, 0x000a); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_5, 0x0a08); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_6, 0x0808); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_7, 0x0000); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_8, 0x0a00); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_9, 0x0710); + ili9225_command(dbi, ILI9225_GAMMA_CONTROL_10, 0x0710); - ili9225_command(mipi, ILI9225_DISPLAY_CONTROL_1, 0x0012); + ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x0012); msleep(50); - ili9225_command(mipi, ILI9225_DISPLAY_CONTROL_1, 0x1017); + ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x1017); mipi->enabled = true; ili9225_fb_dirty(fb, &rect); @@ -290,6 +292,7 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe) { struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = mipi; DRM_DEBUG_KMS("\n"); @@ -303,33 +306,33 @@ static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe) if (!mipi->enabled) return; - ili9225_command(mipi, ILI9225_DISPLAY_CONTROL_1, 0x0000); + ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x0000); msleep(50); - ili9225_command(mipi, ILI9225_POWER_CONTROL_2, 0x0007); + ili9225_command(dbi, ILI9225_POWER_CONTROL_2, 0x0007); msleep(50); - ili9225_command(mipi, ILI9225_POWER_CONTROL_1, 0x0a02); + ili9225_command(dbi, ILI9225_POWER_CONTROL_1, 0x0a02); mipi->enabled = false; } -static int ili9225_dbi_command(struct mipi_dbi *mipi, u8 *cmd, u8 *par, +static int ili9225_dbi_command(struct mipi_dbi *dbi, u8 *cmd, u8 *par, size_t num) { - struct spi_device *spi = mipi->spi; + struct spi_device *spi = dbi->spi; unsigned int bpw = 8; u32 speed_hz; int ret; - gpiod_set_value_cansleep(mipi->dc, 0); + gpiod_set_value_cansleep(dbi->dc, 0); speed_hz = mipi_dbi_spi_cmd_max_speed(spi, 1); ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, cmd, 1); if (ret || !num) return ret; - if (*cmd == ILI9225_WRITE_DATA_TO_GRAM && !mipi->swap_bytes) + if (*cmd == ILI9225_WRITE_DATA_TO_GRAM && !dbi->swap_bytes) bpw = 16; - gpiod_set_value_cansleep(mipi->dc, 1); + gpiod_set_value_cansleep(dbi->dc, 1); speed_hz = mipi_dbi_spi_cmd_max_speed(spi, num); return mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num); @@ -377,6 +380,7 @@ static int ili9225_probe(struct spi_device *spi) struct device *dev = &spi->dev; struct drm_device *drm; struct mipi_dbi *mipi; + struct mipi_dbi *dbi; struct gpio_desc *rs; u32 rotation = 0; int ret; @@ -385,6 +389,7 @@ static int ili9225_probe(struct spi_device *spi) if (!mipi) return -ENOMEM; + dbi = mipi; drm = &mipi->drm; ret = devm_drm_dev_init(dev, drm, &ili9225_driver); if (ret) { @@ -394,10 +399,10 @@ static int ili9225_probe(struct spi_device *spi) drm_mode_config_init(drm); - mipi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(mipi->reset)) { + dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(dbi->reset)) { DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n"); - return PTR_ERR(mipi->reset); + return PTR_ERR(dbi->reset); } rs = devm_gpiod_get(dev, "rs", GPIOD_OUT_LOW); @@ -408,12 +413,12 @@ static int ili9225_probe(struct spi_device *spi) device_property_read_u32(dev, "rotation", &rotation); - ret = mipi_dbi_spi_init(spi, mipi, rs); + ret = mipi_dbi_spi_init(spi, dbi, rs); if (ret) return ret; /* override the command function set in mipi_dbi_spi_init() */ - mipi->command = ili9225_dbi_command; + dbi->command = ili9225_dbi_command; ret = mipi_dbi_init(mipi, &ili9225_pipe_funcs, &ili9225_mode, rotation); if (ret) diff --git a/drivers/gpu/drm/tinydrm/ili9341.c b/drivers/gpu/drm/tinydrm/ili9341.c index cb0a0ddbc090..05ba5ab17ec6 100644 --- a/drivers/gpu/drm/tinydrm/ili9341.c +++ b/drivers/gpu/drm/tinydrm/ili9341.c @@ -54,6 +54,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, struct drm_plane_state *plane_state) { struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = mipi; u8 addr_mode; int ret, idx; @@ -68,47 +69,47 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, if (ret == 1) goto out_enable; - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF); + mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF); - mipi_dbi_command(mipi, ILI9341_PWCTRLB, 0x00, 0xc1, 0x30); - mipi_dbi_command(mipi, ILI9341_PWRSEQ, 0x64, 0x03, 0x12, 0x81); - mipi_dbi_command(mipi, ILI9341_DTCTRLA, 0x85, 0x00, 0x78); - mipi_dbi_command(mipi, ILI9341_PWCTRLA, 0x39, 0x2c, 0x00, 0x34, 0x02); - mipi_dbi_command(mipi, ILI9341_PUMPCTRL, 0x20); - mipi_dbi_command(mipi, ILI9341_DTCTRLB, 0x00, 0x00); + mipi_dbi_command(dbi, ILI9341_PWCTRLB, 0x00, 0xc1, 0x30); + mipi_dbi_command(dbi, ILI9341_PWRSEQ, 0x64, 0x03, 0x12, 0x81); + mipi_dbi_command(dbi, ILI9341_DTCTRLA, 0x85, 0x00, 0x78); + mipi_dbi_command(dbi, ILI9341_PWCTRLA, 0x39, 0x2c, 0x00, 0x34, 0x02); + mipi_dbi_command(dbi, ILI9341_PUMPCTRL, 0x20); + mipi_dbi_command(dbi, ILI9341_DTCTRLB, 0x00, 0x00); /* Power Control */ - mipi_dbi_command(mipi, ILI9341_PWCTRL1, 0x23); - mipi_dbi_command(mipi, ILI9341_PWCTRL2, 0x10); + mipi_dbi_command(dbi, ILI9341_PWCTRL1, 0x23); + mipi_dbi_command(dbi, ILI9341_PWCTRL2, 0x10); /* VCOM */ - mipi_dbi_command(mipi, ILI9341_VMCTRL1, 0x3e, 0x28); - mipi_dbi_command(mipi, ILI9341_VMCTRL2, 0x86); + mipi_dbi_command(dbi, ILI9341_VMCTRL1, 0x3e, 0x28); + mipi_dbi_command(dbi, ILI9341_VMCTRL2, 0x86); /* Memory Access Control */ - mipi_dbi_command(mipi, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT); + mipi_dbi_command(dbi, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT); /* Frame Rate */ - mipi_dbi_command(mipi, ILI9341_FRMCTR1, 0x00, 0x1b); + mipi_dbi_command(dbi, ILI9341_FRMCTR1, 0x00, 0x1b); /* Gamma */ - mipi_dbi_command(mipi, ILI9341_EN3GAM, 0x00); - mipi_dbi_command(mipi, MIPI_DCS_SET_GAMMA_CURVE, 0x01); - mipi_dbi_command(mipi, ILI9341_PGAMCTRL, + mipi_dbi_command(dbi, ILI9341_EN3GAM, 0x00); + mipi_dbi_command(dbi, MIPI_DCS_SET_GAMMA_CURVE, 0x01); + mipi_dbi_command(dbi, ILI9341_PGAMCTRL, 0x0f, 0x31, 0x2b, 0x0c, 0x0e, 0x08, 0x4e, 0xf1, 0x37, 0x07, 0x10, 0x03, 0x0e, 0x09, 0x00); - mipi_dbi_command(mipi, ILI9341_NGAMCTRL, + mipi_dbi_command(dbi, ILI9341_NGAMCTRL, 0x00, 0x0e, 0x14, 0x03, 0x11, 0x07, 0x31, 0xc1, 0x48, 0x08, 0x0f, 0x0c, 0x31, 0x36, 0x0f); /* DDRAM */ - mipi_dbi_command(mipi, ILI9341_ETMOD, 0x07); + mipi_dbi_command(dbi, ILI9341_ETMOD, 0x07); /* Display */ - mipi_dbi_command(mipi, ILI9341_DISCTRL, 0x08, 0x82, 0x27, 0x00); - mipi_dbi_command(mipi, MIPI_DCS_EXIT_SLEEP_MODE); + mipi_dbi_command(dbi, ILI9341_DISCTRL, 0x08, 0x82, 0x27, 0x00); + mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); msleep(100); - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON); + mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); msleep(100); out_enable: @@ -128,7 +129,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, break; } addr_mode |= ILI9341_MADCTL_BGR; - mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); + mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); mipi_dbi_enable_flush(mipi, crtc_state, plane_state); out_exit: drm_dev_exit(idx); @@ -177,6 +178,7 @@ static int ili9341_probe(struct spi_device *spi) struct device *dev = &spi->dev; struct drm_device *drm; struct mipi_dbi *mipi; + struct mipi_dbi *dbi; struct gpio_desc *dc; u32 rotation = 0; int ret; @@ -185,6 +187,7 @@ static int ili9341_probe(struct spi_device *spi) if (!mipi) return -ENOMEM; + dbi = mipi; drm = &mipi->drm; ret = devm_drm_dev_init(dev, drm, &ili9341_driver); if (ret) { @@ -194,10 +197,10 @@ static int ili9341_probe(struct spi_device *spi) drm_mode_config_init(drm); - mipi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(mipi->reset)) { + dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(dbi->reset)) { DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n"); - return PTR_ERR(mipi->reset); + return PTR_ERR(dbi->reset); } dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW); @@ -212,7 +215,7 @@ static int ili9341_probe(struct spi_device *spi) device_property_read_u32(dev, "rotation", &rotation); - ret = mipi_dbi_spi_init(spi, mipi, dc); + ret = mipi_dbi_spi_init(spi, dbi, dc); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c b/drivers/gpu/drm/tinydrm/mi0283qt.c index f21d58dcaa5a..adc8c4872d3f 100644 --- a/drivers/gpu/drm/tinydrm/mi0283qt.c +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c @@ -52,6 +52,7 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, struct drm_plane_state *plane_state) { struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = mipi; u8 addr_mode; int ret, idx; @@ -66,47 +67,47 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, if (ret == 1) goto out_enable; - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF); + mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF); - mipi_dbi_command(mipi, ILI9341_PWCTRLB, 0x00, 0x83, 0x30); - mipi_dbi_command(mipi, ILI9341_PWRSEQ, 0x64, 0x03, 0x12, 0x81); - mipi_dbi_command(mipi, ILI9341_DTCTRLA, 0x85, 0x01, 0x79); - mipi_dbi_command(mipi, ILI9341_PWCTRLA, 0x39, 0x2c, 0x00, 0x34, 0x02); - mipi_dbi_command(mipi, ILI9341_PUMPCTRL, 0x20); - mipi_dbi_command(mipi, ILI9341_DTCTRLB, 0x00, 0x00); + mipi_dbi_command(dbi, ILI9341_PWCTRLB, 0x00, 0x83, 0x30); + mipi_dbi_command(dbi, ILI9341_PWRSEQ, 0x64, 0x03, 0x12, 0x81); + mipi_dbi_command(dbi, ILI9341_DTCTRLA, 0x85, 0x01, 0x79); + mipi_dbi_command(dbi, ILI9341_PWCTRLA, 0x39, 0x2c, 0x00, 0x34, 0x02); + mipi_dbi_command(dbi, ILI9341_PUMPCTRL, 0x20); + mipi_dbi_command(dbi, ILI9341_DTCTRLB, 0x00, 0x00); /* Power Control */ - mipi_dbi_command(mipi, ILI9341_PWCTRL1, 0x26); - mipi_dbi_command(mipi, ILI9341_PWCTRL2, 0x11); + mipi_dbi_command(dbi, ILI9341_PWCTRL1, 0x26); + mipi_dbi_command(dbi, ILI9341_PWCTRL2, 0x11); /* VCOM */ - mipi_dbi_command(mipi, ILI9341_VMCTRL1, 0x35, 0x3e); - mipi_dbi_command(mipi, ILI9341_VMCTRL2, 0xbe); + mipi_dbi_command(dbi, ILI9341_VMCTRL1, 0x35, 0x3e); + mipi_dbi_command(dbi, ILI9341_VMCTRL2, 0xbe); /* Memory Access Control */ - mipi_dbi_command(mipi, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT); + mipi_dbi_command(dbi, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT); /* Frame Rate */ - mipi_dbi_command(mipi, ILI9341_FRMCTR1, 0x00, 0x1b); + mipi_dbi_command(dbi, ILI9341_FRMCTR1, 0x00, 0x1b); /* Gamma */ - mipi_dbi_command(mipi, ILI9341_EN3GAM, 0x08); - mipi_dbi_command(mipi, MIPI_DCS_SET_GAMMA_CURVE, 0x01); - mipi_dbi_command(mipi, ILI9341_PGAMCTRL, + mipi_dbi_command(dbi, ILI9341_EN3GAM, 0x08); + mipi_dbi_command(dbi, MIPI_DCS_SET_GAMMA_CURVE, 0x01); + mipi_dbi_command(dbi, ILI9341_PGAMCTRL, 0x1f, 0x1a, 0x18, 0x0a, 0x0f, 0x06, 0x45, 0x87, 0x32, 0x0a, 0x07, 0x02, 0x07, 0x05, 0x00); - mipi_dbi_command(mipi, ILI9341_NGAMCTRL, + mipi_dbi_command(dbi, ILI9341_NGAMCTRL, 0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3a, 0x78, 0x4d, 0x05, 0x18, 0x0d, 0x38, 0x3a, 0x1f); /* DDRAM */ - mipi_dbi_command(mipi, ILI9341_ETMOD, 0x07); + mipi_dbi_command(dbi, ILI9341_ETMOD, 0x07); /* Display */ - mipi_dbi_command(mipi, ILI9341_DISCTRL, 0x0a, 0x82, 0x27, 0x00); - mipi_dbi_command(mipi, MIPI_DCS_EXIT_SLEEP_MODE); + mipi_dbi_command(dbi, ILI9341_DISCTRL, 0x0a, 0x82, 0x27, 0x00); + mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); msleep(100); - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON); + mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); msleep(100); out_enable: @@ -132,7 +133,7 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, break; } addr_mode |= ILI9341_MADCTL_BGR; - mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); + mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); mipi_dbi_enable_flush(mipi, crtc_state, plane_state); out_exit: drm_dev_exit(idx); @@ -181,6 +182,7 @@ static int mi0283qt_probe(struct spi_device *spi) struct device *dev = &spi->dev; struct drm_device *drm; struct mipi_dbi *mipi; + struct mipi_dbi *dbi; struct gpio_desc *dc; u32 rotation = 0; int ret; @@ -189,6 +191,7 @@ static int mi0283qt_probe(struct spi_device *spi) if (!mipi) return -ENOMEM; + dbi = mipi; drm = &mipi->drm; ret = devm_drm_dev_init(dev, drm, &mi0283qt_driver); if (ret) { @@ -198,10 +201,10 @@ static int mi0283qt_probe(struct spi_device *spi) drm_mode_config_init(drm); - mipi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(mipi->reset)) { + dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(dbi->reset)) { DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n"); - return PTR_ERR(mipi->reset); + return PTR_ERR(dbi->reset); } dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW); @@ -220,7 +223,7 @@ static int mi0283qt_probe(struct spi_device *spi) device_property_read_u32(dev, "rotation", &rotation); - ret = mipi_dbi_spi_init(spi, mipi, dc); + ret = mipi_dbi_spi_init(spi, dbi, dc); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index 37a73b4c0f85..93b9b3ac5568 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -100,17 +100,17 @@ static const u8 mipi_dbi_dcs_read_commands[] = { 0, /* sentinel */ }; -static bool mipi_dbi_command_is_read(struct mipi_dbi *mipi, u8 cmd) +static bool mipi_dbi_command_is_read(struct mipi_dbi *dbi, u8 cmd) { unsigned int i; - if (!mipi->read_commands) + if (!dbi->read_commands) return false; for (i = 0; i < 0xff; i++) { - if (!mipi->read_commands[i]) + if (!dbi->read_commands[i]) return false; - if (cmd == mipi->read_commands[i]) + if (cmd == dbi->read_commands[i]) return true; } @@ -119,7 +119,7 @@ static bool mipi_dbi_command_is_read(struct mipi_dbi *mipi, u8 cmd) /** * mipi_dbi_command_read - MIPI DCS read command - * @mipi: MIPI structure + * @dbi: MIPI DBI structure * @cmd: Command * @val: Value read * @@ -128,21 +128,21 @@ static bool mipi_dbi_command_is_read(struct mipi_dbi *mipi, u8 cmd) * Returns: * Zero on success, negative error code on failure. */ -int mipi_dbi_command_read(struct mipi_dbi *mipi, u8 cmd, u8 *val) +int mipi_dbi_command_read(struct mipi_dbi *dbi, u8 cmd, u8 *val) { - if (!mipi->read_commands) + if (!dbi->read_commands) return -EACCES; - if (!mipi_dbi_command_is_read(mipi, cmd)) + if (!mipi_dbi_command_is_read(dbi, cmd)) return -EINVAL; - return mipi_dbi_command_buf(mipi, cmd, val, 1); + return mipi_dbi_command_buf(dbi, cmd, val, 1); } EXPORT_SYMBOL(mipi_dbi_command_read); /** * mipi_dbi_command_buf - MIPI DCS command with parameter(s) in an array - * @mipi: MIPI structure + * @dbi: MIPI DBI structure * @cmd: Command * @data: Parameter buffer * @len: Buffer length @@ -150,7 +150,7 @@ EXPORT_SYMBOL(mipi_dbi_command_read); * Returns: * Zero on success, negative error code on failure. */ -int mipi_dbi_command_buf(struct mipi_dbi *mipi, u8 cmd, u8 *data, size_t len) +int mipi_dbi_command_buf(struct mipi_dbi *dbi, u8 cmd, u8 *data, size_t len) { u8 *cmdbuf; int ret; @@ -160,9 +160,9 @@ int mipi_dbi_command_buf(struct mipi_dbi *mipi, u8 cmd, u8 *data, size_t len) if (!cmdbuf) return -ENOMEM; - mutex_lock(&mipi->cmdlock); - ret = mipi->command(mipi, cmdbuf, data, len); - mutex_unlock(&mipi->cmdlock); + mutex_lock(&dbi->cmdlock); + ret = dbi->command(dbi, cmdbuf, data, len); + mutex_unlock(&dbi->cmdlock); kfree(cmdbuf); @@ -171,7 +171,7 @@ int mipi_dbi_command_buf(struct mipi_dbi *mipi, u8 cmd, u8 *data, size_t len) EXPORT_SYMBOL(mipi_dbi_command_buf); /* This should only be used by mipi_dbi_command() */ -int mipi_dbi_command_stackbuf(struct mipi_dbi *mipi, u8 cmd, u8 *data, size_t len) +int mipi_dbi_command_stackbuf(struct mipi_dbi *dbi, u8 cmd, u8 *data, size_t len) { u8 *buf; int ret; @@ -180,7 +180,7 @@ int mipi_dbi_command_stackbuf(struct mipi_dbi *mipi, u8 cmd, u8 *data, size_t le if (!buf) return -ENOMEM; - ret = mipi_dbi_command_buf(mipi, cmd, buf, len); + ret = mipi_dbi_command_buf(dbi, cmd, buf, len); kfree(buf); @@ -244,7 +244,8 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) struct mipi_dbi *mipi = drm_to_mipi_dbi(fb->dev); unsigned int height = rect->y2 - rect->y1; unsigned int width = rect->x2 - rect->x1; - bool swap = mipi->swap_bytes; + struct mipi_dbi *dbi = mipi; + bool swap = dbi->swap_bytes; int idx, ret = 0; bool full; void *tr; @@ -259,7 +260,7 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, DRM_RECT_ARG(rect)); - if (!mipi->dc || !full || swap || + if (!dbi->dc || !full || swap || fb->format->format == DRM_FORMAT_XRGB8888) { tr = mipi->tx_buf; ret = mipi_dbi_buf_copy(mipi->tx_buf, fb, rect, swap); @@ -269,14 +270,14 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) tr = cma_obj->vaddr; } - mipi_dbi_command(mipi, MIPI_DCS_SET_COLUMN_ADDRESS, + mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, (rect->x1 >> 8) & 0xff, rect->x1 & 0xff, ((rect->x2 - 1) >> 8) & 0xff, (rect->x2 - 1) & 0xff); - mipi_dbi_command(mipi, MIPI_DCS_SET_PAGE_ADDRESS, + mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, (rect->y1 >> 8) & 0xff, rect->y1 & 0xff, ((rect->y2 - 1) >> 8) & 0xff, (rect->y2 - 1) & 0xff); - ret = mipi_dbi_command_buf(mipi, MIPI_DCS_WRITE_MEMORY_START, tr, + ret = mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, tr, width * height * 2); err_msg: if (ret) @@ -356,6 +357,7 @@ static void mipi_dbi_blank(struct mipi_dbi *mipi) u16 height = drm->mode_config.min_height; u16 width = drm->mode_config.min_width; size_t len = width * height * 2; + struct mipi_dbi *dbi = mipi; int idx; if (!drm_dev_enter(drm, &idx)) @@ -363,11 +365,11 @@ static void mipi_dbi_blank(struct mipi_dbi *mipi) memset(mipi->tx_buf, 0, len); - mipi_dbi_command(mipi, MIPI_DCS_SET_COLUMN_ADDRESS, 0, 0, + mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, 0, 0, (width >> 8) & 0xFF, (width - 1) & 0xFF); - mipi_dbi_command(mipi, MIPI_DCS_SET_PAGE_ADDRESS, 0, 0, + mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, 0, 0, (height >> 8) & 0xFF, (height - 1) & 0xFF); - mipi_dbi_command_buf(mipi, MIPI_DCS_WRITE_MEMORY_START, + mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, (u8 *)mipi->tx_buf, len); drm_dev_exit(idx); @@ -596,25 +598,25 @@ EXPORT_SYMBOL(mipi_dbi_release); /** * mipi_dbi_hw_reset - Hardware reset of controller - * @mipi: MIPI DBI structure + * @dbi: MIPI DBI structure * * Reset controller if the &mipi_dbi->reset gpio is set. */ -void mipi_dbi_hw_reset(struct mipi_dbi *mipi) +void mipi_dbi_hw_reset(struct mipi_dbi *dbi) { - if (!mipi->reset) + if (!dbi->reset) return; - gpiod_set_value_cansleep(mipi->reset, 0); + gpiod_set_value_cansleep(dbi->reset, 0); usleep_range(20, 1000); - gpiod_set_value_cansleep(mipi->reset, 1); + gpiod_set_value_cansleep(dbi->reset, 1); msleep(120); } EXPORT_SYMBOL(mipi_dbi_hw_reset); /** * mipi_dbi_display_is_on - Check if display is on - * @mipi: MIPI DBI structure + * @dbi: MIPI DBI structure * * This function checks the Power Mode register (if readable) to see if * display output is turned on. This can be used to see if the bootloader @@ -624,11 +626,11 @@ EXPORT_SYMBOL(mipi_dbi_hw_reset); * Returns: * true if the display can be verified to be on, false otherwise. */ -bool mipi_dbi_display_is_on(struct mipi_dbi *mipi) +bool mipi_dbi_display_is_on(struct mipi_dbi *dbi) { u8 val; - if (mipi_dbi_command_read(mipi, MIPI_DCS_GET_POWER_MODE, &val)) + if (mipi_dbi_command_read(dbi, MIPI_DCS_GET_POWER_MODE, &val)) return false; val &= ~DCS_POWER_MODE_RESERVED_MASK; @@ -647,6 +649,7 @@ EXPORT_SYMBOL(mipi_dbi_display_is_on); static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *mipi, bool cond) { struct device *dev = mipi->drm.dev; + struct mipi_dbi *dbi = mipi; int ret; if (mipi->regulator) { @@ -657,11 +660,11 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *mipi, bool cond) } } - if (cond && mipi_dbi_display_is_on(mipi)) + if (cond && mipi_dbi_display_is_on(dbi)) return 1; - mipi_dbi_hw_reset(mipi); - ret = mipi_dbi_command(mipi, MIPI_DCS_SOFT_RESET); + mipi_dbi_hw_reset(dbi); + ret = mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET); if (ret) { DRM_DEV_ERROR(dev, "Failed to send reset command (%d)\n", ret); if (mipi->regulator) @@ -674,7 +677,7 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *mipi, bool cond) * per MIPI DSC spec should wait 5ms after soft reset. If we didn't, * we assume worst case and wait 120ms. */ - if (mipi->reset) + if (dbi->reset) usleep_range(5000, 20000); else msleep(120); @@ -763,15 +766,15 @@ static bool mipi_dbi_machine_little_endian(void) * 76543210 */ -static int mipi_dbi_spi1e_transfer(struct mipi_dbi *mipi, int dc, +static int mipi_dbi_spi1e_transfer(struct mipi_dbi *dbi, int dc, const void *buf, size_t len, unsigned int bpw) { bool swap_bytes = (bpw == 16 && mipi_dbi_machine_little_endian()); - size_t chunk, max_chunk = mipi->tx_buf9_len; - struct spi_device *spi = mipi->spi; + size_t chunk, max_chunk = dbi->tx_buf9_len; + struct spi_device *spi = dbi->spi; struct spi_transfer tr = { - .tx_buf = mipi->tx_buf9, + .tx_buf = dbi->tx_buf9, .bits_per_word = 8, }; struct spi_message m; @@ -791,7 +794,7 @@ static int mipi_dbi_spi1e_transfer(struct mipi_dbi *mipi, int dc, return -EINVAL; /* Command: pad no-op's (zeroes) at beginning of block */ - dst = mipi->tx_buf9; + dst = dbi->tx_buf9; memset(dst, 0, 9); dst[8] = *src; tr.len = 9; @@ -811,7 +814,7 @@ static int mipi_dbi_spi1e_transfer(struct mipi_dbi *mipi, int dc, chunk = min(len, max_chunk); len -= chunk; - dst = mipi->tx_buf9; + dst = dbi->tx_buf9; if (chunk < 8) { u8 val, carry = 0; @@ -881,11 +884,11 @@ static int mipi_dbi_spi1e_transfer(struct mipi_dbi *mipi, int dc, return 0; } -static int mipi_dbi_spi1_transfer(struct mipi_dbi *mipi, int dc, +static int mipi_dbi_spi1_transfer(struct mipi_dbi *dbi, int dc, const void *buf, size_t len, unsigned int bpw) { - struct spi_device *spi = mipi->spi; + struct spi_device *spi = dbi->spi; struct spi_transfer tr = { .bits_per_word = 9, }; @@ -897,11 +900,11 @@ static int mipi_dbi_spi1_transfer(struct mipi_dbi *mipi, int dc, int ret; if (!spi_is_bpw_supported(spi, 9)) - return mipi_dbi_spi1e_transfer(mipi, dc, buf, len, bpw); + return mipi_dbi_spi1e_transfer(dbi, dc, buf, len, bpw); tr.speed_hz = mipi_dbi_spi_cmd_max_speed(spi, len); - max_chunk = mipi->tx_buf9_len; - dst16 = mipi->tx_buf9; + max_chunk = dbi->tx_buf9_len; + dst16 = dbi->tx_buf9; if (drm_debug & DRM_UT_DRIVER) pr_debug("[drm:%s] dc=%d, max_chunk=%zu, transfers:\n", @@ -944,30 +947,30 @@ static int mipi_dbi_spi1_transfer(struct mipi_dbi *mipi, int dc, return 0; } -static int mipi_dbi_typec1_command(struct mipi_dbi *mipi, u8 *cmd, +static int mipi_dbi_typec1_command(struct mipi_dbi *dbi, u8 *cmd, u8 *parameters, size_t num) { unsigned int bpw = (*cmd == MIPI_DCS_WRITE_MEMORY_START) ? 16 : 8; int ret; - if (mipi_dbi_command_is_read(mipi, *cmd)) + if (mipi_dbi_command_is_read(dbi, *cmd)) return -ENOTSUPP; MIPI_DBI_DEBUG_COMMAND(*cmd, parameters, num); - ret = mipi_dbi_spi1_transfer(mipi, 0, cmd, 1, 8); + ret = mipi_dbi_spi1_transfer(dbi, 0, cmd, 1, 8); if (ret || !num) return ret; - return mipi_dbi_spi1_transfer(mipi, 1, parameters, num, bpw); + return mipi_dbi_spi1_transfer(dbi, 1, parameters, num, bpw); } /* MIPI DBI Type C Option 3 */ -static int mipi_dbi_typec3_command_read(struct mipi_dbi *mipi, u8 *cmd, +static int mipi_dbi_typec3_command_read(struct mipi_dbi *dbi, u8 *cmd, u8 *data, size_t len) { - struct spi_device *spi = mipi->spi; + struct spi_device *spi = dbi->spi; u32 speed_hz = min_t(u32, MIPI_DBI_MAX_SPI_READ_SPEED, spi->max_speed_hz / 2); struct spi_transfer tr[2] = { @@ -1004,7 +1007,7 @@ static int mipi_dbi_typec3_command_read(struct mipi_dbi *mipi, u8 *cmd, return -ENOMEM; tr[1].rx_buf = buf; - gpiod_set_value_cansleep(mipi->dc, 0); + gpiod_set_value_cansleep(dbi->dc, 0); spi_message_init_with_transfers(&m, tr, ARRAY_SIZE(tr)); ret = spi_sync(spi, &m); @@ -1028,41 +1031,41 @@ static int mipi_dbi_typec3_command_read(struct mipi_dbi *mipi, u8 *cmd, return ret; } -static int mipi_dbi_typec3_command(struct mipi_dbi *mipi, u8 *cmd, +static int mipi_dbi_typec3_command(struct mipi_dbi *dbi, u8 *cmd, u8 *par, size_t num) { - struct spi_device *spi = mipi->spi; + struct spi_device *spi = dbi->spi; unsigned int bpw = 8; u32 speed_hz; int ret; - if (mipi_dbi_command_is_read(mipi, *cmd)) - return mipi_dbi_typec3_command_read(mipi, cmd, par, num); + if (mipi_dbi_command_is_read(dbi, *cmd)) + return mipi_dbi_typec3_command_read(dbi, cmd, par, num); MIPI_DBI_DEBUG_COMMAND(*cmd, par, num); - gpiod_set_value_cansleep(mipi->dc, 0); + gpiod_set_value_cansleep(dbi->dc, 0); speed_hz = mipi_dbi_spi_cmd_max_speed(spi, 1); ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, cmd, 1); if (ret || !num) return ret; - if (*cmd == MIPI_DCS_WRITE_MEMORY_START && !mipi->swap_bytes) + if (*cmd == MIPI_DCS_WRITE_MEMORY_START && !dbi->swap_bytes) bpw = 16; - gpiod_set_value_cansleep(mipi->dc, 1); + gpiod_set_value_cansleep(dbi->dc, 1); speed_hz = mipi_dbi_spi_cmd_max_speed(spi, num); return mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num); } /** - * mipi_dbi_spi_init - Initialize MIPI DBI SPI interfaced controller + * mipi_dbi_spi_init - Initialize MIPI DBI SPI interface * @spi: SPI device - * @mipi: &mipi_dbi structure to initialize + * @dbi: MIPI DBI structure to initialize * @dc: D/C gpio (optional) * - * This function sets &mipi_dbi->command, enables &mipi->read_commands for the + * This function sets &mipi_dbi->command, enables &mipi_dbi->read_commands for the * usual read commands. It should be followed by a call to mipi_dbi_init() or * a driver-specific init. * @@ -1078,7 +1081,7 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *mipi, u8 *cmd, * Returns: * Zero on success, negative error code on failure. */ -int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi, +int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi, struct gpio_desc *dc) { struct device *dev = &spi->dev; @@ -1102,23 +1105,23 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi, } } - mipi->spi = spi; - mipi->read_commands = mipi_dbi_dcs_read_commands; + dbi->spi = spi; + dbi->read_commands = mipi_dbi_dcs_read_commands; if (dc) { - mipi->command = mipi_dbi_typec3_command; - mipi->dc = dc; + dbi->command = mipi_dbi_typec3_command; + dbi->dc = dc; if (mipi_dbi_machine_little_endian() && !spi_is_bpw_supported(spi, 16)) - mipi->swap_bytes = true; + dbi->swap_bytes = true; } else { - mipi->command = mipi_dbi_typec1_command; - mipi->tx_buf9_len = SZ_16K; - mipi->tx_buf9 = devm_kmalloc(dev, mipi->tx_buf9_len, GFP_KERNEL); - if (!mipi->tx_buf9) + dbi->command = mipi_dbi_typec1_command; + dbi->tx_buf9_len = SZ_16K; + dbi->tx_buf9 = devm_kmalloc(dev, dbi->tx_buf9_len, GFP_KERNEL); + if (!dbi->tx_buf9) return -ENOMEM; } - mutex_init(&mipi->cmdlock); + mutex_init(&dbi->cmdlock); DRM_DEBUG_DRIVER("SPI speed: %uMHz\n", spi->max_speed_hz / 1000000); diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c index 4046b0fc3f7a..8339e7dc5d92 100644 --- a/drivers/gpu/drm/tinydrm/st7586.c +++ b/drivers/gpu/drm/tinydrm/st7586.c @@ -115,6 +115,7 @@ static int st7586_buf_copy(void *dst, struct drm_framebuffer *fb, static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) { struct mipi_dbi *mipi = drm_to_mipi_dbi(fb->dev); + struct mipi_dbi *dbi = mipi; int start, end, idx, ret = 0; if (!mipi->enabled) @@ -137,14 +138,14 @@ static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) start = rect->x1 / 3; end = rect->x2 / 3; - mipi_dbi_command(mipi, MIPI_DCS_SET_COLUMN_ADDRESS, + mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, (start >> 8) & 0xFF, start & 0xFF, (end >> 8) & 0xFF, (end - 1) & 0xFF); - mipi_dbi_command(mipi, MIPI_DCS_SET_PAGE_ADDRESS, + mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, (rect->y1 >> 8) & 0xFF, rect->y1 & 0xFF, (rect->y2 >> 8) & 0xFF, (rect->y2 - 1) & 0xFF); - ret = mipi_dbi_command_buf(mipi, MIPI_DCS_WRITE_MEMORY_START, + ret = mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, (u8 *)mipi->tx_buf, (end - start) * (rect->y2 - rect->y1)); err_msg: @@ -178,6 +179,7 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, { struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); struct drm_framebuffer *fb = plane_state->fb; + struct mipi_dbi *dbi = mipi; struct drm_rect rect = { .x1 = 0, .x2 = fb->width, @@ -196,29 +198,29 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, if (ret) goto out_exit; - mipi_dbi_command(mipi, ST7586_AUTO_READ_CTRL, 0x9f); - mipi_dbi_command(mipi, ST7586_OTP_RW_CTRL, 0x00); + mipi_dbi_command(dbi, ST7586_AUTO_READ_CTRL, 0x9f); + mipi_dbi_command(dbi, ST7586_OTP_RW_CTRL, 0x00); msleep(10); - mipi_dbi_command(mipi, ST7586_OTP_READ); + mipi_dbi_command(dbi, ST7586_OTP_READ); msleep(20); - mipi_dbi_command(mipi, ST7586_OTP_CTRL_OUT); - mipi_dbi_command(mipi, MIPI_DCS_EXIT_SLEEP_MODE); - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF); + mipi_dbi_command(dbi, ST7586_OTP_CTRL_OUT); + mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); + mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF); msleep(50); - mipi_dbi_command(mipi, ST7586_SET_VOP_OFFSET, 0x00); - mipi_dbi_command(mipi, ST7586_SET_VOP, 0xe3, 0x00); - mipi_dbi_command(mipi, ST7586_SET_BIAS_SYSTEM, 0x02); - mipi_dbi_command(mipi, ST7586_SET_BOOST_LEVEL, 0x04); - mipi_dbi_command(mipi, ST7586_ENABLE_ANALOG, 0x1d); - mipi_dbi_command(mipi, ST7586_SET_NLINE_INV, 0x00); - mipi_dbi_command(mipi, ST7586_DISP_MODE_GRAY); - mipi_dbi_command(mipi, ST7586_ENABLE_DDRAM, 0x02); + mipi_dbi_command(dbi, ST7586_SET_VOP_OFFSET, 0x00); + mipi_dbi_command(dbi, ST7586_SET_VOP, 0xe3, 0x00); + mipi_dbi_command(dbi, ST7586_SET_BIAS_SYSTEM, 0x02); + mipi_dbi_command(dbi, ST7586_SET_BOOST_LEVEL, 0x04); + mipi_dbi_command(dbi, ST7586_ENABLE_ANALOG, 0x1d); + mipi_dbi_command(dbi, ST7586_SET_NLINE_INV, 0x00); + mipi_dbi_command(dbi, ST7586_DISP_MODE_GRAY); + mipi_dbi_command(dbi, ST7586_ENABLE_DDRAM, 0x02); switch (mipi->rotation) { default: @@ -234,19 +236,19 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, addr_mode = ST7586_DISP_CTRL_MX; break; } - mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); + mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); - mipi_dbi_command(mipi, ST7586_SET_DISP_DUTY, 0x7f); - mipi_dbi_command(mipi, ST7586_SET_PART_DISP, 0xa0); - mipi_dbi_command(mipi, MIPI_DCS_SET_PARTIAL_AREA, 0x00, 0x00, 0x00, 0x77); - mipi_dbi_command(mipi, MIPI_DCS_EXIT_INVERT_MODE); + mipi_dbi_command(dbi, ST7586_SET_DISP_DUTY, 0x7f); + mipi_dbi_command(dbi, ST7586_SET_PART_DISP, 0xa0); + mipi_dbi_command(dbi, MIPI_DCS_SET_PARTIAL_AREA, 0x00, 0x00, 0x00, 0x77); + mipi_dbi_command(dbi, MIPI_DCS_EXIT_INVERT_MODE); msleep(100); mipi->enabled = true; st7586_fb_dirty(fb, &rect); - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON); + mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); out_exit: drm_dev_exit(idx); } @@ -318,6 +320,7 @@ static int st7586_probe(struct spi_device *spi) struct device *dev = &spi->dev; struct drm_device *drm; struct mipi_dbi *mipi; + struct mipi_dbi *dbi; struct gpio_desc *a0; u32 rotation = 0; size_t bufsize; @@ -327,6 +330,7 @@ static int st7586_probe(struct spi_device *spi) if (!mipi) return -ENOMEM; + dbi = mipi; drm = &mipi->drm; ret = devm_drm_dev_init(dev, drm, &st7586_driver); if (ret) { @@ -338,10 +342,10 @@ static int st7586_probe(struct spi_device *spi) bufsize = (st7586_mode.vdisplay + 2) / 3 * st7586_mode.hdisplay; - mipi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(mipi->reset)) { + dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(dbi->reset)) { DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n"); - return PTR_ERR(mipi->reset); + return PTR_ERR(dbi->reset); } a0 = devm_gpiod_get(dev, "a0", GPIOD_OUT_LOW); @@ -352,12 +356,12 @@ static int st7586_probe(struct spi_device *spi) device_property_read_u32(dev, "rotation", &rotation); - ret = mipi_dbi_spi_init(spi, mipi, a0); + ret = mipi_dbi_spi_init(spi, dbi, a0); if (ret) return ret; /* Cannot read from this controller via SPI */ - mipi->read_commands = NULL; + dbi->read_commands = NULL; ret = mipi_dbi_init_with_formats(mipi, &st7586_pipe_funcs, st7586_formats, ARRAY_SIZE(st7586_formats), @@ -372,7 +376,7 @@ static int st7586_probe(struct spi_device *spi) * bytes on little-endian systems and causes out of order data to be * sent to the display). */ - mipi->swap_bytes = true; + dbi->swap_bytes = true; drm_mode_config_reset(drm); diff --git a/drivers/gpu/drm/tinydrm/st7735r.c b/drivers/gpu/drm/tinydrm/st7735r.c index 151749035a19..4309ae299766 100644 --- a/drivers/gpu/drm/tinydrm/st7735r.c +++ b/drivers/gpu/drm/tinydrm/st7735r.c @@ -43,6 +43,7 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_plane_state *plane_state) { struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = mipi; int ret, idx; u8 addr_mode; @@ -57,21 +58,21 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, msleep(150); - mipi_dbi_command(mipi, MIPI_DCS_EXIT_SLEEP_MODE); + mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); msleep(500); - mipi_dbi_command(mipi, ST7735R_FRMCTR1, 0x01, 0x2c, 0x2d); - mipi_dbi_command(mipi, ST7735R_FRMCTR2, 0x01, 0x2c, 0x2d); - mipi_dbi_command(mipi, ST7735R_FRMCTR3, 0x01, 0x2c, 0x2d, 0x01, 0x2c, + mipi_dbi_command(dbi, ST7735R_FRMCTR1, 0x01, 0x2c, 0x2d); + mipi_dbi_command(dbi, ST7735R_FRMCTR2, 0x01, 0x2c, 0x2d); + mipi_dbi_command(dbi, ST7735R_FRMCTR3, 0x01, 0x2c, 0x2d, 0x01, 0x2c, 0x2d); - mipi_dbi_command(mipi, ST7735R_INVCTR, 0x07); - mipi_dbi_command(mipi, ST7735R_PWCTR1, 0xa2, 0x02, 0x84); - mipi_dbi_command(mipi, ST7735R_PWCTR2, 0xc5); - mipi_dbi_command(mipi, ST7735R_PWCTR3, 0x0a, 0x00); - mipi_dbi_command(mipi, ST7735R_PWCTR4, 0x8a, 0x2a); - mipi_dbi_command(mipi, ST7735R_PWCTR5, 0x8a, 0xee); - mipi_dbi_command(mipi, ST7735R_VMCTR1, 0x0e); - mipi_dbi_command(mipi, MIPI_DCS_EXIT_INVERT_MODE); + mipi_dbi_command(dbi, ST7735R_INVCTR, 0x07); + mipi_dbi_command(dbi, ST7735R_PWCTR1, 0xa2, 0x02, 0x84); + mipi_dbi_command(dbi, ST7735R_PWCTR2, 0xc5); + mipi_dbi_command(dbi, ST7735R_PWCTR3, 0x0a, 0x00); + mipi_dbi_command(dbi, ST7735R_PWCTR4, 0x8a, 0x2a); + mipi_dbi_command(dbi, ST7735R_PWCTR5, 0x8a, 0xee); + mipi_dbi_command(dbi, ST7735R_VMCTR1, 0x0e); + mipi_dbi_command(dbi, MIPI_DCS_EXIT_INVERT_MODE); switch (mipi->rotation) { default: addr_mode = ST7735R_MX | ST7735R_MY; @@ -86,20 +87,20 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, addr_mode = ST7735R_MY | ST7735R_MV; break; } - mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); - mipi_dbi_command(mipi, MIPI_DCS_SET_PIXEL_FORMAT, + mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); + mipi_dbi_command(dbi, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT); - mipi_dbi_command(mipi, ST7735R_GAMCTRP1, 0x02, 0x1c, 0x07, 0x12, 0x37, + mipi_dbi_command(dbi, ST7735R_GAMCTRP1, 0x02, 0x1c, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2d, 0x29, 0x25, 0x2b, 0x39, 0x00, 0x01, 0x03, 0x10); - mipi_dbi_command(mipi, ST7735R_GAMCTRN1, 0x03, 0x1d, 0x07, 0x06, 0x2e, + mipi_dbi_command(dbi, ST7735R_GAMCTRN1, 0x03, 0x1d, 0x07, 0x06, 0x2e, 0x2c, 0x29, 0x2d, 0x2e, 0x2e, 0x37, 0x3f, 0x00, 0x00, 0x02, 0x10); - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON); + mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); msleep(100); - mipi_dbi_command(mipi, MIPI_DCS_ENTER_NORMAL_MODE); + mipi_dbi_command(dbi, MIPI_DCS_ENTER_NORMAL_MODE); msleep(20); @@ -151,6 +152,7 @@ static int st7735r_probe(struct spi_device *spi) struct device *dev = &spi->dev; struct drm_device *drm; struct mipi_dbi *mipi; + struct mipi_dbi *dbi; struct gpio_desc *dc; u32 rotation = 0; int ret; @@ -159,6 +161,7 @@ static int st7735r_probe(struct spi_device *spi) if (!mipi) return -ENOMEM; + dbi = mipi; drm = &mipi->drm; ret = devm_drm_dev_init(dev, drm, &st7735r_driver); if (ret) { @@ -168,10 +171,10 @@ static int st7735r_probe(struct spi_device *spi) drm_mode_config_init(drm); - mipi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(mipi->reset)) { + dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(dbi->reset)) { DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n"); - return PTR_ERR(mipi->reset); + return PTR_ERR(dbi->reset); } dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW); @@ -186,12 +189,12 @@ static int st7735r_probe(struct spi_device *spi) device_property_read_u32(dev, "rotation", &rotation); - ret = mipi_dbi_spi_init(spi, mipi, dc); + ret = mipi_dbi_spi_init(spi, dbi, dc); if (ret) return ret; /* Cannot read from Adafruit 1.8" display via SPI */ - mipi->read_commands = NULL; + dbi->read_commands = NULL; ret = mipi_dbi_init(mipi, &jd_t18003_t01_pipe_funcs, &jd_t18003_t01_mode, rotation); if (ret) diff --git a/include/drm/tinydrm/mipi-dbi.h b/include/drm/tinydrm/mipi-dbi.h index 393323f87e12..04b54ec61bc2 100644 --- a/include/drm/tinydrm/mipi-dbi.h +++ b/include/drm/tinydrm/mipi-dbi.h @@ -59,7 +59,7 @@ struct mipi_dbi { struct spi_device *spi; bool enabled; struct mutex cmdlock; - int (*command)(struct mipi_dbi *mipi, u8 *cmd, u8 *param, size_t num); + int (*command)(struct mipi_dbi *dbi, u8 *cmd, u8 *param, size_t num); const u8 *read_commands; struct gpio_desc *dc; u16 *tx_buf; @@ -77,7 +77,7 @@ static inline struct mipi_dbi *drm_to_mipi_dbi(struct drm_device *drm) return container_of(drm, struct mipi_dbi, drm); } -int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi, +int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi, struct gpio_desc *dc); int mipi_dbi_init_with_formats(struct mipi_dbi *mipi, const struct drm_simple_display_pipe_funcs *funcs, @@ -94,8 +94,8 @@ void mipi_dbi_enable_flush(struct mipi_dbi *mipi, struct drm_crtc_state *crtc_state, struct drm_plane_state *plan_state); void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe); -void mipi_dbi_hw_reset(struct mipi_dbi *mipi); -bool mipi_dbi_display_is_on(struct mipi_dbi *mipi); +void mipi_dbi_hw_reset(struct mipi_dbi *dbi); +bool mipi_dbi_display_is_on(struct mipi_dbi *dbi); int mipi_dbi_poweron_reset(struct mipi_dbi *mipi); int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *mipi); @@ -103,14 +103,14 @@ u32 mipi_dbi_spi_cmd_max_speed(struct spi_device *spi, size_t len); int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, u8 bpw, const void *buf, size_t len); -int mipi_dbi_command_read(struct mipi_dbi *mipi, u8 cmd, u8 *val); -int mipi_dbi_command_buf(struct mipi_dbi *mipi, u8 cmd, u8 *data, size_t len); -int mipi_dbi_command_stackbuf(struct mipi_dbi *mipi, u8 cmd, u8 *data, size_t len); +int mipi_dbi_command_read(struct mipi_dbi *dbi, u8 cmd, u8 *val); +int mipi_dbi_command_buf(struct mipi_dbi *dbi, u8 cmd, u8 *data, size_t len); +int mipi_dbi_command_stackbuf(struct mipi_dbi *dbi, u8 cmd, u8 *data, size_t len); int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, struct drm_rect *clip, bool swap); /** * mipi_dbi_command - MIPI DCS command with optional parameter(s) - * @mipi: MIPI structure + * @dbi: MIPI DBI structure * @cmd: Command * @seq...: Optional parameter(s) * @@ -120,10 +120,10 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, * Returns: * Zero on success, negative error code on failure. */ -#define mipi_dbi_command(mipi, cmd, seq...) \ +#define mipi_dbi_command(dbi, cmd, seq...) \ ({ \ u8 d[] = { seq }; \ - mipi_dbi_command_stackbuf(mipi, cmd, d, ARRAY_SIZE(d)); \ + mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \ }) #ifdef CONFIG_DEBUG_FS From patchwork Mon Jul 22 10:43:06 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: 11052129 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 BF8BE112C for ; Mon, 22 Jul 2019 10:43:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC63428500 for ; Mon, 22 Jul 2019 10:43:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A053E2851B; Mon, 22 Jul 2019 10:43:38 +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 C356128500 for ; Mon, 22 Jul 2019 10:43:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F09FD89C07; Mon, 22 Jul 2019 10:43:29 +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 9FD1D89A61 for ; Mon, 22 Jul 2019 10:43:26 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:55388 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 1hpVmu-0001lD-NQ; Mon, 22 Jul 2019 12:43:24 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/9] drm/tinydrm: Rename remaining variable mipi -> dbidev Date: Mon, 22 Jul 2019 12:43:06 +0200 Message-Id: <20190722104312.16184-4-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722104312.16184-1-noralf@tronnes.org> References: <20190722104312.16184-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=5LOtaFwFcFN3ZeDXIdgAYOxOGZJhXd90goB/K+pGlHU=; b=eHwtYnLn/gQPoGRLFFzp2aBOR3/Q1nbQ5UjKce1Jbdh09IvVMghBFTrO+nKzl3GxPBht+n2MXFDJmzCwEJMQDy7ucCMcd0EiRkRbMdTEy/o1JNxfyM+ArOiA/5tZj9MS/vPc/BIB33Tuo1JIaRmZEbXk+am2TEAAsMQMFTXoDFim2xdZDLcjHu3QngvOm5Yr38XM1E7jaPUSXtdHyTbfEm6VJ3k7zMmMnqkHaBKnylN0yepz6I4+1jSXbgXq4leglsl6qaBjsSvZu9DVqO86i9r4Kfh1jhL6y7BvBB0x3hm1O70sEa+H8ZoNFp1AzU59WIJ+D6r6zoB0QPf/6Pmk0Q==; 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: sam@ravnborg.org, david@lechnology.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP struct mipi_dbi is going to be split into an interface part and a display pipeline part. The interface part can be used by drivers that need to initialize the controller, but that won't upload the framebuffer over this interface. tinydrm uses the variable name 'mipi' but this is not a good name since MIPI refers to a lot of standards. This patch changes the variable name to 'dbidev' where it refers to the pipeline part of struct mipi_dbi. Cc: Eric Anholt Cc: David Lechner Reviewed-by: Sam Ravnborg Signed-off-by: Noralf Trønnes Acked-by: David Lechner --- drivers/gpu/drm/tinydrm/hx8357d.c | 30 ++++---- drivers/gpu/drm/tinydrm/ili9225.c | 42 +++++----- drivers/gpu/drm/tinydrm/ili9341.c | 30 ++++---- drivers/gpu/drm/tinydrm/mi0283qt.c | 36 ++++----- drivers/gpu/drm/tinydrm/mipi-dbi.c | 120 ++++++++++++++--------------- drivers/gpu/drm/tinydrm/st7586.c | 34 ++++---- drivers/gpu/drm/tinydrm/st7735r.c | 30 ++++---- include/drm/tinydrm/mipi-dbi.h | 10 +-- 8 files changed, 166 insertions(+), 166 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c b/drivers/gpu/drm/tinydrm/hx8357d.c index f503d14aa36b..e113c434ff55 100644 --- a/drivers/gpu/drm/tinydrm/hx8357d.c +++ b/drivers/gpu/drm/tinydrm/hx8357d.c @@ -47,8 +47,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = dbidev; u8 addr_mode; int ret, idx; @@ -57,7 +57,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, DRM_DEBUG_KMS("\n"); - ret = mipi_dbi_poweron_conditional_reset(mipi); + ret = mipi_dbi_poweron_conditional_reset(dbidev); if (ret < 0) goto out_exit; if (ret == 1) @@ -159,7 +159,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, usleep_range(5000, 7000); out_enable: - switch (mipi->rotation) { + switch (dbidev->rotation) { default: addr_mode = HX8357D_MADCTL_MX | HX8357D_MADCTL_MY; break; @@ -174,7 +174,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, break; } mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); - mipi_dbi_enable_flush(mipi, crtc_state, plane_state); + mipi_dbi_enable_flush(dbidev, crtc_state, plane_state); out_exit: drm_dev_exit(idx); } @@ -220,20 +220,20 @@ MODULE_DEVICE_TABLE(spi, hx8357d_id); static int hx8357d_probe(struct spi_device *spi) { struct device *dev = &spi->dev; + struct mipi_dbi *dbidev; struct drm_device *drm; - struct mipi_dbi *mipi; struct gpio_desc *dc; u32 rotation = 0; int ret; - mipi = kzalloc(sizeof(*mipi), GFP_KERNEL); - if (!mipi) + dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL); + if (!dbidev) return -ENOMEM; - drm = &mipi->drm; + drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &hx8357d_driver); if (ret) { - kfree(mipi); + kfree(dbidev); return ret; } @@ -245,17 +245,17 @@ static int hx8357d_probe(struct spi_device *spi) return PTR_ERR(dc); } - mipi->backlight = devm_of_find_backlight(dev); - if (IS_ERR(mipi->backlight)) - return PTR_ERR(mipi->backlight); + dbidev->backlight = devm_of_find_backlight(dev); + if (IS_ERR(dbidev->backlight)) + return PTR_ERR(dbidev->backlight); device_property_read_u32(dev, "rotation", &rotation); - ret = mipi_dbi_spi_init(spi, mipi, dc); + ret = mipi_dbi_spi_init(spi, dbidev, dc); if (ret) return ret; - ret = mipi_dbi_init(mipi, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation); + ret = mipi_dbi_init(dbidev, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/ili9225.c b/drivers/gpu/drm/tinydrm/ili9225.c index c837d1423362..209a75dab7ce 100644 --- a/drivers/gpu/drm/tinydrm/ili9225.c +++ b/drivers/gpu/drm/tinydrm/ili9225.c @@ -78,10 +78,10 @@ static inline int ili9225_command(struct mipi_dbi *dbi, u8 cmd, u16 data) static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) { struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0); - struct mipi_dbi *mipi = drm_to_mipi_dbi(fb->dev); + struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev); unsigned int height = rect->y2 - rect->y1; unsigned int width = rect->x2 - rect->x1; - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbi = dbidev; bool swap = dbi->swap_bytes; u16 x_start, y_start; u16 x1, x2, y1, y2; @@ -89,7 +89,7 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) bool full; void *tr; - if (!mipi->enabled) + if (!dbidev->enabled) return; if (!drm_dev_enter(fb->dev, &idx)) @@ -101,15 +101,15 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) if (!dbi->dc || !full || swap || fb->format->format == DRM_FORMAT_XRGB8888) { - tr = mipi->tx_buf; - ret = mipi_dbi_buf_copy(mipi->tx_buf, fb, rect, swap); + tr = dbidev->tx_buf; + ret = mipi_dbi_buf_copy(dbidev->tx_buf, fb, rect, swap); if (ret) goto err_msg; } else { tr = cma_obj->vaddr; } - switch (mipi->rotation) { + switch (dbidev->rotation) { default: x1 = rect->x1; x2 = rect->x2 - 1; @@ -183,10 +183,10 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); struct drm_framebuffer *fb = plane_state->fb; struct device *dev = pipe->crtc.dev->dev; - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbi = dbidev; struct drm_rect rect = { .x1 = 0, .x2 = fb->width, @@ -233,7 +233,7 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, msleep(50); - switch (mipi->rotation) { + switch (dbidev->rotation) { default: am_id = 0x30; break; @@ -283,7 +283,7 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x1017); - mipi->enabled = true; + dbidev->enabled = true; ili9225_fb_dirty(fb, &rect); out_exit: drm_dev_exit(idx); @@ -291,8 +291,8 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = dbidev; DRM_DEBUG_KMS("\n"); @@ -303,7 +303,7 @@ static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe) * unplug. */ - if (!mipi->enabled) + if (!dbidev->enabled) return; ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x0000); @@ -312,7 +312,7 @@ static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe) msleep(50); ili9225_command(dbi, ILI9225_POWER_CONTROL_1, 0x0a02); - mipi->enabled = false; + dbidev->enabled = false; } static int ili9225_dbi_command(struct mipi_dbi *dbi, u8 *cmd, u8 *par, @@ -378,22 +378,22 @@ MODULE_DEVICE_TABLE(spi, ili9225_id); static int ili9225_probe(struct spi_device *spi) { struct device *dev = &spi->dev; + struct mipi_dbi *dbidev; struct drm_device *drm; - struct mipi_dbi *mipi; struct mipi_dbi *dbi; struct gpio_desc *rs; u32 rotation = 0; int ret; - mipi = kzalloc(sizeof(*mipi), GFP_KERNEL); - if (!mipi) + dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL); + if (!dbidev) return -ENOMEM; - dbi = mipi; - drm = &mipi->drm; + dbi = dbidev; + drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &ili9225_driver); if (ret) { - kfree(mipi); + kfree(dbidev); return ret; } @@ -420,7 +420,7 @@ static int ili9225_probe(struct spi_device *spi) /* override the command function set in mipi_dbi_spi_init() */ dbi->command = ili9225_dbi_command; - ret = mipi_dbi_init(mipi, &ili9225_pipe_funcs, &ili9225_mode, rotation); + ret = mipi_dbi_init(dbidev, &ili9225_pipe_funcs, &ili9225_mode, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/ili9341.c b/drivers/gpu/drm/tinydrm/ili9341.c index 05ba5ab17ec6..dfa8c6e952c8 100644 --- a/drivers/gpu/drm/tinydrm/ili9341.c +++ b/drivers/gpu/drm/tinydrm/ili9341.c @@ -53,8 +53,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = dbidev; u8 addr_mode; int ret, idx; @@ -63,7 +63,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, DRM_DEBUG_KMS("\n"); - ret = mipi_dbi_poweron_conditional_reset(mipi); + ret = mipi_dbi_poweron_conditional_reset(dbidev); if (ret < 0) goto out_exit; if (ret == 1) @@ -113,7 +113,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, msleep(100); out_enable: - switch (mipi->rotation) { + switch (dbidev->rotation) { default: addr_mode = ILI9341_MADCTL_MX; break; @@ -130,7 +130,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, } addr_mode |= ILI9341_MADCTL_BGR; mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); - mipi_dbi_enable_flush(mipi, crtc_state, plane_state); + mipi_dbi_enable_flush(dbidev, crtc_state, plane_state); out_exit: drm_dev_exit(idx); } @@ -176,22 +176,22 @@ MODULE_DEVICE_TABLE(spi, ili9341_id); static int ili9341_probe(struct spi_device *spi) { struct device *dev = &spi->dev; + struct mipi_dbi *dbidev; struct drm_device *drm; - struct mipi_dbi *mipi; struct mipi_dbi *dbi; struct gpio_desc *dc; u32 rotation = 0; int ret; - mipi = kzalloc(sizeof(*mipi), GFP_KERNEL); - if (!mipi) + dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL); + if (!dbidev) return -ENOMEM; - dbi = mipi; - drm = &mipi->drm; + dbi = dbidev; + drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &ili9341_driver); if (ret) { - kfree(mipi); + kfree(dbidev); return ret; } @@ -209,9 +209,9 @@ static int ili9341_probe(struct spi_device *spi) return PTR_ERR(dc); } - mipi->backlight = devm_of_find_backlight(dev); - if (IS_ERR(mipi->backlight)) - return PTR_ERR(mipi->backlight); + dbidev->backlight = devm_of_find_backlight(dev); + if (IS_ERR(dbidev->backlight)) + return PTR_ERR(dbidev->backlight); device_property_read_u32(dev, "rotation", &rotation); @@ -219,7 +219,7 @@ static int ili9341_probe(struct spi_device *spi) if (ret) return ret; - ret = mipi_dbi_init(mipi, &ili9341_pipe_funcs, &yx240qv29_mode, rotation); + ret = mipi_dbi_init(dbidev, &ili9341_pipe_funcs, &yx240qv29_mode, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c b/drivers/gpu/drm/tinydrm/mi0283qt.c index adc8c4872d3f..9d284fb24c36 100644 --- a/drivers/gpu/drm/tinydrm/mi0283qt.c +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c @@ -51,8 +51,8 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = dbidev; u8 addr_mode; int ret, idx; @@ -61,7 +61,7 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, DRM_DEBUG_KMS("\n"); - ret = mipi_dbi_poweron_conditional_reset(mipi); + ret = mipi_dbi_poweron_conditional_reset(dbidev); if (ret < 0) goto out_exit; if (ret == 1) @@ -117,7 +117,7 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, * As a result, we need to always apply the rotation value * regardless of the display "on/off" state. */ - switch (mipi->rotation) { + switch (dbidev->rotation) { default: addr_mode = ILI9341_MADCTL_MV | ILI9341_MADCTL_MY | ILI9341_MADCTL_MX; @@ -134,7 +134,7 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, } addr_mode |= ILI9341_MADCTL_BGR; mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); - mipi_dbi_enable_flush(mipi, crtc_state, plane_state); + mipi_dbi_enable_flush(dbidev, crtc_state, plane_state); out_exit: drm_dev_exit(idx); } @@ -180,22 +180,22 @@ MODULE_DEVICE_TABLE(spi, mi0283qt_id); static int mi0283qt_probe(struct spi_device *spi) { struct device *dev = &spi->dev; + struct mipi_dbi *dbidev; struct drm_device *drm; - struct mipi_dbi *mipi; struct mipi_dbi *dbi; struct gpio_desc *dc; u32 rotation = 0; int ret; - mipi = kzalloc(sizeof(*mipi), GFP_KERNEL); - if (!mipi) + dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL); + if (!dbidev) return -ENOMEM; - dbi = mipi; - drm = &mipi->drm; + dbi = dbidev; + drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &mi0283qt_driver); if (ret) { - kfree(mipi); + kfree(dbidev); return ret; } @@ -213,13 +213,13 @@ static int mi0283qt_probe(struct spi_device *spi) return PTR_ERR(dc); } - mipi->regulator = devm_regulator_get(dev, "power"); - if (IS_ERR(mipi->regulator)) - return PTR_ERR(mipi->regulator); + dbidev->regulator = devm_regulator_get(dev, "power"); + if (IS_ERR(dbidev->regulator)) + return PTR_ERR(dbidev->regulator); - mipi->backlight = devm_of_find_backlight(dev); - if (IS_ERR(mipi->backlight)) - return PTR_ERR(mipi->backlight); + dbidev->backlight = devm_of_find_backlight(dev); + if (IS_ERR(dbidev->backlight)) + return PTR_ERR(dbidev->backlight); device_property_read_u32(dev, "rotation", &rotation); @@ -227,7 +227,7 @@ static int mi0283qt_probe(struct spi_device *spi) if (ret) return ret; - ret = mipi_dbi_init(mipi, &mi0283qt_pipe_funcs, &mi0283qt_mode, rotation); + ret = mipi_dbi_init(dbidev, &mi0283qt_pipe_funcs, &mi0283qt_mode, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index 93b9b3ac5568..95b032a4b34b 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -241,16 +241,16 @@ EXPORT_SYMBOL(mipi_dbi_buf_copy); static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) { struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0); - struct mipi_dbi *mipi = drm_to_mipi_dbi(fb->dev); + struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev); unsigned int height = rect->y2 - rect->y1; unsigned int width = rect->x2 - rect->x1; - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbi = dbidev; bool swap = dbi->swap_bytes; int idx, ret = 0; bool full; void *tr; - if (!mipi->enabled) + if (!dbidev->enabled) return; if (!drm_dev_enter(fb->dev, &idx)) @@ -262,8 +262,8 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) if (!dbi->dc || !full || swap || fb->format->format == DRM_FORMAT_XRGB8888) { - tr = mipi->tx_buf; - ret = mipi_dbi_buf_copy(mipi->tx_buf, fb, rect, swap); + tr = dbidev->tx_buf; + ret = mipi_dbi_buf_copy(dbidev->tx_buf, fb, rect, swap); if (ret) goto err_msg; } else { @@ -315,7 +315,7 @@ EXPORT_SYMBOL(mipi_dbi_pipe_update); /** * mipi_dbi_enable_flush - MIPI DBI enable helper - * @mipi: MIPI DBI structure + * @dbidev: MIPI DBI device structure * @crtc_state: CRTC state * @plane_state: Plane state * @@ -327,7 +327,7 @@ EXPORT_SYMBOL(mipi_dbi_pipe_update); * framebuffer flushing, can't use this function since they both use the same * flushing code. */ -void mipi_dbi_enable_flush(struct mipi_dbi *mipi, +void mipi_dbi_enable_flush(struct mipi_dbi *dbidev, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { @@ -340,37 +340,37 @@ void mipi_dbi_enable_flush(struct mipi_dbi *mipi, }; int idx; - if (!drm_dev_enter(&mipi->drm, &idx)) + if (!drm_dev_enter(&dbidev->drm, &idx)) return; - mipi->enabled = true; + dbidev->enabled = true; mipi_dbi_fb_dirty(fb, &rect); - backlight_enable(mipi->backlight); + backlight_enable(dbidev->backlight); drm_dev_exit(idx); } EXPORT_SYMBOL(mipi_dbi_enable_flush); -static void mipi_dbi_blank(struct mipi_dbi *mipi) +static void mipi_dbi_blank(struct mipi_dbi *dbidev) { - struct drm_device *drm = &mipi->drm; + struct drm_device *drm = &dbidev->drm; u16 height = drm->mode_config.min_height; u16 width = drm->mode_config.min_width; size_t len = width * height * 2; - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbi = dbidev; int idx; if (!drm_dev_enter(drm, &idx)) return; - memset(mipi->tx_buf, 0, len); + memset(dbidev->tx_buf, 0, len); mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, 0, 0, (width >> 8) & 0xFF, (width - 1) & 0xFF); mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, 0, 0, (height >> 8) & 0xFF, (height - 1) & 0xFF); mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, - (u8 *)mipi->tx_buf, len); + (u8 *)dbidev->tx_buf, len); drm_dev_exit(idx); } @@ -385,31 +385,31 @@ static void mipi_dbi_blank(struct mipi_dbi *mipi) */ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); - if (!mipi->enabled) + if (!dbidev->enabled) return; DRM_DEBUG_KMS("\n"); - mipi->enabled = false; + dbidev->enabled = false; - if (mipi->backlight) - backlight_disable(mipi->backlight); + if (dbidev->backlight) + backlight_disable(dbidev->backlight); else - mipi_dbi_blank(mipi); + mipi_dbi_blank(dbidev); - if (mipi->regulator) - regulator_disable(mipi->regulator); + if (dbidev->regulator) + regulator_disable(dbidev->regulator); } EXPORT_SYMBOL(mipi_dbi_pipe_disable); static int mipi_dbi_connector_get_modes(struct drm_connector *connector) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(connector->dev); + struct mipi_dbi *dbidev = drm_to_mipi_dbi(connector->dev); struct drm_display_mode *mode; - mode = drm_mode_duplicate(connector->dev, &mipi->mode); + mode = drm_mode_duplicate(connector->dev, &dbidev->mode); if (!mode) { DRM_ERROR("Failed to duplicate mode\n"); return 0; @@ -471,7 +471,7 @@ static const uint32_t mipi_dbi_formats[] = { /** * mipi_dbi_init_with_formats - MIPI DBI initialization with custom formats - * @mipi: &mipi_dbi structure to initialize + * @dbidev: MIPI DBI device structure to initialize * @funcs: Display pipe functions * @formats: Array of supported formats (DRM_FORMAT\_\*). * @format_count: Number of elements in @formats @@ -492,7 +492,7 @@ static const uint32_t mipi_dbi_formats[] = { * Returns: * Zero on success, negative error code on failure. */ -int mipi_dbi_init_with_formats(struct mipi_dbi *mipi, +int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev, const struct drm_simple_display_pipe_funcs *funcs, const uint32_t *formats, unsigned int format_count, const struct drm_display_mode *mode, @@ -502,42 +502,42 @@ int mipi_dbi_init_with_formats(struct mipi_dbi *mipi, DRM_FORMAT_MOD_LINEAR, DRM_FORMAT_MOD_INVALID }; - struct drm_device *drm = &mipi->drm; + struct drm_device *drm = &dbidev->drm; int ret; - if (!mipi->command) + if (!dbidev->command) return -EINVAL; - mipi->tx_buf = devm_kmalloc(drm->dev, tx_buf_size, GFP_KERNEL); - if (!mipi->tx_buf) + dbidev->tx_buf = devm_kmalloc(drm->dev, tx_buf_size, GFP_KERNEL); + if (!dbidev->tx_buf) return -ENOMEM; - drm_mode_copy(&mipi->mode, mode); - ret = mipi_dbi_rotate_mode(&mipi->mode, rotation); + drm_mode_copy(&dbidev->mode, mode); + ret = mipi_dbi_rotate_mode(&dbidev->mode, rotation); if (ret) { DRM_ERROR("Illegal rotation value %u\n", rotation); return -EINVAL; } - drm_connector_helper_add(&mipi->connector, &mipi_dbi_connector_hfuncs); - ret = drm_connector_init(drm, &mipi->connector, &mipi_dbi_connector_funcs, + drm_connector_helper_add(&dbidev->connector, &mipi_dbi_connector_hfuncs); + ret = drm_connector_init(drm, &dbidev->connector, &mipi_dbi_connector_funcs, DRM_MODE_CONNECTOR_SPI); if (ret) return ret; - ret = drm_simple_display_pipe_init(drm, &mipi->pipe, funcs, formats, format_count, - modifiers, &mipi->connector); + ret = drm_simple_display_pipe_init(drm, &dbidev->pipe, funcs, formats, format_count, + modifiers, &dbidev->connector); if (ret) return ret; - drm_plane_enable_fb_damage_clips(&mipi->pipe.plane); + drm_plane_enable_fb_damage_clips(&dbidev->pipe.plane); drm->mode_config.funcs = &mipi_dbi_mode_config_funcs; - drm->mode_config.min_width = mipi->mode.hdisplay; - drm->mode_config.max_width = mipi->mode.hdisplay; - drm->mode_config.min_height = mipi->mode.vdisplay; - drm->mode_config.max_height = mipi->mode.vdisplay; - mipi->rotation = rotation; + drm->mode_config.min_width = dbidev->mode.hdisplay; + drm->mode_config.max_width = dbidev->mode.hdisplay; + drm->mode_config.min_height = dbidev->mode.vdisplay; + drm->mode_config.max_height = dbidev->mode.vdisplay; + dbidev->rotation = rotation; DRM_DEBUG_KMS("rotation = %u\n", rotation); @@ -547,7 +547,7 @@ EXPORT_SYMBOL(mipi_dbi_init_with_formats); /** * mipi_dbi_init - MIPI DBI initialization - * @mipi: &mipi_dbi structure to initialize + * @dbidev: MIPI DBI device structure to initialize * @funcs: Display pipe functions * @mode: Display mode * @rotation: Initial rotation in degrees Counter Clock Wise @@ -562,15 +562,15 @@ EXPORT_SYMBOL(mipi_dbi_init_with_formats); * Returns: * Zero on success, negative error code on failure. */ -int mipi_dbi_init(struct mipi_dbi *mipi, +int mipi_dbi_init(struct mipi_dbi *dbidev, const struct drm_simple_display_pipe_funcs *funcs, const struct drm_display_mode *mode, unsigned int rotation) { size_t bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16); - mipi->drm.mode_config.preferred_depth = 16; + dbidev->drm.mode_config.preferred_depth = 16; - return mipi_dbi_init_with_formats(mipi, funcs, mipi_dbi_formats, + return mipi_dbi_init_with_formats(dbidev, funcs, mipi_dbi_formats, ARRAY_SIZE(mipi_dbi_formats), mode, rotation, bufsize); } @@ -646,14 +646,14 @@ bool mipi_dbi_display_is_on(struct mipi_dbi *dbi) } EXPORT_SYMBOL(mipi_dbi_display_is_on); -static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *mipi, bool cond) +static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *dbidev, bool cond) { - struct device *dev = mipi->drm.dev; - struct mipi_dbi *dbi = mipi; + struct device *dev = dbidev->drm.dev; + struct mipi_dbi *dbi = dbidev; int ret; - if (mipi->regulator) { - ret = regulator_enable(mipi->regulator); + if (dbidev->regulator) { + ret = regulator_enable(dbidev->regulator); if (ret) { DRM_DEV_ERROR(dev, "Failed to enable regulator (%d)\n", ret); return ret; @@ -667,8 +667,8 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *mipi, bool cond) ret = mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET); if (ret) { DRM_DEV_ERROR(dev, "Failed to send reset command (%d)\n", ret); - if (mipi->regulator) - regulator_disable(mipi->regulator); + if (dbidev->regulator) + regulator_disable(dbidev->regulator); return ret; } @@ -687,7 +687,7 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *mipi, bool cond) /** * mipi_dbi_poweron_reset - MIPI DBI poweron and reset - * @mipi: MIPI DBI structure + * @dbidev: MIPI DBI device structure * * This function enables the regulator if used and does a hardware and software * reset. @@ -695,15 +695,15 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *mipi, bool cond) * Returns: * Zero on success, or a negative error code. */ -int mipi_dbi_poweron_reset(struct mipi_dbi *mipi) +int mipi_dbi_poweron_reset(struct mipi_dbi *dbidev) { - return mipi_dbi_poweron_reset_conditional(mipi, false); + return mipi_dbi_poweron_reset_conditional(dbidev, false); } EXPORT_SYMBOL(mipi_dbi_poweron_reset); /** * mipi_dbi_poweron_conditional_reset - MIPI DBI poweron and conditional reset - * @mipi: MIPI DBI structure + * @dbidev: MIPI DBI device structure * * This function enables the regulator if used and if the display is off, it * does a hardware and software reset. If mipi_dbi_display_is_on() determines @@ -713,9 +713,9 @@ EXPORT_SYMBOL(mipi_dbi_poweron_reset); * Zero if the controller was reset, 1 if the display was already on, or a * negative error code. */ -int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *mipi) +int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *dbidev) { - return mipi_dbi_poweron_reset_conditional(mipi, true); + return mipi_dbi_poweron_reset_conditional(dbidev, true); } EXPORT_SYMBOL(mipi_dbi_poweron_conditional_reset); diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c index 8339e7dc5d92..cf0d7a26009c 100644 --- a/drivers/gpu/drm/tinydrm/st7586.c +++ b/drivers/gpu/drm/tinydrm/st7586.c @@ -114,11 +114,11 @@ static int st7586_buf_copy(void *dst, struct drm_framebuffer *fb, static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(fb->dev); - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev); + struct mipi_dbi *dbi = dbidev; int start, end, idx, ret = 0; - if (!mipi->enabled) + if (!dbidev->enabled) return; if (!drm_dev_enter(fb->dev, &idx)) @@ -130,7 +130,7 @@ static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, DRM_RECT_ARG(rect)); - ret = st7586_buf_copy(mipi->tx_buf, fb, rect); + ret = st7586_buf_copy(dbidev->tx_buf, fb, rect); if (ret) goto err_msg; @@ -146,7 +146,7 @@ static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) (rect->y2 >> 8) & 0xFF, (rect->y2 - 1) & 0xFF); ret = mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, - (u8 *)mipi->tx_buf, + (u8 *)dbidev->tx_buf, (end - start) * (rect->y2 - rect->y1)); err_msg: if (ret) @@ -177,9 +177,9 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); struct drm_framebuffer *fb = plane_state->fb; - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbi = dbidev; struct drm_rect rect = { .x1 = 0, .x2 = fb->width, @@ -194,7 +194,7 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, DRM_DEBUG_KMS("\n"); - ret = mipi_dbi_poweron_reset(mipi); + ret = mipi_dbi_poweron_reset(dbidev); if (ret) goto out_exit; @@ -222,7 +222,7 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, mipi_dbi_command(dbi, ST7586_DISP_MODE_GRAY); mipi_dbi_command(dbi, ST7586_ENABLE_DDRAM, 0x02); - switch (mipi->rotation) { + switch (dbidev->rotation) { default: addr_mode = 0x00; break; @@ -245,7 +245,7 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, msleep(100); - mipi->enabled = true; + dbidev->enabled = true; st7586_fb_dirty(fb, &rect); mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); @@ -318,23 +318,23 @@ MODULE_DEVICE_TABLE(spi, st7586_id); static int st7586_probe(struct spi_device *spi) { struct device *dev = &spi->dev; + struct mipi_dbi *dbidev; struct drm_device *drm; - struct mipi_dbi *mipi; struct mipi_dbi *dbi; struct gpio_desc *a0; u32 rotation = 0; size_t bufsize; int ret; - mipi = kzalloc(sizeof(*mipi), GFP_KERNEL); - if (!mipi) + dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL); + if (!dbidev) return -ENOMEM; - dbi = mipi; - drm = &mipi->drm; + dbi = dbidev; + drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &st7586_driver); if (ret) { - kfree(mipi); + kfree(dbidev); return ret; } @@ -363,7 +363,7 @@ static int st7586_probe(struct spi_device *spi) /* Cannot read from this controller via SPI */ dbi->read_commands = NULL; - ret = mipi_dbi_init_with_formats(mipi, &st7586_pipe_funcs, + ret = mipi_dbi_init_with_formats(dbidev, &st7586_pipe_funcs, st7586_formats, ARRAY_SIZE(st7586_formats), &st7586_mode, rotation, bufsize); if (ret) diff --git a/drivers/gpu/drm/tinydrm/st7735r.c b/drivers/gpu/drm/tinydrm/st7735r.c index 4309ae299766..5b23657659c6 100644 --- a/drivers/gpu/drm/tinydrm/st7735r.c +++ b/drivers/gpu/drm/tinydrm/st7735r.c @@ -42,8 +42,8 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = mipi; + struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi *dbi = dbidev; int ret, idx; u8 addr_mode; @@ -52,7 +52,7 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, DRM_DEBUG_KMS("\n"); - ret = mipi_dbi_poweron_reset(mipi); + ret = mipi_dbi_poweron_reset(dbidev); if (ret) goto out_exit; @@ -73,7 +73,7 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, mipi_dbi_command(dbi, ST7735R_PWCTR5, 0x8a, 0xee); mipi_dbi_command(dbi, ST7735R_VMCTR1, 0x0e); mipi_dbi_command(dbi, MIPI_DCS_EXIT_INVERT_MODE); - switch (mipi->rotation) { + switch (dbidev->rotation) { default: addr_mode = ST7735R_MX | ST7735R_MY; break; @@ -104,7 +104,7 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, msleep(20); - mipi_dbi_enable_flush(mipi, crtc_state, plane_state); + mipi_dbi_enable_flush(dbidev, crtc_state, plane_state); out_exit: drm_dev_exit(idx); } @@ -150,22 +150,22 @@ MODULE_DEVICE_TABLE(spi, st7735r_id); static int st7735r_probe(struct spi_device *spi) { struct device *dev = &spi->dev; + struct mipi_dbi *dbidev; struct drm_device *drm; - struct mipi_dbi *mipi; struct mipi_dbi *dbi; struct gpio_desc *dc; u32 rotation = 0; int ret; - mipi = kzalloc(sizeof(*mipi), GFP_KERNEL); - if (!mipi) + dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL); + if (!dbidev) return -ENOMEM; - dbi = mipi; - drm = &mipi->drm; + dbi = dbidev; + drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &st7735r_driver); if (ret) { - kfree(mipi); + kfree(dbidev); return ret; } @@ -183,9 +183,9 @@ static int st7735r_probe(struct spi_device *spi) return PTR_ERR(dc); } - mipi->backlight = devm_of_find_backlight(dev); - if (IS_ERR(mipi->backlight)) - return PTR_ERR(mipi->backlight); + dbidev->backlight = devm_of_find_backlight(dev); + if (IS_ERR(dbidev->backlight)) + return PTR_ERR(dbidev->backlight); device_property_read_u32(dev, "rotation", &rotation); @@ -196,7 +196,7 @@ static int st7735r_probe(struct spi_device *spi) /* Cannot read from Adafruit 1.8" display via SPI */ dbi->read_commands = NULL; - ret = mipi_dbi_init(mipi, &jd_t18003_t01_pipe_funcs, &jd_t18003_t01_mode, rotation); + ret = mipi_dbi_init(dbidev, &jd_t18003_t01_pipe_funcs, &jd_t18003_t01_mode, rotation); if (ret) return ret; diff --git a/include/drm/tinydrm/mipi-dbi.h b/include/drm/tinydrm/mipi-dbi.h index 04b54ec61bc2..b7b301130af7 100644 --- a/include/drm/tinydrm/mipi-dbi.h +++ b/include/drm/tinydrm/mipi-dbi.h @@ -79,25 +79,25 @@ static inline struct mipi_dbi *drm_to_mipi_dbi(struct drm_device *drm) int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi, struct gpio_desc *dc); -int mipi_dbi_init_with_formats(struct mipi_dbi *mipi, +int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev, const struct drm_simple_display_pipe_funcs *funcs, const uint32_t *formats, unsigned int format_count, const struct drm_display_mode *mode, unsigned int rotation, size_t tx_buf_size); -int mipi_dbi_init(struct mipi_dbi *mipi, +int mipi_dbi_init(struct mipi_dbi *dbidev, const struct drm_simple_display_pipe_funcs *funcs, const struct drm_display_mode *mode, unsigned int 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); -void mipi_dbi_enable_flush(struct mipi_dbi *mipi, +void mipi_dbi_enable_flush(struct mipi_dbi *dbidev, struct drm_crtc_state *crtc_state, struct drm_plane_state *plan_state); void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe); void mipi_dbi_hw_reset(struct mipi_dbi *dbi); bool mipi_dbi_display_is_on(struct mipi_dbi *dbi); -int mipi_dbi_poweron_reset(struct mipi_dbi *mipi); -int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *mipi); +int mipi_dbi_poweron_reset(struct mipi_dbi *dbidev); +int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *dbidev); u32 mipi_dbi_spi_cmd_max_speed(struct spi_device *spi, size_t len); int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, From patchwork Mon Jul 22 10:43:07 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: 11052127 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 68FA8138D for ; Mon, 22 Jul 2019 10:43:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 562A028500 for ; Mon, 22 Jul 2019 10:43:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A8592851B; Mon, 22 Jul 2019 10:43:36 +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 D697328500 for ; Mon, 22 Jul 2019 10:43:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63CC289BF8; Mon, 22 Jul 2019 10:43:29 +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 E3F1A89A77 for ; Mon, 22 Jul 2019 10:43:26 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:55388 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 1hpVmv-0001lD-1d; Mon, 22 Jul 2019 12:43:25 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 4/9] drm/tinydrm: Split struct mipi_dbi in two Date: Mon, 22 Jul 2019 12:43:07 +0200 Message-Id: <20190722104312.16184-5-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722104312.16184-1-noralf@tronnes.org> References: <20190722104312.16184-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=HIg52yJYwXfDtqqHm8Y5RESKbIcZJtsTIxAHUfF72Ig=; b=mOGp1bXnCM8W7C2t6sfl87xTqaBb8AxzOUXOtri8t6hL6I46iwVyUzxoQ23V7AD1yybgQH5wziVMRYY9l7sHPdikjUA9sno8t7H7i0i/6C0BaWI7mV5mWeVH/AKKm6o5bhsHswZvCR19C6Jbq2wWjMEUlUea+P4Bz/L44S0ekartKBaY32g03KzshMIC25wsEH/5Sal0lg5cH6wfP/H3jmHEno6uECW5YCpLNoS58VR5m28cLJgE7f6+idS5UvA8BlqL/GBj2q97PXOlBsL3OZO6UNTBKcFxQtx4HXSkUf8TdhTVTb7Qix29bqCosgjQXiDFgldO7d3Fxem4W2HgnA==; 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: sam@ravnborg.org, david@lechnology.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Split struct mipi_dbi into an interface part and a display pipeline part. The interface part can be used by drivers that need to initialize the controller, but that won't upload the framebuffer over this interface. MIPI DBI supports 3 interface types: - A. Motorola 6800 type parallel bus - B. Intel 8080 type parallel bus - C. SPI type with 3 options: I've embedded the SPI type specifics in the mipi_dbi struct to avoid adding unnecessary complexity. If more interface types will be supported in the future, the type specifics might have to be split out. Rename functions to match the new struct mipi_dbi_dev: - drm_to_mipi_dbi() -> drm_to_mipi_dbi_dev(). - mipi_dbi_init*() -> mipi_dbi_dev_init*(). Cc: Eric Anholt Cc: David Lechner Reviewed-by: Sam Ravnborg Signed-off-by: Noralf Trønnes Acked-by: David Lechner --- drivers/gpu/drm/tinydrm/hx8357d.c | 10 +-- drivers/gpu/drm/tinydrm/ili9225.c | 18 ++-- drivers/gpu/drm/tinydrm/ili9341.c | 10 +-- drivers/gpu/drm/tinydrm/mi0283qt.c | 10 +-- drivers/gpu/drm/tinydrm/mipi-dbi.c | 83 ++++++++++--------- drivers/gpu/drm/tinydrm/st7586.c | 26 +++--- drivers/gpu/drm/tinydrm/st7735r.c | 10 +-- include/drm/tinydrm/mipi-dbi.h | 129 ++++++++++++++++++++--------- 8 files changed, 175 insertions(+), 121 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c b/drivers/gpu/drm/tinydrm/hx8357d.c index e113c434ff55..471e545154b3 100644 --- a/drivers/gpu/drm/tinydrm/hx8357d.c +++ b/drivers/gpu/drm/tinydrm/hx8357d.c @@ -47,8 +47,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); + struct mipi_dbi *dbi = &dbidev->dbi; u8 addr_mode; int ret, idx; @@ -220,7 +220,7 @@ MODULE_DEVICE_TABLE(spi, hx8357d_id); static int hx8357d_probe(struct spi_device *spi) { struct device *dev = &spi->dev; - struct mipi_dbi *dbidev; + struct mipi_dbi_dev *dbidev; struct drm_device *drm; struct gpio_desc *dc; u32 rotation = 0; @@ -251,11 +251,11 @@ static int hx8357d_probe(struct spi_device *spi) device_property_read_u32(dev, "rotation", &rotation); - ret = mipi_dbi_spi_init(spi, dbidev, dc); + ret = mipi_dbi_spi_init(spi, &dbidev->dbi, dc); if (ret) return ret; - ret = mipi_dbi_init(dbidev, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation); + ret = mipi_dbi_dev_init(dbidev, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/ili9225.c b/drivers/gpu/drm/tinydrm/ili9225.c index 209a75dab7ce..33766fc21b2b 100644 --- a/drivers/gpu/drm/tinydrm/ili9225.c +++ b/drivers/gpu/drm/tinydrm/ili9225.c @@ -78,10 +78,10 @@ static inline int ili9225_command(struct mipi_dbi *dbi, u8 cmd, u16 data) static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) { struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0); - struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev); unsigned int height = rect->y2 - rect->y1; unsigned int width = rect->x2 - rect->x1; - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi *dbi = &dbidev->dbi; bool swap = dbi->swap_bytes; u16 x_start, y_start; u16 x1, x2, y1, y2; @@ -183,10 +183,10 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); struct drm_framebuffer *fb = plane_state->fb; struct device *dev = pipe->crtc.dev->dev; - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi *dbi = &dbidev->dbi; struct drm_rect rect = { .x1 = 0, .x2 = fb->width, @@ -291,8 +291,8 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); + struct mipi_dbi *dbi = &dbidev->dbi; DRM_DEBUG_KMS("\n"); @@ -378,7 +378,7 @@ MODULE_DEVICE_TABLE(spi, ili9225_id); static int ili9225_probe(struct spi_device *spi) { struct device *dev = &spi->dev; - struct mipi_dbi *dbidev; + struct mipi_dbi_dev *dbidev; struct drm_device *drm; struct mipi_dbi *dbi; struct gpio_desc *rs; @@ -389,7 +389,7 @@ static int ili9225_probe(struct spi_device *spi) if (!dbidev) return -ENOMEM; - dbi = dbidev; + dbi = &dbidev->dbi; drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &ili9225_driver); if (ret) { @@ -420,7 +420,7 @@ static int ili9225_probe(struct spi_device *spi) /* override the command function set in mipi_dbi_spi_init() */ dbi->command = ili9225_dbi_command; - ret = mipi_dbi_init(dbidev, &ili9225_pipe_funcs, &ili9225_mode, rotation); + ret = mipi_dbi_dev_init(dbidev, &ili9225_pipe_funcs, &ili9225_mode, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/ili9341.c b/drivers/gpu/drm/tinydrm/ili9341.c index dfa8c6e952c8..71af275522a5 100644 --- a/drivers/gpu/drm/tinydrm/ili9341.c +++ b/drivers/gpu/drm/tinydrm/ili9341.c @@ -53,8 +53,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); + struct mipi_dbi *dbi = &dbidev->dbi; u8 addr_mode; int ret, idx; @@ -176,7 +176,7 @@ MODULE_DEVICE_TABLE(spi, ili9341_id); static int ili9341_probe(struct spi_device *spi) { struct device *dev = &spi->dev; - struct mipi_dbi *dbidev; + struct mipi_dbi_dev *dbidev; struct drm_device *drm; struct mipi_dbi *dbi; struct gpio_desc *dc; @@ -187,7 +187,7 @@ static int ili9341_probe(struct spi_device *spi) if (!dbidev) return -ENOMEM; - dbi = dbidev; + dbi = &dbidev->dbi; drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &ili9341_driver); if (ret) { @@ -219,7 +219,7 @@ static int ili9341_probe(struct spi_device *spi) if (ret) return ret; - ret = mipi_dbi_init(dbidev, &ili9341_pipe_funcs, &yx240qv29_mode, rotation); + ret = mipi_dbi_dev_init(dbidev, &ili9341_pipe_funcs, &yx240qv29_mode, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c b/drivers/gpu/drm/tinydrm/mi0283qt.c index 9d284fb24c36..7925f69bc502 100644 --- a/drivers/gpu/drm/tinydrm/mi0283qt.c +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c @@ -51,8 +51,8 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); + struct mipi_dbi *dbi = &dbidev->dbi; u8 addr_mode; int ret, idx; @@ -180,7 +180,7 @@ MODULE_DEVICE_TABLE(spi, mi0283qt_id); static int mi0283qt_probe(struct spi_device *spi) { struct device *dev = &spi->dev; - struct mipi_dbi *dbidev; + struct mipi_dbi_dev *dbidev; struct drm_device *drm; struct mipi_dbi *dbi; struct gpio_desc *dc; @@ -191,7 +191,7 @@ static int mi0283qt_probe(struct spi_device *spi) if (!dbidev) return -ENOMEM; - dbi = dbidev; + dbi = &dbidev->dbi; drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &mi0283qt_driver); if (ret) { @@ -227,7 +227,7 @@ static int mi0283qt_probe(struct spi_device *spi) if (ret) return ret; - ret = mipi_dbi_init(dbidev, &mi0283qt_pipe_funcs, &mi0283qt_mode, rotation); + ret = mipi_dbi_dev_init(dbidev, &mi0283qt_pipe_funcs, &mi0283qt_mode, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index 95b032a4b34b..1617784fef09 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -241,10 +241,10 @@ EXPORT_SYMBOL(mipi_dbi_buf_copy); static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) { struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0); - struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev); unsigned int height = rect->y2 - rect->y1; unsigned int width = rect->x2 - rect->x1; - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi *dbi = &dbidev->dbi; bool swap = dbi->swap_bytes; int idx, ret = 0; bool full; @@ -327,7 +327,7 @@ EXPORT_SYMBOL(mipi_dbi_pipe_update); * framebuffer flushing, can't use this function since they both use the same * flushing code. */ -void mipi_dbi_enable_flush(struct mipi_dbi *dbidev, +void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { @@ -351,13 +351,13 @@ void mipi_dbi_enable_flush(struct mipi_dbi *dbidev, } EXPORT_SYMBOL(mipi_dbi_enable_flush); -static void mipi_dbi_blank(struct mipi_dbi *dbidev) +static void mipi_dbi_blank(struct mipi_dbi_dev *dbidev) { struct drm_device *drm = &dbidev->drm; u16 height = drm->mode_config.min_height; u16 width = drm->mode_config.min_width; + struct mipi_dbi *dbi = &dbidev->dbi; size_t len = width * height * 2; - struct mipi_dbi *dbi = dbidev; int idx; if (!drm_dev_enter(drm, &idx)) @@ -385,7 +385,7 @@ static void mipi_dbi_blank(struct mipi_dbi *dbidev) */ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); if (!dbidev->enabled) return; @@ -406,7 +406,7 @@ EXPORT_SYMBOL(mipi_dbi_pipe_disable); static int mipi_dbi_connector_get_modes(struct drm_connector *connector) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(connector->dev); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(connector->dev); struct drm_display_mode *mode; mode = drm_mode_duplicate(connector->dev, &dbidev->mode); @@ -470,7 +470,7 @@ static const uint32_t mipi_dbi_formats[] = { }; /** - * mipi_dbi_init_with_formats - MIPI DBI initialization with custom formats + * mipi_dbi_dev_init_with_formats - MIPI DBI device initialization with custom formats * @dbidev: MIPI DBI device structure to initialize * @funcs: Display pipe functions * @formats: Array of supported formats (DRM_FORMAT\_\*). @@ -483,7 +483,7 @@ static const uint32_t mipi_dbi_formats[] = { * has one fixed &drm_display_mode which is rotated according to @rotation. * This mode is used to set the mode config min/max width/height properties. * - * Use mipi_dbi_init() if you don't need custom formats. + * Use mipi_dbi_dev_init() if you don't need custom formats. * * Note: * Some of the helper functions expects RGB565 to be the default format and the @@ -492,11 +492,11 @@ static const uint32_t mipi_dbi_formats[] = { * Returns: * Zero on success, negative error code on failure. */ -int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev, - const struct drm_simple_display_pipe_funcs *funcs, - const uint32_t *formats, unsigned int format_count, - const struct drm_display_mode *mode, - unsigned int rotation, size_t tx_buf_size) +int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev, + const struct drm_simple_display_pipe_funcs *funcs, + const uint32_t *formats, unsigned int format_count, + const struct drm_display_mode *mode, + unsigned int rotation, size_t tx_buf_size) { static const uint64_t modifiers[] = { DRM_FORMAT_MOD_LINEAR, @@ -505,7 +505,7 @@ int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev, struct drm_device *drm = &dbidev->drm; int ret; - if (!dbidev->command) + if (!dbidev->dbi.command) return -EINVAL; dbidev->tx_buf = devm_kmalloc(drm->dev, tx_buf_size, GFP_KERNEL); @@ -543,10 +543,10 @@ int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev, return 0; } -EXPORT_SYMBOL(mipi_dbi_init_with_formats); +EXPORT_SYMBOL(mipi_dbi_dev_init_with_formats); /** - * mipi_dbi_init - MIPI DBI initialization + * mipi_dbi_dev_init - MIPI DBI device initialization * @dbidev: MIPI DBI device structure to initialize * @funcs: Display pipe functions * @mode: Display mode @@ -562,19 +562,19 @@ EXPORT_SYMBOL(mipi_dbi_init_with_formats); * Returns: * Zero on success, negative error code on failure. */ -int mipi_dbi_init(struct mipi_dbi *dbidev, - const struct drm_simple_display_pipe_funcs *funcs, - const struct drm_display_mode *mode, unsigned int rotation) +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) { size_t bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16); dbidev->drm.mode_config.preferred_depth = 16; - return mipi_dbi_init_with_formats(dbidev, funcs, mipi_dbi_formats, - ARRAY_SIZE(mipi_dbi_formats), mode, - rotation, bufsize); + return mipi_dbi_dev_init_with_formats(dbidev, funcs, mipi_dbi_formats, + ARRAY_SIZE(mipi_dbi_formats), mode, + rotation, bufsize); } -EXPORT_SYMBOL(mipi_dbi_init); +EXPORT_SYMBOL(mipi_dbi_dev_init); /** * mipi_dbi_release - DRM driver release helper @@ -586,13 +586,13 @@ EXPORT_SYMBOL(mipi_dbi_init); */ void mipi_dbi_release(struct drm_device *drm) { - struct mipi_dbi *dbi = drm_to_mipi_dbi(drm); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(drm); DRM_DEBUG_DRIVER("\n"); drm_mode_config_cleanup(drm); drm_dev_fini(drm); - kfree(dbi); + kfree(dbidev); } EXPORT_SYMBOL(mipi_dbi_release); @@ -646,10 +646,10 @@ bool mipi_dbi_display_is_on(struct mipi_dbi *dbi) } EXPORT_SYMBOL(mipi_dbi_display_is_on); -static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *dbidev, bool cond) +static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi_dev *dbidev, bool cond) { struct device *dev = dbidev->drm.dev; - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi *dbi = &dbidev->dbi; int ret; if (dbidev->regulator) { @@ -695,7 +695,7 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *dbidev, bool cond * Returns: * Zero on success, or a negative error code. */ -int mipi_dbi_poweron_reset(struct mipi_dbi *dbidev) +int mipi_dbi_poweron_reset(struct mipi_dbi_dev *dbidev) { return mipi_dbi_poweron_reset_conditional(dbidev, false); } @@ -713,7 +713,7 @@ EXPORT_SYMBOL(mipi_dbi_poweron_reset); * Zero if the controller was reset, 1 if the display was already on, or a * negative error code. */ -int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *dbidev) +int mipi_dbi_poweron_conditional_reset(struct mipi_dbi_dev *dbidev) { return mipi_dbi_poweron_reset_conditional(dbidev, true); } @@ -1066,7 +1066,7 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *dbi, u8 *cmd, * @dc: D/C gpio (optional) * * This function sets &mipi_dbi->command, enables &mipi_dbi->read_commands for the - * usual read commands. It should be followed by a call to mipi_dbi_init() or + * usual read commands. It should be followed by a call to mipi_dbi_dev_init() or * a driver-specific init. * * If @dc is set, a Type C Option 3 interface is assumed, if not @@ -1183,13 +1183,13 @@ static ssize_t mipi_dbi_debugfs_command_write(struct file *file, size_t count, loff_t *ppos) { struct seq_file *m = file->private_data; - struct mipi_dbi *mipi = m->private; + struct mipi_dbi_dev *dbidev = m->private; u8 val, cmd = 0, parameters[64]; char *buf, *pos, *token; unsigned int i; int ret, idx; - if (!drm_dev_enter(&mipi->drm, &idx)) + if (!drm_dev_enter(&dbidev->drm, &idx)) return -ENODEV; buf = memdup_user_nul(ubuf, count); @@ -1228,7 +1228,7 @@ static ssize_t mipi_dbi_debugfs_command_write(struct file *file, } } - ret = mipi_dbi_command_buf(mipi, cmd, parameters, i); + ret = mipi_dbi_command_buf(&dbidev->dbi, cmd, parameters, i); err_free: kfree(buf); @@ -1240,16 +1240,17 @@ static ssize_t mipi_dbi_debugfs_command_write(struct file *file, static int mipi_dbi_debugfs_command_show(struct seq_file *m, void *unused) { - struct mipi_dbi *mipi = m->private; + struct mipi_dbi_dev *dbidev = m->private; + struct mipi_dbi *dbi = &dbidev->dbi; u8 cmd, val[4]; int ret, idx; size_t len; - if (!drm_dev_enter(&mipi->drm, &idx)) + if (!drm_dev_enter(&dbidev->drm, &idx)) return -ENODEV; for (cmd = 0; cmd < 255; cmd++) { - if (!mipi_dbi_command_is_read(mipi, cmd)) + if (!mipi_dbi_command_is_read(dbi, cmd)) continue; switch (cmd) { @@ -1269,7 +1270,7 @@ static int mipi_dbi_debugfs_command_show(struct seq_file *m, void *unused) } seq_printf(m, "%02x: ", cmd); - ret = mipi_dbi_command_buf(mipi, cmd, val, len); + ret = mipi_dbi_command_buf(dbi, cmd, val, len); if (ret) { seq_puts(m, "XX\n"); continue; @@ -1311,12 +1312,12 @@ static const struct file_operations mipi_dbi_debugfs_command_fops = { */ int mipi_dbi_debugfs_init(struct drm_minor *minor) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(minor->dev); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(minor->dev); umode_t mode = S_IFREG | S_IWUSR; - if (mipi->read_commands) + if (dbidev->dbi.read_commands) mode |= S_IRUGO; - debugfs_create_file("command", mode, minor->debugfs_root, mipi, + debugfs_create_file("command", mode, minor->debugfs_root, dbidev, &mipi_dbi_debugfs_command_fops); return 0; diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c index cf0d7a26009c..51871ee16ef6 100644 --- a/drivers/gpu/drm/tinydrm/st7586.c +++ b/drivers/gpu/drm/tinydrm/st7586.c @@ -114,8 +114,8 @@ static int st7586_buf_copy(void *dst, struct drm_framebuffer *fb, static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev); - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev); + struct mipi_dbi *dbi = &dbidev->dbi; int start, end, idx, ret = 0; if (!dbidev->enabled) @@ -177,9 +177,9 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); struct drm_framebuffer *fb = plane_state->fb; - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi *dbi = &dbidev->dbi; struct drm_rect rect = { .x1 = 0, .x2 = fb->width, @@ -255,7 +255,7 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, static void st7586_pipe_disable(struct drm_simple_display_pipe *pipe) { - struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev); + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); /* * This callback is not protected by drm_dev_enter/exit since we want to @@ -266,11 +266,11 @@ static void st7586_pipe_disable(struct drm_simple_display_pipe *pipe) DRM_DEBUG_KMS("\n"); - if (!mipi->enabled) + if (!dbidev->enabled) return; - mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF); - mipi->enabled = false; + mipi_dbi_command(&dbidev->dbi, MIPI_DCS_SET_DISPLAY_OFF); + dbidev->enabled = false; } static const u32 st7586_formats[] = { @@ -318,7 +318,7 @@ MODULE_DEVICE_TABLE(spi, st7586_id); static int st7586_probe(struct spi_device *spi) { struct device *dev = &spi->dev; - struct mipi_dbi *dbidev; + struct mipi_dbi_dev *dbidev; struct drm_device *drm; struct mipi_dbi *dbi; struct gpio_desc *a0; @@ -330,7 +330,7 @@ static int st7586_probe(struct spi_device *spi) if (!dbidev) return -ENOMEM; - dbi = dbidev; + dbi = &dbidev->dbi; drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &st7586_driver); if (ret) { @@ -363,9 +363,9 @@ static int st7586_probe(struct spi_device *spi) /* Cannot read from this controller via SPI */ dbi->read_commands = NULL; - ret = mipi_dbi_init_with_formats(dbidev, &st7586_pipe_funcs, - st7586_formats, ARRAY_SIZE(st7586_formats), - &st7586_mode, rotation, bufsize); + ret = mipi_dbi_dev_init_with_formats(dbidev, &st7586_pipe_funcs, + st7586_formats, ARRAY_SIZE(st7586_formats), + &st7586_mode, rotation, bufsize); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/st7735r.c b/drivers/gpu/drm/tinydrm/st7735r.c index 5b23657659c6..66275ef3a456 100644 --- a/drivers/gpu/drm/tinydrm/st7735r.c +++ b/drivers/gpu/drm/tinydrm/st7735r.c @@ -42,8 +42,8 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev); - struct mipi_dbi *dbi = dbidev; + struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); + struct mipi_dbi *dbi = &dbidev->dbi; int ret, idx; u8 addr_mode; @@ -150,7 +150,7 @@ MODULE_DEVICE_TABLE(spi, st7735r_id); static int st7735r_probe(struct spi_device *spi) { struct device *dev = &spi->dev; - struct mipi_dbi *dbidev; + struct mipi_dbi_dev *dbidev; struct drm_device *drm; struct mipi_dbi *dbi; struct gpio_desc *dc; @@ -161,7 +161,7 @@ static int st7735r_probe(struct spi_device *spi) if (!dbidev) return -ENOMEM; - dbi = dbidev; + dbi = &dbidev->dbi; drm = &dbidev->drm; ret = devm_drm_dev_init(dev, drm, &st7735r_driver); if (ret) { @@ -196,7 +196,7 @@ static int st7735r_probe(struct spi_device *spi) /* Cannot read from Adafruit 1.8" display via SPI */ dbi->read_commands = NULL; - ret = mipi_dbi_init(dbidev, &jd_t18003_t01_pipe_funcs, &jd_t18003_t01_mode, rotation); + ret = mipi_dbi_dev_init(dbidev, &jd_t18003_t01_pipe_funcs, &jd_t18003_t01_mode, rotation); if (ret) return ret; diff --git a/include/drm/tinydrm/mipi-dbi.h b/include/drm/tinydrm/mipi-dbi.h index b7b301130af7..67c66f5ee591 100644 --- a/include/drm/tinydrm/mipi-dbi.h +++ b/include/drm/tinydrm/mipi-dbi.h @@ -18,24 +18,62 @@ struct gpio_desc; struct regulator; /** - * struct mipi_dbi - MIPI DBI controller - * @spi: SPI device - * @enabled: Pipeline is enabled - * @cmdlock: Command lock - * @command: Bus specific callback executing commands. - * @read_commands: Array of read commands terminated by a zero entry. - * Reading is disabled if this is NULL. - * @dc: Optional D/C gpio. - * @tx_buf: Buffer used for transfer (copy clip rect area) - * @tx_buf9: Buffer used for Option 1 9-bit conversion - * @tx_buf9_len: Size of tx_buf9. - * @swap_bytes: Swap bytes in buffer before transfer - * @reset: Optional reset gpio - * @rotation: initial rotation in degrees Counter Clock Wise - * @backlight: backlight device (optional) - * @regulator: power regulator (optional) + * struct mipi_dbi - MIPI DBI interface */ struct mipi_dbi { + /** + * @cmdlock: Command lock + */ + struct mutex cmdlock; + + /** + * @command: Bus specific callback executing commands. + */ + int (*command)(struct mipi_dbi *dbi, u8 *cmd, u8 *param, size_t num); + + /** + * @read_commands: Array of read commands terminated by a zero entry. + * Reading is disabled if this is NULL. + */ + const u8 *read_commands; + + /** + * @swap_bytes: Swap bytes in buffer before transfer + */ + bool swap_bytes; + + /** + * @reset: Optional reset gpio + */ + struct gpio_desc *reset; + + /* Type C specific */ + + /** + * @spi: SPI device + */ + struct spi_device *spi; + + /** + * @dc: Optional D/C gpio. + */ + struct gpio_desc *dc; + + /** + * @tx_buf9: Buffer used for Option 1 9-bit conversion + */ + void *tx_buf9; + + /** + * @tx_buf9_len: Size of tx_buf9. + */ + size_t tx_buf9_len; +}; + +/** + * struct mipi_dbi_dev - MIPI DBI device + */ +struct mipi_dbi_dev { /** * @drm: DRM device */ @@ -56,48 +94,63 @@ struct mipi_dbi { */ struct drm_display_mode mode; - struct spi_device *spi; + /** + * @enabled: Pipeline is enabled + */ bool enabled; - struct mutex cmdlock; - int (*command)(struct mipi_dbi *dbi, u8 *cmd, u8 *param, size_t num); - const u8 *read_commands; - struct gpio_desc *dc; + + /** + * @tx_buf: Buffer used for transfer (copy clip rect area) + */ u16 *tx_buf; - void *tx_buf9; - size_t tx_buf9_len; - bool swap_bytes; - struct gpio_desc *reset; + + /** + * @rotation: initial rotation in degrees Counter Clock Wise + */ unsigned int rotation; + + /** + * @backlight: backlight device (optional) + */ struct backlight_device *backlight; + + /** + * @regulator: power regulator (optional) + */ struct regulator *regulator; + + /** + * @dbi: MIPI DBI interface + */ + struct mipi_dbi dbi; }; -static inline struct mipi_dbi *drm_to_mipi_dbi(struct drm_device *drm) +static inline struct mipi_dbi_dev *drm_to_mipi_dbi_dev(struct drm_device *drm) { - return container_of(drm, struct mipi_dbi, drm); + return container_of(drm, struct mipi_dbi_dev, drm); } int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi, struct gpio_desc *dc); -int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev, - const struct drm_simple_display_pipe_funcs *funcs, - const uint32_t *formats, unsigned int format_count, - const struct drm_display_mode *mode, - unsigned int rotation, size_t tx_buf_size); -int mipi_dbi_init(struct mipi_dbi *dbidev, - const struct drm_simple_display_pipe_funcs *funcs, - const struct drm_display_mode *mode, unsigned int rotation); +int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev, + const struct drm_simple_display_pipe_funcs *funcs, + const uint32_t *formats, unsigned int format_count, + const struct drm_display_mode *mode, + unsigned int rotation, size_t tx_buf_size); +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); 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); -void mipi_dbi_enable_flush(struct mipi_dbi *dbidev, +void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev, struct drm_crtc_state *crtc_state, struct drm_plane_state *plan_state); void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe); void mipi_dbi_hw_reset(struct mipi_dbi *dbi); bool mipi_dbi_display_is_on(struct mipi_dbi *dbi); -int mipi_dbi_poweron_reset(struct mipi_dbi *dbidev); -int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *dbidev); +int mipi_dbi_poweron_reset(struct mipi_dbi_dev *dbidev); +int mipi_dbi_poweron_conditional_reset(struct mipi_dbi_dev *dbidev); u32 mipi_dbi_spi_cmd_max_speed(struct spi_device *spi, size_t len); int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, From patchwork Mon Jul 22 10:43:08 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: 11052131 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 14E32138D for ; Mon, 22 Jul 2019 10:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0528F28500 for ; Mon, 22 Jul 2019 10:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDA0428514; Mon, 22 Jul 2019 10:43:40 +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 8924A28500 for ; Mon, 22 Jul 2019 10:43:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 930F689C14; Mon, 22 Jul 2019 10:43:30 +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 1035689BCD for ; Mon, 22 Jul 2019 10:43:27 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:55388 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 1hpVmv-0001lD-Ak; Mon, 22 Jul 2019 12:43:25 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 5/9] drm/tinydrm/mipi-dbi: Remove CMA helper dependency Date: Mon, 22 Jul 2019 12:43:08 +0200 Message-Id: <20190722104312.16184-6-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722104312.16184-1-noralf@tronnes.org> References: <20190722104312.16184-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=u3GkT1hSVcAAIegIRZpj+CUAFZC/g7X8qY/+K+kOBkk=; b=iCZdfxMKJtgJWelbZIkcP2wShOHTpSliEvJNv7u5UM4ObbHlXOR/1ngeeFI+E4cOXmBh9MZRAnenpzsX+reu4J1hKCpNwj7ISaSKYJ7c9rhK/S8D+1FS2cGpe1kay9jm3VzshCv6aaK2Fghw5gTkIuSG0OvUbCdFPI2qbFmQCpaI2NTWICmqOaoaHa8EzUQp/3QX2PcKFeHmSPbTJSnIUKRYa9AChvbMFMpwZi92RYFTVLUIlYLBB72U5cjEn0eGlMZiuX06Vin49l/rw04FJko8Jpn5Pa8nBYHAf4ktpuCx2x2/FIaihWzqFiLmLdX7tX13wAnIXQxaoro0FrtIMg==; 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: sam@ravnborg.org, david@lechnology.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP mipi-dbi depends on the CMA helper through it's use of drm_fb_cma_get_gem_obj(). This is an unnecessary dependency to drag in for drivers that only want to use the MIPI DBI interface part. Avoid this by open coding the function. Signed-off-by: Noralf Trønnes Reviewed-by: David Lechner --- drivers/gpu/drm/tinydrm/mipi-dbi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index 1617784fef09..d6f3406a4075 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -201,8 +200,9 @@ EXPORT_SYMBOL(mipi_dbi_command_stackbuf); int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, struct drm_rect *clip, bool swap) { - struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0); - struct dma_buf_attachment *import_attach = cma_obj->base.import_attach; + struct drm_gem_object *gem = drm_gem_fb_get_obj(fb, 0); + struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(gem); + struct dma_buf_attachment *import_attach = gem->import_attach; struct drm_format_name_buf format_name; void *src = cma_obj->vaddr; int ret = 0; @@ -240,7 +240,8 @@ EXPORT_SYMBOL(mipi_dbi_buf_copy); static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) { - struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0); + struct drm_gem_object *gem = drm_gem_fb_get_obj(fb, 0); + struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(gem); struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev); unsigned int height = rect->y2 - rect->y1; unsigned int width = rect->x2 - rect->x1; From patchwork Mon Jul 22 10:43:09 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: 11052139 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 44692138D for ; Mon, 22 Jul 2019 10:43:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32CA5284E9 for ; Mon, 22 Jul 2019 10:43:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 274BC28514; Mon, 22 Jul 2019 10:43:48 +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 C4CB6284E9 for ; Mon, 22 Jul 2019 10:43:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 896BF89C21; Mon, 22 Jul 2019 10:43:45 +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 43AAC89A61 for ; Mon, 22 Jul 2019 10:43:27 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:55388 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 1hpVmv-0001lD-G1; Mon, 22 Jul 2019 12:43:25 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 6/9] drm/tinydrm/Kconfig: drivers: Select BACKLIGHT_CLASS_DEVICE Date: Mon, 22 Jul 2019 12:43:09 +0200 Message-Id: <20190722104312.16184-7-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722104312.16184-1-noralf@tronnes.org> References: <20190722104312.16184-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=HxBM7w/IVUMbnheFCbztR++zy8K/3ATqtPrRLcbkQnU=; b=s5F0YU89VaL0WmJ/9d5GmbbY1Y5MGkf/07I+B8YWlY0CAlaAUZfInI5+h7jK4vUVTJruIj47KbqsnJytCwBo4OU29xLXNnKFNIu4b1kIO+lBEZ4VwpeKKovu6a0qU9ziLh30fFrJj4D8zk1LRP9i2Fz3TfoHsC47egLuNMUpRFvz16RNBk3mHJF6GsG3NaFMGLmT0VAh9dCEuvW5Zv3YO3dXeRO8Zu4fHbheU9rBzMU/0mLhB+5Bl78IwZVU13DUDrlRjYvqzRnfH8cyeNpr0R5QlJxkxArZWq7y85+LJGClMgvpP0dYfirujb+FnEJGlg4oXFD3UA/iG26xpBLDcg==; 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: sam@ravnborg.org, david@lechnology.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The mipi_dbi helper is missing a dependency on DRM_KMS_HELPER and putting that in revealed this problem: drivers/video/fbdev/Kconfig:12:error: recursive dependency detected! drivers/video/fbdev/Kconfig:12: symbol FB is selected by DRM_KMS_FB_HELPER drivers/gpu/drm/Kconfig:75: symbol DRM_KMS_FB_HELPER depends on DRM_KMS_HELPER drivers/gpu/drm/Kconfig:69: symbol DRM_KMS_HELPER is selected by TINYDRM_MIPI_DBI drivers/gpu/drm/tinydrm/Kconfig:11: symbol TINYDRM_MIPI_DBI is selected by TINYDRM_HX8357D drivers/gpu/drm/tinydrm/Kconfig:15: symbol TINYDRM_HX8357D depends on BACKLIGHT_CLASS_DEVICE drivers/video/backlight/Kconfig:144: symbol BACKLIGHT_CLASS_DEVICE is selected by FB_BACKLIGHT drivers/video/fbdev/Kconfig:187: symbol FB_BACKLIGHT depends on FB A symbol that selects DRM_KMS_HELPER can not depend on BACKLIGHT_CLASS_DEVICE. The reason for this is that DRM_KMS_FB_HELPER selects FB instead of depending on it. The tinydrm drivers have somehow gotten away with depending on BACKLIGHT_CLASS_DEVICE because DRM_TINYDRM selects DRM_KMS_HELPER and the drivers depend on that symbol. An audit shows that all DRM drivers that select DRM_KMS_HELPER and use BACKLIGHT_CLASS_DEVICE, selects it: DRM_TILCDC, DRM_GMA500, DRM_SHMOBILE, DRM_NOUVEAU, DRM_FSL_DCU, DRM_I915, DRM_RADEON, DRM_AMDGPU, DRM_PARADE_PS8622 Documentation/kbuild/kconfig-language.txt has a note regarding select: 1. 'select should be used with care since it doesn't visit dependencies.' This is not a problem since BACKLIGHT_CLASS_DEVICE doesn't have any dependencies. 2. 'In general use select only for non-visible symbols' BACKLIGHT_CLASS_DEVICE is user visible. The real solution to this would be to have DRM_KMS_FB_HELPER depend on the user visible symbol FB. That is a can of worms I'm not willing to tackle. I fear that such a change will result in me handling difficult fallouts for the next weeks. So I'm following DRM suite here. Signed-off-by: Noralf Trønnes Reviewed-by: David Lechner --- drivers/gpu/drm/tinydrm/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/Kconfig b/drivers/gpu/drm/tinydrm/Kconfig index 87819c82bcce..f2f0739d1035 100644 --- a/drivers/gpu/drm/tinydrm/Kconfig +++ b/drivers/gpu/drm/tinydrm/Kconfig @@ -14,8 +14,8 @@ config TINYDRM_MIPI_DBI config TINYDRM_HX8357D tristate "DRM support for HX8357D display panels" depends on DRM_TINYDRM && SPI - depends on BACKLIGHT_CLASS_DEVICE select TINYDRM_MIPI_DBI + select BACKLIGHT_CLASS_DEVICE help DRM driver for the following HX8357D panels: * YX350HV15-T 3.5" 340x350 TFT (Adafruit 3.5") @@ -35,8 +35,8 @@ config TINYDRM_ILI9225 config TINYDRM_ILI9341 tristate "DRM support for ILI9341 display panels" depends on DRM_TINYDRM && SPI - depends on BACKLIGHT_CLASS_DEVICE select TINYDRM_MIPI_DBI + select BACKLIGHT_CLASS_DEVICE help DRM driver for the following Ilitek ILI9341 panels: * YX240QV29-T 2.4" 240x320 TFT (Adafruit 2.4") @@ -46,8 +46,8 @@ config TINYDRM_ILI9341 config TINYDRM_MI0283QT tristate "DRM support for MI0283QT" depends on DRM_TINYDRM && SPI - depends on BACKLIGHT_CLASS_DEVICE select TINYDRM_MIPI_DBI + select BACKLIGHT_CLASS_DEVICE help DRM driver for the Multi-Inno MI0283QT display panel If M is selected the module will be called mi0283qt. @@ -78,8 +78,8 @@ config TINYDRM_ST7586 config TINYDRM_ST7735R tristate "DRM support for Sitronix ST7735R display panels" depends on DRM_TINYDRM && SPI - depends on BACKLIGHT_CLASS_DEVICE select TINYDRM_MIPI_DBI + select BACKLIGHT_CLASS_DEVICE help DRM driver Sitronix ST7735R with one of the following LCDs: * JD-T18003-T01 1.8" 128x160 TFT From patchwork Mon Jul 22 10:43:10 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: 11052137 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 24973138D for ; Mon, 22 Jul 2019 10:43:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 138DA284E9 for ; Mon, 22 Jul 2019 10:43:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07E9828514; Mon, 22 Jul 2019 10:43:46 +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 B4683284E9 for ; Mon, 22 Jul 2019 10:43:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1E8089C16; Mon, 22 Jul 2019 10:43:44 +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 410E489A77 for ; Mon, 22 Jul 2019 10:43:29 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:55388 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 1hpVmx-0001lD-A8; Mon, 22 Jul 2019 12:43:27 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 7/9] drm/tinydrm/mipi-dbi: Select DRM_KMS_HELPER Date: Mon, 22 Jul 2019 12:43:10 +0200 Message-Id: <20190722104312.16184-8-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722104312.16184-1-noralf@tronnes.org> References: <20190722104312.16184-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=mjqglcz27VKBjehvOGMCF17d5hikRR7l1XBNrOwVKpU=; b=Bb8XEBnrrcr9OGpUe4qtOCBM1aymHpb7Y4RT9rhL2Z1vvzPo0OuHAqF/CJKR8xi8FnchNQrYrG6Draf5M66h9f5jeKtuZWW1W9JPuB6+hlmvZFZoz9jnyTdfuP0LAHDHfq7aWvcaIHd8V+xsxJFPr38DNN5bBeIsCJIusHyT0HiXLdSABpN7IUYSyN73p7eJWAG5hnkSJg0dnlWQqGc69Psidp7noRjNmdA83Zjq+JlI+q/FyPGt4qdLeb5ylpwGny2bGHnZuNHhwRqa021+u8yGIcy8MulEMxfaGvhAxOXxM2FjSboEnsk3XD0z5vQB39jeZvC/PpwAcYLesIKmDA==; 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: sam@ravnborg.org, david@lechnology.com, kbuild test robot Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP mipi-dbi uses several KMS helper functions but that build dependency is not expressed. Select DRM_KMS_HELPER to fix that. Reported-by: kbuild test robot Signed-off-by: Noralf Trønnes Reviewed-by: David Lechner --- drivers/gpu/drm/tinydrm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/tinydrm/Kconfig b/drivers/gpu/drm/tinydrm/Kconfig index f2f0739d1035..637697649612 100644 --- a/drivers/gpu/drm/tinydrm/Kconfig +++ b/drivers/gpu/drm/tinydrm/Kconfig @@ -10,6 +10,7 @@ menuconfig DRM_TINYDRM config TINYDRM_MIPI_DBI tristate + select DRM_KMS_HELPER config TINYDRM_HX8357D tristate "DRM support for HX8357D display panels" From patchwork Mon Jul 22 10:43:11 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: 11052135 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 0A12B112C for ; Mon, 22 Jul 2019 10:43:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC55028500 for ; Mon, 22 Jul 2019 10:43:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E09FC28514; Mon, 22 Jul 2019 10:43:42 +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 26E6B28511 for ; Mon, 22 Jul 2019 10:43:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8034789A77; Mon, 22 Jul 2019 10:43:40 +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 7A4D889BFE for ; Mon, 22 Jul 2019 10:43:29 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:55388 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 1hpVmx-0001lD-Je; Mon, 22 Jul 2019 12:43:27 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 8/9] drm/tinydrm: Move mipi-dbi Date: Mon, 22 Jul 2019 12:43:11 +0200 Message-Id: <20190722104312.16184-9-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722104312.16184-1-noralf@tronnes.org> References: <20190722104312.16184-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=hM1YtJqeJNJdqfudogYk1AYVr9ih3uowfSR6As6s0SY=; b=A4uG2TqIDNtrQEpChf1RshfiZhRJi3HpF235OnuWIKSAyWw1Hb85PIzOlVFSMFFce5JNSDRK18OxYOBlBPoCxo2bsDoX3EZ+fMMFAgVx1IP3X0jjog9e3eh6o6Ra7cq13lslcylVm3lFU1B3+my79L/ZgDZDPU2Zj15Tsq36BYtLs/yR1XUqllrvyPhLXnyoxSdukyb6Ozn1YdGAys9yws0L6/Wma/BtIsc4ptjIfCoM7QX8QIqjoWjMMlzJP049514qBwXmPBnMCkxLT1/Piu8vcBAlh8Q2uouoqNdoI6aLmLWNOf7sta4pWAct0R+8x4Ec/OWM0JwQJe+pE3pHBg==; 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: sam@ravnborg.org, david@lechnology.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This moves mipi-dbi to be a core helper with the name drm_mipi_dbi. Fixup include's in drivers. Move the docs entry and delete tinydrm.rst. Delete the last tinydrm todo entry. v2: Make DRM_MIPI_DBI tristate to enable it being built as a module. Cc: Eric Anholt Cc: David Lechner Reviewed-by: Sam Ravnborg Signed-off-by: Noralf Trønnes Acked-by: David Lechner --- Documentation/gpu/drivers.rst | 1 - Documentation/gpu/drm-kms-helpers.rst | 12 ++++++++++++ Documentation/gpu/tinydrm.rst | 18 ------------------ Documentation/gpu/todo.rst | 13 ------------- drivers/gpu/drm/Kconfig | 4 ++++ drivers/gpu/drm/Makefile | 1 + .../drm/{tinydrm/mipi-dbi.c => drm_mipi_dbi.c} | 2 +- drivers/gpu/drm/tinydrm/Kconfig | 16 ++++++---------- drivers/gpu/drm/tinydrm/Makefile | 4 ---- drivers/gpu/drm/tinydrm/hx8357d.c | 2 +- drivers/gpu/drm/tinydrm/ili9225.c | 2 +- drivers/gpu/drm/tinydrm/ili9341.c | 2 +- drivers/gpu/drm/tinydrm/mi0283qt.c | 2 +- drivers/gpu/drm/tinydrm/st7586.c | 2 +- drivers/gpu/drm/tinydrm/st7735r.c | 2 +- .../drm/{tinydrm/mipi-dbi.h => drm_mipi_dbi.h} | 0 16 files changed, 30 insertions(+), 53 deletions(-) delete mode 100644 Documentation/gpu/tinydrm.rst rename drivers/gpu/drm/{tinydrm/mipi-dbi.c => drm_mipi_dbi.c} (99%) rename include/drm/{tinydrm/mipi-dbi.h => drm_mipi_dbi.h} (100%) diff --git a/Documentation/gpu/drivers.rst b/Documentation/gpu/drivers.rst index 4bfb7068e9f7..b4a0ed3ca961 100644 --- a/Documentation/gpu/drivers.rst +++ b/Documentation/gpu/drivers.rst @@ -11,7 +11,6 @@ GPU Driver Documentation meson pl111 tegra - tinydrm tve200 v3d vc4 diff --git a/Documentation/gpu/drm-kms-helpers.rst b/Documentation/gpu/drm-kms-helpers.rst index b327bbc11182..3868008db8a9 100644 --- a/Documentation/gpu/drm-kms-helpers.rst +++ b/Documentation/gpu/drm-kms-helpers.rst @@ -263,6 +263,18 @@ the MST topology helpers easier to understand drm_dp_mst_topology_put_port drm_dp_mst_get_mstb_malloc drm_dp_mst_put_mstb_malloc +MIPI DBI Helper Functions Reference +=================================== + +.. kernel-doc:: drivers/gpu/drm/drm_mipi_dbi.c + :doc: overview + +.. kernel-doc:: include/drm/drm_mipi_dbi.h + :internal: + +.. kernel-doc:: drivers/gpu/drm/drm_mipi_dbi.c + :export: + MIPI DSI Helper Functions Reference =================================== diff --git a/Documentation/gpu/tinydrm.rst b/Documentation/gpu/tinydrm.rst deleted file mode 100644 index 64bdf6356024..000000000000 --- a/Documentation/gpu/tinydrm.rst +++ /dev/null @@ -1,18 +0,0 @@ -============================ -drm/tinydrm Tiny DRM drivers -============================ - -tinydrm is a collection of DRM drivers that are so small they can fit in a -single source file. - -MIPI DBI Compatible Controllers -=============================== - -.. kernel-doc:: drivers/gpu/drm/tinydrm/mipi-dbi.c - :doc: overview - -.. kernel-doc:: include/drm/tinydrm/mipi-dbi.h - :internal: - -.. kernel-doc:: drivers/gpu/drm/tinydrm/mipi-dbi.c - :export: diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index 688b4adbbf62..b81cc007acb8 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -437,19 +437,6 @@ Contact: Daniel Vetter Driver Specific =============== -tinydrm -------- - -Tinydrm is the helper driver for really simple fb drivers. The goal is to make -those drivers as simple as possible, so lots of room for refactoring: - -- extract the mipi-dbi helper (well, the non-tinydrm specific parts at - least) into a separate helper, like we have for mipi-dsi already. Or follow - one of the ideas for having a shared dsi/dbi helper, abstracting away the - transport details more. - -Contact: Noralf Trønnes, Daniel Vetter - AMD DC Display Driver --------------------- diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index b9362b4f6353..5c6fba2e8763 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -24,6 +24,10 @@ menuconfig DRM details. You should also select and configure AGP (/dev/agpgart) support if it is available for your platform. +config DRM_MIPI_DBI + tristate + depends on DRM + config DRM_MIPI_DSI bool depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 9f0d2ee35794..dc894771d56c 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -55,6 +55,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o obj-$(CONFIG_DRM_DEBUG_SELFTEST) += selftests/ obj-$(CONFIG_DRM) += drm.o +obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o obj-y += arm/ diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c similarity index 99% rename from drivers/gpu/drm/tinydrm/mipi-dbi.c rename to drivers/gpu/drm/drm_mipi_dbi.c index d6f3406a4075..1961f713aaab 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/drm_mipi_dbi.c @@ -20,11 +20,11 @@ #include #include #include +#include #include #include #include #include -#include #include