[PATCH v2 06/59] drm/kmb: Initial check-in for Mipi DSI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Basic frame work for mipi encoder and connector.
More hardware specific details will be added in the future commits.

Signed-off-by: Anitha Chrisanthus <anitha.chrisanthus@xxxxxxxxx>
Reviewed-by: Bob Paauwe <bob.j.paauwe@xxxxxxxxx>
---
 drivers/gpu/drm/kmb/Makefile  |  2 +-
 drivers/gpu/drm/kmb/kmb_drv.c |  2 +
 drivers/gpu/drm/kmb/kmb_dsi.c | 94 +++++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/kmb/kmb_dsi.h | 38 +++++++++++++++++
 4 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.h

diff --git a/drivers/gpu/drm/kmb/Makefile b/drivers/gpu/drm/kmb/Makefile
index be9f19c..8102bc9 100644
--- a/drivers/gpu/drm/kmb/Makefile
+++ b/drivers/gpu/drm/kmb/Makefile
@@ -1,2 +1,2 @@
-kmb-display-y := kmb_crtc.o kmb_drv.o kmb_plane.o
+kmb-display-y := kmb_crtc.o kmb_drv.o kmb_plane.o kmb_dsi.o
 obj-$(CONFIG_DRM_KMB_DISPLAY)	+= kmb-display.o
diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c
index 11f8d1f..aec8a5b 100644
--- a/drivers/gpu/drm/kmb/kmb_drv.c
+++ b/drivers/gpu/drm/kmb/kmb_drv.c
@@ -25,6 +25,7 @@
 #include <drm/drm_probe_helper.h>
 #include "kmb_crtc.h"
 #include "kmb_drv.h"
+#include "kmb_dsi.h"
 #include "kmb_plane.h"
 #include "kmb_regs.h"
 
@@ -63,6 +64,7 @@ static int kmb_load(struct drm_device *drm, unsigned long flags)
 		goto setup_fail;
 	}
 
+	kmb_dsi_init(drm);
 	ret = drm_irq_install(drm, platform_get_irq(pdev, 0));
 	if (ret < 0) {
 		DRM_ERROR("failed to install IRQ handler\n");
diff --git a/drivers/gpu/drm/kmb/kmb_dsi.c b/drivers/gpu/drm/kmb/kmb_dsi.c
new file mode 100644
index 0000000..654fae8
--- /dev/null
+++ b/drivers/gpu/drm/kmb/kmb_dsi.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright © 2019-2020 Intel Corporation
+ */
+
+#include <linux/gpio/consumer.h>
+#include <linux/slab.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_connector.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_edid.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_probe_helper.h>
+#include "kmb_drv.h"
+#include "kmb_dsi.h"
+
+static enum drm_mode_status
+kmb_dsi_mode_valid(struct drm_connector *connector,
+		   struct drm_display_mode *mode)
+{
+	return MODE_OK;
+}
+
+static int kmb_dsi_get_modes(struct drm_connector *connector)
+{
+	struct drm_display_mode *mode;
+	struct kmb_connector *kmb_connector = to_kmb_connector(connector);
+
+	mode = drm_mode_duplicate(connector->dev, kmb_connector->fixed_mode);
+	drm_mode_probed_add(connector, mode);
+	return 1;
+}
+
+static void kmb_dsi_connector_destroy(struct drm_connector *connector)
+{
+	struct kmb_connector *kmb_connector = to_kmb_connector(connector);
+
+	drm_connector_cleanup(connector);
+	kfree(kmb_connector);
+}
+
+static void kmb_dsi_encoder_destroy(struct drm_encoder *encoder)
+{
+	struct kmb_dsi *kmb_dsi = to_kmb_dsi(encoder);
+
+	drm_encoder_cleanup(encoder);
+	kfree(kmb_dsi);
+}
+
+static const struct drm_encoder_funcs kmb_dsi_funcs = {
+	.destroy = kmb_dsi_encoder_destroy,
+};
+
+static const struct
+drm_connector_helper_funcs kmb_dsi_connector_helper_funcs = {
+	.get_modes = kmb_dsi_get_modes,
+	.mode_valid = kmb_dsi_mode_valid,
+};
+
+static const struct drm_connector_funcs kmb_dsi_connector_funcs = {
+	.destroy = kmb_dsi_connector_destroy,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+};
+
+void kmb_dsi_init(struct drm_device *dev)
+{
+	struct kmb_dsi *kmb_dsi;
+	struct drm_encoder *encoder;
+	struct kmb_connector *kmb_connector;
+	struct drm_connector *connector;
+
+	kmb_dsi = kzalloc(sizeof(*kmb_dsi), GFP_KERNEL);
+	if (!kmb_dsi)
+		return;
+
+	kmb_connector = kzalloc(sizeof(*kmb_connector), GFP_KERNEL);
+	if (!kmb_connector) {
+		kfree(kmb_dsi);
+		return;
+	}
+
+	kmb_dsi->attached_connector = kmb_connector;
+
+	connector = &kmb_connector->base;
+	encoder = &kmb_dsi->base;
+	drm_encoder_init(dev, encoder, &kmb_dsi_funcs, DRM_MODE_ENCODER_DSI,
+			 "MIPI-DSI");
+	drm_connector_init(dev, connector, &kmb_dsi_connector_funcs,
+			   DRM_MODE_CONNECTOR_DSI);
+	drm_connector_helper_add(connector, &kmb_dsi_connector_helper_funcs);
+}
diff --git a/drivers/gpu/drm/kmb/kmb_dsi.h b/drivers/gpu/drm/kmb/kmb_dsi.h
new file mode 100644
index 0000000..9a6b0b7
--- /dev/null
+++ b/drivers/gpu/drm/kmb/kmb_dsi.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright © 2019-2020 Intel Corporation
+ */
+
+#ifndef __KMB_DSI_H__
+#define __KMB_DSI_H__
+
+#include <drm/drm_crtc.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include "kmb_drv.h"
+
+struct kmb_connector;
+
+struct kmb_dsi {
+	struct drm_encoder base;
+	struct kmb_connector *attached_connector;
+};
+
+struct kmb_dsi_host {
+	struct mipi_dsi_host base;
+	struct kmb_dsi *kmb_dsi;
+};
+
+struct kmb_connector {
+	struct drm_connector base;
+	struct drm_display_mode *fixed_mode;
+};
+
+void kmb_dsi_init(struct drm_device *dev);
+void kmb_plane_destroy(struct drm_plane *plane);
+
+#define to_kmb_connector(x) container_of(x, struct kmb_connector, base)
+#define to_kmb_host(x) container_of(x, struct kmb_dsi_host, base)
+#define to_kmb_dsi(x) container_of(x, struct kmb_dsi, base)
+
+#endif /* __KMB_DSI_H__ */
-- 
2.7.4

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




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux