Linux-Renesas-SoC Archive on lore.kernel.org
 help / color / Atom feed
From: Kieran Bingham <kieran.bingham@ideasonboard.com>
To: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	laurent.pinchart@ideasonboard.com,
	niklas.soderlund+renesas@ragnatech.se
Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v3 6/6] media: adv748x: Implement TX link_setup callback
Date: Thu, 10 Jan 2019 14:36:32 +0000
Message-ID: <ce01bf45-edda-beb2-70df-8c5a237ef515@ideasonboard.com> (raw)
In-Reply-To: <20190110140213.5198-7-jacopo+renesas@jmondi.org>

Hi Jacopo,

Thank you for the update,

On 10/01/2019 14:02, Jacopo Mondi wrote:
> When the adv748x driver is informed about a link being created from HDMI or
> AFE to a CSI-2 TX output, the 'link_setup()' callback is invoked. Make
> sure to implement proper routing management at link setup time, to route
> the selected video stream to the desired TX output.

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
>  drivers/media/i2c/adv748x/adv748x-core.c | 48 +++++++++++++++++++++++-
>  drivers/media/i2c/adv748x/adv748x.h      |  2 +
>  2 files changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
> index 200e00f93546..ea7e5ca48f1a 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -335,6 +335,51 @@ int adv748x_tx_power(struct adv748x_csi2 *tx, bool on)
>  /* -----------------------------------------------------------------------------
>   * Media Operations
>   */
> +static int adv748x_link_setup(struct media_entity *entity,
> +			      const struct media_pad *local,
> +			      const struct media_pad *remote, u32 flags)
> +{
> +	struct v4l2_subdev *rsd = media_entity_to_v4l2_subdev(remote->entity);
> +	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
> +	struct adv748x_state *state = v4l2_get_subdevdata(sd);
> +	struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
> +	bool enable = flags & MEDIA_LNK_FL_ENABLED;
> +	u8 io10_mask = ADV748X_IO_10_CSI1_EN |
> +		       ADV748X_IO_10_CSI4_EN |
> +		       ADV748X_IO_10_CSI4_IN_SEL_AFE;
> +	u8 io10 = 0;
> +
> +	/* Refuse to enable multiple links to the same TX at the same time. */
> +	if (enable && tx->src)
> +		return -EINVAL;
> +
> +	/* Set or clear the source (HDMI or AFE) and the current TX. */
> +	if (rsd == &state->afe.sd)
> +		state->afe.tx = enable ? tx : NULL;
> +	else
> +		state->hdmi.tx = enable ? tx : NULL;
> +
> +	tx->src = enable ? rsd : NULL;
> +
> +	if (state->afe.tx) {
> +		/* AFE Requires TXA enabled, even when output to TXB */
> +		io10 |= ADV748X_IO_10_CSI4_EN;
> +		if (is_txa(tx))
> +			io10 |= ADV748X_IO_10_CSI4_IN_SEL_AFE;
> +		else
> +			io10 |= ADV748X_IO_10_CSI1_EN;
> +	}
> +
> +	if (state->hdmi.tx)
> +		io10 |= ADV748X_IO_10_CSI4_EN;
> +
> +	return io_clrset(state, ADV748X_IO_10, io10_mask, io10);
> +}
> +
> +static const struct media_entity_operations adv748x_tx_media_ops = {
> +	.link_setup	= adv748x_link_setup,
> +	.link_validate	= v4l2_subdev_link_validate,
> +};
>  
>  static const struct media_entity_operations adv748x_media_ops = {
>  	.link_validate = v4l2_subdev_link_validate,
> @@ -516,7 +561,8 @@ void adv748x_subdev_init(struct v4l2_subdev *sd, struct adv748x_state *state,
>  		state->client->addr, ident);
>  
>  	sd->entity.function = function;
> -	sd->entity.ops = &adv748x_media_ops;
> +	sd->entity.ops = is_tx(adv748x_sd_to_csi2(sd)) ?
> +			 &adv748x_tx_media_ops : &adv748x_media_ops;
>  }
>  
>  static int adv748x_parse_csi2_lanes(struct adv748x_state *state,
> diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
> index 934a9d9a75c8..b00c1995efb0 100644
> --- a/drivers/media/i2c/adv748x/adv748x.h
> +++ b/drivers/media/i2c/adv748x/adv748x.h
> @@ -94,6 +94,7 @@ struct adv748x_csi2 {
>  #define is_tx_enabled(_tx) ((_tx)->state->endpoints[(_tx)->port] != NULL)
>  #define is_txa(_tx) ((_tx) == &(_tx)->state->txa)
>  #define is_txb(_tx) ((_tx) == &(_tx)->state->txb)
> +#define is_tx(_tx) (is_txa(_tx) || is_txb(_tx))
>  
>  #define is_afe_enabled(_state)					\
>  	((_state)->endpoints[ADV748X_PORT_AIN0] != NULL ||	\
> @@ -223,6 +224,7 @@ struct adv748x_state {
>  #define ADV748X_IO_10_CSI4_EN		BIT(7)
>  #define ADV748X_IO_10_CSI1_EN		BIT(6)
>  #define ADV748X_IO_10_PIX_OUT_EN	BIT(5)
> +#define ADV748X_IO_10_CSI4_IN_SEL_AFE	BIT(3)
>  
>  #define ADV748X_IO_CHIP_REV_ID_1	0xdf
>  #define ADV748X_IO_CHIP_REV_ID_2	0xe0
> 

-- 
Regards
--
Kieran

  reply index

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 14:02 [PATCH v3 0/6] media: adv748x: Implement dynamic routing support Jacopo Mondi
2019-01-10 14:02 ` [PATCH v3 1/6] media: adv748x: Add is_txb() Jacopo Mondi
2019-01-14 14:47   ` Niklas Söderlund
2019-01-10 14:02 ` [PATCH v3 2/6] media: adv748x: Rename reset procedures Jacopo Mondi
2019-01-14 14:49   ` Niklas Söderlund
2019-01-10 14:02 ` [PATCH v3 3/6] media: adv748x: csi2: Link AFE with TXA and TXB Jacopo Mondi
2019-01-14 14:55   ` Niklas Söderlund
2019-01-16  9:10     ` Jacopo Mondi
2019-01-16 12:28       ` Niklas Söderlund
2019-01-16 13:44     ` Niklas Söderlund
2019-01-28 14:47       ` Jacopo Mondi
2019-02-07 15:57         ` Niklas Söderlund
2019-01-10 14:02 ` [PATCH v3 4/6] media: adv748x: Store the source subdevice in TX Jacopo Mondi
2019-01-16 13:33   ` Niklas Söderlund
2019-01-10 14:02 ` [PATCH v3 5/6] media: adv748x: Store the TX sink in HDMI/AFE Jacopo Mondi
2019-01-16 13:45   ` Niklas Söderlund
2019-01-10 14:02 ` [PATCH v3 6/6] media: adv748x: Implement TX link_setup callback Jacopo Mondi
2019-01-10 14:36   ` Kieran Bingham [this message]
2019-01-16 13:46   ` Niklas Söderlund
2019-01-14 14:22 ` [PATCH v3 0/6] media: adv748x: Implement dynamic routing support Kieran Bingham

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ce01bf45-edda-beb2-70df-8c5a237ef515@ideasonboard.com \
    --to=kieran.bingham@ideasonboard.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org linux-renesas-soc@archiver.kernel.org
	public-inbox-index linux-renesas-soc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox