Skip to contentSkip to conversation

Enable lspcon support for GEN9 devices

PATCH Superseded Shashank Sharma 3 participants 17 messages Jun 21, 2016 – Jul 2, 2016

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover Enable lspcon support for GEN9 devices

LSPCON is essencially a dp++->hdmi adaptor with dual mode of operation.

These modes are:
- Level Shifter mode: In LS mode, this device works as a type2 dp->hdmi passive dongle, which steps up DP++ output to appropriate HDMI 1.4 signal. This mode doesn't do any conversion at the protocol level.

- Protocol Converter mode: In PCON mode, this device acts as an active DP++->HDMI 2.0 dongle, which converts the DP++ output to compatible HDMI 2.0 output. In PCON mode, lspcon can support 4k@60 outputs, using DP HBR2 mode.

Many of Intel GEN9 devices come with in-built lspcon card in motherboartd down mode. This patch series adds support for lspcon devices in I915 driver.

While unit-testing this code, I was able to see a 4k@60 modeset with:
- BXT-T board
- Single HDMI 4k@60 display (ACER S)
- Ubuntu 14.04 desktop

V2: Worked on review comments from Ville
- In general, Ville suggested not to use the dual personality of DDI to drive lspcon, so this patch set drives it just as DP++ display. There is no separate detection for lspcon (hpd_pulse is good enough), and its being driven as a DP display with special initialization and EDID read sequence. To be able to do this, we driving lspcon in PCON mode only, where it can serve both HDMI1.3/HDMI1.4 sinks as well as 4k@60 capable HDMI 2.0 sinks. So compared to previous series, there is one patch less, as we have dropped lspcon detection patch.

Shashank Sharma (4):
drm: Helper for lspcon in drm_dp_dual_mode
drm/i915: Add lspcon support for I915 driver
drm/i915: Parse VBT data for lspcon
drm/i915: Enable lspcon initialization

 drivers/gpu/drm/drm_dp_dual_mode_helper.c | 103 +++++++++++++++++++++
 drivers/gpu/drm/i915/Makefile             |   1 +
 drivers/gpu/drm/i915/i915_drv.h           |   3 +
 drivers/gpu/drm/i915/intel_bios.c         |  49 ++++++++++
 drivers/gpu/drm/i915/intel_ddi.c          |  29 +++++-
 drivers/gpu/drm/i915/intel_drv.h          |  13 ++-
 drivers/gpu/drm/i915/intel_lspcon.c       | 145 ++++++++++++++++++++++++++++++
 include/drm/drm_dp_dual_mode_helper.h     |  25 ++++++
 8 files changed, 366 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lspcon.c
Signature · 6 lines
1.9.1

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

PATCH v2 1/4 drm: Helper for lspcon in drm_dp_dual_mode

This patch adds lspcon support in dp_dual_mode helper. lspcon is essentially a dp->hdmi dongle with dual personality.

LS mode: It works as a passive dongle, by level shifting DP++ signals to HDMI signals, in LS mode.
PCON mode: It works as a protocol converter active dongle in pcon mode, by converting DP++ outputs to HDMI 2.0 outputs.

This patch adds support for lspcon detection and mode set switch operations, as a dp dual mode dongle.

v2: Addressed review comments from Ville
- add adaptor id for lspcon devices (0x08), use it to identify lspcon
- change function names
old: drm_lspcon_get_current_mode/drm_lspcon_change_mode
new: drm_lspcon_get_mode/drm_lspcon_set_mode
- change drm_lspcon_get_mode type to int, to match drm_dp_dual_mode_get_tmds_output
- change 'err' to 'ret' to match the rest of the functions
- remove pointless typecasting during call to dual_mode_read
- fix the but while setting value of data, while writing lspcon mode
- fix indentation
- change mdelay(10) -> msleep(10)
- return ETIMEDOUT instead of EFAULT, when lspcon mode change times out
- Add an empty line to separate std regs macros and lspcon regs macros Indent bit definition

---
 drivers/gpu/drm/drm_dp_dual_mode_helper.c | 103 ++++++++++++++++++++++++++++++
 include/drm/drm_dp_dual_mode_helper.h     |  25 ++++++++
 2 files changed, 128 insertions(+)
drivers/gpu/drm/drm_dp_dual_mode_helper.c +103 -0
index a7b2a75..404e715 100644
@@ -148,6 +148,14 @@ static bool is_type2_adaptor(uint8_t adaptor_id)
 			      DP_DUAL_MODE_REV_TYPE2);
 }
 
+bool is_lspcon_adaptor(const char hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN],
+	const uint8_t adaptor_id)
+{
+	return is_hdmi_adaptor(hdmi_id) &&
+		(adaptor_id == (DP_DUAL_MODE_REV_TYPE2 |
+			DP_DUAL_MODE_TYPE_TYPE2 | DP_DUAL_MODE_TYPE_LSPCON));
+}
+
 /**
  * drm_dp_dual_mode_detect - Identify the DP dual mode adaptor
  * @adapter: I2C adapter for the DDC bus
@@ -203,6 +211,8 @@ enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter *adapter)
 	ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_ADAPTOR_ID,
 				    &adaptor_id, sizeof(adaptor_id));
 	if (ret == 0) {
+		if (is_lspcon_adaptor(hdmi_id, adaptor_id))
+			return DRM_DP_DUAL_MODE_LSPCON;
 		if (is_type2_adaptor(adaptor_id)) {
 			if (is_hdmi_adaptor(hdmi_id))
 				return DRM_DP_DUAL_MODE_TYPE2_HDMI;
@@ -364,3 +374,96 @@ const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type)
 	}
 }
 EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
+
+/**
+ * drm_lspcon_get_current_mode: Get LSPCON's current mode of operation by
+ * by reading offset (0x80, 0x41)
+ * @i2c_adapter: I2C-over-aux adapter
+ * @current_mode: out vaiable, current lspcon mode of operation
+ *
+ * Returns:
+ * 0 on success, sets the current_mode value to appropriate mode
+ * -error on failure
+ */
+int drm_lspcon_get_mode(struct i2c_adapter *adapter,
+	enum drm_lspcon_mode *current_mode)
+{
+	u8 data;
+	int ret = 0;
+
+	if (!current_mode) {
+		DRM_ERROR("NULL input\n");
+		return -EINVAL;
+	}
+
+	/* Read Status: i2c over aux */
+	ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_CURRENT_MODE,
+			(void *)&data, sizeof(data));
+	if (ret < 0) {
+		DRM_ERROR("LSPCON read(0x80, 0x41) failed\n");
+		return -EFAULT;
+	}
+
+	if (data & DP_DUAL_MODE_LSPCON_MODE_MASK)
+		*current_mode = DRM_LSPCON_MODE_PCON;
+	else
+		*current_mode = DRM_LSPCON_MODE_LS;
+	return 0;
+}
+EXPORT_SYMBOL(drm_lspcon_get_mode);
+
+/**
+ * drm_lspcon_change_mode: Change LSPCON's mode of operation by
+ * by writing offset (0x80, 0x40)
+ * @i2c_adapter: I2C-over-aux adapter
+ * @reqd_mode: required mode of operation
+ *
+ * Returns:
+ * 0 on success, -error on failure/timeout
+ */
+int drm_lspcon_set_mode(struct i2c_adapter *adapter,
+	enum drm_lspcon_mode reqd_mode)
+{
+	u8 data = 0;
+	int ret;
+	int time_out = 200;
+	enum drm_lspcon_mode changed_mode;
+
+	if (reqd_mode == DRM_LSPCON_MODE_PCON)
+		data = DP_DUAL_MODE_LSPCON_MODE_MASK;
+
+	/* Change mode */
+	ret = drm_dp_dual_mode_write(adapter, DP_DUAL_MODE_LSPCON_MODE_CHANGE,
+			&data, sizeof(data));
+	if (ret < 0) {
+		DRM_ERROR("LSPCON mode change failed\n");
+		return ret;
+	}
+
+	/*
+	  * Confirm mode change by reading the status bit.
+	  * Sometimes, it takes a while to change the mode,
+	  * so wait and retry until time out or done.
+	  */
+	do {
+		ret = drm_lspcon_get_mode(adapter, &changed_mode);
+		if (ret) {
+			DRM_ERROR("cant confirm LSPCON mode change\n");
+			return ret;
+		} else {
+			if (changed_mode != reqd_mode) {
+				msleep(10);
+				time_out -= 10;
+			} else {
+				DRM_DEBUG_KMS("LSPCON mode changed to %s\n",
+					reqd_mode == DRM_LSPCON_MODE_LS ?
+						"LS" : "PCON");
+				return 0;
+			}
+		}
+	} while (time_out);
+
+	DRM_ERROR("LSPCON mode change timed out\n");
+	return -ETIMEDOUT;
+}
+EXPORT_SYMBOL(drm_lspcon_set_mode);
include/drm/drm_dp_dual_mode_helper.h +25 -0
index e8a9dfd..441c6cb 100644
@@ -24,6 +24,7 @@
 #define DRM_DP_DUAL_MODE_HELPER_H
 
 #include <linux/types.h>
+#include <drm/drm_edid.h>
 
 /*
  * Optional for type 1 DVI adaptors
@@ -40,6 +41,7 @@
 #define  DP_DUAL_MODE_REV_TYPE2 0x00
 #define  DP_DUAL_MODE_TYPE_MASK 0xf0
 #define  DP_DUAL_MODE_TYPE_TYPE2 0xa0
+#define  DP_DUAL_MODE_TYPE_LSPCON 0x08
 #define DP_DUAL_MODE_IEEE_OUI 0x11 /* 11-13*/
 #define  DP_DUAL_IEEE_OUI_LEN 3
 #define DP_DUAL_DEVICE_ID 0x14 /* 14-19 */
@@ -55,6 +57,10 @@
 #define  DP_DUAL_MODE_CEC_ENABLE 0x01
 #define DP_DUAL_MODE_I2C_SPEED_CTRL 0x22
 
+#define DP_DUAL_MODE_LSPCON_MODE_CHANGE		0x40
+#define DP_DUAL_MODE_LSPCON_CURRENT_MODE		0x41
+#define  DP_DUAL_MODE_LSPCON_MODE_MASK			0x1
+
 struct i2c_adapter;
 
 ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
@@ -63,6 +69,19 @@ ssize_t drm_dp_dual_mode_write(struct i2c_adapter *adapter,
 			       u8 offset, const void *buffer, size_t size);
 
 /**
+* enum drm_lspcon_mode
+* @lspcon_mode_ls: Level shifter mode of LSPCON
+*	which drives DP++ to HDMI 1.4 conversion.
+* @lspcon_mode_pcon: Protocol converter mode of LSPCON
+*	which drives DP++ to HDMI 2.0 active conversion.
+*/
+enum drm_lspcon_mode {
+	DRM_LSPCON_MODE_INVALID,
+	DRM_LSPCON_MODE_LS,
+	DRM_LSPCON_MODE_PCON,
+};
+
+/**
  * enum drm_dp_dual_mode_type - Type of the DP dual mode adaptor
  * @DRM_DP_DUAL_MODE_NONE: No DP dual mode adaptor
  * @DRM_DP_DUAL_MODE_UNKNOWN: Could be either none or type 1 DVI adaptor
@@ -70,6 +89,7 @@ ssize_t drm_dp_dual_mode_write(struct i2c_adapter *adapter,
  * @DRM_DP_DUAL_MODE_TYPE1_HDMI: Type 1 HDMI adaptor
  * @DRM_DP_DUAL_MODE_TYPE2_DVI: Type 2 DVI adaptor
  * @DRM_DP_DUAL_MODE_TYPE2_HDMI: Type 2 HDMI adaptor
+ * @DRM_DP_DUAL_MODE_TYPE2_LSPCON: Level shifter /protocol converter
  */
 enum drm_dp_dual_mode_type {
 	DRM_DP_DUAL_MODE_NONE,
@@ -78,6 +98,7 @@ enum drm_dp_dual_mode_type {
 	DRM_DP_DUAL_MODE_TYPE1_HDMI,
 	DRM_DP_DUAL_MODE_TYPE2_DVI,
 	DRM_DP_DUAL_MODE_TYPE2_HDMI,
+	DRM_DP_DUAL_MODE_LSPCON,
 };
 
 enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter *adapter);
@@ -89,4 +110,8 @@ int drm_dp_dual_mode_set_tmds_output(enum drm_dp_dual_mode_type type,
 				     struct i2c_adapter *adapter, bool enable);
 const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type);
 
+int drm_lspcon_get_mode(struct i2c_adapter *adapter,
+	enum drm_lspcon_mode *current_mode);
+int drm_lspcon_set_mode(struct i2c_adapter *adapter,
+		enum drm_lspcon_mode reqd_mode);
 #endif
Signature · 6 lines
1.9.1

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

Re: [PATCH v2 1/4] drm: Helper for lspcon in drm_dp_dual_mode

Quoted 38 lines · Shashank Sharma

This patch adds lspcon support in dp_dual_mode helper. lspcon is essentially a dp->hdmi dongle with dual personality.

LS mode: It works as a passive dongle, by level shifting DP++ signals to HDMI signals, in LS mode.
PCON mode: It works as a protocol converter active dongle in pcon mode, by converting DP++ outputs to HDMI 2.0 outputs.

This patch adds support for lspcon detection and mode set switch operations, as a dp dual mode dongle.

v2: Addressed review comments from Ville
- add adaptor id for lspcon devices (0x08), use it to identify lspcon
- change function names
old: drm_lspcon_get_current_mode/drm_lspcon_change_mode
new: drm_lspcon_get_mode/drm_lspcon_set_mode
- change drm_lspcon_get_mode type to int, to match drm_dp_dual_mode_get_tmds_output
- change 'err' to 'ret' to match the rest of the functions
- remove pointless typecasting during call to dual_mode_read
- fix the but while setting value of data, while writing lspcon mode
- fix indentation
- change mdelay(10) -> msleep(10)
- return ETIMEDOUT instead of EFAULT, when lspcon mode change times out
- Add an empty line to separate std regs macros and lspcon regs macros Indent bit definition

---
 drivers/gpu/drm/drm_dp_dual_mode_helper.c | 103 ++++++++++++++++++++++++++++++
 include/drm/drm_dp_dual_mode_helper.h     |  25 ++++++++
 2 files changed, 128 insertions(+)
drivers/gpu/drm/drm_dp_dual_mode_helper.c +0 -0
index a7b2a75..404e715 100644

drivers/gpu/drm/drm_dp_dual_mode_helper.c static bool is_type2_adaptor(uint8_t adaptor_id) · line 155

Quoted 8 lines
drivers/gpu/drm/drm_dp_dual_mode_helper.c +5 -0
@@ -148,6 +148,14 @@ static bool is_type2_adaptor(uint8_t adaptor_id)
                              DP_DUAL_MODE_REV_TYPE2);
 }
 
+bool is_lspcon_adaptor(const char hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN],
+       const uint8_t adaptor_id)
+{
+       return is_hdmi_adaptor(hdmi_id) &&
+               (adaptor_id == (DP_DUAL_MODE_REV_TYPE2 |

DP_DUAL_MODE_REV_TYPE2 = 0 so useless here and confusing.

drivers/gpu/drm/drm_dp_dual_mode_helper.c static bool is_type2_adaptor(uint8_t adaptor_id) · line 156

Quoted 1 line
drivers/gpu/drm/drm_dp_dual_mode_helper.c +1 -0
+                       DP_DUAL_MODE_TYPE_TYPE2 | DP_DUAL_MODE_TYPE_LSPCON));

Also this is confusing and took me a while to uderstand that LSPCON is the type2 with DPCD

so my suggestion is to define DP_DUAL_MODE_TYPE_HAS_DPCD (1<<3) with a comment this is defined by LSPCON docs since this is not part of VESA DP Dual Mode that only defines the Type2 = 0xA0.

so you could use
TYPE2 | HAS_DPCD = LSPCON.

Quoted 133 lines
drivers/gpu/drm/drm_dp_dual_mode_helper.c +97 -0
+}
+
 /**
  * drm_dp_dual_mode_detect - Identify the DP dual mode adaptor
  * @adapter: I2C adapter for the DDC bus
@@ -203,6 +211,8 @@ enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter *adapter)
        ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_ADAPTOR_ID,
                                    &adaptor_id, sizeof(adaptor_id));
        if (ret == 0) {
+               if (is_lspcon_adaptor(hdmi_id, adaptor_id))
+                       return DRM_DP_DUAL_MODE_LSPCON;
                if (is_type2_adaptor(adaptor_id)) {
                        if (is_hdmi_adaptor(hdmi_id))
                                return DRM_DP_DUAL_MODE_TYPE2_HDMI;
@@ -364,3 +374,96 @@ const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type)
        }
 }
 EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
+
+/**
+ * drm_lspcon_get_current_mode: Get LSPCON's current mode of operation by
+ * by reading offset (0x80, 0x41)
+ * @i2c_adapter: I2C-over-aux adapter
+ * @current_mode: out vaiable, current lspcon mode of operation
+ *
+ * Returns:
+ * 0 on success, sets the current_mode value to appropriate mode
+ * -error on failure
+ */
+int drm_lspcon_get_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode *current_mode)
+{
+       u8 data;
+       int ret = 0;
+
+       if (!current_mode) {
+               DRM_ERROR("NULL input\n");
+               return -EINVAL;
+       }
+
+       /* Read Status: i2c over aux */
+       ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_CURRENT_MODE,
+                       (void *)&data, sizeof(data));
+       if (ret < 0) {
+               DRM_ERROR("LSPCON read(0x80, 0x41) failed\n");
+               return -EFAULT;
+       }
 
+
+       if (data & DP_DUAL_MODE_LSPCON_MODE_MASK)
+               *current_mode = DRM_LSPCON_MODE_PCON;
+       else
+               *current_mode = DRM_LSPCON_MODE_LS;
+       return 0;
+}
+EXPORT_SYMBOL(drm_lspcon_get_mode);
+
+/**
+ * drm_lspcon_change_mode: Change LSPCON's mode of operation by
+ * by writing offset (0x80, 0x40)
+ * @i2c_adapter: I2C-over-aux adapter
+ * @reqd_mode: required mode of operation
+ *
+ * Returns:
+ * 0 on success, -error on failure/timeout
+ */
+int drm_lspcon_set_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode reqd_mode)
+{
+       u8 data = 0;
+       int ret;
+       int time_out = 200;
+       enum drm_lspcon_mode changed_mode;
+
+       if (reqd_mode == DRM_LSPCON_MODE_PCON)
+               data = DP_DUAL_MODE_LSPCON_MODE_MASK;
+
+       /* Change mode */
+       ret = drm_dp_dual_mode_write(adapter, DP_DUAL_MODE_LSPCON_MODE_CHANGE,
+                       &data, sizeof(data));
+       if (ret < 0) {
+               DRM_ERROR("LSPCON mode change failed\n");
+               return ret;
+       }
+
+       /*
+         * Confirm mode change by reading the status bit.
+         * Sometimes, it takes a while to change the mode,
+         * so wait and retry until time out or done.
+         */
+       do {
+               ret = drm_lspcon_get_mode(adapter, &changed_mode);
+               if (ret) {
+                       DRM_ERROR("cant confirm LSPCON mode change\n");
+                       return ret;
+               } else {
+                       if (changed_mode != reqd_mode) {
+                               msleep(10);
+                               time_out -= 10;
+                       } else {
+                               DRM_DEBUG_KMS("LSPCON mode changed to %s\n",
+                                       reqd_mode == DRM_LSPCON_MODE_LS ?
+                                               "LS" : "PCON");
+                               return 0;
+                       }
+               }
+       } while (time_out);
+
+       DRM_ERROR("LSPCON mode change timed out\n");
+       return -ETIMEDOUT;
+}
+EXPORT_SYMBOL(drm_lspcon_set_mode);
include/drm/drm_dp_dual_mode_helper.h +2 -0
index e8a9dfd..441c6cb 100644
@@ -24,6 +24,7 @@
 #define DRM_DP_DUAL_MODE_HELPER_H
 
 #include <linux/types.h>
+#include <drm/drm_edid.h>
 
 /*
  * Optional for type 1 DVI adaptors
@@ -40,6 +41,7 @@
 #define  DP_DUAL_MODE_REV_TYPE2 0x00
 #define  DP_DUAL_MODE_TYPE_MASK 0xf0
 #define  DP_DUAL_MODE_TYPE_TYPE2 0xa0
+#define  DP_DUAL_MODE_TYPE_LSPCON 0x08
 #define DP_DUAL_MODE_IEEE_OUI 0x11 /* 11-13*/
 #define  DP_DUAL_IEEE_OUI_LEN 3
 #define DP_DUAL_DEVICE_ID 0x14 /* 14-19 */

include/drm/drm_dp_dual_mode_helper.h line 61

Quoted 5 lines
include/drm/drm_dp_dual_mode_helper.h +2 -0
@@ -55,6 +57,10 @@
 #define  DP_DUAL_MODE_CEC_ENABLE 0x01
 #define DP_DUAL_MODE_I2C_SPEED_CTRL 0x22
 
+#define DP_DUAL_MODE_LSPCON_MODE_CHANGE                0x40
+#define DP_DUAL_MODE_LSPCON_CURRENT_MODE               0x41

Where did you get this from? I haven't seen any offset 80, adress 41 defined anywhere in any of the docs I have here. What am I missing?

include/drm/drm_dp_dual_mode_helper.h line 62

Quoted 1 line
include/drm/drm_dp_dual_mode_helper.h +1 -0
+#define  DP_DUAL_MODE_LSPCON_MODE_MASK                 0x1

I don't believe "mask" is a good term here....

probably
DP_DUAL_MODE_LSPCON_MODE_PCON (1<<0)

Quoted 56 lines
include/drm/drm_dp_dual_mode_helper.h +20 -1
+
 struct i2c_adapter;
 
 ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
@@ -63,6 +69,19 @@ ssize_t drm_dp_dual_mode_write(struct i2c_adapter *adapter,
                               u8 offset, const void *buffer, size_t size);
 
 /**
+* enum drm_lspcon_mode
+* @lspcon_mode_ls: Level shifter mode of LSPCON
+*      which drives DP++ to HDMI 1.4 conversion.
+* @lspcon_mode_pcon: Protocol converter mode of LSPCON
+*      which drives DP++ to HDMI 2.0 active conversion.
+*/
+enum drm_lspcon_mode {
+       DRM_LSPCON_MODE_INVALID,
+       DRM_LSPCON_MODE_LS,
+       DRM_LSPCON_MODE_PCON,
+};
+
+/**
  * enum drm_dp_dual_mode_type - Type of the DP dual mode adaptor
  * @DRM_DP_DUAL_MODE_NONE: No DP dual mode adaptor
  * @DRM_DP_DUAL_MODE_UNKNOWN: Could be either none or type 1 DVI adaptor
@@ -70,6 +89,7 @@ ssize_t drm_dp_dual_mode_write(struct i2c_adapter *adapter,
  * @DRM_DP_DUAL_MODE_TYPE1_HDMI: Type 1 HDMI adaptor
  * @DRM_DP_DUAL_MODE_TYPE2_DVI: Type 2 DVI adaptor
  * @DRM_DP_DUAL_MODE_TYPE2_HDMI: Type 2 HDMI adaptor
+ * @DRM_DP_DUAL_MODE_TYPE2_LSPCON: Level shifter /protocol converter
  */
 enum drm_dp_dual_mode_type {
        DRM_DP_DUAL_MODE_NONE,
@@ -78,6 +98,7 @@ enum drm_dp_dual_mode_type {
        DRM_DP_DUAL_MODE_TYPE1_HDMI,
        DRM_DP_DUAL_MODE_TYPE2_DVI,
        DRM_DP_DUAL_MODE_TYPE2_HDMI,
+       DRM_DP_DUAL_MODE_LSPCON,
 };
 
 enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter *adapter);
@@ -89,4 +110,8 @@ int drm_dp_dual_mode_set_tmds_output(enum drm_dp_dual_mode_type type,
                                     struct i2c_adapter *adapter, bool enable);
 const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type);
 
+int drm_lspcon_get_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode *current_mode);
+int drm_lspcon_set_mode(struct i2c_adapter *adapter,
+               enum drm_lspcon_mode reqd_mode);
 #endif
--

1.9.1

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

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH v2 1/4] drm: Helper for lspcon in drm_dp_dual_mode

Thanks for the review Rodrigo. My comments inline.

Regards
Shashank

Quoted 43 lines · Rodrigo Vivi
Quoted 41 lines · Shashank Sharma

This patch adds lspcon support in dp_dual_mode helper. lspcon is essentially a dp->hdmi dongle with dual personality.

LS mode: It works as a passive dongle, by level shifting DP++ signals to HDMI signals, in LS mode.
PCON mode: It works as a protocol converter active dongle in pcon mode, by converting DP++ outputs to HDMI 2.0 outputs.

This patch adds support for lspcon detection and mode set switch operations, as a dp dual mode dongle.

v2: Addressed review comments from Ville
- add adaptor id for lspcon devices (0x08), use it to identify lspcon
- change function names
old: drm_lspcon_get_current_mode/drm_lspcon_change_mode
new: drm_lspcon_get_mode/drm_lspcon_set_mode
- change drm_lspcon_get_mode type to int, to match drm_dp_dual_mode_get_tmds_output
- change 'err' to 'ret' to match the rest of the functions
- remove pointless typecasting during call to dual_mode_read
- fix the but while setting value of data, while writing lspcon mode
- fix indentation
- change mdelay(10) -> msleep(10)
- return ETIMEDOUT instead of EFAULT, when lspcon mode change times out
- Add an empty line to separate std regs macros and lspcon regs macros Indent bit definition

---
  drivers/gpu/drm/drm_dp_dual_mode_helper.c | 103 ++++++++++++++++++++++++++++++
  include/drm/drm_dp_dual_mode_helper.h     |  25 ++++++++
  2 files changed, 128 insertions(+)
drivers/gpu/drm/drm_dp_dual_mode_helper.c +0 -0
index a7b2a75..404e715 100644
@@ -148,6 +148,14 @@ static bool is_type2_adaptor(uint8_t adaptor_id)
                               DP_DUAL_MODE_REV_TYPE2);
  }
 
Quoted 7 lines

drivers/gpu/drm/drm_dp_dual_mode_helper.c static bool is_type2_adaptor(uint8_t adaptor_id) · line 155

Quoted 5 lines
drivers/gpu/drm/drm_dp_dual_mode_helper.c +5 -0
+bool is_lspcon_adaptor(const char hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN],
+       const uint8_t adaptor_id)
+{
+       return is_hdmi_adaptor(hdmi_id) &&
+               (adaptor_id == (DP_DUAL_MODE_REV_TYPE2 |

DP_DUAL_MODE_REV_TYPE2 = 0 so useless here and confusing.

This was a review comment from Ville, on the last patch. I think he suggested for the better readability of the code.

Quoted 5 lines

drivers/gpu/drm/drm_dp_dual_mode_helper.c static bool is_type2_adaptor(uint8_t adaptor_id) · line 156

Quoted 2 lines
drivers/gpu/drm/drm_dp_dual_mode_helper.c +1 -0
+                       DP_DUAL_MODE_TYPE_TYPE2 | DP_DUAL_MODE_TYPE_LSPCON));

Also this is confusing and took me a while to uderstand that LSPCON is the type2 with DPCD

I know, due to LSPCON's dual personality, its complicated to understand. I tried to cover some theory, in the cover letter, can add some here too:
LSPCON is a dp->hdmi adapter which can operate in two modes
Passive dongle mode / LS mode: in this mode, it acts as type2 dp dual mode adapter (no DPCD readable here)
Active mode / PCON mode: in this mode, it acts as active DP++->HDMI2.0 protocol convertor dongle, and allows DPCD read/write like a DP++ display.

Quoted 8 lines

so my suggestion is to define DP_DUAL_MODE_TYPE_HAS_DPCD (1<<3) with a comment this is defined by LSPCON docs since this is not part of VESA DP Dual Mode that only defines the Type2 = 0xA0.

so you could use
TYPE2 | HAS_DPCD = LSPCON.

Sure, got it. Will change it like this.

Quoted 136 lines
Quoted 136 lines
drivers/gpu/drm/drm_dp_dual_mode_helper.c +97 -0
+}
+
  /**
   * drm_dp_dual_mode_detect - Identify the DP dual mode adaptor
   * @adapter: I2C adapter for the DDC bus
@@ -203,6 +211,8 @@ enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter *adapter)
         ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_ADAPTOR_ID,
                                     &adaptor_id, sizeof(adaptor_id));
         if (ret == 0) {
+               if (is_lspcon_adaptor(hdmi_id, adaptor_id))
+                       return DRM_DP_DUAL_MODE_LSPCON;
                 if (is_type2_adaptor(adaptor_id)) {
                         if (is_hdmi_adaptor(hdmi_id))
                                 return DRM_DP_DUAL_MODE_TYPE2_HDMI;
@@ -364,3 +374,96 @@ const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type)
         }
  }
  EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
+
+/**
+ * drm_lspcon_get_current_mode: Get LSPCON's current mode of operation by
+ * by reading offset (0x80, 0x41)
+ * @i2c_adapter: I2C-over-aux adapter
+ * @current_mode: out vaiable, current lspcon mode of operation
+ *
+ * Returns:
+ * 0 on success, sets the current_mode value to appropriate mode
+ * -error on failure
+ */
+int drm_lspcon_get_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode *current_mode)
+{
+       u8 data;
+       int ret = 0;
+
+       if (!current_mode) {
+               DRM_ERROR("NULL input\n");
+               return -EINVAL;
+       }
+
+       /* Read Status: i2c over aux */
+       ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_CURRENT_MODE,
+                       (void *)&data, sizeof(data));
+       if (ret < 0) {
+               DRM_ERROR("LSPCON read(0x80, 0x41) failed\n");
+               return -EFAULT;
+       }
 
+
+       if (data & DP_DUAL_MODE_LSPCON_MODE_MASK)
+               *current_mode = DRM_LSPCON_MODE_PCON;
+       else
+               *current_mode = DRM_LSPCON_MODE_LS;
+       return 0;
+}
+EXPORT_SYMBOL(drm_lspcon_get_mode);
+
+/**
+ * drm_lspcon_change_mode: Change LSPCON's mode of operation by
+ * by writing offset (0x80, 0x40)
+ * @i2c_adapter: I2C-over-aux adapter
+ * @reqd_mode: required mode of operation
+ *
+ * Returns:
+ * 0 on success, -error on failure/timeout
+ */
+int drm_lspcon_set_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode reqd_mode)
+{
+       u8 data = 0;
+       int ret;
+       int time_out = 200;
+       enum drm_lspcon_mode changed_mode;
+
+       if (reqd_mode == DRM_LSPCON_MODE_PCON)
+               data = DP_DUAL_MODE_LSPCON_MODE_MASK;
+
+       /* Change mode */
+       ret = drm_dp_dual_mode_write(adapter, DP_DUAL_MODE_LSPCON_MODE_CHANGE,
+                       &data, sizeof(data));
+       if (ret < 0) {
+               DRM_ERROR("LSPCON mode change failed\n");
+               return ret;
+       }
+
+       /*
+         * Confirm mode change by reading the status bit.
+         * Sometimes, it takes a while to change the mode,
+         * so wait and retry until time out or done.
+         */
+       do {
+               ret = drm_lspcon_get_mode(adapter, &changed_mode);
+               if (ret) {
+                       DRM_ERROR("cant confirm LSPCON mode change\n");
+                       return ret;
+               } else {
+                       if (changed_mode != reqd_mode) {
+                               msleep(10);
+                               time_out -= 10;
+                       } else {
+                               DRM_DEBUG_KMS("LSPCON mode changed to %s\n",
+                                       reqd_mode == DRM_LSPCON_MODE_LS ?
+                                               "LS" : "PCON");
+                               return 0;
+                       }
+               }
+       } while (time_out);
+
+       DRM_ERROR("LSPCON mode change timed out\n");
+       return -ETIMEDOUT;
+}
+EXPORT_SYMBOL(drm_lspcon_set_mode);
include/drm/drm_dp_dual_mode_helper.h +2 -0
index e8a9dfd..441c6cb 100644
@@ -24,6 +24,7 @@
  #define DRM_DP_DUAL_MODE_HELPER_H
 
  #include <linux/types.h>
+#include <drm/drm_edid.h>
 
  /*
   * Optional for type 1 DVI adaptors
@@ -40,6 +41,7 @@
  #define  DP_DUAL_MODE_REV_TYPE2 0x00
  #define  DP_DUAL_MODE_TYPE_MASK 0xf0
  #define  DP_DUAL_MODE_TYPE_TYPE2 0xa0
+#define  DP_DUAL_MODE_TYPE_LSPCON 0x08
  #define DP_DUAL_MODE_IEEE_OUI 0x11 /* 11-13*/
  #define  DP_DUAL_IEEE_OUI_LEN 3
  #define DP_DUAL_DEVICE_ID 0x14 /* 14-19 */
@@ -55,6 +57,10 @@
  #define  DP_DUAL_MODE_CEC_ENABLE 0x01
  #define DP_DUAL_MODE_I2C_SPEED_CTRL 0x22
 
Quoted 6 lines

include/drm/drm_dp_dual_mode_helper.h line 61

Quoted 2 lines
include/drm/drm_dp_dual_mode_helper.h +2 -0
+#define DP_DUAL_MODE_LSPCON_MODE_CHANGE                0x40
+#define DP_DUAL_MODE_LSPCON_CURRENT_MODE               0x41

Where did you get this from? I haven't seen any offset 80, adress 41 defined anywhere in any of the docs I have here. What am I missing?

This offset was added by MCA after Intel requested them to confirm the LSPCON modeset success. Initially they gave us just 0x40, which is to request a change in mode from LS->PCON or other way. But we saw many times this change was not happening, so Intel requested MCA to have another register offset (0x41) to confirm the current LSPCON mode. I dont have an updated MCA doc on this, but I can arrange if you insist on this.

Quoted 6 lines

include/drm/drm_dp_dual_mode_helper.h line 62

Quoted 1 line
include/drm/drm_dp_dual_mode_helper.h +1 -0
+#define  DP_DUAL_MODE_LSPCON_MODE_MASK                 0x1

I don't believe "mask" is a good term here....

probably
DP_DUAL_MODE_LSPCON_MODE_PCON (1<<0)

Agree, will change it to something as you suggested

Shashank

Quoted 53 lines
Quoted 53 lines
include/drm/drm_dp_dual_mode_helper.h +20 -1
+
  struct i2c_adapter;
 
  ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
@@ -63,6 +69,19 @@ ssize_t drm_dp_dual_mode_write(struct i2c_adapter *adapter,
                                u8 offset, const void *buffer, size_t size);
 
  /**
+* enum drm_lspcon_mode
+* @lspcon_mode_ls: Level shifter mode of LSPCON
+*      which drives DP++ to HDMI 1.4 conversion.
+* @lspcon_mode_pcon: Protocol converter mode of LSPCON
+*      which drives DP++ to HDMI 2.0 active conversion.
+*/
+enum drm_lspcon_mode {
+       DRM_LSPCON_MODE_INVALID,
+       DRM_LSPCON_MODE_LS,
+       DRM_LSPCON_MODE_PCON,
+};
+
+/**
   * enum drm_dp_dual_mode_type - Type of the DP dual mode adaptor
   * @DRM_DP_DUAL_MODE_NONE: No DP dual mode adaptor
   * @DRM_DP_DUAL_MODE_UNKNOWN: Could be either none or type 1 DVI adaptor
@@ -70,6 +89,7 @@ ssize_t drm_dp_dual_mode_write(struct i2c_adapter *adapter,
   * @DRM_DP_DUAL_MODE_TYPE1_HDMI: Type 1 HDMI adaptor
   * @DRM_DP_DUAL_MODE_TYPE2_DVI: Type 2 DVI adaptor
   * @DRM_DP_DUAL_MODE_TYPE2_HDMI: Type 2 HDMI adaptor
+ * @DRM_DP_DUAL_MODE_TYPE2_LSPCON: Level shifter /protocol converter
   */
  enum drm_dp_dual_mode_type {
         DRM_DP_DUAL_MODE_NONE,
@@ -78,6 +98,7 @@ enum drm_dp_dual_mode_type {
         DRM_DP_DUAL_MODE_TYPE1_HDMI,
         DRM_DP_DUAL_MODE_TYPE2_DVI,
         DRM_DP_DUAL_MODE_TYPE2_HDMI,
+       DRM_DP_DUAL_MODE_LSPCON,
  };
 
  enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter *adapter);
@@ -89,4 +110,8 @@ int drm_dp_dual_mode_set_tmds_output(enum drm_dp_dual_mode_type type,
                                      struct i2c_adapter *adapter, bool enable);
  const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type);
 
+int drm_lspcon_get_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode *current_mode);
+int drm_lspcon_set_mode(struct i2c_adapter *adapter,
+               enum drm_lspcon_mode reqd_mode);
  #endif
--

1.9.1

Quoted 7 lines
Quoted 4 lines

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

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

#4 lore raw

Re: [PATCH v2 1/4] drm: Helper for lspcon in drm_dp_dual_mode

Quoted 243 lines · Shashank

Thanks for the review Rodrigo. My comments inline.

Regards
Shashank

Quoted 47 lines · Rodrigo Vivi
Quoted 44 lines · Shashank Sharma

This patch adds lspcon support in dp_dual_mode helper. lspcon is essentially a dp->hdmi dongle with dual personality.

LS mode: It works as a passive dongle, by level shifting DP++ signals to HDMI signals, in LS mode.
PCON mode: It works as a protocol converter active dongle in pcon mode, by converting DP++ outputs to HDMI 2.0 outputs.

This patch adds support for lspcon detection and mode set switch operations, as a dp dual mode dongle.

v2: Addressed review comments from Ville
- add adaptor id for lspcon devices (0x08), use it to identify lspcon
- change function names
old: drm_lspcon_get_current_mode/drm_lspcon_change_mode
new: drm_lspcon_get_mode/drm_lspcon_set_mode
- change drm_lspcon_get_mode type to int, to match drm_dp_dual_mode_get_tmds_output
- change 'err' to 'ret' to match the rest of the functions
- remove pointless typecasting during call to dual_mode_read
- fix the but while setting value of data, while writing lspcon mode
- fix indentation
- change mdelay(10) -> msleep(10)
- return ETIMEDOUT instead of EFAULT, when lspcon mode change times out
- Add an empty line to separate std regs macros and lspcon regs macros Indent bit definition

---
  drivers/gpu/drm/drm_dp_dual_mode_helper.c | 103
++++++++++++++++++++++++++++++
  include/drm/drm_dp_dual_mode_helper.h     |  25 ++++++++
  2 files changed, 128 insertions(+)
drivers/gpu/drm/drm_dp_dual_mode_helper.c +0 -0
index a7b2a75..404e715 100644
@@ -148,6 +148,14 @@ static bool is_type2_adaptor(uint8_t adaptor_id)
                               DP_DUAL_MODE_REV_TYPE2);
  }
 
Quoted 8 lines

drivers/gpu/drm/drm_dp_dual_mode_helper.c static bool is_type2_adaptor(uint8_t adaptor_id) · line 155

Quoted 5 lines
drivers/gpu/drm/drm_dp_dual_mode_helper.c +5 -0
+bool is_lspcon_adaptor(const char hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN],
+       const uint8_t adaptor_id)
+{
+       return is_hdmi_adaptor(hdmi_id) &&
+               (adaptor_id == (DP_DUAL_MODE_REV_TYPE2 |

DP_DUAL_MODE_REV_TYPE2 = 0 so useless here and confusing.

This was a review comment from Ville, on the last patch. I think he suggested for the better readability of the code.

Quoted 8 lines

drivers/gpu/drm/drm_dp_dual_mode_helper.c static bool is_type2_adaptor(uint8_t adaptor_id) · line 157

Quoted 4 lines
drivers/gpu/drm/drm_dp_dual_mode_helper.c +1 -0
+                       DP_DUAL_MODE_TYPE_TYPE2 |
 DP_DUAL_MODE_TYPE_LSPCON));

Also this is confusing and took me a while to uderstand that LSPCON is the type2 with DPCD

I know, due to LSPCON's dual personality, its complicated to understand. I tried to cover some theory, in the cover letter, can add some here too:
LSPCON is a dp->hdmi adapter which can operate in two modes Passive dongle mode / LS mode: in this mode, it acts as type2 dp dual mode adapter (no DPCD readable here)
Active mode / PCON mode: in this mode, it acts as active DP++->HDMI2.0 protocol convertor dongle, and allows DPCD read/write like a DP++ display.

Quoted 9 lines

so my suggestion is to define DP_DUAL_MODE_TYPE_HAS_DPCD (1<<3) with a comment this is defined by LSPCON docs since this is not part of VESA DP Dual Mode that only defines the Type2 = 0xA0.

so you could use
TYPE2 | HAS_DPCD = LSPCON.

Sure, got it. Will change it like this.

Quoted 144 lines
Quoted 144 lines
drivers/gpu/drm/drm_dp_dual_mode_helper.c +2 -0
+}
+
  /**
   * drm_dp_dual_mode_detect - Identify the DP dual mode adaptor

* @adapter: I2C adapter for the DDC bus

drivers/gpu/drm/drm_dp_dual_mode_helper.c +2 -0
@@ -203,6 +211,8 @@ enum drm_dp_dual_mode_type
 drm_dp_dual_mode_detect(struct i2c_adapter *adapter)
         ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_ADAPTOR_ID,
                                     &adaptor_id, sizeof(adaptor_id));
         if (ret == 0) {
+               if (is_lspcon_adaptor(hdmi_id, adaptor_id))
+                       return DRM_DP_DUAL_MODE_LSPCON;
                 if (is_type2_adaptor(adaptor_id)) {
                         if (is_hdmi_adaptor(hdmi_id))
                                 return DRM_DP_DUAL_MODE_TYPE2_HDMI;
drivers/gpu/drm/drm_dp_dual_mode_helper.c +3 -0
@@ -364,3 +374,96 @@ const char *drm_dp_get_dual_mode_type_name(enum
 drm_dp_dual_mode_type type)
         }
  }
  EXPORT_SYMBOL(drm_dp_get_dual_mode_type_name);
+
+/**
+ * drm_lspcon_get_current_mode: Get LSPCON's current mode of operation

by
+ * by reading offset (0x80, 0x41)
+ * @i2c_adapter: I2C-over-aux adapter
+ * @current_mode: out vaiable, current lspcon mode of operation
+ *
+ * Returns:
+ * 0 on success, sets the current_mode value to appropriate mode
+ * -error on failure
+ */

drivers/gpu/drm/drm_dp_dual_mode_helper.c +13 -0
+int drm_lspcon_get_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode *current_mode)
+{
+       u8 data;
+       int ret = 0;
+
+       if (!current_mode) {
+               DRM_ERROR("NULL input\n");
+               return -EINVAL;
+       }
+
+       /* Read Status: i2c over aux */
+       ret = drm_dp_dual_mode_read(adapter,

DP_DUAL_MODE_LSPCON_CURRENT_MODE,

drivers/gpu/drm/drm_dp_dual_mode_helper.c +36 -0
+                       (void *)&data, sizeof(data));
+       if (ret < 0) {
+               DRM_ERROR("LSPCON read(0x80, 0x41) failed\n");
+               return -EFAULT;
+       }
 
 
+
+       if (data & DP_DUAL_MODE_LSPCON_MODE_MASK)
+               *current_mode = DRM_LSPCON_MODE_PCON;
+       else
+               *current_mode = DRM_LSPCON_MODE_LS;
+       return 0;
+}
+EXPORT_SYMBOL(drm_lspcon_get_mode);
+
+/**
+ * drm_lspcon_change_mode: Change LSPCON's mode of operation by
+ * by writing offset (0x80, 0x40)
+ * @i2c_adapter: I2C-over-aux adapter
+ * @reqd_mode: required mode of operation
+ *
+ * Returns:
+ * 0 on success, -error on failure/timeout
+ */
+int drm_lspcon_set_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode reqd_mode)
+{
+       u8 data = 0;
+       int ret;
+       int time_out = 200;
+       enum drm_lspcon_mode changed_mode;
+
+       if (reqd_mode == DRM_LSPCON_MODE_PCON)
+               data = DP_DUAL_MODE_LSPCON_MODE_MASK;
+
+       /* Change mode */
+       ret = drm_dp_dual_mode_write(adapter,

DP_DUAL_MODE_LSPCON_MODE_CHANGE,

drivers/gpu/drm/drm_dp_dual_mode_helper.c +22 -0
+                       &data, sizeof(data));
+       if (ret < 0) {
+               DRM_ERROR("LSPCON mode change failed\n");
+               return ret;
+       }
+
+       /*
+         * Confirm mode change by reading the status bit.
+         * Sometimes, it takes a while to change the mode,
+         * so wait and retry until time out or done.
+         */
+       do {
+               ret = drm_lspcon_get_mode(adapter, &changed_mode);
+               if (ret) {
+                       DRM_ERROR("cant confirm LSPCON mode change\n");
+                       return ret;
+               } else {
+                       if (changed_mode != reqd_mode) {
+                               msleep(10);
+                               time_out -= 10;
+                       } else {
+                               DRM_DEBUG_KMS("LSPCON mode changed to

%s\n",

drivers/gpu/drm/drm_dp_dual_mode_helper.c +11 -0
+                                       reqd_mode == DRM_LSPCON_MODE_LS ?
+                                               "LS" : "PCON");
+                               return 0;
+                       }
+               }
+       } while (time_out);
+
+       DRM_ERROR("LSPCON mode change timed out\n");
+       return -ETIMEDOUT;
+}
+EXPORT_SYMBOL(drm_lspcon_set_mode);
include/drm/drm_dp_dual_mode_helper.h +2 -0
index e8a9dfd..441c6cb 100644
@@ -24,6 +24,7 @@
  #define DRM_DP_DUAL_MODE_HELPER_H
 
  #include <linux/types.h>
+#include <drm/drm_edid.h>
 
  /*
   * Optional for type 1 DVI adaptors
@@ -40,6 +41,7 @@
  #define  DP_DUAL_MODE_REV_TYPE2 0x00
  #define  DP_DUAL_MODE_TYPE_MASK 0xf0
  #define  DP_DUAL_MODE_TYPE_TYPE2 0xa0
+#define  DP_DUAL_MODE_TYPE_LSPCON 0x08
  #define DP_DUAL_MODE_IEEE_OUI 0x11 /* 11-13*/
  #define  DP_DUAL_IEEE_OUI_LEN 3
  #define DP_DUAL_DEVICE_ID 0x14 /* 14-19 */
@@ -55,6 +57,10 @@
  #define  DP_DUAL_MODE_CEC_ENABLE 0x01
  #define DP_DUAL_MODE_I2C_SPEED_CTRL 0x22
 
Quoted 7 lines

include/drm/drm_dp_dual_mode_helper.h line 61

Quoted 2 lines
include/drm/drm_dp_dual_mode_helper.h +2 -0
+#define DP_DUAL_MODE_LSPCON_MODE_CHANGE                0x40
+#define DP_DUAL_MODE_LSPCON_CURRENT_MODE               0x41

Where did you get this from? I haven't seen any offset 80, adress 41 defined anywhere in any of the docs I have here. What am I missing?

Quoted 7 lines

This offset was added by MCA after Intel requested them to confirm the LSPCON modeset success. Initially they gave us just 0x40, which is to request a change in mode from LS->PCON or other way. But we saw many times this change was not happening, so Intel requested MCA to have another register offset (0x41) to confirm the current LSPCON mode.
I dont have an updated MCA doc on this, but I can arrange if you insist on this.

No, I won't insist. I take your world, but I believe it worth a comment in the code explaining it in case some future reader find the old spec we have.

Quoted 83 lines
Quoted 8 lines

include/drm/drm_dp_dual_mode_helper.h line 62

Quoted 2 lines
include/drm/drm_dp_dual_mode_helper.h +1 -0
+#define  DP_DUAL_MODE_LSPCON_MODE_MASK                 0x1

I don't believe "mask" is a good term here....

probably
DP_DUAL_MODE_LSPCON_MODE_PCON (1<<0)

Agree, will change it to something as you suggested

Shashank

Quoted 69 lines
Quoted 65 lines
include/drm/drm_dp_dual_mode_helper.h +14 -0
+
  struct i2c_adapter;
 
  ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
@@ -63,6 +69,19 @@ ssize_t drm_dp_dual_mode_write(struct i2c_adapter
 *adapter,
                                u8 offset, const void *buffer, size_t
 size);
 
  /**
+* enum drm_lspcon_mode
+* @lspcon_mode_ls: Level shifter mode of LSPCON
+*      which drives DP++ to HDMI 1.4 conversion.
+* @lspcon_mode_pcon: Protocol converter mode of LSPCON
+*      which drives DP++ to HDMI 2.0 active conversion.
+*/
+enum drm_lspcon_mode {
+       DRM_LSPCON_MODE_INVALID,
+       DRM_LSPCON_MODE_LS,
+       DRM_LSPCON_MODE_PCON,
+};
+
+/**
   * enum drm_dp_dual_mode_type - Type of the DP dual mode adaptor

* @DRM_DP_DUAL_MODE_NONE: No DP dual mode adaptor
* @DRM_DP_DUAL_MODE_UNKNOWN: Could be either none or type 1 DVI
adaptor

include/drm/drm_dp_dual_mode_helper.h +1 -0
@@ -70,6 +89,7 @@ ssize_t drm_dp_dual_mode_write(struct i2c_adapter
 *adapter,
   * @DRM_DP_DUAL_MODE_TYPE1_HDMI: Type 1 HDMI adaptor
   * @DRM_DP_DUAL_MODE_TYPE2_DVI: Type 2 DVI adaptor
   * @DRM_DP_DUAL_MODE_TYPE2_HDMI: Type 2 HDMI adaptor
+ * @DRM_DP_DUAL_MODE_TYPE2_LSPCON: Level shifter /protocol converter
   */
  enum drm_dp_dual_mode_type {

DRM_DP_DUAL_MODE_NONE,

include/drm/drm_dp_dual_mode_helper.h +1 -0
@@ -78,6 +98,7 @@ enum drm_dp_dual_mode_type {
         DRM_DP_DUAL_MODE_TYPE1_HDMI,
         DRM_DP_DUAL_MODE_TYPE2_DVI,
         DRM_DP_DUAL_MODE_TYPE2_HDMI,
+       DRM_DP_DUAL_MODE_LSPCON,
  };
 
  enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter

*adapter);

include/drm/drm_dp_dual_mode_helper.h +0 -0
@@ -89,4 +110,8 @@ int drm_dp_dual_mode_set_tmds_output(enum
 drm_dp_dual_mode_type type,
                                      struct i2c_adapter *adapter, bool
 enable);
  const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type

type);

include/drm/drm_dp_dual_mode_helper.h +4 -1
+int drm_lspcon_get_mode(struct i2c_adapter *adapter,
+       enum drm_lspcon_mode *current_mode);
+int drm_lspcon_set_mode(struct i2c_adapter *adapter,
+               enum drm_lspcon_mode reqd_mode);
  #endif
--

1.9.1

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

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH v2 2/4 drm/i915: Add lspcon support for I915 driver

In reply to Shashank Sharma

This patch adds a new file, to accommodate lspcon support for I915 driver. These functions probe, detect, initialize and configure an on-board lspcon device during the driver init time.

Also, this patch adds a small structure for lspcon device, which will provide the runtime status of the device.

V2: addressed ville's review comments
- Clean the leftover macros from previous patch set

---
 drivers/gpu/drm/i915/Makefile       |   1 +
 drivers/gpu/drm/i915/intel_drv.h    |  13 +++-
 drivers/gpu/drm/i915/intel_lspcon.c | 145 ++++++++++++++++++++++++++++++++++++
 3 files changed, 158 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lspcon.c
drivers/gpu/drm/i915/Makefile +1 -0
index 276abf1..d40ff7d 100644
@@ -93,6 +93,7 @@ i915-y += dvo_ch7017.o \
 	  intel_dvo.o \
 	  intel_hdmi.o \
 	  intel_i2c.o \
+	  intel_lspcon.o \
 	  intel_lvds.o \
 	  intel_panel.o \
 	  intel_sdvo.o \
drivers/gpu/drm/i915/intel_drv.h +12 -1
index 7d0e071..4e49c16 100644
@@ -894,12 +894,19 @@ struct intel_dp {
 	bool compliance_test_active;
 };
 
