diff mbox

[02/14] drm: Include the encoder itself in possible_clones

Message ID 20180615164925.28971-3-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjala June 15, 2018, 4:49 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The docs say possible_clones should always include the encoder itself.
Since most drivers don't want to deal with the complexities of cloning
let's allow them to set possible_clones=0 and instead we'll fix that
up in the core.

We can't put this special case into drm_encoder_init() because drivers
will have to fill up possible_clones after adding all the relevant
encoders. Otherwise they wouldn't know the proper encoder indexes to
use. So we'll just do the fallback whenever someone wants to look
at possible_clones. Or maybe we could do it in the late register?

TODO: Should we add the bit even if possible_clones was otherwise
populated by the driver?

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_encoder.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index 273e1c59c54a..ad13c9cf4312 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -63,6 +63,19 @@  static const struct drm_prop_enum_list drm_encoder_enum_list[] = {
 	{ DRM_MODE_ENCODER_DPI, "DPI" },
 };
 
+/*
+ * For some reason we want the encoder itself included in
+ * possible_clones. Make life easy for drivers by allowing them
+ * to leave possible_clones unset if no cloning is possible.
+ */
+static u32 encoder_possible_clones(struct drm_encoder *encoder)
+{
+	if (encoder->possible_clones)
+		return encoder->possible_clones;
+	else
+		return drm_encoder_mask(encoder);
+}
+
 int drm_encoder_register_all(struct drm_device *dev)
 {
 	struct drm_encoder *encoder;
@@ -240,7 +253,7 @@  int drm_mode_getencoder(struct drm_device *dev, void *data,
 	enc_resp->encoder_id = encoder->base.id;
 	enc_resp->possible_crtcs = drm_lease_filter_crtcs(file_priv,
 							  encoder->possible_crtcs);
-	enc_resp->possible_clones = encoder->possible_clones;
+	enc_resp->possible_clones = encoder_possible_clones(encoder);
 
 	return 0;
 }