public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kbingham@kernel.org>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Subject: Re: [PATCH v3 4/5] media: adv7604: Add support for i2c_new_secondary_device
Date: Tue, 13 Feb 2018 14:19:06 +0200	[thread overview]
Message-ID: <12162268.j7DyVD3ArW@avalon> (raw)
In-Reply-To: <1518473273-6333-5-git-send-email-kbingham@kernel.org>

Hi Kieran,

Thank you for the patch.

On Tuesday, 13 February 2018 00:07:52 EET Kieran Bingham wrote:
> From: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
> 
> The ADV7604 has thirteen 256-byte maps that can be accessed via the main
> I²C ports. Each map has it own I²C address and acts as a standard slave
> device on the I²C bus.
> 
> Allow a device tree node to override the default addresses so that
> address conflicts with other devices on the same bus may be resolved at
> the board description level.
> 
> Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
> [Kieran: Re-adapted for mainline]
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> ---
> Based upon the original posting :
>   https://lkml.org/lkml/2014/10/22/469
> 
> v2:
>  - Split out DT bindings from driver updates
>  - Return -EINVAL on error paths from adv76xx_dummy_client()
> 
>  drivers/media/i2c/adv7604.c | 62 ++++++++++++++++++++++++++----------------
>  1 file changed, 40 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index 1544920ec52d..872e124793f8 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -2734,6 +2734,27 @@ static const struct v4l2_ctrl_config
> adv76xx_ctrl_free_run_color = {
> 
>  /* --------------------------------------------------------------------- */
> 
> +struct adv76xx_register {

adv76xx_register seems to imply that this describes a particular register, 
while the structure describes a registers map. How about adv76xx_register_map, 
adv76xx_register_bank or adv76xx_register_page ?

> +	const char *name;
> +	u8 default_addr;
> +};
> +
> +static const struct adv76xx_register adv76xx_secondary_names[] = {

The table doesn't contain secondary names only as there's an entry for the 
main map. How about calling it adv76xx_default_addresses or something along 
the same line ?

> +	[ADV76XX_PAGE_IO] = { "main", 0x4c },
> +	[ADV7604_PAGE_AVLINK] = { "avlink", 0x42 },
> +	[ADV76XX_PAGE_CEC] = { "cec", 0x40 },
> +	[ADV76XX_PAGE_INFOFRAME] = { "infoframe", 0x3e },
> +	[ADV7604_PAGE_ESDP] = { "esdp", 0x38 },
> +	[ADV7604_PAGE_DPP] = { "dpp", 0x3c },
> +	[ADV76XX_PAGE_AFE] = { "afe", 0x26 },
> +	[ADV76XX_PAGE_REP] = { "rep", 0x32 },
> +	[ADV76XX_PAGE_EDID] = { "edid", 0x36 },
> +	[ADV76XX_PAGE_HDMI] = { "hdmi", 0x34 },
> +	[ADV76XX_PAGE_TEST] = { "test", 0x30 },
> +	[ADV76XX_PAGE_CP] = { "cp", 0x22 },
> +	[ADV7604_PAGE_VDP] = { "vdp", 0x24 },
> +};
> +
>  static int adv76xx_core_init(struct v4l2_subdev *sd)
>  {
>  	struct adv76xx_state *state = to_state(sd);
> @@ -2834,13 +2855,26 @@ static void adv76xx_unregister_clients(struct
> adv76xx_state *state) }
> 
>  static struct i2c_client *adv76xx_dummy_client(struct v4l2_subdev *sd,
> -							u8 addr, u8 io_reg)
> +					       unsigned int i)

Maybe unsigned int page ?

