@@ -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
@@ -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");
new file mode 100644
@@ -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);
+}
new file mode 100644
@@ -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__ */