Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40d16b0e authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Gerrit - the friendly Code Review server
Browse files

drm: Add drm_connector_for_each_possible_encoder()



Add a convenience macro for iterating connector->encoder_ids[].
Isolates the users from the implementation details.

Note that we don't seem to pass the file_priv down to drm_encoder_find()
because encoders apparently don't get leased. No idea why
drm_encoder_finc() even takes the file_priv actually.

Also use ARRAY_SIZE() when populating the array to avoid spreading
knowledge about the array size all over.

v2: Hide the drm_encoder_find() in the macro, and
    rename the macro appropriately (Daniel)
v3: Fix kernel docs (Daniel)

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180628131315.14156-4-ville.syrjala@linux.intel.com


Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Patch-mainline: 20180628131315.14156-4-ville.syrjala@linux.intel.com @ 28/06/18, 01:13 p.m.
[stalek@codeaurora.org: drop all changes except drm_connector.h file].

Change-Id: I4744ceaeffcc65860734daee4231f01995aede2a
Signed-off-by: default avatarShubham Talekar <stalek@codeaurora.org>
parent 57ef6124
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -836,4 +836,17 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
	     &connector->head != (&(dev)->mode_config.connector_list);		\
	     connector = list_next_entry(connector, head))

/**
 * drm_connector_for_each_possible_encoder - iterate connector's possible encoders
 * @connector: &struct drm_connector pointer
 * @encoder: &struct drm_encoder pointer used as cursor
 * @__i: int iteration cursor, for macro-internal use
 */
#define drm_connector_for_each_possible_encoder(connector, encoder, __i) \
	for ((__i) = 0; (__i) < ARRAY_SIZE((connector)->encoder_ids) && \
		     (connector)->encoder_ids[(__i)] != 0; (__i)++) \
		for_each_if((encoder) = \
			    drm_encoder_find((connector)->dev, NULL, \
					     (connector)->encoder_ids[(__i)])) \

#endif