With these fixed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  {
>  	struct i2c_client *client = v4l2_get_subdevdata(sd);
> +	struct adv76xx_state *state = to_state(sd);
> +	struct adv76xx_platform_data *pdata = &state->pdata;
> +	unsigned int io_reg = 0xf2 + i;
> +	struct i2c_client *new_client;
> +
> +	if (pdata && pdata->i2c_addresses[i])
> +		new_client = i2c_new_dummy(client->adapter,
> +					   pdata->i2c_addresses[i]);
> +	else
> +		new_client = i2c_new_secondary_device(client,
> +				adv76xx_secondary_names[i].name,
> +				adv76xx_secondary_names[i].default_addr);
> 
> -	if (addr)
> -		io_write(sd, io_reg, addr << 1);
> -	return i2c_new_dummy(client->adapter, io_read(sd, io_reg) >> 1);
> +	if (new_client)
> +		io_write(sd, io_reg, new_client->addr << 1);
> +
> +	return new_client;
>  }
> 
>  static const struct adv76xx_reg_seq adv7604_recommended_settings_afe[] = {
> @@ -3115,20 +3149,6 @@ static int adv76xx_parse_dt(struct adv76xx_state
> *state) /* Disable the interrupt for now as no DT-based board uses it. */
> state->pdata.int1_config = ADV76XX_INT1_CONFIG_DISABLED;
> 
> -	/* Use the default I2C addresses. */
> -	state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] = 0x42;
> -	state->pdata.i2c_addresses[ADV76XX_PAGE_CEC] = 0x40;
> -	state->pdata.i2c_addresses[ADV76XX_PAGE_INFOFRAME] = 0x3e;
> -	state->pdata.i2c_addresses[ADV7604_PAGE_ESDP] = 0x38;
> -	state->pdata.i2c_addresses[ADV7604_PAGE_DPP] = 0x3c;
> -	state->pdata.i2c_addresses[ADV76XX_PAGE_AFE] = 0x26;
> -	state->pdata.i2c_addresses[ADV76XX_PAGE_REP] = 0x32;
> -	state->pdata.i2c_addresses[ADV76XX_PAGE_EDID] = 0x36;
> -	state->pdata.i2c_addresses[ADV76XX_PAGE_HDMI] = 0x34;
> -	state->pdata.i2c_addresses[ADV76XX_PAGE_TEST] = 0x30;
> -	state->pdata.i2c_addresses[ADV76XX_PAGE_CP] = 0x22;
> -	state->pdata.i2c_addresses[ADV7604_PAGE_VDP] = 0x24;
> -
>  	/* Hardcode the remaining platform data fields. */
>  	state->pdata.disable_pwrdnb = 0;
>  	state->pdata.disable_cable_det_rst = 0;
> @@ -3478,11 +3498,9 @@ static int adv76xx_probe(struct i2c_client *client,
>  		if (!(BIT(i) & state->info->page_mask))
>  			continue;
> 
> -		state->i2c_clients[i] =
> -			adv76xx_dummy_client(sd, state->pdata.i2c_addresses[i],
> -					     0xf2 + i);
> +		state->i2c_clients[i] = adv76xx_dummy_client(sd, i);
>  		if (!state->i2c_clients[i]) {
> -			err = -ENOMEM;
> +			err = -EINVAL;
>  			v4l2_err(sd, "failed to create i2c client %u\n", i);
>  			goto err_i2c;
>  		}

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2018-02-13 12:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 22:07 [PATCH v3 0/5] Add support for i2c_new_secondary_device Kieran Bingham
2018-02-12 22:07 ` [PATCH v3 1/5] dt-bindings: media: adv7604: " Kieran Bingham
2018-02-13 12:06   ` Laurent Pinchart
2018-02-13 13:14     ` Kieran Bingham
2018-02-13 13:30       ` Laurent Pinchart
2018-02-12 22:07 ` [PATCH v3 2/5] dt-bindings: adv7511: " Kieran Bingham
2018-02-13 12:10   ` Laurent Pinchart
2018-02-12 22:07 ` [PATCH v3 3/5] [RFT] ARM: dts: wheat: Fix ADV7513 address usage Kieran Bingham
2018-02-13 12:11   ` Laurent Pinchart
2018-02-12 22:07 ` [PATCH v3 4/5] media: adv7604: Add support for i2c_new_secondary_device Kieran Bingham
2018-02-13 12:19   ` Laurent Pinchart [this message]
2018-02-12 22:07 ` [PATCH v3 5/5] drm: adv7511: " Kieran Bingham
2018-02-13 12:23   ` Laurent Pinchart
2018-02-13 14:23     ` Kieran Bingham

Reply instructions:

You may reply publicly 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=12162268.j7DyVD3ArW@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hans.verkuil@cisco.com \
    --cc=jean-michel.hautbois@vodalys.com \
    --cc=kbingham@kernel.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox