LinuxTV Patchwork [v3,28/31] adv748x: afe: Implement has_route()

login
register
mail settings
Submitter Jacopo Mondi
Date March 5, 2019, 6:51 p.m.
Message ID <20190305185150.20776-29-jacopo+renesas@jmondi.org>
Download mbox | patch
Permalink /patch/54883/
State Superseded
Headers show

Comments

Jacopo Mondi - March 5, 2019, 6:51 p.m.
Now that the adv748x subdevice supports internal routing, add an
has_route() operation used during media graph traversal.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/adv748x/adv748x-afe.c | 26 +++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
Sakari Ailus - March 7, 2019, 12:49 p.m.
On Tue, Mar 05, 2019 at 07:51:47PM +0100, Jacopo Mondi wrote:
> Now that the adv748x subdevice supports internal routing, add an
> has_route() operation used during media graph traversal.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
>  drivers/media/i2c/adv748x/adv748x-afe.c | 26 +++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c
> index 3f770f71413f..39ac55f0adbb 100644
> --- a/drivers/media/i2c/adv748x/adv748x-afe.c
> +++ b/drivers/media/i2c/adv748x/adv748x-afe.c
> @@ -463,6 +463,30 @@ static const struct v4l2_subdev_ops adv748x_afe_ops = {
>  	.pad = &adv748x_afe_pad_ops,
>  };
>  
> +/* -----------------------------------------------------------------------------
> + * media_entity_operations
> + */
> +
> +static bool adv748x_afe_has_route(struct media_entity *entity,
> +				  unsigned int pad0, unsigned int pad1)
> +{
> +	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
> +	struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
> +
> +	/* Only consider direct sink->source routes. */
> +	if (pad0 > ADV748X_AFE_SINK_AIN7 ||
> +	    pad1 != ADV748X_AFE_SOURCE)

Fits on a single line.

> +		return false;
> +
> +	if (pad0 != afe->input)
> +		return false;
> +
> +	return true;
> +}
> +
> +static const struct media_entity_operations adv748x_afe_entity_ops = {
> +	.has_route = adv748x_afe_has_route,
> +};
>  /* -----------------------------------------------------------------------------
>   * Controls
>   */
> @@ -595,6 +619,8 @@ int adv748x_afe_init(struct adv748x_afe *afe)
>  
>  	afe->pads[ADV748X_AFE_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
>  
> +	afe->sd.entity.ops = &adv748x_afe_entity_ops;
> +
>  	ret = media_entity_pads_init(&afe->sd.entity, ADV748X_AFE_NR_PADS,
>  			afe->pads);
>  	if (ret)
> -- 
> 2.20.1
>
Luca Ceresoli - March 14, 2019, 2:45 p.m.
Hi,

On 05/03/19 19:51, Jacopo Mondi wrote:
> Now that the adv748x subdevice supports internal routing, add an
> has_route() operation used during media graph traversal.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
>  drivers/media/i2c/adv748x/adv748x-afe.c | 26 +++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c
> index 3f770f71413f..39ac55f0adbb 100644
> --- a/drivers/media/i2c/adv748x/adv748x-afe.c
> +++ b/drivers/media/i2c/adv748x/adv748x-afe.c
> @@ -463,6 +463,30 @@ static const struct v4l2_subdev_ops adv748x_afe_ops = {
>  	.pad = &adv748x_afe_pad_ops,
>  };
>  
> +/* -----------------------------------------------------------------------------
> + * media_entity_operations
> + */
> +
> +static bool adv748x_afe_has_route(struct media_entity *entity,
> +				  unsigned int pad0, unsigned int pad1)
> +{
> +	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
> +	struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
> +
> +	/* Only consider direct sink->source routes. */
> +	if (pad0 > ADV748X_AFE_SINK_AIN7 ||
> +	    pad1 != ADV748X_AFE_SOURCE)
> +		return false;
> +
> +	if (pad0 != afe->input)
> +		return false;
> +
> +	return true;
> +}
> +
> +static const struct media_entity_operations adv748x_afe_entity_ops = {
> +	.has_route = adv748x_afe_has_route,
> +};

Missing empty line.

>  /* -----------------------------------------------------------------------------
>   * Controls
>   */

Patch

diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c
index 3f770f71413f..39ac55f0adbb 100644
--- a/drivers/media/i2c/adv748x/adv748x-afe.c
+++ b/drivers/media/i2c/adv748x/adv748x-afe.c
@@ -463,6 +463,30 @@  static const struct v4l2_subdev_ops adv748x_afe_ops = {
 	.pad = &adv748x_afe_pad_ops,
 };
 
+/* -----------------------------------------------------------------------------
+ * media_entity_operations
+ */
+
+static bool adv748x_afe_has_route(struct media_entity *entity,
+				  unsigned int pad0, unsigned int pad1)
+{
+	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
+	struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
+
+	/* Only consider direct sink->source routes. */
+	if (pad0 > ADV748X_AFE_SINK_AIN7 ||
+	    pad1 != ADV748X_AFE_SOURCE)
+		return false;
+
+	if (pad0 != afe->input)
+		return false;
+
+	return true;
+}
+
+static const struct media_entity_operations adv748x_afe_entity_ops = {
+	.has_route = adv748x_afe_has_route,
+};
 /* -----------------------------------------------------------------------------
  * Controls
  */
@@ -595,6 +619,8 @@  int adv748x_afe_init(struct adv748x_afe *afe)
 
 	afe->pads[ADV748X_AFE_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 
+	afe->sd.entity.ops = &adv748x_afe_entity_ops;
+
 	ret = media_entity_pads_init(&afe->sd.entity, ADV748X_AFE_NR_PADS,
 			afe->pads);
 	if (ret)

Privacy Policy