+struct intel_lspcon {
+	bool active;
+	enum drm_lspcon_mode mode_of_op;
+	struct drm_dp_aux *aux;
+};
+
 struct intel_digital_port {
 	struct intel_encoder base;
 	enum port port;
 	u32 saved_port_bits;
 	struct intel_dp dp;
 	struct intel_hdmi hdmi;
+	struct intel_lspcon lspcon;
 	enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
 	bool release_cl2_override;
 	uint8_t max_lanes;
@@ -1450,7 +1457,6 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
 			       struct intel_crtc_state *pipe_config);
 void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable);
 
-
 /* intel_lvds.c */
 void intel_lvds_init(struct drm_device *dev);
 bool intel_is_dual_link_lvds(struct drm_device *dev);
@@ -1745,4 +1751,9 @@ int intel_color_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
 void intel_color_set_csc(struct drm_crtc_state *crtc_state);
 void intel_color_load_luts(struct drm_crtc_state *crtc_state);
 
+/* intel_lspcon.c */
+bool lspcon_init(struct intel_digital_port *intel_dig_port);
+enum drm_connector_status
+lspcon_ls_mode_detect(struct drm_connector *connector, bool force);
+bool is_lspcon_active(struct intel_digital_port *dig_port);
 #endif /* __INTEL_DRV_H__ */
drivers/gpu/drm/i915/intel_lspcon.c new file +145 -0

145 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

Re: [PATCH v2 2/4] drm/i915: Add lspcon support for I915 driver

Quoted 99 lines · Shashank Sharma

This patch adds a new file, to accommodate lspcon support for I915 driver. These functions probe, detect, initialize and configure an on-board lspcon device during the driver init time.

Also, this patch adds a small structure for lspcon device, which will provide the runtime status of the device.

V2: addressed ville's review comments
- Clean the leftover macros from previous patch set

---
 drivers/gpu/drm/i915/Makefile       |   1 +
 drivers/gpu/drm/i915/intel_drv.h    |  13 +++-
 drivers/gpu/drm/i915/intel_lspcon.c | 145 ++++++++++++++++++++++++++++++++++++
 3 files changed, 158 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lspcon.c
drivers/gpu/drm/i915/Makefile +1 -0
index 276abf1..d40ff7d 100644
@@ -93,6 +93,7 @@ i915-y += dvo_ch7017.o \
          intel_dvo.o \
          intel_hdmi.o \
          intel_i2c.o \
+         intel_lspcon.o \
          intel_lvds.o \
          intel_panel.o \
          intel_sdvo.o \
drivers/gpu/drm/i915/intel_drv.h +12 -1
index 7d0e071..4e49c16 100644
@@ -894,12 +894,19 @@ struct intel_dp {
        bool compliance_test_active;
 };
 
+struct intel_lspcon {
+       bool active;
+       enum drm_lspcon_mode mode_of_op;
+       struct drm_dp_aux *aux;
+};
+
 struct intel_digital_port {
        struct intel_encoder base;
        enum port port;
        u32 saved_port_bits;
        struct intel_dp dp;
        struct intel_hdmi hdmi;
+       struct intel_lspcon lspcon;
        enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
        bool release_cl2_override;
        uint8_t max_lanes;
@@ -1450,7 +1457,6 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
                               struct intel_crtc_state *pipe_config);
 void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable);
 
-
 /* intel_lvds.c */
 void intel_lvds_init(struct drm_device *dev);
 bool intel_is_dual_link_lvds(struct drm_device *dev);
@@ -1745,4 +1751,9 @@ int intel_color_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
 void intel_color_set_csc(struct drm_crtc_state *crtc_state);
 void intel_color_load_luts(struct drm_crtc_state *crtc_state);
 
+/* intel_lspcon.c */
+bool lspcon_init(struct intel_digital_port *intel_dig_port);
+enum drm_connector_status
+lspcon_ls_mode_detect(struct drm_connector *connector, bool force);
+bool is_lspcon_active(struct intel_digital_port *dig_port);
 #endif /* __INTEL_DRV_H__ */
drivers/gpu/drm/i915/intel_lspcon.c new file +19 -0
new file mode 100644
index 0000000..fdeff71
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

drivers/gpu/drm/i915/intel_lspcon.c line 29

Quoted 10 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +10 -0
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *
+ */
+#include <drm/drm_edid.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_dual_mode_helper.h>
+#include "intel_drv.h"
+

Does this new file worth/deserves/needs a Docbook?

Quoted 23 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +23 -0
+bool is_lspcon_active(struct intel_digital_port *dig_port)
+{
+       return dig_port->lspcon.active;
+}
+
+enum drm_lspcon_mode lspcon_get_current_mode(struct intel_lspcon *lspcon)
+{
+       enum drm_lspcon_mode current_mode = DRM_LSPCON_MODE_INVALID;
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       if (drm_lspcon_get_mode(adapter, &current_mode))
+               DRM_ERROR("Error reading LSPCON mode\n");
+       else
+               DRM_DEBUG_KMS("Current LSPCON mode %s\n",
+                       current_mode == DRM_LSPCON_MODE_PCON ? "PCON" : "LS");
+       return current_mode;
+}
+
+int lspcon_change_mode(struct intel_lspcon *lspcon,
+       enum drm_lspcon_mode mode, bool force)
+{
+       int err;
+       enum drm_lspcon_mode current_mode;

drivers/gpu/drm/i915/intel_lspcon.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +10 -0
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       err = drm_lspcon_get_mode(adapter, &current_mode);
+       if (err) {
+               DRM_ERROR("Error reading LSPCON mode\n");
+               return err;
+       }
+
+       if (current_mode == mode && !force) {
+               DRM_DEBUG_KMS("Current mode = desired LSPCON mode\n");\

debug or error?
maybe print the desired mode here?

in case desired mode is useless to know and if it happens with frequency I'd believe we could skip the debug message and just move on...

Quoted 12 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +12 -0
+               return 0;
+       }
+
+       err = drm_lspcon_set_mode(adapter, mode);
+       if (err < 0) {
+               DRM_ERROR("LSPCON mode change failed\n");
+               return err;
+       }
+
+       lspcon->mode_of_op = mode;
+       DRM_DEBUG_KMS("LSPCON mode changed done\n");
+       return 0;

drivers/gpu/drm/i915/intel_lspcon.c line 84

Quoted 10 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +10 -0
+}
+
+bool lspcon_detect_identifier(struct intel_lspcon *lspcon)
+{
+       enum drm_dp_dual_mode_type adaptor_type;
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       /* Lets probe the adaptor and check its type */
+       adaptor_type = drm_dp_dual_mode_detect(adapter);
+       if (adaptor_type != DRM_DP_DUAL_MODE_LSPCON) {

shouldn't we do TYPE2 | bit3 here?

Quoted 40 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +40 -0
+               DRM_DEBUG_KMS("No LSPCON detected, found %s\n",
+                       drm_dp_get_dual_mode_type_name(adaptor_type));
+               return false;
+       }
+
+       /* Yay ... got a LSPCON device */
+       DRM_DEBUG_KMS("LSPCON detected\n");
+       return true;
+}
+
+enum drm_lspcon_mode lspcon_probe(struct intel_lspcon *lspcon)
+{
+
+       /* Detect a valid lspcon adaptor */
+       if (!lspcon_detect_identifier(lspcon)) {
+               DRM_DEBUG_KMS("No LSPCON identifier found\n");
+               return false;
+       }
+
+       /* Get LSPCON's mode of operation */
+       lspcon->mode_of_op = lspcon_get_current_mode(lspcon);
+       lspcon->active = true;
+       return true;
+}
+
+bool lspcon_init(struct intel_digital_port *intel_dig_port)
+{
+       struct intel_dp *dp = &intel_dig_port->dp;
+       struct intel_lspcon *lspcon = &intel_dig_port->lspcon;
+       struct drm_device *dev = intel_dig_port->base.base.dev;
+
+       if (!IS_GEN9(dev)) {
+               DRM_ERROR("LSPCON is supported on GEN9 only\n");
+               return false;
+       }
+
+       lspcon->active = false;
+       lspcon->mode_of_op = DRM_LSPCON_MODE_INVALID;
+       lspcon->aux = &dp->aux;
+

drivers/gpu/drm/i915/intel_lspcon.c line 134

Quoted 10 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +10 -0
+       if (!lspcon_probe(lspcon)) {
+               DRM_ERROR("Failed to probe lspcon\n");
+               return false;
+       }
+
+       /*
+       * In the SW state machine, lets Put LSPCON in PCON mode only.
+       * In this way, it will work with both HDMI 1.4 sinks as well as HDMI
+       * 2.0 sinks.
+       */

Reading the specs seems to me that for HDMI 1.4 the LS is the recommended and for HDMI 2.0 the PCON is required... but I believe we don't have a way to determine that right?

Quoted 18 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +11 -1
+       if (lspcon->active && lspcon->mode_of_op != DRM_LSPCON_MODE_PCON) {
+               if (lspcon_change_mode(lspcon, DRM_LSPCON_MODE_PCON,
+                       true) < 0) {
+                       DRM_ERROR("LSPCON mode change to PCON failed\n");
+                       return false;
+               }
+       }
+
+       DRM_DEBUG_KMS("Success: LSPCON init\n");
+       return true;
+}
--

1.9.1

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

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

Re: [PATCH v2 2/4] drm/i915: Add lspcon support for I915 driver

Regards
Shashank

Quoted 105 lines · Rodrigo Vivi
Quoted 103 lines · Shashank Sharma

This patch adds a new file, to accommodate lspcon support for I915 driver. These functions probe, detect, initialize and configure an on-board lspcon device during the driver init time.

Also, this patch adds a small structure for lspcon device, which will provide the runtime status of the device.

V2: addressed ville's review comments
- Clean the leftover macros from previous patch set

---
  drivers/gpu/drm/i915/Makefile       |   1 +
  drivers/gpu/drm/i915/intel_drv.h    |  13 +++-
  drivers/gpu/drm/i915/intel_lspcon.c | 145 ++++++++++++++++++++++++++++++++++++
  3 files changed, 158 insertions(+), 1 deletion(-)

create mode 100644 drivers/gpu/drm/i915/intel_lspcon.c

drivers/gpu/drm/i915/Makefile +1 -0
index 276abf1..d40ff7d 100644
@@ -93,6 +93,7 @@ i915-y += dvo_ch7017.o \
           intel_dvo.o \
           intel_hdmi.o \
           intel_i2c.o \
+         intel_lspcon.o \
           intel_lvds.o \
           intel_panel.o \
           intel_sdvo.o \
drivers/gpu/drm/i915/intel_drv.h +12 -1
index 7d0e071..4e49c16 100644
@@ -894,12 +894,19 @@ struct intel_dp {
         bool compliance_test_active;
  };
 
+struct intel_lspcon {
+       bool active;
+       enum drm_lspcon_mode mode_of_op;
+       struct drm_dp_aux *aux;
+};
+
  struct intel_digital_port {
         struct intel_encoder base;
         enum port port;
         u32 saved_port_bits;
         struct intel_dp dp;
         struct intel_hdmi hdmi;
+       struct intel_lspcon lspcon;
         enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
         bool release_cl2_override;
         uint8_t max_lanes;
@@ -1450,7 +1457,6 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
                                struct intel_crtc_state *pipe_config);
  void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable);
 
-
  /* intel_lvds.c */
  void intel_lvds_init(struct drm_device *dev);
  bool intel_is_dual_link_lvds(struct drm_device *dev);
@@ -1745,4 +1751,9 @@ int intel_color_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
  void intel_color_set_csc(struct drm_crtc_state *crtc_state);
  void intel_color_load_luts(struct drm_crtc_state *crtc_state);
 
+/* intel_lspcon.c */
+bool lspcon_init(struct intel_digital_port *intel_dig_port);
+enum drm_connector_status
+lspcon_ls_mode_detect(struct drm_connector *connector, bool force);
+bool is_lspcon_active(struct intel_digital_port *dig_port);
  #endif /* __INTEL_DRV_H__ */
drivers/gpu/drm/i915/intel_lspcon.c new file +23 -0
new file mode 100644
index 0000000..fdeff71
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *
Quoted 8 lines

drivers/gpu/drm/i915/intel_lspcon.c line 29

Quoted 6 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +6 -0
+ */
+#include <drm/drm_edid.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_dual_mode_helper.h>
+#include "intel_drv.h"
+

Does this new file worth/deserves/needs a Docbook?

Its a wrapper over the drm_dp_dual_mode layer, where most of the job is being done. But if you suggest, I can make some documentation.

Quoted 38 lines
Quoted 24 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +23 -0
+bool is_lspcon_active(struct intel_digital_port *dig_port)
+{
+       return dig_port->lspcon.active;
+}
+
+enum drm_lspcon_mode lspcon_get_current_mode(struct intel_lspcon *lspcon)
+{
+       enum drm_lspcon_mode current_mode = DRM_LSPCON_MODE_INVALID;
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       if (drm_lspcon_get_mode(adapter, &current_mode))
+               DRM_ERROR("Error reading LSPCON mode\n");
+       else
+               DRM_DEBUG_KMS("Current LSPCON mode %s\n",
+                       current_mode == DRM_LSPCON_MODE_PCON ? "PCON" : "LS");
+       return current_mode;
+}
+
+int lspcon_change_mode(struct intel_lspcon *lspcon,
+       enum drm_lspcon_mode mode, bool force)
+{
+       int err;
+       enum drm_lspcon_mode current_mode;

drivers/gpu/drm/i915/intel_lspcon.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +10 -0
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       err = drm_lspcon_get_mode(adapter, &current_mode);
+       if (err) {
+               DRM_ERROR("Error reading LSPCON mode\n");
+               return err;
+       }
+
+       if (current_mode == mode && !force) {
+               DRM_DEBUG_KMS("Current mode = desired LSPCON mode\n");\

debug or error?
maybe print the desired mode here?

Quoted 3 lines

in case desired mode is useless to know and if it happens with frequency I'd believe we could skip the debug message and just move on...

Actually I was leaving scope for a long-term design, where an IOCTL is being given to the userspace, which can request a LS->PCON or PCON->LS mode, and in that case, it would be good to print this considering its a dumb IOCTL, do you think so ?

Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +16 -0
+               return 0;
+       }
+
+       err = drm_lspcon_set_mode(adapter, mode);
+       if (err < 0) {
+               DRM_ERROR("LSPCON mode change failed\n");
+               return err;
+       }
+
+       lspcon->mode_of_op = mode;
+       DRM_DEBUG_KMS("LSPCON mode changed done\n");
+       return 0;
+}
+
+bool lspcon_detect_identifier(struct intel_lspcon *lspcon)
+{
Quoted 9 lines

drivers/gpu/drm/i915/intel_lspcon.c line 84

Quoted 6 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +6 -0
+       enum drm_dp_dual_mode_type adaptor_type;
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       /* Lets probe the adaptor and check its type */
+       adaptor_type = drm_dp_dual_mode_detect(adapter);
+       if (adaptor_type != DRM_DP_DUAL_MODE_LSPCON) {

shouldn't we do TYPE2 | bit3 here?

I have added LSPCON detection case in drm_dp_dual_mode_detect() function, so it directly returns DRM_DP_DUAL_MODE_LSPCON when detected :).

Quoted 46 lines
Quoted 46 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +46 -0
+               DRM_DEBUG_KMS("No LSPCON detected, found %s\n",
+                       drm_dp_get_dual_mode_type_name(adaptor_type));
+               return false;
+       }
+
+       /* Yay ... got a LSPCON device */
+       DRM_DEBUG_KMS("LSPCON detected\n");
+       return true;
+}
+
+enum drm_lspcon_mode lspcon_probe(struct intel_lspcon *lspcon)
+{
+
+       /* Detect a valid lspcon adaptor */
+       if (!lspcon_detect_identifier(lspcon)) {
+               DRM_DEBUG_KMS("No LSPCON identifier found\n");
+               return false;
+       }
+
+       /* Get LSPCON's mode of operation */
+       lspcon->mode_of_op = lspcon_get_current_mode(lspcon);
+       lspcon->active = true;
+       return true;
+}
+
+bool lspcon_init(struct intel_digital_port *intel_dig_port)
+{
+       struct intel_dp *dp = &intel_dig_port->dp;
+       struct intel_lspcon *lspcon = &intel_dig_port->lspcon;
+       struct drm_device *dev = intel_dig_port->base.base.dev;
+
+       if (!IS_GEN9(dev)) {
+               DRM_ERROR("LSPCON is supported on GEN9 only\n");
+               return false;
+       }
+
+       lspcon->active = false;
+       lspcon->mode_of_op = DRM_LSPCON_MODE_INVALID;
+       lspcon->aux = &dp->aux;
+
+       if (!lspcon_probe(lspcon)) {
+               DRM_ERROR("Failed to probe lspcon\n");
+               return false;
+       }
+
+       /*
Quoted 9 lines

drivers/gpu/drm/i915/intel_lspcon.c line 134

Quoted 4 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +4 -0
+       * In the SW state machine, lets Put LSPCON in PCON mode only.
+       * In this way, it will work with both HDMI 1.4 sinks as well as HDMI
+       * 2.0 sinks.
+       */

Reading the specs seems to me that for HDMI 1.4 the LS is the recommended and for HDMI 2.0 the PCON is required... but I believe we don't have a way to determine that right?

If you remember the previous design, we were deciding the mode of operation, on the modeset, depending on the pixel clock (start in LS mode, if modeset->clock > 297M make it go on PCON, else keep in LS)

But this approach was causing few problems with previous design and code review suggestion, like:
- in this scenario, we needed to register dual connectors, one HDMI and one DP, and this was causing on extra detect to swicth between DP->HDMI
Also, ville suggested not to exploit DDI's dual connector personality anymore.
- second possibility was to create a new connector for LSPCON, and come up with all the functions for it. But Paulo thought there was too much code duplication there, which is making code unnecessary complex.
- If monitor is HDCP2.2 capable, you have to always be in PCON mode to handle HDCP handshaking.

So based on this history, learning from android products, and code review suggestions, I thought it would be very simple to have it always running in PCON mode, which is automatically backward compatible to HDMI 1.4 monitors.

Shashank

Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +11 -1
+       if (lspcon->active && lspcon->mode_of_op != DRM_LSPCON_MODE_PCON) {
+               if (lspcon_change_mode(lspcon, DRM_LSPCON_MODE_PCON,
+                       true) < 0) {
+                       DRM_ERROR("LSPCON mode change to PCON failed\n");
+                       return false;
+               }
+       }
+
+       DRM_DEBUG_KMS("Success: LSPCON init\n");
+       return true;
+}
--

1.9.1

Quoted 7 lines
Quoted 4 lines

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

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

Reviewed-by
#8 lore raw

Re: [PATCH v2 2/4] drm/i915: Add lspcon support for I915 driver

Quoted 140 lines · Shashank

Regards
Shashank

Quoted 126 lines · Rodrigo Vivi
Quoted 123 lines · Shashank Sharma

This patch adds a new file, to accommodate lspcon support for I915 driver. These functions probe, detect, initialize and configure an on-board lspcon device during the driver init time.

Also, this patch adds a small structure for lspcon device, which will provide the runtime status of the device.

V2: addressed ville's review comments
- Clean the leftover macros from previous patch set

---
  drivers/gpu/drm/i915/Makefile       |   1 +
  drivers/gpu/drm/i915/intel_drv.h    |  13 +++-
  drivers/gpu/drm/i915/intel_lspcon.c | 145
++++++++++++++++++++++++++++++++++++
  3 files changed, 158 insertions(+), 1 deletion(-)

create mode 100644 drivers/gpu/drm/i915/intel_lspcon.c

drivers/gpu/drm/i915/Makefile +1 -0
index 276abf1..d40ff7d 100644
@@ -93,6 +93,7 @@ i915-y += dvo_ch7017.o \
           intel_dvo.o \
           intel_hdmi.o \
           intel_i2c.o \
+         intel_lspcon.o \
           intel_lvds.o \
           intel_panel.o \
           intel_sdvo.o \
drivers/gpu/drm/i915/intel_drv.h +7 -1
index 7d0e071..4e49c16 100644
@@ -894,12 +894,19 @@ struct intel_dp {
         bool compliance_test_active;
  };
 
+struct intel_lspcon {
+       bool active;
+       enum drm_lspcon_mode mode_of_op;
+       struct drm_dp_aux *aux;
+};
+
  struct intel_digital_port {
         struct intel_encoder base;
         enum port port;
         u32 saved_port_bits;
         struct intel_dp dp;
         struct intel_hdmi hdmi;
+       struct intel_lspcon lspcon;
         enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
         bool release_cl2_override;
         uint8_t max_lanes;
@@ -1450,7 +1457,6 @@ bool intel_hdmi_compute_config(struct intel_encoder
 *encoder,
                                struct intel_crtc_state *pipe_config);
  void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool
 enable);
 
-
  /* intel_lvds.c */
  void intel_lvds_init(struct drm_device *dev);
  bool intel_is_dual_link_lvds(struct drm_device *dev);
drivers/gpu/drm/i915/intel_drv.h +5 -0
@@ -1745,4 +1751,9 @@ int intel_color_check(struct drm_crtc *crtc, struct
 drm_crtc_state *state);
  void intel_color_set_csc(struct drm_crtc_state *crtc_state);
  void intel_color_load_luts(struct drm_crtc_state *crtc_state);
 
+/* intel_lspcon.c */
+bool lspcon_init(struct intel_digital_port *intel_dig_port);
+enum drm_connector_status
+lspcon_ls_mode_detect(struct drm_connector *connector, bool force);
+bool is_lspcon_active(struct intel_digital_port *dig_port);
  #endif /* __INTEL_DRV_H__ */
drivers/gpu/drm/i915/intel_lspcon.c new file +4 -0
new file mode 100644
index 0000000..fdeff71
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining

a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *
+ */

Quoted 8 lines

drivers/gpu/drm/i915/intel_lspcon.c line 29

Quoted 5 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +5 -0
+#include <drm/drm_edid.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_dual_mode_helper.h>
+#include "intel_drv.h"
+

Does this new file worth/deserves/needs a Docbook?

Quoted 2 lines

Its a wrapper over the drm_dp_dual_mode layer, where most of the job is being done. But if you suggest, I can make some documentation.

you are right... there is where the interfaces matter although LSPCON we just have here for now.
Anyway no strong opinion from my part.

Quoted 42 lines
Quoted 42 lines
Quoted 27 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +6 -0
+bool is_lspcon_active(struct intel_digital_port *dig_port)
+{
+       return dig_port->lspcon.active;
+}
+
+enum drm_lspcon_mode lspcon_get_current_mode(struct intel_lspcon

*lspcon)

drivers/gpu/drm/i915/intel_lspcon.c new file +9 -0
+{
+       enum drm_lspcon_mode current_mode = DRM_LSPCON_MODE_INVALID;
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       if (drm_lspcon_get_mode(adapter, &current_mode))
+               DRM_ERROR("Error reading LSPCON mode\n");
+       else
+               DRM_DEBUG_KMS("Current LSPCON mode %s\n",
+                       current_mode == DRM_LSPCON_MODE_PCON ? "PCON" :

"LS");

drivers/gpu/drm/i915/intel_lspcon.c new file +8 -0
+       return current_mode;
+}
+
+int lspcon_change_mode(struct intel_lspcon *lspcon,
+       enum drm_lspcon_mode mode, bool force)
+{
+       int err;
+       enum drm_lspcon_mode current_mode;

drivers/gpu/drm/i915/intel_lspcon.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +10 -0
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       err = drm_lspcon_get_mode(adapter, &current_mode);
+       if (err) {
+               DRM_ERROR("Error reading LSPCON mode\n");
+               return err;
+       }
+
+       if (current_mode == mode && !force) {
+               DRM_DEBUG_KMS("Current mode = desired LSPCON mode\n");\

debug or error?
maybe print the desired mode here?

Quoted 8 lines
Quoted 3 lines

in case desired mode is useless to know and if it happens with frequency I'd believe we could skip the debug message and just move on...

Actually I was leaving scope for a long-term design, where an IOCTL is being given to the userspace, which can request a LS->PCON or PCON->LS mode, and in that case, it would be good to print this considering its a dumb IOCTL, do you think so ?

oh I see...
well, if setting with ioctl they probably know what they request right... so ignore me ;)

Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +17 -0
+               return 0;
+       }
+
+       err = drm_lspcon_set_mode(adapter, mode);
+       if (err < 0) {
+               DRM_ERROR("LSPCON mode change failed\n");
+               return err;
+       }
+
+       lspcon->mode_of_op = mode;
+       DRM_DEBUG_KMS("LSPCON mode changed done\n");
+       return 0;
+}
+
+bool lspcon_detect_identifier(struct intel_lspcon *lspcon)
+{
+       enum drm_dp_dual_mode_type adaptor_type;
Quoted 9 lines

drivers/gpu/drm/i915/intel_lspcon.c line 84

Quoted 5 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +5 -0
+       struct i2c_adapter *adapter = &lspcon->aux->ddc;
+
+       /* Lets probe the adaptor and check its type */
+       adaptor_type = drm_dp_dual_mode_detect(adapter);
+       if (adaptor_type != DRM_DP_DUAL_MODE_LSPCON) {

shouldn't we do TYPE2 | bit3 here?

Quoted 2 lines

I have added LSPCON detection case in drm_dp_dual_mode_detect() function, so it directly returns DRM_DP_DUAL_MODE_LSPCON when detected :).

Oh that is true.... now I got why you did the mode like this! ;)

Quoted 74 lines
Quoted 49 lines
Quoted 49 lines
drivers/gpu/drm/i915/intel_lspcon.c new file +48 -0
+               DRM_DEBUG_KMS("No LSPCON detected, found %s\n",
+                       drm_dp_get_dual_mode_type_name(adaptor_type));
+               return false;
+       }
+
+       /* Yay ... got a LSPCON device */
+       DRM_DEBUG_KMS("LSPCON detected\n");
+       return true;
+}
+
+enum drm_lspcon_mode lspcon_probe(struct intel_lspcon *lspcon)
+{
+
+       /* Detect a valid lspcon adaptor */
+       if (!lspcon_detect_identifier(lspcon)) {
+               DRM_DEBUG_KMS("No LSPCON identifier found\n");
+               return false;
+       }
+
+       /* Get LSPCON's mode of operation */
+       lspcon->mode_of_op = lspcon_get_current_mode(lspcon);
+       lspcon->active = true;
+       return true;
+}
+
+bool lspcon_init(struct intel_digital_port *intel_dig_port)
+{
+       struct intel_dp *dp = &intel_dig_port->dp;
+       struct intel_lspcon *lspcon = &intel_dig_port->lspcon;
+       struct drm_device *dev = intel_dig_port->base.base.dev;
+
+       if (!IS_GEN9(dev)) {
+               DRM_ERROR("LSPCON is supported on GEN9 only\n");
+               return false;
+       }
+
+       lspcon->active = false;
+       lspcon->mode_of_op = DRM_LSPCON_MODE_INVALID;
+       lspcon->aux = &dp->aux;
+
+       if (!lspcon_probe(lspcon)) {
+               DRM_ERROR("Failed to probe lspcon\n");
+               return false;
+       }
+
+       /*
+       * In the SW state machine, lets Put LSPCON in PCON mode only.
+       * In this way, it will work with both HDMI 1.4 sinks as well as
Quoted 9 lines

drivers/gpu/drm/i915/intel_lspcon.c line 134

Quoted 3 lines

HDMI

drivers/gpu/drm/i915/intel_lspcon.c new file +2 -0
+       * 2.0 sinks.
+       */

Reading the specs seems to me that for HDMI 1.4 the LS is the recommended and for HDMI 2.0 the PCON is required... but I believe we don't have a way to determine that right?

If you remember the previous design, we were deciding the mode of operation, on the modeset, depending on the pixel clock (start in LS mode, if modeset->clock > 297M make it go on PCON, else keep in LS)

But this approach was causing few problems with previous design and code review suggestion, like:
- in this scenario, we needed to register dual connectors, one HDMI and one DP, and this was causing on extra detect to swicth between DP->HDMI Also, ville suggested not to exploit DDI's dual connector personality anymore.
- second possibility was to create a new connector for LSPCON, and come up with all the functions for it. But Paulo thought there was too much code duplication there, which is making code unnecessary complex.
- If monitor is HDCP2.2 capable, you have to always be in PCON mode to handle HDCP handshaking.

Quoted 3 lines

So based on this history, learning from android products, and code review suggestions, I thought it would be very simple to have it always running in PCON mode, which is automatically backward compatible to HDMI 1.4 monitors.

if it falls back automatically I agree this is the best cleaner approach.

so, with or without the doc feel free to use:

Quoted 27 lines

Shashank

Quoted 23 lines
Quoted 19 lines

+ if (lspcon->active && lspcon->mode_of_op != DRM_LSPCON_MODE_PCON)
{

drivers/gpu/drm/i915/intel_lspcon.c new file +10 -1
+               if (lspcon_change_mode(lspcon, DRM_LSPCON_MODE_PCON,
+                       true) < 0) {
+                       DRM_ERROR("LSPCON mode change to PCON failed\n");
+                       return false;
+               }
+       }
+
+       DRM_DEBUG_KMS("Success: LSPCON init\n");
+       return true;
+}
--

1.9.1

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

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH v2 3/4 drm/i915: Parse VBT data for lspcon

In reply to Shashank Sharma

Many GEN9 boards come with on-board lspcon cards.
Fot these boards, VBT configuration should properly point out if a particular port contains lspcon device, so that driver can initialize it properly.

This patch adds a utility function, which checks the VBT flag for lspcon bit, and tells us if a port is configured to have a lspcon device or not.

V2: Fixed review comments from Ville
- Do not forget PORT_D while checking lspcon for GEN9

---
 drivers/gpu/drm/i915/i915_drv.h   |  3 +++
 drivers/gpu/drm/i915/intel_bios.c | 49 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 25ebe46..3719b81 100644
