All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] drm/i915/dsi: convert DSI sub-encoders to drm_bridge
@ 2013-09-20 12:31 Jani Nikula
  2013-09-20 12:31 ` [RFC PATCH 1/4] drm/i915/dsi: remove hot plug callback Jani Nikula
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jani Nikula @ 2013-09-20 12:31 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula, yogesh.mohan.marimuthu

Hi all, this series converts the homebrew DSI sub-encoder model to use
the recently merged drm_bridge model instead. I hear there's fixes
coming on top of current -nightly, so we may want to get those in before
this one. High level comments still welcome; those will apply regardless
of the order in which stuff gets merge.

BR,
Jani.


Jani Nikula (3):
  drm/i915/dsi: remove hot plug callback
  drm/i915/dsi: call drm_bridge callbacks if available
  drm/i915/dsi: switch from custom sub-encoder model to drm_bridge

Shobhit Kumar (1):
  drm/i915/dsi: add AUO MIPI DSI display driver

 drivers/gpu/drm/i915/Makefile          |    1 +
 drivers/gpu/drm/i915/auo_dsi_display.c |  253 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi.c       |  149 +++++++------------
 drivers/gpu/drm/i915/intel_dsi.h       |   50 ++-----
 4 files changed, 322 insertions(+), 131 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/auo_dsi_display.c

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH 1/4] drm/i915/dsi: remove hot plug callback
  2013-09-20 12:31 [RFC PATCH 0/4] drm/i915/dsi: convert DSI sub-encoders to drm_bridge Jani Nikula
@ 2013-09-20 12:31 ` Jani Nikula
  2013-09-20 12:31 ` [RFC PATCH 2/4] drm/i915/dsi: call drm_bridge callbacks if available Jani Nikula
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2013-09-20 12:31 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula, yogesh.mohan.marimuthu

Not needed or used.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_dsi.c |    6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 674fd49..9f87238 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -98,11 +98,6 @@ static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
 	return intel_dsi->dev.type == INTEL_DSI_COMMAND_MODE;
 }
 
-static void intel_dsi_hot_plug(struct intel_encoder *encoder)
-{
-	DRM_DEBUG_KMS("\n");
-}
-
 static bool intel_dsi_compute_config(struct intel_encoder *encoder,
 				     struct intel_crtc_config *config)
 {
@@ -558,7 +553,6 @@ bool intel_dsi_init(struct drm_device *dev)
 	drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);
 
 	/* XXX: very likely not all of these are needed */
-	intel_encoder->hot_plug = intel_dsi_hot_plug;
 	intel_encoder->compute_config = intel_dsi_compute_config;
 	intel_encoder->pre_pll_enable = intel_dsi_pre_pll_enable;
 	intel_encoder->pre_enable = intel_dsi_pre_enable;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 2/4] drm/i915/dsi: call drm_bridge callbacks if available
  2013-09-20 12:31 [RFC PATCH 0/4] drm/i915/dsi: convert DSI sub-encoders to drm_bridge Jani Nikula
  2013-09-20 12:31 ` [RFC PATCH 1/4] drm/i915/dsi: remove hot plug callback Jani Nikula
