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 <[email protected]>
> ---
> 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
>
--
Sakari Ailus
[email protected]