Skip to contentSkip to conversation

media: entity: Swap pads if route is checked from source to sink

PATCH In review Sakari Ailus 2 participants 3 messages Nov 8, 2016 – Mar 7, 2017 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: entity: Swap pads if route is checked from source to sink

This way the pads are always passed to the has_route() op sink pad first. Makes sense.

---
Hi Niklas,

This should make it easier to implement the has_route() op in drivers.

Feel free to merge this to "[PATCH 02/32] media: entity: Add media_entity_has_route() function" if you like, or add separately after the second patch.

 drivers/media/media-entity.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/media-entity.c +4 -0
index 747adcb..520f3f6 100644
@@ -254,6 +254,10 @@ bool media_entity_has_route(struct media_entity *entity, unsigned int pad0,
 	if (!entity->ops || !entity->ops->has_route)
 		return true;
 
+	if (entity->pads[pad0].flags & MEDIA_PAD_FL_SOURCE
+	    && entity->pads[pad1].flags & MEDIA_PAD_FL_SINK)
+		swap(pad0, pad1);
+
 	return entity->ops->has_route(entity, pad0, pad1);
 }
 EXPORT_SYMBOL_GPL(media_entity_has_route);
Signature · 1 line
2.7.4
#1 lore raw

Hi Sakari,

Thanks for the patch.

Quoted 4 lines · Sakari Ailus

This way the pads are always passed to the has_route() op sink pad first. Makes sense.

Quoted 8 lines

---
Hi Niklas,

This should make it easier to implement the has_route() op in drivers.

Feel free to merge this to "[PATCH 02/32] media: entity: Add media_entity_has_route() function" if you like, or add separately after the second patch.

I choose to append this as a separated patch on top of Laurents patches and include all 3 in my next R-Car VIN series.

Quoted 22 lines
 drivers/media/media-entity.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/media-entity.c +4 -0
index 747adcb..520f3f6 100644
@@ -254,6 +254,10 @@ bool media_entity_has_route(struct media_entity *entity, unsigned int pad0,
 	if (!entity->ops || !entity->ops->has_route)
 		return true;
 
+	if (entity->pads[pad0].flags & MEDIA_PAD_FL_SOURCE
+	    && entity->pads[pad1].flags & MEDIA_PAD_FL_SINK)
+		swap(pad0, pad1);
+
 	return entity->ops->has_route(entity, pad0, pad1);
 }
 EXPORT_SYMBOL_GPL(media_entity_has_route);
Signature · 1 line
2.7.4
Signature · 2 lines
Regards,
Niklas Söderlund
#2 lore raw

Hi Niklas,

Quoted 12 lines · Niklas Söderlund

Hi Sakari,

Thanks for the patch.

Quoted 7 lines · Sakari Ailus

This way the pads are always passed to the has_route() op sink pad first. Makes sense.

---
Hi Niklas,

Quoted 8 lines
Quoted 5 lines

This should make it easier to implement the has_route() op in drivers.

Feel free to merge this to "[PATCH 02/32] media: entity: Add media_entity_has_route() function" if you like, or add separately after the second patch.

I choose to append this as a separated patch on top of Laurents patches and include all 3 in my next R-Car VIN series.

Ack. Thanks for the info.

Signature · 2 lines
Sakari Ailus
[email protected]