Skip to contentSkip to conversation

drm: Add update_native_mode callback to connectors

RFC PATCH In review Alexander Stein 1 participant 2 messages Mar 18, 2014 – Mar 28, 2014 1 message not in the archive

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

RFC PATCH 1/1 drm: Add update_native_mode callback to connectors

When reading EDID from firmware file, the nouveau driver can not setup it's native_mode like when reading EDID from hardware.
Add this callback to allow driver to update their native_mode.

---
This might be a fast forward hack. I'm wondering if there is a better way to achieve the same.
The actual problem is that nv_connector->native_mode stays NULL when EDID is read from file instead of hardware because nouveau_connector_get_modes isn't called in that case. Neither is nouveau_connector_native_mode which would update native_mode.

 drivers/gpu/drm/drm_crtc_helper.c           |  3 +++
 drivers/gpu/drm/nouveau/nouveau_connector.c | 11 +++++++++++
 include/drm/drm_crtc_helper.h               |  1 +
 3 files changed, 15 insertions(+)
drivers/gpu/drm/drm_crtc_helper.c +3 -0
index ea92b82..8816f3f 100644
@@ -173,6 +173,9 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
 	if (count == 0)
 		goto prune;
 
+	if (*connector_funcs->update_native_mode)
+		(*connector_funcs->update_native_mode)(connector);
+
 	drm_mode_connector_list_update(connector);
 
 	if (maxX && maxY)
drivers/gpu/drm/nouveau/nouveau_connector.c +11 -0
index 1674882..c9c32b7 100644
@@ -880,11 +880,22 @@ nouveau_connector_best_encoder(struct drm_connector *connector)
 	return NULL;
 }
 
+static void
+nouveau_connector_update_native_mode(struct drm_connector *connector)
+{
+	struct nouveau_connector *nv_connector = nouveau_connector(connector);
+
+	if (!nv_connector->native_mode)
+		nv_connector->native_mode =
+			nouveau_connector_native_mode(connector);
+}
+
 static const struct drm_connector_helper_funcs
 nouveau_connector_helper_funcs = {
 	.get_modes = nouveau_connector_get_modes,
 	.mode_valid = nouveau_connector_mode_valid,
 	.best_encoder = nouveau_connector_best_encoder,
+	.update_native_mode = nouveau_connector_update_native_mode,
 };
 
 static const struct drm_connector_funcs
include/drm/drm_crtc_helper.h +1 -0
index b1388b5..5327d4f 100644
@@ -123,6 +123,7 @@ struct drm_connector_helper_funcs {
 	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
 					   struct drm_display_mode *mode);
 	struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
+	void (*update_native_mode)(struct drm_connector *connector);
 };
 
 extern int drm_helper_probe_single_connector_modes(struct drm_connector *connector, uint32_t maxX, uint32_t maxY);
Signature · 1 line
1.9.0
#2 lore raw
In reply to a message not in the archive

Any updates on this?

Alexander

On Wednesday 19 March 2014, 00:39:10 wrote Alexander Stein:

Quoted 72 lines

When reading EDID from firmware file, the nouveau driver can not setup it's native_mode like when reading EDID from hardware.
Add this callback to allow driver to update their native_mode.

---
This might be a fast forward hack. I'm wondering if there is a better way to achieve the same.
The actual problem is that nv_connector->native_mode stays NULL when EDID is read from file instead of hardware because nouveau_connector_get_modes isn't called in that case. Neither is nouveau_connector_native_mode which would update native_mode.

 drivers/gpu/drm/drm_crtc_helper.c           |  3 +++
 drivers/gpu/drm/nouveau/nouveau_connector.c | 11 +++++++++++
 include/drm/drm_crtc_helper.h               |  1 +
 3 files changed, 15 insertions(+)
drivers/gpu/drm/drm_crtc_helper.c +3 -0
index ea92b82..8816f3f 100644
@@ -173,6 +173,9 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
 	if (count == 0)
 		goto prune;
 
+	if (*connector_funcs->update_native_mode)
+		(*connector_funcs->update_native_mode)(connector);
+
 	drm_mode_connector_list_update(connector);
 
 	if (maxX && maxY)
drivers/gpu/drm/nouveau/nouveau_connector.c +11 -0
index 1674882..c9c32b7 100644
@@ -880,11 +880,22 @@ nouveau_connector_best_encoder(struct drm_connector *connector)
 	return NULL;
 }
 
+static void
+nouveau_connector_update_native_mode(struct drm_connector *connector)
+{
+	struct nouveau_connector *nv_connector = nouveau_connector(connector);
+
+	if (!nv_connector->native_mode)
+		nv_connector->native_mode =
+			nouveau_connector_native_mode(connector);
+}
+
 static const struct drm_connector_helper_funcs
 nouveau_connector_helper_funcs = {
 	.get_modes = nouveau_connector_get_modes,
 	.mode_valid = nouveau_connector_mode_valid,
 	.best_encoder = nouveau_connector_best_encoder,
+	.update_native_mode = nouveau_connector_update_native_mode,
 };
 
 static const struct drm_connector_funcs
include/drm/drm_crtc_helper.h +1 -0
index b1388b5..5327d4f 100644
@@ -123,6 +123,7 @@ struct drm_connector_helper_funcs {
 	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
 					   struct drm_display_mode *mode);
 	struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
+	void (*update_native_mode)(struct drm_connector *connector);
 };
 
 extern int drm_helper_probe_single_connector_modes(struct drm_connector *connector, uint32_t maxX, uint32_t maxY);