@ 2013-09-20 12:31 ` Jani Nikula
  2013-09-20 12:31 ` [RFC PATCH 3/4] drm/i915/dsi: switch from custom sub-encoder model to drm_bridge Jani Nikula
  2013-09-20 12:31 ` [RFC PATCH 4/4] drm/i915/dsi: add AUO MIPI DSI display driver Jani Nikula
  3 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2013-09-20 12:31 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula, yogesh.mohan.marimuthu

Not used yet, but this is similar to what the crtc helpers do with
drm_bridge callbacks. The same functions are mandatory as in crtc
helpers.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_dsi.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 9f87238..0d49540 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -107,12 +107,17 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
 	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
 	struct drm_display_mode *adjusted_mode = &config->adjusted_mode;
 	struct drm_display_mode *mode = &config->requested_mode;
+	struct drm_bridge *bridge = encoder->base.bridge;
 
 	DRM_DEBUG_KMS("\n");
 
 	if (fixed_mode)
 		intel_fixed_panel_mode(fixed_mode, adjusted_mode);
 
+	if (bridge && bridge->funcs->mode_fixup)
+		return bridge->funcs->mode_fixup(bridge, mode, adjusted_mode);
+
+	/* transitional, will go away */
 	if (intel_dsi->dev.dev_ops->mode_fixup)
 		return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev,
 							  mode, adjusted_mode);
@@ -129,7 +134,12 @@ static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
 
 static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 {
+	struct drm_bridge *bridge = encoder->base.bridge;
+
 	DRM_DEBUG_KMS("\n");
+
+	if (bridge)
+		bridge->funcs->pre_enable(bridge);
 }
 
 static void intel_dsi_enable(struct intel_encoder *encoder)
@@ -137,6 +147,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct drm_bridge *bridge = encoder->base.bridge;
 	int pipe = intel_crtc->pipe;
 	u32 temp;
 
@@ -171,6 +182,10 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 		POSTING_READ(MIPI_PORT_CTRL(pipe));
 	}
 
+	if (bridge)
+		bridge->funcs->enable(bridge);
+
+	/* transitional, will go away */
 	intel_dsi->dev.dev_ops->enable(&intel_dsi->dev);
 }
 
@@ -179,11 +194,16 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct drm_bridge *bridge = encoder->base.bridge;
 	int pipe = intel_crtc->pipe;
 	u32 temp;
 
 	DRM_DEBUG_KMS("\n");
 
+	if (bridge)
+		bridge->funcs->disable(bridge);
+
+	/* transitional, will go away */
 	intel_dsi->dev.dev_ops->disable(&intel_dsi->dev);
 
 	if (is_vid_mode(intel_dsi)) {
@@ -208,8 +228,13 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 
 static void intel_dsi_post_disable(struct intel_encoder *encoder)
 {
+	struct drm_bridge *bridge = encoder->base.bridge;
+
 	DRM_DEBUG_KMS("\n");
 
+	if (bridge)
+		bridge->funcs->post_disable(bridge);
+
 	vlv_disable_dsi_pll(encoder);
 }
 
@@ -339,8 +364,11 @@ static void intel_dsi_mode_set(struct intel_encoder *intel_encoder)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
+	struct drm_bridge *bridge = encoder->bridge;
 	struct drm_display_mode *adjusted_mode =
 		&intel_crtc->config.adjusted_mode;
+	struct drm_display_mode *requested_mode =
+		&intel_crtc->config.requested_mode;
 	int pipe = intel_crtc->pipe;
 	unsigned int bpp = intel_crtc->config.pipe_bpp;
 	u32 val, tmp;
@@ -460,6 +488,9 @@ static void intel_dsi_mode_set(struct intel_encoder *intel_encoder)
 	if (is_vid_mode(intel_dsi))
 		I915_WRITE(MIPI_VIDEO_MODE_FORMAT(pipe),
 			   intel_dsi->video_mode_format);
+
+	if (bridge && bridge->funcs->mode_set)
+		bridge->funcs->mode_set(bridge, requested_mode, adjusted_mode);
 }
 
 static enum drm_connector_status
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 3/4] drm/i915/dsi: switch from custom sub-encoder model to drm_bridge
  2013-09-20 12:31 [RFC PATCH 0/4] drm/i915/dsi: convert DSI sub-encoders to drm_bridge Jani Nikula
  2013-09-20 12:31 ` [RFC PATCH 1/4] drm/i915/dsi: remove hot plug callback Jani Nikula
  2013-09-20 12:31 ` [RFC PATCH 2/4] drm/i915/dsi: call drm_bridge callbacks if available Jani Nikula
@ 2013-09-20 12:31 ` Jani Nikula
  2013-09-20 12:31 ` [RFC PATCH 4/4] drm/i915/dsi: add AUO MIPI DSI display driver Jani Nikula
  3 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2013-09-20 12:31 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula, yogesh.mohan.marimuthu

Drop intel_dsi_device and intel_dsi_dev_ops, and switch to drm_bridge
and its own drm_bridge_funcs for sub-encoder (panel driver) callbacks.

Push DSI connector creation and initialization to bridge drivers, which
is more natural than the current approach.

Leave the connector callbacks (now prefixed as intel_dsi_connector_*)
around as helpers the bridge drivers can choose to use.

This is fairly straightforward as no panel drivers have been merged yet.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_dsi.c |  119 +++++++++-----------------------------
 drivers/gpu/drm/i915/intel_dsi.h |   50 ++++------------
 2 files changed, 38 insertions(+), 131 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 0d49540..0dff575 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -34,9 +34,13 @@
 #include "intel_dsi_cmd.h"
 
 /* the sub-encoders aka panel drivers */
-static const struct intel_dsi_device intel_dsi_devices[] = {
+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[] = {
+};
 
 static void vlv_cck_modify(struct drm_i915_private *dev_priv, u32 reg, u32 val,
 			   u32 mask)
@@ -82,46 +86,28 @@ static void band_gap_wa(struct drm_i915_private *dev_priv)
 	msleep(100);
 }
 
-static struct intel_dsi *intel_attached_dsi(struct drm_connector *connector)
-{
-	return container_of(intel_attached_encoder(connector),
-			    struct intel_dsi, base);
-}
-
 static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
 {
-	return intel_dsi->dev.type == INTEL_DSI_VIDEO_MODE;
+	return intel_dsi->type == INTEL_DSI_VIDEO_MODE;
 }
 
 static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
 {
-	return intel_dsi->dev.type == INTEL_DSI_COMMAND_MODE;
+	return intel_dsi->type == INTEL_DSI_COMMAND_MODE;
 }
 
 static bool intel_dsi_compute_config(struct intel_encoder *encoder,
 				     struct intel_crtc_config *config)
 {
-	struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi,
-						   base);
-	struct intel_connector *intel_connector = intel_dsi->attached_connector;
-	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
 	struct drm_display_mode *adjusted_mode = &config->adjusted_mode;
 	struct drm_display_mode *mode = &config->requested_mode;
 	struct drm_bridge *bridge = encoder->base.bridge;
 
 	DRM_DEBUG_KMS("\n");
 
-	if (fixed_mode)
-		intel_fixed_panel_mode(fixed_mode, adjusted_mode);
-
 	if (bridge && bridge->funcs->mode_fixup)
 		return bridge->funcs->mode_fixup(bridge, mode, adjusted_mode);
 
-	/* transitional, will go away */
-	if (intel_dsi->dev.dev_ops->mode_fixup)
-		return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev,
-							  mode, adjusted_mode);
-
 	return true;
 }
 
@@ -184,9 +170,6 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 
 	if (bridge)
 		bridge->funcs->enable(bridge);
-
-	/* transitional, will go away */
-	intel_dsi->dev.dev_ops->enable(&intel_dsi->dev);
 }
 
 static void intel_dsi_disable(struct intel_encoder *encoder)
@@ -203,9 +186,6 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 	if (bridge)
 		bridge->funcs->disable(bridge);
 
-	/* transitional, will go away */
-	intel_dsi->dev.dev_ops->disable(&intel_dsi->dev);
-
 	if (is_vid_mode(intel_dsi)) {
 		dpi_send_cmd(intel_dsi, SHUTDOWN);
 		msleep(10);
@@ -271,12 +251,11 @@ static void intel_dsi_get_config(struct intel_encoder *encoder,
 	/* XXX: read flags, set to adjusted_mode */
 }
 
-static int intel_dsi_mode_valid(struct drm_connector *connector,
-				struct drm_display_mode *mode)
+int intel_dsi_connector_mode_valid(struct drm_connector *connector,
+				   struct drm_display_mode *mode)
 {
 	struct intel_connector *intel_connector = to_intel_connector(connector);
 	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
 
 	DRM_DEBUG_KMS("\n");
 
@@ -292,7 +271,7 @@ static int intel_dsi_mode_valid(struct drm_connector *connector,
 			return MODE_PANEL;
 	}
 
-	return intel_dsi->dev.dev_ops->mode_valid(&intel_dsi->dev, mode);
+	return MODE_OK;
 }
 
 /* return txclkesc cycles in terms of divider and duration in us */
@@ -493,15 +472,14 @@ static void intel_dsi_mode_set(struct intel_encoder *intel_encoder)
 		bridge->funcs->mode_set(bridge, requested_mode, adjusted_mode);
 }
 
-static enum drm_connector_status
-intel_dsi_detect(struct drm_connector *connector, bool force)
+enum drm_connector_status
+intel_dsi_connector_detect(struct drm_connector *connector, bool force)
 {
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
 	DRM_DEBUG_KMS("\n");
-	return intel_dsi->dev.dev_ops->detect(&intel_dsi->dev);
+	return connector_status_connected;
 }
 
-static int intel_dsi_get_modes(struct drm_connector *connector)
+int intel_dsi_connector_get_modes(struct drm_connector *connector)
 {
 	struct intel_connector *intel_connector = to_intel_connector(connector);
 	struct drm_display_mode *mode;
@@ -524,7 +502,7 @@ static int intel_dsi_get_modes(struct drm_connector *connector)
 	return 1;
 }
 
-static void intel_dsi_destroy(struct drm_connector *connector)
+void intel_dsi_connector_destroy(struct drm_connector *connector)
 {
 	struct intel_connector *intel_connector = to_intel_connector(connector);
 
@@ -539,28 +517,13 @@ static const struct drm_encoder_funcs intel_dsi_funcs = {
 	.destroy = intel_encoder_destroy,
 };
 
-static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs = {
-	.get_modes = intel_dsi_get_modes,
-	.mode_valid = intel_dsi_mode_valid,
-	.best_encoder = intel_best_encoder,
-};
-
-static const struct drm_connector_funcs intel_dsi_connector_funcs = {
-	.dpms = intel_connector_dpms,
-	.detect = intel_dsi_detect,
-	.destroy = intel_dsi_destroy,
-	.fill_modes = drm_helper_probe_single_connector_modes,
-};
-
 bool intel_dsi_init(struct drm_device *dev)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_dsi *intel_dsi;
 	struct intel_encoder *intel_encoder;
 	struct drm_encoder *encoder;
-	struct intel_connector *intel_connector;
-	struct drm_connector *connector;
-	struct drm_display_mode *fixed_mode = NULL;
-	const struct intel_dsi_device *dsi;
+	struct drm_bridge *bridge = NULL;
 	unsigned int i;
 
 	DRM_DEBUG_KMS("\n");
@@ -569,17 +532,8 @@ bool intel_dsi_init(struct drm_device *dev)
 	if (!intel_dsi)
 		return false;
 
-	intel_connector = kzalloc(sizeof(*intel_connector), GFP_KERNEL);
-	if (!intel_connector) {
-		kfree(intel_dsi);
-		return false;
-	}
-
 	intel_encoder = &intel_dsi->base;
 	encoder = &intel_encoder->base;
-	intel_dsi->attached_connector = intel_connector;
-
-	connector = &intel_connector->base;
 
 	drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);
 
@@ -594,53 +548,34 @@ bool intel_dsi_init(struct drm_device *dev)
 	intel_encoder->get_hw_state = intel_dsi_get_hw_state;
 	intel_encoder->get_config = intel_dsi_get_config;
 
-	intel_connector->get_hw_state = intel_connector_get_hw_state;
-
 	for (i = 0; i < ARRAY_SIZE(intel_dsi_devices); i++) {
-		dsi = &intel_dsi_devices[i];
-		intel_dsi->dev = *dsi;
+		const struct intel_dsi_device *dsi = &intel_dsi_devices[i];
 
-		if (dsi->dev_ops->init(&intel_dsi->dev))
+		if (dsi->id && dsi->id != dev_priv->vbt.dsi.panel_id)
+			continue;
+
+		/* bridge creates connector and attaches to encoder */
+		bridge = dsi->init(intel_dsi, dev_priv->vbt.dsi.panel_id);
+		if (!IS_ERR_OR_NULL(bridge))
 			break;
 	}
 
-	if (i == ARRAY_SIZE(intel_dsi_devices)) {
+	if (IS_ERR_OR_NULL(bridge)) {
 		DRM_DEBUG_KMS("no device found\n");
 		goto err;
 	}
 
+	encoder->bridge = bridge;
+
 	intel_encoder->type = INTEL_OUTPUT_DSI;
 	intel_encoder->crtc_mask = (1 << 0); /* XXX */
-
 	intel_encoder->cloneable = false;
-	drm_connector_init(dev, connector, &intel_dsi_connector_funcs,
-			   DRM_MODE_CONNECTOR_DSI);
-
-	drm_connector_helper_add(connector, &intel_dsi_connector_helper_funcs);
-
-	connector->display_info.subpixel_order = SubPixelHorizontalRGB; /*XXX*/
-	connector->interlace_allowed = false;
-	connector->doublescan_allowed = false;
-
-	intel_connector_attach_encoder(intel_connector, intel_encoder);
-
-	drm_sysfs_connector_add(connector);
-
-	fixed_mode = dsi->dev_ops->get_modes(&intel_dsi->dev);
-	if (!fixed_mode) {
-		DRM_DEBUG_KMS("no fixed mode\n");
-		goto err;
-	}
-
-	fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
-	intel_panel_init(&intel_connector->panel, fixed_mode);
 
 	return true;
 
 err:
 	drm_encoder_cleanup(&intel_encoder->base);
 	kfree(intel_dsi);
-	kfree(intel_connector);
 
 	return false;
 }
diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
index c7765f3..979d781 100644
--- a/drivers/gpu/drm/i915/intel_dsi.h
+++ b/drivers/gpu/drm/i915/intel_dsi.h
@@ -28,50 +28,14 @@
 #include <drm/drm_crtc.h>
 #include "intel_drv.h"
 
-struct intel_dsi_device {
-	unsigned int panel_id;
-	const char *name;
-	int type;
-	const struct intel_dsi_dev_ops *dev_ops;
-	void *dev_priv;
-};
-
-struct intel_dsi_dev_ops {
-	bool (*init)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*enable)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*disable)(struct intel_dsi_device *dsi);
-
-	int (*mode_valid)(struct intel_dsi_device *dsi,
-			  struct drm_display_mode *mode);
-
-	bool (*mode_fixup)(struct intel_dsi_device *dsi,
-			   const struct drm_display_mode *mode,
-			   struct drm_display_mode *adjusted_mode);
-
-	void (*mode_set)(struct intel_dsi_device *dsi,
-			 struct drm_display_mode *mode,
-			 struct drm_display_mode *adjusted_mode);
-
-	enum drm_connector_status (*detect)(struct intel_dsi_device *dsi);
-
-	bool (*get_hw_state)(struct intel_dsi_device *dev);
-
-	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-
-	void (*destroy) (struct intel_dsi_device *dsi);
-};
-
 struct intel_dsi {
 	struct intel_encoder base;
 
-	struct intel_dsi_device dev;
-
 	struct intel_connector *attached_connector;
 
+	/* video vs. command mode */
+	int type;
+
 	/* if true, use HS mode, otherwise LP */
 	bool hs;
 
@@ -99,4 +63,12 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 extern void vlv_enable_dsi_pll(struct intel_encoder *encoder);
 extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
 
+int intel_dsi_connector_mode_valid(struct drm_connector *connector,
+				   struct drm_display_mode *mode);
+enum drm_connector_status
+intel_dsi_connector_detect(struct drm_connector *connector, bool force);
+int intel_dsi_connector_get_modes(struct drm_connector *connector);
+void intel_dsi_connector_destroy(struct drm_connector *connector);
+
+
 #endif /* _INTEL_DSI_H */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 4/4] drm/i915/dsi: add AUO MIPI DSI display driver
  2013-09-20 12:31 [RFC PATCH 0/4] drm/i915/dsi: convert DSI sub-encoders to drm_bridge Jani Nikula
                   ` (2 preceding siblings ...)
  2013-09-20 12:31 ` [RFC PATCH 3/4] drm/i915/dsi: switch from custom sub-encoder model to drm_bridge Jani Nikula
@ 2013-09-20 12:31 ` Jani Nikula
  3 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2013-09-20 12:31 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula, yogesh.mohan.marimuthu

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

Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@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@intel.com>
+ *	   Shobhit Kumar <shobhit.kumar@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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-20 12:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-20 12:31 [RFC PATCH 0/4] drm/i915/dsi: convert DSI sub-encoders to drm_bridge Jani Nikula
2013-09-20 12:31 ` [RFC PATCH 1/4] drm/i915/dsi: remove hot plug callback Jani Nikula
2013-09-20 12:31 ` [RFC PATCH 2/4] drm/i915/dsi: call drm_bridge callbacks if available Jani Nikula
2013-09-20 12:31 ` [RFC PATCH 3/4] drm/i915/dsi: switch from custom sub-encoder model to drm_bridge Jani Nikula
2013-09-20 12:31 ` [RFC PATCH 4/4] drm/i915/dsi: add AUO MIPI DSI display driver Jani Nikula

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.