All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] add color management support for the crtc
@ 2022-11-16 14:30 ` Kalyan Thota
  0 siblings, 0 replies; 18+ messages in thread
From: Kalyan Thota @ 2022-11-16 14:30 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, linux-kernel, robdclark, dianders, swboyd,
	quic_vpolimer, dmitry.baryshkov, quic_abhinavk

Add color management support for the crtc provided there are
enough dspps that can be allocated from the catalog

Kalyan Thota (3):
  drm/msm/disp/dpu1: pin 1 crtc to 1 encoder
  drm/msm/disp/dpu1: add helper to know if display is pluggable
  drm/msm/disp/dpu1: add color management support for the crtc

 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c    |  5 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h    |  6 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 23 ++++++++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 +++
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c     | 75 ++++++++++++++++++++++++++---
 5 files changed, 101 insertions(+), 14 deletions(-)

-- 
2.7.4


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

* [PATCH v2 0/3] add color management support for the crtc
@ 2022-11-16 14:30 ` Kalyan Thota
  0 siblings, 0 replies; 18+ messages in thread
From: Kalyan Thota @ 2022-11-16 14:30 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, robdclark, dianders, quic_abhinavk, linux-kernel,
	swboyd, dmitry.baryshkov, quic_vpolimer

Add color management support for the crtc provided there are
enough dspps that can be allocated from the catalog

Kalyan Thota (3):
  drm/msm/disp/dpu1: pin 1 crtc to 1 encoder
  drm/msm/disp/dpu1: add helper to know if display is pluggable
  drm/msm/disp/dpu1: add color management support for the crtc

 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c    |  5 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h    |  6 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 23 ++++++++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 +++
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c     | 75 ++++++++++++++++++++++++++---
 5 files changed, 101 insertions(+), 14 deletions(-)

-- 
2.7.4


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

* [PATCH v2 1/3] drm/msm/disp/dpu1: pin 1 crtc to 1 encoder
  2022-11-16 14:30 ` Kalyan Thota
@ 2022-11-16 14:30   ` Kalyan Thota
  -1 siblings, 0 replies; 18+ messages in thread
From: Kalyan Thota @ 2022-11-16 14:30 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, linux-kernel, robdclark, dianders, swboyd,
	quic_vpolimer, dmitry.baryshkov, quic_abhinavk

Pin each crtc with one encoder. This arrangement will
disallow crtc switching between encoders and also will
facilitate to advertise certain features on crtc based
on encoder type.

Changes in v1:
- use drm_for_each_encoder macro while iterating through
  encoder list (Dmitry)

Changes in v2:
- make sure no encoder miss to have a crtc (Dmitry)
- revisit various factors in deciding the crtc count
  such as num_mixers, num_sspp (Dmitry)

Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 7a5fabc..4784db8 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -763,7 +763,7 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 	drm_for_each_encoder(encoder, dev)
 		num_encoders++;
 
-	max_crtc_count = min(catalog->mixer_count, num_encoders);
+	max_crtc_count = num_encoders;
 
 	/* Create the planes, keeping track of one primary/cursor per crtc */
 	for (i = 0; i < catalog->sspp_count; i++) {
@@ -795,22 +795,25 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 			primary_planes[primary_planes_idx++] = plane;
 	}
 
-	max_crtc_count = min(max_crtc_count, primary_planes_idx);
+	/*
+	 * All the platforms should have at least 1 primary plane for an
+	 * encoder. The below warn should help in setting up the catalog
+	 */
+	WARN_ON(num_encoders > primary_planes_idx);
 
 	/* Create one CRTC per encoder */
-	for (i = 0; i < max_crtc_count; i++) {
+	i = 0;
+	drm_for_each_encoder(encoder, dev) {
 		crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i]);
 		if (IS_ERR(crtc)) {
 			ret = PTR_ERR(crtc);
 			return ret;
 		}
 		priv->crtcs[priv->num_crtcs++] = crtc;
+		encoder->possible_crtcs = 1 << drm_crtc_index(crtc);
+		i++;
 	}
 
-	/* All CRTCs are compatible with all encoders */
-	drm_for_each_encoder(encoder, dev)
-		encoder->possible_crtcs = (1 << priv->num_crtcs) - 1;
-
 	return 0;
 }
 
-- 
2.7.4


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

* [PATCH v2 1/3] drm/msm/disp/dpu1: pin 1 crtc to 1 encoder
@ 2022-11-16 14:30   ` Kalyan Thota
  0 siblings, 0 replies; 18+ messages in thread
From: Kalyan Thota @ 2022-11-16 14:30 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, robdclark, dianders, quic_abhinavk, linux-kernel,
	swboyd, dmitry.baryshkov, quic_vpolimer

Pin each crtc with one encoder. This arrangement will
disallow crtc switching between encoders and also will
facilitate to advertise certain features on crtc based
on encoder type.

Changes in v1:
- use drm_for_each_encoder macro while iterating through
  encoder list (Dmitry)

Changes in v2:
- make sure no encoder miss to have a crtc (Dmitry)
- revisit various factors in deciding the crtc count
  such as num_mixers, num_sspp (Dmitry)

Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 7a5fabc..4784db8 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -763,7 +763,7 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 	drm_for_each_encoder(encoder, dev)
 		num_encoders++;
 
-	max_crtc_count = min(catalog->mixer_count, num_encoders);
+	max_crtc_count = num_encoders;
 
 	/* Create the planes, keeping track of one primary/cursor per crtc */
 	for (i = 0; i < catalog->sspp_count; i++) {
@@ -795,22 +795,25 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 			primary_planes[primary_planes_idx++] = plane;
 	}
 
-	max_crtc_count = min(max_crtc_count, primary_planes_idx);
+	/*
+	 * All the platforms should have at least 1 primary plane for an
+	 * encoder. The below warn should help in setting up the catalog
+	 */
+	WARN_ON(num_encoders > primary_planes_idx);
 
 	/* Create one CRTC per encoder */
-	for (i = 0; i < max_crtc_count; i++) {
+	i = 0;
+	drm_for_each_encoder(encoder, dev) {
 		crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i]);
 		if (IS_ERR(crtc)) {
 			ret = PTR_ERR(crtc);
 			return ret;
 		}
 		priv->crtcs[priv->num_crtcs++] = crtc;
+		encoder->possible_crtcs = 1 << drm_crtc_index(crtc);
+		i++;
 	}
 
-	/* All CRTCs are compatible with all encoders */
-	drm_for_each_encoder(encoder, dev)
-		encoder->possible_crtcs = (1 << priv->num_crtcs) - 1;
-
 	return 0;
 }
 
-- 
2.7.4


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

* [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
  2022-11-16 14:30 ` Kalyan Thota
@ 2022-11-16 14:30   ` Kalyan Thota
  -1 siblings, 0 replies; 18+ messages in thread
From: Kalyan Thota @ 2022-11-16 14:30 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, linux-kernel, robdclark, dianders, swboyd,
	quic_vpolimer, dmitry.baryshkov, quic_abhinavk

Since DRM encoder type for few encoders can be similar
(like eDP and DP) find out if the interface supports HPD
from encoder bridge to differentiate between builtin
and pluggable displays.

Changes in v1:
- add connector type in the disp_info (Dmitry)
- add helper functions to know encoder type
- update commit text reflecting the change

Changes in v2:
- avoid hardcode of connector type for DSI as it may not be true (Dmitry)
- get the HPD information from encoder bridge

Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index 9c6817b..be93269 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -15,6 +15,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_file.h>
 #include <drm/drm_probe_helper.h>
+#include <drm/drm_bridge.h>
 
 #include "msm_drv.h"
 #include "dpu_kms.h"
@@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
 	15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
 };
 
+bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
+{
+	struct drm_bridge *bridge;
+	int ops = 0;
+
+	if (!encoder)
+		return false;
+
+	/* Get last bridge in the chain to determine pluggable state */
+	drm_for_each_bridge_in_chain(encoder, bridge)
+		if (!drm_bridge_get_next_bridge(bridge))
+			ops = bridge->ops;
+
+	return ops & DRM_BRIDGE_OP_HPD;
+}
 
 bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc)
 {
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
index 9e7236e..691ab57 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
@@ -224,4 +224,10 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc,
  */
 bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc);
 
+/**
+ * dpu_encoder_is_pluggable - find if the encoder is of type pluggable
+ * @drm_enc:    Pointer to previously created drm encoder structure
+ */
+bool dpu_encoder_is_pluggable(struct drm_encoder *drm_enc);
+
 #endif /* __DPU_ENCODER_H__ */
-- 
2.7.4


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

* [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
@ 2022-11-16 14:30   ` Kalyan Thota
  0 siblings, 0 replies; 18+ messages in thread
