Skip to contentSkip to conversation

MIPI DSI Support for BXT

PATCH In review Uma Shankar 5 participants 69 messages Sep 1, 2015 – Oct 6, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover MIPI DSI Support for BXT

This patch series adds support for MIPI DSI for BXT platform. Support for VBT v3 sequence parsing and programming is needed for panel, backlight enable and control. The same will be added as part of a different patch series. This is already floated and is under review.

Below is the link for earlier patch series in mailing list:
v1: http://www.spinics.net/lists/intel-gfx/msg67354.html
v2: http://lists.freedesktop.org/archives/intel-gfx/2015-July/072353.html

v2: Addressed the review comments from Jani. Fixed Macros
definitions as per convention. Adjusted the BXT DSI MACROS to get proper offsets for PORT C. DDI/DSI handling in generic code has been simplified. Backlight handling for BXT DSI has been re-designed.

v3: Rebased on latest drm-nightly branch. Addressed review comments
fom Jani.

Shashank Sharma (10):
drm/i915/bxt: Initialize MIPI for BXT drm/i915/bxt: Enable BXT DSI PLL drm/i915/bxt: Disable DSI PLL for BXT drm/i915/bxt: DSI prepare changes for BXT drm/i915/bxt: DSI encoder support in CRTC modeset drm/i915/bxt: DSI enable for BXT drm/i915/bxt: Program Tx Rx and Dphy clocks drm/i915/bxt: DSI disable and post-disable drm/i915/bxt: get_hw_state for BXT drm/i915/bxt: get DSI pixelclock

Sunil Kamath (1):
drm/i915/bxt: Modify BXT BLC according to VBT changes

Uma Shankar (3):
drm/i915/bxt: Program Backlight PWM frequency drm/i915/bxt: Remove DSP CLK_GATE programming for BXT drm/i915: Added BXT DSI backlight support

 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/i915_reg.h       |  140 ++++++++++++++-
 drivers/gpu/drm/i915/intel_ddi.c      |   29 ++-
 drivers/gpu/drm/i915/intel_display.c  |   22 ++-
 drivers/gpu/drm/i915/intel_dp_mst.c   |    1 +
 drivers/gpu/drm/i915/intel_drv.h      |    2 +
 drivers/gpu/drm/i915/intel_dsi.c      |  313 ++++++++++++++++++++++++---------
 drivers/gpu/drm/i915/intel_dsi.h      |    7 +-
 drivers/gpu/drm/i915/intel_dsi_pll.c  |  240 ++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_opregion.c |    3 +-
 drivers/gpu/drm/i915/intel_panel.c    |   95 ++++++++--
 11 files changed, 732 insertions(+), 121 deletions(-)
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v3 1/14 drm/i915/bxt: Initialize MIPI for BXT

From: Shashank Sharma <[email protected]>

This patch contains following changes:
1. Add BXT MIPI display address base.
2. Call dsi_init from display_setup function.

v2: Rebased on latest nightly branch

---
 drivers/gpu/drm/i915/i915_reg.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    3 +++
 drivers/gpu/drm/i915/intel_dsi.c     |    2 ++
 3 files changed, 6 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 2030f60..621151b 100644
@@ -1641,6 +1641,7 @@ enum skl_disp_power_wells {
 
 #define VLV_DISPLAY_BASE 0x180000
 #define VLV_MIPI_BASE VLV_DISPLAY_BASE
+#define BXT_MIPI_BASE 0x60000
 
 #define VLV_GU_CTL0	(VLV_DISPLAY_BASE + 0x2030)
 #define VLV_GU_CTL1	(VLV_DISPLAY_BASE + 0x2034)
drivers/gpu/drm/i915/intel_display.c +3 -0
index 87476ff..b8e0310 100644
@@ -13906,6 +13906,9 @@ static void intel_setup_outputs(struct drm_device *dev)
 		 * DDI_BUF_CTL_A or SFUSE_STRAP registers, find another way to
 		 * detect the ports.
 		 */
+		/* Initialize MIPI for BXT */
+		intel_dsi_init(dev);
+
 		intel_ddi_init(dev, PORT_A);
 		intel_ddi_init(dev, PORT_B);
 		intel_ddi_init(dev, PORT_C);
drivers/gpu/drm/i915/intel_dsi.c +2 -0
index b5a5558..b59b828 100644
@@ -998,6 +998,8 @@ void intel_dsi_init(struct drm_device *dev)
 
 	if (IS_VALLEYVIEW(dev)) {
 		dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
+	} else if (IS_BROXTON(dev)) {
+		dev_priv->mipi_mmio_base = BXT_MIPI_BASE;
 	} else {
 		DRM_ERROR("Unsupported Mipi device to reg base");
 		return;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 1/14
#2 lore raw

Re: [BXT MIPI PATCH v3 01/14] drm/i915/bxt: Initialize MIPI for BXT

Quoted 10 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch contains following changes:
1. Add BXT MIPI display address base.
2. Call dsi_init from display_setup function.

v2: Rebased on latest nightly branch

I'm not sure if this should be applied as the first patch or not, but

Quoted 48 lines
---
 drivers/gpu/drm/i915/i915_reg.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    3 +++
 drivers/gpu/drm/i915/intel_dsi.c     |    2 ++
 3 files changed, 6 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 2030f60..621151b 100644
@@ -1641,6 +1641,7 @@ enum skl_disp_power_wells {
 
 #define VLV_DISPLAY_BASE 0x180000
 #define VLV_MIPI_BASE VLV_DISPLAY_BASE
+#define BXT_MIPI_BASE 0x60000
 
 #define VLV_GU_CTL0	(VLV_DISPLAY_BASE + 0x2030)
 #define VLV_GU_CTL1	(VLV_DISPLAY_BASE + 0x2034)
drivers/gpu/drm/i915/intel_display.c +3 -0
index 87476ff..b8e0310 100644
@@ -13906,6 +13906,9 @@ static void intel_setup_outputs(struct drm_device *dev)
 		 * DDI_BUF_CTL_A or SFUSE_STRAP registers, find another way to
 		 * detect the ports.
 		 */
+		/* Initialize MIPI for BXT */
+		intel_dsi_init(dev);
+
 		intel_ddi_init(dev, PORT_A);
 		intel_ddi_init(dev, PORT_B);
 		intel_ddi_init(dev, PORT_C);
drivers/gpu/drm/i915/intel_dsi.c +2 -0
index b5a5558..b59b828 100644
@@ -998,6 +998,8 @@ void intel_dsi_init(struct drm_device *dev)
 
 	if (IS_VALLEYVIEW(dev)) {
 		dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
+	} else if (IS_BROXTON(dev)) {
+		dev_priv->mipi_mmio_base = BXT_MIPI_BASE;
 	} else {
 		DRM_ERROR("Unsupported Mipi device to reg base");
 		return;
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [BXT MIPI PATCH v3 01/14] drm/i915/bxt: Initialize MIPI for BXT

Quoted 7 lines · Jani Nikula
Quoted 6 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch contains following changes:
1. Add BXT MIPI display address base.
2. Call dsi_init from display_setup function.

Quoted 6 lines
Quoted 4 lines

v2: Rebased on latest nightly branch

I'm not sure if this should be applied as the first patch or not, but

Enabling patch should be last to avoid fireworks shows. I'll reorder while applying since this isn't the first patch series today with this problem ;-)

Cheers, Daniel

Quoted 58 lines
Quoted 48 lines
---
 drivers/gpu/drm/i915/i915_reg.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    3 +++
 drivers/gpu/drm/i915/intel_dsi.c     |    2 ++
 3 files changed, 6 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 2030f60..621151b 100644
@@ -1641,6 +1641,7 @@ enum skl_disp_power_wells {
 
 #define VLV_DISPLAY_BASE 0x180000
 #define VLV_MIPI_BASE VLV_DISPLAY_BASE
+#define BXT_MIPI_BASE 0x60000
 
 #define VLV_GU_CTL0	(VLV_DISPLAY_BASE + 0x2030)
 #define VLV_GU_CTL1	(VLV_DISPLAY_BASE + 0x2034)
drivers/gpu/drm/i915/intel_display.c +3 -0
index 87476ff..b8e0310 100644
@@ -13906,6 +13906,9 @@ static void intel_setup_outputs(struct drm_device *dev)
 		 * DDI_BUF_CTL_A or SFUSE_STRAP registers, find another way to
 		 * detect the ports.
 		 */
+		/* Initialize MIPI for BXT */
+		intel_dsi_init(dev);
+
 		intel_ddi_init(dev, PORT_A);
 		intel_ddi_init(dev, PORT_B);
 		intel_ddi_init(dev, PORT_C);
drivers/gpu/drm/i915/intel_dsi.c +2 -0
index b5a5558..b59b828 100644
@@ -998,6 +998,8 @@ void intel_dsi_init(struct drm_device *dev)
 
 	if (IS_VALLEYVIEW(dev)) {
 		dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
+	} else if (IS_BROXTON(dev)) {
+		dev_priv->mipi_mmio_base = BXT_MIPI_BASE;
 	} else {
 		DRM_ERROR("Unsupported Mipi device to reg base");
 		return;
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH v3 2/14 drm/i915/bxt: Enable BXT DSI PLL

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

This patch adds new functions for BXT clock and PLL programming. They are:
1. configure_dsi_pll for BXT.
This function does the basic math and generates the divider ratio based on requested pixclock, and program clock registers.
2. enable_dsi_pll function.
This function programs the calculated clock values on the PLL.
3. intel_enable_dsi_pll
Wrapper function to use same code for multiple platforms. It checks the platform and calls appropriate core pll enable function.

v2: Fixed Jani's review comments. Macros are adjusted as per convention.

v3: Removed a redundant change wrt code comment.

---
 drivers/gpu/drm/i915/i915_reg.h      |   22 ++++++++
 drivers/gpu/drm/i915/intel_dsi.c     |    2 +-
 drivers/gpu/drm/i915/intel_dsi.h     |    2 +-
 drivers/gpu/drm/i915/intel_dsi_pll.c |   95 +++++++++++++++++++++++++++++++++-
 4 files changed, 118 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +22 -0
index 621151b..06bb2e1 100644
@@ -7362,6 +7362,28 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+#define BXT_DSI_PLL_CTL			0x161000
+#define  BXT_DSI_PLL_PVD_RATIO_SHIFT	16
+#define  BXT_DSI_PLL_PVD_RATIO_MASK	(3 << BXT_DSI_PLL_PVD_RATIO_SHIFT)
+#define  BXT_DSI_PLL_PVD_RATIO_1	(1 << BXT_DSI_PLL_PVD_RATIO_SHIFT)
+#define  BXT_DSIC_16X_BY2		(1 << 10)
+#define  BXT_DSIC_16X_BY3		(2 << 10)
+#define  BXT_DSIC_16X_BY4		(3 << 10)
+#define  BXT_DSIA_16X_BY2		(1 << 8)
+#define  BXT_DSIA_16X_BY3		(2 << 8)
+#define  BXT_DSIA_16X_BY4		(3 << 8)
+#define  BXT_DSI_FREQ_SEL_SHIFT		8
+#define  BXT_DSI_FREQ_SEL_MASK		(0xF << BXT_DSI_FREQ_SEL_SHIFT)
+
+#define BXT_DSI_PLL_RATIO_MAX		0x7D
+#define BXT_DSI_PLL_RATIO_MIN		0x22
+#define BXT_DSI_PLL_RATIO_MASK		0xFF
+#define BXT_REF_CLOCK_KHZ		19500
+
+#define BXT_DSI_PLL_ENABLE		0x46080
+#define  BXT_DSI_PLL_DO_ENABLE		(1 << 31)
+#define  BXT_DSI_PLL_LOCKED		(1 << 30)
+
 #define _MIPIA_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61190)
 #define _MIPIC_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61700)
 #define MIPI_PORT_CTRL(port)	_MIPI_PORT(port, _MIPIA_PORT_CTRL, _MIPIC_PORT_CTRL)
drivers/gpu/drm/i915/intel_dsi.c +1 -1
index b59b828..fb259fb 100644
@@ -903,8 +903,8 @@ static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
 	DRM_DEBUG_KMS("\n");
 
 	intel_dsi_prepare(encoder);
+	intel_enable_dsi_pll(encoder);
 
-	vlv_enable_dsi_pll(encoder);
 }
 
 static enum drm_connector_status
drivers/gpu/drm/i915/intel_dsi.h +1 -1
index 2784ac4..20cfcf07 100644
@@ -121,7 +121,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 	return container_of(encoder, struct intel_dsi, base.base);
 }
 
-extern void vlv_enable_dsi_pll(struct intel_encoder *encoder);
+extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
 extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 
drivers/gpu/drm/i915/intel_dsi_pll.c +94 -1

104 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 2/14
#5 lore raw

Re: [BXT MIPI PATCH v3 02/14] drm/i915/bxt: Enable BXT DSI PLL

Quoted 13 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch adds new functions for BXT clock and PLL programming. They are:
1. configure_dsi_pll for BXT.
This function does the basic math and generates the divider ratio based on requested pixclock, and program clock registers.
2. enable_dsi_pll function.
This function programs the calculated clock values on the PLL.
3. intel_enable_dsi_pll
Wrapper function to use same code for multiple platforms. It checks the platform and calls appropriate core pll enable function.

Quoted 6 lines

v2: Fixed Jani's review comments. Macros are adjusted as per convention.

v3: Removed a redundant change wrt code comment.

Quoted 180 lines
---
 drivers/gpu/drm/i915/i915_reg.h      |   22 ++++++++
 drivers/gpu/drm/i915/intel_dsi.c     |    2 +-
 drivers/gpu/drm/i915/intel_dsi.h     |    2 +-
 drivers/gpu/drm/i915/intel_dsi_pll.c |   95 +++++++++++++++++++++++++++++++++-
 4 files changed, 118 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +22 -0
index 621151b..06bb2e1 100644
@@ -7362,6 +7362,28 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+#define BXT_DSI_PLL_CTL			0x161000
+#define  BXT_DSI_PLL_PVD_RATIO_SHIFT	16
+#define  BXT_DSI_PLL_PVD_RATIO_MASK	(3 << BXT_DSI_PLL_PVD_RATIO_SHIFT)
+#define  BXT_DSI_PLL_PVD_RATIO_1	(1 << BXT_DSI_PLL_PVD_RATIO_SHIFT)
+#define  BXT_DSIC_16X_BY2		(1 << 10)
+#define  BXT_DSIC_16X_BY3		(2 << 10)
+#define  BXT_DSIC_16X_BY4		(3 << 10)
+#define  BXT_DSIA_16X_BY2		(1 << 8)
+#define  BXT_DSIA_16X_BY3		(2 << 8)
+#define  BXT_DSIA_16X_BY4		(3 << 8)
+#define  BXT_DSI_FREQ_SEL_SHIFT		8
+#define  BXT_DSI_FREQ_SEL_MASK		(0xF << BXT_DSI_FREQ_SEL_SHIFT)
+
+#define BXT_DSI_PLL_RATIO_MAX		0x7D
+#define BXT_DSI_PLL_RATIO_MIN		0x22
+#define BXT_DSI_PLL_RATIO_MASK		0xFF
+#define BXT_REF_CLOCK_KHZ		19500
+
+#define BXT_DSI_PLL_ENABLE		0x46080
+#define  BXT_DSI_PLL_DO_ENABLE		(1 << 31)
+#define  BXT_DSI_PLL_LOCKED		(1 << 30)
+
 #define _MIPIA_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61190)
 #define _MIPIC_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61700)
 #define MIPI_PORT_CTRL(port)	_MIPI_PORT(port, _MIPIA_PORT_CTRL, _MIPIC_PORT_CTRL)
drivers/gpu/drm/i915/intel_dsi.c +1 -1
index b59b828..fb259fb 100644
@@ -903,8 +903,8 @@ static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
 	DRM_DEBUG_KMS("\n");
 
 	intel_dsi_prepare(encoder);
+	intel_enable_dsi_pll(encoder);
 
-	vlv_enable_dsi_pll(encoder);
 }
 
 static enum drm_connector_status
drivers/gpu/drm/i915/intel_dsi.h +1 -1
index 2784ac4..20cfcf07 100644
@@ -121,7 +121,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 	return container_of(encoder, struct intel_dsi, base.base);
 }
 
-extern void vlv_enable_dsi_pll(struct intel_encoder *encoder);
+extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
 extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 
drivers/gpu/drm/i915/intel_dsi_pll.c +94 -1
index d20cf37..3830a4f 100644
@@ -237,7 +237,7 @@ static void vlv_configure_dsi_pll(struct intel_encoder *encoder)
 	vlv_cck_write(dev_priv, CCK_REG_DSI_PLL_CONTROL, dsi_mnp.dsi_pll_ctrl);
 }
 
-void vlv_enable_dsi_pll(struct intel_encoder *encoder)
+static void vlv_enable_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	u32 tmp;
@@ -368,3 +368,96 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
 
 	return pclk;
 }
+
+static bool bxt_configure_dsi_pll(struct intel_encoder *encoder)
+{
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	u8 dsi_ratio;
+	u32 dsi_clk;
+	u32 val;
+
+	dsi_clk = dsi_clk_from_pclk(intel_dsi->pclk, intel_dsi->pixel_format,
+			intel_dsi->lane_count);
+
+	/*
+	 * From clock diagram, to get PLL ratio divider, divide double of DSI
+	 * link rate (i.e., 2*8x=16x frequency value) by ref clock. Make sure to
+	 * round 'up' the result
+	 */
+	dsi_ratio = DIV_ROUND_UP(dsi_clk * 2, BXT_REF_CLOCK_KHZ);
+	if (dsi_ratio < BXT_DSI_PLL_RATIO_MIN ||
+			dsi_ratio > BXT_DSI_PLL_RATIO_MAX) {
+		DRM_ERROR("Cant get a suitable ratio from DSI PLL ratios\n");
+		return false;
+	}
+
+	/*
+	 * Program DSI ratio and Select MIPIC and MIPIA PLL output as 8x
+	 * Spec says both have to be programmed, even if one is not getting
+	 * used. Configure MIPI_CLOCK_CTL dividers in modeset
+	 */
+	val = I915_READ(BXT_DSI_PLL_CTL);
+	val &= ~BXT_DSI_PLL_PVD_RATIO_MASK;
+	val &= ~BXT_DSI_FREQ_SEL_MASK;
+	val &= ~BXT_DSI_PLL_RATIO_MASK;
+	val |= (dsi_ratio | BXT_DSIA_16X_BY2 | BXT_DSIC_16X_BY2);
+
+	/* As per recommendation from hardware team,
+	 * Prog PVD ratio =1 if dsi ratio <= 50
+	 */
+	if (dsi_ratio <= 50) {
+		val &= ~BXT_DSI_PLL_PVD_RATIO_MASK;
+		val |= BXT_DSI_PLL_PVD_RATIO_1;
+	}
+
+	I915_WRITE(BXT_DSI_PLL_CTL, val);
+	POSTING_READ(BXT_DSI_PLL_CTL);
+
+	return true;
+}
+
+static void bxt_enable_dsi_pll(struct intel_encoder *encoder)
+{
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	u32 val;
+
+	DRM_DEBUG_KMS("\n");
+
+	val = I915_READ(BXT_DSI_PLL_ENABLE);
+
+	if (val & BXT_DSI_PLL_DO_ENABLE) {
+		WARN(1, "DSI PLL already enabled. Disabling it.\n");
+		val &= ~BXT_DSI_PLL_DO_ENABLE;
+		I915_WRITE(BXT_DSI_PLL_ENABLE, val);
+	}
+
+	/* Configure PLL vales */
+	if (!bxt_configure_dsi_pll(encoder)) {
+		DRM_ERROR("Configure DSI PLL failed, abort PLL enable\n");
+		return;
+	}
+
+	/* Enable DSI PLL */
+	val = I915_READ(BXT_DSI_PLL_ENABLE);
+	val |= BXT_DSI_PLL_DO_ENABLE;
+	I915_WRITE(BXT_DSI_PLL_ENABLE, val);
+
+	/* Timeout and fail if PLL not locked */
+	if (wait_for(I915_READ(BXT_DSI_PLL_ENABLE) & BXT_DSI_PLL_LOCKED, 1)) {
+		DRM_ERROR("Timed out waiting for DSI PLL to lock\n");
+		return;
+	}
+
+	DRM_DEBUG_KMS("DSI PLL locked\n");
+}
+
+void intel_enable_dsi_pll(struct intel_encoder *encoder)
+{
+	struct drm_device *dev = encoder->base.dev;
+
+	if (IS_VALLEYVIEW(dev))
+		vlv_enable_dsi_pll(encoder);
+	else if (IS_BROXTON(dev))
+		bxt_enable_dsi_pll(encoder);
+}
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

PATCH v3 3/14 drm/i915/bxt: Disable DSI PLL for BXT

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

This patch adds two new functions:
- disable_dsi_pll.
BXT DSI disable sequence and registers are
different from previous platforms.
- intel_disable_dsi_pll
wrapper function to re-use the same code for
multiple platforms. It checks platform type and
calls appropriate core pll disable function.

v2: Fixed Jani's review comments.

v3: Rebased on latest drm-nightly branch.

---
 drivers/gpu/drm/i915/intel_dsi.c     |    2 +-
 drivers/gpu/drm/i915/intel_dsi.h     |    2 +-
 drivers/gpu/drm/i915/intel_dsi_pll.c |   32 +++++++++++++++++++++++++++++++-
 3 files changed, 33 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +1 -1
index fb259fb..bac988a 100644
@@ -553,7 +553,7 @@ static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
 		usleep_range(2000, 2500);
 	}
 
-	vlv_disable_dsi_pll(encoder);
+	intel_disable_dsi_pll(encoder);
 }
 
 static void intel_dsi_post_disable(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_dsi.h +1 -1
index 20cfcf07..759983e 100644
@@ -122,7 +122,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 }
 
 extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
-extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
+extern void intel_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 
 struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id);
drivers/gpu/drm/i915/intel_dsi_pll.c +31 -1
index 3830a4f..21a2e37 100644
@@ -267,7 +267,7 @@ static void vlv_enable_dsi_pll(struct intel_encoder *encoder)
 	DRM_DEBUG_KMS("DSI PLL locked\n");
 }
 
-void vlv_disable_dsi_pll(struct intel_encoder *encoder)
+static void vlv_disable_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	u32 tmp;
@@ -284,6 +284,26 @@ void vlv_disable_dsi_pll(struct intel_encoder *encoder)
 	mutex_unlock(&dev_priv->sb_lock);
 }
 
+static void bxt_disable_dsi_pll(struct intel_encoder *encoder)
+{
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	u32 val;
+
+	DRM_DEBUG_KMS("\n");
+
+	val = I915_READ(BXT_DSI_PLL_ENABLE);
+	val &= ~BXT_DSI_PLL_DO_ENABLE;
+	I915_WRITE(BXT_DSI_PLL_ENABLE, val);
+
+	/*
+	 * PLL lock should deassert within 200us.
+	 * Wait up to 1ms before timing out.
+	 */
+	if (wait_for((I915_READ(BXT_DSI_PLL_ENABLE)
+					& BXT_DSI_PLL_LOCKED) == 0, 1))
+		DRM_ERROR("Timeout waiting for PLL lock deassertion\n");
+}
+
 static void assert_bpp_mismatch(int pixel_format, int pipe_bpp)
 {
 	int bpp;
@@ -461,3 +481,13 @@ void intel_enable_dsi_pll(struct intel_encoder *encoder)
 	else if (IS_BROXTON(dev))
 		bxt_enable_dsi_pll(encoder);
 }
+
+void intel_disable_dsi_pll(struct intel_encoder *encoder)
+{
+	struct drm_device *dev = encoder->base.dev;
+
+	if (IS_VALLEYVIEW(dev))
+		vlv_disable_dsi_pll(encoder);
+	else if (IS_BROXTON(dev))
+		bxt_disable_dsi_pll(encoder);
+}
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 3/14
#7 lore raw

Re: [BXT MIPI PATCH v3 03/14] drm/i915/bxt: Disable DSI PLL for BXT

Quoted 11 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch adds two new functions:
- disable_dsi_pll.
BXT DSI disable sequence and registers are
different from previous platforms.
- intel_disable_dsi_pll
wrapper function to re-use the same code for
multiple platforms. It checks platform type and
calls appropriate core pll disable function.

Quoted 6 lines

v2: Fixed Jani's review comments.

v3: Rebased on latest drm-nightly branch.

Quoted 89 lines
---
 drivers/gpu/drm/i915/intel_dsi.c     |    2 +-
 drivers/gpu/drm/i915/intel_dsi.h     |    2 +-
 drivers/gpu/drm/i915/intel_dsi_pll.c |   32 +++++++++++++++++++++++++++++++-
 3 files changed, 33 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +1 -1
index fb259fb..bac988a 100644
@@ -553,7 +553,7 @@ static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
 		usleep_range(2000, 2500);
 	}
 
-	vlv_disable_dsi_pll(encoder);
+	intel_disable_dsi_pll(encoder);
 }
 
 static void intel_dsi_post_disable(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_dsi.h +1 -1
index 20cfcf07..759983e 100644
@@ -122,7 +122,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 }
 
 extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
-extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
+extern void intel_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 
 struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id);
drivers/gpu/drm/i915/intel_dsi_pll.c +31 -1
index 3830a4f..21a2e37 100644
@@ -267,7 +267,7 @@ static void vlv_enable_dsi_pll(struct intel_encoder *encoder)
 	DRM_DEBUG_KMS("DSI PLL locked\n");
 }
 
-void vlv_disable_dsi_pll(struct intel_encoder *encoder)
+static void vlv_disable_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	u32 tmp;
@@ -284,6 +284,26 @@ void vlv_disable_dsi_pll(struct intel_encoder *encoder)
 	mutex_unlock(&dev_priv->sb_lock);
 }
 
+static void bxt_disable_dsi_pll(struct intel_encoder *encoder)
+{
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	u32 val;
+
+	DRM_DEBUG_KMS("\n");
+
+	val = I915_READ(BXT_DSI_PLL_ENABLE);
+	val &= ~BXT_DSI_PLL_DO_ENABLE;
+	I915_WRITE(BXT_DSI_PLL_ENABLE, val);
+
+	/*
+	 * PLL lock should deassert within 200us.
+	 * Wait up to 1ms before timing out.
+	 */
+	if (wait_for((I915_READ(BXT_DSI_PLL_ENABLE)
+					& BXT_DSI_PLL_LOCKED) == 0, 1))
+		DRM_ERROR("Timeout waiting for PLL lock deassertion\n");
+}
+
 static void assert_bpp_mismatch(int pixel_format, int pipe_bpp)
 {
 	int bpp;
@@ -461,3 +481,13 @@ void intel_enable_dsi_pll(struct intel_encoder *encoder)
 	else if (IS_BROXTON(dev))
 		bxt_enable_dsi_pll(encoder);
 }
+
+void intel_disable_dsi_pll(struct intel_encoder *encoder)
+{
+	struct drm_device *dev = encoder->base.dev;
+
+	if (IS_VALLEYVIEW(dev))
+		vlv_disable_dsi_pll(encoder);
+	else if (IS_BROXTON(dev))
+		bxt_disable_dsi_pll(encoder);
+}
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH v3 4/14 drm/i915/bxt: DSI prepare changes for BXT

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

This patch modifies dsi_prepare() function to support the same modeset prepare sequence for BXT also. Main changes are:
1. BXT port control register is different than VLV.
2. BXT modeset sequence needs vdisplay and hdisplay programmed for transcoder.
3. BXT can select PIPE for MIPI transcoders.
4. BXT needs to program register MIPI_INIT_COUNT for both the ports, even if only one is being used.

v2: Fixed Jani's review comments. Rectified the DSI Macros to get
proper register offsets using _MIPI_PORT instead of _TRANSCODER

v3: Rebased on latest drm-nightly branch. Fixed Jani's review comments.

---
 drivers/gpu/drm/i915/i915_reg.h  |   21 ++++++++++++
 drivers/gpu/drm/i915/intel_dsi.c |   69 ++++++++++++++++++++++++++++++++------
 2 files changed, 80 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +21 -0
index 06bb2e1..997a999 100644
@@ -7362,6 +7362,22 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+/* BXT MIPI mode configure */
+#define  _BXT_MIPIA_TRANS_HACTIVE			0x6B0F8
+#define  _BXT_MIPIC_TRANS_HACTIVE			0x6B8F8
+#define  BXT_MIPI_TRANS_HACTIVE(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_HACTIVE, _BXT_MIPIC_TRANS_HACTIVE)
+
+#define  _BXT_MIPIA_TRANS_VACTIVE			0x6B0FC
+#define  _BXT_MIPIC_TRANS_VACTIVE			0x6B8FC
+#define  BXT_MIPI_TRANS_VACTIVE(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_VACTIVE, _BXT_MIPIC_TRANS_VACTIVE)
+
+#define  _BXT_MIPIA_TRANS_VTOTAL			0x6B100
+#define  _BXT_MIPIC_TRANS_VTOTAL			0x6B900
+#define  BXT_MIPI_TRANS_VTOTAL(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_VTOTAL, _BXT_MIPIC_TRANS_VTOTAL)
+
 #define BXT_DSI_PLL_CTL			0x161000
 #define  BXT_DSI_PLL_PVD_RATIO_SHIFT	16
 #define  BXT_DSI_PLL_PVD_RATIO_MASK	(3 << BXT_DSI_PLL_PVD_RATIO_SHIFT)
@@ -7797,6 +7813,11 @@ enum skl_disp_power_wells {
 #define  READ_REQUEST_PRIORITY_HIGH			(3 << 3)
 #define  RGB_FLIP_TO_BGR				(1 << 2)
 
+#define  BXT_PIPE_SELECT_MASK				(7 << 7)
+#define  BXT_PIPE_SELECT_C				(2 << 7)
+#define  BXT_PIPE_SELECT_B				(1 << 7)
+#define  BXT_PIPE_SELECT_A				(0 << 7)
+
 #define _MIPIA_DATA_ADDRESS		(dev_priv->mipi_mmio_base + 0xb108)
 #define _MIPIC_DATA_ADDRESS		(dev_priv->mipi_mmio_base + 0xb908)
 #define MIPI_DATA_ADDRESS(port)		_MIPI_PORT(port, _MIPIA_DATA_ADDRESS, \
drivers/gpu/drm/i915/intel_dsi.c +59 -10

87 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 4/14
#9 lore raw

Re: [BXT MIPI PATCH v3 04/14] drm/i915/bxt: DSI prepare changes for BXT

Quoted 11 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch modifies dsi_prepare() function to support the same modeset prepare sequence for BXT also. Main changes are:
1. BXT port control register is different than VLV.
2. BXT modeset sequence needs vdisplay and hdisplay programmed for transcoder.
3. BXT can select PIPE for MIPI transcoders.
4. BXT needs to program register MIPI_INIT_COUNT for both the ports, even if only one is being used.

Quoted 7 lines

v2: Fixed Jani's review comments. Rectified the DSI Macros to get
proper register offsets using _MIPI_PORT instead of _TRANSCODER

v3: Rebased on latest drm-nightly branch. Fixed Jani's review comments.

Quoted 141 lines
---
 drivers/gpu/drm/i915/i915_reg.h  |   21 ++++++++++++
 drivers/gpu/drm/i915/intel_dsi.c |   69 ++++++++++++++++++++++++++++++++------
 2 files changed, 80 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +21 -0
index 06bb2e1..997a999 100644
@@ -7362,6 +7362,22 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+/* BXT MIPI mode configure */
+#define  _BXT_MIPIA_TRANS_HACTIVE			0x6B0F8
+#define  _BXT_MIPIC_TRANS_HACTIVE			0x6B8F8
+#define  BXT_MIPI_TRANS_HACTIVE(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_HACTIVE, _BXT_MIPIC_TRANS_HACTIVE)
+
+#define  _BXT_MIPIA_TRANS_VACTIVE			0x6B0FC
+#define  _BXT_MIPIC_TRANS_VACTIVE			0x6B8FC
+#define  BXT_MIPI_TRANS_VACTIVE(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_VACTIVE, _BXT_MIPIC_TRANS_VACTIVE)
+
+#define  _BXT_MIPIA_TRANS_VTOTAL			0x6B100
+#define  _BXT_MIPIC_TRANS_VTOTAL			0x6B900
+#define  BXT_MIPI_TRANS_VTOTAL(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_VTOTAL, _BXT_MIPIC_TRANS_VTOTAL)
+
 #define BXT_DSI_PLL_CTL			0x161000
 #define  BXT_DSI_PLL_PVD_RATIO_SHIFT	16
 #define  BXT_DSI_PLL_PVD_RATIO_MASK	(3 << BXT_DSI_PLL_PVD_RATIO_SHIFT)
@@ -7797,6 +7813,11 @@ enum skl_disp_power_wells {
 #define  READ_REQUEST_PRIORITY_HIGH			(3 << 3)
 #define  RGB_FLIP_TO_BGR				(1 << 2)
 
+#define  BXT_PIPE_SELECT_MASK				(7 << 7)
+#define  BXT_PIPE_SELECT_C				(2 << 7)
+#define  BXT_PIPE_SELECT_B				(1 << 7)
+#define  BXT_PIPE_SELECT_A				(0 << 7)
+
 #define _MIPIA_DATA_ADDRESS		(dev_priv->mipi_mmio_base + 0xb108)
 #define _MIPIC_DATA_ADDRESS		(dev_priv->mipi_mmio_base + 0xb908)
 #define MIPI_DATA_ADDRESS(port)		_MIPI_PORT(port, _MIPIA_DATA_ADDRESS, \
drivers/gpu/drm/i915/intel_dsi.c +59 -10
index bac988a..6d0c992 100644
@@ -726,6 +726,21 @@ static void set_dsi_timings(struct drm_encoder *encoder,
 	hbp = txbyteclkhs(hbp, bpp, lane_count, intel_dsi->burst_mode_ratio);
 
 	for_each_dsi_port(port, intel_dsi->ports) {
+		if (IS_BROXTON(dev)) {
+			/*
+			 * Program hdisplay and vdisplay on MIPI transcoder.
+			 * This is different from calculated hactive and
+			 * vactive, as they are calculated per channel basis,
+			 * whereas these values should be based on resolution.
+			 */
+			I915_WRITE(BXT_MIPI_TRANS_HACTIVE(port),
+					mode->hdisplay);
+			I915_WRITE(BXT_MIPI_TRANS_VACTIVE(port),
+					mode->vdisplay);
+			I915_WRITE(BXT_MIPI_TRANS_VTOTAL(port),
+					mode->vtotal);
+		}
+
 		I915_WRITE(MIPI_HACTIVE_AREA_COUNT(port), hactive);
 		I915_WRITE(MIPI_HFP_COUNT(port), hfp);
 
@@ -766,16 +781,39 @@ static void intel_dsi_prepare(struct intel_encoder *intel_encoder)
 	}
 
 	for_each_dsi_port(port, intel_dsi->ports) {
-		/* escape clock divider, 20MHz, shared for A and C.
-		 * device ready must be off when doing this! txclkesc? */
-		tmp = I915_READ(MIPI_CTRL(PORT_A));
-		tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
-		I915_WRITE(MIPI_CTRL(PORT_A), tmp | ESCAPE_CLOCK_DIVIDER_1);
-
-		/* read request priority is per pipe */
-		tmp = I915_READ(MIPI_CTRL(port));
-		tmp &= ~READ_REQUEST_PRIORITY_MASK;
-		I915_WRITE(MIPI_CTRL(port), tmp | READ_REQUEST_PRIORITY_HIGH);
+		if (IS_VALLEYVIEW(dev)) {
+			/*
+			 * escape clock divider, 20MHz, shared for A and C.
+			 * device ready must be off when doing this! txclkesc?
+			 */
+			tmp = I915_READ(MIPI_CTRL(PORT_A));
+			tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
+			I915_WRITE(MIPI_CTRL(PORT_A), tmp |
+					ESCAPE_CLOCK_DIVIDER_1);
+
+			/* read request priority is per pipe */
+			tmp = I915_READ(MIPI_CTRL(port));
+			tmp &= ~READ_REQUEST_PRIORITY_MASK;
+			I915_WRITE(MIPI_CTRL(port), tmp |
+					READ_REQUEST_PRIORITY_HIGH);
+		} else if (IS_BROXTON(dev)) {
+			/*
+			 * FIXME:
+			 * BXT can connect any PIPE to any MIPI port.
+			 * Select the pipe based on the MIPI port read from
+			 * VBT for now. Pick PIPE A for MIPI port A and C
+			 * for port C.
+			 */
+			tmp = I915_READ(MIPI_CTRL(port));
+			tmp &= ~BXT_PIPE_SELECT_MASK;
+
+			if (port == PORT_A)
+				tmp |= BXT_PIPE_SELECT_A;
+			else if (port == PORT_C)
+				tmp |= BXT_PIPE_SELECT_C;
+
+			I915_WRITE(MIPI_CTRL(port), tmp);
+		}
 
 		/* XXX: why here, why like this? handling in irq handler?! */
 		I915_WRITE(MIPI_INTR_STAT(port), 0xffffffff);
@@ -852,6 +890,17 @@ static void intel_dsi_prepare(struct intel_encoder *intel_encoder)
 		I915_WRITE(MIPI_INIT_COUNT(port),
 				txclkesc(intel_dsi->escape_clk_div, 100));
 
+		if (IS_BROXTON(dev) && (!intel_dsi->dual_link)) {
+			/*
+			 * BXT spec says write MIPI_INIT_COUNT for
+			 * both the ports, even if only one is
+			 * getting used. So write the other port
+			 * if not in dual link mode.
+			 */
+			I915_WRITE(MIPI_INIT_COUNT(port ==
+						PORT_A ? PORT_C : PORT_A),
+					intel_dsi->init_count);
+		}
 
 		/* recovery disables */
 		I915_WRITE(MIPI_EOT_DISABLE(port), tmp);
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

Re: [BXT MIPI PATCH v3 04/14] drm/i915/bxt: DSI prepare changes for BXT

Quoted 15 lines · Jani Nikula
Quoted 14 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch modifies dsi_prepare() function to support the same modeset prepare sequence for BXT also. Main changes are:
1. BXT port control register is different than VLV.
2. BXT modeset sequence needs vdisplay and hdisplay programmed for transcoder.
3. BXT can select PIPE for MIPI transcoders.
4. BXT needs to program register MIPI_INIT_COUNT for both the ports, even if only one is being used.

v2: Fixed Jani's review comments. Rectified the DSI Macros to get
proper register offsets using _MIPI_PORT instead of _TRANSCODER

Quoted 6 lines
Quoted 4 lines

v3: Rebased on latest drm-nightly branch. Fixed Jani's review comments.

Merged up to this patch (except for patch 1, that should be at the end). -Daniel

Quoted 150 lines
Quoted 143 lines

---
 drivers/gpu/drm/i915/i915_reg.h  |   21 ++++++++++++
 drivers/gpu/drm/i915/intel_dsi.c |   69 ++++++++++++++++++++++++++++++++------
 2 files changed, 80 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +21 -0
index 06bb2e1..997a999 100644
@@ -7362,6 +7362,22 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+/* BXT MIPI mode configure */
+#define  _BXT_MIPIA_TRANS_HACTIVE			0x6B0F8
+#define  _BXT_MIPIC_TRANS_HACTIVE			0x6B8F8
+#define  BXT_MIPI_TRANS_HACTIVE(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_HACTIVE, _BXT_MIPIC_TRANS_HACTIVE)
+
+#define  _BXT_MIPIA_TRANS_VACTIVE			0x6B0FC
+#define  _BXT_MIPIC_TRANS_VACTIVE			0x6B8FC
+#define  BXT_MIPI_TRANS_VACTIVE(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_VACTIVE, _BXT_MIPIC_TRANS_VACTIVE)
+
+#define  _BXT_MIPIA_TRANS_VTOTAL			0x6B100
+#define  _BXT_MIPIC_TRANS_VTOTAL			0x6B900
+#define  BXT_MIPI_TRANS_VTOTAL(tc)	_MIPI_PORT(tc, \
+		_BXT_MIPIA_TRANS_VTOTAL, _BXT_MIPIC_TRANS_VTOTAL)
+
 #define BXT_DSI_PLL_CTL			0x161000
 #define  BXT_DSI_PLL_PVD_RATIO_SHIFT	16
 #define  BXT_DSI_PLL_PVD_RATIO_MASK	(3 << BXT_DSI_PLL_PVD_RATIO_SHIFT)
@@ -7797,6 +7813,11 @@ enum skl_disp_power_wells {
 #define  READ_REQUEST_PRIORITY_HIGH			(3 << 3)
 #define  RGB_FLIP_TO_BGR				(1 << 2)
 
+#define  BXT_PIPE_SELECT_MASK				(7 << 7)
+#define  BXT_PIPE_SELECT_C				(2 << 7)
+#define  BXT_PIPE_SELECT_B				(1 << 7)
+#define  BXT_PIPE_SELECT_A				(0 << 7)
+
 #define _MIPIA_DATA_ADDRESS		(dev_priv->mipi_mmio_base + 0xb108)
 #define _MIPIC_DATA_ADDRESS		(dev_priv->mipi_mmio_base + 0xb908)
 #define MIPI_DATA_ADDRESS(port)		_MIPI_PORT(port, _MIPIA_DATA_ADDRESS, \
drivers/gpu/drm/i915/intel_dsi.c +59 -10
index bac988a..6d0c992 100644
@@ -726,6 +726,21 @@ static void set_dsi_timings(struct drm_encoder *encoder,
 	hbp = txbyteclkhs(hbp, bpp, lane_count, intel_dsi->burst_mode_ratio);
 
 	for_each_dsi_port(port, intel_dsi->ports) {
+		if (IS_BROXTON(dev)) {
+			/*
+			 * Program hdisplay and vdisplay on MIPI transcoder.
+			 * This is different from calculated hactive and
+			 * vactive, as they are calculated per channel basis,
+			 * whereas these values should be based on resolution.
+			 */
+			I915_WRITE(BXT_MIPI_TRANS_HACTIVE(port),
+					mode->hdisplay);
+			I915_WRITE(BXT_MIPI_TRANS_VACTIVE(port),
+					mode->vdisplay);
+			I915_WRITE(BXT_MIPI_TRANS_VTOTAL(port),
+					mode->vtotal);
+		}
+
 		I915_WRITE(MIPI_HACTIVE_AREA_COUNT(port), hactive);
 		I915_WRITE(MIPI_HFP_COUNT(port), hfp);
 
@@ -766,16 +781,39 @@ static void intel_dsi_prepare(struct intel_encoder *intel_encoder)
 	}
 
 	for_each_dsi_port(port, intel_dsi->ports) {
-		/* escape clock divider, 20MHz, shared for A and C.
-		 * device ready must be off when doing this! txclkesc? */
-		tmp = I915_READ(MIPI_CTRL(PORT_A));
-		tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
-		I915_WRITE(MIPI_CTRL(PORT_A), tmp | ESCAPE_CLOCK_DIVIDER_1);
-
-		/* read request priority is per pipe */
-		tmp = I915_READ(MIPI_CTRL(port));
-		tmp &= ~READ_REQUEST_PRIORITY_MASK;
-		I915_WRITE(MIPI_CTRL(port), tmp | READ_REQUEST_PRIORITY_HIGH);
+		if (IS_VALLEYVIEW(dev)) {
+			/*
+			 * escape clock divider, 20MHz, shared for A and C.
+			 * device ready must be off when doing this! txclkesc?
+			 */
+			tmp = I915_READ(MIPI_CTRL(PORT_A));
+			tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
+			I915_WRITE(MIPI_CTRL(PORT_A), tmp |
+					ESCAPE_CLOCK_DIVIDER_1);
+
+			/* read request priority is per pipe */
+			tmp = I915_READ(MIPI_CTRL(port));
+			tmp &= ~READ_REQUEST_PRIORITY_MASK;
+			I915_WRITE(MIPI_CTRL(port), tmp |
+					READ_REQUEST_PRIORITY_HIGH);
+		} else if (IS_BROXTON(dev)) {
+			/*
+			 * FIXME:
+			 * BXT can connect any PIPE to any MIPI port.
+			 * Select the pipe based on the MIPI port read from
+			 * VBT for now. Pick PIPE A for MIPI port A and C
+			 * for port C.
+			 */
+			tmp = I915_READ(MIPI_CTRL(port));
+			tmp &= ~BXT_PIPE_SELECT_MASK;
+
+			if (port == PORT_A)
+				tmp |= BXT_PIPE_SELECT_A;
+			else if (port == PORT_C)
+				tmp |= BXT_PIPE_SELECT_C;
+
+			I915_WRITE(MIPI_CTRL(port), tmp);
+		}
 
 		/* XXX: why here, why like this? handling in irq handler?! */
 		I915_WRITE(MIPI_INTR_STAT(port), 0xffffffff);
@@ -852,6 +890,17 @@ static void intel_dsi_prepare(struct intel_encoder *intel_encoder)
 		I915_WRITE(MIPI_INIT_COUNT(port),
 				txclkesc(intel_dsi->escape_clk_div, 100));
 
+		if (IS_BROXTON(dev) && (!intel_dsi->dual_link)) {
+			/*
+			 * BXT spec says write MIPI_INIT_COUNT for
+			 * both the ports, even if only one is
+			 * getting used. So write the other port
+			 * if not in dual link mode.
+			 */
+			I915_WRITE(MIPI_INIT_COUNT(port ==
+						PORT_A ? PORT_C : PORT_A),
+					intel_dsi->init_count);
+		}
 
 		/* recovery disables */
 		I915_WRITE(MIPI_EOT_DISABLE(port), tmp);
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

PATCH v3 5/14 drm/i915/bxt: DSI encoder support in CRTC modeset

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   29 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   19 ++++++++++++++-----
 drivers/gpu/drm/i915/intel_dp_mst.c   |    1 +
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 5 files changed, 46 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index fd1de45..78d31c5 100644
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] + (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,
 	PORT_A = 0,
 	PORT_B,
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +28 -1
index cacb07b..5d5aad2 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct intel_encoder *intel_encoder,
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
 	} else {
 		DRM_ERROR("Invalid DDI encoder type %d\n", type);
 		BUG();
@@ -392,6 +396,11 @@ void intel_prepare_ddi(struct drm_device *dev)
 
 		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 
+		if (port == PORT_INVALID) {
+			WARN_ON(1);
+			continue;
+		}
+
 		if (visited[port])
 			continue;
 
@@ -980,6 +989,8 @@ static void bxt_ddi_clock_get(struct intel_encoder *encoder,
 	enum port port = intel_ddi_get_encoder_port(encoder);
 	uint32_t dpll = port;
 
+	WARN_ON(port == PORT_INVALID);
+
 	pipe_config->port_clock =
 		bxt_calc_pll_link(dev_priv, dpll);
 
@@ -1572,6 +1583,8 @@ void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc)
 	int type = intel_encoder->type;
 	uint32_t temp;
 
+	WARN_ON(port == PORT_INVALID);
+
 	/* Enable TRANS_DDI_FUNC_CTL for the pipe to work in HDMI mode */
 	temp = TRANS_DDI_FUNC_ENABLE;
 	temp |= TRANS_DDI_SELECT_PORT(port);
@@ -1684,6 +1697,8 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)
 	enum intel_display_power_domain power_domain;
 	uint32_t tmp;
 
+	WARN_ON(port == PORT_INVALID);
+
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	if (!intel_display_power_is_enabled(dev_priv, power_domain))
 		return false;
@@ -1730,6 +1745,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	u32 tmp;
 	int i;
 
+	WARN_ON(port == PORT_INVALID);
+
 	power_domain = intel_display_port_power_domain(encoder);
 	if (!intel_display_power_is_enabled(dev_priv, power_domain))
 		return false;
@@ -1779,11 +1796,14 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
 
+	WARN_ON(port == PORT_INVALID);
+
 	if (cpu_transcoder != TRANSCODER_EDP)
 		I915_WRITE(TRANS_CLK_SEL(cpu_transcoder),
 			   TRANS_CLK_SEL_PORT(port));
@@ -1870,6 +1890,8 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 	int type = intel_encoder->type;
 	int hdmi_level;
 
+	WARN_ON(port == PORT_INVALID);
+
 	if (type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 		intel_edp_panel_on(intel_dp);
@@ -1947,6 +1969,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder)
 	uint32_t val;
 	bool wait = false;
 
+	WARN_ON(port == PORT_INVALID);
+
 	val = I915_READ(DDI_BUF_CTL(port));
 	if (val & DDI_BUF_CTL_ENABLE) {
 		val &= ~DDI_BUF_CTL_ENABLE;
@@ -1986,6 +2010,8 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	int type = intel_encoder->type;
 
+	WARN_ON(port == PORT_INVALID);
+
 	if (type == INTEL_OUTPUT_HDMI) {
 		struct intel_digital_port *intel_dig_port =
 			enc_to_dig_port(encoder);
@@ -2732,6 +2758,7 @@ static bool intel_ddi_compute_config(struct intel_encoder *encoder,
 	int port = intel_ddi_get_encoder_port(encoder);
 
 	WARN(type == INTEL_OUTPUT_UNKNOWN, "compute_config() on unknown output!\n");
+	WARN_ON(port == PORT_INVALID);
 
 	if (port == PORT_A)
 		pipe_config->cpu_transcoder = TRANSCODER_EDP;
drivers/gpu/drm/i915/intel_display.c +14 -5
index b8e0310..7f39cc9 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5033,7 +5034,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5051,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,13 +5060,16 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
 	drm_crtc_vblank_on(crtc);
 
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
+
 		encoder->enable(encoder);
 		intel_opregion_notify_encoder(encoder, true);
 	}
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
index 600afdb..d69186c 100644
@@ -173,6 +173,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder)
 
 	if (intel_dp->active_mst_links == 0) {
 		enum port port = intel_ddi_get_encoder_port(encoder);
+		WARN_ON(port == PORT_INVALID);
 
 		/* FIXME: add support for SKL */
 		if (INTEL_INFO(dev)->gen < 9)
drivers/gpu/drm/i915/intel_opregion.c +2 -1
index 4813374..326aa6b 100644
@@ -335,7 +335,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		return 0;
 
 	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if ((port == PORT_E) || (port == PORT_INVALID)) {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +356,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 46 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   29 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   19 ++++++++++++++-----
 drivers/gpu/drm/i915/intel_dp_mst.c   |    1 +
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 5 files changed, 46 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index fd1de45..78d31c5 100644
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] + (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,
 	PORT_A = 0,
 	PORT_B,
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..5d5aad2 100644

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct intel_encoder *intel_encoder,
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

Please remind me again what are the legitimate paths to get here with DSI?

With all the changes and warns across the driver, I'm beginning to think we should have a version of this function that accepts DSI, and another one that (calls the other one) and WARNS on DSI, and that should be called on all paths that should never encounter a DSI encoder.

The proliferation of WARNS all over the place is not very nice.

I'm sorry, I know this is not the review I gave previously on this.

BR,
Jani.

Quoted 216 lines
drivers/gpu/drm/i915/intel_ddi.c +24 -1
 	} else {
 		DRM_ERROR("Invalid DDI encoder type %d\n", type);
 		BUG();
@@ -392,6 +396,11 @@ void intel_prepare_ddi(struct drm_device *dev)
 
 		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 
+		if (port == PORT_INVALID) {
+			WARN_ON(1);
+			continue;
+		}
+
 		if (visited[port])
 			continue;
 
@@ -980,6 +989,8 @@ static void bxt_ddi_clock_get(struct intel_encoder *encoder,
 	enum port port = intel_ddi_get_encoder_port(encoder);
 	uint32_t dpll = port;
 
+	WARN_ON(port == PORT_INVALID);
+
 	pipe_config->port_clock =
 		bxt_calc_pll_link(dev_priv, dpll);
 
@@ -1572,6 +1583,8 @@ void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc)
 	int type = intel_encoder->type;
 	uint32_t temp;
 
+	WARN_ON(port == PORT_INVALID);
+
 	/* Enable TRANS_DDI_FUNC_CTL for the pipe to work in HDMI mode */
 	temp = TRANS_DDI_FUNC_ENABLE;
 	temp |= TRANS_DDI_SELECT_PORT(port);
@@ -1684,6 +1697,8 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)
 	enum intel_display_power_domain power_domain;
 	uint32_t tmp;
 
+	WARN_ON(port == PORT_INVALID);
+
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	if (!intel_display_power_is_enabled(dev_priv, power_domain))
 		return false;
@@ -1730,6 +1745,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	u32 tmp;
 	int i;
 
+	WARN_ON(port == PORT_INVALID);
+
 	power_domain = intel_display_port_power_domain(encoder);
 	if (!intel_display_power_is_enabled(dev_priv, power_domain))
 		return false;
@@ -1779,11 +1796,14 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
 
+	WARN_ON(port == PORT_INVALID);
+
 	if (cpu_transcoder != TRANSCODER_EDP)
 		I915_WRITE(TRANS_CLK_SEL(cpu_transcoder),
 			   TRANS_CLK_SEL_PORT(port));
@@ -1870,6 +1890,8 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 	int type = intel_encoder->type;
 	int hdmi_level;
 
+	WARN_ON(port == PORT_INVALID);
+
 	if (type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 		intel_edp_panel_on(intel_dp);
@@ -1947,6 +1969,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder)
 	uint32_t val;
 	bool wait = false;
 
+	WARN_ON(port == PORT_INVALID);
+
 	val = I915_READ(DDI_BUF_CTL(port));
 	if (val & DDI_BUF_CTL_ENABLE) {
 		val &= ~DDI_BUF_CTL_ENABLE;
@@ -1986,6 +2010,8 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	int type = intel_encoder->type;
 
+	WARN_ON(port == PORT_INVALID);
+
 	if (type == INTEL_OUTPUT_HDMI) {
 		struct intel_digital_port *intel_dig_port =
 			enc_to_dig_port(encoder);
@@ -2732,6 +2758,7 @@ static bool intel_ddi_compute_config(struct intel_encoder *encoder,
 	int port = intel_ddi_get_encoder_port(encoder);
 
 	WARN(type == INTEL_OUTPUT_UNKNOWN, "compute_config() on unknown output!\n");
+	WARN_ON(port == PORT_INVALID);
 
 	if (port == PORT_A)
 		pipe_config->cpu_transcoder = TRANSCODER_EDP;
drivers/gpu/drm/i915/intel_display.c +14 -5
index b8e0310..7f39cc9 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5033,7 +5034,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5051,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,13 +5060,16 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
 	drm_crtc_vblank_on(crtc);
 
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
+
 		encoder->enable(encoder);
 		intel_opregion_notify_encoder(encoder, true);
 	}
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
index 600afdb..d69186c 100644
@@ -173,6 +173,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder)
 
 	if (intel_dp->active_mst_links == 0) {
 		enum port port = intel_ddi_get_encoder_port(encoder);
+		WARN_ON(port == PORT_INVALID);
 
 		/* FIXME: add support for SKL */
 		if (INTEL_INFO(dev)->gen < 9)
drivers/gpu/drm/i915/intel_opregion.c +2 -1
index 4813374..326aa6b 100644
@@ -335,7 +335,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		return 0;
 
 	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if ((port == PORT_E) || (port == PORT_INVALID)) {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +356,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 75 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 7:48 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct

Quoted 48 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   29 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   19 ++++++++++++++-----
 drivers/gpu/drm/i915/intel_dp_mst.c   |    1 +
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 5 files changed, 46 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] +
 (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,
 	PORT_A = 0,
 	PORT_B,
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..5d5aad2 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

Please remind me again what are the legitimate paths to get here with DSI?

With all the changes and warns across the driver, I'm beginning to think we should have a version of this function that accepts DSI, and another one that (calls the other one) and WARNS on DSI, and that should be called on all paths that should never encounter a DSI encoder.

Quoted 6 lines

The proliferation of WARNS all over the place is not very nice.

I'm sorry, I know this is not the review I gave previously on this.

BR,
Jani.

This is a tricky piece Jani. Our code for BXT extensively uses haswell functions which was a DDI only implementation. So many functions just use intel_ddi_get_encoder_port (bxt_ddi_clock_get is one such example). Currently I have added WARN_ON in all of these functions, though some may not get called if DSI encoder is present. We can remove those, but still this will be a good check to have IMO.

Overall, I feel even if we implement two separate functions, for the generic functions to pick the correct one, we may have to have a DSI check there in those generic functions.

Please suggest.

Regards,
Uma Shankar

Quoted 3 lines

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 236

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	} else {
 		DRM_ERROR("Invalid DDI encoder type %d\n", type);
 		BUG();

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 82 lines · Uma
Quoted 75 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 7:48 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct

Quoted 48 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   29 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   19 ++++++++++++++-----
 drivers/gpu/drm/i915/intel_dp_mst.c   |    1 +
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 5 files changed, 46 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] +
 (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,
 	PORT_A = 0,
 	PORT_B,
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..5d5aad2 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

Please remind me again what are the legitimate paths to get here with DSI?

With all the changes and warns across the driver, I'm beginning to think we should have a version of this function that accepts DSI, and another one that (calls the other one) and WARNS on DSI, and that should be called on all paths that should never encounter a DSI encoder.

Quoted 6 lines

The proliferation of WARNS all over the place is not very nice.

I'm sorry, I know this is not the review I gave previously on this.

BR,
Jani.

Quoted 7 lines

This is a tricky piece Jani. Our code for BXT extensively uses haswell functions which was a DDI only implementation. So many functions just use intel_ddi_get_encoder_port (bxt_ddi_clock_get is one such example). Currently I have added WARN_ON in all of these functions, though some may not get called if DSI encoder is present. We can remove those, but still this will be a good check to have IMO.

Overall, I feel even if we implement two separate functions, for the generic functions to pick the correct one, we may have to have a DSI check there in those generic functions.

Yeah hsw+ ddi design isn't great since the split between encoder and crtc isn't where the crossbar is, which means there's lots of calls from crtc code into DDI encoder functions. I started with that reshuffling a while back but Paulo shot it down a bit, but I think with bxt dsi we have a good reason for this.

Essentially all differences between DSI, DDI (hdmi or DP) and DDI in FDI mode (for vga on hsw) should be hidden behind intel_encoder callbacks.

But since it doesn't make much sense to hold up dsi enabling for even longer we should do that in parallel. And for doing that refactoring throwing piles of WARN_ON checks at the code imo makes sense (even if it doesn't look pretty).
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 97 lines · Daniel Vetter
Quoted 82 lines · Uma
Quoted 75 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 7:48 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct

Quoted 48 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   29 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   19 ++++++++++++++-----
 drivers/gpu/drm/i915/intel_dp_mst.c   |    1 +
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 5 files changed, 46 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] +
 (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,
 	PORT_A = 0,
 	PORT_B,
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..5d5aad2 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

Please remind me again what are the legitimate paths to get here with DSI?

With all the changes and warns across the driver, I'm beginning to think we should have a version of this function that accepts DSI, and another one that (calls the other one) and WARNS on DSI, and that should be called on all paths that should never encounter a DSI encoder.

Quoted 6 lines

The proliferation of WARNS all over the place is not very nice.

I'm sorry, I know this is not the review I gave previously on this.

BR,
Jani.

Quoted 7 lines

This is a tricky piece Jani. Our code for BXT extensively uses haswell functions which was a DDI only implementation. So many functions just use intel_ddi_get_encoder_port (bxt_ddi_clock_get is one such example). Currently I have added WARN_ON in all of these functions, though some may not get called if DSI encoder is present. We can remove those, but still this will be a good check to have IMO.

Overall, I feel even if we implement two separate functions, for the generic functions to pick the correct one, we may have to have a DSI check there in those generic functions.

Yeah hsw+ ddi design isn't great since the split between encoder and crtc isn't where the crossbar is, which means there's lots of calls from crtc code into DDI encoder functions. I started with that reshuffling a while back but Paulo shot it down a bit, but I think with bxt dsi we have a good reason for this.

Quoted 7 lines

Essentially all differences between DSI, DDI (hdmi or DP) and DDI in FDI mode (for vga on hsw) should be hidden behind intel_encoder callbacks.

But since it doesn't make much sense to hold up dsi enabling for even longer we should do that in parallel. And for doing that refactoring throwing piles of WARN_ON checks at the code imo makes sense (even if it doesn't look pretty).

As far as I can tell, there's two calls to {intel_}ddi_get_encoder_port that are functionally changed for DSI in this patch: intel_prepare_ddi() (which adds a WARN for good measure anyway), and intel_opregion_notify_encoder().

I am wondering if it would be cleaner to check for intel_encoder->type == INTEL_OUTPUT_DSI in these two sites *instead* of doing the call, and having a WARN_ON(type == INTEL_OUTPUT_DSI) inside ddi_get_encoder_port.

My worry beyond this patch is that the checks for PORT_INVALID will proliferate across the driver for no good reason other than this corner case.

BR,
Jani.

Quoted 5 lines

-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 111 lines · Jani Nikula
Quoted 97 lines · Daniel Vetter
Quoted 82 lines · Uma
Quoted 75 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 7:48 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct

Quoted 48 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   29 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   19 ++++++++++++++-----
 drivers/gpu/drm/i915/intel_dp_mst.c   |    1 +
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 5 files changed, 46 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] +
 (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,
 	PORT_A = 0,
 	PORT_B,
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..5d5aad2 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

Please remind me again what are the legitimate paths to get here with DSI?

With all the changes and warns across the driver, I'm beginning to think we should have a version of this function that accepts DSI, and another one that (calls the other one) and WARNS on DSI, and that should be called on all paths that should never encounter a DSI encoder.

Quoted 6 lines

The proliferation of WARNS all over the place is not very nice.

I'm sorry, I know this is not the review I gave previously on this.

BR,
Jani.

Quoted 7 lines

This is a tricky piece Jani. Our code for BXT extensively uses haswell functions which was a DDI only implementation. So many functions just use intel_ddi_get_encoder_port (bxt_ddi_clock_get is one such example). Currently I have added WARN_ON in all of these functions, though some may not get called if DSI encoder is present. We can remove those, but still this will be a good check to have IMO.

Overall, I feel even if we implement two separate functions, for the generic functions to pick the correct one, we may have to have a DSI check there in those generic functions.

Yeah hsw+ ddi design isn't great since the split between encoder and crtc isn't where the crossbar is, which means there's lots of calls from crtc code into DDI encoder functions. I started with that reshuffling a while back but Paulo shot it down a bit, but I think with bxt dsi we have a good reason for this.

Quoted 7 lines

Essentially all differences between DSI, DDI (hdmi or DP) and DDI in FDI mode (for vga on hsw) should be hidden behind intel_encoder callbacks.

But since it doesn't make much sense to hold up dsi enabling for even longer we should do that in parallel. And for doing that refactoring throwing piles of WARN_ON checks at the code imo makes sense (even if it doesn't look pretty).

As far as I can tell, there's two calls to {intel_}ddi_get_encoder_port that are functionally changed for DSI in this patch: intel_prepare_ddi() (which adds a WARN for good measure anyway), and intel_opregion_notify_encoder().

Quoted 7 lines

I am wondering if it would be cleaner to check for intel_encoder->type == INTEL_OUTPUT_DSI in these two sites *instead* of doing the call, and having a WARN_ON(type == INTEL_OUTPUT_DSI) inside ddi_get_encoder_port.

My worry beyond this patch is that the checks for PORT_INVALID will proliferate across the driver for no good reason other than this corner case.

I like this idea, since it also aligns more with the rework we need to do For that one we probably need to add a ddi_port to the crtc config and make sure only ddi encoder related code (for hdmi/dp and vga w/ fdi) use it.

Seems like the simpler solution with less interim detour overall. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 138 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, September 23, 2015 6:42 PM
To: Nikula, Jani
Cc: Daniel Vetter; Shankar, Uma; [email protected]; Kumar, Shobhit
Subject: Re: [Intel-gfx] [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 29 lines · Jani Nikula
Quoted 28 lines · Daniel Vetter
Quoted 27 lines · Uma
Quoted 27 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 7:48 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 16 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   29

++++++++++++++++++++++++++++-

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct

Quoted 24 lines
 drivers/gpu/drm/i915/intel_display.c  |   19 ++++++++++++++-----
 drivers/gpu/drm/i915/intel_dp_mst.c   |    1 +
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 5 files changed, 46 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -142,6 +142,7 @@ enum plane {  #define sprite_name(p, s) ((p)
 * INTEL_INFO(dev)->num_sprites[(p)] +
 (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,
 	PORT_A = 0,
 	PORT_B,
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..5d5aad2 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct

intel_encoder *intel_encoder,

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

Please remind me again what are the legitimate paths to get here with

DSI?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

With all the changes and warns across the driver, I'm beginning to think we should have a version of this function that accepts DSI, and another one that (calls the other one) and WARNS on DSI, and that should be called on all paths that should never encounter a DSI

encoder.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

The proliferation of WARNS all over the place is not very nice.

I'm sorry, I know this is not the review I gave previously on this.

BR,
Jani.

This is a tricky piece Jani. Our code for BXT extensively uses haswell

functions which was a DDI only implementation.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

So many functions just use intel_ddi_get_encoder_port (bxt_ddi_clock_get is one such example). Currently I have added WARN_ON in all of these functions, though some may not get called if DSI

encoder is present. We can remove those, but still this will be a good check to have IMO.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Overall, I feel even if we implement two separate functions, for the generic functions to pick the correct one, we may have to have a DSI

check there in those generic functions.

Quoted 15 lines
Quoted 7 lines

Yeah hsw+ ddi design isn't great since the split between encoder and crtc isn't where the crossbar is, which means there's lots of calls from crtc code into DDI encoder functions. I started with that reshuffling a while back but Paulo shot it down a bit, but I think with bxt dsi we have a good reason for this.

Quoted 7 lines

Essentially all differences between DSI, DDI (hdmi or DP) and DDI in FDI mode (for vga on hsw) should be hidden behind intel_encoder callbacks.

But since it doesn't make much sense to hold up dsi enabling for even longer we should do that in parallel. And for doing that refactoring throwing piles of WARN_ON checks at the code imo makes sense (even if it doesn't look pretty).

Quoted 8 lines

As far as I can tell, there's two calls to {intel_}ddi_get_encoder_port that are functionally changed for DSI in this patch: intel_prepare_ddi() (which adds a WARN for good measure anyway), and intel_opregion_notify_encoder().

I am wondering if it would be cleaner to check for intel_encoder->type == INTEL_OUTPUT_DSI in these two sites *instead* of doing the call, and having a WARN_ON(type == INTEL_OUTPUT_DSI) inside

ddi_get_encoder_port.

Quoted 4 lines

My worry beyond this patch is that the checks for PORT_INVALID will proliferate across the driver for no good reason other than this corner case.

Quoted 7 lines

I like this idea, since it also aligns more with the rework we need to do For that one we probably need to add a ddi_port to the crtc config and make sure only ddi encoder related code (for hdmi/dp and vga w/ fdi) use it.

Seems like the simpler solution with less interim detour overall. -Daniel
--

The suggestion looks good. Will remove the WARN_ON spilled all over and put the warning in intel_ddi_get_encoder_port instead, if it's a NON DSI encoder.

Thanks Jani for the suggestion.

Regards,
Uma Shankar
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

In reply to Uma Shankar
Quoted 5 lines · Uma Shankar
drivers/gpu/drm/i915/intel_display.c +0 -1
@@ -5057,13 +5060,16 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc) · line 5072

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
 	drm_crtc_vblank_on(crtc);
 
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
+

We should not modify the crtc enable sequence to accommodate the needs of one encoder type only. The hook names should be taken as describing roughly when in the sequence they are called, not necessarily what they must do for each encoder. If an encoder requires a different ordering or sequence, it should handle this in what it does in its hooks - and this may possibly need to be different on each platform.

Here, the ->pre_pll_enable call is added after the ->pre_enable call, making the sequence of calls surprising. Also, there is no point in calling ->pre_pll_enable in the same loop as ->enable; the encoder could just as well do everything in ->enable. Indeed, this may be what you should do on Broxton.

I'm willing to ignore [1] if Daniel thinks my worry is unwarranted, but this part must be fixed.

BR,
Jani.

[1] http://mid.gmane.org/[email protected]

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 		encoder->enable(encoder);
 		intel_opregion_notify_encoder(encoder, true);
 	}
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 38 lines

-----Original Message-----
From: Nikula, Jani
Sent: Wednesday, September 23, 2015 6:24 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Review static void haswell_crtc_enable(struct drm_crtc

Quoted 1 line · Uma Shankar
(quoted diff) +0 -0
@@ -5057,13 +5060,16 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +0 -1
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc) · line 5072

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
 	drm_crtc_vblank_on(crtc);
 
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
+

We should not modify the crtc enable sequence to accommodate the needs of one encoder type only. The hook names should be taken as describing roughly when in the sequence they are called, not necessarily what they must do for each encoder. If an encoder requires a different ordering or sequence, it should handle this in what it does in its hooks - and this may possibly need to be different on each platform.

Here, the ->pre_pll_enable call is added after the ->pre_enable call, making the sequence of calls surprising. Also, there is no point in calling ->pre_pll_enable in the same loop as ->enable; the encoder could just as well do everything in -

Quoted 9 lines
Quoted 1 line

enable. Indeed, this may be what you should do on Broxton.

I'm willing to ignore [1] if Daniel thinks my worry is unwarranted, but this part must be fixed.

BR,
Jani.

The pre_pll_enable callback was not being used earlier for any encoder in haswell functions. This is the reason we used it for DSI at place appropriate for DSI sequence. I will remove the callback and put the code in encoder->enable callback itself.

Regards,
Uma Shankar

Quoted 7 lines

[1] http://mid.gmane.org/[email protected]

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 		encoder->enable(encoder);
 		intel_opregion_notify_encoder(encoder, true);
 	}

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#20 lore raw

Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 61 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Wednesday, September 23, 2015 8:19 PM
To: Nikula, Jani; [email protected]
Cc: Kumar, Shobhit
Subject: Re: [Intel-gfx] [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 38 lines

-----Original Message-----
From: Nikula, Jani
Sent: Wednesday, September 23, 2015 6:24 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 2 lines · Uma Shankar
(quoted diff) +0 -0
@@ -5057,13 +5060,16 @@ static void haswell_crtc_enable(struct

drm_crtc

*crtc)

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +0 -1
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc) · line 5072

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
 	drm_crtc_vblank_on(crtc);
 
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
+

We should not modify the crtc enable sequence to accommodate the needs of one encoder type only. The hook names should be taken as describing roughly when in the sequence they are called, not necessarily what they must do for each encoder. If an encoder requires a different ordering or sequence, it should handle this in what it does in its hooks - and this may possibly need to be different on each platform.

Here, the ->pre_pll_enable call is added after the ->pre_enable call, making the sequence of calls surprising. Also, there is no point in calling ->pre_pll_enable in the same loop as ->enable; the encoder could just as well do everything in -

Quoted 9 lines
Quoted 1 line

enable. Indeed, this may be what you should do on Broxton.

I'm willing to ignore [1] if Daniel thinks my worry is unwarranted, but this part must be fixed.

BR,
Jani.

Quoted 7 lines

The pre_pll_enable callback was not being used earlier for any encoder in haswell functions.
This is the reason we used it for DSI at place appropriate for DSI sequence. I will remove the callback and put the code in encoder->enable callback itself.

Regards,
Uma Shankar

This callback should ideally be before pre_enable. I will update and resend the patch. This is the order followed for BYT/CHT as well.

Regards,
Uma Shankar

The correct order for BXT is also pre_pll_enable,

Quoted 8 lines
Quoted 7 lines

[1] http://mid.gmane.org/[email protected]

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 		encoder->enable(encoder);
 		intel_opregion_notify_encoder(encoder, true);
 	}
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#21 lore raw

PATCH v4 5/14 drm/i915/bxt: DSI encoder support in CRTC modeset

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   21 ++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 4 files changed, 38 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index fd1de45..78d31c5 100644
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] + (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,
 	PORT_A = 0,
 	PORT_B,
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +20 -1
index cacb07b..8edb632 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct intel_encoder *intel_encoder,
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
 	} else {
 		DRM_ERROR("Invalid DDI encoder type %d\n", type);
 		BUG();
@@ -237,6 +241,15 @@ enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder)
 {
 	struct intel_digital_port *dig_port;
 	enum port port;
+	int type = intel_encoder->type;
+
+	if (type == INTEL_OUTPUT_DSI) {
+		port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
+		WARN_ON(1);
+
+		return port;
+	}
 
 	ddi_get_encoder_port(intel_encoder, &dig_port, &port);
 
@@ -392,6 +405,11 @@ void intel_prepare_ddi(struct drm_device *dev)
 
 		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 
+		if (port == PORT_INVALID) {
+			WARN_ON(1);
+			continue;
+		}
+
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1797,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +15 -6
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
@@ -5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5054,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +2 -1
index 4813374..326aa6b 100644
@@ -335,7 +335,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		return 0;
 
 	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if ((port == PORT_E) || (port == PORT_INVALID)) {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +356,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#22 lore raw

Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 36 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   21 ++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 4 files changed, 38 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h enum plane { · line 145

Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] + (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,

My idea was that you wouldn't add this. Maybe I wasn't clear enough.

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_A = 0,
 	PORT_B,
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..8edb632 100644

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct intel_encoder *intel_encoder,
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you could do a warn here. Doesn't matter what you set *port to, it's going to be wrong anyway, and this is only slightly better than not oopsing on the BUG below.

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	} else {
 		DRM_ERROR("Invalid DDI encoder type %d\n", type);
 		BUG();
@@ -237,6 +241,15 @@ enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder)
 {
 	struct intel_digital_port *dig_port;

drivers/gpu/drm/i915/intel_ddi.c enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder) · line 252

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +9 -0
 	enum port port;
+	int type = intel_encoder->type;
+
+	if (type == INTEL_OUTPUT_DSI) {
+		port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
+		WARN_ON(1);
+
+		return port;
+	}

Remove these.

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 407

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	ddi_get_encoder_port(intel_encoder, &dig_port, &port);
 
@@ -392,6 +405,11 @@ void intel_prepare_ddi(struct drm_device *dev)
 
 		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you'd have to add a check for DSI here.

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 409

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+		if (port == PORT_INVALID) {
+			WARN_ON(1);

But this warn now makes me think we don't ever get here on with DSI. Don't warn for normal cases.

Quoted 104 lines
drivers/gpu/drm/i915/intel_ddi.c +5 -1
+			continue;
+		}
+
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1797,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +15 -6
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
@@ -5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5054,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +0 -0
index 4813374..326aa6b 100644

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, · line 337

Quoted 3 lines
drivers/gpu/drm/i915/intel_opregion.c +0 -0
@@ -335,7 +335,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		return 0;
 
 	port = intel_ddi_get_encoder_port(intel_encoder);

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you'd have to add a check for DSI here.

BR,
Jani.

Quoted 16 lines
drivers/gpu/drm/i915/intel_opregion.c +2 -1
-	if (port == PORT_E) {
+	if ((port == PORT_E) || (port == PORT_INVALID)) {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +356,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#23 lore raw

Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 88 lines

-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Monday, September 28, 2015 6:58 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 36 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   21 ++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 4 files changed, 38 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h enum plane { · line 146

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] +
 (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,

My idea was that you wouldn't add this. Maybe I wasn't clear enough.

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct

Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_A = 0,
 	PORT_B,
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..8edb632 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you could do a warn here. Doesn't matter what you set *port to, it's going to be wrong anyway, and this is only slightly better than not oopsing on the BUG below.

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
 	} else {
 		DRM_ERROR("Invalid DDI encoder type %d\n", type);
 		BUG();
@@ -237,6 +241,15 @@ enum port intel_ddi_get_encoder_port(struct
 intel_encoder *intel_encoder)  {
 	struct intel_digital_port *dig_port;
 	enum port port;
+	int type = intel_encoder->type;
+
+	if (type == INTEL_OUTPUT_DSI) {
Quoted 9 lines

drivers/gpu/drm/i915/intel_ddi.c enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder) · line 252

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
+		port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
+		WARN_ON(1);
+
+		return port;
+	}

Remove these.

intel_ddi_get_encoder_port is the one getting called from multiple locations. This expects an enum to be returned. We could either set the *port in

@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct
intel_encoder *intel_encoder,
} else if (type == INTEL_OUTPUT_ANALOG) {
*dig_port = NULL;
*port = PORT_E;
+ } else if (type == INTEL_OUTPUT_DSI) {
+ *dig_port = NULL;
+ *port = PORT_INVALID;
+ DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

And let this function return the PORT_INVALID with a WARN. Or we can initialize the port to PORT_INVALID and return that instead. Then I can remove these lines from here. Also, If we try to avoid this function getting called from various locations, we will again end up to the original problem of spilled over DSI checks at multiple places in code.

Please suggest which ever looks ok.

Quoted 11 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 407

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	ddi_get_encoder_port(intel_encoder, &dig_port, &port);
 
@@ -392,6 +405,11 @@ void intel_prepare_ddi(struct drm_device *dev)
 
 		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you'd have to add a check for DSI here.

Quoted 5 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 409

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+		if (port == PORT_INVALID) {
+			WARN_ON(1);

But this warn now makes me think we don't ever get here on with DSI. Don't warn for normal cases.

Yes, you are right. This shouldn't be Warning, just a DSI protection should be fine. Will rectify this.

Quoted 115 lines

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 22 lines
drivers/gpu/drm/i915/intel_ddi.c +5 -1
+			continue;
+		}
+
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1797,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder
 *encoder,  void intel_ddi_enable_pipe_clock(struct intel_crtc
 *intel_crtc)  {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +0 -0
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv,

TRANSCODER_A, @@

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 10 lines

-5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1); @@ -5049,7 +5054,8 @@

static

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 11 lines

void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc *crtc)

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2 -1
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0); @@ -5188,7 +5196,8 @@

static

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 16 lines

void haswell_crtc_disable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +0 -0
index 4813374..326aa6b 100644
@@ -335,7 +335,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 7 lines

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, · line 337

Quoted 3 lines
drivers/gpu/drm/i915/intel_opregion.c +0 -0
 		return 0;
 
 	port = intel_ddi_get_encoder_port(intel_encoder);

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you'd have to add a check for DSI here.

Currently, I have implemented it as all other occurrences of this function. Even if it gets called for DSI, it will return PORT_INVALID. That case is handled below.

But it would be better to check for DSI and avoid the call and an unnecessary Warning. Will change this.

Please comment if the overall approach looks OK. Will implement accordingly.

Thanks for all the suggestions and comments.

Regards,
Uma Shankar

Quoted 10 lines

BR,
Jani.

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 6 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
-	if (port == PORT_E) {
+	if ((port == PORT_E) || (port == PORT_INVALID)) {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +356,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 13 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
--

1.7.9.5

--
Jani Nikula, Intel Open Source Technology Center

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#24 lore raw

Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 108 lines · Uma
Quoted 86 lines

-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Monday, September 28, 2015 6:58 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 36 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   21 ++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 4 files changed, 38 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h enum plane { · line 146

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] +
 (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,

My idea was that you wouldn't add this. Maybe I wasn't clear enough.

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct

Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_A = 0,
 	PORT_B,
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..8edb632 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you could do a warn here. Doesn't matter what you set *port to, it's going to be wrong anyway, and this is only slightly better than not oopsing on the BUG below.

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
 	} else {
 		DRM_ERROR("Invalid DDI encoder type %d\n", type);
 		BUG();
@@ -237,6 +241,15 @@ enum port intel_ddi_get_encoder_port(struct
 intel_encoder *intel_encoder)  {
 	struct intel_digital_port *dig_port;
 	enum port port;
+	int type = intel_encoder->type;
+
+	if (type == INTEL_OUTPUT_DSI) {
Quoted 9 lines

drivers/gpu/drm/i915/intel_ddi.c enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder) · line 252

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
+		port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
+		WARN_ON(1);
+
+		return port;
+	}

Remove these.

intel_ddi_get_encoder_port is the one getting called from multiple locations. This expects an enum to be returned. We could either set the *port in

@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct
intel_encoder *intel_encoder,
} else if (type == INTEL_OUTPUT_ANALOG) {
*dig_port = NULL;
*port = PORT_E;

drivers/gpu/drm/i915/intel_ddi.c +4 -0
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
Quoted 4 lines

And let this function return the PORT_INVALID with a WARN. Or we can initialize the port to PORT_INVALID and return that instead. Then I can remove these lines from here. Also, If we try to avoid this function getting called from various locations, we will again end up to the original problem of spilled over DSI checks at multiple places in code.

Please suggest which ever looks ok.

I just sent two patches [1][2] to modify ddi_get_encoder_port a little. Rebase on top, and don't modify ddi_get_encoder_port() or intel_ddi_get_encoder_port() at all. Just make sure you don't call the functions for DSI. No need to add PORT_INVALID either.

BR,
Jani.

[1] http://mid.gmane.org/[email protected]
[2] http://mid.gmane.org/[email protected]

Quoted 178 lines
Quoted 12 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 407

Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	ddi_get_encoder_port(intel_encoder, &dig_port, &port);
 
@@ -392,6 +405,11 @@ void intel_prepare_ddi(struct drm_device *dev)
 
 		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you'd have to add a check for DSI here.

Quoted 5 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 409

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+		if (port == PORT_INVALID) {
+			WARN_ON(1);

But this warn now makes me think we don't ever get here on with DSI. Don't warn for normal cases.

Yes, you are right. This shouldn't be Warning, just a DSI protection should be fine. Will rectify this.

Quoted 115 lines

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 22 lines
drivers/gpu/drm/i915/intel_ddi.c +5 -1
+			continue;
+		}
+
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1797,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder
 *encoder,  void intel_ddi_enable_pipe_clock(struct intel_crtc
 *intel_crtc)  {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +0 -0
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv,

TRANSCODER_A, @@

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 10 lines

-5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1); @@ -5049,7 +5054,8 @@

static

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 11 lines

void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc *crtc)

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2 -1
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0); @@ -5188,7 +5196,8 @@

static

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 16 lines

void haswell_crtc_disable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +0 -0
index 4813374..326aa6b 100644
@@ -335,7 +335,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 7 lines

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, · line 337

Quoted 3 lines
drivers/gpu/drm/i915/intel_opregion.c +0 -0
 		return 0;
 
 	port = intel_ddi_get_encoder_port(intel_encoder);

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you'd have to add a check for DSI here.

Currently, I have implemented it as all other occurrences of this function. Even if it gets called for DSI, it will return PORT_INVALID. That case is handled below.

But it would be better to check for DSI and avoid the call and an unnecessary Warning. Will change this.

Please comment if the overall approach looks OK. Will implement accordingly.

Thanks for all the suggestions and comments.

Regards,
Uma Shankar

Quoted 23 lines

BR,
Jani.

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 6 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
-	if (port == PORT_E) {
+	if ((port == PORT_E) || (port == PORT_INVALID)) {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +356,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 10 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
--

1.7.9.5

--
Jani Nikula, Intel Open Source Technology Center

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#25 lore raw

Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 131 lines

-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Tuesday, September 29, 2015 12:59 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank
Subject: RE: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 111 lines · Uma
Quoted 87 lines

-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Monday, September 28, 2015 6:58 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 36 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   21 ++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    3 ++-
 4 files changed, 38 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..78d31c5 100644

drivers/gpu/drm/i915/i915_drv.h enum plane { · line 147

Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -142,6 +142,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)]
+
 (s) + 'A')
 
 enum port {
+	PORT_INVALID = -1,

My idea was that you wouldn't add this. Maybe I wasn't clear enough.

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct

Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
 	PORT_A = 0,
 	PORT_B,
 	PORT_C,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..8edb632 100644
@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_ddi.c static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, · line 233

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 	} else if (type == INTEL_OUTPUT_ANALOG) {
 		*dig_port = NULL;
 		*port = PORT_E;
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you could do a warn here. Doesn't matter what you set *port to, it's going to be wrong anyway, and this is only slightly better than not oopsing on the BUG below.

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
 	} else {
 		DRM_ERROR("Invalid DDI encoder type %d\n", type);
 		BUG();
@@ -237,6 +241,15 @@ enum port intel_ddi_get_encoder_port(struct
 intel_encoder *intel_encoder)  {
 	struct intel_digital_port *dig_port;
 	enum port port;
+	int type = intel_encoder->type;
+
+	if (type == INTEL_OUTPUT_DSI) {
Quoted 9 lines

drivers/gpu/drm/i915/intel_ddi.c enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder) · line 252

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
+		port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
+		WARN_ON(1);
+
+		return port;
+	}

Remove these.

intel_ddi_get_encoder_port is the one getting called from multiple locations. This expects an enum to be returned. We could either set the *port in

@@ -227,6 +227,10 @@ static void ddi_get_encoder_port(struct
intel_encoder *intel_encoder,
} else if (type == INTEL_OUTPUT_ANALOG) {
*dig_port = NULL;
*port = PORT_E;

drivers/gpu/drm/i915/intel_ddi.c +4 -0
+	} else if (type == INTEL_OUTPUT_DSI) {
+		*dig_port = NULL;
+		*port = PORT_INVALID;
+		DRM_DEBUG_KMS("Encoder type: DSI. Returning...\n");
Quoted 1 line

And let this function return the PORT_INVALID with a WARN. Or we can

initialize the port to PORT_INVALID and return that instead. Then I can remove these lines from here.

Quoted 1 line

Also, If we try to avoid this function getting called from various locations, we

will again end up to the original problem of spilled over DSI checks at multiple places in code.

Quoted 2 lines

Please suggest which ever looks ok.

Quoted 8 lines

I just sent two patches [1][2] to modify ddi_get_encoder_port a little. Rebase on top, and don't modify ddi_get_encoder_port() or intel_ddi_get_encoder_port() at all. Just make sure you don't call the functions for DSI. No need to add PORT_INVALID either.

BR,
Jani.

Thanks Jani. I will rebase and re-submit. Personally I feel this will be best approach as it will avoid the call itself. However, only flip side is protection at multiple places in code for DSI.

Regards,
Uma Shankar

Quoted 195 lines

[1] http://mid.gmane.org/1443511466-8017-1-git-send-email-
[email protected]
[2] http://mid.gmane.org/1443511466-8017-2-git-send-email-
[email protected]

Quoted 12 lines
Quoted 12 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 407

Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	ddi_get_encoder_port(intel_encoder, &dig_port, &port);
 
@@ -392,6 +405,11 @@ void intel_prepare_ddi(struct drm_device *dev)
 
 		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you'd have to add a check for DSI here.

Quoted 7 lines
Quoted 5 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 409

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+		if (port == PORT_INVALID) {
+			WARN_ON(1);

But this warn now makes me think we don't ever get here on with DSI. Don't warn for normal cases.

Yes, you are right. This shouldn't be Warning, just a DSI protection should be

fine. Will rectify this.

Quoted 126 lines
Quoted 126 lines
Quoted 25 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
+			continue;
+		}
+
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1797,8 @@ bool intel_ddi_get_hw_state(struct

intel_encoder *encoder, void intel_ddi_enable_pipe_clock(struct intel_crtc
*intel_crtc) {

drivers/gpu/drm/i915/intel_ddi.c +2 -1
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder =

intel_crtc->config->cpu_transcoder;

drivers/gpu/drm/i915/intel_display.c +0 -0
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct
Quoted 1 line

drm_crtc

*crtc)

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct

drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv,

TRANSCODER_A, @@

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 10 lines

-5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1); @@ -5049,7 +5054,8 @@

static

Quoted 11 lines

void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct
Quoted 1 line

drm_crtc

*crtc)

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct

drm_crtc

*crtc)

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder =

intel_crtc->config->cpu_transcoder;

drivers/gpu/drm/i915/intel_display.c +1 -0
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct

drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc *crtc)

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2 -1
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0); @@ -5188,7 +5196,8 @@

static

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 16 lines

void haswell_crtc_disable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +0 -0
index 4813374..326aa6b 100644
@@ -335,7 +335,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 2 lines
drivers/gpu/drm/i915/intel_opregion.c +0 -0
 		return 0;
 
Quoted 8 lines
Quoted 5 lines

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, · line 337

Quoted 1 line
drivers/gpu/drm/i915/intel_opregion.c +0 -0
 	port = intel_ddi_get_encoder_port(intel_encoder);

My idea was that you'd only call this function on DDI (i.e. non-DSI) encoders. So you'd have to add a check for DSI here.

Currently, I have implemented it as all other occurrences of this function. Even if it gets called for DSI, it will return PORT_INVALID. That case is

handled below.

Quoted 2 lines

But it would be better to check for DSI and avoid the call and an unnecessary

Warning. Will change this.

Quoted 31 lines

Please comment if the overall approach looks OK. Will implement accordingly.

Thanks for all the suggestions and comments.

Regards,
Uma Shankar

Quoted 23 lines

BR,
Jani.

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 6 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
-	if (port == PORT_E) {
+	if ((port == PORT_E) || (port == PORT_INVALID)) {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +356,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 10 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
--

1.7.9.5

--
Jani Nikula, Intel Open Source Technology Center

Quoted 2 lines

--
Jani Nikula, Intel Open Source Technology Center

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#26 lore raw

Re: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 13 lines · Uma
Quoted 13 lines

-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Tuesday, September 29, 2015 12:59 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank
Subject: RE: [BXT MIPI PATCH v4 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

I just sent two patches [1][2] to modify ddi_get_encoder_port a little. Rebase on top, and don't modify ddi_get_encoder_port() or intel_ddi_get_encoder_port() at all. Just make sure you don't call the functions for DSI. No need to add PORT_INVALID either.

Quoted 7 lines
Quoted 3 lines

BR,
Jani.

Thanks Jani. I will rebase and re-submit. Personally I feel this will be best approach as it will avoid the call itself. However, only flip side is protection at multiple places in code for DSI.

As I explain in my review, it is not necessary to add those checks everywhere.

BR,
Jani.

Quoted 4 lines
Quoted 4 lines

[1] http://mid.gmane.org/1443511466-8017-1-git-send-email-
[email protected]
[2] http://mid.gmane.org/1443511466-8017-2-git-send-email-
[email protected]

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#27 lore raw

PATCH v5 5/14 drm/i915/bxt: DSI encoder support in CRTC modeset

In reply to Jani Nikula

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

v5: Protected DDI code paths in case of DSI encoder calls.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   83 ++++++++++++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_display.c  |   21 ++++++---
 drivers/gpu/drm/i915/intel_dp_mst.c   |    8 +++-
 drivers/gpu/drm/i915/intel_opregion.c |    9 +++-
 5 files changed, 101 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index fd1de45..f97a2a2 100644
@@ -2482,6 +2482,7 @@ struct drm_i915_cmd_table {
 				 INTEL_INFO(dev)->gen >= 9)
 
 #define HAS_DDI(dev)		(INTEL_INFO(dev)->has_ddi)
+#define has_encoder_ddi(type)  ((type) == (INTEL_OUTPUT_DSI) ?  0 : 1)
 #define HAS_FPGA_DBG_UNCLAIMED(dev)	(INTEL_INFO(dev)->has_fpga_dbg)
 #define HAS_PSR(dev)		(IS_HASWELL(dev) || IS_BROADWELL(dev) || \
 				 IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev) || \
drivers/gpu/drm/i915/intel_ddi.c +71 -12

169 lines not on this page · raw message

drivers/gpu/drm/i915/intel_display.c +15 -6
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
@@ -5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5054,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_dp_mst.c +7 -1
index 600afdb..00327bc 100644
@@ -172,8 +172,14 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder)
 	intel_mst->port = found->port;
 
 	if (intel_dp->active_mst_links == 0) {
-		enum port port = intel_ddi_get_encoder_port(encoder);
+		enum port port;
 
+		if (!has_encoder_ddi(encoder->type)) {
+			DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+			return;
+		}
+
+		port = intel_ddi_get_encoder_port(encoder);
 		/* FIXME: add support for SKL */
 		if (INTEL_INFO(dev)->gen < 9)
 			I915_WRITE(PORT_CLK_SEL(port),
drivers/gpu/drm/i915/intel_opregion.c +7 -2
index 4813374..64b8bcd 100644
@@ -334,8 +334,12 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 	if (!HAS_DDI(dev))
 		return 0;
 
-	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if (!has_encoder_ddi(type))
+		port = 0;
+	else
+		port = intel_ddi_get_encoder_port(intel_encoder);
+
+	if (port == PORT_E)  {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +360,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#28 lore raw

Re: [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 39 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

v5: Protected DDI code paths in case of DSI encoder calls.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   83 ++++++++++++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_display.c  |   21 ++++++---
 drivers/gpu/drm/i915/intel_dp_mst.c   |    8 +++-
 drivers/gpu/drm/i915/intel_opregion.c |    9 +++-
 5 files changed, 101 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index fd1de45..f97a2a2 100644

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_cmd_table { · line 2485

Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2482,6 +2482,7 @@ struct drm_i915_cmd_table {
 				 INTEL_INFO(dev)->gen >= 9)
 
 #define HAS_DDI(dev)		(INTEL_INFO(dev)->has_ddi)
+#define has_encoder_ddi(type)  ((type) == (INTEL_OUTPUT_DSI) ?  0 : 1)

Drop this change.

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
 #define HAS_FPGA_DBG_UNCLAIMED(dev)	(INTEL_INFO(dev)->has_fpga_dbg)
 #define HAS_PSR(dev)		(IS_HASWELL(dev) || IS_BROADWELL(dev) || \
 				 IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev) || \
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index cacb07b..4abc13d 100644

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 395

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
@@ -390,8 +390,10 @@ void intel_prepare_ddi(struct drm_device *dev)
 		enum port port;
 		bool supports_hdmi;
 
-		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
+		if (intel_encoder->type == INTEL_OUTPUT_DSI)
+			continue;
 

This is good.

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -2
+		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 		if (visited[port])
 			continue;
 
@@ -977,8 +979,16 @@ static void bxt_ddi_clock_get(struct intel_encoder *encoder,
 				struct intel_crtc_state *pipe_config)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
-	enum port port = intel_ddi_get_encoder_port(encoder);
-	uint32_t dpll = port;

drivers/gpu/drm/i915/intel_ddi.c static void bxt_ddi_clock_get(struct intel_encoder *encoder, · line 991

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+	enum port port;
+	uint32_t dpll;
+
+	if (!has_encoder_ddi(encoder->type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(encoder);
+	dpll = port;

No. Drop this change.

Ask yourself, is it okay to call this function (bxt_ddi_clock_get) if the encoder type is DSI.

No, it's not. We should not be here, at all, if encoder is DSI.

We have modified ddi_get_encoder_port (and therefore intel_ddi_get_encoder_port) to emit a big warning if that function is called on a DSI encoder.

So don't make those extra checks. We'll catch the bugs with the warning in ddi_get_encoder_port. We'll fix the code paths, and move on.

We don't care if the function goes on and does something stupid because we called it with the wrong preconditions. Similarly, we don't check for, say, IS_GEN2() in DDI code, because that should not have happened. The bug is somewhere else.

Now, there *are* valid code paths which will be called if encoder is DSI. In those cases, we need to handle DSI gracefully and not call ddi_get_encoder_port. For example intel_prepare_ddi above and intel_opregion_notify_encoder below.

Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -1
 	pipe_config->port_clock =
 		bxt_calc_pll_link(dev_priv, dpll);
@@ -1568,10 +1578,16 @@ void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	enum pipe pipe = intel_crtc->pipe;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc) · line 1590

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -0
+	enum port port;
 	int type = intel_encoder->type;
 	uint32_t temp;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
 	/* Enable TRANS_DDI_FUNC_CTL for the pipe to work in HDMI mode */
 	temp = TRANS_DDI_FUNC_ENABLE;
 	temp |= TRANS_DDI_SELECT_PORT(port);
@@ -1678,12 +1694,18 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_connector->encoder;
 	int type = intel_connector->base.connector_type;
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);
+	enum port port;
 	enum pipe pipe = 0;

drivers/gpu/drm/i915/intel_ddi.c bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector) · line 1708

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
 	enum transcoder cpu_transcoder;
 	enum intel_display_power_domain power_domain;
 	uint32_t tmp;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return false;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

Quoted 9 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	if (!intel_display_power_is_enabled(dev_priv, power_domain))
 		return false;
@@ -1725,11 +1747,17 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 {
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum port port = intel_ddi_get_encoder_port(encoder);
+	enum port port;

drivers/gpu/drm/i915/intel_ddi.c bool intel_ddi_get_hw_state(struct intel_encoder *encoder, · line 1760

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
 	enum intel_display_power_domain power_domain;
 	u32 tmp;
 	int i;
 
+	if (!has_encoder_ddi(encoder->type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return false;
+	}
+
+	port = intel_ddi_get_encoder_port(encoder);

Drop this change.

Quoted 11 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
 	power_domain = intel_display_port_power_domain(encoder);
 	if (!intel_display_power_is_enabled(dev_priv, power_domain))
 		return false;
@@ -1779,11 +1807,18 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);

drivers/gpu/drm/i915/intel_ddi.c bool intel_ddi_get_hw_state(struct intel_encoder *encoder, · line 1821

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -1
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);
+	enum port port;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
 
+	if (!has_encoder_ddi(intel_encoder->type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -1
 	if (cpu_transcoder != TRANSCODER_EDP)
 		I915_WRITE(TRANS_CLK_SEL(cpu_transcoder),
 			   TRANS_CLK_SEL_PORT(port));
@@ -1866,10 +1901,16 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) · line 1913

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -0
+	enum port port;
 	int type = intel_encoder->type;
 	int hdmi_level;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

Quoted 9 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
 	if (type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 		intel_edp_panel_on(intel_dp);
@@ -1942,11 +1983,17 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder)
 	struct drm_encoder *encoder = &intel_encoder->base;
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);
+	enum port port;

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder) · line 1996

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
 	int type = intel_encoder->type;
 	uint32_t val;
 	bool wait = false;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	val = I915_READ(DDI_BUF_CTL(port));
 	if (val & DDI_BUF_CTL_ENABLE) {
 		val &= ~DDI_BUF_CTL_ENABLE;
@@ -1983,9 +2030,15 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_ddi.c static void intel_enable_ddi(struct intel_encoder *intel_encoder) · line 2041

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -1
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);
+	enum port port;
 	int type = intel_encoder->type;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	if (type == INTEL_OUTPUT_HDMI) {
 		struct intel_digital_port *intel_dig_port =
 			enc_to_dig_port(encoder);
@@ -2729,8 +2782,14 @@ static bool intel_ddi_compute_config(struct intel_encoder *encoder,
 				     struct intel_crtc_state *pipe_config)
 {

drivers/gpu/drm/i915/intel_ddi.c static bool intel_ddi_compute_config(struct intel_encoder *encoder, · line 2792

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -1
 	int type = encoder->type;
-	int port = intel_ddi_get_encoder_port(encoder);
+	int port;
+
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return false;
+	}
 
+	port = intel_ddi_get_encoder_port(encoder);

Drop this change.

Quoted 93 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	WARN(type == INTEL_OUTPUT_UNKNOWN, "compute_config() on unknown output!\n");
 
 	if (port == PORT_A)
drivers/gpu/drm/i915/intel_display.c +15 -6
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
@@ -5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5054,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
index 600afdb..00327bc 100644
@@ -172,8 +172,14 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder)
 	intel_mst->port = found->port;
 

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_pre_enable_dp(struct intel_encoder *encoder) · line 182

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp_mst.c +7 -1
 	if (intel_dp->active_mst_links == 0) {
-		enum port port = intel_ddi_get_encoder_port(encoder);
+		enum port port;
 
+		if (!has_encoder_ddi(encoder->type)) {
+			DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+			return;
+		}
+
+		port = intel_ddi_get_encoder_port(encoder);

Drop this change.

Quoted 8 lines
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
 		/* FIXME: add support for SKL */
 		if (INTEL_INFO(dev)->gen < 9)
 			I915_WRITE(PORT_CLK_SEL(port),
drivers/gpu/drm/i915/intel_opregion.c +0 -0
index 4813374..64b8bcd 100644

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, · line 337

Quoted 6 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -2
@@ -334,8 +334,12 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 	if (!HAS_DDI(dev))
 		return 0;
 
-	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if (!has_encoder_ddi(type))

This is good, but don't add extra wrapper (has_encoder_ddi) for the encode type check.

Quoted 19 lines
drivers/gpu/drm/i915/intel_opregion.c +6 -0
+		port = 0;
+	else
+		port = intel_ddi_get_encoder_port(intel_encoder);
+
+	if (port == PORT_E)  {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +360,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#29 lore raw

Re: [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 115 lines

-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Thursday, October 1, 2015 3:24 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 22 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

Quoted 7 lines

v5: Protected DDI code paths in case of DSI encoder calls.

---
 drivers/gpu/drm/i915/i915_drv.h       |    1 +
 drivers/gpu/drm/i915/intel_ddi.c      |   83 ++++++++++++++++++++++++++++-

----

Quoted 10 lines
 drivers/gpu/drm/i915/intel_display.c  |   21 ++++++---
 drivers/gpu/drm/i915/intel_dp_mst.c   |    8 +++-
 drivers/gpu/drm/i915/intel_opregion.c |    9 +++-
 5 files changed, 101 insertions(+), 21 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index fd1de45..f97a2a2 100644

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_cmd_table { · line 2486

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -2482,6 +2482,7 @@ struct drm_i915_cmd_table {
 				 INTEL_INFO(dev)->gen >= 9)
 
 #define HAS_DDI(dev)		(INTEL_INFO(dev)->has_ddi)
+#define has_encoder_ddi(type)  ((type) == (INTEL_OUTPUT_DSI) ?  0 :
+1)

Drop this change.

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_cmd_table {

Quoted 3 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
 #define HAS_FPGA_DBG_UNCLAIMED(dev)	(INTEL_INFO(dev)-
 has_fpga_dbg)
 #define HAS_PSR(dev)		(IS_HASWELL(dev) ||

IS_BROADWELL(dev) || \

Quoted 1 line

IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)

|| \ diff --git

drivers/gpu/drm/i915/intel_ddi.c void intel_prepare_ddi(struct drm_device *dev) · line 395

Quoted 12 lines

a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index cacb07b..4abc13d 100644

drivers/gpu/drm/i915/intel_ddi.c +2 -1
@@ -390,8 +390,10 @@ void intel_prepare_ddi(struct drm_device *dev)
 		enum port port;
 		bool supports_hdmi;
 
-		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
+		if (intel_encoder->type == INTEL_OUTPUT_DSI)
+			continue;
 

This is good.

drivers/gpu/drm/i915/intel_ddi.c static void bxt_ddi_clock_get(struct intel_encoder

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -0
+		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 		if (visited[port])
 			continue;
 
@@ -977,8 +979,16 @@ static void bxt_ddi_clock_get(struct intel_encoder

*encoder,

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -2
 				struct intel_crtc_state *pipe_config)  {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
-	enum port port = intel_ddi_get_encoder_port(encoder);
-	uint32_t dpll = port;

drivers/gpu/drm/i915/intel_ddi.c static void bxt_ddi_clock_get(struct intel_encoder *encoder, · line 991

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+	enum port port;
+	uint32_t dpll;
+
+	if (!has_encoder_ddi(encoder->type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(encoder);
+	dpll = port;

No. Drop this change.

Ask yourself, is it okay to call this function (bxt_ddi_clock_get) if the encoder type is DSI.

No, it's not. We should not be here, at all, if encoder is DSI.

We have modified ddi_get_encoder_port (and therefore intel_ddi_get_encoder_port) to emit a big warning if that function is called on a DSI encoder.

So don't make those extra checks. We'll catch the bugs with the warning in ddi_get_encoder_port. We'll fix the code paths, and move on.

Quoted 9 lines

We don't care if the function goes on and does something stupid because we called it with the wrong preconditions. Similarly, we don't check for, say, IS_GEN2() in DDI code, because that should not have happened. The bug is somewhere else.

Now, there *are* valid code paths which will be called if encoder is DSI. In those cases, we need to handle DSI gracefully and not call ddi_get_encoder_port. For example intel_prepare_ddi above and intel_opregion_notify_encoder below.

Ok got it. Will do the same.

Regards,
Uma Shankar

Quoted 327 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_enable_transcoder_func(struct

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	pipe_config->port_clock =
 		bxt_calc_pll_link(dev_priv, dpll);
@@ -1568,10 +1578,16 @@ void intel_ddi_enable_transcoder_func(struct

drm_crtc *crtc)

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -1
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	enum pipe pipe = intel_crtc->pipe;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc) · line 1590

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -0
+	enum port port;
 	int type = intel_encoder->type;
 	uint32_t temp;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc)

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	/* Enable TRANS_DDI_FUNC_CTL for the pipe to work in HDMI mode */
 	temp = TRANS_DDI_FUNC_ENABLE;
 	temp |= TRANS_DDI_SELECT_PORT(port); @@ -1678,12 +1694,18 @@

bool

Quoted 7 lines

intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)

drivers/gpu/drm/i915/intel_ddi.c +1 -1
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_connector->encoder;
 	int type = intel_connector->base.connector_type;
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);
+	enum port port;
 	enum pipe pipe = 0;

drivers/gpu/drm/i915/intel_ddi.c bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector) · line 1708

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
 	enum transcoder cpu_transcoder;
 	enum intel_display_power_domain power_domain;
 	uint32_t tmp;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return false;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

Quoted 9 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	if (!intel_display_power_is_enabled(dev_priv, power_domain))
 		return false;
@@ -1725,11 +1747,17 @@ bool intel_ddi_get_hw_state(struct
 intel_encoder *encoder,  {
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum port port = intel_ddi_get_encoder_port(encoder);
+	enum port port;

drivers/gpu/drm/i915/intel_ddi.c bool intel_ddi_get_hw_state(struct · line 1760

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
 	enum intel_display_power_domain power_domain;
 	u32 tmp;
 	int i;
 
+	if (!has_encoder_ddi(encoder->type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return false;
+	}
+
+	port = intel_ddi_get_encoder_port(encoder);

Drop this change.

Quoted 11 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	power_domain = intel_display_port_power_domain(encoder);
 	if (!intel_display_power_is_enabled(dev_priv, power_domain))
 		return false;
@@ -1779,11 +1807,18 @@ bool intel_ddi_get_hw_state(struct

intel_encoder *encoder, void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc) {

drivers/gpu/drm/i915/intel_ddi.c +2 -1
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);

drivers/gpu/drm/i915/intel_ddi.c bool intel_ddi_get_hw_state(struct intel_encoder *encoder, · line 1821

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -1
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);
+	enum port port;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
 
+	if (!has_encoder_ddi(intel_encoder->type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_pre_enable(struct

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	if (cpu_transcoder != TRANSCODER_EDP)
 		I915_WRITE(TRANS_CLK_SEL(cpu_transcoder),
 			   TRANS_CLK_SEL_PORT(port));
@@ -1866,10 +1901,16 @@ static void intel_ddi_pre_enable(struct

intel_encoder *intel_encoder)

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -1
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) · line 1913

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -0
+	enum port port;
 	int type = intel_encoder->type;
 	int hdmi_level;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	if (type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 		intel_edp_panel_on(intel_dp);
@@ -1942,11 +1983,17 @@ static void intel_ddi_post_disable(struct

intel_encoder *intel_encoder)

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
 	struct drm_encoder *encoder = &intel_encoder->base;
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);
+	enum port port;

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder) · line 1996

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -0
 	int type = intel_encoder->type;
 	uint32_t val;
 	bool wait = false;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

drivers/gpu/drm/i915/intel_ddi.c static void intel_enable_ddi(struct intel_encoder

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	val = I915_READ(DDI_BUF_CTL(port));
 	if (val & DDI_BUF_CTL_ENABLE) {
 		val &= ~DDI_BUF_CTL_ENABLE;
@@ -1983,9 +2030,15 @@ static void intel_enable_ddi(struct intel_encoder

*intel_encoder)

drivers/gpu/drm/i915/intel_ddi.c static void intel_enable_ddi(struct intel_encoder *intel_encoder) · line 2041

Quoted 13 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -1
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum port port = intel_ddi_get_encoder_port(intel_encoder);
+	enum port port;
 	int type = intel_encoder->type;
 
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return;
+	}
+
+	port = intel_ddi_get_encoder_port(intel_encoder);

Drop this change.

drivers/gpu/drm/i915/intel_ddi.c static bool intel_ddi_compute_config(struct

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	if (type == INTEL_OUTPUT_HDMI) {
 		struct intel_digital_port *intel_dig_port =
 			enc_to_dig_port(encoder);
@@ -2729,8 +2782,14 @@ static bool intel_ddi_compute_config(struct

intel_encoder *encoder,

drivers/gpu/drm/i915/intel_ddi.c static bool intel_ddi_compute_config(struct intel_encoder *encoder, · line 2792

Quoted 11 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -1
 				     struct intel_crtc_state *pipe_config)  {
 	int type = encoder->type;
-	int port = intel_ddi_get_encoder_port(encoder);
+	int port;
+
+	if (!has_encoder_ddi(type)) {
+		DRM_DEBUG_KMS("DDI func getting called for DSI?\n");
+		return false;
+	}
 
+	port = intel_ddi_get_encoder_port(encoder);

Drop this change.

drivers/gpu/drm/i915/intel_ddi.c static bool intel_ddi_compute_config(struct · line 2792

Quoted 1 line
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	WARN(type == INTEL_OUTPUT_UNKNOWN, "compute_config() on

unknown

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 9 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 output!\n");
 
 	if (port == PORT_A)
drivers/gpu/drm/i915/intel_display.c +0 -0
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv,

TRANSCODER_A, @@

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 10 lines

-5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1); @@ -5049,7 +5054,8 @@

static

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 11 lines

void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc *crtc)

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2 -1
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0); @@ -5188,7 +5196,8 @@

static

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_pre_enable_dp(struct

Quoted 16 lines

void haswell_crtc_disable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
index 600afdb..00327bc 100644
@@ -172,8 +172,14 @@ static void intel_mst_pre_enable_dp(struct

intel_encoder *encoder)

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_pre_enable_dp(struct intel_encoder *encoder)

Quoted 8 lines
drivers/gpu/drm/i915/intel_dp_mst.c +3 -1
 	intel_mst->port = found->port;
 
 	if (intel_dp->active_mst_links == 0) {
-		enum port port = intel_ddi_get_encoder_port(encoder);
+		enum port port;
 
+		if (!has_encoder_ddi(encoder->type)) {
+			DRM_DEBUG_KMS("DDI func getting called for

DSI?\n");

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_pre_enable_dp(struct · line 182

Quoted 4 lines
drivers/gpu/drm/i915/intel_dp_mst.c +4 -0
+			return;
+		}
+
+		port = intel_ddi_get_encoder_port(encoder);

Drop this change.

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 9 lines
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
 		/* FIXME: add support for SKL */
 		if (INTEL_INFO(dev)->gen < 9)
 			I915_WRITE(PORT_CLK_SEL(port),
drivers/gpu/drm/i915/intel_opregion.c +0 -0
index 4813374..64b8bcd 100644
@@ -334,8 +334,12 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, · line 337

Quoted 6 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -2
 	if (!HAS_DDI(dev))
 		return 0;
 
-	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if (!has_encoder_ddi(type))

This is good, but don't add extra wrapper (has_encoder_ddi) for the encode type check.

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 9 lines
drivers/gpu/drm/i915/intel_opregion.c +5 -0
+		port = 0;
+	else
+		port = intel_ddi_get_encoder_port(intel_encoder);
+
+	if (port == PORT_E)  {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +360,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 13 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
--

1.7.9.5

--
Jani Nikula, Intel Open Source Technology Center

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#30 lore raw

PATCH v5 5/14 drm/i915/bxt: DSI encoder support in CRTC modeset

In reply to Jani Nikula

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

v5: Protected DDI code paths in case of DSI encoder calls.

---
 drivers/gpu/drm/i915/intel_ddi.c      |    7 +++++--
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    9 +++++++--
 3 files changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +5 -2
index cacb07b..7b7f544 100644
@@ -390,8 +390,10 @@ void intel_prepare_ddi(struct drm_device *dev)
 		enum port port;
 		bool supports_hdmi;
 
-		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
+		if (intel_encoder->type == INTEL_OUTPUT_DSI)
+			continue;
 
+		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1781,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +15 -6
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
@@ -5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5054,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +7 -2
index 4813374..db518ef 100644
@@ -334,8 +334,12 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 	if (!HAS_DDI(dev))
 		return 0;
 
-	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if (intel_encoder->type == INTEL_OUTPUT_DSI)
+		port = 0;
+	else
+		port = intel_ddi_get_encoder_port(intel_encoder);
+
+	if (port == PORT_E)  {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +360,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v5 5/14
#31 lore raw

Re: [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 19 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

Quoted 7 lines

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

v5: Protected DDI code paths in case of DSI encoder calls.

Quoted 145 lines
---
 drivers/gpu/drm/i915/intel_ddi.c      |    7 +++++--
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    9 +++++++--
 3 files changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +5 -2
index cacb07b..7b7f544 100644
@@ -390,8 +390,10 @@ void intel_prepare_ddi(struct drm_device *dev)
 		enum port port;
 		bool supports_hdmi;
 
-		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
+		if (intel_encoder->type == INTEL_OUTPUT_DSI)
+			continue;
 
+		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1781,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +15 -6
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
@@ -5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5054,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +7 -2
index 4813374..db518ef 100644
@@ -334,8 +334,12 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 	if (!HAS_DDI(dev))
 		return 0;
 
-	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if (intel_encoder->type == INTEL_OUTPUT_DSI)
+		port = 0;
+	else
+		port = intel_ddi_get_encoder_port(intel_encoder);
+
+	if (port == PORT_E)  {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +360,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#32 lore raw

Re: [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

In reply to Uma Shankar
Quoted 19 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

Quoted 7 lines

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

v5: Protected DDI code paths in case of DSI encoder calls.

Ok, after this patch we get stuff like this:

	for_each_encoder_on_crtc(dev, crtc, encoder) {
		if (encoder->pre_pll_enable)
			encoder->pre_pll_enable(encoder);
		if (encoder->pre_enable)
			encoder->pre_enable(encoder);
	}

	if (intel_crtc->config->has_pch_encoder) {
		intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
						      true);
		dev_priv->display.fdi_link_train(crtc);
	}

	if (!is_dsi)
		intel_ddi_enable_pipe_clock(intel_crtc);

1. Please remove pre_pll_enable again, we don't need 2 callbacks in exactly the same spot. Yes this might mean that you need special bxt_ versions of that in the dsi encoder, we have that everywhere.

2. the has_pch_encoder is already something encoder-specific (it's exclusively used by the HSW LPT CRT encoder). Now we have another one of those for the !is_dsi case. These special-cases should be moved into the encoder->pre_enable callbacks, that's what they're for.

I'm not going to block these patches are (18months is already ridiculous), but I want this cleanup done. Uma, can you pls own this? If you can't do it yourself please escalate to Indranil so he can find someone.

Thanks, Daniel

Quoted 149 lines
---
 drivers/gpu/drm/i915/intel_ddi.c      |    7 +++++--
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    9 +++++++--
 3 files changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +5 -2
index cacb07b..7b7f544 100644
@@ -390,8 +390,10 @@ void intel_prepare_ddi(struct drm_device *dev)
 		enum port port;
 		bool supports_hdmi;
 
-		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
+		if (intel_encoder->type == INTEL_OUTPUT_DSI)
+			continue;
 
+		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1781,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +15 -6
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
@@ -5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1);
@@ -5049,7 +5054,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0);
@@ -5188,7 +5196,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +7 -2
index 4813374..db518ef 100644
@@ -334,8 +334,12 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 	if (!HAS_DDI(dev))
 		return 0;
 
-	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if (intel_encoder->type == INTEL_OUTPUT_DSI)
+		port = 0;
+	else
+		port = intel_ddi_get_encoder_port(intel_encoder);
+
+	if (port == PORT_E)  {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +360,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#33 lore raw

Re: [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 66 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Friday, October 2, 2015 6:05 PM
To: Shankar, Uma
Cc: [email protected]; Kumar, Shobhit
Subject: Re: [Intel-gfx] [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 19 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

Quoted 7 lines

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

v5: Protected DDI code paths in case of DSI encoder calls.

Ok, after this patch we get stuff like this:

	for_each_encoder_on_crtc(dev, crtc, encoder) {
		if (encoder->pre_pll_enable)
			encoder->pre_pll_enable(encoder);
		if (encoder->pre_enable)
			encoder->pre_enable(encoder);
	}

	if (intel_crtc->config->has_pch_encoder) {
		intel_set_pch_fifo_underrun_reporting(dev_priv,
TRANSCODER_A,
						      true);
		dev_priv->display.fdi_link_train(crtc);
	}

	if (!is_dsi)
		intel_ddi_enable_pipe_clock(intel_crtc);

1. Please remove pre_pll_enable again, we don't need 2 callbacks in exactly the same spot. Yes this might mean that you need special bxt_ versions of that in the dsi encoder, we have that everywhere.

2. the has_pch_encoder is already something encoder-specific (it's exclusively used by the HSW LPT CRT encoder). Now we have another one of those for the !is_dsi case. These special-cases should be moved into the encoder->pre_enable callbacks, that's what they're for.

Quoted 6 lines

I'm not going to block these patches are (18months is already ridiculous), but I want this cleanup done. Uma, can you pls own this? If you can't do it yourself please escalate to Indranil so he can find someone.

Thanks, Daniel

Hi Daniel,
I will discuss with Indranil and will get this done.

Thanks for your support in getting the video mode patches merged.

Regards,
Uma Shankar

Quoted 158 lines

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 39 lines
---
 drivers/gpu/drm/i915/intel_ddi.c      |    7 +++++--
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    9 +++++++--
 3 files changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +5 -2
index cacb07b..7b7f544 100644
@@ -390,8 +390,10 @@ void intel_prepare_ddi(struct drm_device *dev)
 		enum port port;
 		bool supports_hdmi;
 
-		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
+		if (intel_encoder->type == INTEL_OUTPUT_DSI)
+			continue;
 
+		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1781,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder
 *encoder,  void intel_ddi_enable_pipe_clock(struct intel_crtc
 *intel_crtc)  {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +0 -0
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv,

TRANSCODER_A, @@

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 10 lines

-5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1); @@ -5049,7 +5054,8 @@

static

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 11 lines

void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc *crtc)

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2 -1
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0); @@ -5188,7 +5196,8 @@

static

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 16 lines

void haswell_crtc_disable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +0 -0
index 4813374..db518ef 100644
@@ -334,8 +334,12 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 15 lines
drivers/gpu/drm/i915/intel_opregion.c +6 -2
 	if (!HAS_DDI(dev))
 		return 0;
 
-	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if (intel_encoder->type == INTEL_OUTPUT_DSI)
+		port = 0;
+	else
+		port = intel_ddi_get_encoder_port(intel_encoder);
+
+	if (port == PORT_E)  {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +360,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 10 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
--

1.7.9.5

Quoted 9 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#34 lore raw

Re: [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 68 lines · Uma
Quoted 68 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Friday, October 2, 2015 6:05 PM
To: Shankar, Uma
Cc: [email protected]; Kumar, Shobhit
Subject: Re: [Intel-gfx] [BXT MIPI PATCH v5 05/14] drm/i915/bxt: DSI encoder support in CRTC modeset

Quoted 19 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

SKL and BXT qualifies the HAS_DDI() check, and hence haswell modeset functions are re-used for modeset sequence. But DDI interface doesn't include support for DSI.
This patch adds:
1. cases for DSI encoder, in those modeset functions and allows a CRTC modeset
2. Adds call to pre_pll enabled from CRTC modeset function. Nothing needs to be done as such in CRTC for DSI encoder, as PLL, clock and and transcoder programming will be taken care in encoder's pre_enable and pre_pll_enable function.

v2: Fixed Jani's review comments. Added INVALID_PORT for non DDI
encoder like DSI for platforms having HAS_DDI as true.

v3: Rebased on latest drm-nightly branch. Added a WARN_ON for invalid
encoder.

Quoted 7 lines

v4: WARN_ON for invalid encoder is refactored as per Jani's suggestion.
Fixed the sequence for pre_pll_enable.

v5: Protected DDI code paths in case of DSI encoder calls.

Ok, after this patch we get stuff like this:

	for_each_encoder_on_crtc(dev, crtc, encoder) {
		if (encoder->pre_pll_enable)
			encoder->pre_pll_enable(encoder);
		if (encoder->pre_enable)
			encoder->pre_enable(encoder);
	}

	if (intel_crtc->config->has_pch_encoder) {
		intel_set_pch_fifo_underrun_reporting(dev_priv,
TRANSCODER_A,
						      true);
		dev_priv->display.fdi_link_train(crtc);
	}

	if (!is_dsi)
		intel_ddi_enable_pipe_clock(intel_crtc);

1. Please remove pre_pll_enable again, we don't need 2 callbacks in exactly the same spot. Yes this might mean that you need special bxt_ versions of that in the dsi encoder, we have that everywhere.

2. the has_pch_encoder is already something encoder-specific (it's exclusively used by the HSW LPT CRT encoder). Now we have another one of those for the !is_dsi case. These special-cases should be moved into the encoder->pre_enable callbacks, that's what they're for.

I'm not going to block these patches are (18months is already ridiculous), but I want this cleanup done. Uma, can you pls own this? If you can't do it yourself please escalate to Indranil so he can find someone.

Quoted 7 lines
Quoted 2 lines

Thanks, Daniel

Hi Daniel,
I will discuss with Indranil and will get this done.

Thanks for your support in getting the video mode patches merged.

I'll do the cleanups, don't worry about it.

BR,
Jani.

Quoted 175 lines

Regards,
Uma Shankar

Quoted 158 lines

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 39 lines
---
 drivers/gpu/drm/i915/intel_ddi.c      |    7 +++++--
 drivers/gpu/drm/i915/intel_display.c  |   21 +++++++++++++++------
 drivers/gpu/drm/i915/intel_opregion.c |    9 +++++++--
 3 files changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +5 -2
index cacb07b..7b7f544 100644
@@ -390,8 +390,10 @@ void intel_prepare_ddi(struct drm_device *dev)
 		enum port port;
 		bool supports_hdmi;
 
-		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
+		if (intel_encoder->type == INTEL_OUTPUT_DSI)
+			continue;
 
+		ddi_get_encoder_port(intel_encoder, &intel_dig_port, &port);
 		if (visited[port])
 			continue;
 
@@ -1779,7 +1781,8 @@ bool intel_ddi_get_hw_state(struct intel_encoder
 *encoder,  void intel_ddi_enable_pipe_clock(struct intel_crtc
 *intel_crtc)  {
 	struct drm_crtc *crtc = &intel_crtc->base;
-	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
drivers/gpu/drm/i915/intel_display.c +0 -0
index b8e0310..ea0f533 100644
@@ -4991,6 +4991,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 	int pipe = intel_crtc->pipe;
 
 	WARN_ON(!crtc->state->enable);
@@ -5023,9 +5024,12 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
 	intel_crtc->active = true;
 
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
-	for_each_encoder_on_crtc(dev, crtc, encoder)
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		if (encoder->pre_pll_enable)
+			encoder->pre_pll_enable(encoder);
 		if (encoder->pre_enable)
 			encoder->pre_enable(encoder);
+	}
 
 	if (intel_crtc->config->has_pch_encoder) {
 		intel_set_pch_fifo_underrun_reporting(dev_priv,

TRANSCODER_A, @@

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc)

Quoted 10 lines

-5033,7 +5037,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 		dev_priv->display.fdi_link_train(crtc);
 	}
 
-	intel_ddi_enable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_enable_pipe_clock(intel_crtc);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 1); @@ -5049,7 +5054,8 @@

static

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc

Quoted 11 lines

void haswell_crtc_enable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	intel_crtc_load_lut(crtc);
 
 	intel_ddi_set_pipe_settings(crtc);
-	intel_ddi_enable_transcoder_func(crtc);
+	if (!is_dsi)
+		intel_ddi_enable_transcoder_func(crtc);
 
 	intel_update_watermarks(crtc);
 	intel_enable_pipe(intel_crtc);
@@ -5057,7 +5063,7 @@ static void haswell_crtc_enable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
 	if (intel_crtc->config->has_pch_encoder)
 		lpt_pch_enable(crtc);
 
-	if (intel_crtc->config->dp_encoder_is_mst)
+	if (intel_crtc->config->dp_encoder_is_mst && !is_dsi)
 		intel_ddi_set_vc_payload_alloc(crtc, true);
 
 	assert_vblank_disabled(crtc);
@@ -5159,6 +5165,7 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
+	bool is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI);
 
 	if (!intel_crtc->active)
 		return;
@@ -5179,7 +5186,8 @@ static void haswell_crtc_disable(struct drm_crtc

*crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_disable(struct drm_crtc *crtc)

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2 -1
 	if (intel_crtc->config->dp_encoder_is_mst)
 		intel_ddi_set_vc_payload_alloc(crtc, false);
 
-	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
+	if (!is_dsi)
+		intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
 	if (INTEL_INFO(dev)->gen == 9)
 		skylake_pfit_update(intel_crtc, 0); @@ -5188,7 +5196,8 @@

static

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 16 lines

void haswell_crtc_disable(struct drm_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c +2 -1
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	intel_ddi_disable_pipe_clock(intel_crtc);
+	if (!is_dsi)
+		intel_ddi_disable_pipe_clock(intel_crtc);
 
 	if (intel_crtc->config->has_pch_encoder) {
 		lpt_disable_pch_transcoder(dev_priv);
drivers/gpu/drm/i915/intel_opregion.c +0 -0
index 4813374..db518ef 100644
@@ -334,8 +334,12 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_opregion.c int intel_opregion_notify_encoder(struct

Quoted 15 lines
drivers/gpu/drm/i915/intel_opregion.c +6 -2
 	if (!HAS_DDI(dev))
 		return 0;
 
-	port = intel_ddi_get_encoder_port(intel_encoder);
-	if (port == PORT_E) {
+	if (intel_encoder->type == INTEL_OUTPUT_DSI)
+		port = 0;
+	else
+		port = intel_ddi_get_encoder_port(intel_encoder);
+
+	if (port == PORT_E)  {
 		port = 0;
 	} else {
 		parm |= 1 << port;
@@ -356,6 +360,7 @@ int intel_opregion_notify_encoder(struct

intel_encoder *intel_encoder,

Quoted 10 lines
drivers/gpu/drm/i915/intel_opregion.c +1 -1
 		type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL;
 		break;
 	case INTEL_OUTPUT_EDP:
+	case INTEL_OUTPUT_DSI:
 		type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL;
 		break;
 	default:
--

1.7.9.5

Quoted 9 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#35 lore raw

PATCH v3 6/14 drm/i915/bxt: DSI enable for BXT

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

This patch contains following changes:
1. MIPI device ready changes to support dsi_pre_enable. Changes are specific to BXT device ready sequence. Added check for ULPS mode(No effects on VLV).
2. Changes in dsi_enable to pick BXT port control register.
3. Changes in dsi_pre_enable to restrict DPIO programming for VLV

v2: Fixed Jani's review comments. Removed the changes in VLV/CHV
code. Fixed the macros to get proper port offsets.

v3: Rebased on latest drm-nightly branch. Fixed Jani's review comments.

---
 drivers/gpu/drm/i915/i915_reg.h  |    7 ++
 drivers/gpu/drm/i915/intel_dsi.c |  165 ++++++++++++++++++++++++++------------
 2 files changed, 119 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +7 -0
index 997a999..57c5dbf 100644
@@ -7403,6 +7403,13 @@ enum skl_disp_power_wells {
 #define _MIPIA_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61190)
 #define _MIPIC_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61700)
 #define MIPI_PORT_CTRL(port)	_MIPI_PORT(port, _MIPIA_PORT_CTRL, _MIPIC_PORT_CTRL)
+
+ /* BXT port control */
+#define _BXT_MIPIA_PORT_CTRL				0x6B0C0
+#define _BXT_MIPIC_PORT_CTRL				0x6B8C0
+#define BXT_MIPI_PORT_CTRL(tc)	_MIPI_PORT(tc, _BXT_MIPIA_PORT_CTRL, \
+						_BXT_MIPIC_PORT_CTRL)
+
 #define  DPI_ENABLE					(1 << 31) /* A + C */
 #define  MIPIA_MIPI4DPHY_DELAY_COUNT_SHIFT		27
 #define  MIPIA_MIPI4DPHY_DELAY_COUNT_MASK		(0xf << 27)
drivers/gpu/drm/i915/intel_dsi.c +112 -53

195 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 6/14
#36 lore raw

Re: [BXT MIPI PATCH v3 06/14] drm/i915/bxt: DSI enable for BXT

Quoted 9 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch contains following changes:
1. MIPI device ready changes to support dsi_pre_enable. Changes are specific to BXT device ready sequence. Added check for ULPS mode(No effects on VLV).
2. Changes in dsi_enable to pick BXT port control register.
3. Changes in dsi_pre_enable to restrict DPIO programming for VLV

Quoted 7 lines

v2: Fixed Jani's review comments. Removed the changes in VLV/CHV
code. Fixed the macros to get proper port offsets.

v3: Rebased on latest drm-nightly branch. Fixed Jani's review comments.

When you look at the commits before sending, you should pay more attention to what the diffs end up looking like. In this case, the review becomes unnecessarily hard just because you've moved code (intel_dsi_port_enable) around for no apparent reason, and the diff seems like intel_dsi_port_enable is rewritten into bxt_dsi_device_ready. It should be a hint to *not* combine code movement into the same patch.

Quoted 228 lines
---
 drivers/gpu/drm/i915/i915_reg.h  |    7 ++
 drivers/gpu/drm/i915/intel_dsi.c |  165 ++++++++++++++++++++++++++------------
 2 files changed, 119 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +7 -0
index 997a999..57c5dbf 100644
@@ -7403,6 +7403,13 @@ enum skl_disp_power_wells {
 #define _MIPIA_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61190)
 #define _MIPIC_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61700)
 #define MIPI_PORT_CTRL(port)	_MIPI_PORT(port, _MIPIA_PORT_CTRL, _MIPIC_PORT_CTRL)
+
+ /* BXT port control */
+#define _BXT_MIPIA_PORT_CTRL				0x6B0C0
+#define _BXT_MIPIC_PORT_CTRL				0x6B8C0
+#define BXT_MIPI_PORT_CTRL(tc)	_MIPI_PORT(tc, _BXT_MIPIA_PORT_CTRL, \
+						_BXT_MIPIC_PORT_CTRL)
+
 #define  DPI_ENABLE					(1 << 31) /* A + C */
 #define  MIPIA_MIPI4DPHY_DELAY_COUNT_SHIFT		27
 #define  MIPIA_MIPI4DPHY_DELAY_COUNT_MASK		(0xf << 27)
drivers/gpu/drm/i915/intel_dsi.c +112 -53
index 6d0c992..5a42f87 100644
@@ -286,58 +286,46 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
 	return true;
 }
 
-static void intel_dsi_port_enable(struct intel_encoder *encoder)
+static void bxt_dsi_device_ready(struct intel_encoder *encoder)
 {
-	struct drm_device *dev = encoder->base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	enum port port;
-	u32 temp;
+	u32 val;
 
-	if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
-		temp = I915_READ(VLV_CHICKEN_3);
-		temp &= ~PIXEL_OVERLAP_CNT_MASK |
-					intel_dsi->pixel_overlap <<
-					PIXEL_OVERLAP_CNT_SHIFT;
-		I915_WRITE(VLV_CHICKEN_3, temp);
-	}
+	DRM_DEBUG_KMS("\n");
 
+	/* Exit Low power state in 4 steps*/
 	for_each_dsi_port(port, intel_dsi->ports) {
-		temp = I915_READ(MIPI_PORT_CTRL(port));
-		temp &= ~LANE_CONFIGURATION_MASK;
-		temp &= ~DUAL_LINK_MODE_MASK;
 
-		if (intel_dsi->ports == ((1 << PORT_A) | (1 << PORT_C))) {
-			temp |= (intel_dsi->dual_link - 1)
-						<< DUAL_LINK_MODE_SHIFT;
-			temp |= intel_crtc->pipe ?
-					LANE_CONFIGURATION_DUAL_LINK_B :
-					LANE_CONFIGURATION_DUAL_LINK_A;
-		}
-		/* assert ip_tg_enable signal */
-		I915_WRITE(MIPI_PORT_CTRL(port), temp | DPI_ENABLE);
-		POSTING_READ(MIPI_PORT_CTRL(port));
-	}
-}
+		/* 1. Enable MIPI PHY transparent latch */
+		val = I915_READ(BXT_MIPI_PORT_CTRL(port));
+		I915_WRITE(BXT_MIPI_PORT_CTRL(port), val | LP_OUTPUT_HOLD);
+		usleep_range(2000, 2500);
 
-static void intel_dsi_port_disable(struct intel_encoder *encoder)
-{
-	struct drm_device *dev = encoder->base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
-	enum port port;
-	u32 temp;
+		/* 2. Enter ULPS */
+		val = I915_READ(MIPI_DEVICE_READY(port));
+		val &= ~ULPS_STATE_MASK;
+		val |= (ULPS_STATE_ENTER | DEVICE_READY);
+		I915_WRITE(MIPI_DEVICE_READY(port), val);
+		usleep_range(2, 3);
+
+		/* 3. Exit ULPS */
+		val = I915_READ(MIPI_DEVICE_READY(port));
+		val &= ~ULPS_STATE_MASK;
+		val |= (ULPS_STATE_EXIT | DEVICE_READY);
+		I915_WRITE(MIPI_DEVICE_READY(port), val);
+		usleep_range(1000, 1500);
 
-	for_each_dsi_port(port, intel_dsi->ports) {
-		/* de-assert ip_tg_enable signal */
-		temp = I915_READ(MIPI_PORT_CTRL(port));
-		I915_WRITE(MIPI_PORT_CTRL(port), temp & ~DPI_ENABLE);
-		POSTING_READ(MIPI_PORT_CTRL(port));
+		/* Clear ULPS and set device ready */
+		val = I915_READ(MIPI_DEVICE_READY(port));
+		val &= ~ULPS_STATE_MASK;
+		val |= DEVICE_READY;
+		I915_WRITE(MIPI_DEVICE_READY(port), val);
 	}
 }
 
-static void intel_dsi_device_ready(struct intel_encoder *encoder)
+static void vlv_dsi_device_ready(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
@@ -376,6 +364,72 @@ static void intel_dsi_device_ready(struct intel_encoder *encoder)
 	}
 }
 
+static void intel_dsi_device_ready(struct intel_encoder *encoder)
+{
+	struct drm_device *dev = encoder->base.dev;
+
+	if (IS_VALLEYVIEW(dev))
+		vlv_dsi_device_ready(encoder);
+	else if (IS_BROXTON(dev))
+		bxt_dsi_device_ready(encoder);
+}
+
+static void intel_dsi_port_enable(struct intel_encoder *encoder)
+{
+	struct drm_device *dev = encoder->base.dev;
+	struct drm_i915_private *dev_priv = 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);
+	enum port port;
+	u32 temp;
+	u32 port_ctrl;
+
+	if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
+		temp = I915_READ(VLV_CHICKEN_3);
+		temp &= ~PIXEL_OVERLAP_CNT_MASK |
+					intel_dsi->pixel_overlap <<
+					PIXEL_OVERLAP_CNT_SHIFT;
+		I915_WRITE(VLV_CHICKEN_3, temp);
+	}
+
+	for_each_dsi_port(port, intel_dsi->ports) {
+		port_ctrl = IS_BROXTON(dev) ? BXT_MIPI_PORT_CTRL(port) :
+						MIPI_PORT_CTRL(port);
+
+		temp = I915_READ(port_ctrl);
+
+		temp &= ~LANE_CONFIGURATION_MASK;
+		temp &= ~DUAL_LINK_MODE_MASK;
+
+		if (intel_dsi->ports == ((1 << PORT_A) | (1 << PORT_C))) {
+			temp |= (intel_dsi->dual_link - 1)
+						<< DUAL_LINK_MODE_SHIFT;
+			temp |= intel_crtc->pipe ?
+					LANE_CONFIGURATION_DUAL_LINK_B :
+					LANE_CONFIGURATION_DUAL_LINK_A;
+		}
+		/* assert ip_tg_enable signal */
+		I915_WRITE(port_ctrl, temp | DPI_ENABLE);
+		POSTING_READ(port_ctrl);
+	}
+}
+
+static void intel_dsi_port_disable(struct intel_encoder *encoder)
+{
+	struct drm_device *dev = encoder->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	enum port port;
+	u32 temp;
+
+	for_each_dsi_port(port, intel_dsi->ports) {
+		/* de-assert ip_tg_enable signal */
+		temp = I915_READ(MIPI_PORT_CTRL(port));
+		I915_WRITE(MIPI_PORT_CTRL(port), temp & ~DPI_ENABLE);
+		POSTING_READ(MIPI_PORT_CTRL(port));
+	}
+}
+
 static void intel_dsi_enable(struct intel_encoder *encoder)
 {
 	struct drm_device *dev = encoder->base.dev;
@@ -415,19 +469,24 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 
 	DRM_DEBUG_KMS("\n");
 
-	/* Disable DPOunit clock gating, can stall pipe
-	 * and we need DPLL REFA always enabled */
-	tmp = I915_READ(DPLL(pipe));
-	tmp |= DPLL_REFA_CLK_ENABLE_VLV;
-	I915_WRITE(DPLL(pipe), tmp);
-
-	/* update the hw state for DPLL */
-	intel_crtc->config->dpll_hw_state.dpll = DPLL_INTEGRATED_CLOCK_VLV |
-		DPLL_REFA_CLK_ENABLE_VLV;
-
-	tmp = I915_READ(DSPCLK_GATE_D);
-	tmp |= DPOUNIT_CLOCK_GATE_DISABLE;
-	I915_WRITE(DSPCLK_GATE_D, tmp);
+	if (IS_VALLEYVIEW(dev)) {
+		/*
+		 * Disable DPOunit clock gating, can stall pipe
+		 * and we need DPLL REFA always enabled
+		 */
+		tmp = I915_READ(DPLL(pipe));
+		tmp |= DPLL_REFA_CLK_ENABLE_VLV;
+		I915_WRITE(DPLL(pipe), tmp);
+
+		/* update the hw state for DPLL */
+		intel_crtc->config->dpll_hw_state.dpll =
+				DPLL_INTEGRATED_CLOCK_VLV |
+					DPLL_REFA_CLK_ENABLE_VLV;
+
+		tmp = I915_READ(DSPCLK_GATE_D);
+		tmp |= DPOUNIT_CLOCK_GATE_DISABLE;
+		I915_WRITE(DSPCLK_GATE_D, tmp);
+	}
 
 	/* put device in ready state */
 	intel_dsi_device_ready(encoder);
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#37 lore raw

Re: [BXT MIPI PATCH v3 06/14] drm/i915/bxt: DSI enable for BXT

Quoted 80 lines · Jani Nikula
Quoted 9 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch contains following changes:
1. MIPI device ready changes to support dsi_pre_enable. Changes are specific to BXT device ready sequence. Added check for ULPS mode(No effects on VLV).
2. Changes in dsi_enable to pick BXT port control register.
3. Changes in dsi_pre_enable to restrict DPIO programming for VLV

Quoted 7 lines

v2: Fixed Jani's review comments. Removed the changes in VLV/CHV
code. Fixed the macros to get proper port offsets.

v3: Rebased on latest drm-nightly branch. Fixed Jani's review comments.

When you look at the commits before sending, you should pay more attention to what the diffs end up looking like. In this case, the review becomes unnecessarily hard just because you've moved code (intel_dsi_port_enable) around for no apparent reason, and the diff seems like intel_dsi_port_enable is rewritten into bxt_dsi_device_ready. It should be a hint to *not* combine code movement into the same patch.

I understand the concern. Will be careful of this in future to avoid such issues.

Quoted 52 lines
---
  drivers/gpu/drm/i915/i915_reg.h  |    7 ++
  drivers/gpu/drm/i915/intel_dsi.c |  165 ++++++++++++++++++++++++++------------
  2 files changed, 119 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +7 -0
index 997a999..57c5dbf 100644
@@ -7403,6 +7403,13 @@ enum skl_disp_power_wells {
  #define _MIPIA_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61190)
  #define _MIPIC_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61700)
  #define MIPI_PORT_CTRL(port)	_MIPI_PORT(port, _MIPIA_PORT_CTRL, _MIPIC_PORT_CTRL)
+
+ /* BXT port control */
+#define _BXT_MIPIA_PORT_CTRL				0x6B0C0
+#define _BXT_MIPIC_PORT_CTRL				0x6B8C0
+#define BXT_MIPI_PORT_CTRL(tc)	_MIPI_PORT(tc, _BXT_MIPIA_PORT_CTRL, \
+						_BXT_MIPIC_PORT_CTRL)
+
  #define  DPI_ENABLE					(1 << 31) /* A + C */
  #define  MIPIA_MIPI4DPHY_DELAY_COUNT_SHIFT		27
  #define  MIPIA_MIPI4DPHY_DELAY_COUNT_MASK		(0xf << 27)
drivers/gpu/drm/i915/intel_dsi.c +4 -12
index 6d0c992..5a42f87 100644
@@ -286,58 +286,46 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  	return true;
  }
 
-static void intel_dsi_port_enable(struct intel_encoder *encoder)
+static void bxt_dsi_device_ready(struct intel_encoder *encoder)
  {
-	struct drm_device *dev = encoder->base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  	enum port port;
-	u32 temp;
+	u32 val;
 
-	if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
-		temp = I915_READ(VLV_CHICKEN_3);
-		temp &= ~PIXEL_OVERLAP_CNT_MASK |
-					intel_dsi->pixel_overlap <<
-					PIXEL_OVERLAP_CNT_SHIFT;
-		I915_WRITE(VLV_CHICKEN_3, temp);
-	}
+	DRM_DEBUG_KMS("\n");
 
Quoted 2 lines

drivers/gpu/drm/i915/intel_dsi.c static bool intel_dsi_compute_config(struct intel_encoder *encoder, · line 300

Quoted 2 lines
drivers/gpu/drm/i915/intel_dsi.c +1 -0
+	/* Exit Low power state in 4 steps*/
 

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#38 lore raw

PATCH v3 7/14 drm/i915/bxt: Program Tx Rx and Dphy clocks

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

BXT DSI clocks are different than previous platforms. So adding a new function to program following clocks and dividers:
1. Program variable divider to generate input to Tx clock divider (Output value must be < 39.5Mhz)
2. Select divide by 2 option to get < 20Mhz for Tx clock
3. Program 8by3 divider to generate Rx clock

v2: Fixed Jani's review comments. Adjusted the Macro definition as
per convention. Simplified the logic for bit definitions for MIPI PORT A and PORT C in same registers.

v3: Refactored the macros for TX, RX Escape and DPHY clocks as per
Jani's suggestion.

---
 drivers/gpu/drm/i915/i915_reg.h      |   62 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi_pll.c |   39 +++++++++++++++++++++
 2 files changed, 101 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +62 -0
index 57c5dbf..e43b053 100644
@@ -7362,6 +7362,68 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+/* BXT MIPI clock controls */
+#define BXT_MAX_VAR_OUTPUT_KHZ			39500
+
+#define BXT_MIPI_CLOCK_CTL			0x46090
+#define  BXT_MIPI1_DIV_SHIFT			26
+#define  BXT_MIPI2_DIV_SHIFT			10
+#define  BXT_MIPI_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DIV_SHIFT, \
+					BXT_MIPI2_DIV_SHIFT)
+/* Var clock divider to generate TX source. Result must be < 39.5 M */
+#define  BXT_MIPI1_ESCLK_VAR_DIV_MASK		(0x3F << 26)
+#define  BXT_MIPI2_ESCLK_VAR_DIV_MASK		(0x3F << 10)
+#define  BXT_MIPI_ESCLK_VAR_DIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_ESCLK_VAR_DIV_MASK, \
+						BXT_MIPI2_ESCLK_VAR_DIV_MASK)
+
+#define  BXT_MIPI_ESCLK_VAR_DIV(port, val)	\
+			(val << BXT_MIPI_DIV_SHIFT(port))
+/* TX control divider to select actual TX clock output from (8x/var) */
+#define  BXT_MIPI1_TX_ESCLK_SHIFT		21
+#define  BXT_MIPI2_TX_ESCLK_SHIFT		5
+#define  BXT_MIPI_TX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_SHIFT, \
+					BXT_MIPI2_TX_ESCLK_SHIFT)
+#define  BXT_MIPI1_TX_ESCLK_FIXDIV_MASK		(3 << 21)
+#define  BXT_MIPI2_TX_ESCLK_FIXDIV_MASK		(3 << 5)
+#define  BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_FIXDIV_MASK, \
+						BXT_MIPI2_TX_ESCLK_FIXDIV_MASK)
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY2(port)	\
+		(0x0 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY4(port)	\
+		(0x1 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY8(port)	\
+		(0x2 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+/* RX control divider to select actual RX clock output from 8x*/
+#define  BXT_MIPI1_RX_ESCLK_SHIFT		19
+#define  BXT_MIPI2_RX_ESCLK_SHIFT		3
+#define  BXT_MIPI_RX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_RX_ESCLK_SHIFT, \
+					BXT_MIPI2_RX_ESCLK_SHIFT)
+#define  BXT_MIPI1_RX_ESCLK_FIXDIV_MASK		(3 << 19)
+#define  BXT_MIPI2_RX_ESCLK_FIXDIV_MASK		(3 << 3)
+#define  BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY2(port)	\
+		(1 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY3(port)	\
+		(2 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY4(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+/* BXT: Always prog DPHY dividers to 00 */
+#define  BXT_MIPI1_DPHY_DIV_SHIFT		16
+#define  BXT_MIPI2_DPHY_DIV_SHIFT		0
+#define  BXT_MIPI_DPHY_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DPHY_DIV_SHIFT, \
+					BXT_MIPI2_DPHY_DIV_SHIFT)
+#define  BXT_MIPI_1_DPHY_DIVIDER_MASK		(3 << 16)
+#define  BXT_MIPI_2_DPHY_DIVIDER_MASK		(3 << 0)
+#define  BXT_MIPI_DPHY_DIVIDER_MASK(port)	\
+		(3 << BXT_MIPI_DPHY_DIV_SHIFT(port))
+
 /* BXT MIPI mode configure */
 #define  _BXT_MIPIA_TRANS_HACTIVE			0x6B0F8
 #define  _BXT_MIPIC_TRANS_HACTIVE			0x6B8F8
drivers/gpu/drm/i915/intel_dsi_pll.c +39 -0
index 21a2e37..63f9aed 100644
@@ -389,6 +389,39 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
 	return pclk;
 }
 
+/* Program BXT Mipi clocks and dividers */
+static void bxt_dsi_program_clocks(struct drm_device *dev, enum port port)
+{
+	u32 tmp;
+	u32 divider;
+	u32 dsi_rate;
+	u32 pll_ratio;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	/* Clear old configurations */
+	tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
+	tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_ESCLK_VAR_DIV_MASK(port));
+	tmp &= ~(BXT_MIPI_DPHY_DIVIDER_MASK(port));
+
+	/* Get the current DSI rate(actual) */
+	pll_ratio = I915_READ(BXT_DSI_PLL_CTL) &
+				BXT_DSI_PLL_RATIO_MASK;
+	dsi_rate = (BXT_REF_CLOCK_KHZ * pll_ratio) / 2;
+
+	/* Max possible output of clock is 39.5 MHz, program value -1 */
+	divider = (dsi_rate / BXT_MAX_VAR_OUTPUT_KHZ) - 1;
+	tmp |= BXT_MIPI_ESCLK_VAR_DIV(port, divider);
+
+	/* Tx escape clock should be >=20MHz, so select divide by 2 */
+	tmp |= BXT_MIPI_TX_ESCLK_8XDIV_BY2(port);
+
+	tmp |= BXT_MIPI_RX_ESCLK_8X_BY3(port);
+
+	I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
+}
+
 static bool bxt_configure_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
@@ -440,6 +473,8 @@ static bool bxt_configure_dsi_pll(struct intel_encoder *encoder)
 static void bxt_enable_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	enum port port;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +493,10 @@ static void bxt_enable_dsi_pll(struct intel_encoder *encoder)
 		return;
 	}
 
+	/* Program TX, RX, Dphy clocks */
+	for_each_dsi_port(port, intel_dsi->ports)
+		bxt_dsi_program_clocks(encoder->base.dev, port);
+
 	/* Enable DSI PLL */
 	val = I915_READ(BXT_DSI_PLL_ENABLE);
 	val |= BXT_DSI_PLL_DO_ENABLE;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 7/14
#39 lore raw

Re: [BXT MIPI PATCH v3 07/14] drm/i915/bxt: Program Tx Rx and Dphy clocks

Quoted 13 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

BXT DSI clocks are different than previous platforms. So adding a new function to program following clocks and dividers:
1. Program variable divider to generate input to Tx clock divider (Output value must be < 39.5Mhz)
2. Select divide by 2 option to get < 20Mhz for Tx clock
3. Program 8by3 divider to generate Rx clock

v2: Fixed Jani's review comments. Adjusted the Macro definition as
per convention. Simplified the logic for bit definitions for MIPI PORT A and PORT C in same registers.

Quoted 5 lines

v3: Refactored the macros for TX, RX Escape and DPHY clocks as per
Jani's suggestion.

Minor comments below, anyway

Quoted 55 lines
---
 drivers/gpu/drm/i915/i915_reg.h      |   62 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi_pll.c |   39 +++++++++++++++++++++
 2 files changed, 101 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +42 -0
index 57c5dbf..e43b053 100644
@@ -7362,6 +7362,68 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+/* BXT MIPI clock controls */
+#define BXT_MAX_VAR_OUTPUT_KHZ			39500
+
+#define BXT_MIPI_CLOCK_CTL			0x46090
+#define  BXT_MIPI1_DIV_SHIFT			26
+#define  BXT_MIPI2_DIV_SHIFT			10
+#define  BXT_MIPI_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DIV_SHIFT, \
+					BXT_MIPI2_DIV_SHIFT)
+/* Var clock divider to generate TX source. Result must be < 39.5 M */
+#define  BXT_MIPI1_ESCLK_VAR_DIV_MASK		(0x3F << 26)
+#define  BXT_MIPI2_ESCLK_VAR_DIV_MASK		(0x3F << 10)
+#define  BXT_MIPI_ESCLK_VAR_DIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_ESCLK_VAR_DIV_MASK, \
+						BXT_MIPI2_ESCLK_VAR_DIV_MASK)
+
+#define  BXT_MIPI_ESCLK_VAR_DIV(port, val)	\
+			(val << BXT_MIPI_DIV_SHIFT(port))
+/* TX control divider to select actual TX clock output from (8x/var) */
+#define  BXT_MIPI1_TX_ESCLK_SHIFT		21
+#define  BXT_MIPI2_TX_ESCLK_SHIFT		5
+#define  BXT_MIPI_TX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_SHIFT, \
+					BXT_MIPI2_TX_ESCLK_SHIFT)
+#define  BXT_MIPI1_TX_ESCLK_FIXDIV_MASK		(3 << 21)
+#define  BXT_MIPI2_TX_ESCLK_FIXDIV_MASK		(3 << 5)
+#define  BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_FIXDIV_MASK, \
+						BXT_MIPI2_TX_ESCLK_FIXDIV_MASK)
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY2(port)	\
+		(0x0 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY4(port)	\
+		(0x1 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY8(port)	\
+		(0x2 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+/* RX control divider to select actual RX clock output from 8x*/
+#define  BXT_MIPI1_RX_ESCLK_SHIFT		19
+#define  BXT_MIPI2_RX_ESCLK_SHIFT		3
+#define  BXT_MIPI_RX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_RX_ESCLK_SHIFT, \
+					BXT_MIPI2_RX_ESCLK_SHIFT)
+#define  BXT_MIPI1_RX_ESCLK_FIXDIV_MASK		(3 << 19)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 7416

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+#define  BXT_MIPI2_RX_ESCLK_FIXDIV_MASK		(3 << 3)
+#define  BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY2(port)	\
+		(1 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY3(port)	\
+		(2 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY4(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+/* BXT: Always prog DPHY dividers to 00 */

Actually BXT A stepping W/A, but I don't know the name for it.

Quoted 37 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+#define  BXT_MIPI1_DPHY_DIV_SHIFT		16
+#define  BXT_MIPI2_DPHY_DIV_SHIFT		0
+#define  BXT_MIPI_DPHY_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DPHY_DIV_SHIFT, \
+					BXT_MIPI2_DPHY_DIV_SHIFT)
+#define  BXT_MIPI_1_DPHY_DIVIDER_MASK		(3 << 16)
+#define  BXT_MIPI_2_DPHY_DIVIDER_MASK		(3 << 0)
+#define  BXT_MIPI_DPHY_DIVIDER_MASK(port)	\
+		(3 << BXT_MIPI_DPHY_DIV_SHIFT(port))
+
 /* BXT MIPI mode configure */
 #define  _BXT_MIPIA_TRANS_HACTIVE			0x6B0F8
 #define  _BXT_MIPIC_TRANS_HACTIVE			0x6B8F8
drivers/gpu/drm/i915/intel_dsi_pll.c +16 -0
index 21a2e37..63f9aed 100644
@@ -389,6 +389,39 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
 	return pclk;
 }
 
+/* Program BXT Mipi clocks and dividers */
+static void bxt_dsi_program_clocks(struct drm_device *dev, enum port port)
+{
+	u32 tmp;
+	u32 divider;
+	u32 dsi_rate;
+	u32 pll_ratio;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	/* Clear old configurations */
+	tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
+	tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_ESCLK_VAR_DIV_MASK(port));
+	tmp &= ~(BXT_MIPI_DPHY_DIVIDER_MASK(port));
+

drivers/gpu/drm/i915/intel_dsi_pll.c u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp) · line 417

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_pll.c +10 -0
+	/* Get the current DSI rate(actual) */
+	pll_ratio = I915_READ(BXT_DSI_PLL_CTL) &
+				BXT_DSI_PLL_RATIO_MASK;
+	dsi_rate = (BXT_REF_CLOCK_KHZ * pll_ratio) / 2;
+
+	/* Max possible output of clock is 39.5 MHz, program value -1 */
+	divider = (dsi_rate / BXT_MAX_VAR_OUTPUT_KHZ) - 1;
+	tmp |= BXT_MIPI_ESCLK_VAR_DIV(port, divider);
+
+	/* Tx escape clock should be >=20MHz, so select divide by 2 */

Actually the Tx escape clock must be as close as possible to, but not exceed, 20 MHz.

Quoted 33 lines
drivers/gpu/drm/i915/intel_dsi_pll.c +13 -0
+	tmp |= BXT_MIPI_TX_ESCLK_8XDIV_BY2(port);
+
+	tmp |= BXT_MIPI_RX_ESCLK_8X_BY3(port);
+
+	I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
+}
+
 static bool bxt_configure_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
@@ -440,6 +473,8 @@ static bool bxt_configure_dsi_pll(struct intel_encoder *encoder)
 static void bxt_enable_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	enum port port;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +493,10 @@ static void bxt_enable_dsi_pll(struct intel_encoder *encoder)
 		return;
 	}
 
+	/* Program TX, RX, Dphy clocks */
+	for_each_dsi_port(port, intel_dsi->ports)
+		bxt_dsi_program_clocks(encoder->base.dev, port);
+
 	/* Enable DSI PLL */
 	val = I915_READ(BXT_DSI_PLL_ENABLE);
 	val |= BXT_DSI_PLL_DO_ENABLE;
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#40 lore raw

Re: [BXT MIPI PATCH v3 07/14] drm/i915/bxt: Program Tx Rx and Dphy clocks

Quoted 24 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 6:58 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Sharma, Shashank; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 07/14] drm/i915/bxt: Program Tx Rx and Dphy clocks

Quoted 13 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

BXT DSI clocks are different than previous platforms. So adding a new function to program following clocks and dividers:
1. Program variable divider to generate input to Tx clock divider (Output value must be < 39.5Mhz)
2. Select divide by 2 option to get < 20Mhz for Tx clock 3. Program 8by3 divider to generate Rx clock

v2: Fixed Jani's review comments. Adjusted the Macro definition as
per convention. Simplified the logic for bit definitions for MIPI PORT A and PORT C in same registers.

Quoted 7 lines
Quoted 5 lines

v3: Refactored the macros for TX, RX Escape and DPHY clocks as per
Jani's suggestion.

Minor comments below, anyway

Thanks for the comments Jani. Will update while sending next patchset.

Quoted 83 lines
Quoted 2 lines
---
 drivers/gpu/drm/i915/i915_reg.h      |   62

++++++++++++++++++++++++++++++++++

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 7363

Quoted 10 lines
 drivers/gpu/drm/i915/intel_dsi_pll.c |   39 +++++++++++++++++++++
 2 files changed, 101 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h index 57c5dbf..e43b053 100644

drivers/gpu/drm/i915/i915_reg.h +0 -0
@@ -7362,6 +7362,68 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and

C only */

Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +5 -0
+/* BXT MIPI clock controls */
+#define BXT_MAX_VAR_OUTPUT_KHZ			39500
+
+#define BXT_MIPI_CLOCK_CTL			0x46090
+#define  BXT_MIPI1_DIV_SHIFT			26

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 7380

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+#define  BXT_MIPI2_DIV_SHIFT			10
+#define  BXT_MIPI_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DIV_SHIFT, \
+					BXT_MIPI2_DIV_SHIFT)
+/* Var clock divider to generate TX source. Result must be < 39.5 M */
+#define  BXT_MIPI1_ESCLK_VAR_DIV_MASK		(0x3F << 26)
+#define  BXT_MIPI2_ESCLK_VAR_DIV_MASK		(0x3F << 10)
+#define  BXT_MIPI_ESCLK_VAR_DIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_ESCLK_VAR_DIV_MASK, \
+

BXT_MIPI2_ESCLK_VAR_DIV_MASK)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 13 lines
drivers/gpu/drm/i915/i915_reg.h +13 -0
+
+#define  BXT_MIPI_ESCLK_VAR_DIV(port, val)	\
+			(val << BXT_MIPI_DIV_SHIFT(port))
+/* TX control divider to select actual TX clock output from (8x/var) */
+#define  BXT_MIPI1_TX_ESCLK_SHIFT		21
+#define  BXT_MIPI2_TX_ESCLK_SHIFT		5
+#define  BXT_MIPI_TX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_SHIFT, \
+					BXT_MIPI2_TX_ESCLK_SHIFT)
+#define  BXT_MIPI1_TX_ESCLK_FIXDIV_MASK		(3 << 21)
+#define  BXT_MIPI2_TX_ESCLK_FIXDIV_MASK		(3 << 5)
+#define  BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_FIXDIV_MASK,

\

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 7416

Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +4 -0
+		(2 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY4(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+/* BXT: Always prog DPHY dividers to 00 */

Actually BXT A stepping W/A, but I don't know the name for it.

Quoted 13 lines
drivers/gpu/drm/i915/i915_reg.h +13 -0
+#define  BXT_MIPI1_DPHY_DIV_SHIFT		16
+#define  BXT_MIPI2_DPHY_DIV_SHIFT		0
+#define  BXT_MIPI_DPHY_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DPHY_DIV_SHIFT, \
+					BXT_MIPI2_DPHY_DIV_SHIFT)
+/* Program BXT Mipi clocks and dividers */ static void
+bxt_dsi_program_clocks(struct drm_device *dev, enum port port) {
+	u32 tmp;
+	u32 divider;
+	u32 dsi_rate;
+	u32 pll_ratio;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 7418

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+	/* Get the current DSI rate(actual) */
+	pll_ratio = I915_READ(BXT_DSI_PLL_CTL) &
+				BXT_DSI_PLL_RATIO_MASK;
+	dsi_rate = (BXT_REF_CLOCK_KHZ * pll_ratio) / 2;
+
+	/* Max possible output of clock is 39.5 MHz, program value -1 */
+	divider = (dsi_rate / BXT_MAX_VAR_OUTPUT_KHZ) - 1;
+	tmp |= BXT_MIPI_ESCLK_VAR_DIV(port, divider);
+
+	/* Tx escape clock should be >=20MHz, so select divide by 2 */

Actually the Tx escape clock must be as close as possible to, but not exceed, 20 MHz.

Quoted 2 lines

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 7420

Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
+	tmp |= BXT_MIPI_TX_ESCLK_8XDIV_BY2(port);
+

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#41 lore raw

PATCH v4 7/14 drm/i915/bxt: Program Tx Rx and Dphy clocks

In reply to Jani Nikula

From: Shashank Sharma <[email protected]>

BXT DSI clocks are different than previous platforms. So adding a new function to program following clocks and dividers:
1. Program variable divider to generate input to Tx clock divider (Output value must be < 39.5Mhz)
2. Select divide by 2 option to get < 20Mhz for Tx clock
3. Program 8by3 divider to generate Rx clock

v2: Fixed Jani's review comments. Adjusted the Macro definition as
per convention. Simplified the logic for bit definitions for MIPI PORT A and PORT C in same registers.

v3: Refactored the macros for TX, RX Escape and DPHY clocks as per
Jani's suggestion.

v4: Addressed Jani's review comments.

---
 drivers/gpu/drm/i915/i915_reg.h      |   62 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi_pll.c |   42 +++++++++++++++++++++++
 2 files changed, 104 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +62 -0
index 57c5dbf..88a16e2 100644
@@ -7362,6 +7362,68 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+/* BXT MIPI clock controls */
+#define BXT_MAX_VAR_OUTPUT_KHZ			39500
+
+#define BXT_MIPI_CLOCK_CTL			0x46090
+#define  BXT_MIPI1_DIV_SHIFT			26
+#define  BXT_MIPI2_DIV_SHIFT			10
+#define  BXT_MIPI_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DIV_SHIFT, \
+					BXT_MIPI2_DIV_SHIFT)
+/* Var clock divider to generate TX source. Result must be < 39.5 M */
+#define  BXT_MIPI1_ESCLK_VAR_DIV_MASK		(0x3F << 26)
+#define  BXT_MIPI2_ESCLK_VAR_DIV_MASK		(0x3F << 10)
+#define  BXT_MIPI_ESCLK_VAR_DIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_ESCLK_VAR_DIV_MASK, \
+						BXT_MIPI2_ESCLK_VAR_DIV_MASK)
+
+#define  BXT_MIPI_ESCLK_VAR_DIV(port, val)	\
+			(val << BXT_MIPI_DIV_SHIFT(port))
+/* TX control divider to select actual TX clock output from (8x/var) */
+#define  BXT_MIPI1_TX_ESCLK_SHIFT		21
+#define  BXT_MIPI2_TX_ESCLK_SHIFT		5
+#define  BXT_MIPI_TX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_SHIFT, \
+					BXT_MIPI2_TX_ESCLK_SHIFT)
+#define  BXT_MIPI1_TX_ESCLK_FIXDIV_MASK		(3 << 21)
+#define  BXT_MIPI2_TX_ESCLK_FIXDIV_MASK		(3 << 5)
+#define  BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_FIXDIV_MASK, \
+						BXT_MIPI2_TX_ESCLK_FIXDIV_MASK)
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY2(port)	\
+		(0x0 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY4(port)	\
+		(0x1 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY8(port)	\
+		(0x2 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+/* RX control divider to select actual RX clock output from 8x*/
+#define  BXT_MIPI1_RX_ESCLK_SHIFT		19
+#define  BXT_MIPI2_RX_ESCLK_SHIFT		3
+#define  BXT_MIPI_RX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_RX_ESCLK_SHIFT, \
+					BXT_MIPI2_RX_ESCLK_SHIFT)
+#define  BXT_MIPI1_RX_ESCLK_FIXDIV_MASK		(3 << 19)
+#define  BXT_MIPI2_RX_ESCLK_FIXDIV_MASK		(3 << 3)
+#define  BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY2(port)	\
+		(1 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY3(port)	\
+		(2 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY4(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+/* BXT-A WA: Always prog DPHY dividers to 00 */
+#define  BXT_MIPI1_DPHY_DIV_SHIFT		16
+#define  BXT_MIPI2_DPHY_DIV_SHIFT		0
+#define  BXT_MIPI_DPHY_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DPHY_DIV_SHIFT, \
+					BXT_MIPI2_DPHY_DIV_SHIFT)
+#define  BXT_MIPI_1_DPHY_DIVIDER_MASK		(3 << 16)
+#define  BXT_MIPI_2_DPHY_DIVIDER_MASK		(3 << 0)
+#define  BXT_MIPI_DPHY_DIVIDER_MASK(port)	\
+		(3 << BXT_MIPI_DPHY_DIV_SHIFT(port))
+
 /* BXT MIPI mode configure */
 #define  _BXT_MIPIA_TRANS_HACTIVE			0x6B0F8
 #define  _BXT_MIPIC_TRANS_HACTIVE			0x6B8F8
drivers/gpu/drm/i915/intel_dsi_pll.c +42 -0

60 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v4 7/14
#42 lore raw

Re: [BXT MIPI PATCH v4 07/14] drm/i915/bxt: Program Tx Rx and Dphy clocks

Quoted 13 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

BXT DSI clocks are different than previous platforms. So adding a new function to program following clocks and dividers:
1. Program variable divider to generate input to Tx clock divider (Output value must be < 39.5Mhz)
2. Select divide by 2 option to get < 20Mhz for Tx clock
3. Program 8by3 divider to generate Rx clock

v2: Fixed Jani's review comments. Adjusted the Macro definition as
per convention. Simplified the logic for bit definitions for MIPI PORT A and PORT C in same registers.

Quoted 7 lines

v3: Refactored the macros for TX, RX Escape and DPHY clocks as per
Jani's suggestion.

v4: Addressed Jani's review comments.

Quoted 148 lines
---
 drivers/gpu/drm/i915/i915_reg.h      |   62 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi_pll.c |   42 +++++++++++++++++++++++
 2 files changed, 104 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +62 -0
index 57c5dbf..88a16e2 100644
@@ -7362,6 +7362,68 @@ enum skl_disp_power_wells {
 
 #define _MIPI_PORT(port, a, c)	_PORT3(port, a, 0, c)	/* ports A and C only */
 
+/* BXT MIPI clock controls */
+#define BXT_MAX_VAR_OUTPUT_KHZ			39500
+
+#define BXT_MIPI_CLOCK_CTL			0x46090
+#define  BXT_MIPI1_DIV_SHIFT			26
+#define  BXT_MIPI2_DIV_SHIFT			10
+#define  BXT_MIPI_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DIV_SHIFT, \
+					BXT_MIPI2_DIV_SHIFT)
+/* Var clock divider to generate TX source. Result must be < 39.5 M */
+#define  BXT_MIPI1_ESCLK_VAR_DIV_MASK		(0x3F << 26)
+#define  BXT_MIPI2_ESCLK_VAR_DIV_MASK		(0x3F << 10)
+#define  BXT_MIPI_ESCLK_VAR_DIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_ESCLK_VAR_DIV_MASK, \
+						BXT_MIPI2_ESCLK_VAR_DIV_MASK)
+
+#define  BXT_MIPI_ESCLK_VAR_DIV(port, val)	\
+			(val << BXT_MIPI_DIV_SHIFT(port))
+/* TX control divider to select actual TX clock output from (8x/var) */
+#define  BXT_MIPI1_TX_ESCLK_SHIFT		21
+#define  BXT_MIPI2_TX_ESCLK_SHIFT		5
+#define  BXT_MIPI_TX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_SHIFT, \
+					BXT_MIPI2_TX_ESCLK_SHIFT)
+#define  BXT_MIPI1_TX_ESCLK_FIXDIV_MASK		(3 << 21)
+#define  BXT_MIPI2_TX_ESCLK_FIXDIV_MASK		(3 << 5)
+#define  BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port)	\
+			_MIPI_PORT(port, BXT_MIPI1_TX_ESCLK_FIXDIV_MASK, \
+						BXT_MIPI2_TX_ESCLK_FIXDIV_MASK)
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY2(port)	\
+		(0x0 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY4(port)	\
+		(0x1 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_TX_ESCLK_8XDIV_BY8(port)	\
+		(0x2 << BXT_MIPI_TX_ESCLK_SHIFT(port))
+/* RX control divider to select actual RX clock output from 8x*/
+#define  BXT_MIPI1_RX_ESCLK_SHIFT		19
+#define  BXT_MIPI2_RX_ESCLK_SHIFT		3
+#define  BXT_MIPI_RX_ESCLK_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_RX_ESCLK_SHIFT, \
+					BXT_MIPI2_RX_ESCLK_SHIFT)
+#define  BXT_MIPI1_RX_ESCLK_FIXDIV_MASK		(3 << 19)
+#define  BXT_MIPI2_RX_ESCLK_FIXDIV_MASK		(3 << 3)
+#define  BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY2(port)	\
+		(1 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY3(port)	\
+		(2 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+#define  BXT_MIPI_RX_ESCLK_8X_BY4(port)	\
+		(3 << BXT_MIPI_RX_ESCLK_SHIFT(port))
+/* BXT-A WA: Always prog DPHY dividers to 00 */
+#define  BXT_MIPI1_DPHY_DIV_SHIFT		16
+#define  BXT_MIPI2_DPHY_DIV_SHIFT		0
+#define  BXT_MIPI_DPHY_DIV_SHIFT(port)		\
+			_MIPI_PORT(port, BXT_MIPI1_DPHY_DIV_SHIFT, \
+					BXT_MIPI2_DPHY_DIV_SHIFT)
+#define  BXT_MIPI_1_DPHY_DIVIDER_MASK		(3 << 16)
+#define  BXT_MIPI_2_DPHY_DIVIDER_MASK		(3 << 0)
+#define  BXT_MIPI_DPHY_DIVIDER_MASK(port)	\
+		(3 << BXT_MIPI_DPHY_DIV_SHIFT(port))
+
 /* BXT MIPI mode configure */
 #define  _BXT_MIPIA_TRANS_HACTIVE			0x6B0F8
 #define  _BXT_MIPIC_TRANS_HACTIVE			0x6B8F8
drivers/gpu/drm/i915/intel_dsi_pll.c +42 -0
index 21a2e37..e62729f 100644
@@ -389,6 +389,42 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
 	return pclk;
 }
 
+/* Program BXT Mipi clocks and dividers */
+static void bxt_dsi_program_clocks(struct drm_device *dev, enum port port)
+{
+	u32 tmp;
+	u32 divider;
+	u32 dsi_rate;
+	u32 pll_ratio;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	/* Clear old configurations */
+	tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
+	tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_ESCLK_VAR_DIV_MASK(port));
+	tmp &= ~(BXT_MIPI_DPHY_DIVIDER_MASK(port));
+
+	/* Get the current DSI rate(actual) */
+	pll_ratio = I915_READ(BXT_DSI_PLL_CTL) &
+				BXT_DSI_PLL_RATIO_MASK;
+	dsi_rate = (BXT_REF_CLOCK_KHZ * pll_ratio) / 2;
+
+	/* Max possible output of clock is 39.5 MHz, program value -1 */
+	divider = (dsi_rate / BXT_MAX_VAR_OUTPUT_KHZ) - 1;
+	tmp |= BXT_MIPI_ESCLK_VAR_DIV(port, divider);
+
+	/*
+	 * Tx escape clock must be as close to 20MHz possible, but should
+	 * not exceed it. Hence select divide by 2
+	 */
+	tmp |= BXT_MIPI_TX_ESCLK_8XDIV_BY2(port);
+
+	tmp |= BXT_MIPI_RX_ESCLK_8X_BY3(port);
+
+	I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
+}
+
 static bool bxt_configure_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
@@ -440,6 +476,8 @@ static bool bxt_configure_dsi_pll(struct intel_encoder *encoder)
 static void bxt_enable_dsi_pll(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	enum port port;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +496,10 @@ static void bxt_enable_dsi_pll(struct intel_encoder *encoder)
 		return;
 	}
 
+	/* Program TX, RX, Dphy clocks */
+	for_each_dsi_port(port, intel_dsi->ports)
+		bxt_dsi_program_clocks(encoder->base.dev, port);
+
 	/* Enable DSI PLL */
 	val = I915_READ(BXT_DSI_PLL_ENABLE);
 	val |= BXT_DSI_PLL_DO_ENABLE;
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#43 lore raw

PATCH v3 8/14 drm/i915/bxt: DSI disable and post-disable

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

This patch contains changes to support DSI disble sequence in BXT. The changes are:
1. BXT specific changes in clear_device_ready function.
2. BXT specific changes in DSI disable and post-disable functions.
3. Add a new function to reset BXT Dphy clock and dividers (bxt_dsi_reset_clocks).
4. Moved some part of the vlv clock reset code, in a new function (vlv_dsi_reset_clocks) maintaining the exact same sequence.
5. Wrapper function to call corresponding reset clock function.

v2: Fixed Jani's review comments.

v3: Removed the GET_DSI_PORT_CTRL Macro for consistency with earlier
implementations as per Jani's suggestion.

---
 drivers/gpu/drm/i915/intel_dsi.c     |   36 +++++++++++++++++--------------
 drivers/gpu/drm/i915/intel_dsi.h     |    2 ++
 drivers/gpu/drm/i915/intel_dsi_pll.c |   39 ++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +20 -16
index 5a42f87..110a895 100644
@@ -421,12 +421,15 @@ static void intel_dsi_port_disable(struct intel_encoder *encoder)
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	enum port port;
 	u32 temp;
+	u32 port_ctrl;
 
 	for_each_dsi_port(port, intel_dsi->ports) {
 		/* de-assert ip_tg_enable signal */
-		temp = I915_READ(MIPI_PORT_CTRL(port));
-		I915_WRITE(MIPI_PORT_CTRL(port), temp & ~DPI_ENABLE);
-		POSTING_READ(MIPI_PORT_CTRL(port));
+		port_ctrl = IS_BROXTON(dev) ? BXT_MIPI_PORT_CTRL(port) :
+						MIPI_PORT_CTRL(port);
+		temp = I915_READ(port_ctrl);
+		I915_WRITE(port_ctrl, temp & ~DPI_ENABLE);
+		POSTING_READ(port_ctrl);
 	}
 }
 
@@ -550,12 +553,7 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 		/* Panel commands can be sent when clock is in LP11 */
 		I915_WRITE(MIPI_DEVICE_READY(port), 0x0);
 
-		temp = I915_READ(MIPI_CTRL(port));
-		temp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
-		I915_WRITE(MIPI_CTRL(port), temp |
-			   intel_dsi->escape_clk_div <<
-			   ESCAPE_CLOCK_DIVIDER_SHIFT);
-
+		intel_dsi_reset_clocks(encoder, port);
 		I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
 
 		temp = I915_READ(MIPI_DSI_FUNC_PRG(port));
@@ -574,10 +572,12 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 
 static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
 {
+	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	enum port port;
 	u32 val;
+	u32 port_ctrl = 0;
 
 	DRM_DEBUG_KMS("\n");
 	for_each_dsi_port(port, intel_dsi->ports) {
@@ -594,18 +594,22 @@ static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
 							ULPS_STATE_ENTER);
 		usleep_range(2000, 2500);
 
+		if (IS_BROXTON(dev))
+			port_ctrl = BXT_MIPI_PORT_CTRL(port);
+		else if (IS_VALLEYVIEW(dev))
+			/* Common bit for both MIPI Port A & MIPI Port C */
+			port_ctrl = MIPI_PORT_CTRL(PORT_A);
+
 		/* Wait till Clock lanes are in LP-00 state for MIPI Port A
 		 * only. MIPI Port C has no similar bit for checking
 		 */
-		if (wait_for(((I915_READ(MIPI_PORT_CTRL(PORT_A)) & AFE_LATCHOUT)
-							== 0x00000), 30))
+		if (wait_for(((I915_READ(port_ctrl) & AFE_LATCHOUT)
+						== 0x00000), 30))
 			DRM_ERROR("DSI LP not going Low\n");
 
-		/* Disable MIPI PHY transparent latch
-		 * Common bit for both MIPI Port A & MIPI Port C
-		 */
-		val = I915_READ(MIPI_PORT_CTRL(PORT_A));
-		I915_WRITE(MIPI_PORT_CTRL(PORT_A), val & ~LP_OUTPUT_HOLD);
+		/* Disable MIPI PHY transparent latch */
+		val = I915_READ(port_ctrl);
+		I915_WRITE(port_ctrl, val & ~LP_OUTPUT_HOLD);
 		usleep_range(1000, 1500);
 
 		I915_WRITE(MIPI_DEVICE_READY(port), 0x00);
drivers/gpu/drm/i915/intel_dsi.h +2 -0
index 759983e..078ea1b 100644
@@ -124,6 +124,8 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
 extern void intel_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
+extern void intel_dsi_reset_clocks(struct intel_encoder *encoder,
+							enum port port);
 
 struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id);
 
drivers/gpu/drm/i915/intel_dsi_pll.c +39 -0
index 63f9aed..918bc5f 100644
@@ -389,6 +389,19 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
 	return pclk;
 }
 
+void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
+{
+	u32 temp;
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+
+	temp = I915_READ(MIPI_CTRL(port));
+	temp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
+	I915_WRITE(MIPI_CTRL(port), temp |
+			intel_dsi->escape_clk_div <<
+			ESCAPE_CLOCK_DIVIDER_SHIFT);
+}
+
 /* Program BXT Mipi clocks and dividers */
 static void bxt_dsi_program_clocks(struct drm_device *dev, enum port port)
 {
@@ -530,3 +543,29 @@ void intel_disable_dsi_pll(struct intel_encoder *encoder)
 	else if (IS_BROXTON(dev))
 		bxt_disable_dsi_pll(encoder);
 }
+
+void bxt_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
+{
+	u32 tmp;
+	struct drm_device *dev = encoder->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	/* Clear old configurations */
+	tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
+	tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_ESCLK_VAR_DIV_MASK(port));
+	tmp &= ~(BXT_MIPI_DPHY_DIVIDER_MASK(port));
+	I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
+	I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
+}
+
+void intel_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
+{
+	struct drm_device *dev = encoder->base.dev;
+
+	if (IS_BROXTON(dev))
+		bxt_dsi_reset_clocks(encoder, port);
+	else if (IS_VALLEYVIEW(dev))
+		vlv_dsi_reset_clocks(encoder, port);
+}
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 8/14
#44 lore raw

Re: [BXT MIPI PATCH v3 08/14] drm/i915/bxt: DSI disable and post-disable

Quoted 12 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

This patch contains changes to support DSI disble sequence in BXT. The changes are:
1. BXT specific changes in clear_device_ready function.
2. BXT specific changes in DSI disable and post-disable functions.
3. Add a new function to reset BXT Dphy clock and dividers (bxt_dsi_reset_clocks).
4. Moved some part of the vlv clock reset code, in a new function (vlv_dsi_reset_clocks) maintaining the exact same sequence.
5. Wrapper function to call corresponding reset clock function.

Quoted 7 lines

v2: Fixed Jani's review comments.

v3: Removed the GET_DSI_PORT_CTRL Macro for consistency with earlier
implementations as per Jani's suggestion.

Quoted 156 lines
---
 drivers/gpu/drm/i915/intel_dsi.c     |   36 +++++++++++++++++--------------
 drivers/gpu/drm/i915/intel_dsi.h     |    2 ++
 drivers/gpu/drm/i915/intel_dsi_pll.c |   39 ++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +20 -16
index 5a42f87..110a895 100644
@@ -421,12 +421,15 @@ static void intel_dsi_port_disable(struct intel_encoder *encoder)
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	enum port port;
 	u32 temp;
+	u32 port_ctrl;
 
 	for_each_dsi_port(port, intel_dsi->ports) {
 		/* de-assert ip_tg_enable signal */
-		temp = I915_READ(MIPI_PORT_CTRL(port));
-		I915_WRITE(MIPI_PORT_CTRL(port), temp & ~DPI_ENABLE);
-		POSTING_READ(MIPI_PORT_CTRL(port));
+		port_ctrl = IS_BROXTON(dev) ? BXT_MIPI_PORT_CTRL(port) :
+						MIPI_PORT_CTRL(port);
+		temp = I915_READ(port_ctrl);
+		I915_WRITE(port_ctrl, temp & ~DPI_ENABLE);
+		POSTING_READ(port_ctrl);
 	}
 }
 
@@ -550,12 +553,7 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 		/* Panel commands can be sent when clock is in LP11 */
 		I915_WRITE(MIPI_DEVICE_READY(port), 0x0);
 
-		temp = I915_READ(MIPI_CTRL(port));
-		temp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
-		I915_WRITE(MIPI_CTRL(port), temp |
-			   intel_dsi->escape_clk_div <<
-			   ESCAPE_CLOCK_DIVIDER_SHIFT);
-
+		intel_dsi_reset_clocks(encoder, port);
 		I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
 
 		temp = I915_READ(MIPI_DSI_FUNC_PRG(port));
@@ -574,10 +572,12 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 
 static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
 {
+	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	enum port port;
 	u32 val;
+	u32 port_ctrl = 0;
 
 	DRM_DEBUG_KMS("\n");
 	for_each_dsi_port(port, intel_dsi->ports) {
@@ -594,18 +594,22 @@ static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
 							ULPS_STATE_ENTER);
 		usleep_range(2000, 2500);
 
+		if (IS_BROXTON(dev))
+			port_ctrl = BXT_MIPI_PORT_CTRL(port);
+		else if (IS_VALLEYVIEW(dev))
+			/* Common bit for both MIPI Port A & MIPI Port C */
+			port_ctrl = MIPI_PORT_CTRL(PORT_A);
+
 		/* Wait till Clock lanes are in LP-00 state for MIPI Port A
 		 * only. MIPI Port C has no similar bit for checking
 		 */
-		if (wait_for(((I915_READ(MIPI_PORT_CTRL(PORT_A)) & AFE_LATCHOUT)
-							== 0x00000), 30))
+		if (wait_for(((I915_READ(port_ctrl) & AFE_LATCHOUT)
+						== 0x00000), 30))
 			DRM_ERROR("DSI LP not going Low\n");
 
-		/* Disable MIPI PHY transparent latch
-		 * Common bit for both MIPI Port A & MIPI Port C
-		 */
-		val = I915_READ(MIPI_PORT_CTRL(PORT_A));
-		I915_WRITE(MIPI_PORT_CTRL(PORT_A), val & ~LP_OUTPUT_HOLD);
+		/* Disable MIPI PHY transparent latch */
+		val = I915_READ(port_ctrl);
+		I915_WRITE(port_ctrl, val & ~LP_OUTPUT_HOLD);
 		usleep_range(1000, 1500);
 
 		I915_WRITE(MIPI_DEVICE_READY(port), 0x00);
drivers/gpu/drm/i915/intel_dsi.h +2 -0
index 759983e..078ea1b 100644
@@ -124,6 +124,8 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
 extern void intel_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
+extern void intel_dsi_reset_clocks(struct intel_encoder *encoder,
+							enum port port);
 
 struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id);
 
drivers/gpu/drm/i915/intel_dsi_pll.c +39 -0
index 63f9aed..918bc5f 100644
@@ -389,6 +389,19 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
 	return pclk;
 }
 
+void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
+{
+	u32 temp;
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+
+	temp = I915_READ(MIPI_CTRL(port));
+	temp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
+	I915_WRITE(MIPI_CTRL(port), temp |
+			intel_dsi->escape_clk_div <<
+			ESCAPE_CLOCK_DIVIDER_SHIFT);
+}
+
 /* Program BXT Mipi clocks and dividers */
 static void bxt_dsi_program_clocks(struct drm_device *dev, enum port port)
 {
@@ -530,3 +543,29 @@ void intel_disable_dsi_pll(struct intel_encoder *encoder)
 	else if (IS_BROXTON(dev))
 		bxt_disable_dsi_pll(encoder);
 }
+
+void bxt_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
+{
+	u32 tmp;
+	struct drm_device *dev = encoder->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	/* Clear old configurations */
+	tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
+	tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_RX_ESCLK_FIXDIV_MASK(port));
+	tmp &= ~(BXT_MIPI_ESCLK_VAR_DIV_MASK(port));
+	tmp &= ~(BXT_MIPI_DPHY_DIVIDER_MASK(port));
+	I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
+	I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
+}
+
+void intel_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
+{
+	struct drm_device *dev = encoder->base.dev;
+
+	if (IS_BROXTON(dev))
+		bxt_dsi_reset_clocks(encoder, port);
+	else if (IS_VALLEYVIEW(dev))
+		vlv_dsi_reset_clocks(encoder, port);
+}
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#45 lore raw

PATCH v3 9/14 drm/i915/bxt: get_hw_state for BXT

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

Pick appropriate port control register (BXT or VLV), based on device. Get the current hw state wrt Mipi port.

v2: Rebased on latest drm nightly branch.

v3: Removed the GET_DSI_PORT_CTRL Macro for consistency with earlier
implementations as per Jani's suggestion.

---
 drivers/gpu/drm/i915/intel_dsi.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +4 -3
index 110a895..001569b 100644
@@ -648,7 +648,7 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	struct drm_device *dev = encoder->base.dev;
 	enum intel_display_power_domain power_domain;
-	u32 dpi_enabled, func;
+	u32 dpi_enabled, func, ctrl_reg;
 	enum port port;
 
 	DRM_DEBUG_KMS("\n");
@@ -660,8 +660,9 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
 	/* XXX: this only works for one DSI output */
 	for_each_dsi_port(port, intel_dsi->ports) {
 		func = I915_READ(MIPI_DSI_FUNC_PRG(port));
-		dpi_enabled = I915_READ(MIPI_PORT_CTRL(port)) &
-							DPI_ENABLE;
+		ctrl_reg = IS_BROXTON(dev) ? BXT_MIPI_PORT_CTRL(port) :
+						MIPI_PORT_CTRL(port);
+		dpi_enabled = I915_READ(ctrl_reg) & DPI_ENABLE;
 
 		/* Due to some hardware limitations on BYT, MIPI Port C DPI
 		 * Enable bit does not get set. To check whether DSI Port C
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 9/14
#46 lore raw

Re: [BXT MIPI PATCH v3 09/14] drm/i915/bxt: get_hw_state for BXT

Quoted 5 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

Pick appropriate port control register (BXT or VLV), based on device. Get the current hw state wrt Mipi port.

Quoted 7 lines

v2: Rebased on latest drm nightly branch.

v3: Removed the GET_DSI_PORT_CTRL Macro for consistency with earlier
implementations as per Jani's suggestion.

Quoted 32 lines
---
 drivers/gpu/drm/i915/intel_dsi.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +4 -3
index 110a895..001569b 100644
@@ -648,7 +648,7 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	struct drm_device *dev = encoder->base.dev;
 	enum intel_display_power_domain power_domain;
-	u32 dpi_enabled, func;
+	u32 dpi_enabled, func, ctrl_reg;
 	enum port port;
 
 	DRM_DEBUG_KMS("\n");
@@ -660,8 +660,9 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
 	/* XXX: this only works for one DSI output */
 	for_each_dsi_port(port, intel_dsi->ports) {
 		func = I915_READ(MIPI_DSI_FUNC_PRG(port));
-		dpi_enabled = I915_READ(MIPI_PORT_CTRL(port)) &
-							DPI_ENABLE;
+		ctrl_reg = IS_BROXTON(dev) ? BXT_MIPI_PORT_CTRL(port) :
+						MIPI_PORT_CTRL(port);
+		dpi_enabled = I915_READ(ctrl_reg) & DPI_ENABLE;
 
 		/* Due to some hardware limitations on BYT, MIPI Port C DPI
 		 * Enable bit does not get set. To check whether DSI Port C
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#47 lore raw

PATCH v3 10/14 drm/i915/bxt: get DSI pixelclock

In reply to Uma Shankar

From: Shashank Sharma <[email protected]>

BXT's DSI PLL is different from that of VLV. So this patch adds a new function to get the current DSI pixel clock based on the PLL divider ratio and lane count.

This function is required for intel_dsi_get_config() function.

v2: Fixed Jani's review comments.

---
 drivers/gpu/drm/i915/intel_dsi.c     |    8 ++++++--
 drivers/gpu/drm/i915/intel_dsi.h     |    1 +
 drivers/gpu/drm/i915/intel_dsi_pll.c |   35 ++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +6 -2
index 001569b..6a0071f 100644
@@ -687,7 +687,7 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
 static void intel_dsi_get_config(struct intel_encoder *encoder,
 				 struct intel_crtc_state *pipe_config)
 {
-	u32 pclk;
+	u32 pclk = 0;
 	DRM_DEBUG_KMS("\n");
 
 	/*
@@ -696,7 +696,11 @@ static void intel_dsi_get_config(struct intel_encoder *encoder,
 	 */
 	pipe_config->dpll_hw_state.dpll_md = 0;
 
-	pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
+	if (IS_BROXTON(encoder->base.dev))
+		pclk = bxt_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
+	else if (IS_VALLEYVIEW(encoder->base.dev))
+		pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
+
 	if (!pclk)
 		return;
 
drivers/gpu/drm/i915/intel_dsi.h +1 -0
index 078ea1b..24fc550 100644
@@ -124,6 +124,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
 extern void intel_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
+extern u32 bxt_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 extern void intel_dsi_reset_clocks(struct intel_encoder *encoder,
 							enum port port);
 
drivers/gpu/drm/i915/intel_dsi_pll.c +35 -0
index 918bc5f..9860bb5 100644
@@ -389,6 +389,41 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
 	return pclk;
 }
 
+u32 bxt_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
+{
+	u32 pclk;
+	u32 dsi_clk;
+	u32 dsi_ratio;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+
+	/* Divide by zero */
+	if (!pipe_bpp) {
+		DRM_ERROR("Invalid BPP(0)\n");
+		return 0;
+	}
+
+	dsi_ratio = I915_READ(BXT_DSI_PLL_CTL) &
+				BXT_DSI_PLL_RATIO_MASK;
+
+	/* Invalid DSI ratio ? */
+	if (dsi_ratio < BXT_DSI_PLL_RATIO_MIN ||
+			dsi_ratio > BXT_DSI_PLL_RATIO_MAX) {
+		DRM_ERROR("Invalid DSI pll ratio(%u) programmed\n", dsi_ratio);
+		return 0;
+	}
+
+	dsi_clk = (dsi_ratio * BXT_REF_CLOCK_KHZ) / 2;
+
+	/* pixel_format and pipe_bpp should agree */
+	assert_bpp_mismatch(intel_dsi->pixel_format, pipe_bpp);
+
+	pclk = DIV_ROUND_CLOSEST(dsi_clk * intel_dsi->lane_count, pipe_bpp);
+
+	DRM_DEBUG_DRIVER("Calculated pclk=%u\n", pclk);
+	return pclk;
+}
+
 void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
 {
 	u32 temp;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 10/14
#48 lore raw

Re: [BXT MIPI PATCH v3 10/14] drm/i915/bxt: get DSI pixelclock

Quoted 6 lines · Uma Shankar

From: Shashank Sharma <[email protected]>

BXT's DSI PLL is different from that of VLV. So this patch adds a new function to get the current DSI pixel clock based on the PLL divider ratio and lane count.

Quoted 6 lines

This function is required for intel_dsi_get_config() function.

v2: Fixed Jani's review comments.

Quoted 93 lines
---
 drivers/gpu/drm/i915/intel_dsi.c     |    8 ++++++--
 drivers/gpu/drm/i915/intel_dsi.h     |    1 +
 drivers/gpu/drm/i915/intel_dsi_pll.c |   35 ++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +6 -2
index 001569b..6a0071f 100644
@@ -687,7 +687,7 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
 static void intel_dsi_get_config(struct intel_encoder *encoder,
 				 struct intel_crtc_state *pipe_config)
 {
-	u32 pclk;
+	u32 pclk = 0;
 	DRM_DEBUG_KMS("\n");
 
 	/*
@@ -696,7 +696,11 @@ static void intel_dsi_get_config(struct intel_encoder *encoder,
 	 */
 	pipe_config->dpll_hw_state.dpll_md = 0;
 
-	pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
+	if (IS_BROXTON(encoder->base.dev))
+		pclk = bxt_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
+	else if (IS_VALLEYVIEW(encoder->base.dev))
+		pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
+
 	if (!pclk)
 		return;
 
drivers/gpu/drm/i915/intel_dsi.h +1 -0
index 078ea1b..24fc550 100644
@@ -124,6 +124,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
 extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
 extern void intel_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
+extern u32 bxt_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 extern void intel_dsi_reset_clocks(struct intel_encoder *encoder,
 							enum port port);
 
drivers/gpu/drm/i915/intel_dsi_pll.c +35 -0
index 918bc5f..9860bb5 100644
@@ -389,6 +389,41 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
 	return pclk;
 }
 
+u32 bxt_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
+{
+	u32 pclk;
+	u32 dsi_clk;
+	u32 dsi_ratio;
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+
+	/* Divide by zero */
+	if (!pipe_bpp) {
+		DRM_ERROR("Invalid BPP(0)\n");
+		return 0;
+	}
+
+	dsi_ratio = I915_READ(BXT_DSI_PLL_CTL) &
+				BXT_DSI_PLL_RATIO_MASK;
+
+	/* Invalid DSI ratio ? */
+	if (dsi_ratio < BXT_DSI_PLL_RATIO_MIN ||
+			dsi_ratio > BXT_DSI_PLL_RATIO_MAX) {
+		DRM_ERROR("Invalid DSI pll ratio(%u) programmed\n", dsi_ratio);
+		return 0;
+	}
+
+	dsi_clk = (dsi_ratio * BXT_REF_CLOCK_KHZ) / 2;
+
+	/* pixel_format and pipe_bpp should agree */
+	assert_bpp_mismatch(intel_dsi->pixel_format, pipe_bpp);
+
+	pclk = DIV_ROUND_CLOSEST(dsi_clk * intel_dsi->lane_count, pipe_bpp);
+
+	DRM_DEBUG_DRIVER("Calculated pclk=%u\n", pclk);
+	return pclk;
+}
+
 void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
 {
 	u32 temp;
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#49 lore raw

PATCH v3 11/14 drm/i915/bxt: Modify BXT BLC according to VBT changes

In reply to Uma Shankar

From: Sunil Kamath <[email protected]>

Latest VBT mentions which set of registers will be used for BLC, as controller number field. Making use of this field in BXT
BLC implementation. Also, the registers are used in case control pin indicates display DDI. Adding a check for this.
According to Bspec, BLC_PWM_*_2 uses the display utility pin for output. To use backlight 2, enable the utility pin with mode = PWM
v2: Jani's review comments
addressed
- Add a prefix _ to BXT BLC registers definitions.
- Add "bxt only" comment for u8 controller
- Remove control_pin check for DDI controller
- Check for valid controller values
- Set pipe bits in UTIL_PIN_CTL
- Enable/Disable UTIL_PIN_CTL in enable/disable_backlight()
- If BLC 2 is used, read active_low_pwm from UTIL_PIN polarity
Satheesh's review comment addressed
- If UTIL PIN is already enabled, BIOS would have programmed it. No need to disable and enable again.
v3: Jani's review comments
- add UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK
- Disable UTIL_PIN if controller 1 is used
- Mask out UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK before enabling UTIL_PIN
- check valid controller value in intel_bios.c
- add backlight.util_pin_active_low
- disable util pin before enabling
v4: Change for BXT-PO branch:
Stubbed unwanted definition which was existing before because of DC6 patch.
UTIL_PIN_MODE_PWM (0x1b << 24)

v2: Fixed Jani's review comment.

v3: Split the backight PWM frequency programming into separate patch,
in cases BIOS doesn't initializes it.

---
 drivers/gpu/drm/i915/i915_reg.h    |   28 ++++++++----
 drivers/gpu/drm/i915/intel_drv.h   |    2 +
 drivers/gpu/drm/i915/intel_panel.c |   84 ++++++++++++++++++++++++++++--------
 3 files changed, 89 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +20 -8
index e43b053..8407b5c 100644
@@ -3512,17 +3512,29 @@ enum skl_disp_power_wells {
 #define UTIL_PIN_CTL		0x48400
 #define   UTIL_PIN_ENABLE	(1 << 31)
 
+#define   UTIL_PIN_PIPE(x)     ((x) << 29)
+#define   UTIL_PIN_PIPE_MASK   (3 << 29)
+#define   UTIL_PIN_MODE_PWM    (1 << 24)
+#define   UTIL_PIN_MODE_MASK   (0xf << 24)
+#define   UTIL_PIN_POLARITY    (1 << 22)
+
 /* BXT backlight register definition. */
-#define BXT_BLC_PWM_CTL1			0xC8250
+#define _BXT_BLC_PWM_CTL1			0xC8250
 #define   BXT_BLC_PWM_ENABLE			(1 << 31)
 #define   BXT_BLC_PWM_POLARITY			(1 << 29)
-#define BXT_BLC_PWM_FREQ1			0xC8254
-#define BXT_BLC_PWM_DUTY1			0xC8258
-
-#define BXT_BLC_PWM_CTL2			0xC8350
-#define BXT_BLC_PWM_FREQ2			0xC8354
-#define BXT_BLC_PWM_DUTY2			0xC8358
-
+#define _BXT_BLC_PWM_FREQ1			0xC8254
+#define _BXT_BLC_PWM_DUTY1			0xC8258
+
+#define _BXT_BLC_PWM_CTL2			0xC8350
+#define _BXT_BLC_PWM_FREQ2			0xC8354
+#define _BXT_BLC_PWM_DUTY2			0xC8358
+
+#define BXT_BLC_PWM_CTL(controller)    _PIPE(controller, \
+					_BXT_BLC_PWM_CTL1, _BXT_BLC_PWM_CTL2)
+#define BXT_BLC_PWM_FREQ(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_FREQ1, _BXT_BLC_PWM_FREQ2)
+#define BXT_BLC_PWM_DUTY(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_DUTY1, _BXT_BLC_PWM_DUTY2)
 
 #define PCH_GTC_CTL		0xe7000
 #define   PCH_GTC_ENABLE	(1 << 31)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 1059283..d8ca075 100644
@@ -182,7 +182,9 @@ struct intel_panel {
 		bool enabled;
 		bool combination_mode;	/* gen 2/4 only */
 		bool active_low_pwm;
+		bool util_pin_active_low;	/* bxt+ */
 		struct backlight_device *device;
+		u8 controller;		/* bxt+ only */
 	} backlight;
 
 	void (*backlight_power)(struct intel_connector *, bool enable);
drivers/gpu/drm/i915/intel_panel.c +67 -17

133 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 11/14
#50 lore raw

Re: [BXT MIPI PATCH v3 11/14] drm/i915/bxt: Modify BXT BLC according to VBT changes

Quoted 165 lines · Uma Shankar

From: Sunil Kamath <[email protected]>

Latest VBT mentions which set of registers will be used for BLC, as controller number field. Making use of this field in BXT
BLC implementation. Also, the registers are used in case control pin indicates display DDI. Adding a check for this.
According to Bspec, BLC_PWM_*_2 uses the display utility pin for output. To use backlight 2, enable the utility pin with mode = PWM
v2: Jani's review comments
addressed
- Add a prefix _ to BXT BLC registers definitions.
- Add "bxt only" comment for u8 controller
- Remove control_pin check for DDI controller
- Check for valid controller values
- Set pipe bits in UTIL_PIN_CTL
- Enable/Disable UTIL_PIN_CTL in enable/disable_backlight()
- If BLC 2 is used, read active_low_pwm from UTIL_PIN polarity
Satheesh's review comment addressed
- If UTIL PIN is already enabled, BIOS would have programmed it. No need to disable and enable again.
v3: Jani's review comments
- add UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK
- Disable UTIL_PIN if controller 1 is used
- Mask out UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK before enabling UTIL_PIN
- check valid controller value in intel_bios.c
- add backlight.util_pin_active_low
- disable util pin before enabling
v4: Change for BXT-PO branch:
Stubbed unwanted definition which was existing before because of DC6 patch.
UTIL_PIN_MODE_PWM (0x1b << 24)

v2: Fixed Jani's review comment.

v3: Split the backight PWM frequency programming into separate patch,
in cases BIOS doesn't initializes it.

---
 drivers/gpu/drm/i915/i915_reg.h    |   28 ++++++++----
 drivers/gpu/drm/i915/intel_drv.h   |    2 +
 drivers/gpu/drm/i915/intel_panel.c |   84 ++++++++++++++++++++++++++++--------
 3 files changed, 89 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +20 -8
index e43b053..8407b5c 100644
@@ -3512,17 +3512,29 @@ enum skl_disp_power_wells {
 #define UTIL_PIN_CTL		0x48400
 #define   UTIL_PIN_ENABLE	(1 << 31)
 
+#define   UTIL_PIN_PIPE(x)     ((x) << 29)
+#define   UTIL_PIN_PIPE_MASK   (3 << 29)
+#define   UTIL_PIN_MODE_PWM    (1 << 24)
+#define   UTIL_PIN_MODE_MASK   (0xf << 24)
+#define   UTIL_PIN_POLARITY    (1 << 22)
+
 /* BXT backlight register definition. */
-#define BXT_BLC_PWM_CTL1			0xC8250
+#define _BXT_BLC_PWM_CTL1			0xC8250
 #define   BXT_BLC_PWM_ENABLE			(1 << 31)
 #define   BXT_BLC_PWM_POLARITY			(1 << 29)
-#define BXT_BLC_PWM_FREQ1			0xC8254
-#define BXT_BLC_PWM_DUTY1			0xC8258
-
-#define BXT_BLC_PWM_CTL2			0xC8350
-#define BXT_BLC_PWM_FREQ2			0xC8354
-#define BXT_BLC_PWM_DUTY2			0xC8358
-
+#define _BXT_BLC_PWM_FREQ1			0xC8254
+#define _BXT_BLC_PWM_DUTY1			0xC8258
+
+#define _BXT_BLC_PWM_CTL2			0xC8350
+#define _BXT_BLC_PWM_FREQ2			0xC8354
+#define _BXT_BLC_PWM_DUTY2			0xC8358
+
+#define BXT_BLC_PWM_CTL(controller)    _PIPE(controller, \
+					_BXT_BLC_PWM_CTL1, _BXT_BLC_PWM_CTL2)
+#define BXT_BLC_PWM_FREQ(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_FREQ1, _BXT_BLC_PWM_FREQ2)
+#define BXT_BLC_PWM_DUTY(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_DUTY1, _BXT_BLC_PWM_DUTY2)
 
 #define PCH_GTC_CTL		0xe7000
 #define   PCH_GTC_ENABLE	(1 << 31)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 1059283..d8ca075 100644
@@ -182,7 +182,9 @@ struct intel_panel {
 		bool enabled;
 		bool combination_mode;	/* gen 2/4 only */
 		bool active_low_pwm;
+		bool util_pin_active_low;	/* bxt+ */
 		struct backlight_device *device;
+		u8 controller;		/* bxt+ only */
 	} backlight;
 
 	void (*backlight_power)(struct intel_connector *, bool enable);
drivers/gpu/drm/i915/intel_panel.c +21 -6
index 55aad23..9fcf86c 100644
@@ -539,9 +539,10 @@ static u32 vlv_get_backlight(struct intel_connector *connector)
 static u32 bxt_get_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
+	struct intel_panel *panel = &connector->panel;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	return I915_READ(BXT_BLC_PWM_DUTY1);
+	return I915_READ(BXT_BLC_PWM_DUTY(panel->backlight.controller));
 }
 
 static u32 intel_panel_get_backlight(struct intel_connector *connector)
@@ -628,8 +629,9 @@ static void bxt_set_backlight(struct intel_connector *connector, u32 level)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_panel *panel = &connector->panel;
 
-	I915_WRITE(BXT_BLC_PWM_DUTY1, level);
+	I915_WRITE(BXT_BLC_PWM_DUTY(panel->backlight.controller), level);
 }
 
 static void
@@ -761,12 +763,20 @@ static void bxt_disable_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 tmp;
+	struct intel_panel *panel = &connector->panel;
+	u32 tmp, val;
 
 	intel_panel_actually_set_backlight(connector, 0);
 
-	tmp = I915_READ(BXT_BLC_PWM_CTL1);
-	I915_WRITE(BXT_BLC_PWM_CTL1, tmp & ~BXT_BLC_PWM_ENABLE);
+	tmp = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+			tmp & ~BXT_BLC_PWM_ENABLE);
+
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		val &= ~UTIL_PIN_ENABLE;
+		I915_WRITE(UTIL_PIN_CTL, val);
+	}
 }
 
 void intel_panel_disable_backlight(struct intel_connector *connector)
@@ -988,16 +998,39 @@ static void bxt_enable_backlight(struct intel_connector *connector)
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_panel *panel = &connector->panel;
-	u32 pwm_ctl;
+	enum pipe pipe = intel_get_pipe_from_connector(connector);
+	u32 pwm_ctl, val;
+
+	/* To use 2nd set of backlight registers, utility pin has to be
+	 * enabled with PWM mode.
+	 * The field should only be changed when the utility pin is disabled

drivers/gpu/drm/i915/intel_panel.c static void bxt_enable_backlight(struct intel_connector *connector) · line 1016

Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +10 -0
+	 */
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		if (val & UTIL_PIN_ENABLE) {
+			DRM_DEBUG_KMS("util pin already enabled\n");
+			val &= ~UTIL_PIN_ENABLE;
+			I915_WRITE(UTIL_PIN_CTL, val);
+		}
+		/* mask out UTIL_PIN_PIPE and UTIL_PIN_MODE */
+		val &= ~(UTIL_PIN_PIPE_MASK | UTIL_PIN_MODE_MASK);

Please start out with 0 val instead of modifying existing state. This is the style across backlight enabling, apart from setup which gathers the needed state.

With that fixed,

Quoted 74 lines
drivers/gpu/drm/i915/intel_panel.c +36 -11
+		I915_WRITE(UTIL_PIN_CTL, val);
+		if (panel->backlight.util_pin_active_low)
+			val |= UTIL_PIN_POLARITY;
+		I915_WRITE(UTIL_PIN_CTL, val | UTIL_PIN_PIPE(pipe) |
+				UTIL_PIN_MODE_PWM | UTIL_PIN_ENABLE);
+	}
 
-	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL1);
+	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
 	if (pwm_ctl & BXT_BLC_PWM_ENABLE) {
 		DRM_DEBUG_KMS("backlight already enabled\n");
 		pwm_ctl &= ~BXT_BLC_PWM_ENABLE;
-		I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl);
+		I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+				pwm_ctl);
 	}
 
-	I915_WRITE(BXT_BLC_PWM_FREQ1, panel->backlight.max);
+	I915_WRITE(BXT_BLC_PWM_FREQ(panel->backlight.controller),
+			panel->backlight.max);
 
 	intel_panel_actually_set_backlight(connector, panel->backlight.level);
 
@@ -1005,9 +1038,10 @@ static void bxt_enable_backlight(struct intel_connector *connector)
 	if (panel->backlight.active_low_pwm)
 		pwm_ctl |= BXT_BLC_PWM_POLARITY;
 
-	I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl);
-	POSTING_READ(BXT_BLC_PWM_CTL1);
-	I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl | BXT_BLC_PWM_ENABLE);
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl);
+	POSTING_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+			pwm_ctl | BXT_BLC_PWM_ENABLE);
 }
 
 void intel_panel_enable_backlight(struct intel_connector *connector)
@@ -1370,12 +1404,28 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
 	struct intel_panel *panel = &connector->panel;
 	u32 pwm_ctl, val;
 
-	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL1);
-	panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
+	/*
+	 * For BXT hard coding the Backlight controller to 0.
+	 * TODO : Read the controller value from VBT and generalize
+	 */
+	panel->backlight.controller = 0;
 
-	panel->backlight.max = I915_READ(BXT_BLC_PWM_FREQ1);
-	if (!panel->backlight.max)
-		return -ENODEV;
+	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+
+	/* Keeping the check if controller 1 is to be programmed.
+	 * This will come into affect once the VBT parsing
+	 * is fixed for controller selection, and controller 1 is used
+	 * for a prticular display configuration.
+	 */
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		panel->backlight.util_pin_active_low =
+					val & UTIL_PIN_POLARITY;
+	}
+
+	panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
+	panel->backlight.max = I915_READ(
+			BXT_BLC_PWM_FREQ(panel->backlight.controller));
 
 	val = bxt_get_backlight(connector);
 	panel->backlight.level = intel_panel_compute_brightness(connector, val);
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#51 lore raw

Re: [BXT MIPI PATCH v3 11/14] drm/i915/bxt: Modify BXT BLC according to VBT changes

Quoted 95 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 7:21 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Kamath, Sunil; Kannan, Vandana; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 11/14] drm/i915/bxt: Modify BXT BLC according to VBT changes

Quoted 16 lines · Uma Shankar

From: Sunil Kamath <[email protected]>

Latest VBT mentions which set of registers will be used for BLC, as controller number field. Making use of this field in BXT BLC implementation. Also, the registers are used in case control pin indicates display DDI. Adding a check for this.
According to Bspec, BLC_PWM_*_2 uses the display utility pin for output. To use backlight 2, enable the utility pin with mode = PWM
v2: Jani's review comments
addressed
- Add a prefix _ to BXT BLC registers definitions.
- Add "bxt only" comment for u8 controller
- Remove control_pin check for DDI controller
- Check for valid controller values
- Set pipe bits in UTIL_PIN_CTL
- Enable/Disable UTIL_PIN_CTL in enable/disable_backlight()

Quoted 8 lines

- If BLC 2 is used, read active_low_pwm from UTIL_PIN polarity
Satheesh's review comment addressed
- If UTIL PIN is already enabled, BIOS would have programmed it. No need to disable and enable again.
v3: Jani's review comments
- add UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK
- Disable UTIL_PIN if controller 1 is used
- Mask out UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK before

enabling

Quoted 14 lines

UTIL_PIN
- check valid controller value in intel_bios.c
- add backlight.util_pin_active_low
- disable util pin before enabling
v4: Change for BXT-PO branch:
Stubbed unwanted definition which was existing before because of DC6 patch.
UTIL_PIN_MODE_PWM (0x1b << 24)

v2: Fixed Jani's review comment.

v3: Split the backight PWM frequency programming into separate patch,
in cases BIOS doesn't initializes it.

Quoted 7 lines
---
 drivers/gpu/drm/i915/i915_reg.h    |   28 ++++++++----
 drivers/gpu/drm/i915/intel_drv.h   |    2 +
 drivers/gpu/drm/i915/intel_panel.c |   84 ++++++++++++++++++++++++++++--

------

drivers/gpu/drm/i915/i915_reg.h static void bxt_enable_backlight(struct

Quoted 12 lines
 3 files changed, 89 insertions(+), 25 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h index e43b053..8407b5c 100644

drivers/gpu/drm/i915/i915_reg.h +0 -0
@@ -3512,17 +3512,29 @@ enum skl_disp_power_wells {
 #define UTIL_PIN_CTL		0x48400
 #define   UTIL_PIN_ENABLE	(1 << 31)
 
 void intel_panel_disable_backlight(struct intel_connector *connector)
@@ -988,16 +998,39 @@ static void bxt_enable_backlight(struct

intel_connector *connector)

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +6 -1
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_panel *panel = &connector->panel;
-	u32 pwm_ctl;
+	enum pipe pipe = intel_get_pipe_from_connector(connector);
+	u32 pwm_ctl, val;
+
+	/* To use 2nd set of backlight registers, utility pin has to be
+	 * enabled with PWM mode.
+	 * The field should only be changed when the utility pin is disabled

drivers/gpu/drm/i915/i915_reg.h static void bxt_enable_backlight(struct · line 1016

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+	 */
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		if (val & UTIL_PIN_ENABLE) {
+			DRM_DEBUG_KMS("util pin already enabled\n");
+			val &= ~UTIL_PIN_ENABLE;
+			I915_WRITE(UTIL_PIN_CTL, val);
+		}
+		/* mask out UTIL_PIN_PIPE and UTIL_PIN_MODE */
+		val &= ~(UTIL_PIN_PIPE_MASK | UTIL_PIN_MODE_MASK);

Please start out with 0 val instead of modifying existing state. This is the style across backlight enabling, apart from setup which gathers the needed state.

Quoted 4 lines

With that fixed,

Thanks for the comment and spotting it out. Will update this in subsequent patchset.

Regards,
Uma Shankar

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#52 lore raw

PATCH v4 11/14 drm/i915/bxt: Modify BXT BLC according to VBT changes

In reply to Jani Nikula

From: Sunil Kamath <[email protected]>

Latest VBT mentions which set of registers will be used for BLC, as controller number field. Making use of this field in BXT
BLC implementation. Also, the registers are used in case control pin indicates display DDI. Adding a check for this.
According to Bspec, BLC_PWM_*_2 uses the display utility pin for output. To use backlight 2, enable the utility pin with mode = PWM
v2: Jani's review comments
addressed
- Add a prefix _ to BXT BLC registers definitions.
- Add "bxt only" comment for u8 controller
- Remove control_pin check for DDI controller
- Check for valid controller values
- Set pipe bits in UTIL_PIN_CTL
- Enable/Disable UTIL_PIN_CTL in enable/disable_backlight()
- If BLC 2 is used, read active_low_pwm from UTIL_PIN polarity
Satheesh's review comment addressed
- If UTIL PIN is already enabled, BIOS would have programmed it. No need to disable and enable again.
v3: Jani's review comments
- add UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK
- Disable UTIL_PIN if controller 1 is used
- Mask out UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK before enabling UTIL_PIN
- check valid controller value in intel_bios.c
- add backlight.util_pin_active_low
- disable util pin before enabling
v4: Change for BXT-PO branch:
Stubbed unwanted definition which was existing before because of DC6 patch.
UTIL_PIN_MODE_PWM (0x1b << 24)

v2: Fixed Jani's review comment.

v3: Split the backight PWM frequency programming into separate patch,
in cases BIOS doesn't initializes it.

v4: Starting afresh and not modifying existing state for backlight, as
per Jani's recommendation.

---
 drivers/gpu/drm/i915/i915_reg.h    |   28 +++++++++----
 drivers/gpu/drm/i915/intel_drv.h   |    2 +
 drivers/gpu/drm/i915/intel_panel.c |   76 ++++++++++++++++++++++++++++--------
 3 files changed, 81 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +20 -8
index 88a16e2..519f764 100644
@@ -3512,17 +3512,29 @@ enum skl_disp_power_wells {
 #define UTIL_PIN_CTL		0x48400
 #define   UTIL_PIN_ENABLE	(1 << 31)
 
+#define   UTIL_PIN_PIPE(x)     ((x) << 29)
+#define   UTIL_PIN_PIPE_MASK   (3 << 29)
+#define   UTIL_PIN_MODE_PWM    (1 << 24)
+#define   UTIL_PIN_MODE_MASK   (0xf << 24)
+#define   UTIL_PIN_POLARITY    (1 << 22)
+
 /* BXT backlight register definition. */
-#define BXT_BLC_PWM_CTL1			0xC8250
+#define _BXT_BLC_PWM_CTL1			0xC8250
 #define   BXT_BLC_PWM_ENABLE			(1 << 31)
 #define   BXT_BLC_PWM_POLARITY			(1 << 29)
-#define BXT_BLC_PWM_FREQ1			0xC8254
-#define BXT_BLC_PWM_DUTY1			0xC8258
-
-#define BXT_BLC_PWM_CTL2			0xC8350
-#define BXT_BLC_PWM_FREQ2			0xC8354
-#define BXT_BLC_PWM_DUTY2			0xC8358
-
+#define _BXT_BLC_PWM_FREQ1			0xC8254
+#define _BXT_BLC_PWM_DUTY1			0xC8258
+
+#define _BXT_BLC_PWM_CTL2			0xC8350
+#define _BXT_BLC_PWM_FREQ2			0xC8354
+#define _BXT_BLC_PWM_DUTY2			0xC8358
+
+#define BXT_BLC_PWM_CTL(controller)    _PIPE(controller, \
+					_BXT_BLC_PWM_CTL1, _BXT_BLC_PWM_CTL2)
+#define BXT_BLC_PWM_FREQ(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_FREQ1, _BXT_BLC_PWM_FREQ2)
+#define BXT_BLC_PWM_DUTY(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_DUTY1, _BXT_BLC_PWM_DUTY2)
 
 #define PCH_GTC_CTL		0xe7000
 #define   PCH_GTC_ENABLE	(1 << 31)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 1059283..d8ca075 100644
@@ -182,7 +182,9 @@ struct intel_panel {
 		bool enabled;
 		bool combination_mode;	/* gen 2/4 only */
 		bool active_low_pwm;
+		bool util_pin_active_low;	/* bxt+ */
 		struct backlight_device *device;
+		u8 controller;		/* bxt+ only */
 	} backlight;
 
 	void (*backlight_power)(struct intel_connector *, bool enable);
drivers/gpu/drm/i915/intel_panel.c +59 -17

125 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v4 11/14
#53 lore raw

Re: [BXT MIPI PATCH v4 11/14] drm/i915/bxt: Modify BXT BLC according to VBT changes

Quoted 160 lines · Uma Shankar

From: Sunil Kamath <[email protected]>

Latest VBT mentions which set of registers will be used for BLC, as controller number field. Making use of this field in BXT
BLC implementation. Also, the registers are used in case control pin indicates display DDI. Adding a check for this.
According to Bspec, BLC_PWM_*_2 uses the display utility pin for output. To use backlight 2, enable the utility pin with mode = PWM
v2: Jani's review comments
addressed
- Add a prefix _ to BXT BLC registers definitions.
- Add "bxt only" comment for u8 controller
- Remove control_pin check for DDI controller
- Check for valid controller values
- Set pipe bits in UTIL_PIN_CTL
- Enable/Disable UTIL_PIN_CTL in enable/disable_backlight()
- If BLC 2 is used, read active_low_pwm from UTIL_PIN polarity
Satheesh's review comment addressed
- If UTIL PIN is already enabled, BIOS would have programmed it. No need to disable and enable again.
v3: Jani's review comments
- add UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK
- Disable UTIL_PIN if controller 1 is used
- Mask out UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK before enabling UTIL_PIN
- check valid controller value in intel_bios.c
- add backlight.util_pin_active_low
- disable util pin before enabling
v4: Change for BXT-PO branch:
Stubbed unwanted definition which was existing before because of DC6 patch.
UTIL_PIN_MODE_PWM (0x1b << 24)

v2: Fixed Jani's review comment.

v3: Split the backight PWM frequency programming into separate patch,
in cases BIOS doesn't initializes it.

v4: Starting afresh and not modifying existing state for backlight, as
per Jani's recommendation.

---
 drivers/gpu/drm/i915/i915_reg.h    |   28 +++++++++----
 drivers/gpu/drm/i915/intel_drv.h   |    2 +
 drivers/gpu/drm/i915/intel_panel.c |   76 ++++++++++++++++++++++++++++--------
 3 files changed, 81 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +20 -8
index 88a16e2..519f764 100644
@@ -3512,17 +3512,29 @@ enum skl_disp_power_wells {
 #define UTIL_PIN_CTL		0x48400
 #define   UTIL_PIN_ENABLE	(1 << 31)
 
+#define   UTIL_PIN_PIPE(x)     ((x) << 29)
+#define   UTIL_PIN_PIPE_MASK   (3 << 29)
+#define   UTIL_PIN_MODE_PWM    (1 << 24)
+#define   UTIL_PIN_MODE_MASK   (0xf << 24)
+#define   UTIL_PIN_POLARITY    (1 << 22)
+
 /* BXT backlight register definition. */
-#define BXT_BLC_PWM_CTL1			0xC8250
+#define _BXT_BLC_PWM_CTL1			0xC8250
 #define   BXT_BLC_PWM_ENABLE			(1 << 31)
 #define   BXT_BLC_PWM_POLARITY			(1 << 29)
-#define BXT_BLC_PWM_FREQ1			0xC8254
-#define BXT_BLC_PWM_DUTY1			0xC8258
-
-#define BXT_BLC_PWM_CTL2			0xC8350
-#define BXT_BLC_PWM_FREQ2			0xC8354
-#define BXT_BLC_PWM_DUTY2			0xC8358
-
+#define _BXT_BLC_PWM_FREQ1			0xC8254
+#define _BXT_BLC_PWM_DUTY1			0xC8258
+
+#define _BXT_BLC_PWM_CTL2			0xC8350
+#define _BXT_BLC_PWM_FREQ2			0xC8354
+#define _BXT_BLC_PWM_DUTY2			0xC8358
+
+#define BXT_BLC_PWM_CTL(controller)    _PIPE(controller, \
+					_BXT_BLC_PWM_CTL1, _BXT_BLC_PWM_CTL2)
+#define BXT_BLC_PWM_FREQ(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_FREQ1, _BXT_BLC_PWM_FREQ2)
+#define BXT_BLC_PWM_DUTY(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_DUTY1, _BXT_BLC_PWM_DUTY2)
 
 #define PCH_GTC_CTL		0xe7000
 #define   PCH_GTC_ENABLE	(1 << 31)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 1059283..d8ca075 100644
@@ -182,7 +182,9 @@ struct intel_panel {
 		bool enabled;
 		bool combination_mode;	/* gen 2/4 only */
 		bool active_low_pwm;
+		bool util_pin_active_low;	/* bxt+ */
 		struct backlight_device *device;
+		u8 controller;		/* bxt+ only */
 	} backlight;
 
 	void (*backlight_power)(struct intel_connector *, bool enable);
drivers/gpu/drm/i915/intel_panel.c +15 -5
index 55aad23..fafbccc 100644
@@ -539,9 +539,10 @@ static u32 vlv_get_backlight(struct intel_connector *connector)
 static u32 bxt_get_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
+	struct intel_panel *panel = &connector->panel;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	return I915_READ(BXT_BLC_PWM_DUTY1);
+	return I915_READ(BXT_BLC_PWM_DUTY(panel->backlight.controller));
 }
 
 static u32 intel_panel_get_backlight(struct intel_connector *connector)
@@ -628,8 +629,9 @@ static void bxt_set_backlight(struct intel_connector *connector, u32 level)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_panel *panel = &connector->panel;
 
-	I915_WRITE(BXT_BLC_PWM_DUTY1, level);
+	I915_WRITE(BXT_BLC_PWM_DUTY(panel->backlight.controller), level);
 }
 
 static void
@@ -761,12 +763,20 @@ static void bxt_disable_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 tmp;
+	struct intel_panel *panel = &connector->panel;
+	u32 tmp, val;
 
 	intel_panel_actually_set_backlight(connector, 0);
 
-	tmp = I915_READ(BXT_BLC_PWM_CTL1);
-	I915_WRITE(BXT_BLC_PWM_CTL1, tmp & ~BXT_BLC_PWM_ENABLE);
+	tmp = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+			tmp & ~BXT_BLC_PWM_ENABLE);
+
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		val &= ~UTIL_PIN_ENABLE;
+		I915_WRITE(UTIL_PIN_CTL, val);
+	}
 }
 
 void intel_panel_disable_backlight(struct intel_connector *connector)
@@ -988,16 +998,31 @@ static void bxt_enable_backlight(struct intel_connector *connector)
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_panel.c static void bxt_enable_backlight(struct intel_connector *connector) · line 1008

Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +8 -1
 	struct intel_panel *panel = &connector->panel;
-	u32 pwm_ctl;
+	enum pipe pipe = intel_get_pipe_from_connector(connector);
+	u32 pwm_ctl, val;
+
+	/* To use 2nd set of backlight registers, utility pin has to be
+	 * enabled with PWM mode.
+	 * The field should only be changed when the utility pin is disabled
+	 */
+	if (panel->backlight.controller == 1) {

Please put back this part from the previous patch:

+ val = I915_READ(UTIL_PIN_CTL);
+ if (val & UTIL_PIN_ENABLE) {
+ DRM_DEBUG_KMS("util pin already enabled\n");
+ val &= ~UTIL_PIN_ENABLE;
+ I915_WRITE(UTIL_PIN_CTL, val);
+ }

And then continue like below.

With that fixes, this is

Quoted 74 lines
drivers/gpu/drm/i915/intel_panel.c +36 -11
+		val = 0;
+		if (panel->backlight.util_pin_active_low)
+			val |= UTIL_PIN_POLARITY;
+		I915_WRITE(UTIL_PIN_CTL, val | UTIL_PIN_PIPE(pipe) |
+				UTIL_PIN_MODE_PWM | UTIL_PIN_ENABLE);
+	}
 
-	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL1);
+	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
 	if (pwm_ctl & BXT_BLC_PWM_ENABLE) {
 		DRM_DEBUG_KMS("backlight already enabled\n");
 		pwm_ctl &= ~BXT_BLC_PWM_ENABLE;
-		I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl);
+		I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+				pwm_ctl);
 	}
 
-	I915_WRITE(BXT_BLC_PWM_FREQ1, panel->backlight.max);
+	I915_WRITE(BXT_BLC_PWM_FREQ(panel->backlight.controller),
+			panel->backlight.max);
 
 	intel_panel_actually_set_backlight(connector, panel->backlight.level);
 
@@ -1005,9 +1030,10 @@ static void bxt_enable_backlight(struct intel_connector *connector)
 	if (panel->backlight.active_low_pwm)
 		pwm_ctl |= BXT_BLC_PWM_POLARITY;
 
-	I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl);
-	POSTING_READ(BXT_BLC_PWM_CTL1);
-	I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl | BXT_BLC_PWM_ENABLE);
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl);
+	POSTING_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+			pwm_ctl | BXT_BLC_PWM_ENABLE);
 }
 
 void intel_panel_enable_backlight(struct intel_connector *connector)
@@ -1370,12 +1396,28 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
 	struct intel_panel *panel = &connector->panel;
 	u32 pwm_ctl, val;
 
-	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL1);
-	panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
+	/*
+	 * For BXT hard coding the Backlight controller to 0.
+	 * TODO : Read the controller value from VBT and generalize
+	 */
+	panel->backlight.controller = 0;
 
-	panel->backlight.max = I915_READ(BXT_BLC_PWM_FREQ1);
-	if (!panel->backlight.max)
-		return -ENODEV;
+	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+
+	/* Keeping the check if controller 1 is to be programmed.
+	 * This will come into affect once the VBT parsing
+	 * is fixed for controller selection, and controller 1 is used
+	 * for a prticular display configuration.
+	 */
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		panel->backlight.util_pin_active_low =
+					val & UTIL_PIN_POLARITY;
+	}
+
+	panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
+	panel->backlight.max = I915_READ(
+			BXT_BLC_PWM_FREQ(panel->backlight.controller));
 
 	val = bxt_get_backlight(connector);
 	panel->backlight.level = intel_panel_compute_brightness(connector, val);
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#54 lore raw

PATCH v5 11/14 drm/i915/bxt: Modify BXT BLC according to VBT changes

From: Sunil Kamath <[email protected]>

Latest VBT mentions which set of registers will be used for BLC, as controller number field. Making use of this field in BXT
BLC implementation. Also, the registers are used in case control pin indicates display DDI. Adding a check for this.
According to Bspec, BLC_PWM_*_2 uses the display utility pin for output. To use backlight 2, enable the utility pin with mode = PWM
v2: Jani's review comments
addressed
- Add a prefix _ to BXT BLC registers definitions.
- Add "bxt only" comment for u8 controller
- Remove control_pin check for DDI controller
- Check for valid controller values
- Set pipe bits in UTIL_PIN_CTL
- Enable/Disable UTIL_PIN_CTL in enable/disable_backlight()
- If BLC 2 is used, read active_low_pwm from UTIL_PIN polarity
Satheesh's review comment addressed
- If UTIL PIN is already enabled, BIOS would have programmed it. No need to disable and enable again.
v3: Jani's review comments
- add UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK
- Disable UTIL_PIN if controller 1 is used
- Mask out UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK before enabling UTIL_PIN
- check valid controller value in intel_bios.c
- add backlight.util_pin_active_low
- disable util pin before enabling
v4: Change for BXT-PO branch:
Stubbed unwanted definition which was existing before because of DC6 patch.
UTIL_PIN_MODE_PWM (0x1b << 24)

v2: Fixed Jani's review comment.

v3: Split the backight PWM frequency programming into separate patch,
in cases BIOS doesn't initializes it.

v4: Starting afresh and not modifying existing state for backlight, as
per Jani's recommendation.

v5: Fixed Jani's review comment wrt util pin enable

---
 drivers/gpu/drm/i915/i915_reg.h    |   28 ++++++++----
 drivers/gpu/drm/i915/intel_drv.h   |    2 +
 drivers/gpu/drm/i915/intel_panel.c |   83 ++++++++++++++++++++++++++++--------
 3 files changed, 88 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +20 -8
index 88a16e2..519f764 100644
@@ -3512,17 +3512,29 @@ enum skl_disp_power_wells {
 #define UTIL_PIN_CTL		0x48400
 #define   UTIL_PIN_ENABLE	(1 << 31)
 
+#define   UTIL_PIN_PIPE(x)     ((x) << 29)
+#define   UTIL_PIN_PIPE_MASK   (3 << 29)
+#define   UTIL_PIN_MODE_PWM    (1 << 24)
+#define   UTIL_PIN_MODE_MASK   (0xf << 24)
+#define   UTIL_PIN_POLARITY    (1 << 22)
+
 /* BXT backlight register definition. */
-#define BXT_BLC_PWM_CTL1			0xC8250
+#define _BXT_BLC_PWM_CTL1			0xC8250
 #define   BXT_BLC_PWM_ENABLE			(1 << 31)
 #define   BXT_BLC_PWM_POLARITY			(1 << 29)
-#define BXT_BLC_PWM_FREQ1			0xC8254
-#define BXT_BLC_PWM_DUTY1			0xC8258
-
-#define BXT_BLC_PWM_CTL2			0xC8350
-#define BXT_BLC_PWM_FREQ2			0xC8354
-#define BXT_BLC_PWM_DUTY2			0xC8358
-
+#define _BXT_BLC_PWM_FREQ1			0xC8254
+#define _BXT_BLC_PWM_DUTY1			0xC8258
+
+#define _BXT_BLC_PWM_CTL2			0xC8350
+#define _BXT_BLC_PWM_FREQ2			0xC8354
+#define _BXT_BLC_PWM_DUTY2			0xC8358
+
+#define BXT_BLC_PWM_CTL(controller)    _PIPE(controller, \
+					_BXT_BLC_PWM_CTL1, _BXT_BLC_PWM_CTL2)
+#define BXT_BLC_PWM_FREQ(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_FREQ1, _BXT_BLC_PWM_FREQ2)
+#define BXT_BLC_PWM_DUTY(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_DUTY1, _BXT_BLC_PWM_DUTY2)
 
 #define PCH_GTC_CTL		0xe7000
 #define   PCH_GTC_ENABLE	(1 << 31)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 1059283..d8ca075 100644
@@ -182,7 +182,9 @@ struct intel_panel {
 		bool enabled;
 		bool combination_mode;	/* gen 2/4 only */
 		bool active_low_pwm;
+		bool util_pin_active_low;	/* bxt+ */
 		struct backlight_device *device;
+		u8 controller;		/* bxt+ only */
 	} backlight;
 
 	void (*backlight_power)(struct intel_connector *, bool enable);
drivers/gpu/drm/i915/intel_panel.c +66 -17

132 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v5 11/14
#55 lore raw

Re: [BXT MIPI PATCH v5 11/14] drm/i915/bxt: Modify BXT BLC according to VBT changes

Quoted 38 lines · Uma Shankar

From: Sunil Kamath <[email protected]>

Latest VBT mentions which set of registers will be used for BLC, as controller number field. Making use of this field in BXT
BLC implementation. Also, the registers are used in case control pin indicates display DDI. Adding a check for this.
According to Bspec, BLC_PWM_*_2 uses the display utility pin for output. To use backlight 2, enable the utility pin with mode = PWM
v2: Jani's review comments
addressed
- Add a prefix _ to BXT BLC registers definitions.
- Add "bxt only" comment for u8 controller
- Remove control_pin check for DDI controller
- Check for valid controller values
- Set pipe bits in UTIL_PIN_CTL
- Enable/Disable UTIL_PIN_CTL in enable/disable_backlight()
- If BLC 2 is used, read active_low_pwm from UTIL_PIN polarity
Satheesh's review comment addressed
- If UTIL PIN is already enabled, BIOS would have programmed it. No need to disable and enable again.
v3: Jani's review comments
- add UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK
- Disable UTIL_PIN if controller 1 is used
- Mask out UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK before enabling UTIL_PIN
- check valid controller value in intel_bios.c
- add backlight.util_pin_active_low
- disable util pin before enabling
v4: Change for BXT-PO branch:
Stubbed unwanted definition which was existing before because of DC6 patch.
UTIL_PIN_MODE_PWM (0x1b << 24)

v2: Fixed Jani's review comment.

v3: Split the backight PWM frequency programming into separate patch,
in cases BIOS doesn't initializes it.

Quoted 8 lines

v4: Starting afresh and not modifying existing state for backlight, as
per Jani's recommendation.

v5: Fixed Jani's review comment wrt util pin enable

Quoted 207 lines
---
 drivers/gpu/drm/i915/i915_reg.h    |   28 ++++++++----
 drivers/gpu/drm/i915/intel_drv.h   |    2 +
 drivers/gpu/drm/i915/intel_panel.c |   83 ++++++++++++++++++++++++++++--------
 3 files changed, 88 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +20 -8
index 88a16e2..519f764 100644
@@ -3512,17 +3512,29 @@ enum skl_disp_power_wells {
 #define UTIL_PIN_CTL		0x48400
 #define   UTIL_PIN_ENABLE	(1 << 31)
 
+#define   UTIL_PIN_PIPE(x)     ((x) << 29)
+#define   UTIL_PIN_PIPE_MASK   (3 << 29)
+#define   UTIL_PIN_MODE_PWM    (1 << 24)
+#define   UTIL_PIN_MODE_MASK   (0xf << 24)
+#define   UTIL_PIN_POLARITY    (1 << 22)
+
 /* BXT backlight register definition. */
-#define BXT_BLC_PWM_CTL1			0xC8250
+#define _BXT_BLC_PWM_CTL1			0xC8250
 #define   BXT_BLC_PWM_ENABLE			(1 << 31)
 #define   BXT_BLC_PWM_POLARITY			(1 << 29)
-#define BXT_BLC_PWM_FREQ1			0xC8254
-#define BXT_BLC_PWM_DUTY1			0xC8258
-
-#define BXT_BLC_PWM_CTL2			0xC8350
-#define BXT_BLC_PWM_FREQ2			0xC8354
-#define BXT_BLC_PWM_DUTY2			0xC8358
-
+#define _BXT_BLC_PWM_FREQ1			0xC8254
+#define _BXT_BLC_PWM_DUTY1			0xC8258
+
+#define _BXT_BLC_PWM_CTL2			0xC8350
+#define _BXT_BLC_PWM_FREQ2			0xC8354
+#define _BXT_BLC_PWM_DUTY2			0xC8358
+
+#define BXT_BLC_PWM_CTL(controller)    _PIPE(controller, \
+					_BXT_BLC_PWM_CTL1, _BXT_BLC_PWM_CTL2)
+#define BXT_BLC_PWM_FREQ(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_FREQ1, _BXT_BLC_PWM_FREQ2)
+#define BXT_BLC_PWM_DUTY(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_DUTY1, _BXT_BLC_PWM_DUTY2)
 
 #define PCH_GTC_CTL		0xe7000
 #define   PCH_GTC_ENABLE	(1 << 31)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 1059283..d8ca075 100644
@@ -182,7 +182,9 @@ struct intel_panel {
 		bool enabled;
 		bool combination_mode;	/* gen 2/4 only */
 		bool active_low_pwm;
+		bool util_pin_active_low;	/* bxt+ */
 		struct backlight_device *device;
+		u8 controller;		/* bxt+ only */
 	} backlight;
 
 	void (*backlight_power)(struct intel_connector *, bool enable);
drivers/gpu/drm/i915/intel_panel.c +66 -17
index 55aad23..0d21715 100644
@@ -539,9 +539,10 @@ static u32 vlv_get_backlight(struct intel_connector *connector)
 static u32 bxt_get_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
+	struct intel_panel *panel = &connector->panel;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	return I915_READ(BXT_BLC_PWM_DUTY1);
+	return I915_READ(BXT_BLC_PWM_DUTY(panel->backlight.controller));
 }
 
 static u32 intel_panel_get_backlight(struct intel_connector *connector)
@@ -628,8 +629,9 @@ static void bxt_set_backlight(struct intel_connector *connector, u32 level)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_panel *panel = &connector->panel;
 
-	I915_WRITE(BXT_BLC_PWM_DUTY1, level);
+	I915_WRITE(BXT_BLC_PWM_DUTY(panel->backlight.controller), level);
 }
 
 static void
@@ -761,12 +763,20 @@ static void bxt_disable_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 tmp;
+	struct intel_panel *panel = &connector->panel;
+	u32 tmp, val;
 
 	intel_panel_actually_set_backlight(connector, 0);
 
-	tmp = I915_READ(BXT_BLC_PWM_CTL1);
-	I915_WRITE(BXT_BLC_PWM_CTL1, tmp & ~BXT_BLC_PWM_ENABLE);
+	tmp = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+			tmp & ~BXT_BLC_PWM_ENABLE);
+
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		val &= ~UTIL_PIN_ENABLE;
+		I915_WRITE(UTIL_PIN_CTL, val);
+	}
 }
 
 void intel_panel_disable_backlight(struct intel_connector *connector)
@@ -988,16 +998,38 @@ static void bxt_enable_backlight(struct intel_connector *connector)
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_panel *panel = &connector->panel;
-	u32 pwm_ctl;
+	enum pipe pipe = intel_get_pipe_from_connector(connector);
+	u32 pwm_ctl, val;
+
+	/* To use 2nd set of backlight registers, utility pin has to be
+	 * enabled with PWM mode.
+	 * The field should only be changed when the utility pin is disabled
+	 */
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		if (val & UTIL_PIN_ENABLE) {
+			DRM_DEBUG_KMS("util pin already enabled\n");
+			val &= ~UTIL_PIN_ENABLE;
+			I915_WRITE(UTIL_PIN_CTL, val);
+		}
 
-	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL1);
+		val = 0;
+		if (panel->backlight.util_pin_active_low)
+			val |= UTIL_PIN_POLARITY;
+		I915_WRITE(UTIL_PIN_CTL, val | UTIL_PIN_PIPE(pipe) |
+				UTIL_PIN_MODE_PWM | UTIL_PIN_ENABLE);
+	}
+
+	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
 	if (pwm_ctl & BXT_BLC_PWM_ENABLE) {
 		DRM_DEBUG_KMS("backlight already enabled\n");
 		pwm_ctl &= ~BXT_BLC_PWM_ENABLE;
-		I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl);
+		I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+				pwm_ctl);
 	}
 
-	I915_WRITE(BXT_BLC_PWM_FREQ1, panel->backlight.max);
+	I915_WRITE(BXT_BLC_PWM_FREQ(panel->backlight.controller),
+			panel->backlight.max);
 
 	intel_panel_actually_set_backlight(connector, panel->backlight.level);
 
@@ -1005,9 +1037,10 @@ static void bxt_enable_backlight(struct intel_connector *connector)
 	if (panel->backlight.active_low_pwm)
 		pwm_ctl |= BXT_BLC_PWM_POLARITY;
 
-	I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl);
-	POSTING_READ(BXT_BLC_PWM_CTL1);
-	I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl | BXT_BLC_PWM_ENABLE);
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl);
+	POSTING_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+			pwm_ctl | BXT_BLC_PWM_ENABLE);
 }
 
 void intel_panel_enable_backlight(struct intel_connector *connector)
@@ -1370,12 +1403,28 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
 	struct intel_panel *panel = &connector->panel;
 	u32 pwm_ctl, val;
 
-	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL1);
-	panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
+	/*
+	 * For BXT hard coding the Backlight controller to 0.
+	 * TODO : Read the controller value from VBT and generalize
+	 */
+	panel->backlight.controller = 0;
 
-	panel->backlight.max = I915_READ(BXT_BLC_PWM_FREQ1);
-	if (!panel->backlight.max)
-		return -ENODEV;
+	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+
+	/* Keeping the check if controller 1 is to be programmed.
+	 * This will come into affect once the VBT parsing
+	 * is fixed for controller selection, and controller 1 is used
+	 * for a prticular display configuration.
+	 */
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		panel->backlight.util_pin_active_low =
+					val & UTIL_PIN_POLARITY;
+	}
+
+	panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
+	panel->backlight.max = I915_READ(
+			BXT_BLC_PWM_FREQ(panel->backlight.controller));
 
 	val = bxt_get_backlight(connector);
 	panel->backlight.level = intel_panel_compute_brightness(connector, val);
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#56 lore raw

Re: [BXT MIPI PATCH v5 11/14] drm/i915/bxt: Modify BXT BLC according to VBT changes

In reply to Uma Shankar
Quoted 221 lines · Uma Shankar

From: Sunil Kamath <[email protected]>

Latest VBT mentions which set of registers will be used for BLC, as controller number field. Making use of this field in BXT
BLC implementation. Also, the registers are used in case control pin indicates display DDI. Adding a check for this.
According to Bspec, BLC_PWM_*_2 uses the display utility pin for output. To use backlight 2, enable the utility pin with mode = PWM
v2: Jani's review comments
addressed
- Add a prefix _ to BXT BLC registers definitions.
- Add "bxt only" comment for u8 controller
- Remove control_pin check for DDI controller
- Check for valid controller values
- Set pipe bits in UTIL_PIN_CTL
- Enable/Disable UTIL_PIN_CTL in enable/disable_backlight()
- If BLC 2 is used, read active_low_pwm from UTIL_PIN polarity
Satheesh's review comment addressed
- If UTIL PIN is already enabled, BIOS would have programmed it. No need to disable and enable again.
v3: Jani's review comments
- add UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK
- Disable UTIL_PIN if controller 1 is used
- Mask out UTIL_PIN_PIPE_MASK and UTIL_PIN_MODE_MASK before enabling UTIL_PIN
- check valid controller value in intel_bios.c
- add backlight.util_pin_active_low
- disable util pin before enabling
v4: Change for BXT-PO branch:
Stubbed unwanted definition which was existing before because of DC6 patch.
UTIL_PIN_MODE_PWM (0x1b << 24)

v2: Fixed Jani's review comment.

v3: Split the backight PWM frequency programming into separate patch,
in cases BIOS doesn't initializes it.

v4: Starting afresh and not modifying existing state for backlight, as
per Jani's recommendation.

v5: Fixed Jani's review comment wrt util pin enable

---
 drivers/gpu/drm/i915/i915_reg.h    |   28 ++++++++----
 drivers/gpu/drm/i915/intel_drv.h   |    2 +
 drivers/gpu/drm/i915/intel_panel.c |   83 ++++++++++++++++++++++++++++--------
 3 files changed, 88 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +20 -8
index 88a16e2..519f764 100644
@@ -3512,17 +3512,29 @@ enum skl_disp_power_wells {
 #define UTIL_PIN_CTL		0x48400
 #define   UTIL_PIN_ENABLE	(1 << 31)
 
+#define   UTIL_PIN_PIPE(x)     ((x) << 29)
+#define   UTIL_PIN_PIPE_MASK   (3 << 29)
+#define   UTIL_PIN_MODE_PWM    (1 << 24)
+#define   UTIL_PIN_MODE_MASK   (0xf << 24)
+#define   UTIL_PIN_POLARITY    (1 << 22)
+
 /* BXT backlight register definition. */
-#define BXT_BLC_PWM_CTL1			0xC8250
+#define _BXT_BLC_PWM_CTL1			0xC8250
 #define   BXT_BLC_PWM_ENABLE			(1 << 31)
 #define   BXT_BLC_PWM_POLARITY			(1 << 29)
-#define BXT_BLC_PWM_FREQ1			0xC8254
-#define BXT_BLC_PWM_DUTY1			0xC8258
-
-#define BXT_BLC_PWM_CTL2			0xC8350
-#define BXT_BLC_PWM_FREQ2			0xC8354
-#define BXT_BLC_PWM_DUTY2			0xC8358
-
+#define _BXT_BLC_PWM_FREQ1			0xC8254
+#define _BXT_BLC_PWM_DUTY1			0xC8258
+
+#define _BXT_BLC_PWM_CTL2			0xC8350
+#define _BXT_BLC_PWM_FREQ2			0xC8354
+#define _BXT_BLC_PWM_DUTY2			0xC8358
+
+#define BXT_BLC_PWM_CTL(controller)    _PIPE(controller, \
+					_BXT_BLC_PWM_CTL1, _BXT_BLC_PWM_CTL2)
+#define BXT_BLC_PWM_FREQ(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_FREQ1, _BXT_BLC_PWM_FREQ2)
+#define BXT_BLC_PWM_DUTY(controller)   _PIPE(controller, \
+					_BXT_BLC_PWM_DUTY1, _BXT_BLC_PWM_DUTY2)
 
 #define PCH_GTC_CTL		0xe7000
 #define   PCH_GTC_ENABLE	(1 << 31)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 1059283..d8ca075 100644
@@ -182,7 +182,9 @@ struct intel_panel {
 		bool enabled;
 		bool combination_mode;	/* gen 2/4 only */
 		bool active_low_pwm;
+		bool util_pin_active_low;	/* bxt+ */
 		struct backlight_device *device;
+		u8 controller;		/* bxt+ only */
 	} backlight;
 
 	void (*backlight_power)(struct intel_connector *, bool enable);
drivers/gpu/drm/i915/intel_panel.c +45 -13
index 55aad23..0d21715 100644
@@ -539,9 +539,10 @@ static u32 vlv_get_backlight(struct intel_connector *connector)
 static u32 bxt_get_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
+	struct intel_panel *panel = &connector->panel;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	return I915_READ(BXT_BLC_PWM_DUTY1);
+	return I915_READ(BXT_BLC_PWM_DUTY(panel->backlight.controller));
 }
 
 static u32 intel_panel_get_backlight(struct intel_connector *connector)
@@ -628,8 +629,9 @@ static void bxt_set_backlight(struct intel_connector *connector, u32 level)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_panel *panel = &connector->panel;
 
-	I915_WRITE(BXT_BLC_PWM_DUTY1, level);
+	I915_WRITE(BXT_BLC_PWM_DUTY(panel->backlight.controller), level);
 }
 
 static void
@@ -761,12 +763,20 @@ static void bxt_disable_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 tmp;
+	struct intel_panel *panel = &connector->panel;
+	u32 tmp, val;
 
 	intel_panel_actually_set_backlight(connector, 0);
 
-	tmp = I915_READ(BXT_BLC_PWM_CTL1);
-	I915_WRITE(BXT_BLC_PWM_CTL1, tmp & ~BXT_BLC_PWM_ENABLE);
+	tmp = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+			tmp & ~BXT_BLC_PWM_ENABLE);
+
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		val &= ~UTIL_PIN_ENABLE;
+		I915_WRITE(UTIL_PIN_CTL, val);
+	}
 }
 
 void intel_panel_disable_backlight(struct intel_connector *connector)
@@ -988,16 +998,38 @@ static void bxt_enable_backlight(struct intel_connector *connector)
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_panel *panel = &connector->panel;
-	u32 pwm_ctl;
+	enum pipe pipe = intel_get_pipe_from_connector(connector);
+	u32 pwm_ctl, val;
+
+	/* To use 2nd set of backlight registers, utility pin has to be
+	 * enabled with PWM mode.
+	 * The field should only be changed when the utility pin is disabled
+	 */
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		if (val & UTIL_PIN_ENABLE) {
+			DRM_DEBUG_KMS("util pin already enabled\n");
+			val &= ~UTIL_PIN_ENABLE;
+			I915_WRITE(UTIL_PIN_CTL, val);
+		}
 
-	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL1);
+		val = 0;
+		if (panel->backlight.util_pin_active_low)
+			val |= UTIL_PIN_POLARITY;
+		I915_WRITE(UTIL_PIN_CTL, val | UTIL_PIN_PIPE(pipe) |
+				UTIL_PIN_MODE_PWM | UTIL_PIN_ENABLE);
+	}
+
+	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
 	if (pwm_ctl & BXT_BLC_PWM_ENABLE) {
 		DRM_DEBUG_KMS("backlight already enabled\n");
 		pwm_ctl &= ~BXT_BLC_PWM_ENABLE;
-		I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl);
+		I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+				pwm_ctl);
 	}
 
-	I915_WRITE(BXT_BLC_PWM_FREQ1, panel->backlight.max);
+	I915_WRITE(BXT_BLC_PWM_FREQ(panel->backlight.controller),
+			panel->backlight.max);
 
 	intel_panel_actually_set_backlight(connector, panel->backlight.level);
 
@@ -1005,9 +1037,10 @@ static void bxt_enable_backlight(struct intel_connector *connector)
 	if (panel->backlight.active_low_pwm)
 		pwm_ctl |= BXT_BLC_PWM_POLARITY;
 
-	I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl);
-	POSTING_READ(BXT_BLC_PWM_CTL1);
-	I915_WRITE(BXT_BLC_PWM_CTL1, pwm_ctl | BXT_BLC_PWM_ENABLE);
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl);
+	POSTING_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+	I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
+			pwm_ctl | BXT_BLC_PWM_ENABLE);
 }
 
 void intel_panel_enable_backlight(struct intel_connector *connector)
@@ -1370,12 +1403,28 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
 	struct intel_panel *panel = &connector->panel;
 	u32 pwm_ctl, val;
 
-	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL1);

drivers/gpu/drm/i915/intel_panel.c bxt_setup_backlight(struct intel_connector *connector, enum pipe unused) · line 1378

Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +5 -4
-	panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
+	/*
+	 * For BXT hard coding the Backlight controller to 0.
+	 * TODO : Read the controller value from VBT and generalize
+	 */
+	panel->backlight.controller = 0;
 
-	panel->backlight.max = I915_READ(BXT_BLC_PWM_FREQ1);
-	if (!panel->backlight.max)
-		return -ENODEV;

There was a conflict here and removing that if check seemed accidental. So I kept it.

Quoted 6 lines
drivers/gpu/drm/i915/intel_panel.c +6 -0
+	pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
+
+	/* Keeping the check if controller 1 is to be programmed.
+	 * This will come into affect once the VBT parsing
+	 * is fixed for controller selection, and controller 1 is used
+	 * for a prticular display configuration.

drivers/gpu/drm/i915/intel_panel.c bxt_setup_backlight(struct intel_connector *connector, enum pipe unused) · line 1427

Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +10 -0
+	 */
+	if (panel->backlight.controller == 1) {
+		val = I915_READ(UTIL_PIN_CTL);
+		panel->backlight.util_pin_active_low =
+					val & UTIL_PIN_POLARITY;
+	}
+
+	panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
+	panel->backlight.max = I915_READ(
+			BXT_BLC_PWM_FREQ(panel->backlight.controller));

This isn't how we break lines. Fixed while applying. -Daniel

Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +0 -0
 	val = bxt_get_backlight(connector);
 	panel->backlight.level = intel_panel_compute_brightness(connector, val);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#57 lore raw

PATCH v3 12/14 drm/i915/bxt: Program Backlight PWM frequency

In reply to Uma Shankar

In some cases, BIOS doesn't initializes DSI panel.DSI and backlight registers are thereby not initialized. Programming the same in driver backlight setup.

---
 drivers/gpu/drm/i915/i915_reg.h    |    3 +++
 drivers/gpu/drm/i915/intel_panel.c |   11 +++++++++++
 2 files changed, 14 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 8407b5c..10f73b1 100644
@@ -7166,6 +7166,9 @@ enum skl_disp_power_wells {
 #define  TRANS_MSA_12_BPC		(3<<5)
 #define  TRANS_MSA_16_BPC		(4<<5)
 
+/* Max CDCLK freq for BXT in HZ */
+#define BXT_CDCLK_MAX                   624000000
+
 /* LCPLL Control */
 #define LCPLL_CTL			0x130040
 #define  LCPLL_PLL_DISABLE		(1<<31)
drivers/gpu/drm/i915/intel_panel.c +11 -0
index 9fcf86c..8225cea 100644
@@ -1427,6 +1427,17 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
 	panel->backlight.max = I915_READ(
 			BXT_BLC_PWM_FREQ(panel->backlight.controller));
 
+	if (!panel->backlight.max) {
+		DRM_DEBUG_KMS("PWM freq not programmed by BIOS\n");
+		DRM_DEBUG_KMS("Programming PWM freq\n");
+
+		/* Max Backlight = Max CD Clock / pwm freq) */
+		panel->backlight.max = (BXT_CDCLK_MAX /
+				dev_priv->vbt.backlight.pwm_freq_hz);
+		I915_WRITE(BXT_BLC_PWM_FREQ(panel->backlight.controller),
+				panel->backlight.max);
+	}
+
 	val = bxt_get_backlight(connector);
 	panel->backlight.level = intel_panel_compute_brightness(connector, val);
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#58 lore raw

Re: [BXT MIPI PATCH v3 12/14] drm/i915/bxt: Program Backlight PWM frequency

Quoted 5 lines · Uma Shankar

In some cases, BIOS doesn't initializes DSI panel.DSI and backlight registers are thereby not initialized. Programming the same in driver backlight setup.

This is probably obsolete now. See current bxt_setup_backlight.

BR,
Jani.

Quoted 44 lines
---
 drivers/gpu/drm/i915/i915_reg.h    |    3 +++
 drivers/gpu/drm/i915/intel_panel.c |   11 +++++++++++
 2 files changed, 14 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 8407b5c..10f73b1 100644
@@ -7166,6 +7166,9 @@ enum skl_disp_power_wells {
 #define  TRANS_MSA_12_BPC		(3<<5)
 #define  TRANS_MSA_16_BPC		(4<<5)
 
+/* Max CDCLK freq for BXT in HZ */
+#define BXT_CDCLK_MAX                   624000000
+
 /* LCPLL Control */
 #define LCPLL_CTL			0x130040
 #define  LCPLL_PLL_DISABLE		(1<<31)
drivers/gpu/drm/i915/intel_panel.c +11 -0
index 9fcf86c..8225cea 100644
@@ -1427,6 +1427,17 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
 	panel->backlight.max = I915_READ(
 			BXT_BLC_PWM_FREQ(panel->backlight.controller));
 
+	if (!panel->backlight.max) {
+		DRM_DEBUG_KMS("PWM freq not programmed by BIOS\n");
+		DRM_DEBUG_KMS("Programming PWM freq\n");
+
+		/* Max Backlight = Max CD Clock / pwm freq) */
+		panel->backlight.max = (BXT_CDCLK_MAX /
+				dev_priv->vbt.backlight.pwm_freq_hz);
+		I915_WRITE(BXT_BLC_PWM_FREQ(panel->backlight.controller),
+				panel->backlight.max);
+	}
+
 	val = bxt_get_backlight(connector);
 	panel->backlight.level = intel_panel_compute_brightness(connector, val);
 
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#59 lore raw

Re: [BXT MIPI PATCH v3 12/14] drm/i915/bxt: Program Backlight PWM frequency

Quoted 15 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 7:03 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 12/14] drm/i915/bxt: Program Backlight PWM frequency

Quoted 4 lines · Uma Shankar

In some cases, BIOS doesn't initializes DSI panel.DSI and backlight registers are thereby not initialized. Programming the same in driver backlight setup.

Quoted 7 lines
Quoted 1 line

This is probably obsolete now. See current bxt_setup_backlight.

BR,
Jani.

Yeah, we can drop this patch since the values will be updated in VBT. Thanks Jani for notifying.

Quoted 29 lines

drivers/gpu/drm/i915/intel_panel.c bxt_setup_backlight(struct intel_connector

Quoted 25 lines
---
 drivers/gpu/drm/i915/i915_reg.h    |    3 +++
 drivers/gpu/drm/i915/intel_panel.c |   11 +++++++++++
 2 files changed, 14 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h index 8407b5c..10f73b1 100644

drivers/gpu/drm/i915/i915_reg.h +3 -0
@@ -7166,6 +7166,9 @@ enum skl_disp_power_wells {
 #define  TRANS_MSA_12_BPC		(3<<5)
 #define  TRANS_MSA_16_BPC		(4<<5)
 
+/* Max CDCLK freq for BXT in HZ */
+#define BXT_CDCLK_MAX                   624000000
+
 /* LCPLL Control */
 #define LCPLL_CTL			0x130040
 #define  LCPLL_PLL_DISABLE		(1<<31)
drivers/gpu/drm/i915/intel_panel.c +0 -0
index 9fcf86c..8225cea 100644
@@ -1427,6 +1427,17 @@ bxt_setup_backlight(struct intel_connector

*connector, enum pipe unused)

Quoted 3 lines
drivers/gpu/drm/i915/intel_panel.c +0 -0
 	panel->backlight.max = I915_READ(
 			BXT_BLC_PWM_FREQ(panel->backlight.controller));
 
Quoted 15 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_panel.c +4 -0
+	if (!panel->backlight.max) {
+		DRM_DEBUG_KMS("PWM freq not programmed by BIOS\n");
+		DRM_DEBUG_KMS("Programming PWM freq\n");
+

drivers/gpu/drm/i915/intel_panel.c bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)

Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +7 -0
+		/* Max Backlight = Max CD Clock / pwm freq) */
+		panel->backlight.max = (BXT_CDCLK_MAX /
+				dev_priv->vbt.backlight.pwm_freq_hz);
+		I915_WRITE(BXT_BLC_PWM_FREQ(panel->backlight.controller),
+				panel->backlight.max);
+	}
+
 	val = bxt_get_backlight(connector);
 	panel->backlight.level = intel_panel_compute_brightness(connector,
 val);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#60 lore raw

PATCH v3 13/14 drm/i915/bxt: Remove DSP CLK_GATE programming for BXT

In reply to Uma Shankar

DSP CLK_GATE registers are specific to BYT and CHT. Avoid programming the same for BXT platform.

v2: Rebased on latest drm nightly branch.

v3: Fixed Jani's review comments

---
 drivers/gpu/drm/i915/intel_dsi.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +5 -3
index 6a0071f..08bade2 100644
@@ -631,9 +631,11 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 
 	intel_dsi_clear_device_ready(encoder);
 
-	val = I915_READ(DSPCLK_GATE_D);
-	val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
-	I915_WRITE(DSPCLK_GATE_D, val);
+	if (!IS_BROXTON(dev_priv->dev)) {
+		val = I915_READ(DSPCLK_GATE_D);
+		val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
+		I915_WRITE(DSPCLK_GATE_D, val);
+	}
 
 	drm_panel_unprepare(intel_dsi->panel);
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 13/14
#61 lore raw

Re: [BXT MIPI PATCH v3 13/14] drm/i915/bxt: Remove DSP CLK_GATE programming for BXT

Quoted 8 lines · Uma Shankar

DSP CLK_GATE registers are specific to BYT and CHT. Avoid programming the same for BXT platform.

v2: Rebased on latest drm nightly branch.

v3: Fixed Jani's review comments

Quoted 26 lines
---
 drivers/gpu/drm/i915/intel_dsi.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +5 -3
index 6a0071f..08bade2 100644
@@ -631,9 +631,11 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 
 	intel_dsi_clear_device_ready(encoder);
 
-	val = I915_READ(DSPCLK_GATE_D);
-	val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
-	I915_WRITE(DSPCLK_GATE_D, val);
+	if (!IS_BROXTON(dev_priv->dev)) {
+		val = I915_READ(DSPCLK_GATE_D);
+		val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
+		I915_WRITE(DSPCLK_GATE_D, val);
+	}
 
 	drm_panel_unprepare(intel_dsi->panel);
 
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#62 lore raw

Re: [BXT MIPI PATCH v3 13/14] drm/i915/bxt: Remove DSP CLK_GATE programming for BXT

Quoted 11 lines · Jani Nikula
Quoted 8 lines · Uma Shankar

DSP CLK_GATE registers are specific to BYT and CHT. Avoid programming the same for BXT platform.

v2: Rebased on latest drm nightly branch.

v3: Fixed Jani's review comments

Merged everything in this series to dinq, with the exception of two backlight-related patches which seem superseeded.

I'll expect follow-up work to clean up the encoder callback code organization.
-Daniel

Quoted 35 lines
Quoted 28 lines

---
 drivers/gpu/drm/i915/intel_dsi.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +5 -3
index 6a0071f..08bade2 100644
@@ -631,9 +631,11 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 
 	intel_dsi_clear_device_ready(encoder);
 
-	val = I915_READ(DSPCLK_GATE_D);
-	val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
-	I915_WRITE(DSPCLK_GATE_D, val);
+	if (!IS_BROXTON(dev_priv->dev)) {
+		val = I915_READ(DSPCLK_GATE_D);
+		val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
+		I915_WRITE(DSPCLK_GATE_D, val);
+	}
 
 	drm_panel_unprepare(intel_dsi->panel);
 
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#63 lore raw

PATCH v3 14/14 drm/i915: Added BXT DSI backlight support

In reply to Uma Shankar

DSI backlight support for bxt is added.

TODO: There is no support for backlight control in drm panel
framework. This will be added as part of VBT version patches fixing the backlight sequence.

v2: Fixed Jani's review comments from previous patch. Added the
BXT DSI backlight code in this patch. Backlight setup and enable/disable code for backlight is added in intel_dsi.c.

v3: Rebased on latest drm-nightly. Fixed Jani's review comments.

---
 drivers/gpu/drm/i915/intel_dsi.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dsi.c +19 -1
index 08bade2..aee1539 100644
@@ -438,6 +438,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	enum port port;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +459,11 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 
 		intel_dsi_port_enable(encoder);
 	}
+
+	if (IS_BROXTON(dev)) {
+		msleep(intel_dsi->backlight_on_delay);
+		intel_panel_enable_backlight(intel_connector);
+	}
 }
 
 static void intel_dsi_pre_enable(struct intel_encoder *encoder)
@@ -623,10 +629,16 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
 
+	if (IS_BROXTON(dev_priv->dev)) {
+		intel_panel_disable_backlight(intel_connector);
+		msleep(intel_dsi->backlight_off_delay);
+	}
+
 	intel_dsi_disable(encoder);
 
 	intel_dsi_clear_device_ready(encoder);
@@ -1226,8 +1238,14 @@ void intel_dsi_init(struct drm_device *dev)
 
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
-	return;
+	/*
+	 * Pipe parameter is not used for BXT.
+	 * Passing INVALID_PIPE to adher to API requirement.
+	 */
+	if (IS_BROXTON(dev))
+		intel_panel_setup_backlight(connector, INVALID_PIPE);
 
+	return;
 err:
 	drm_encoder_cleanup(&intel_encoder->base);
 	kfree(intel_dsi);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#64 lore raw

Re: [BXT MIPI PATCH v3 14/14] drm/i915: Added BXT DSI backlight support

Quoted 11 lines · Uma Shankar

DSI backlight support for bxt is added.

TODO: There is no support for backlight control in drm panel
framework. This will be added as part of VBT version patches fixing the backlight sequence.

v2: Fixed Jani's review comments from previous patch. Added the
BXT DSI backlight code in this patch. Backlight setup and enable/disable code for backlight is added in intel_dsi.c.

v3: Rebased on latest drm-nightly. Fixed Jani's review comments.

I'm not sure why these calls need to be within IS_BROXTON blocks. What happens with the current backlight calls? Shouldn't we just have one set of calls?

Also, I think we should get this [1] in first, and see how that affects things.

BR,
Jani.

[1] http://mid.gmane.org/[email protected]

Quoted 66 lines
---
 drivers/gpu/drm/i915/intel_dsi.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dsi.c +19 -1
index 08bade2..aee1539 100644
@@ -438,6 +438,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	enum port port;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +459,11 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 
 		intel_dsi_port_enable(encoder);
 	}
+
+	if (IS_BROXTON(dev)) {
+		msleep(intel_dsi->backlight_on_delay);
+		intel_panel_enable_backlight(intel_connector);
+	}
 }
 
 static void intel_dsi_pre_enable(struct intel_encoder *encoder)
@@ -623,10 +629,16 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
 
+	if (IS_BROXTON(dev_priv->dev)) {
+		intel_panel_disable_backlight(intel_connector);
+		msleep(intel_dsi->backlight_off_delay);
+	}
+
 	intel_dsi_disable(encoder);
 
 	intel_dsi_clear_device_ready(encoder);
@@ -1226,8 +1238,14 @@ void intel_dsi_init(struct drm_device *dev)
 
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
-	return;
+	/*
+	 * Pipe parameter is not used for BXT.
+	 * Passing INVALID_PIPE to adher to API requirement.
+	 */
+	if (IS_BROXTON(dev))
+		intel_panel_setup_backlight(connector, INVALID_PIPE);
 
+	return;
 err:
 	drm_encoder_cleanup(&intel_encoder->base);
 	kfree(intel_dsi);
Signature · 1 line
1.7.9.5
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#65 lore raw

Re: [BXT MIPI PATCH v3 14/14] drm/i915: Added BXT DSI backlight support

Quoted 26 lines

-----Original Message-----
From: Nikula, Jani
Sent: Friday, September 18, 2015 7:08 PM
To: Shankar, Uma; [email protected]
Cc: Kumar, Shobhit; Deak, Imre; Shankar, Uma
Subject: Re: [BXT MIPI PATCH v3 14/14] drm/i915: Added BXT DSI backlight support

Quoted 11 lines · Uma Shankar

DSI backlight support for bxt is added.

TODO: There is no support for backlight control in drm panel
framework. This will be added as part of VBT version patches fixing the backlight sequence.

v2: Fixed Jani's review comments from previous patch. Added the
BXT DSI backlight code in this patch. Backlight setup and enable/disable code for backlight is added in intel_dsi.c.

v3: Rebased on latest drm-nightly. Fixed Jani's review comments.

I'm not sure why these calls need to be within IS_BROXTON blocks. What happens with the current backlight calls? Shouldn't we just have one set of calls?

Quoted 7 lines

Also, I think we should get this [1] in first, and see how that affects things.

BR,
Jani.

[1] http://mid.gmane.org/[email protected]

The idea was not to disturb existing platforms and add support for BXT. We can hold this patch back and get the patch you mentioned merged, Accordingly if needed we can create a follow up patch to iron things out.

Regards,
Uma Shankar

Quoted 64 lines

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_enable(struct intel_encoder

Quoted 12 lines
---
 drivers/gpu/drm/i915/intel_dsi.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dsi.c +0 -0
index 08bade2..aee1539 100644
@@ -438,6 +438,7 @@ static void intel_dsi_enable(struct intel_encoder

*encoder)

Quoted 51 lines
drivers/gpu/drm/i915/intel_dsi.c +7 -0
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector =
+intel_dsi->attached_connector;
 	enum port port;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +459,11 @@ static void intel_dsi_enable(struct intel_encoder
 *encoder)
 
 		intel_dsi_port_enable(encoder);
 	}
+
+	if (IS_BROXTON(dev)) {
+		msleep(intel_dsi->backlight_on_delay);
+		intel_panel_enable_backlight(intel_connector);
+	}
 }
 

static void intel_dsi_pre_enable(struct intel_encoder *encoder) @@
-623,10 +629,16 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder) {

drivers/gpu/drm/i915/intel_dsi.c +13 -1
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector =
+intel_dsi->attached_connector;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
 
+	if (IS_BROXTON(dev_priv->dev)) {
+		intel_panel_disable_backlight(intel_connector);
+		msleep(intel_dsi->backlight_off_delay);
+	}
+
 	intel_dsi_disable(encoder);
 
 	intel_dsi_clear_device_ready(encoder);
@@ -1226,8 +1238,14 @@ void intel_dsi_init(struct drm_device *dev)
 
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
-	return;
+	/*
+	 * Pipe parameter is not used for BXT.
+	 * Passing INVALID_PIPE to adher to API requirement.
+	 */
+	if (IS_BROXTON(dev))
+		intel_panel_setup_backlight(connector, INVALID_PIPE);
 
Quoted 10 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi.c +1 -1
+	return;
 err:
 	drm_encoder_cleanup(&intel_encoder->base);
 	kfree(intel_dsi);
--

1.7.9.5

--
Jani Nikula, Intel Open Source Technology Center

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#66 lore raw

PATCH v4 14/14 drm/i915: Added BXT DSI backlight support

In reply to Jani Nikula

DSI backlight support for bxt is added.

TODO: There is no support for backlight control in drm panel
framework. This will be added as part of VBT version patches fixing the backlight sequence.

v2: Fixed Jani's review comments from previous patch. Added the
BXT DSI backlight code in this patch. Backlight setup and enable/disable code for backlight is added in intel_dsi.c.

v3: Rebased on latest drm-nightly. Fixed Jani's review comments.

v4: Making backlight calls generic as per Jani's suggestion.

---
 drivers/gpu/drm/i915/intel_dsi.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dsi.c +19 -1
index 08bade2..3e7f796 100644
@@ -438,6 +438,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	enum port port;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +459,9 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 
 		intel_dsi_port_enable(encoder);
 	}
+
+	msleep(intel_dsi->backlight_on_delay);
+	intel_panel_enable_backlight(intel_connector);
 }
 
 static void intel_dsi_pre_enable(struct intel_encoder *encoder)
@@ -623,10 +627,14 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
 
+	intel_panel_disable_backlight(intel_connector);
+	msleep(intel_dsi->backlight_off_delay);
+
 	intel_dsi_disable(encoder);
 
 	intel_dsi_clear_device_ready(encoder);
@@ -1226,8 +1234,18 @@ void intel_dsi_init(struct drm_device *dev)
 
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
-	return;
+	/*
+	 * Pipe parameter is not used for BXT.
+	 * Passing INVALID_PIPE to adher to API requirement.
+	 */
+	if (IS_BROXTON(dev))
+		intel_panel_setup_backlight(connector, INVALID_PIPE);
+	else
+		intel_panel_setup_backlight(connector,
+			intel_encoder->crtc_mask == (1 << PIPE_A) ?
+					PIPE_A : PIPE_B);
 
+	return;
 err:
 	drm_encoder_cleanup(&intel_encoder->base);
 	kfree(intel_dsi);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#67 lore raw

Re: [BXT MIPI PATCH v4 14/14] drm/i915: Added BXT DSI backlight support

Quoted 61 lines · Uma Shankar

DSI backlight support for bxt is added.

TODO: There is no support for backlight control in drm panel
framework. This will be added as part of VBT version patches fixing the backlight sequence.

v2: Fixed Jani's review comments from previous patch. Added the
BXT DSI backlight code in this patch. Backlight setup and enable/disable code for backlight is added in intel_dsi.c.

v3: Rebased on latest drm-nightly. Fixed Jani's review comments.

v4: Making backlight calls generic as per Jani's suggestion.

---
 drivers/gpu/drm/i915/intel_dsi.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dsi.c +8 -1
index 08bade2..3e7f796 100644
@@ -438,6 +438,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	enum port port;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +459,9 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 
 		intel_dsi_port_enable(encoder);
 	}
+
+	msleep(intel_dsi->backlight_on_delay);
+	intel_panel_enable_backlight(intel_connector);
 }
 
 static void intel_dsi_pre_enable(struct intel_encoder *encoder)
@@ -623,10 +627,14 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
 
+	intel_panel_disable_backlight(intel_connector);
+	msleep(intel_dsi->backlight_off_delay);
+
 	intel_dsi_disable(encoder);
 
 	intel_dsi_clear_device_ready(encoder);
@@ -1226,8 +1234,18 @@ void intel_dsi_init(struct drm_device *dev)
 
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
-	return;

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 1246

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi.c +10 -0
+	/*
+	 * Pipe parameter is not used for BXT.
+	 * Passing INVALID_PIPE to adher to API requirement.
+	 */
+	if (IS_BROXTON(dev))
+		intel_panel_setup_backlight(connector, INVALID_PIPE);
+	else
+		intel_panel_setup_backlight(connector,
+			intel_encoder->crtc_mask == (1 << PIPE_A) ?
+					PIPE_A : PIPE_B);

Is this aganst some ancient kernel version? We have backlight calls in the dsi code already.

Quoted 12 lines
drivers/gpu/drm/i915/intel_dsi.c +1 -0
+	return;
 err:
 	drm_encoder_cleanup(&intel_encoder->base);
 	kfree(intel_dsi);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#68 lore raw

Re: [BXT MIPI PATCH v4 14/14] drm/i915: Added BXT DSI backlight support

Quoted 76 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, September 24, 2015 10:29 PM
To: Shankar, Uma
Cc: [email protected]; Kumar, Shobhit
Subject: Re: [Intel-gfx] [BXT MIPI PATCH v4 14/14] drm/i915: Added BXT DSI backlight support

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_enable(struct intel_encoder

Quoted 25 lines · Uma Shankar

DSI backlight support for bxt is added.

TODO: There is no support for backlight control in drm panel
framework. This will be added as part of VBT version patches fixing the backlight sequence.

v2: Fixed Jani's review comments from previous patch. Added the
BXT DSI backlight code in this patch. Backlight setup and enable/disable code for backlight is added in intel_dsi.c.

v3: Rebased on latest drm-nightly. Fixed Jani's review comments.

v4: Making backlight calls generic as per Jani's suggestion.

---
 drivers/gpu/drm/i915/intel_dsi.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dsi.c +0 -0
index 08bade2..3e7f796 100644
@@ -438,6 +438,7 @@ static void intel_dsi_enable(struct intel_encoder

*encoder)

Quoted 39 lines
drivers/gpu/drm/i915/intel_dsi.c +5 -0
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector =
+intel_dsi->attached_connector;
 	enum port port;
 
 	DRM_DEBUG_KMS("\n");
@@ -458,6 +459,9 @@ static void intel_dsi_enable(struct intel_encoder
 *encoder)
 
 		intel_dsi_port_enable(encoder);
 	}
+
+	msleep(intel_dsi->backlight_on_delay);
+	intel_panel_enable_backlight(intel_connector);
 }
 

static void intel_dsi_pre_enable(struct intel_encoder *encoder) @@
-623,10 +627,14 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder) {

drivers/gpu/drm/i915/intel_dsi.c +5 -0
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	struct intel_connector *intel_connector =
+intel_dsi->attached_connector;
 	u32 val;
 
 	DRM_DEBUG_KMS("\n");
 
+	intel_panel_disable_backlight(intel_connector);
+	msleep(intel_dsi->backlight_off_delay);
+
 	intel_dsi_disable(encoder);
 
 	intel_dsi_clear_device_ready(encoder);
@@ -1226,8 +1234,18 @@ void intel_dsi_init(struct drm_device *dev)
 
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
Quoted 15 lines

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 1246

Quoted 11 lines
drivers/gpu/drm/i915/intel_dsi.c +10 -1
-	return;
+	/*
+	 * Pipe parameter is not used for BXT.
+	 * Passing INVALID_PIPE to adher to API requirement.
+	 */
+	if (IS_BROXTON(dev))
+		intel_panel_setup_backlight(connector, INVALID_PIPE);
+	else
+		intel_panel_setup_backlight(connector,
+			intel_encoder->crtc_mask == (1 << PIPE_A) ?
+					PIPE_A : PIPE_B);

Is this aganst some ancient kernel version? We have backlight calls in the dsi code already.

This support is added recently with Shobhit's "backlight control using CRC PMIC Based PWM driver" series. This seems to be merged last week. We can drop this patch, as it is already taken care in nightly branch.

Regards,
Uma Shankar

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi.c +1 -1
+	return;
 err:
 	drm_encoder_cleanup(&intel_encoder->base);
 	kfree(intel_dsi);
--

1.7.9.5

Quoted 8 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Ville Syrjälä
Intel OTC

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx