All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Noralf Trønnes" <noralf@tronnes.org>
To: dri-devel@lists.freedesktop.org
Cc: david@lechnology.com
Subject: [PATCH 08/10] drm/tinydrm/repaper: Don't use tinydrm_display_pipe_init()
Date: Wed, 17 Jul 2019 13:58:15 +0200	[thread overview]
Message-ID: <20190717115817.30110-9-noralf@tronnes.org> (raw)
In-Reply-To: <20190717115817.30110-1-noralf@tronnes.org>

tinydrm.ko is going away so let's implement a connector.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
 drivers/gpu/drm/tinydrm/repaper.c | 58 ++++++++++++++++++++++++++++---
 1 file changed, 53 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/repaper.c b/drivers/gpu/drm/tinydrm/repaper.c
index 40afa66107e5..76d179200775 100644
--- a/drivers/gpu/drm/tinydrm/repaper.c
+++ b/drivers/gpu/drm/tinydrm/repaper.c
@@ -23,6 +23,7 @@
 #include <linux/thermal.h>
 
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_connector.h>
 #include <drm/drm_damage_helper.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_fb_cma_helper.h>
@@ -30,10 +31,11 @@
 #include <drm/drm_format_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_modes.h>
 #include <drm/drm_rect.h>
 #include <drm/drm_vblank.h>
+#include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-#include <drm/tinydrm/tinydrm-helpers.h>
 
 #define REPAPER_RID_G2_COG_ID	0x12
 
@@ -60,6 +62,8 @@ enum repaper_epd_border_byte {
 struct repaper_epd {
 	struct drm_device drm;
 	struct drm_simple_display_pipe pipe;
+	const struct drm_display_mode *mode;
+	struct drm_connector connector;
 	struct spi_device *spi;
 
 	struct gpio_desc *panel_on;
@@ -873,6 +877,39 @@ static const struct drm_simple_display_pipe_funcs repaper_pipe_funcs = {
 	.prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
 };
 
+static int repaper_connector_get_modes(struct drm_connector *connector)
+{
+	struct repaper_epd *epd = drm_to_epd(connector->dev);
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, epd->mode);
+	if (!mode) {
+		DRM_ERROR("Failed to duplicate mode\n");
+		return 0;
+	}
+
+	drm_mode_set_name(mode);
+	mode->type |= DRM_MODE_TYPE_PREFERRED;
+	drm_mode_probed_add(connector, mode);
+
+	connector->display_info.width_mm = mode->width_mm;
+	connector->display_info.height_mm = mode->height_mm;
+
+	return 1;
+}
+
+static const struct drm_connector_helper_funcs repaper_connector_hfuncs = {
+	.get_modes = repaper_connector_get_modes,
+};
+
+static const struct drm_connector_funcs repaper_connector_funcs = {
+	.reset = drm_atomic_helper_connector_reset,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = drm_connector_cleanup,
+	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+};
+
 static const struct drm_mode_config_funcs repaper_mode_config_funcs = {
 	.fb_create = drm_gem_fb_create_with_dirty,
 	.atomic_check = drm_atomic_helper_check,
@@ -1095,6 +1132,7 @@ static int repaper_probe(struct spi_device *spi)
 		return -ENODEV;
 	}
 
+	epd->mode = mode;
 	epd->width = mode->hdisplay;
 	epd->height = mode->vdisplay;
 	epd->factored_stage_time = epd->stage_time;
@@ -1109,10 +1147,20 @@ static int repaper_probe(struct spi_device *spi)
 	if (!epd->current_frame)
 		return -ENOMEM;
 
-	ret = tinydrm_display_pipe_init(drm, &epd->pipe, &repaper_pipe_funcs,
-					DRM_MODE_CONNECTOR_SPI,
-					repaper_formats,
-					ARRAY_SIZE(repaper_formats), mode, 0);
+	drm->mode_config.min_width = mode->hdisplay;
+	drm->mode_config.max_width = mode->hdisplay;
+	drm->mode_config.min_height = mode->vdisplay;
+	drm->mode_config.max_height = mode->vdisplay;
+
+	drm_connector_helper_add(&epd->connector, &repaper_connector_hfuncs);
+	ret = drm_connector_init(drm, &epd->connector, &repaper_connector_funcs,
+				 DRM_MODE_CONNECTOR_SPI);
+	if (ret)
+		return ret;
+
+	ret = drm_simple_display_pipe_init(drm, &epd->pipe, &repaper_pipe_funcs,
+					   repaper_formats, ARRAY_SIZE(repaper_formats),
+					   NULL, &epd->connector);
 	if (ret)
 		return ret;
 
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-07-17 11:58 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17 11:58 [PATCH 00/10] drm/tinydrm: Remove tinydrm.ko Noralf Trønnes
2019-07-17 11:58 ` [PATCH 01/10] drm: Add SPI connector type Noralf Trønnes
2019-07-17 19:24   ` David Lechner
2019-07-19  9:17   ` Daniel Vetter
2019-07-19 12:34     ` Noralf Trønnes
2019-07-19 12:39       ` Daniel Vetter
2019-07-17 11:58 ` [PATCH 02/10] drm/tinydrm: Use spi_is_bpw_supported() Noralf Trønnes
2019-07-17 11:58 ` [PATCH 03/10] drm/tinydrm: Remove spi debug buffer dumping Noralf Trønnes
2019-07-17 11:58 ` [PATCH 04/10] drm/tinydrm: Remove tinydrm_spi_max_transfer_size() Noralf Trønnes
2019-07-17 11:58 ` [PATCH 05/10] drm/tinydrm: Clean up tinydrm_spi_transfer() Noralf Trønnes
2019-07-17 13:09   ` Sam Ravnborg
2019-07-17 16:18     ` Noralf Trønnes
2019-07-17 18:13       ` Sam Ravnborg
2019-07-17 19:37   ` David Lechner
2019-07-17 11:58 ` [PATCH 06/10] drm/tinydrm: Move tinydrm_spi_transfer() Noralf Trønnes
2019-07-17 13:15   ` Sam Ravnborg
2019-07-17 16:20     ` Noralf Trønnes
2019-07-17 19:48   ` David Lechner
2019-07-18 12:14     ` Noralf Trønnes
2019-07-25 14:16       ` Noralf Trønnes
2019-07-25 14:29         ` David Lechner
2019-07-17 11:58 ` [PATCH 07/10] drm/tinydrm: Move tinydrm_machine_little_endian() Noralf Trønnes
2019-07-17 20:09   ` David Lechner
2019-07-18 12:20     ` Noralf Trønnes
2019-07-17 11:58 ` Noralf Trønnes [this message]
2019-07-17 11:58 ` [PATCH 09/10] drm/tinydrm/mipi-dbi: Add mipi_dbi_init_with_formats() Noralf Trønnes
2019-07-17 20:38   ` David Lechner
2019-07-17 11:58 ` [PATCH 10/10] drm/tinydrm: Move tinydrm_display_pipe_init() to mipi-dbi Noralf Trønnes
2019-07-17 13:34   ` Sam Ravnborg
2019-07-17 20:46   ` David Lechner
2019-07-18 12:27     ` Noralf Trønnes
2019-07-17 13:31 ` [PATCH 00/10] drm/tinydrm: Remove tinydrm.ko Sam Ravnborg
2019-07-17 16:22   ` Noralf Trønnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190717115817.30110-9-noralf@tronnes.org \
    --to=noralf@tronnes.org \
    --cc=david@lechnology.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.