[Intel-gfx] [RFC PATCH 4/4] drm/i915/dsi: add AUO MIPI DSI display driver

Jani Nikula jani.nikula at intel.com
Fri Sep 20 14:31:37 CEST 2013


From: Shobhit Kumar <shobhit.kumar at intel.com>

Signed-off-by: Shobhit Kumar <shobhit.kumar at intel.com>
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 drivers/gpu/drm/i915/Makefile          |    1 +
 drivers/gpu/drm/i915/auo_dsi_display.c |  253 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi.c       |    5 +
 3 files changed, 259 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/auo_dsi_display.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 65e60d2..18bf236 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -42,6 +42,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o \
 	  intel_opregion.o \
 	  intel_sideband.o \
 	  intel_uncore.o \
+	  auo_dsi_display.o \
 	  dvo_ch7xxx.o \
 	  dvo_ch7017.o \
 	  dvo_ivch.o \
diff --git a/drivers/gpu/drm/i915/auo_dsi_display.c b/drivers/gpu/drm/i915/auo_dsi_display.c
new file mode 100644
index 0000000..6a5aea6
--- /dev/null
+++ b/drivers/gpu/drm/i915/auo_dsi_display.c
@@ -0,0 +1,253 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Jani Nikula <jani.nikula at intel.com>
+ *	   Shobhit Kumar <shobhit.kumar at intel.com>
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_edid.h>
+#include <drm/i915_drm.h>
+#include <linux/slab.h>
+#include <video/mipi_display.h>
+#include "i915_drv.h"
+#include "intel_drv.h"
+#include "intel_dsi.h"
+#include "intel_dsi_cmd.h"
+
+struct auo_dsi {
+	struct drm_bridge base;
+	struct intel_dsi *intel_dsi;
+	uint16_t panel_id;
+};
+#define to_auo_dsi(x) container_of(x, struct auo_dsi, base)
+
+static void auo_pre_enable(struct drm_bridge *bridge)
+{
+}
+
+static void auo_enable(struct drm_bridge *bridge)
+{
+	struct auo_dsi *auo = to_auo_dsi(bridge);
+	struct intel_dsi *intel_dsi = auo->intel_dsi;
+
+	DRM_DEBUG_KMS("\n");
+
+	dsi_vc_dcs_write_0(intel_dsi, 0, MIPI_DCS_EXIT_SLEEP_MODE);
+
+	dsi_vc_dcs_write_1(intel_dsi, 0, MIPI_DCS_SET_TEAR_ON, 0x00);
+
+	dsi_vc_dcs_write_0(intel_dsi, 0, MIPI_DCS_SET_DISPLAY_ON);
+	dsi_vc_dcs_write_1(intel_dsi, 0, 0x14, 0x55);
+}
+
+static void auo_disable(struct drm_bridge *bridge)
+{
+	struct auo_dsi *auo = to_auo_dsi(bridge);
+	struct intel_dsi *intel_dsi = auo->intel_dsi;
+
+	DRM_DEBUG_KMS("\n");
+
+	dsi_vc_dcs_write_0(intel_dsi, 0, MIPI_DCS_SET_DISPLAY_OFF);
+	dsi_vc_dcs_write_0(intel_dsi, 0, MIPI_DCS_ENTER_SLEEP_MODE);
+}
+
+static void auo_post_disable(struct drm_bridge *bridge)
+{
+}
+
+static bool auo_mode_fixup(struct drm_bridge *bridge,
+			   const struct drm_display_mode *mode,
+			   struct drm_display_mode *adjusted_mode)
+{
+	struct auo_dsi *auo = to_auo_dsi(bridge);
+	struct intel_dsi *intel_dsi = auo->intel_dsi;
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
+
+	DRM_DEBUG_KMS("\n");
+
+	intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
+			       adjusted_mode);
+	return true;
+}
+
+static void auo_mode_set(struct drm_bridge *bridge,
+			 struct drm_display_mode *mode,
+			 struct drm_display_mode *adjusted_mode)
+{
+}
+
+static void auo_destroy(struct drm_bridge *bridge)
+{
+	struct auo_dsi *auo = to_auo_dsi(bridge);
+
+	drm_bridge_cleanup(bridge);
+	kfree(auo);
+}
+
+static const struct drm_bridge_funcs auo_bridge_funcs = {
+	.pre_enable = auo_pre_enable,
+	.enable = auo_enable,
+	.disable = auo_disable,
+	.post_disable = auo_post_disable,
+	.mode_fixup = auo_mode_fixup,
+	.mode_set = auo_mode_set,
+	.destroy = auo_destroy,
+};
+
+static struct drm_display_mode *auo_fixed_mode(struct drm_device *dev)
+{
+	struct drm_display_mode *mode;
+	const int hblank = 0x78;
+	const int vblank = 0x0c;
+	const int hsync_offset = 0x28;
+	const int hsync_width = 0x28;
+	const int vsync_offset = 0x04;
+	const int vsync_width = 0x04;
+
+	mode = drm_mode_create(dev);
+	if (!mode)
+		return NULL;
+
+	strlcpy(mode->name, "1920x1200", sizeof(mode->name));
+	mode->hdisplay = 0x780;
+	mode->vdisplay = 0x4B0;
+	mode->vrefresh = 60;
+	mode->clock =  148350;
+
+	/* Calculate */
+	mode->hsync_start = mode->hdisplay + hsync_offset;
+	mode->hsync_end = mode->hdisplay + hsync_offset + hsync_width;
+	mode->htotal = mode->hdisplay + hblank;
+	mode->vsync_start = mode->vdisplay + vsync_offset;
+	mode->vsync_end = mode->vdisplay + vsync_offset + vsync_width;
+	mode->vtotal = mode->vdisplay + vblank;
+
+	/* Configure */
+	mode->flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC;
+	mode->type |= DRM_MODE_TYPE_PREFERRED;
+	mode->status = MODE_OK;
+
+	return mode;
+}
+
+/* connector */
+static const struct drm_connector_helper_funcs auo_connector_helper_funcs = {
+	.get_modes = intel_dsi_connector_get_modes,
+	.mode_valid = intel_dsi_connector_mode_valid,
+	.best_encoder = intel_best_encoder,
+};
+
+static const struct drm_connector_funcs auo_connector_funcs = {
+	.dpms = intel_connector_dpms,
+	.detect = intel_dsi_connector_detect,
+	.destroy = intel_dsi_connector_destroy,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+};
+
+/* could be a helper in intel_dsi.c */
+static struct intel_connector *auo_dsi_connector_init(struct drm_device *dev)
+{
+	struct intel_connector *intel_connector;
+	struct drm_connector *connector;
+	struct drm_display_mode *fixed_mode;
+
+	intel_connector = kzalloc(sizeof(*intel_connector), GFP_KERNEL);
+	if (!intel_connector)
+		return ERR_PTR(-ENOMEM);
+	connector = &intel_connector->base;
+
+	fixed_mode = auo_fixed_mode(dev);
+	if (!fixed_mode) {
+		DRM_DEBUG_KMS("no fixed mode\n");
+		kfree(intel_connector);
+		return ERR_PTR(-ENOMEM);
+	}
+	intel_panel_init(&intel_connector->panel, fixed_mode);
+
+	intel_connector->get_hw_state = intel_connector_get_hw_state;
+
+	drm_connector_init(dev, connector, &auo_connector_funcs,
+			   DRM_MODE_CONNECTOR_DSI);
+	drm_connector_helper_add(connector, &auo_connector_helper_funcs);
+
+	/* connector config */
+	connector->interlace_allowed = false;
+	connector->doublescan_allowed = false;
+
+	connector->display_info.subpixel_order = SubPixelHorizontalRGB; /*XXX*/
+	connector->display_info.width_mm = 216;
+	connector->display_info.height_mm = 135;
+
+	drm_sysfs_connector_add(connector);
+
+	return intel_connector;
+}
+
+struct drm_bridge *auo_init(struct intel_dsi *intel_dsi, uint16_t panel_id)
+{
+	struct intel_encoder *intel_encoder = &intel_dsi->base;
+	struct drm_device *dev = intel_encoder->base.dev;
+	struct intel_connector *intel_connector;
+	struct drm_bridge *bridge = NULL;
+	struct auo_dsi *auo;
+	int ret;
+
+	DRM_DEBUG_KMS("\n");
+
+	auo = kzalloc(sizeof(*auo), GFP_KERNEL);
+	if (!auo) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	auo->intel_dsi = intel_dsi;
+	auo->panel_id = panel_id;
+
+	bridge = &auo->base;
+	drm_bridge_init(dev, bridge, &auo_bridge_funcs);
+
+	intel_connector = auo_dsi_connector_init(dev);
+	if (IS_ERR_OR_NULL(intel_connector)) {
+		ret = PTR_ERR(intel_connector);
+		goto err;
+	}
+
+	intel_dsi->attached_connector = intel_connector;
+	intel_connector_attach_encoder(intel_connector, intel_encoder);
+
+	/* encoder config */
+	intel_dsi->type = INTEL_DSI_VIDEO_MODE;
+	intel_dsi->eot_disable = 0;
+	intel_dsi->pixel_format = VID_MODE_FORMAT_RGB888;
+	intel_dsi->video_mode_format = VIDEO_MODE_NON_BURST_WITH_SYNC_PULSE;
+	intel_dsi->lane_count = 4;
+
+	return bridge;
+
+err:
+	if (bridge)
+		auo_destroy(bridge);
+
+	return ERR_PTR(ret);
+}
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 0dff575..ec4d3e1 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -34,12 +34,17 @@
 #include "intel_dsi_cmd.h"
 
 /* the sub-encoders aka panel drivers */
+extern struct drm_bridge *auo_init(struct intel_dsi *intel_dsi, uint16_t panel_id);
+
 struct intel_dsi_device {
 	uint16_t id;
 	struct drm_bridge *(*init)(struct intel_dsi *intel_dsi, uint16_t id);
 };
 
 static const struct intel_dsi_device intel_dsi_devices[] = {
+	{
+		.init = auo_init,
+	},
 };
 
 static void vlv_cck_modify(struct drm_i915_private *dev_priv, u32 reg, u32 val,
-- 
1.7.9.5




More information about the Intel-gfx mailing list