From: Kalyan Thota @ 2022-11-16 14:30 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, robdclark, dianders, quic_abhinavk, linux-kernel,
	swboyd, dmitry.baryshkov, quic_vpolimer

Since DRM encoder type for few encoders can be similar
(like eDP and DP) find out if the interface supports HPD
from encoder bridge to differentiate between builtin
and pluggable displays.

Changes in v1:
- add connector type in the disp_info (Dmitry)
- add helper functions to know encoder type
- update commit text reflecting the change

Changes in v2:
- avoid hardcode of connector type for DSI as it may not be true (Dmitry)
- get the HPD information from encoder bridge

Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index 9c6817b..be93269 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -15,6 +15,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_file.h>
 #include <drm/drm_probe_helper.h>
+#include <drm/drm_bridge.h>
 
 #include "msm_drv.h"
 #include "dpu_kms.h"
@@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
 	15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
 };
 
+bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
+{
+	struct drm_bridge *bridge;
+	int ops = 0;
+
+	if (!encoder)
+		return false;
+
+	/* Get last bridge in the chain to determine pluggable state */
+	drm_for_each_bridge_in_chain(encoder, bridge)
+		if (!drm_bridge_get_next_bridge(bridge))
+			ops = bridge->ops;
+
+	return ops & DRM_BRIDGE_OP_HPD;
+}
 
 bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc)
 {
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
index 9e7236e..691ab57 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
@@ -224,4 +224,10 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc,
  */
 bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc);
 
+/**
+ * dpu_encoder_is_pluggable - find if the encoder is of type pluggable
+ * @drm_enc:    Pointer to previously created drm encoder structure
+ */
+bool dpu_encoder_is_pluggable(struct drm_encoder *drm_enc);
+
 #endif /* __DPU_ENCODER_H__ */
-- 
2.7.4


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

* [PATCH v2 3/3] drm/msm/disp/dpu1: add color management support for the crtc
  2022-11-16 14:30 ` Kalyan Thota
@ 2022-11-16 14:30   ` Kalyan Thota
  -1 siblings, 0 replies; 18+ messages in thread
From: Kalyan Thota @ 2022-11-16 14:30 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, linux-kernel, robdclark, dianders, swboyd,
	quic_vpolimer, dmitry.baryshkov, quic_abhinavk

Add color management support for the crtc provided there are
enough dspps that can be allocated from the catalog.

Changes in v1:
- cache color enabled state in the dpu crtc obj (Dmitry)
- simplify dspp allocation while creating crtc (Dmitry)
- register for color when crtc is created (Dmitry)