@@ -3671,6 +3671,9 @@ bool intel_bios_is_port_dp_dual_mode(struct drm_i915_private *dev_priv, enum por
 bool intel_bios_is_dsi_present(struct drm_i915_private *dev_priv, enum port *port);
 bool intel_bios_is_port_hpd_inverted(struct drm_i915_private *dev_priv,
 				     enum port port);
+bool intel_bios_is_lspcon_present(struct drm_i915_private *dev_priv,
+				enum port port);
+
 
 /* intel_opregion.c */
 #ifdef CONFIG_ACPI
drivers/gpu/drm/i915/intel_bios.c +49 -0

52 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

Re: [PATCH v2 3/4] drm/i915: Parse VBT data for lspcon

Quoted 46 lines · Shashank Sharma

Many GEN9 boards come with on-board lspcon cards.
Fot these boards, VBT configuration should properly point out if a particular port contains lspcon device, so that driver can initialize it properly.

This patch adds a utility function, which checks the VBT flag for lspcon bit, and tells us if a port is configured to have a lspcon device or not.

V2: Fixed review comments from Ville
- Do not forget PORT_D while checking lspcon for GEN9

---
 drivers/gpu/drm/i915/i915_drv.h   |  3 +++
 drivers/gpu/drm/i915/intel_bios.c | 49 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 25ebe46..3719b81 100644
@@ -3671,6 +3671,9 @@ bool intel_bios_is_port_dp_dual_mode(struct drm_i915_private *dev_priv, enum por
 bool intel_bios_is_dsi_present(struct drm_i915_private *dev_priv, enum port *port);
 bool intel_bios_is_port_hpd_inverted(struct drm_i915_private *dev_priv,
                                     enum port port);
+bool intel_bios_is_lspcon_present(struct drm_i915_private *dev_priv,
+                               enum port port);
+
 
 /* intel_opregion.c */
 #ifdef CONFIG_ACPI
drivers/gpu/drm/i915/intel_bios.c +6 -0
index da5ed4a..2b00c89 100644
@@ -1759,3 +1759,52 @@ intel_bios_is_port_hpd_inverted(struct drm_i915_private *dev_priv,
 
        return false;
 }
+
+/**
+ * intel_bios_is_lspcon_present - if LSPCON is attached on %port
+ * @dev_priv:  i915 device instance
+ * @port:      port to check
+ *

drivers/gpu/drm/i915/intel_bios.c intel_bios_is_port_hpd_inverted(struct drm_i915_private *dev_priv, · line 1777

Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.c +10 -0
+ * Return true if LSPCON is present on this port
+ */
+bool
+intel_bios_is_lspcon_present(struct drm_i915_private *dev_priv,
+                               enum port port)
+{
+       int i;
+
+       if (WARN_ON_ONCE(!IS_GEN9(dev_priv)))
+               return false;

This will cause noise on other platforms.

Also I'd prefer gen < 9 assuming next gens will inherit this support. Or also create a HAS_LSPCON on the platform definition and there use gen < 9.

Quoted 40 lines
drivers/gpu/drm/i915/intel_bios.c +33 -1
+
+       for (i = 0; i < dev_priv->vbt.child_dev_num; i++) {
+               if (!dev_priv->vbt.child_dev[i].common.lspcon)
+                       continue;
+
+               switch (dev_priv->vbt.child_dev[i].common.dvo_port) {
+               case DVO_PORT_DPA:
+               case DVO_PORT_HDMIA:
+                       if (port == PORT_A)
+                               return true;
+                       break;
+               case DVO_PORT_DPB:
+               case DVO_PORT_HDMIB:
+                       if (port == PORT_B)
+                               return true;
+                       break;
+               case DVO_PORT_DPC:
+               case DVO_PORT_HDMIC:
+                       if (port == PORT_C)
+                               return true;
+                       break;
+               case DVO_PORT_DPD:
+               case DVO_PORT_HDMID:
+                       if (port == PORT_D)
+                               return true;
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       return false;
+}
--

1.9.1

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

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

Re: [PATCH v2 3/4] drm/i915: Parse VBT data for lspcon

Regards
Shashank

Quoted 61 lines · Rodrigo Vivi
Quoted 46 lines · Shashank Sharma

Many GEN9 boards come with on-board lspcon cards.
Fot these boards, VBT configuration should properly point out if a particular port contains lspcon device, so that driver can initialize it properly.

This patch adds a utility function, which checks the VBT flag for lspcon bit, and tells us if a port is configured to have a lspcon device or not.

V2: Fixed review comments from Ville
- Do not forget PORT_D while checking lspcon for GEN9

---
  drivers/gpu/drm/i915/i915_drv.h   |  3 +++
  drivers/gpu/drm/i915/intel_bios.c | 49 +++++++++++++++++++++++++++++++++++++++
  2 files changed, 52 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 25ebe46..3719b81 100644
@@ -3671,6 +3671,9 @@ bool intel_bios_is_port_dp_dual_mode(struct drm_i915_private *dev_priv, enum por
  bool intel_bios_is_dsi_present(struct drm_i915_private *dev_priv, enum port *port);
  bool intel_bios_is_port_hpd_inverted(struct drm_i915_private *dev_priv,
                                      enum port port);
+bool intel_bios_is_lspcon_present(struct drm_i915_private *dev_priv,
+                               enum port port);
+
 
  /* intel_opregion.c */
  #ifdef CONFIG_ACPI
drivers/gpu/drm/i915/intel_bios.c +6 -0
index da5ed4a..2b00c89 100644
@@ -1759,3 +1759,52 @@ intel_bios_is_port_hpd_inverted(struct drm_i915_private *dev_priv,
 
         return false;
  }
+
+/**
+ * intel_bios_is_lspcon_present - if LSPCON is attached on %port
+ * @dev_priv:  i915 device instance
+ * @port:      port to check
+ *

drivers/gpu/drm/i915/intel_bios.c intel_bios_is_port_hpd_inverted(struct drm_i915_private *dev_priv, · line 1777

Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.c +10 -0
+ * Return true if LSPCON is present on this port
+ */
+bool
+intel_bios_is_lspcon_present(struct drm_i915_private *dev_priv,
+                               enum port port)
+{
+       int i;
+
+       if (WARN_ON_ONCE(!IS_GEN9(dev_priv)))
+               return false;

This will cause noise on other platforms.

Quoted 3 lines

Also I'd prefer gen < 9 assuming next gens will inherit this support. Or also create a HAS_LSPCON on the platform definition and there use gen < 9.

That's a good suggestion. I assumed that we have native HDMI 2.0 controllers in gen10 onwards, so LSPCON would be required only for GEN9 devices which are not native HDMI 2.0 capable. Do you see anything which will inherit LSPCON ?

Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/i915/intel_bios.c +33 -1
+
+       for (i = 0; i < dev_priv->vbt.child_dev_num; i++) {
+               if (!dev_priv->vbt.child_dev[i].common.lspcon)
+                       continue;
+
+               switch (dev_priv->vbt.child_dev[i].common.dvo_port) {
+               case DVO_PORT_DPA:
+               case DVO_PORT_HDMIA:
+                       if (port == PORT_A)
+                               return true;
+                       break;
+               case DVO_PORT_DPB:
+               case DVO_PORT_HDMIB:
+                       if (port == PORT_B)
+                               return true;
+                       break;
+               case DVO_PORT_DPC:
+               case DVO_PORT_HDMIC:
+                       if (port == PORT_C)
+                               return true;
+                       break;
+               case DVO_PORT_DPD:
+               case DVO_PORT_HDMID:
+                       if (port == PORT_D)
+                               return true;
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       return false;
+}
--

1.9.1

Quoted 7 lines
Quoted 4 lines

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

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

#12 lore raw

PATCH v2 4/4 drm/i915: Enable lspcon initialization

In reply to Shashank Sharma

This patch adds initialization code for lspcon.
What we are doing here is:
- Check if lspcon is configured in VBT for this port
- If lspcon is configured, initialize it and configure it as DP port.

V2: Addressed Ville's review comments:
- Not adding AVI IF functions for LSPCON display now. This part will be added once the dig_port level AVI-IF series gets merged.

---
 drivers/gpu/drm/i915/intel_ddi.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +28 -1
index ad3b0ee..208a1ff 100644
@@ -2323,7 +2323,7 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
 	struct intel_digital_port *intel_dig_port;
 	struct intel_encoder *intel_encoder;
 	struct drm_encoder *encoder;
-	bool init_hdmi, init_dp;
+	bool init_hdmi, init_dp, init_lspcon = false;
 	int max_lanes;
 
 	if (I915_READ(DDI_BUF_CTL(PORT_A)) & DDI_A_4_LANES) {
@@ -2355,6 +2355,19 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
 	init_hdmi = (dev_priv->vbt.ddi_port_info[port].supports_dvi ||
 		     dev_priv->vbt.ddi_port_info[port].supports_hdmi);
 	init_dp = dev_priv->vbt.ddi_port_info[port].supports_dp;
+
+	if (intel_bios_is_lspcon_present(dev_priv, port)) {
+		/*
+		 * Lspcon device needs to be driven with DP connector
+		 * with special detection sequence. So make sure DP
+		 * is initialized before lspcon.
+		 */
+		init_dp = true;
+		init_lspcon = true;
+		init_hdmi = false;
+		DRM_DEBUG_KMS("VBT says port %c has lspcon\n", port_name(port));
+	}
+
 	if (!init_dp && !init_hdmi) {
 		DRM_DEBUG_KMS("VBT says port %c is not DVI/HDMI/DP compatible, respect it\n",
 			      port_name(port));
@@ -2430,6 +2443,20 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
 			goto err;
 	}
 
+	if (init_lspcon) {
+		if (lspcon_init(intel_dig_port))
+			/* TODO: handle hdmi info frame part */
+			DRM_DEBUG_KMS("LSPCON init success on port %c\n",
+				port_name(port));
+		else
+			/*
+			 * LSPCON init faied, but DP init was success, so
+			 * lets try to drive as DP++ port.
+			 */
+			DRM_ERROR("LSPCON init failed on port %c\n",
+				port_name(port));
+	}
+
 	return;
 
 err:
Signature · 6 lines
1.9.1

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

Re: [PATCH v2 4/4] drm/i915: Enable lspcon initialization

Quoted 50 lines · Shashank Sharma

This patch adds initialization code for lspcon.
What we are doing here is:
- Check if lspcon is configured in VBT for this port
- If lspcon is configured, initialize it and configure it as DP port.

V2: Addressed Ville's review comments:
- Not adding AVI IF functions for LSPCON display now. This part will be added once the dig_port level AVI-IF series gets merged.

---
 drivers/gpu/drm/i915/intel_ddi.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +14 -1
index ad3b0ee..208a1ff 100644
@@ -2323,7 +2323,7 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
        struct intel_digital_port *intel_dig_port;
        struct intel_encoder *intel_encoder;
        struct drm_encoder *encoder;
-       bool init_hdmi, init_dp;
+       bool init_hdmi, init_dp, init_lspcon = false;
        int max_lanes;
 
        if (I915_READ(DDI_BUF_CTL(PORT_A)) & DDI_A_4_LANES) {
@@ -2355,6 +2355,19 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
        init_hdmi = (dev_priv->vbt.ddi_port_info[port].supports_dvi ||
                     dev_priv->vbt.ddi_port_info[port].supports_hdmi);
        init_dp = dev_priv->vbt.ddi_port_info[port].supports_dp;
+
+       if (intel_bios_is_lspcon_present(dev_priv, port)) {
+               /*
+                * Lspcon device needs to be driven with DP connector
+                * with special detection sequence. So make sure DP
+                * is initialized before lspcon.
+                */
+               init_dp = true;
+               init_lspcon = true;
+               init_hdmi = false;
+               DRM_DEBUG_KMS("VBT says port %c has lspcon\n", port_name(port));
+       }
+
        if (!init_dp && !init_hdmi) {
                DRM_DEBUG_KMS("VBT says port %c is not DVI/HDMI/DP compatible, respect it\n",
                              port_name(port));

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_init(struct drm_device *dev, enum port port) · line 2448

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
@@ -2430,6 +2443,20 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
                        goto err;
        }
 
+       if (init_lspcon) {
+               if (lspcon_init(intel_dig_port))
+                       /* TODO: handle hdmi info frame part */

Does it work without handling it? What are we missing here? Is this related to "drm/i915: Allow DP ports to set/readout infoframe state (WIP)"
shouldn't it be part of a same series?

Quoted 21 lines
drivers/gpu/drm/i915/intel_ddi.c +11 -1
+                       DRM_DEBUG_KMS("LSPCON init success on port %c\n",
+                               port_name(port));
+               else
+                       /*
+                        * LSPCON init faied, but DP init was success, so
+                        * lets try to drive as DP++ port.
+                        */
+                       DRM_ERROR("LSPCON init failed on port %c\n",
+                               port_name(port));
+       }
+
        return;
 
 err:
--

1.9.1

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

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

Re: [PATCH v2 4/4] drm/i915: Enable lspcon initialization

Regards
Shashank

Quoted 55 lines · Rodrigo Vivi
Quoted 53 lines · Shashank Sharma

This patch adds initialization code for lspcon.
What we are doing here is:
- Check if lspcon is configured in VBT for this port
- If lspcon is configured, initialize it and configure it as DP port.

V2: Addressed Ville's review comments:
- Not adding AVI IF functions for LSPCON display now. This part will be added once the dig_port level AVI-IF series gets merged.

---
  drivers/gpu/drm/i915/intel_ddi.c | 29 ++++++++++++++++++++++++++++-
  1 file changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +14 -1
index ad3b0ee..208a1ff 100644
@@ -2323,7 +2323,7 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
         struct intel_digital_port *intel_dig_port;
         struct intel_encoder *intel_encoder;
         struct drm_encoder *encoder;
-       bool init_hdmi, init_dp;
+       bool init_hdmi, init_dp, init_lspcon = false;
         int max_lanes;
 
         if (I915_READ(DDI_BUF_CTL(PORT_A)) & DDI_A_4_LANES) {
@@ -2355,6 +2355,19 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
         init_hdmi = (dev_priv->vbt.ddi_port_info[port].supports_dvi ||
                      dev_priv->vbt.ddi_port_info[port].supports_hdmi);
         init_dp = dev_priv->vbt.ddi_port_info[port].supports_dp;
+
+       if (intel_bios_is_lspcon_present(dev_priv, port)) {
+               /*
+                * Lspcon device needs to be driven with DP connector
+                * with special detection sequence. So make sure DP
+                * is initialized before lspcon.
+                */
+               init_dp = true;
+               init_lspcon = true;
+               init_hdmi = false;
+               DRM_DEBUG_KMS("VBT says port %c has lspcon\n", port_name(port));
+       }
+
         if (!init_dp && !init_hdmi) {
                 DRM_DEBUG_KMS("VBT says port %c is not DVI/HDMI/DP compatible, respect it\n",
                               port_name(port));
@@ -2430,6 +2443,20 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
                         goto err;
         }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_init(struct drm_device *dev, enum port port) · line 2448

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
+       if (init_lspcon) {
+               if (lspcon_init(intel_dig_port))
+                       /* TODO: handle hdmi info frame part */

Does it work without handling it? What are we missing here? Is this related to "drm/i915: Allow DP ports to set/readout infoframe state (WIP)"

Yes, Ville suggested not to handle AVI IF in LSPCON specifically, but he gave this patch set where its being handled for DDI displays.

Quoted 2 lines

shouldn't it be part of a same series?

I am not sure, they are two different threads going on, you can suggest how to go for this.

Quoted 1 line

Shashank

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/i915/intel_ddi.c +11 -0
+                       DRM_DEBUG_KMS("LSPCON init success on port %c\n",
+                               port_name(port));
+               else
+                       /*
+                        * LSPCON init faied, but DP init was success, so
+                        * lets try to drive as DP++ port.
+                        */
+                       DRM_ERROR("LSPCON init failed on port %c\n",
+                               port_name(port));
+       }
+
         return;
 
Quoted 11 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -1
  err:
--

1.9.1

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

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

#15 lore raw

Re: [PATCH v2 4/4] drm/i915: Enable lspcon initialization

Quoted 77 lines · Shashank

Regards
Shashank

Quoted 63 lines · Rodrigo Vivi
Quoted 60 lines · Shashank Sharma

This patch adds initialization code for lspcon.
What we are doing here is:
- Check if lspcon is configured in VBT for this port
- If lspcon is configured, initialize it and configure it as DP port.

V2: Addressed Ville's review comments:
- Not adding AVI IF functions for LSPCON display now. This part will be added once the dig_port level AVI-IF series gets merged.

---
  drivers/gpu/drm/i915/intel_ddi.c | 29 ++++++++++++++++++++++++++++-
  1 file changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +1 -1
index ad3b0ee..208a1ff 100644
@@ -2323,7 +2323,7 @@ void intel_ddi_init(struct drm_device *dev, enum
 port port)
         struct intel_digital_port *intel_dig_port;
         struct intel_encoder *intel_encoder;
         struct drm_encoder *encoder;
-       bool init_hdmi, init_dp;
+       bool init_hdmi, init_dp, init_lspcon = false;
         int max_lanes;
 
         if (I915_READ(DDI_BUF_CTL(PORT_A)) & DDI_A_4_LANES) {
drivers/gpu/drm/i915/intel_ddi.c +13 -0
@@ -2355,6 +2355,19 @@ void intel_ddi_init(struct drm_device *dev, enum
 port port)
         init_hdmi = (dev_priv->vbt.ddi_port_info[port].supports_dvi ||
                      dev_priv->vbt.ddi_port_info[port].supports_hdmi);
         init_dp = dev_priv->vbt.ddi_port_info[port].supports_dp;
+
+       if (intel_bios_is_lspcon_present(dev_priv, port)) {
+               /*
+                * Lspcon device needs to be driven with DP connector
+                * with special detection sequence. So make sure DP
+                * is initialized before lspcon.
+                */
+               init_dp = true;
+               init_lspcon = true;
+               init_hdmi = false;
+               DRM_DEBUG_KMS("VBT says port %c has lspcon\n",
 port_name(port));
+       }
+
         if (!init_dp && !init_hdmi) {

DRM_DEBUG_KMS("VBT says port %c is not DVI/HDMI/DP
compatible, respect it\n",

                               port_name(port));
drivers/gpu/drm/i915/intel_ddi.c +0 -0
@@ -2430,6 +2443,20 @@ void intel_ddi_init(struct drm_device *dev, enum
 port port)
                         goto err;
         }
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_init(struct drm_device *dev, enum port port) · line 2448

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
+       if (init_lspcon) {
+               if (lspcon_init(intel_dig_port))
+                       /* TODO: handle hdmi info frame part */

Does it work without handling it? What are we missing here? Is this related to "drm/i915: Allow DP ports to set/readout infoframe state (WIP)"

Quoted 7 lines

Yes, Ville suggested not to handle AVI IF in LSPCON specifically, but he gave this patch set where its being handled for DDI displays.

Quoted 3 lines

shouldn't it be part of a same series?

I am not sure, they are two different threads going on, you can suggest how to go for this.

depends on the answer of: Does it work without handling it?

Quoted 31 lines
Quoted 2 lines

Shashank

Quoted 25 lines
Quoted 21 lines
drivers/gpu/drm/i915/intel_ddi.c +11 -0
+                       DRM_DEBUG_KMS("LSPCON init success on port %c\n",
+                               port_name(port));
+               else
+                       /*
+                        * LSPCON init faied, but DP init was success, so
+                        * lets try to drive as DP++ port.
+                        */
+                       DRM_ERROR("LSPCON init failed on port %c\n",
+                               port_name(port));
+       }
+
         return;
 

err:
--
1.9.1

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

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

✗ Ro.CI.BAT: failure for Enable lspcon support for GEN9 devices (rev2)

In reply to Shashank Sharma
== Series Details ==

== Series Details ==

Series: Enable lspcon support for GEN9 devices (rev2)
URL : https://patchwork.freedesktop.org/series/8024/
State : failure

== Summary ==

Series 8024v2 Enable lspcon support for GEN9 devices
http://patchwork.freedesktop.org/api/1.0/series/8024/revisions/2/mbox

Test drv_module_reload_basic:

                pass       -> DMESG-WARN (ro-hsw-i7-4770r)
                pass       -> DMESG-WARN (ro-bdw-i7-5600u)
                pass       -> DMESG-WARN (ro-bdw-i7-5557U)
                pass       -> DMESG-WARN (ro-hsw-i3-4010u)
                pass       -> DMESG-WARN (ro-bdw-i5-5250u)
Test kms_pipe_crc_basic:
        Subgroup hang-read-crc-pipe-a:
                pass       -> FAIL       (fi-skl-i5-6260u)
        Subgroup suspend-read-crc-pipe-a:
                dmesg-warn -> SKIP       (ro-bdw-i5-5250u)
        Subgroup suspend-read-crc-pipe-c:
                dmesg-warn -> SKIP       (ro-bdw-i5-5250u)
fi-skl-i5-6260u  total:225  pass:199  dwarn:0   dfail:0   fail:3   skip:23 
fi-skl-i7-6700k  total:225  pass:186  dwarn:0   dfail:0   fail:2   skip:37 
fi-snb-i7-2600   total:225  pass:172  dwarn:0   dfail:0   fail:2   skip:51 
ro-bdw-i5-5250u  total:225  pass:196  dwarn:2   dfail:0   fail:0   skip:27 
ro-bdw-i7-5557U  total:225  pass:197  dwarn:1   dfail:0   fail:0   skip:27 
ro-bdw-i7-5600u  total:225  pass:184  dwarn:1   dfail:0   fail:0   skip:40 
ro-byt-n2820     total:225  pass:173  dwarn:0   dfail:0   fail:3   skip:49 
ro-hsw-i3-4010u  total:225  pass:189  dwarn:1   dfail:0   fail:0   skip:35 
ro-hsw-i7-4770r  total:225  pass:189  dwarn:1   dfail:0   fail:0   skip:35 
ro-ilk-i7-620lm  total:225  pass:150  dwarn:0   dfail:0   fail:1   skip:74 
ro-ilk1-i5-650   total:220  pass:150  dwarn:0   dfail:0   fail:1   skip:69 
ro-ivb-i7-3770   total:225  pass:181  dwarn:0   dfail:0   fail:0   skip:44 
ro-ivb2-i7-3770  total:225  pass:185  dwarn:0   dfail:0   fail:0   skip:40 
ro-skl3-i5-6260u total:225  pass:201  dwarn:1   dfail:0   fail:0   skip:23 
ro-snb-i7-2620M  total:225  pass:174  dwarn:0   dfail:0   fail:1   skip:50 

fi-hsw-i7-4770k failed to connect after reboot
fi-kbl-qkkr failed to connect after reboot

Results at /archive/results/CI_IGT_test/RO_Patchwork_1258/

12ce3eec drm-intel-nightly: 2016y-06m-21d-14h-43m-47s UTC integration manifest e600d56 drm/i915: Enable lspcon initialization
cede9a2 drm/i915: Parse VBT data for lspcon
72229b0 drm/i915: Add lspcon support for I915 driver
b9ee05e drm: Helper for lspcon in drm_dp_dual_mode

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