Changes in v2:
- avoid primary encoders in the documentation (Dmitry)

Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c    |  5 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h    |  6 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c |  7 +++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c     | 58 ++++++++++++++++++++++++++++-
 4 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 4170fbe..ca4c3b3 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -1571,7 +1571,7 @@ static const struct drm_crtc_helper_funcs dpu_crtc_helper_funcs = {
 
 /* initialize crtc */
 struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,
-				struct drm_plane *cursor)
+				struct drm_plane *cursor, unsigned long features)
 {
 	struct drm_crtc *crtc = NULL;
 	struct dpu_crtc *dpu_crtc = NULL;
@@ -1583,6 +1583,7 @@ struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,
 
 	crtc = &dpu_crtc->base;
 	crtc->dev = dev;
+	dpu_crtc->color_enabled = features & BIT(DPU_DSPP_PCC);
 
 	spin_lock_init(&dpu_crtc->spin_lock);
 	atomic_set(&dpu_crtc->frame_pending, 0);
@@ -1604,7 +1605,7 @@ struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,
 
 	drm_crtc_helper_add(crtc, &dpu_crtc_helper_funcs);
 
-	drm_crtc_enable_color_mgmt(crtc, 0, true, 0);
+	drm_crtc_enable_color_mgmt(crtc, 0, dpu_crtc->color_enabled, 0);
 
 	/* save user friendly CRTC name for later */
 	snprintf(dpu_crtc->name, DPU_CRTC_NAME_SIZE, "crtc%u", crtc->base.id);
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
index 539b68b..342f9ae 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
@@ -136,6 +136,7 @@ struct dpu_crtc_frame_event {
  * @enabled       : whether the DPU CRTC is currently enabled. updated in the
  *                  commit-thread, not state-swap time which is earlier, so
  *                  safe to make decisions on during VBLANK on/off work
+ * @color_enabled : whether crtc supports color management
  * @feature_list  : list of color processing features supported on a crtc
  * @active_list   : list of color processing features are active
  * @dirty_list    : list of color processing features are dirty
@@ -164,7 +165,7 @@ struct dpu_crtc {
 	u64 play_count;
 	ktime_t vblank_cb_time;
 	bool enabled;
-
+	bool color_enabled;
 	struct list_head feature_list;
 	struct list_head active_list;
 	struct list_head dirty_list;
@@ -269,10 +270,11 @@ void dpu_crtc_complete_commit(struct drm_crtc *crtc);
  * @dev: dpu device
  * @plane: base plane
  * @cursor: cursor plane
+ * @features: color features
  * @Return: new crtc object or error
  */
 struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,
-			       struct drm_plane *cursor);
+			       struct drm_plane *cursor, unsigned long features);
 
 /**
  * dpu_crtc_register_custom_event - api for enabling/disabling crtc event
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index be93269..7f1cfc5 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -561,6 +561,7 @@ bool dpu_encoder_use_dsc_merge(struct drm_encoder *drm_enc)
 static struct msm_display_topology dpu_encoder_get_topology(
 			struct dpu_encoder_virt *dpu_enc,
 			struct dpu_kms *dpu_kms,
+			struct dpu_crtc *dpu_crtc,
 			struct drm_display_mode *mode)
 {
 	struct msm_display_topology topology = {0};
@@ -589,7 +590,7 @@ static struct msm_display_topology dpu_encoder_get_topology(
 	else
 		topology.num_lm = (mode->hdisplay > MAX_HDISPLAY_SPLIT) ? 2 : 1;
 
-	if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) {
+	if (dpu_crtc->color_enabled) {
 		if (dpu_kms->catalog->dspp &&
 			(dpu_kms->catalog->dspp_count >= topology.num_lm))
 			topology.num_dspp = topology.num_lm;
@@ -624,6 +625,7 @@ static int dpu_encoder_virt_atomic_check(
 	struct drm_display_mode *adj_mode;
 	struct msm_display_topology topology;
 	struct dpu_global_state *global_state;
+	struct dpu_crtc *dpu_crtc;
 	int i = 0;
 	int ret = 0;
 
@@ -634,6 +636,7 @@ static int dpu_encoder_virt_atomic_check(
 	}
 
 	dpu_enc = to_dpu_encoder_virt(drm_enc);
+	dpu_crtc = to_dpu_crtc(crtc_state->crtc);
 	DPU_DEBUG_ENC(dpu_enc, "\n");
 
 	priv = drm_enc->dev->dev_private;
@@ -659,7 +662,7 @@ static int dpu_encoder_virt_atomic_check(
 		}
 	}
 
-	topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode);
+	topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, dpu_crtc, adj_mode);
 
 	/* Reserve dynamic resources now. */
 	if (!ret) {
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 4784db8..84e948d 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -732,7 +732,58 @@ static int _dpu_kms_setup_displays(struct drm_device *dev,
 	return rc;
 }
 
+/**
+ * _dpu_kms_populate_dspp_features - Evaluate how many dspps pairs can be facilitated
+ *                                   to enable color features for encoder and assign
+ *                                   color features preferring primary
+ * @dpu_kms:    Pointer to dpu kms structure
+ * @features:   Pointer to feature array
+ *
+ * Baring single entry, if at least 2 dspps are available in the catalogue,
+ * then color can be enabled for that crtc
+ */
+static void _dpu_kms_populate_dspp_features(struct dpu_kms *dpu_kms,
+	unsigned long *features)
+{
+	struct drm_encoder *encoder;
+	u32 enc_mask = 0;
+	u32 num_dspps = dpu_kms->catalog->dspp_count;
+
+	if (!num_dspps)
+		return;
+	else if (num_dspps > 1)
+		num_dspps /= 2;
+
+	/* Ensure all builtin displays get first allocation of color */
+	drm_for_each_encoder(encoder, dpu_kms->dev) {
+		if (!dpu_encoder_is_pluggable(encoder) &&
+			encoder->encoder_type != DRM_MODE_ENCODER_VIRTUAL) {
+			if (num_dspps) {
+				features[encoder->index] =
+					dpu_kms->catalog->dspp->features;
+				num_dspps--;
+			}
+		} else if (dpu_encoder_is_pluggable(encoder)) {
+			enc_mask |= drm_encoder_mask(encoder);
+		}
+	}
+
+	/* if color resources are exhausted return */
+	if (!num_dspps)
+		return;
+
+	/* Add color for pluggable displays after builtin on availability */
+	drm_for_each_encoder_mask(encoder, dpu_kms->dev, enc_mask) {
+		if (num_dspps) {
+			features[encoder->index] =
+				dpu_kms->catalog->dspp->features;
+			num_dspps--;
+		}
+	}
+}
+
 #define MAX_PLANES 20
+#define MAX_ENCODERS 10
 static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 {
 	struct drm_device *dev;
@@ -747,6 +798,8 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 
 	int primary_planes_idx = 0, cursor_planes_idx = 0, i, ret;
 	int max_crtc_count;
+	unsigned long features[MAX_ENCODERS] = {0};
+
 	dev = dpu_kms->dev;
 	priv = dev->dev_private;
 	catalog = dpu_kms->catalog;
@@ -801,10 +854,13 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 	 */
 	WARN_ON(num_encoders > primary_planes_idx);
 
+	_dpu_kms_populate_dspp_features(dpu_kms, features);
+
 	/* Create one CRTC per encoder */
 	i = 0;
 	drm_for_each_encoder(encoder, dev) {
-		crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i]);
+		crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i],
+				    features[encoder->index]);
 		if (IS_ERR(crtc)) {
 			ret = PTR_ERR(crtc);
 			return ret;
-- 
2.7.4


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

* [PATCH v2 3/3] drm/msm/disp/dpu1: add color management support for the crtc
@ 2022-11-16 14:30   ` Kalyan Thota
  0 siblings, 0 replies; 18+ messages in thread
From: Kalyan Thota @ 2022-11-16 14:30 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, robdclark, dianders, quic_abhinavk, linux-kernel,
	swboyd, dmitry.baryshkov, quic_vpolimer

Add color management support for the crtc provided there are
enough dspps that can be allocated from the catalog.

Changes in v1:
- cache color enabled state in the dpu crtc obj (Dmitry)
- simplify dspp allocation while creating crtc (Dmitry)
- register for color when crtc is created (Dmitry)

Changes in v2:
- avoid primary encoders in the documentation (Dmitry)

Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c    |  5 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h    |  6 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c |  7 +++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c     | 58 ++++++++++++++++++++++++++++-
 4 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 4170fbe..ca4c3b3 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -1571,7 +1571,7 @@ static const struct drm_crtc_helper_funcs dpu_crtc_helper_funcs = {
 
 /* initialize crtc */
 struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,
-				struct drm_plane *cursor)
+				struct drm_plane *cursor, unsigned long features)
 {
 	struct drm_crtc *crtc = NULL;
 	struct dpu_crtc *dpu_crtc = NULL;
@@ -1583,6 +1583,7 @@ struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,
 
 	crtc = &dpu_crtc->base;
 	crtc->dev = dev;
+	dpu_crtc->color_enabled = features & BIT(DPU_DSPP_PCC);
 
 	spin_lock_init(&dpu_crtc->spin_lock);
 	atomic_set(&dpu_crtc->frame_pending, 0);
@@ -1604,7 +1605,7 @@ struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,
 
 	drm_crtc_helper_add(crtc, &dpu_crtc_helper_funcs);
 
-	drm_crtc_enable_color_mgmt(crtc, 0, true, 0);
+	drm_crtc_enable_color_mgmt(crtc, 0, dpu_crtc->color_enabled, 0);
 
 	/* save user friendly CRTC name for later */
 	snprintf(dpu_crtc->name, DPU_CRTC_NAME_SIZE, "crtc%u", crtc->base.id);
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
index 539b68b..342f9ae 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
@@ -136,6 +136,7 @@ struct dpu_crtc_frame_event {
  * @enabled       : whether the DPU CRTC is currently enabled. updated in the
  *                  commit-thread, not state-swap time which is earlier, so
  *                  safe to make decisions on during VBLANK on/off work
+ * @color_enabled : whether crtc supports color management
  * @feature_list  : list of color processing features supported on a crtc
  * @active_list   : list of color processing features are active
  * @dirty_list    : list of color processing features are dirty
@@ -164,7 +165,7 @@ struct dpu_crtc {
 	u64 play_count;
 	ktime_t vblank_cb_time;
 	bool enabled;
-
+	bool color_enabled;
 	struct list_head feature_list;
 	struct list_head active_list;
 	struct list_head dirty_list;
@@ -269,10 +270,11 @@ void dpu_crtc_complete_commit(struct drm_crtc *crtc);
  * @dev: dpu device
  * @plane: base plane
  * @cursor: cursor plane
+ * @features: color features
  * @Return: new crtc object or error
  */
 struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,
-			       struct drm_plane *cursor);
+			       struct drm_plane *cursor, unsigned long features);
 
 /**
  * dpu_crtc_register_custom_event - api for enabling/disabling crtc event
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index be93269..7f1cfc5 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -561,6 +561,7 @@ bool dpu_encoder_use_dsc_merge(struct drm_encoder *drm_enc)
 static struct msm_display_topology dpu_encoder_get_topology(
 			struct dpu_encoder_virt *dpu_enc,
 			struct dpu_kms *dpu_kms,
+			struct dpu_crtc *dpu_crtc,
 			struct drm_display_mode *mode)
 {
 	struct msm_display_topology topology = {0};
@@ -589,7 +590,7 @@ static struct msm_display_topology dpu_encoder_get_topology(
 	else
 		topology.num_lm = (mode->hdisplay > MAX_HDISPLAY_SPLIT) ? 2 : 1;
 
-	if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) {
+	if (dpu_crtc->color_enabled) {
 		if (dpu_kms->catalog->dspp &&
 			(dpu_kms->catalog->dspp_count >= topology.num_lm))
 			topology.num_dspp = topology.num_lm;
@@ -624,6 +625,7 @@ static int dpu_encoder_virt_atomic_check(
 	struct drm_display_mode *adj_mode;
 	struct msm_display_topology topology;
 	struct dpu_global_state *global_state;
+	struct dpu_crtc *dpu_crtc;
 	int i = 0;
 	int ret = 0;
 
@@ -634,6 +636,7 @@ static int dpu_encoder_virt_atomic_check(
 	}
 
 	dpu_enc = to_dpu_encoder_virt(drm_enc);
+	dpu_crtc = to_dpu_crtc(crtc_state->crtc);
 	DPU_DEBUG_ENC(dpu_enc, "\n");
 
 	priv = drm_enc->dev->dev_private;
@@ -659,7 +662,7 @@ static int dpu_encoder_virt_atomic_check(
 		}
 	}
 
-	topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode);
+	topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, dpu_crtc, adj_mode);
 
 	/* Reserve dynamic resources now. */
 	if (!ret) {
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 4784db8..84e948d 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -732,7 +732,58 @@ static int _dpu_kms_setup_displays(struct drm_device *dev,
 	return rc;
 }
 
+/**
+ * _dpu_kms_populate_dspp_features - Evaluate how many dspps pairs can be facilitated
+ *                                   to enable color features for encoder and assign
+ *                                   color features preferring primary
+ * @dpu_kms:    Pointer to dpu kms structure
+ * @features:   Pointer to feature array
+ *
+ * Baring single entry, if at least 2 dspps are available in the catalogue,
+ * then color can be enabled for that crtc
+ */
+static void _dpu_kms_populate_dspp_features(struct dpu_kms *dpu_kms,
+	unsigned long *features)
+{
+	struct drm_encoder *encoder;
+	u32 enc_mask = 0;
+	u32 num_dspps = dpu_kms->catalog->dspp_count;
+
+	if (!num_dspps)
+		return;
+	else if (num_dspps > 1)
+		num_dspps /= 2;
+
+	/* Ensure all builtin displays get first allocation of color */
+	drm_for_each_encoder(encoder, dpu_kms->dev) {
+		if (!dpu_encoder_is_pluggable(encoder) &&
+			encoder->encoder_type != DRM_MODE_ENCODER_VIRTUAL) {
+			if (num_dspps) {
+				features[encoder->index] =
+					dpu_kms->catalog->dspp->features;
+				num_dspps--;
+			}
+		} else if (dpu_encoder_is_pluggable(encoder)) {
+			enc_mask |= drm_encoder_mask(encoder);
+		}
+	}
+
+	/* if color resources are exhausted return */
+	if (!num_dspps)
+		return;
+
+	/* Add color for pluggable displays after builtin on availability */
+	drm_for_each_encoder_mask(encoder, dpu_kms->dev, enc_mask) {
+		if (num_dspps) {
+			features[encoder->index] =
+				dpu_kms->catalog->dspp->features;
+			num_dspps--;
+		}
+	}
+}
+
 #define MAX_PLANES 20
+#define MAX_ENCODERS 10
 static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 {
 	struct drm_device *dev;
@@ -747,6 +798,8 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 
 	int primary_planes_idx = 0, cursor_planes_idx = 0, i, ret;
 	int max_crtc_count;
+	unsigned long features[MAX_ENCODERS] = {0};
+
 	dev = dpu_kms->dev;
 	priv = dev->dev_private;
 	catalog = dpu_kms->catalog;
@@ -801,10 +854,13 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 	 */
 	WARN_ON(num_encoders > primary_planes_idx);
 
+	_dpu_kms_populate_dspp_features(dpu_kms, features);
+
 	/* Create one CRTC per encoder */
 	i = 0;
 	drm_for_each_encoder(encoder, dev) {
-		crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i]);
+		crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i],
+				    features[encoder->index]);
 		if (IS_ERR(crtc)) {
 			ret = PTR_ERR(crtc);
 			return ret;
-- 
2.7.4


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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
  2022-11-16 14:30   ` Kalyan Thota
@ 2022-11-16 15:08     ` Dmitry Baryshkov
  -1 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2022-11-16 15:08 UTC (permalink / raw)
  To: Kalyan Thota, dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: linux-kernel, robdclark, dianders, swboyd, quic_vpolimer, quic_abhinavk

On 16/11/2022 17:30, Kalyan Thota wrote:
> Since DRM encoder type for few encoders can be similar
> (like eDP and DP) find out if the interface supports HPD
> from encoder bridge to differentiate between builtin
> and pluggable displays.
> 
> Changes in v1:
> - add connector type in the disp_info (Dmitry)
> - add helper functions to know encoder type
> - update commit text reflecting the change
> 
> Changes in v2:
> - avoid hardcode of connector type for DSI as it may not be true (Dmitry)
> - get the HPD information from encoder bridge
> 
> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>   2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index 9c6817b..be93269 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -15,6 +15,7 @@
>   #include <drm/drm_crtc.h>
>   #include <drm/drm_file.h>
>   #include <drm/drm_probe_helper.h>
> +#include <drm/drm_bridge.h>
>   
>   #include "msm_drv.h"
>   #include "dpu_kms.h"
> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>   	15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>   };
>   
> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
> +{
> +	struct drm_bridge *bridge;
> +	int ops = 0;
> +
> +	if (!encoder)
> +		return false;
> +
> +	/* Get last bridge in the chain to determine pluggable state */
> +	drm_for_each_bridge_in_chain(encoder, bridge)
> +		if (!drm_bridge_get_next_bridge(bridge))
> +			ops = bridge->ops;
> +
> +	return ops & DRM_BRIDGE_OP_HPD;

No. This is not what you should be checking (hint: polled connectors 
also can be pluggable).

Please check the type of the actual connector connected to this encoder.

> +}
>   
>   bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc)
>   {
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
> index 9e7236e..691ab57 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
> @@ -224,4 +224,10 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc,
>    */
>   bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc);
>   
> +/**
> + * dpu_encoder_is_pluggable - find if the encoder is of type pluggable
> + * @drm_enc:    Pointer to previously created drm encoder structure
> + */
> +bool dpu_encoder_is_pluggable(struct drm_encoder *drm_enc);
> +
>   #endif /* __DPU_ENCODER_H__ */

-- 
With best wishes
Dmitry


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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
@ 2022-11-16 15:08     ` Dmitry Baryshkov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2022-11-16 15:08 UTC (permalink / raw)
  To: Kalyan Thota, dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: robdclark, dianders, quic_abhinavk, linux-kernel, quic_vpolimer, swboyd

On 16/11/2022 17:30, Kalyan Thota wrote:
> Since DRM encoder type for few encoders can be similar
> (like eDP and DP) find out if the interface supports HPD
> from encoder bridge to differentiate between builtin
> and pluggable displays.
> 
> Changes in v1:
> - add connector type in the disp_info (Dmitry)
> - add helper functions to know encoder type
> - update commit text reflecting the change
> 
> Changes in v2:
> - avoid hardcode of connector type for DSI as it may not be true (Dmitry)
> - get the HPD information from encoder bridge
> 
> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>   2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index 9c6817b..be93269 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -15,6 +15,7 @@
>   #include <drm/drm_crtc.h>
>   #include <drm/drm_file.h>
>   #include <drm/drm_probe_helper.h>
> +#include <drm/drm_bridge.h>
>   
>   #include "msm_drv.h"
>   #include "dpu_kms.h"
> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>   	15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>   };
>   
> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
> +{
> +	struct drm_bridge *bridge;
> +	int ops = 0;
> +
> +	if (!encoder)
> +		return false;
> +
> +	/* Get last bridge in the chain to determine pluggable state */
> +	drm_for_each_bridge_in_chain(encoder, bridge)
> +		if (!drm_bridge_get_next_bridge(bridge))
> +			ops = bridge->ops;
> +
> +	return ops & DRM_BRIDGE_OP_HPD;

No. This is not what you should be checking (hint: polled connectors 
also can be pluggable).

Please check the type of the actual connector connected to this encoder.

> +}
>   
>   bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc)
>   {
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
> index 9e7236e..691ab57 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
> @@ -224,4 +224,10 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc,
>    */
>   bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc);
>   
> +/**
> + * dpu_encoder_is_pluggable - find if the encoder is of type pluggable
> + * @drm_enc:    Pointer to previously created drm encoder structure
> + */
> +bool dpu_encoder_is_pluggable(struct drm_encoder *drm_enc);
> +
>   #endif /* __DPU_ENCODER_H__ */

-- 
With best wishes
Dmitry


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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
  2022-11-16 15:08     ` Dmitry Baryshkov
@ 2022-11-16 15:11       ` Abhinav Kumar
  -1 siblings, 0 replies; 18+ messages in thread
From: Abhinav Kumar @ 2022-11-16 15:11 UTC (permalink / raw)
  To: Dmitry Baryshkov, Kalyan Thota, dri-devel, linux-arm-msm,
	freedreno, devicetree
  Cc: linux-kernel, robdclark, dianders, swboyd, quic_vpolimer



On 11/16/2022 7:08 AM, Dmitry Baryshkov wrote:
> On 16/11/2022 17:30, Kalyan Thota wrote:
>> Since DRM encoder type for few encoders can be similar
>> (like eDP and DP) find out if the interface supports HPD
>> from encoder bridge to differentiate between builtin
>> and pluggable displays.
>>
>> Changes in v1:
>> - add connector type in the disp_info (Dmitry)
>> - add helper functions to know encoder type
>> - update commit text reflecting the change
>>
>> Changes in v2:
>> - avoid hardcode of connector type for DSI as it may not be true (Dmitry)
>> - get the HPD information from encoder bridge
>>
>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>> ---
>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>>   2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> index 9c6817b..be93269 100644
>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> @@ -15,6 +15,7 @@
>>   #include <drm/drm_crtc.h>
>>   #include <drm/drm_file.h>
>>   #include <drm/drm_probe_helper.h>
>> +#include <drm/drm_bridge.h>
>>   #include "msm_drv.h"
>>   #include "dpu_kms.h"
>> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>>       15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>>   };
>> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
>> +{
>> +    struct drm_bridge *bridge;
>> +    int ops = 0;
>> +
>> +    if (!encoder)
>> +        return false;
>> +
>> +    /* Get last bridge in the chain to determine pluggable state */
>> +    drm_for_each_bridge_in_chain(encoder, bridge)
>> +        if (!drm_bridge_get_next_bridge(bridge))
>> +            ops = bridge->ops;
>> +
>> +    return ops & DRM_BRIDGE_OP_HPD;
> 
> No. This is not what you should be checking (hint: polled connectors 
> also can be pluggable).
> 
> Please check the type of the actual connector connected to this encoder.
> 

Even if we check the connector type as DSI or eDP that does not 
necessarily mean its built-in.

We can even use DSI or eDP as a pluggable display.

Thats why we thought of this check.

>> +}
>>   bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc)
>>   {
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h 
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>> index 9e7236e..691ab57 100644
>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>> @@ -224,4 +224,10 @@ void dpu_encoder_cleanup_wb_job(struct 
>> drm_encoder *drm_enc,
>>    */
>>   bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc);
>> +/**
>> + * dpu_encoder_is_pluggable - find if the encoder is of type pluggable
>> + * @drm_enc:    Pointer to previously created drm encoder structure
>> + */
>> +bool dpu_encoder_is_pluggable(struct drm_encoder *drm_enc);
>> +
>>   #endif /* __DPU_ENCODER_H__ */
> 

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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
@ 2022-11-16 15:11       ` Abhinav Kumar
  0 siblings, 0 replies; 18+ messages in thread
From: Abhinav Kumar @ 2022-11-16 15:11 UTC (permalink / raw)
  To: Dmitry Baryshkov, Kalyan Thota, dri-devel, linux-arm-msm,
	freedreno, devicetree
  Cc: robdclark, quic_vpolimer, swboyd, linux-kernel, dianders



On 11/16/2022 7:08 AM, Dmitry Baryshkov wrote:
> On 16/11/2022 17:30, Kalyan Thota wrote:
>> Since DRM encoder type for few encoders can be similar
>> (like eDP and DP) find out if the interface supports HPD
>> from encoder bridge to differentiate between builtin
>> and pluggable displays.
>>
>> Changes in v1:
>> - add connector type in the disp_info (Dmitry)
>> - add helper functions to know encoder type
>> - update commit text reflecting the change
>>
>> Changes in v2:
>> - avoid hardcode of connector type for DSI as it may not be true (Dmitry)
>> - get the HPD information from encoder bridge
>>
>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>> ---
>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>>   2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> index 9c6817b..be93269 100644
>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> @@ -15,6 +15,7 @@
>>   #include <drm/drm_crtc.h>
>>   #include <drm/drm_file.h>
>>   #include <drm/drm_probe_helper.h>
>> +#include <drm/drm_bridge.h>
>>   #include "msm_drv.h"
>>   #include "dpu_kms.h"
>> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>>       15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>>   };
>> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
>> +{
>> +    struct drm_bridge *bridge;
>> +    int ops = 0;
>> +
>> +    if (!encoder)
>> +        return false;
>> +
>> +    /* Get last bridge in the chain to determine pluggable state */
>> +    drm_for_each_bridge_in_chain(encoder, bridge)
>> +        if (!drm_bridge_get_next_bridge(bridge))
>> +            ops = bridge->ops;
>> +
>> +    return ops & DRM_BRIDGE_OP_HPD;
> 
> No. This is not what you should be checking (hint: polled connectors 
> also can be pluggable).
> 
> Please check the type of the actual connector connected to this encoder.
> 

Even if we check the connector type as DSI or eDP that does not 
necessarily mean its built-in.

We can even use DSI or eDP as a pluggable display.

Thats why we thought of this check.

>> +}
>>   bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc)
>>   {
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h 
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>> index 9e7236e..691ab57 100644
>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>> @@ -224,4 +224,10 @@ void dpu_encoder_cleanup_wb_job(struct 
>> drm_encoder *drm_enc,
>>    */
>>   bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc);
>> +/**
>> + * dpu_encoder_is_pluggable - find if the encoder is of type pluggable
>> + * @drm_enc:    Pointer to previously created drm encoder structure
>> + */
>> +bool dpu_encoder_is_pluggable(struct drm_encoder *drm_enc);
>> +
>>   #endif /* __DPU_ENCODER_H__ */
> 

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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
  2022-11-16 15:11       ` Abhinav Kumar
@ 2022-11-16 15:18         ` Dmitry Baryshkov
  -1 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2022-11-16 15:18 UTC (permalink / raw)
  To: Abhinav Kumar, Kalyan Thota, dri-devel, linux-arm-msm, freedreno,
	devicetree
  Cc: linux-kernel, robdclark, dianders, swboyd, quic_vpolimer

On 16/11/2022 18:11, Abhinav Kumar wrote:
> 
> 
> On 11/16/2022 7:08 AM, Dmitry Baryshkov wrote:
>> On 16/11/2022 17:30, Kalyan Thota wrote:
>>> Since DRM encoder type for few encoders can be similar
>>> (like eDP and DP) find out if the interface supports HPD
>>> from encoder bridge to differentiate between builtin
>>> and pluggable displays.
>>>
>>> Changes in v1:
>>> - add connector type in the disp_info (Dmitry)
>>> - add helper functions to know encoder type
>>> - update commit text reflecting the change
>>>
>>> Changes in v2:
>>> - avoid hardcode of connector type for DSI as it may not be true 
>>> (Dmitry)
>>> - get the HPD information from encoder bridge
>>>
>>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>>> ---
>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>>>   2 files changed, 22 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> index 9c6817b..be93269 100644
>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> @@ -15,6 +15,7 @@
>>>   #include <drm/drm_crtc.h>
>>>   #include <drm/drm_file.h>
>>>   #include <drm/drm_probe_helper.h>
>>> +#include <drm/drm_bridge.h>
>>>   #include "msm_drv.h"
>>>   #include "dpu_kms.h"
>>> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>>>       15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>>>   };
>>> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
>>> +{
>>> +    struct drm_bridge *bridge;
>>> +    int ops = 0;
>>> +
>>> +    if (!encoder)
>>> +        return false;
>>> +
>>> +    /* Get last bridge in the chain to determine pluggable state */
>>> +    drm_for_each_bridge_in_chain(encoder, bridge)
>>> +        if (!drm_bridge_get_next_bridge(bridge))
>>> +            ops = bridge->ops;
>>> +
>>> +    return ops & DRM_BRIDGE_OP_HPD;
>>
>> No. This is not what you should be checking (hint: polled connectors 
>> also can be pluggable).
>>
>> Please check the type of the actual connector connected to this encoder.
>>
> 
> Even if we check the connector type as DSI or eDP that does not 
> necessarily mean its built-in.
> 
> We can even use DSI or eDP as a pluggable display.

Well, I don't think so. eDP and DSI connectors are not pluggable per 
design. One can use them so, but they are not thought to be used this 
way. Unlike e.g. HDMI, DP, VGA, etc.

I would say LVDS, eDP, DSI, DPI and SPI can be assumed to be constantly 
plugged.

Compare this with Composite, SVIDEO, 9PinDIN, TV. They can be assumed to 
be external even if they do not have the HPD (or even polling). And 
these connectors usually don't have it.

> 
> Thats why we thought of this check.
> 
-- 
With best wishes
Dmitry


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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
@ 2022-11-16 15:18         ` Dmitry Baryshkov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2022-11-16 15:18 UTC (permalink / raw)
  To: Abhinav Kumar, Kalyan Thota, dri-devel, linux-arm-msm, freedreno,
	devicetree
  Cc: robdclark, quic_vpolimer, swboyd, linux-kernel, dianders

On 16/11/2022 18:11, Abhinav Kumar wrote:
> 
> 
> On 11/16/2022 7:08 AM, Dmitry Baryshkov wrote:
>> On 16/11/2022 17:30, Kalyan Thota wrote:
>>> Since DRM encoder type for few encoders can be similar
>>> (like eDP and DP) find out if the interface supports HPD
>>> from encoder bridge to differentiate between builtin
>>> and pluggable displays.
>>>
>>> Changes in v1:
>>> - add connector type in the disp_info (Dmitry)
>>> - add helper functions to know encoder type
>>> - update commit text reflecting the change
>>>
>>> Changes in v2:
>>> - avoid hardcode of connector type for DSI as it may not be true 
>>> (Dmitry)
>>> - get the HPD information from encoder bridge
>>>
>>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>>> ---
>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>>>   2 files changed, 22 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> index 9c6817b..be93269 100644
>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> @@ -15,6 +15,7 @@
>>>   #include <drm/drm_crtc.h>
>>>   #include <drm/drm_file.h>
>>>   #include <drm/drm_probe_helper.h>
>>> +#include <drm/drm_bridge.h>
>>>   #include "msm_drv.h"
>>>   #include "dpu_kms.h"
>>> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>>>       15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>>>   };
>>> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
>>> +{
>>> +    struct drm_bridge *bridge;
>>> +    int ops = 0;
>>> +
>>> +    if (!encoder)
>>> +        return false;
>>> +
>>> +    /* Get last bridge in the chain to determine pluggable state */
>>> +    drm_for_each_bridge_in_chain(encoder, bridge)
>>> +        if (!drm_bridge_get_next_bridge(bridge))
>>> +            ops = bridge->ops;
>>> +
>>> +    return ops & DRM_BRIDGE_OP_HPD;
>>
>> No. This is not what you should be checking (hint: polled connectors 
>> also can be pluggable).
>>
>> Please check the type of the actual connector connected to this encoder.
>>
> 
> Even if we check the connector type as DSI or eDP that does not 
> necessarily mean its built-in.
> 
> We can even use DSI or eDP as a pluggable display.

Well, I don't think so. eDP and DSI connectors are not pluggable per 
design. One can use them so, but they are not thought to be used this 
way. Unlike e.g. HDMI, DP, VGA, etc.

I would say LVDS, eDP, DSI, DPI and SPI can be assumed to be constantly 
plugged.

Compare this with Composite, SVIDEO, 9PinDIN, TV. They can be assumed to 
be external even if they do not have the HPD (or even polling). And 
these connectors usually don't have it.

> 
> Thats why we thought of this check.
> 
-- 
With best wishes
Dmitry


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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
  2022-11-16 15:18         ` Dmitry Baryshkov
@ 2022-11-16 15:35           ` Abhinav Kumar
  -1 siblings, 0 replies; 18+ messages in thread
From: Abhinav Kumar @ 2022-11-16 15:35 UTC (permalink / raw)
  To: Dmitry Baryshkov, Kalyan Thota, dri-devel, linux-arm-msm,
	freedreno, devicetree
  Cc: linux-kernel, robdclark, dianders, swboyd, quic_vpolimer



On 11/16/2022 7:18 AM, Dmitry Baryshkov wrote:
> On 16/11/2022 18:11, Abhinav Kumar wrote:
>>
>>
>> On 11/16/2022 7:08 AM, Dmitry Baryshkov wrote:
>>> On 16/11/2022 17:30, Kalyan Thota wrote:
>>>> Since DRM encoder type for few encoders can be similar
>>>> (like eDP and DP) find out if the interface supports HPD
>>>> from encoder bridge to differentiate between builtin
>>>> and pluggable displays.
>>>>
>>>> Changes in v1:
>>>> - add connector type in the disp_info (Dmitry)
>>>> - add helper functions to know encoder type
>>>> - update commit text reflecting the change
>>>>
>>>> Changes in v2:
>>>> - avoid hardcode of connector type for DSI as it may not be true 
>>>> (Dmitry)
>>>> - get the HPD information from encoder bridge
>>>>
>>>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>>>> ---
>>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>>>>   2 files changed, 22 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>> index 9c6817b..be93269 100644
>>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>> @@ -15,6 +15,7 @@
>>>>   #include <drm/drm_crtc.h>
>>>>   #include <drm/drm_file.h>
>>>>   #include <drm/drm_probe_helper.h>
>>>> +#include <drm/drm_bridge.h>
>>>>   #include "msm_drv.h"
>>>>   #include "dpu_kms.h"
>>>> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>>>>       15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>>>>   };
>>>> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
>>>> +{
>>>> +    struct drm_bridge *bridge;
>>>> +    int ops = 0;
>>>> +
>>>> +    if (!encoder)
>>>> +        return false;
>>>> +
>>>> +    /* Get last bridge in the chain to determine pluggable state */
>>>> +    drm_for_each_bridge_in_chain(encoder, bridge)
>>>> +        if (!drm_bridge_get_next_bridge(bridge))
>>>> +            ops = bridge->ops;
>>>> +
>>>> +    return ops & DRM_BRIDGE_OP_HPD;
>>>
>>> No. This is not what you should be checking (hint: polled connectors 
>>> also can be pluggable).
>>>
>>> Please check the type of the actual connector connected to this encoder.
>>>
>>
>> Even if we check the connector type as DSI or eDP that does not 
>> necessarily mean its built-in.
>>
>> We can even use DSI or eDP as a pluggable display.
> 
> Well, I don't think so. eDP and DSI connectors are not pluggable per 
> design. One can use them so, but they are not thought to be used this 
> way. Unlike e.g. HDMI, DP, VGA, etc.
> 

We have had many products where we used HDMI as the primary display 
where the HPD line was disconnected in the design, so now if we 
generalize all HDMI connectors to be pluggable we can never enable color 
management on those even though DSI is not even used in that product.

Thats why I felt we should rely on the HPD_OPS as that way we know that 
it will be set only if HPD will be used.

Wouldnt it be just better to also check polling displays to complete 
this check? Is there a way to do it?

> I would say LVDS, eDP, DSI, DPI and SPI can be assumed to be constantly 
> plugged.
> 
> Compare this with Composite, SVIDEO, 9PinDIN, TV. They can be assumed to 
> be external even if they do not have the HPD (or even polling). And 
> these connectors usually don't have it.
> 
>>
>> Thats why we thought of this check.
>>

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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
@ 2022-11-16 15:35           ` Abhinav Kumar
  0 siblings, 0 replies; 18+ messages in thread
From: Abhinav Kumar @ 2022-11-16 15:35 UTC (permalink / raw)
  To: Dmitry Baryshkov, Kalyan Thota, dri-devel, linux-arm-msm,
	freedreno, devicetree
  Cc: robdclark, quic_vpolimer, swboyd, linux-kernel, dianders



On 11/16/2022 7:18 AM, Dmitry Baryshkov wrote:
> On 16/11/2022 18:11, Abhinav Kumar wrote:
>>
>>
>> On 11/16/2022 7:08 AM, Dmitry Baryshkov wrote:
>>> On 16/11/2022 17:30, Kalyan Thota wrote:
>>>> Since DRM encoder type for few encoders can be similar
>>>> (like eDP and DP) find out if the interface supports HPD
>>>> from encoder bridge to differentiate between builtin
>>>> and pluggable displays.
>>>>
>>>> Changes in v1:
>>>> - add connector type in the disp_info (Dmitry)
>>>> - add helper functions to know encoder type
>>>> - update commit text reflecting the change
>>>>
>>>> Changes in v2:
>>>> - avoid hardcode of connector type for DSI as it may not be true 
>>>> (Dmitry)
>>>> - get the HPD information from encoder bridge
>>>>
>>>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>>>> ---
>>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>>>>   2 files changed, 22 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>> index 9c6817b..be93269 100644
>>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>> @@ -15,6 +15,7 @@
>>>>   #include <drm/drm_crtc.h>
>>>>   #include <drm/drm_file.h>
>>>>   #include <drm/drm_probe_helper.h>
>>>> +#include <drm/drm_bridge.h>
>>>>   #include "msm_drv.h"
>>>>   #include "dpu_kms.h"
>>>> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>>>>       15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>>>>   };
>>>> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
>>>> +{
>>>> +    struct drm_bridge *bridge;
>>>> +    int ops = 0;
>>>> +
>>>> +    if (!encoder)
>>>> +        return false;
>>>> +
>>>> +    /* Get last bridge in the chain to determine pluggable state */
>>>> +    drm_for_each_bridge_in_chain(encoder, bridge)
>>>> +        if (!drm_bridge_get_next_bridge(bridge))
>>>> +            ops = bridge->ops;
>>>> +
>>>> +    return ops & DRM_BRIDGE_OP_HPD;
>>>
>>> No. This is not what you should be checking (hint: polled connectors 
>>> also can be pluggable).
>>>
>>> Please check the type of the actual connector connected to this encoder.
>>>
>>
>> Even if we check the connector type as DSI or eDP that does not 
>> necessarily mean its built-in.
>>
>> We can even use DSI or eDP as a pluggable display.
> 
> Well, I don't think so. eDP and DSI connectors are not pluggable per 
> design. One can use them so, but they are not thought to be used this 
> way. Unlike e.g. HDMI, DP, VGA, etc.
> 

We have had many products where we used HDMI as the primary display 
where the HPD line was disconnected in the design, so now if we 
generalize all HDMI connectors to be pluggable we can never enable color 
management on those even though DSI is not even used in that product.

Thats why I felt we should rely on the HPD_OPS as that way we know that 
it will be set only if HPD will be used.

Wouldnt it be just better to also check polling displays to complete 
this check? Is there a way to do it?

> I would say LVDS, eDP, DSI, DPI and SPI can be assumed to be constantly 
> plugged.
> 
> Compare this with Composite, SVIDEO, 9PinDIN, TV. They can be assumed to 
> be external even if they do not have the HPD (or even polling). And 
> these connectors usually don't have it.
> 
>>
>> Thats why we thought of this check.
>>

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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
  2022-11-16 15:35           ` Abhinav Kumar
@ 2022-11-16 15:55             ` Dmitry Baryshkov
  -1 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2022-11-16 15:55 UTC (permalink / raw)
  To: Abhinav Kumar, Kalyan Thota, dri-devel, linux-arm-msm, freedreno,
	devicetree
  Cc: robdclark, quic_vpolimer, swboyd, linux-kernel, dianders

On 16/11/2022 18:35, Abhinav Kumar wrote:
> 
> 
> On 11/16/2022 7:18 AM, Dmitry Baryshkov wrote:
>> On 16/11/2022 18:11, Abhinav Kumar wrote:
>>>
>>>
>>> On 11/16/2022 7:08 AM, Dmitry Baryshkov wrote:
>>>> On 16/11/2022 17:30, Kalyan Thota wrote:
>>>>> Since DRM encoder type for few encoders can be similar
>>>>> (like eDP and DP) find out if the interface supports HPD
>>>>> from encoder bridge to differentiate between builtin
>>>>> and pluggable displays.
>>>>>
>>>>> Changes in v1:
>>>>> - add connector type in the disp_info (Dmitry)
>>>>> - add helper functions to know encoder type
>>>>> - update commit text reflecting the change
>>>>>
>>>>> Changes in v2:
>>>>> - avoid hardcode of connector type for DSI as it may not be true 
>>>>> (Dmitry)
>>>>> - get the HPD information from encoder bridge
>>>>>
>>>>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>>>>> ---
>>>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>>>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>>>>>   2 files changed, 22 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>>>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>>> index 9c6817b..be93269 100644
>>>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>>> @@ -15,6 +15,7 @@
>>>>>   #include <drm/drm_crtc.h>
>>>>>   #include <drm/drm_file.h>
>>>>>   #include <drm/drm_probe_helper.h>
>>>>> +#include <drm/drm_bridge.h>
>>>>>   #include "msm_drv.h"
>>>>>   #include "dpu_kms.h"
>>>>> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>>>>>       15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>>>>>   };
>>>>> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
>>>>> +{
>>>>> +    struct drm_bridge *bridge;
>>>>> +    int ops = 0;
>>>>> +
>>>>> +    if (!encoder)
>>>>> +        return false;
>>>>> +
>>>>> +    /* Get last bridge in the chain to determine pluggable state */
>>>>> +    drm_for_each_bridge_in_chain(encoder, bridge)
>>>>> +        if (!drm_bridge_get_next_bridge(bridge))
>>>>> +            ops = bridge->ops;
>>>>> +
>>>>> +    return ops & DRM_BRIDGE_OP_HPD;
>>>>
>>>> No. This is not what you should be checking (hint: polled connectors 
>>>> also can be pluggable).
>>>>
>>>> Please check the type of the actual connector connected to this 
>>>> encoder.
>>>>
>>>
>>> Even if we check the connector type as DSI or eDP that does not 
>>> necessarily mean its built-in.
>>>
>>> We can even use DSI or eDP as a pluggable display.
>>
>> Well, I don't think so. eDP and DSI connectors are not pluggable per 
>> design. One can use them so, but they are not thought to be used this 
>> way. Unlike e.g. HDMI, DP, VGA, etc.
>>
> 
> We have had many products where we used HDMI as the primary display 
> where the HPD line was disconnected in the design, so now if we 
> generalize all HDMI connectors to be pluggable we can never enable color 
> management on those even though DSI is not even used in that product.

Did they use HDMI connector internally? Or was it just a panel wired 
somehow to the HDMI pins?

If the former is true, then they still are pluggable. Even if you don't 
have a way to detect that via the HPD pin.

If the later is the case, then it shouldn't be DRM_MODE_CONNECTOR_HDMI.
Well, even if this is an internal HDMI, I'd still use some other 
connector (e.g. DRM_MODE_CONNECTOR_Unknown) just to point out that this 
is not an externally visible HDMI connector one assumes to be able to 
find on the body of the device.

Last, but not least, how would you remove DRM_BRIDGE_OPS_HPD from the 
corresponding bridge driver?


> Thats why I felt we should rely on the HPD_OPS as that way we know that 
> it will be set only if HPD will be used.
> 
> Wouldnt it be just better to also check polling displays to complete 
> this check? Is there a way to do it?


Yes, check DRM_BRIDGE_OP_DETECT. But as I noted, there is a list of 
connectors that will not ever have HPD or polling, but still always are 
external. Well, even for VGA there is no good way to detect whether it 
is plugged in or not (see the comment in display-connector.c).



>> I would say LVDS, eDP, DSI, DPI and SPI can be assumed to be 
>> constantly plugged.
>>
>> Compare this with Composite, SVIDEO, 9PinDIN, TV. They can be assumed 
>> to be external even if they do not have the HPD (or even polling). And 
>> these connectors usually don't have it.
>>
>>>
>>> Thats why we thought of this check.
>>>

-- 
With best wishes
Dmitry


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

* Re: [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable
@ 2022-11-16 15:55             ` Dmitry Baryshkov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2022-11-16 15:55 UTC (permalink / raw)
  To: Abhinav Kumar, Kalyan Thota, dri-devel, linux-arm-msm, freedreno,
	devicetree
  Cc: linux-kernel, robdclark, dianders, swboyd, quic_vpolimer

On 16/11/2022 18:35, Abhinav Kumar wrote:
> 
> 
> On 11/16/2022 7:18 AM, Dmitry Baryshkov wrote:
>> On 16/11/2022 18:11, Abhinav Kumar wrote:
>>>
>>>
>>> On 11/16/2022 7:08 AM, Dmitry Baryshkov wrote:
>>>> On 16/11/2022 17:30, Kalyan Thota wrote:
>>>>> Since DRM encoder type for few encoders can be similar
>>>>> (like eDP and DP) find out if the interface supports HPD
>>>>> from encoder bridge to differentiate between builtin
>>>>> and pluggable displays.
>>>>>
>>>>> Changes in v1:
>>>>> - add connector type in the disp_info (Dmitry)
>>>>> - add helper functions to know encoder type
>>>>> - update commit text reflecting the change
>>>>>
>>>>> Changes in v2:
>>>>> - avoid hardcode of connector type for DSI as it may not be true 
>>>>> (Dmitry)
>>>>> - get the HPD information from encoder bridge
>>>>>
>>>>> Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com>
>>>>> ---
>>>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 16 ++++++++++++++++
>>>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  6 ++++++
>>>>>   2 files changed, 22 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>>>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>>> index 9c6817b..be93269 100644
>>>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>>>> @@ -15,6 +15,7 @@
>>>>>   #include <drm/drm_crtc.h>
>>>>>   #include <drm/drm_file.h>
>>>>>   #include <drm/drm_probe_helper.h>
>>>>> +#include <drm/drm_bridge.h>
>>>>>   #include "msm_drv.h"
>>>>>   #include "dpu_kms.h"
>>>>> @@ -217,6 +218,21 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
>>>>>       15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
>>>>>   };
>>>>> +bool dpu_encoder_is_pluggable(struct drm_encoder *encoder)
>>>>> +{
>>>>> +    struct drm_bridge *bridge;
>>>>> +    int ops = 0;
>>>>> +
>>>>> +    if (!encoder)
>>>>> +        return false;
>>>>> +
>>>>> +    /* Get last bridge in the chain to determine pluggable state */
>>>>> +    drm_for_each_bridge_in_chain(encoder, bridge)
>>>>> +        if (!drm_bridge_get_next_bridge(bridge))
>>>>> +            ops = bridge->ops;
>>>>> +
>>>>> +    return ops & DRM_BRIDGE_OP_HPD;
>>>>
>>>> No. This is not what you should be checking (hint: polled connectors 
>>>> also can be pluggable).
>>>>
>>>> Please check the type of the actual connector connected to this 
>>>> encoder.
>>>>
>>>
>>> Even if we check the connector type as DSI or eDP that does not 
>>> necessarily mean its built-in.
>>>
>>> We can even use DSI or eDP as a pluggable display.
>>
>> Well, I don't think so. eDP and DSI connectors are not pluggable per 
>> design. One can use them so, but they are not thought to be used this 
>> way. Unlike e.g. HDMI, DP, VGA, etc.
>>
> 
> We have had many products where we used HDMI as the primary display 
> where the HPD line was disconnected in the design, so now if we 
> generalize all HDMI connectors to be pluggable we can never enable color 
> management on those even though DSI is not even used in that product.

Did they use HDMI connector internally? Or was it just a panel wired 
somehow to the HDMI pins?

If the former is true, then they still are pluggable. Even if you don't 
have a way to detect that via the HPD pin.

If the later is the case, then it shouldn't be DRM_MODE_CONNECTOR_HDMI.
Well, even if this is an internal HDMI, I'd still use some other 
connector (e.g. DRM_MODE_CONNECTOR_Unknown) just to point out that this 
is not an externally visible HDMI connector one assumes to be able to 
find on the body of the device.

Last, but not least, how would you remove DRM_BRIDGE_OPS_HPD from the 
corresponding bridge driver?


> Thats why I felt we should rely on the HPD_OPS as that way we know that 
> it will be set only if HPD will be used.
> 
> Wouldnt it be just better to also check polling displays to complete 
> this check? Is there a way to do it?


Yes, check DRM_BRIDGE_OP_DETECT. But as I noted, there is a list of 
connectors that will not ever have HPD or polling, but still always are 
external. Well, even for VGA there is no good way to detect whether it 
is plugged in or not (see the comment in display-connector.c).



>> I would say LVDS, eDP, DSI, DPI and SPI can be assumed to be 
>> constantly plugged.
>>
>> Compare this with Composite, SVIDEO, 9PinDIN, TV. They can be assumed 
>> to be external even if they do not have the HPD (or even polling). And 
>> these connectors usually don't have it.
>>
>>>
>>> Thats why we thought of this check.
>>>

-- 
With best wishes
Dmitry


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

end of thread, other threads:[~2022-11-16 15:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 14:30 [PATCH v2 0/3] add color management support for the crtc Kalyan Thota
2022-11-16 14:30 ` Kalyan Thota
2022-11-16 14:30 ` [PATCH v2 1/3] drm/msm/disp/dpu1: pin 1 crtc to 1 encoder Kalyan Thota
2022-11-16 14:30   ` Kalyan Thota
2022-11-16 14:30 ` [PATCH v2 2/3] drm/msm/disp/dpu1: add helper to know if display is pluggable Kalyan Thota
2022-11-16 14:30   ` Kalyan Thota
2022-11-16 15:08   ` Dmitry Baryshkov
2022-11-16 15:08     ` Dmitry Baryshkov
2022-11-16 15:11     ` Abhinav Kumar
2022-11-16 15:11       ` Abhinav Kumar
2022-11-16 15:18       ` Dmitry Baryshkov
2022-11-16 15:18         ` Dmitry Baryshkov
2022-11-16 15:35         ` Abhinav Kumar
2022-11-16 15:35           ` Abhinav Kumar
2022-11-16 15:55           ` Dmitry Baryshkov
2022-11-16 15:55             ` Dmitry Baryshkov
2022-11-16 14:30 ` [PATCH v2 3/3] drm/msm/disp/dpu1: add color management support for the crtc Kalyan Thota
2022-11-16 14:30   ` Kalyan Thota

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.