Re: [PATCH 14/78] staging: media: imx7-mipi-csis: use pm_runtime_resume_and_get()

2021-04-26 Thread Rui Miguel Silva
Hi Mauro,
On Sat Apr 24, 2021 at 7:44 AM WEST, Mauro Carvalho Chehab wrote:
> Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with 
> usage counter")
> added pm_runtime_resume_and_get() in order to automatically handle
> dev->power.usage_count decrement on errors.
>
> Use the new API, in order to cleanup the error check logic.
>
> Signed-off-by: Mauro Carvalho Chehab 

Thanks, looks good.

Acked-by: Rui Miguel Silva 

--
Cheers,
 Rui
> ---
>  drivers/staging/media/imx/imx7-mipi-csis.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 025fdc488bd6..1dc680d94a46 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -695,11 +695,10 @@ static int mipi_csis_s_stream(struct v4l2_subdev 
> *mipi_sd, int enable)
>  
>   mipi_csis_clear_counters(state);
>  
> - ret = pm_runtime_get_sync(>pdev->dev);
> - if (ret < 0) {
> - pm_runtime_put_noidle(>pdev->dev);
> + ret = pm_runtime_resume_and_get(>pdev->dev);
> + if (ret < 0)
>   return ret;
> - }
> +
>   ret = v4l2_subdev_call(state->src_sd, core, s_power, 1);
>   if (ret < 0 && ret != -ENOIOCTLCMD)
>   goto done;
> -- 
> 2.30.2


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 06/10] staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay

2021-03-09 Thread Rui Miguel Silva
Hi,
On Tue, Mar 09, 2021 at 09:58:09AM +0530, Viresh Kumar wrote:
> On 08-03-21, 16:54, Alexandru Ardelean wrote:
> > The intent is the removal of the 'delay_usecs' field from the
> > spi_transfer struct, as there is a 'delay' field that does the same
> > thing.
> > 
> > The spi_delay_to_ns() can be used to get the transfer delay. It works by
> > using the 'delay_usecs' field first (if it is non-zero), and finally
> > uses the 'delay' field.
> > 
> > Since the 'delay_usecs' field is going away, this change makes use of the
> > spi_delay_to_ns() function. This also means dividing the return value of
> > the function by 1000, to convert it to microseconds.
> > To prevent any potential faults when converting to microseconds and since
> > the result of spi_delay_to_ns() is int, the delay is being computed in 32
> > bits and then clamped between 0 & U16_MAX.
> > 
> > Signed-off-by: Alexandru Ardelean 
> > ---
> >  drivers/staging/greybus/spilib.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/greybus/spilib.c 
> > b/drivers/staging/greybus/spilib.c
> > index 672d540d3365..30655153df6a 100644
> > --- a/drivers/staging/greybus/spilib.c
> > +++ b/drivers/staging/greybus/spilib.c
> > @@ -245,6 +245,7 @@ static struct gb_operation 
> > *gb_spi_operation_create(struct gb_spilib *spi,
> > /* Fill in the transfers array */
> > xfer = spi->first_xfer;
> > while (msg->state != GB_SPI_STATE_OP_DONE) {
> > +   int xfer_delay;
> > if (xfer == spi->last_xfer)
> > xfer_len = spi->last_xfer_size;
> > else
> > @@ -259,7 +260,9 @@ static struct gb_operation 
> > *gb_spi_operation_create(struct gb_spilib *spi,
> >  
> > gb_xfer->speed_hz = cpu_to_le32(xfer->speed_hz);
> > gb_xfer->len = cpu_to_le32(xfer_len);
> > -   gb_xfer->delay_usecs = cpu_to_le16(xfer->delay_usecs);
> > +   xfer_delay = spi_delay_to_ns(>delay, xfer) / 1000;
> > +       xfer_delay = clamp_t(u16, xfer_delay, 0, U16_MAX);
> > +   gb_xfer->delay_usecs = cpu_to_le16(xfer_delay);
> > gb_xfer->cs_change = xfer->cs_change;
> > gb_xfer->bits_per_word = xfer->bits_per_word;
> 
> Acked-by: Viresh Kumar 

Acked-by: Rui Miguel Silva 

--
Cheers,
 Rui
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 -next] staging: greybus: light: Use kzalloc for allocating only one thing

2020-12-30 Thread Rui Miguel Silva
Hi Yongjun,
many thanks for your patch.

On Wed, Dec 30, 2020 at 09:37:06AM +0800, Zheng Yongjun wrote:
> Use kzalloc rather than kcalloc(1,...)
> 
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> @@
> 
> - kcalloc(1,
> + kzalloc(
>   ...)
> // 
> 
> Signed-off-by: Zheng Yongjun 

Like Alex said, LGTM also.

Reviewed-by: Rui Miguel Silva 

--
Cheers,
 Rui
> ---
>  drivers/staging/greybus/light.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index d2672b65c3f4..87d36948c610 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -290,8 +290,7 @@ static int channel_attr_groups_set(struct gb_channel 
> *channel,
>   channel->attrs = kcalloc(size + 1, sizeof(*channel->attrs), GFP_KERNEL);
>   if (!channel->attrs)
>   return -ENOMEM;
> - channel->attr_group = kcalloc(1, sizeof(*channel->attr_group),
> -   GFP_KERNEL);
> + channel->attr_group = kzalloc(sizeof(*channel->attr_group), GFP_KERNEL);
>   if (!channel->attr_group)
>   return -ENOMEM;
>   channel->attr_groups = kcalloc(2, sizeof(*channel->attr_groups),
> -- 
> 2.22.0
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: media: imx: no need to check return value of debugfs_create functions

2020-04-28 Thread Rui Miguel Silva
Hi Greg,
Thanks for the cleanup.

On Tue, Apr 28, 2020 at 07:04:05PM +0200, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> Cc: Rui Miguel Silva 
> Cc: Steve Longerbeam 
> Cc: Philipp Zabel 
> Cc: Mauro Carvalho Chehab 
> Cc: Greg Kroah-Hartman 
> Cc: Shawn Guo 
> Cc: Sascha Hauer 
> Cc: Pengutronix Kernel Team 
> Cc: Fabio Estevam 
> Cc: NXP Linux Team 
> Cc: linux-me...@vger.kernel.org
> Cc: de...@driverdev.osuosl.org
> Signed-off-by: Greg Kroah-Hartman 

Reviewed-by: Rui Miguel Silva 


Cheers,
 Rui
> ---
>  drivers/staging/media/imx/imx7-mipi-csis.c | 29 --
>  1 file changed, 5 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index fbc1a924652a..d7c9e7343f1f 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -915,33 +915,14 @@ static int mipi_csis_dump_regs_show(struct seq_file *m, 
> void *private)
>  }
>  DEFINE_SHOW_ATTRIBUTE(mipi_csis_dump_regs);
>  
> -static int mipi_csis_debugfs_init(struct csi_state *state)
> +static void mipi_csis_debugfs_init(struct csi_state *state)
>  {
> - struct dentry *d;
> -
> - if (!debugfs_initialized())
> - return -ENODEV;
> -
>   state->debugfs_root = debugfs_create_dir(dev_name(state->dev), NULL);
> - if (!state->debugfs_root)
> - return -ENOMEM;
> -
> - d = debugfs_create_bool("debug_enable", 0600, state->debugfs_root,
> - >debug);
> - if (!d)
> - goto remove_debugfs;
> -
> - d = debugfs_create_file("dump_regs", 0600, state->debugfs_root,
> - state, _csis_dump_regs_fops);
> - if (!d)
> - goto remove_debugfs;
> -
> - return 0;
> -
> -remove_debugfs:
> - debugfs_remove_recursive(state->debugfs_root);
>  
> - return -ENOMEM;
> + debugfs_create_bool("debug_enable", 0600, state->debugfs_root,
> + >debug);
> + debugfs_create_file("dump_regs", 0600, state->debugfs_root, state,
> + _csis_dump_regs_fops);
>  }
>  
>  static void mipi_csis_debugfs_exit(struct csi_state *state)
> -- 
> 2.26.2
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH -next] staging: greybus: fix a missing-check bug in gb_lights_light_config()

2020-04-02 Thread Rui Miguel Silva
Hi,
On Thu, Apr 02, 2020 at 05:22:37PM +0300, Dan Carpenter wrote:
> On Thu, Apr 02, 2020 at 02:16:18PM +0100, Rui Miguel Silva wrote:
> > > > --- a/drivers/staging/greybus/light.c
> > > > +++ b/drivers/staging/greybus/light.c
> > > > @@ -1026,7 +1026,8 @@ static int gb_lights_light_config(struct 
> > > > gb_lights *glights, u8 id)
> > > >  
> > > > light->channels_count = conf.channel_count;
> > > > light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
> > > > -
> > > > +   if (!light->name)
> > > > +   return -ENOMEM;
> > > > light->channels = kcalloc(light->channels_count,
> > > >   sizeof(struct gb_channel), 
> > > > GFP_KERNEL);
> > > > if (!light->channels)
> > > 
> > > The clean up in this function is non-existant.  :(
> > 
> > Yeah, this have a central point to do the cleanups, gb_lights_release,
> > since we may have other lights already configured at this point, we
> > could cleanup this specific one here, but than would need to make sure
> > all other already configure got clean also.
> 
> Central clean up functions never work correctly.

I agree.

> 
> For example, we allocate "cdev->name" in gb_lights_channel_config()
> before we register the channel later in gb_lights_register_all(glights);.
> Now imagine that the register fails.  Then when we're freeing it in
> __gb_lights_led_unregister() we see that the ->is_registered is false
> so we don't kfree(cdev->name).
> 
> That's just a small memory leak.  But there are going to be tons of
> little bugs like that.

Yeah, when I have some cycles I'll go over that error codes paths and
mitigate this kind of issues.

> 
> Anyway it doesn't affect this patch so it's fine.

Yeah, thanks.

--
Cheers,
 Rui
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH -next] staging: greybus: fix a missing-check bug in gb_lights_light_config()

2020-04-02 Thread Rui Miguel Silva
Hi Dan,

On Thu, Apr 02, 2020 at 03:22:28PM +0300, Dan Carpenter wrote:
> On Wed, Apr 01, 2020 at 11:00:17AM +0800, Chen Zhou wrote:
> > In gb_lights_light_config(), 'light->name' is allocated by kstrndup().
> > It returns NULL when fails, add check for it.
> > 
> > Signed-off-by: Chen Zhou 
> > ---
> >  drivers/staging/greybus/light.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/greybus/light.c 
> > b/drivers/staging/greybus/light.c
> > index d6ba25f..d2672b6 100644
> > --- a/drivers/staging/greybus/light.c
> > +++ b/drivers/staging/greybus/light.c
> > @@ -1026,7 +1026,8 @@ static int gb_lights_light_config(struct gb_lights 
> > *glights, u8 id)
> >  
> > light->channels_count = conf.channel_count;
> > light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
> > -
> > +   if (!light->name)
> > +   return -ENOMEM;
> > light->channels = kcalloc(light->channels_count,
> >   sizeof(struct gb_channel), GFP_KERNEL);
> > if (!light->channels)
> 
> The clean up in this function is non-existant.  :(

Yeah, this have a central point to do the cleanups, gb_lights_release,
since we may have other lights already configured at this point, we
could cleanup this specific one here, but than would need to make sure
all other already configure got clean also.

--
Cheers,
 Rui

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH -next] staging: greybus: fix a missing-check bug in gb_lights_light_config()

2020-04-01 Thread Rui Miguel Silva
Hi Chen Zhou,
Thanks for the patch.

On Wed, Apr 01, 2020 at 11:00:17AM +0800, Chen Zhou wrote:
> In gb_lights_light_config(), 'light->name' is allocated by kstrndup().
> It returns NULL when fails, add check for it.
> 
> Signed-off-by: Chen Zhou 

Acked-by: Rui Miguel Silva 

--
Cheers,
 Rui

> ---
>  drivers/staging/greybus/light.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index d6ba25f..d2672b6 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -1026,7 +1026,8 @@ static int gb_lights_light_config(struct gb_lights 
> *glights, u8 id)
>  
>   light->channels_count = conf.channel_count;
>   light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
> -
> + if (!light->name)
> + return -ENOMEM;
>   light->channels = kcalloc(light->channels_count,
> sizeof(struct gb_channel), GFP_KERNEL);
>   if (!light->channels)
> -- 
> 2.7.4
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] media: imx7-mipi-csis: remove subdev_notifier

2019-12-13 Thread Rui Miguel Silva
Hi Hans,
On Fri, Dec 13, 2019 at 08:59:22AM +0100, Hans Verkuil wrote:
> On 12/12/19 8:17 PM, Rui Miguel Silva wrote:
> > It was defined a notifier in the csi_state structure that is never
> > allocated. And besides that it's unregister in the remove, even
> > though it is a no-op, just remove both.
> > 
> > Fixes: 7807063b862b ("media: staging/imx7: add MIPI CSI-2 receiver
> > subdev for i.MX7") Reported-by: Hans Verkuil 
> > Suggested-by: Dan Carpenter 
> > Suggested-by: Philipp Zabel 
> > Signed-off-by: Rui Miguel Silva 
> 
> Mismatch between this Signed-off-by and your email address.  Is it
> OK if I use your linaro email in this Signed-off-by?

Yeah, no problem. go ahead. Thanks.

--
Cheers,
 Rui

> 
> Regards,
> 
>   Hans
> 
> > --- drivers/staging/media/imx/imx7-mipi-csis.c | 3 ---
> >  1 file changed, 3 deletions(-)
> > 
> > diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c
> > b/drivers/staging/media/imx/imx7-mipi-csis.c index
> > 99166afca071..383abecb3bec 100644 ---
> > a/drivers/staging/media/imx/imx7-mipi-csis.c +++
> > b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -251,8 +251,6 @@
> > struct csi_state {
> >  
> > struct mipi_csis_event events[MIPI_CSIS_NUM_EVENTS];
> >  
> > -   struct v4l2_async_notifier subdev_notifier; - struct
> > csis_hw_reset hw_reset; struct regulator *mipi_phy_regulator; bool
> > sink_linked; @@ -1104,7 +1102,6 @@ static int
> > mipi_csis_remove(struct platform_device *pdev)
> >  
> > mipi_csis_debugfs_exit(state);
> > v4l2_async_unregister_subdev(>mipi_sd); -
> > v4l2_async_notifier_unregister(>subdev_notifier);
> >  
> > pm_runtime_disable(>dev);
> > mipi_csis_pm_suspend(>dev, true);
> > 
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] media: imx7-mipi-csis: remove subdev_notifier

2019-12-12 Thread Rui Miguel Silva
It was defined a notifier in the csi_state structure that is never
allocated. And besides that it's unregister in the remove, even though
it is a no-op, just remove both.

Fixes: 7807063b862b ("media: staging/imx7: add MIPI CSI-2 receiver subdev for 
i.MX7")
Reported-by: Hans Verkuil 
Suggested-by: Dan Carpenter 
Suggested-by: Philipp Zabel 
Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
index 99166afca071..383abecb3bec 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -251,8 +251,6 @@ struct csi_state {
 
struct mipi_csis_event events[MIPI_CSIS_NUM_EVENTS];
 
-   struct v4l2_async_notifier subdev_notifier;
-
struct csis_hw_reset hw_reset;
struct regulator *mipi_phy_regulator;
bool sink_linked;
@@ -1104,7 +1102,6 @@ static int mipi_csis_remove(struct platform_device *pdev)
 
mipi_csis_debugfs_exit(state);
v4l2_async_unregister_subdev(>mipi_sd);
-   v4l2_async_notifier_unregister(>subdev_notifier);
 
pm_runtime_disable(>dev);
mipi_csis_pm_suspend(>dev, true);
-- 
2.24.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] media: imx7-mipi-csis: Add the missed v4l2_async_notifier_cleanup in remove

2019-12-12 Thread Rui Miguel Silva
Hi Dan,
Thanks for the inputs.
On Thu, Dec 12, 2019 at 02:51:34PM +0300, Dan Carpenter wrote:
> On Mon, Dec 09, 2019 at 04:58:28PM +0800, Chuhong Yuan wrote:
> > All drivers in imx call v4l2_async_notifier_cleanup() after
> > unregistering the notifier except this driver.  This should be a
> > miss and we need to add the call to fix it.
> > 
> > Signed-off-by: Chuhong Yuan  ---
> > drivers/staging/media/imx/imx7-mipi-csis.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c
> > b/drivers/staging/media/imx/imx7-mipi-csis.c index
> > 99166afca071..2bfa85bb84e7 100644 ---
> > a/drivers/staging/media/imx/imx7-mipi-csis.c +++
> > b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -1105,6 +1105,7 @@
> > static int mipi_csis_remove(struct platform_device *pdev)
> > mipi_csis_debugfs_exit(state);
> > v4l2_async_unregister_subdev(>mipi_sd);
> > v4l2_async_notifier_unregister(>subdev_notifier); +
> > v4l2_async_notifier_cleanup(>subdev_notifier);
> >  
> 
> In this case the "state->subdev_notifier" was never initialized or
> used so both v4l2_async_notifier_unregister() and
> v4l2_async_notifier_cleanup() are no-ops.

I have applied this patch on top of Steve's series [0], since by the
timeline I was expecting to be applied before this one, that series
adds a bound notifier, even though, it is not named the same, eheh.

That trigged me to think that this cleanup was correct since a
notifier was initialized in probe.

But as you say, it is a no-ops in the end.

@Steve, that said, it looks that in [0], you will need to add some
unregister and cleanup for the notifiers that you are adding in
several places.

A patch to fix this will follow.

--
Cheers,
 Rui



[0]: https://patchwork.kernel.org/project/linux-media/list/?series=207517

> 
> We should just delete "subdev_notifier".
> 
> regards, dan carpenter
> 
> ___ devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] media: imx7-mipi-csis: Add the missed v4l2_async_notifier_cleanup in remove

2019-12-11 Thread Rui Miguel Silva
Hi Chuhong,
Thanks for the patch.

On Mon, Dec 09, 2019 at 04:58:28PM +0800, Chuhong Yuan wrote:
> All drivers in imx call v4l2_async_notifier_cleanup() after unregistering
> the notifier except this driver.
> This should be a miss and we need to add the call to fix it.
> 
> Signed-off-by: Chuhong Yuan 

Reviewed-by: Rui Miguel Silva 

--
Cheers,
 Rui
> ---
>  drivers/staging/media/imx/imx7-mipi-csis.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 99166afca071..2bfa85bb84e7 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -1105,6 +1105,7 @@ static int mipi_csis_remove(struct platform_device 
> *pdev)
>   mipi_csis_debugfs_exit(state);
>   v4l2_async_unregister_subdev(>mipi_sd);
>   v4l2_async_notifier_unregister(>subdev_notifier);
> + v4l2_async_notifier_cleanup(>subdev_notifier);
>  
>   pm_runtime_disable(>dev);
>   mipi_csis_pm_suspend(>dev, true);
> -- 
> 2.24.0
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-10-23 Thread Rui Miguel Silva
Hi Steve,
On Tue 22 Oct 2019 at 17:26, Steve Longerbeam wrote:
> Hi Laurent, Rui,
>
> Besides field type ANY, the imx7 CSI should probably be dealing with other 
> field
> type conversions as well. I may be mistaken, but like the imx6, the imx7 does
> not have the ability to detect whether a captured field is a top field or a
> bottom field, so it can't support ALTERNATE mode. It should probably capture 
> two
> consecutive fields and in that case and report seq-tb or seq-bt at its output.
> Also the imx6 supports interlacing field lines, if that is the case for imx7 
> it
> should also support converting ALTERNATE to INTERLACED at its output.
>

Yeah, that makes sense to me, I already saw yours csi_try_field
that does something in this lines.

I will try to handle that in imx7 also.

Thanks for your inputs here.

Cheers,
Rui
>
> Steve
>
>
> On 10/22/19 6:34 AM, Rui Miguel Silva wrote:
>> Hi Laurent,
>> On Tue 22 Oct 2019 at 02:44, Laurent Pinchart wrote:
>>> Hi Steve,
>>>
>>> On Tue, May 21, 2019 at 06:03:17PM -0700, Steve Longerbeam wrote:
>>>> Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
>>>> renaming it to to imx_media_try_colorimetry(), and call it at both sink and
>>>> source pad try_fmt's. The unrelated check for uninitialized field value is
>>>> moved out to appropriate places in each subdev try_fmt.
>>>>
>>>> The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
>>>> and full range quantization for both YUV and RGB space, so allow those
>>>> for pipelines that route through the IC.
>>>>
>>>> Signed-off-by: Steve Longerbeam 
>>>> ---
>>>> Changes in v7:
>>>> - squashed with "media: imx: Allow Rec.709 encoding for IC routes".
>>>> - remove the RGB full-range quantization restriction for IC routes.
>>>> ---
>>>>   drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
>>>>   drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
>>>>   drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
>>>>   drivers/staging/media/imx/imx-media-utils.c | 73 ++---
>>>>   drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
>>>>   drivers/staging/media/imx/imx-media.h   |  5 +-
>>>>   drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
>>>>   7 files changed, 62 insertions(+), 62 deletions(-)
>>>>
>>>> diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
>>>> b/drivers/staging/media/imx/imx-ic-prp.c
>>>> index 10ffe00f1a54..f87fe0203720 100644
>>>> --- a/drivers/staging/media/imx/imx-ic-prp.c
>>>> +++ b/drivers/staging/media/imx/imx-ic-prp.c
>>>> @@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>>>>sdformat->format.code = cc->codes[0];
>>>>}
>>>>
>>>> -  imx_media_fill_default_mbus_fields(>format, infmt,
>>>> - true);
>>>> +  if (sdformat->format.field == V4L2_FIELD_ANY)
>>>> +  sdformat->format.field = V4L2_FIELD_NONE;
>>>>break;
>>>>case PRP_SRC_PAD_PRPENC:
>>>>case PRP_SRC_PAD_PRPVF:
>>>> @@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>>>>break;
>>>>}
>>>>
>>>> +  imx_media_try_colorimetry(>format, true);
>>>> +
>>>>fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
>>>>*fmt = sdformat->format;
>>>>   out:
>>>> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
>>>> b/drivers/staging/media/imx/imx-ic-prpencvf.c
>>>> index e8b36a181ccc..f2fe3c11c70e 100644
>>>> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
>>>> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
>>>> @@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
>>>>/* propagate colorimetry from sink */
>>>>sdformat->format.colorspace = infmt->colorspace;
>>>>sdformat->format.xfer_func = infmt->xfer_func;
>>>> -  sdformat->format.quantization = infmt->quantization;
>>>> -  sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
>>>>} else {
>>>>v4l_bound_align_image(>format.width,
>>>> 

Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-10-22 Thread Rui Miguel Silva
Hi Laurent,
On Tue 22 Oct 2019 at 02:44, Laurent Pinchart wrote:
> Hi Steve,
>
> On Tue, May 21, 2019 at 06:03:17PM -0700, Steve Longerbeam wrote:
>> Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
>> renaming it to to imx_media_try_colorimetry(), and call it at both sink and
>> source pad try_fmt's. The unrelated check for uninitialized field value is
>> moved out to appropriate places in each subdev try_fmt.
>>
>> The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
>> and full range quantization for both YUV and RGB space, so allow those
>> for pipelines that route through the IC.
>>
>> Signed-off-by: Steve Longerbeam 
>> ---
>> Changes in v7:
>> - squashed with "media: imx: Allow Rec.709 encoding for IC routes".
>> - remove the RGB full-range quantization restriction for IC routes.
>> ---
>>  drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
>>  drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
>>  drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
>>  drivers/staging/media/imx/imx-media-utils.c | 73 ++---
>>  drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
>>  drivers/staging/media/imx/imx-media.h   |  5 +-
>>  drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
>>  7 files changed, 62 insertions(+), 62 deletions(-)
>>
>> diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
>> b/drivers/staging/media/imx/imx-ic-prp.c
>> index 10ffe00f1a54..f87fe0203720 100644
>> --- a/drivers/staging/media/imx/imx-ic-prp.c
>> +++ b/drivers/staging/media/imx/imx-ic-prp.c
>> @@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>>  sdformat->format.code = cc->codes[0];
>>  }
>>
>> -imx_media_fill_default_mbus_fields(>format, infmt,
>> -   true);
>> +if (sdformat->format.field == V4L2_FIELD_ANY)
>> +sdformat->format.field = V4L2_FIELD_NONE;
>>  break;
>>  case PRP_SRC_PAD_PRPENC:
>>  case PRP_SRC_PAD_PRPVF:
>> @@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>>  break;
>>  }
>>
>> +imx_media_try_colorimetry(>format, true);
>> +
>>  fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
>>  *fmt = sdformat->format;
>>  out:
>> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
>> b/drivers/staging/media/imx/imx-ic-prpencvf.c
>> index e8b36a181ccc..f2fe3c11c70e 100644
>> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
>> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
>> @@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
>>  /* propagate colorimetry from sink */
>>  sdformat->format.colorspace = infmt->colorspace;
>>  sdformat->format.xfer_func = infmt->xfer_func;
>> -sdformat->format.quantization = infmt->quantization;
>> -sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
>>  } else {
>>  v4l_bound_align_image(>format.width,
>>MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
>> @@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
>>MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
>>S_ALIGN);
>>
>> -imx_media_fill_default_mbus_fields(>format, infmt,
>> -   true);
>> +if (sdformat->format.field == V4L2_FIELD_ANY)
>> +sdformat->format.field = V4L2_FIELD_NONE;
>>  }
>> +
>> +imx_media_try_colorimetry(>format, true);
>>  }
>>
>>  static int prp_set_fmt(struct v4l2_subdev *sd,
>> diff --git a/drivers/staging/media/imx/imx-media-csi.c 
>> b/drivers/staging/media/imx/imx-media-csi.c
>> index 1d248aca40a9..dce4addadff4 100644
>> --- a/drivers/staging/media/imx/imx-media-csi.c
>> +++ b/drivers/staging/media/imx/imx-media-csi.c
>> @@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
>>  struct v4l2_mbus_framefmt *infmt =
>>  __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
>>
>> -/* no restrictions on sink pad field type */
>> -if (sdformat->pad == CSI_SINK_PAD)
>> +/*
>> + * no restrictions on sink pad field type except must
>> + * be initialized.
>> + */
>> +if (sdformat->pad == CSI_SINK_PAD) {
>> +if (sdformat->format.field == V4L2_FIELD_ANY)
>> +sdformat->format.field = V4L2_FIELD_NONE;
>>  return;
>> +}
>>
>>  switch (infmt->field) {
>>  case V4L2_FIELD_SEQ_TB:
>> @@ -1455,8 +1461,6 @@ static void csi_try_fmt(struct csi_priv *priv,
>>  /* propagate colorimetry from sink */
>>  sdformat->format.colorspace = infmt->colorspace;
>>  sdformat->format.xfer_func = infmt->xfer_func;
>> -sdformat->format.quantization = infmt->quantization;
>> -sdformat->format.ycbcr_enc = 

Re: [PATCH v2] media: imx7-mipi-csis: Add a check for devm_regulator_get

2019-10-17 Thread Rui Miguel Silva
Hi Chuhong,
many thanks for the patch.

On Tue 15 Oct 2019 at 14:59, Chuhong Yuan wrote:
> devm_regulator_get may return an error but mipi_csis_phy_init misses
> a check for it.
> This may lead to problems when regulator_set_voltage uses the unchecked
> pointer.
> This patch adds a check for devm_regulator_get to avoid potential risk.
>
> Signed-off-by: Chuhong Yuan 

Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui

> ---
> Changes in v2:
>   - Add a check in mipi_csis_probe for the modified mipi_csis_phy_init.
>
>  drivers/staging/media/imx/imx7-mipi-csis.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 73d8354e618c..e8a6acaa969e 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -350,6 +350,8 @@ static void mipi_csis_sw_reset(struct csi_state *state)
>  static int mipi_csis_phy_init(struct csi_state *state)
>  {
>   state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
> + if (IS_ERR(state->mipi_phy_regulator))
> + return PTR_ERR(state->mipi_phy_regulator);
>
>   return regulator_set_voltage(state->mipi_phy_regulator, 100,
>100);
> @@ -966,7 +968,10 @@ static int mipi_csis_probe(struct platform_device *pdev)
>   return ret;
>   }
>
> - mipi_csis_phy_init(state);
> + ret = mipi_csis_phy_init(state);
> + if (ret < 0)
> + return ret;
> +
>   mipi_csis_phy_reset(state);
>
>   mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] media: imx7-mipi-csis: Add a check for devm_regulator_get

2019-10-17 Thread Rui Miguel Silva
Hi Marco,
On Thu 17 Oct 2019 at 09:10, Marco Felsch wrote:
> Hi Rui,
>
> On 19-10-16 14:43, Rui Miguel Silva wrote:
>> Hi Marco,
>> On Wed 16 Oct 2019 at 10:06, Marco Felsch wrote:
>> > Hi Chuhong,
>> >
>> > On 19-10-15 21:59, Chuhong Yuan wrote:
>> >> devm_regulator_get may return an error but mipi_csis_phy_init misses
>> >> a check for it.
>> >> This may lead to problems when regulator_set_voltage uses the unchecked
>> >> pointer.
>> >> This patch adds a check for devm_regulator_get to avoid potential risk.
>> >>
>> >> Signed-off-by: Chuhong Yuan 
>> >> ---
>> >> Changes in v2:
>> >>   - Add a check in mipi_csis_probe for the modified mipi_csis_phy_init.
>> >
>> > Did you miss the check for -EPROBE_DEFER?
>> >
>>
>> I think nothing special is really needed to do in case of
>> EPROBE_DEFER, or am I missing something?
>> It just return to probe and probe returns also. I just talked
>> about it because it was not cover in the original code.
>
> Yes, your are right... I shouldn't comment on anything I read with one
> eye. Sorry.
>

ehehe, no problem and thanks for your inputs.

---
Cheers,
Rui

>
> Regards,
>   Marco
>
>> ---
>> Cheers,
>>  Rui
>>
>> >
>> > Regards,
>> >   Marco
>> >
>> >>
>> >>  drivers/staging/media/imx/imx7-mipi-csis.c | 8 +++-
>> >>  1 file changed, 7 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
>> >> b/drivers/staging/media/imx/imx7-mipi-csis.c
>> >> index 73d8354e618c..e8a6acaa969e 100644
>> >> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
>> >> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
>> >> @@ -350,6 +350,8 @@ static void mipi_csis_sw_reset(struct csi_state 
>> >> *state)
>> >>  static int mipi_csis_phy_init(struct csi_state *state)
>> >>  {
>> >>   state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
>> >> + if (IS_ERR(state->mipi_phy_regulator))
>> >> + return PTR_ERR(state->mipi_phy_regulator);
>> >>
>> >>   return regulator_set_voltage(state->mipi_phy_regulator, 100,
>> >>100);
>> >> @@ -966,7 +968,10 @@ static int mipi_csis_probe(struct platform_device 
>> >> *pdev)
>> >>   return ret;
>> >>   }
>> >>
>> >> - mipi_csis_phy_init(state);
>> >> + ret = mipi_csis_phy_init(state);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >>   mipi_csis_phy_reset(state);
>> >>
>> >>   mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> >> --
>> >> 2.20.1
>> >>
>> >>
>> >>
>>
>>

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] media: imx7-mipi-csis: Add a check for devm_regulator_get

2019-10-16 Thread Rui Miguel Silva
Hi Marco,
On Wed 16 Oct 2019 at 10:06, Marco Felsch wrote:
> Hi Chuhong,
>
> On 19-10-15 21:59, Chuhong Yuan wrote:
>> devm_regulator_get may return an error but mipi_csis_phy_init misses
>> a check for it.
>> This may lead to problems when regulator_set_voltage uses the unchecked
>> pointer.
>> This patch adds a check for devm_regulator_get to avoid potential risk.
>>
>> Signed-off-by: Chuhong Yuan 
>> ---
>> Changes in v2:
>>   - Add a check in mipi_csis_probe for the modified mipi_csis_phy_init.
>
> Did you miss the check for -EPROBE_DEFER?
>

I think nothing special is really needed to do in case of
EPROBE_DEFER, or am I missing something?
It just return to probe and probe returns also. I just talked
about it because it was not cover in the original code.

---
Cheers,
Rui

>
> Regards,
>   Marco
>
>>
>>  drivers/staging/media/imx/imx7-mipi-csis.c | 8 +++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
>> b/drivers/staging/media/imx/imx7-mipi-csis.c
>> index 73d8354e618c..e8a6acaa969e 100644
>> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
>> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
>> @@ -350,6 +350,8 @@ static void mipi_csis_sw_reset(struct csi_state *state)
>>  static int mipi_csis_phy_init(struct csi_state *state)
>>  {
>>  state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
>> +if (IS_ERR(state->mipi_phy_regulator))
>> +return PTR_ERR(state->mipi_phy_regulator);
>>
>>  return regulator_set_voltage(state->mipi_phy_regulator, 100,
>>   100);
>> @@ -966,7 +968,10 @@ static int mipi_csis_probe(struct platform_device *pdev)
>>  return ret;
>>  }
>>
>> -mipi_csis_phy_init(state);
>> +ret = mipi_csis_phy_init(state);
>> +if (ret < 0)
>> +return ret;
>> +
>>  mipi_csis_phy_reset(state);
>>
>>  mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> --
>> 2.20.1
>>
>>
>>

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] media: imx7-mipi-csis: Add a check for devm_regulator_get

2019-10-15 Thread Rui Miguel Silva
Hi Chuhong,
Thanks for the patch.

On Mon 14 Oct 2019 at 03:08, Chuhong Yuan wrote:
> devm_regulator_get may return an error but mipi_csis_phy_init misses
> a check for it.
> This may lead to problems when regulator_set_voltage uses the unchecked
> pointer.
> This patch adds a check for devm_regulator_get to avoid potential risk.
>
> Signed-off-by: Chuhong Yuan 
> ---
>  drivers/staging/media/imx/imx7-mipi-csis.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 73d8354e618c..9a07b54c4ab1 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -350,6 +350,8 @@ static void mipi_csis_sw_reset(struct csi_state *state)
>  static int mipi_csis_phy_init(struct csi_state *state)
>  {
>   state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
> + if (IS_ERR(state->mipi_phy_regulator))
> + return PTR_ERR(state->mipi_phy_regulator);

This regulator is marked as mandatory in the device tree entry,
however it looks good to me to have this check, even because it
can return -EPROBE_DEFER and we need to retry.

But for that we may need to extend this patch to make the caller
of this (mipi_csis_probe), to also really care about the returned
code.

Cheers,
   Rui

>
>   return regulator_set_voltage(state->mipi_phy_regulator, 100,
>100);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: media: imx: make use devm_platform_ioremap_resource

2019-10-08 Thread Rui Miguel Silva
Hi Hariprasad,
Thanks for the patch
On Tue 08 Oct 2019 at 07:17, nobody wrote:
> From: Hariprasad Kelam 
>

Something went wrong formating the patch email, no To: nor From:

>
> fix below issue reported by coccicheck
> drivers/staging//media/imx/imx7-mipi-csis.c:973:1-12: WARNING: Use
> devm_platform_ioremap_resource for state -> regs
>

Sorry, but someone else, Jeeeun, already sent a patch for this
[0]. Thanks anyway.

---
Cheers,
Rui


[0]: https://lore.kernel.org/linux-media/m3wodvgec4@gmail.com/

>
> Signed-off-by: Hariprasad Kelam 
> ---
>  drivers/staging/media/imx/imx7-mipi-csis.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 73d8354..bf21db3 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -947,7 +947,6 @@ static void mipi_csis_debugfs_exit(struct csi_state 
> *state)
>  static int mipi_csis_probe(struct platform_device *pdev)
>  {
>   struct device *dev = >dev;
> - struct resource *mem_res;
>   struct csi_state *state;
>   int ret;
>
> @@ -969,8 +968,7 @@ static int mipi_csis_probe(struct platform_device *pdev)
>   mipi_csis_phy_init(state);
>   mipi_csis_phy_reset(state);
>
> - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - state->regs = devm_ioremap_resource(dev, mem_res);
> + state->regs = devm_platform_ioremap_resource(pdev, 0);
>   if (IS_ERR(state->regs))
>   return PTR_ERR(state->regs);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: media: imx: Use devm_platform_ioremap_resource().

2019-09-26 Thread Rui Miguel Silva
Hi Jeeeun,
On Thu 26 Sep 2019 at 16:55, Jeeeun Evans wrote:
> This patch fixes a warning by coccicheck:
> drivers/staging/media/imx/imx7-mipi-csis.c:973:1-12: WARNING: Use 
> devm_platform_ioremap_resource for state -> regs
>
> Use devm_platform_ioremap_resource helper which wraps platform_get_resource()
> and devm_ioremap_resource() together.
>
> Signed-off-by: Jeeeun Evans 
>

Thanks for the patch.
LGTM.

Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui


>  drivers/staging/media/imx/imx7-mipi-csis.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 73d8354e618c..bf21db38441f 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -947,7 +947,6 @@ static void mipi_csis_debugfs_exit(struct csi_state 
> *state)
>  static int mipi_csis_probe(struct platform_device *pdev)
>  {
>   struct device *dev = >dev;
> - struct resource *mem_res;
>   struct csi_state *state;
>   int ret;
>
> @@ -969,8 +968,7 @@ static int mipi_csis_probe(struct platform_device *pdev)
>   mipi_csis_phy_init(state);
>   mipi_csis_phy_reset(state);
>
> - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - state->regs = devm_ioremap_resource(dev, mem_res);
> + state->regs = devm_platform_ioremap_resource(pdev, 0);
>   if (IS_ERR(state->regs))
>   return PTR_ERR(state->regs);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] media: imx7-mipi-csis: make array 'registers' static const, makes object smaller

2019-09-10 Thread Rui Miguel Silva
Hi Colin,
Thanks for the patch.

On Fri 06 Sep 2019 at 16:08, Colin King wrote:
> From: Colin Ian King 
>
> Don't populate the array 'registers' on the stack but instead make it
> static const. Makes the object code smaller by 10 bytes.
>
>
> Before:
>text  data bss dec hex filename
>   20138  5196 128   254626376 
> staging/media/imx/imx7-mipi-csis.o
>
> After:
>text  data bss dec hex filename
>   20032  5292 128   25452636c 
> staging/media/imx/imx7-mipi-csis.o
>
> (gcc version 9.2.1, amd64)
>
> Signed-off-by: Colin Ian King 

Looks very good to me.
Reviewed-by: Rui Miguel Silva 

Cheers,
   Rui
> ---
>  drivers/staging/media/imx/imx7-mipi-csis.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 73d8354e618c..f8a97b7e2535 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -293,7 +293,7 @@ static int mipi_csis_dump_regs(struct csi_state *state)
>   struct device *dev = >pdev->dev;
>   unsigned int i;
>   u32 cfg;
> - struct {
> + static const struct {
>   u32 offset;
>   const char * const name;
>   } registers[] = {

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 15/22] media: imx7-media-csi: Create media links in bound notifier

2019-09-02 Thread Rui Miguel Silva
Hi Steve,
On Tue 06 Aug 2019 at 00:34, Steve Longerbeam wrote:
> Implement a notifier bound op to register media links from the remote
> sub-device's source pad(s) to the CSI sink pad.
>
> Signed-off-by: Steve Longerbeam 
> ---
>  drivers/staging/media/imx/imx7-media-csi.c | 24 ++
>  1 file changed, 24 insertions(+)
>
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
> b/drivers/staging/media/imx/imx7-media-csi.c
> index a1c96c52a606..f71ac485f780 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -196,6 +196,11 @@ struct imx7_csi {
>   struct completion last_eof_completion;
>  };
>
> +static inline struct imx7_csi *notifier_to_dev(struct v4l2_async_notifier *n)
>

As the other one add the namespace for the function name:
imx7_csi_notifier_to_dev

other than this, looks good to me.

Cheers,
  Rui
> +{
> + return container_of(n, struct imx7_csi, notifier);
> +}
> +
>  static u32 imx7_csi_reg_read(struct imx7_csi *csi, unsigned int offset)
>  {
>   return readl(csi->regbase + offset);
> @@ -1173,6 +1178,23 @@ static int imx7_csi_parse_endpoint(struct device *dev,
>   return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL;
>  }
>
> +static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier,
> +  struct v4l2_subdev *sd,
> +  struct v4l2_async_subdev *asd)
> +{
> + struct imx7_csi *csi = notifier_to_dev(notifier);
> + struct media_pad *sink = >sd.entity.pads[IMX7_CSI_PAD_SINK];
> +
> + return media_create_fwnode_pad_links(sink,
> +  dev_fwnode(csi->sd.dev),
> +  >entity,
> +  dev_fwnode(sd->dev), 0);
> +}
> +
> +static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = {
> + .bound = imx7_csi_notify_bound,
> +};
> +
>  static int imx7_csi_probe(struct platform_device *pdev)
>  {
>   struct device *dev = >dev;
> @@ -1253,6 +1275,8 @@ static int imx7_csi_probe(struct platform_device *pdev)
>
>   v4l2_async_notifier_init(>notifier);
>
> + csi->notifier.ops = _csi_notify_ops;
> +
>   ret = v4l2_async_register_fwnode_subdev(>sd, >notifier,
>   sizeof(struct 
> v4l2_async_subdev),
>   NULL, 0,

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 14/22] media: imx7-mipi-csis: Create media links in bound notifier

2019-09-02 Thread Rui Miguel Silva
Hi Steve,
Just to let you know that this series no longer apply clean after
your other series:
media: imx: Fix subdev unregister/register issues

And since you will need to send a new one, some notes...

On Tue 06 Aug 2019 at 00:34, Steve Longerbeam wrote:
> Implement a notifier bound op to register media links from the remote
> sub-device's source pad(s) to the mipi csi-2 receiver sink pad.
>
> Signed-off-by: Steve Longerbeam 
> ---
>  drivers/staging/media/imx/imx7-mipi-csis.c | 25 ++
>  1 file changed, 25 insertions(+)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
> b/drivers/staging/media/imx/imx7-mipi-csis.c
> index f71d9183cad2..e03b2317a1ac 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -259,6 +259,12 @@ struct csi_state {
>   bool sink_linked;
>  };
>
> +static inline struct csi_state *
> +notifier_to_csis_state(struct v4l2_async_notifier *n)
>

instead of adding this between structs declaration can you move it
down near the similar converter:

static struct csi_state *mipi_sd_to_csis_state(struct v4l2_subdev *sdev)

and remove the inline since the compiler should do this and add
namespacing function name like the other functions, something like:

static struct csi_state * mipi_notifier_to_csis_state(struct 
v4l2_async_notifier *n)

Just to coherency.

Other than this, looks good to me.

Cheers,
   Rui

> +{
> + return container_of(n, struct csi_state, notifier);
> +}
> +
>  struct csis_pix_format {
>   unsigned int pix_width_alignment;
>   u32 code;
> @@ -863,6 +869,23 @@ static int mipi_csis_parse_endpoint(struct device *dev,
>   return 0;
>  }
>
> +static int mipi_csis_notify_bound(struct v4l2_async_notifier *notifier,
> +   struct v4l2_subdev *sd,
> +   struct v4l2_async_subdev *asd)
> +{
> + struct csi_state *state = notifier_to_csis_state(notifier);
> + struct media_pad *sink = >mipi_sd.entity.pads[CSIS_PAD_SINK];
> +
> + return media_create_fwnode_pad_links(sink,
> +  dev_fwnode(state->mipi_sd.dev),
> +  >entity,
> +  dev_fwnode(sd->dev), 0);
> +}
> +
> +static const struct v4l2_async_notifier_operations mipi_csis_notify_ops = {
> + .bound = mipi_csis_notify_bound,
> +};
> +
>  static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd,
>struct platform_device *pdev,
>const struct v4l2_subdev_ops *ops)
> @@ -895,6 +918,8 @@ static int mipi_csis_subdev_init(struct v4l2_subdev 
> *mipi_sd,
>
>   v4l2_async_notifier_init(>notifier);
>
> + state->notifier.ops = _csis_notify_ops;
> +
>   ret = v4l2_async_register_fwnode_subdev(mipi_sd, >notifier,
>   sizeof(struct 
> v4l2_async_subdev),
>   _port, 1,

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: light: fix a couple double frees

2019-08-29 Thread Rui Miguel Silva
Hi Dan,
On Thu 29 Aug 2019 at 13:28, Dan Carpenter wrote:
> The problem is in gb_lights_request_handler().  If we get a request to
> change the config then we release the light with gb_lights_light_release()
> and re-allocated it.  However, if the allocation fails part way through
> then we call gb_lights_light_release() again.  This can lead to a couple
> different double frees where we haven't cleared out the original values:
>
>   gb_lights_light_v4l2_unregister(light);
>   ...
>   kfree(light->channels);
>   kfree(light->name);
>
> I also made a small change to how we set "light->channels_count = 0;".
> The original code handled this part fine and did not cause a use after
> free but it was sort of complicated to read.
>
> Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
> Signed-off-by: Dan Carpenter 
>

Thanks so much for this, I was looking for some time at this and
was half way to a much less elegant fix then yours.

Acked-by: Rui Miguel Silva 

Cheers,
Rui

> ---
>  drivers/staging/greybus/light.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index 010ae1e9c7fb..40680eaf3974 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -1098,21 +1098,21 @@ static void gb_lights_channel_release(struct 
> gb_channel *channel)
>  static void gb_lights_light_release(struct gb_light *light)
>  {
>   int i;
> - int count;
>
>   light->ready = false;
>
> - count = light->channels_count;
> -
>   if (light->has_flash)
>   gb_lights_light_v4l2_unregister(light);
> + light->has_flash = false;
>
> - for (i = 0; i < count; i++) {
> + for (i = 0; i < light->channels_count; i++)
>   gb_lights_channel_release(>channels[i]);
> - light->channels_count--;
> - }
> + light->channels_count = 0;
> +
>   kfree(light->channels);
> + light->channels = NULL;
>   kfree(light->name);
> + light->name = NULL;
>  }
>
>  static void gb_lights_release(struct gb_lights *glights)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: greybus: add missing includes

2019-08-28 Thread Rui Miguel Silva
Hi Randy,
On Wed 28 Aug 2019 at 16:09, Randy Dunlap wrote:
> On 8/28/19 1:35 AM, Greg Kroah-Hartman wrote:
>> On Tue, Aug 27, 2019 at 09:59:17PM +0100, Rui Miguel Silva wrote:
>>> Before moving greybus core out of staging and moving header files to
>>> include/linux some greybus header files were missing the necessary
>>> includes. This would trigger compilation faillures with some example
>>> errors logged bellow for with CONFIG_KERNEL_HEADER_TEST=y.
>>>
>>> So, add the necessary headers to compile clean before relocating the
>>> header files.
>>>
>>> ./include/linux/greybus/hd.h:23:50: error: unknown type name 'u16'
>>>   int (*cport_disable)(struct gb_host_device *hd, u16 cport_id); ^~~
>>> ./include/linux/greybus/greybus_protocols.h:1314:2: error: unknown type 
>>> name '__u8'
>>>   __u8 data[0];
>>>   ^~~~
>>> ./include/linux/greybus/hd.h:24:52: error: unknown type name 'u16'
>>>   int (*cport_connected)(struct gb_host_device *hd, u16 cport_id); ^~~
>>> ./include/linux/greybus/hd.h:25:48: error: unknown type name 'u16'
>>>   int (*cport_flush)(struct gb_host_device *hd, u16 cport_id); ^~~
>>> ./include/linux/greybus/hd.h:26:51: error: unknown type name 'u16'
>>>   int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id, ^~~
>>> ./include/linux/greybus/hd.h:27:5: error: unknown type name 'u8'
>>> u8 phase, unsigned int timeout);
>>>  ^~
>>> ./include/linux/greybus/hd.h:28:50: error: unknown type name 'u16'
>>>   int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id, ^~~
>>> ./include/linux/greybus/hd.h:29:5: error: unknown type name 'size_t'
>>>  size_t peer_space, unsigned int timeout);
>>>  ^~
>>> ./include/linux/greybus/hd.h:29:5: note: 'size_t' is defined in header 
>>> ''; did you forget to '#include '?
>>> ./include/linux/greybus/hd.h:1:1:
>>> +#include 
>>>  /* SPDX-License-Identifier: GPL-2.0 */
>>> ./include/linux/greybus/hd.h:29:5:
>>>  size_t peer_space, unsigned int timeout);
>>>  ^~
>>> ./include/linux/greybus/hd.h:30:48: error: unknown type name 'u16'
>>>   int (*cport_clear)(struct gb_host_device *hd, u16 cport_id); ^~~
>>> ./include/linux/greybus/hd.h:32:49: error: unknown type name 'u16'
>>>   int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id, ^~~
>>> ./include/linux/greybus/hd.h:33:32: error: unknown type name 'gfp_t'
>>> struct gb_message *message, gfp_t gfp_mask); ^
>>> ./include/linux/greybus/hd.h:35:55: error: unknown type name 'u16'
>>>   int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);
>>>
>>> Reported-by: kbuild test robot 
>>> Reported-by: Gao Xiang 
>>> Signed-off-by: Rui Miguel Silva 
>>> Acked-by: Alex Elder 
>>> ---
>>>
>>> v1->v2:
>>> lkp@intel:
>>>   - added greybus_protocols.h include to svc.h header
>>> Alex Elder:
>>>   - remove extra line in operation.h
>>>
>>> Looks like lkp can now find missing headers that we can not :),
>>> it must be the config. but it is right.
>>>
>>> Greg please note the new include in svc.h may need to be changed
>>> when moving headers to include/linux
>>
>> As a version of your first patch is already in my tree, this one will
>> not apply :(
>>
>> Can you just send a fix-up patch against my staging-next branch instead?
>>
>> thanks,
>>
>> greg k-h
>> ___
>> devel mailing list
>> de...@linuxdriverproject.org
>> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
>>
>
> linux-next of 20190828 has these warnings:
>
> ./../include/linux/greybus/svc.h:91:18: warning: 'struct gb_svc_l2_timer_cfg' 
> declared inside parameter list will not be visible outside of this definition 
> or declaration
> ./../include/linux/greybus/operation.h:188:34: warning: 'struct 
> gb_host_device' declared inside parameter list will not be visible outside of 
> this definition or declaration
>
>
> Are they fixed by some of these patches?
>

Yes, this [0] should fix it.

---
Cheers,
Rui

[0]: 
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2019-August/138016.html
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: fix more header includes

2019-08-28 Thread Rui Miguel Silva
Hi,
On Wed 28 Aug 2019 at 12:42, Greg Kroah-Hartman wrote:
> On Wed, Aug 28, 2019 at 12:47:26PM +0200, Johan Hovold wrote:
>> On Wed, Aug 28, 2019 at 11:28:59AM +0100, Rui Miguel Silva wrote:
>> > More headers needed to be fixed when moving greybus out of staging and
>> > enabling the COMPILE_TEST option.
>> >
>> > Reported-by: kbuild test robot 
>> > Signed-off-by: Rui Miguel Silva 
>> > ---
>> >  include/linux/greybus/operation.h | 1 +
>> >  include/linux/greybus/svc.h   | 2 ++
>> >  2 files changed, 3 insertions(+)
>> >
>> > diff --git a/include/linux/greybus/operation.h 
>> > b/include/linux/greybus/operation.h
>> > index 8ca864bba23e..bfbc56d8d863 100644
>> > --- a/include/linux/greybus/operation.h
>> > +++ b/include/linux/greybus/operation.h
>> > @@ -15,6 +15,7 @@
>> >  #include 
>> >  #include 
>> >
>> > +#include "hd.h"
>>
>> No need to include hd.h, you only need a forward declaration of struct
>> gb_host_device.
>>
>> >  struct gb_operation;
>> >
>> > diff --git a/include/linux/greybus/svc.h b/include/linux/greybus/svc.h
>> > index 507f8bd4e4c8..11a86504c429 100644
>> > --- a/include/linux/greybus/svc.h
>> > +++ b/include/linux/greybus/svc.h
>> > @@ -12,6 +12,8 @@
>> >  #include 
>> >  #include 
>> >
>> > +#include "greybus_protocols.h"
>>
>> Same here, no need to include all the protocol definitions for struct
>> gb_svc_l2_timer_cfg.
>
> I agree with Johan, just forward declare these things and all should be
> fine and much simpler.
>

Agree also, v2 out.

---
Cheers,
Rui

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: greybus: fix more header declarations

2019-08-28 Thread Rui Miguel Silva
More headers needed to be fixed when moving greybus out of staging and
enabling the COMPILE_TEST option.

Add forward declarations for the needed structures.

Reported-by: kbuild test robot 
Signed-off-by: Rui Miguel Silva 
---
v1->v2:
Johan Hovold:
  - use forward declarations instead including all headers

 include/linux/greybus/operation.h | 2 +-
 include/linux/greybus/svc.h   | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/greybus/operation.h 
b/include/linux/greybus/operation.h
index 8ca864bba23e..cb8e4ef45222 100644
--- a/include/linux/greybus/operation.h
+++ b/include/linux/greybus/operation.h
@@ -15,7 +15,7 @@
 #include 
 #include 
 
-
+struct gb_host_device;
 struct gb_operation;
 
 /* The default amount of time a request is given to complete */
diff --git a/include/linux/greybus/svc.h b/include/linux/greybus/svc.h
index 507f8bd4e4c8..5afaf5f06856 100644
--- a/include/linux/greybus/svc.h
+++ b/include/linux/greybus/svc.h
@@ -12,6 +12,8 @@
 #include 
 #include 
 
+struct gb_svc_l2_timer_cfg;
+
 #define GB_SVC_CPORT_FLAG_E2EFCBIT(0)
 #define GB_SVC_CPORT_FLAG_CSD_NBIT(1)
 #define GB_SVC_CPORT_FLAG_CSV_NBIT(2)
-- 
2.22.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: greybus: fix more header includes

2019-08-28 Thread Rui Miguel Silva
More headers needed to be fixed when moving greybus out of staging and
enabling the COMPILE_TEST option.

Reported-by: kbuild test robot 
Signed-off-by: Rui Miguel Silva 
---
 include/linux/greybus/operation.h | 1 +
 include/linux/greybus/svc.h   | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/include/linux/greybus/operation.h 
b/include/linux/greybus/operation.h
index 8ca864bba23e..bfbc56d8d863 100644
--- a/include/linux/greybus/operation.h
+++ b/include/linux/greybus/operation.h
@@ -15,6 +15,7 @@
 #include 
 #include 
 
+#include "hd.h"
 
 struct gb_operation;
 
diff --git a/include/linux/greybus/svc.h b/include/linux/greybus/svc.h
index 507f8bd4e4c8..11a86504c429 100644
--- a/include/linux/greybus/svc.h
+++ b/include/linux/greybus/svc.h
@@ -12,6 +12,8 @@
 #include 
 #include 
 
+#include "greybus_protocols.h"
+
 #define GB_SVC_CPORT_FLAG_E2EFCBIT(0)
 #define GB_SVC_CPORT_FLAG_CSD_NBIT(1)
 #define GB_SVC_CPORT_FLAG_CSV_NBIT(2)
-- 
2.22.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: greybus: add missing includes

2019-08-27 Thread Rui Miguel Silva
Before moving greybus core out of staging and moving header files to
include/linux some greybus header files were missing the necessary
includes. This would trigger compilation faillures with some example
errors logged bellow for with CONFIG_KERNEL_HEADER_TEST=y.

So, add the necessary headers to compile clean before relocating the
header files.

./include/linux/greybus/hd.h:23:50: error: unknown type name 'u16'
  int (*cport_disable)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/greybus_protocols.h:1314:2: error: unknown type name 
'__u8'
  __u8 data[0];
  ^~~~
./include/linux/greybus/hd.h:24:52: error: unknown type name 'u16'
  int (*cport_connected)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:25:48: error: unknown type name 'u16'
  int (*cport_flush)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:26:51: error: unknown type name 'u16'
  int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id, ^~~
./include/linux/greybus/hd.h:27:5: error: unknown type name 'u8'
u8 phase, unsigned int timeout);
 ^~
./include/linux/greybus/hd.h:28:50: error: unknown type name 'u16'
  int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id, ^~~
./include/linux/greybus/hd.h:29:5: error: unknown type name 'size_t'
 size_t peer_space, unsigned int timeout);
 ^~
./include/linux/greybus/hd.h:29:5: note: 'size_t' is defined in header 
''; did you forget to '#include '?
./include/linux/greybus/hd.h:1:1:
+#include 
 /* SPDX-License-Identifier: GPL-2.0 */
./include/linux/greybus/hd.h:29:5:
 size_t peer_space, unsigned int timeout);
 ^~
./include/linux/greybus/hd.h:30:48: error: unknown type name 'u16'
  int (*cport_clear)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:32:49: error: unknown type name 'u16'
  int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id, ^~~
./include/linux/greybus/hd.h:33:32: error: unknown type name 'gfp_t'
struct gb_message *message, gfp_t gfp_mask); ^
./include/linux/greybus/hd.h:35:55: error: unknown type name 'u16'
  int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);

Reported-by: kbuild test robot 
Reported-by: Gao Xiang 
Signed-off-by: Rui Miguel Silva 
Acked-by: Alex Elder 
---

v1->v2:
lkp@intel:
  - added greybus_protocols.h include to svc.h header
Alex Elder:
  - remove extra line in operation.h

Looks like lkp can now find missing headers that we can not :),
it must be the config. but it is right.

Greg please note the new include in svc.h may need to be changed
when moving headers to include/linux

 drivers/staging/greybus/bundle.h| 3 +++
 drivers/staging/greybus/connection.h| 3 +++
 drivers/staging/greybus/control.h   | 3 +++
 drivers/staging/greybus/greybus_manifest.h  | 3 +++
 drivers/staging/greybus/greybus_protocols.h | 2 ++
 drivers/staging/greybus/hd.h| 3 +++
 drivers/staging/greybus/interface.h | 3 +++
 drivers/staging/greybus/manifest.h  | 2 ++
 drivers/staging/greybus/module.h| 3 +++
 drivers/staging/greybus/operation.h | 4 
 drivers/staging/greybus/svc.h   | 5 +
 11 files changed, 34 insertions(+)

diff --git a/drivers/staging/greybus/bundle.h b/drivers/staging/greybus/bundle.h
index 8734d2055657..69fe5610bb42 100644
--- a/drivers/staging/greybus/bundle.h
+++ b/drivers/staging/greybus/bundle.h
@@ -9,7 +9,10 @@
 #ifndef __BUNDLE_H
 #define __BUNDLE_H
 
+#include 
 #include 
+#include 
+#include 
 
 #defineBUNDLE_ID_NONE  U8_MAX
 
diff --git a/drivers/staging/greybus/connection.h 
b/drivers/staging/greybus/connection.h
index 5ca3befc0636..d59b7fc1de3e 100644
--- a/drivers/staging/greybus/connection.h
+++ b/drivers/staging/greybus/connection.h
@@ -9,8 +9,11 @@
 #ifndef __CONNECTION_H
 #define __CONNECTION_H
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #define GB_CONNECTION_FLAG_CSD BIT(0)
 #define GB_CONNECTION_FLAG_NO_FLOWCTRL BIT(1)
diff --git a/drivers/staging/greybus/control.h 
b/drivers/staging/greybus/control.h
index 3a29ec05f631..0d4e2ed20fe4 100644
--- a/drivers/staging/greybus/control.h
+++ b/drivers/staging/greybus/control.h
@@ -9,6 +9,9 @@
 #ifndef __CONTROL_H
 #define __CONTROL_H
 
+#include 
+#include 
+
 struct gb_control {
struct device dev;
struct gb_interface *intf;
diff --git a/drivers/staging/greybus/greybus_manifest.h 
b/drivers/staging/greybus/greybus_manifest.h
index 2cec5cf7a846..1cb60af4febd 100644
--- a/drivers/staging/greybus/greybus_manifest.h
+++ b/drivers/staging/greybus/greybus_manifest.h
@@ -14,6 +14,9 @@
 #ifndef __GREYBUS_MANIFEST_H
 #define __GREYBUS_MANIFEST_H
 
+#include 
+#include 
+
 enum greybus_descriptor_type {
GREYBUS_TYPE_INVALID= 0x00,
GREYBUS_TYPE_INTERFACE  = 0x01,
diff --git a/drivers/staging/greybus/greybus_protocols.h 
b/drivers/staging/greybus/greybus_protocols.h
in

Re: [PATCH] staging: greybus: add missing includes

2019-08-27 Thread Rui Miguel Silva
Hi Alex,
On Tue 27 Aug 2019 at 18:22, Alex Elder wrote:
> On 8/27/19 10:53 AM, Rui Miguel Silva wrote:
>> Before moving greybus core out of staging and moving header files to
>> include/linux some greybus header files were missing the necessary
>> includes. This would trigger compilation faillures with some example
>> errors logged bellow for with CONFIG_KERNEL_HEADER_TEST=y.
>>
>> So, add the necessary headers to compile clean before relocating the
>> header files.
>
> This looks good to me; I trust you compiled it.
>

Yeah, in the staging and in the new location to make sure it
make the compilation issues go away.

> There is one extra
> blank line you added in "operation.h" but that's not important.
>

Right, I missed that.

>
> I don't think what I've done here serves as a real review, so:
>
> Acked-by: Alex Elder 
>

I think Greg already queued up this one in staging-next,
nevertheless many thanks for the acked.

---
Cheers,
Rui
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/9] staging: move greybus core out of staging

2019-08-27 Thread Rui Miguel Silva
Hi Greg,
On Tue 27 Aug 2019 at 16:43, Greg KH wrote:
> On Tue, Aug 27, 2019 at 03:30:21PM +0100, Rui Miguel Silva wrote:
>> Hi,
>> On Tue 27 Aug 2019 at 14:45, Greg Kroah-Hartman wrote:
>> > On Tue, Aug 27, 2019 at 04:36:11PM +0300, Dan Carpenter wrote:
>> >> I can't compile greybus so it's hard to run Smatch on it...  I have a
>> >> Smatch thing which ignores missing includes and just tries its best.
>> >> It mostly generates garbage output but a couple of these look like
>> >> potential issues:
>> >
>> > Why can't you compile the code?
>> >
>>
>> I think we are missing includes in some of the
>> greybus header files.
>
> Really?  Where?  Builds fine here and passes 0-day :)
>

Yeah; just sent a patch to fix it.

Cheers,
   Rui
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: greybus: add missing includes

2019-08-27 Thread Rui Miguel Silva
Before moving greybus core out of staging and moving header files to
include/linux some greybus header files were missing the necessary
includes. This would trigger compilation faillures with some example
errors logged bellow for with CONFIG_KERNEL_HEADER_TEST=y.

So, add the necessary headers to compile clean before relocating the
header files.

./include/linux/greybus/hd.h:23:50: error: unknown type name 'u16'
  int (*cport_disable)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/greybus_protocols.h:1314:2: error: unknown type name 
'__u8'
  __u8 data[0];
  ^~~~
./include/linux/greybus/hd.h:24:52: error: unknown type name 'u16'
  int (*cport_connected)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:25:48: error: unknown type name 'u16'
  int (*cport_flush)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:26:51: error: unknown type name 'u16'
  int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id, ^~~
./include/linux/greybus/hd.h:27:5: error: unknown type name 'u8'
u8 phase, unsigned int timeout);
 ^~
./include/linux/greybus/hd.h:28:50: error: unknown type name 'u16'
  int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id, ^~~
./include/linux/greybus/hd.h:29:5: error: unknown type name 'size_t'
 size_t peer_space, unsigned int timeout);
 ^~
./include/linux/greybus/hd.h:29:5: note: 'size_t' is defined in header 
''; did you forget to '#include '?
./include/linux/greybus/hd.h:1:1:
+#include 
 /* SPDX-License-Identifier: GPL-2.0 */
./include/linux/greybus/hd.h:29:5:
 size_t peer_space, unsigned int timeout);
 ^~
./include/linux/greybus/hd.h:30:48: error: unknown type name 'u16'
  int (*cport_clear)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:32:49: error: unknown type name 'u16'
  int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id, ^~~
./include/linux/greybus/hd.h:33:32: error: unknown type name 'gfp_t'
struct gb_message *message, gfp_t gfp_mask); ^
./include/linux/greybus/hd.h:35:55: error: unknown type name 'u16'
  int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);

Signed-off-by: Rui Miguel Silva 
Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/greybus/bundle.h| 3 +++
 drivers/staging/greybus/connection.h| 3 +++
 drivers/staging/greybus/control.h   | 3 +++
 drivers/staging/greybus/greybus_manifest.h  | 3 +++
 drivers/staging/greybus/greybus_protocols.h | 2 ++
 drivers/staging/greybus/hd.h| 3 +++
 drivers/staging/greybus/interface.h | 3 +++
 drivers/staging/greybus/manifest.h  | 2 ++
 drivers/staging/greybus/module.h| 3 +++
 drivers/staging/greybus/operation.h | 5 +
 drivers/staging/greybus/svc.h   | 3 +++
 11 files changed, 33 insertions(+)

diff --git a/drivers/staging/greybus/bundle.h b/drivers/staging/greybus/bundle.h
index 8734d2055657..69fe5610bb42 100644
--- a/drivers/staging/greybus/bundle.h
+++ b/drivers/staging/greybus/bundle.h
@@ -9,7 +9,10 @@
 #ifndef __BUNDLE_H
 #define __BUNDLE_H
 
+#include 
 #include 
+#include 
+#include 
 
 #defineBUNDLE_ID_NONE  U8_MAX
 
diff --git a/drivers/staging/greybus/connection.h 
b/drivers/staging/greybus/connection.h
index 5ca3befc0636..d59b7fc1de3e 100644
--- a/drivers/staging/greybus/connection.h
+++ b/drivers/staging/greybus/connection.h
@@ -9,8 +9,11 @@
 #ifndef __CONNECTION_H
 #define __CONNECTION_H
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #define GB_CONNECTION_FLAG_CSD BIT(0)
 #define GB_CONNECTION_FLAG_NO_FLOWCTRL BIT(1)
diff --git a/drivers/staging/greybus/control.h 
b/drivers/staging/greybus/control.h
index 3a29ec05f631..0d4e2ed20fe4 100644
--- a/drivers/staging/greybus/control.h
+++ b/drivers/staging/greybus/control.h
@@ -9,6 +9,9 @@
 #ifndef __CONTROL_H
 #define __CONTROL_H
 
+#include 
+#include 
+
 struct gb_control {
struct device dev;
struct gb_interface *intf;
diff --git a/drivers/staging/greybus/greybus_manifest.h 
b/drivers/staging/greybus/greybus_manifest.h
index 2cec5cf7a846..1cb60af4febd 100644
--- a/drivers/staging/greybus/greybus_manifest.h
+++ b/drivers/staging/greybus/greybus_manifest.h
@@ -14,6 +14,9 @@
 #ifndef __GREYBUS_MANIFEST_H
 #define __GREYBUS_MANIFEST_H
 
+#include 
+#include 
+
 enum greybus_descriptor_type {
GREYBUS_TYPE_INVALID= 0x00,
GREYBUS_TYPE_INTERFACE  = 0x01,
diff --git a/drivers/staging/greybus/greybus_protocols.h 
b/drivers/staging/greybus/greybus_protocols.h
index ddc73f10eb22..e883edb50ed8 100644
--- a/drivers/staging/greybus/greybus_protocols.h
+++ b/drivers/staging/greybus/greybus_protocols.h
@@ -53,6 +53,8 @@
 #ifndef __GREYBUS_PROTOCOLS_H
 #define __GREYBUS_PROTOCOLS_H
 
+#include 
+
 /* Fixed IDs for control/svc protocols */
 
 /* SVC switch-port device ids */
diff --git a/drivers/staging/greybus/hd.h b/drivers/staging/greybus/hd.h
index

Re: [PATCH 0/9] staging: move greybus core out of staging

2019-08-27 Thread Rui Miguel Silva
Hi,
On Tue 27 Aug 2019 at 14:45, Greg Kroah-Hartman wrote:
> On Tue, Aug 27, 2019 at 04:36:11PM +0300, Dan Carpenter wrote:
>> I can't compile greybus so it's hard to run Smatch on it...  I have a
>> Smatch thing which ignores missing includes and just tries its best.
>> It mostly generates garbage output but a couple of these look like
>> potential issues:
>
> Why can't you compile the code?
>

I think we are missing includes in some of the
greybus header files.

>
>> drivers/staging/greybus/operation.c:379 gb_operation_message_alloc() warn: 
>> check 'message_size' for integer overflows 'kzalloc()'
>
> That should be checked on line 368, right?
>
>> drivers/staging/greybus/light.c:1256 gb_lights_request_handler() warn: 
>> 'light->channels' double freed
>> drivers/staging/greybus/light.c:1256 gb_lights_request_handler() warn: 
>> 'light->name' double freed
>
> I don't understand this warning, how are these potentially double freed?
>
> And the light.c file isn't moving out of drivers/staging/ just yet :)
>

I will take a look at this also.

Cheers,
   Rui


Re: [PATCH v3 2/3] media: imx7-media-csi: add i.MX6UL support

2019-08-01 Thread Rui Miguel Silva
Hi Sebastien,
Thanks for the patch.

On Wed 31 Jul 2019 at 17:33, Sébastien Szymanski wrote:
> i.MX7 and i.MX6UL/L have the same CSI controller. So add i.MX6UL/L support
> to imx7-media-csi driver.
>
> Signed-off-by: Sébastien Szymanski 
>

LGTM. Thanks for adding the support to this imx6ul/l soc.

Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui

> ---
>
> Changes for v3:
> - rebase on Linux v5.3-rc2
> - remove csi_soc_id var as it's not needed anymore thanks to commit
>   e0c76a7d3428 ("media: imx7-media-csi: get csi upstream endpoint")
>
> Changes for v2:
>  - rebase on top of linuxtv/master
>  - mention i.MX6UL/L in header and Kconfig help text
>  - rename csi_type to csi_soc_id
>
>  drivers/staging/media/imx/Kconfig  |  4 +--
>  drivers/staging/media/imx/imx7-media-csi.c | 30 +++---
>  2 files changed, 23 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/media/imx/Kconfig 
> b/drivers/staging/media/imx/Kconfig
> index 4c726345dc25..f51476243016 100644
> --- a/drivers/staging/media/imx/Kconfig
> +++ b/drivers/staging/media/imx/Kconfig
> @@ -22,11 +22,11 @@ config VIDEO_IMX_CSI
> A video4linux camera sensor interface driver for i.MX5/6.
>
>  config VIDEO_IMX7_CSI
> - tristate "i.MX7 Camera Sensor Interface driver"
> + tristate "i.MX6UL/L / i.MX7 Camera Sensor Interface driver"
>   depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
>   default y
>   help
> Enable support for video4linux camera sensor interface driver for
> -   i.MX7.
> +   i.MX6UL/L or i.MX7.
>  endmenu
>  endif
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
> b/drivers/staging/media/imx/imx7-media-csi.c
> index 500b4c08d967..4ca79ff4c9b3 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC
> + * V4L2 Capture CSI Subdev for Freescale i.MX6UL/L / i.MX7 SOC
>   *
>   * Copyright (c) 2019 Linaro Ltd
>   *
> @@ -765,6 +765,7 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>   struct v4l2_pix_format *out_pix = >fmt.fmt.pix;
>   __u32 in_code = csi->format_mbus[IMX7_CSI_PAD_SINK].code;
>   u32 cr1, cr18;
> + int width = out_pix->width;
>
>   if (out_pix->field == V4L2_FIELD_INTERLACED) {
>   imx7_csi_deinterlace_enable(csi, true);
> @@ -774,15 +775,27 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>   imx7_csi_buf_stride_set(csi, 0);
>   }
>
> - imx7_csi_set_imagpara(csi, out_pix->width, out_pix->height);
> + cr18 = imx7_csi_reg_read(csi, CSI_CSICR18);
> +
> + if (!csi->is_csi2) {
> + if (out_pix->pixelformat == V4L2_PIX_FMT_UYVY ||
> + out_pix->pixelformat == V4L2_PIX_FMT_YUYV)
> + width *= 2;
> +
> + imx7_csi_set_imagpara(csi, width, out_pix->height);
> +
> + cr18 |= (BIT_BASEADDR_SWITCH_EN | BIT_BASEADDR_SWITCH_SEL |
> + BIT_BASEADDR_CHG_ERR_EN);
> + imx7_csi_reg_write(csi, cr18, CSI_CSICR18);
>
> - if (!csi->is_csi2)
>   return 0;
> + }
> +
> + imx7_csi_set_imagpara(csi, width, out_pix->height);
>
>   cr1 = imx7_csi_reg_read(csi, CSI_CSICR1);
>   cr1 &= ~BIT_GCLK_MODE;
>
> - cr18 = imx7_csi_reg_read(csi, CSI_CSICR18);
>   cr18 &= BIT_MIPI_DATA_FORMAT_MASK;
>   cr18 |= BIT_DATA_FROM_MIPI;
>
> @@ -817,11 +830,9 @@ static void imx7_csi_enable(struct imx7_csi *csi)
>  {
>   imx7_csi_sw_reset(csi);
>
> - if (csi->is_csi2) {
> - imx7_csi_dmareq_rff_enable(csi);
> - imx7_csi_hw_enable_irq(csi);
> - imx7_csi_hw_enable(csi);
> - }
> + imx7_csi_dmareq_rff_enable(csi);
> + imx7_csi_hw_enable_irq(csi);
> + imx7_csi_hw_enable(csi);
>  }
>
>  static void imx7_csi_disable(struct imx7_csi *csi)
> @@ -1302,6 +1313,7 @@ static int imx7_csi_remove(struct platform_device *pdev)
>
>  static const struct of_device_id imx7_csi_of_match[] = {
>   { .compatible = "fsl,imx7-csi" },
> + { .compatible = "fsl,imx6ul-csi" },
>   { },
>  };
>  MODULE_DEVICE_TABLE(of, imx7_csi_of_match);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] media: imx7-media-csi: Remove unneeded break after return

2019-07-01 Thread Rui Miguel Silva
Hi Chinmaya,
Thanks for your patch.

On Sun 30 Jun 2019 at 04:49, Chinmaya Krishnan Mahesh wrote:
> This patch fixes the checkpatch.pl warning:
>
> WARNING: break is not useful after a goto or return

but this is already fixed in the media subsystem tree, by a patch
from Fabio:

964fcacddf media: imx7-media-csi: Remove unneeded break

It is better to use that tree as reference for media fixes,
sometimes some are already fixed there.

Nevertheless many thanks for the patch.

---
Cheers,
Rui


>
> Signed-off-by: Chinmaya Krishnan Mahesh 
> ---
>  drivers/staging/media/imx/imx7-media-csi.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
> b/drivers/staging/media/imx/imx7-media-csi.c
> index a708a0340eb1..c15acca1dc0d 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -1021,7 +1021,6 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi,
>   break;
>   default:
>   return -EINVAL;
> - break;
>   }
>   return 0;
>  }

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] media: imx7-media-csi: get csi upstream endpoint

2019-06-12 Thread Rui Miguel Silva
When the upstream endpoint is neither a mux nor a CSI2 module, just get
the source pad directly upstream from the CSI.

Fixes: 05f634040c0d ("media: staging/imx7: add imx7 CSI subdev driver")
Reported-by: Sebastien Szymanski 
Signed-off-by: Rui Miguel Silva 
---
v1->v2:
Dan Carpenter:
  - s/in/is/
  - align code, and white space fix.

 drivers/staging/media/imx/imx7-media-csi.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
index 9101566f3f67..f775870df7e0 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -442,6 +442,14 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi 
*csi,
 
src = >src_sd->entity;
 
+   /*
+* if the source is neither a mux or csi2 get the one directly upstream
+* from this csi
+*/
+   if (src->function != MEDIA_ENT_F_VID_IF_BRIDGE &&
+   src->function != MEDIA_ENT_F_VID_MUX)
+   src = >sd.entity;
+
 skip_video_mux:
/* get source pad of entity directly upstream from src */
pad = imx_media_pipeline_pad(src, 0, 0, true);
-- 
2.22.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] media: imx7-media-csi: get csi upstream endpoint

2019-06-12 Thread Rui Miguel Silva
Hi Dan,
On Wed 12 Jun 2019 at 08:43, Dan Carpenter wrote:
> On Tue, Jun 11, 2019 at 04:09:55PM +0100, Rui Miguel Silva wrote:
>> When the upstream endpoint is neither a mux nor a CSI2 module, just get
>> the source pad directly upstream from the CSI.
>>
>> Fixes: 05f634040c0d ("media: staging/imx7: add imx7 CSI subdev driver")
>> Reported-by: Sebastien Szymanski 
>> Signed-off-by: Rui Miguel Silva 
>> ---
>>  drivers/staging/media/imx/imx7-media-csi.c | 8 
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
>> b/drivers/staging/media/imx/imx7-media-csi.c
>> index 9101566f3f67..8979ee0c8202 100644
>> --- a/drivers/staging/media/imx/imx7-media-csi.c
>> +++ b/drivers/staging/media/imx/imx7-media-csi.c
>> @@ -442,6 +442,14 @@ static int imx7_csi_get_upstream_endpoint(struct 
>> imx7_csi *csi,
>>
>>  src = >src_sd->entity;
>>
>> +/*
>> + * if the source in neither a mux or csi2 get the one directly upstream
>  ^^
> is?

yup.

>
>> + * from this csi
>> + */
>> +if (src->function != MEDIA_ENT_F_VID_IF_BRIDGE &&
>> +src->function != MEDIA_ENT_F_VID_MUX)
>> +src = >sd.entity;
>
> This would be easier to read if the white space were tweaked a little:
>
>   if (src->function != MEDIA_ENT_F_VID_IF_BRIDGE &&
>   src->function != MEDIA_ENT_F_VID_MUX)
>   src = >sd.entity;

Agreed, Thanks for the feedback.

---
Cheers,
Rui

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] media: imx7-media-csi: get csi upstream endpoint

2019-06-11 Thread Rui Miguel Silva
When the upstream endpoint is neither a mux nor a CSI2 module, just get
the source pad directly upstream from the CSI.

Fixes: 05f634040c0d ("media: staging/imx7: add imx7 CSI subdev driver")
Reported-by: Sebastien Szymanski 
Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx7-media-csi.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
index 9101566f3f67..8979ee0c8202 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -442,6 +442,14 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi 
*csi,
 
src = >src_sd->entity;
 
+   /*
+* if the source in neither a mux or csi2 get the one directly upstream
+* from this csi
+*/
+   if (src->function != MEDIA_ENT_F_VID_IF_BRIDGE &&
+   src->function != MEDIA_ENT_F_VID_MUX)
+   src = >sd.entity;
+
 skip_video_mux:
/* get source pad of entity directly upstream from src */
pad = imx_media_pipeline_pad(src, 0, 0, true);
-- 
2.22.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/3] media: imx7-media-csi: add i.MX6UL support

2019-06-11 Thread Rui Miguel Silva
Hi Sebastien,
On Tue 11 Jun 2019 at 11:03, Sébastien Szymanski wrote:
> On 6/11/19 11:40 AM, Rui Miguel Silva wrote:
>> Hi Sebastien,
>> On Tue 11 Jun 2019 at 09:16, Sébastien Szymanski wrote:
>>> Hi Rui,
>>>
>>> thanks for the review!
>>>
>>> On 6/10/19 12:28 PM, Rui Miguel Silva wrote:
>>>> Hi Sebastien,
>>>> Thanks for the patch.
>>>>
>>>> On Thu 06 Jun 2019 at 16:38, Sébastien Szymanski wrote:
>>>>> i.MX7 and i.MX6UL/L have the same CSI controller. So add i.MX6UL/L support
>>>>> to imx7-media-csi driver.
>>>>>
>>>>> Signed-off-by: Sébastien Szymanski 
>>>>> ---
>>>>>
>>>>> Changes for v2:
>>>>>  - rebase on top of linuxtv/master
>>>>>  - mention i.MX6UL/L in header and Kconfig help text
>>>>>  - rename csi_type to csi_soc_id
>>>>>
>>>>>  drivers/staging/media/imx/Kconfig  |  4 +-
>>>>>  drivers/staging/media/imx/imx7-media-csi.c | 62 --
>>>>>  2 files changed, 49 insertions(+), 17 deletions(-)
>>>>>
>>>>> diff --git a/drivers/staging/media/imx/Kconfig 
>>>>> b/drivers/staging/media/imx/Kconfig
>>>>> index ad3d7df6bb3c..8b6dc42c39e0 100644
>>>>> --- a/drivers/staging/media/imx/Kconfig
>>>>> +++ b/drivers/staging/media/imx/Kconfig
>>>>> @@ -22,11 +22,11 @@ config VIDEO_IMX_CSI
>>>>> A video4linux camera sensor interface driver for i.MX5/6.
>>>>>
>>>>>  config VIDEO_IMX7_CSI
>>>>> - tristate "i.MX7 Camera Sensor Interface driver"
>>>>> + tristate "i.MX6UL/L / i.MX7 Camera Sensor Interface driver"
>>>>>   depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
>>>>>   default y
>>>>>   help
>>>>> Enable support for video4linux camera sensor interface driver for
>>>>> -   i.MX7.
>>>>> +   i.MX6UL/L or i.MX7.
>>>>>  endmenu
>>>>>  endif
>>>>> diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
>>>>> b/drivers/staging/media/imx/imx7-media-csi.c
>>>>> index 9101566f3f67..902bdce594cf 100644
>>>>> --- a/drivers/staging/media/imx/imx7-media-csi.c
>>>>> +++ b/drivers/staging/media/imx/imx7-media-csi.c
>>>>> @@ -1,6 +1,6 @@
>>>>>  // SPDX-License-Identifier: GPL-2.0
>>>>>  /*
>>>>> - * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC
>>>>> + * V4L2 Capture CSI Subdev for Freescale i.MX6UL/L / i.MX7 SOC
>>>>>   *
>>>>>   * Copyright (c) 2019 Linaro Ltd
>>>>>   *
>>>>> @@ -152,6 +152,11 @@
>>>>>  #define CSI_CSICR18  0x48
>>>>>  #define CSI_CSICR19  0x4c
>>>>>
>>>>> +enum csi_soc_id {
>>>>> + IMX7,
>>>>> + IMX6UL
>>>>> +};
>>>>> +
>>>>>  struct imx7_csi {
>>>>>   struct device *dev;
>>>>>   struct v4l2_subdev sd;
>>>>> @@ -191,6 +196,7 @@ struct imx7_csi {
>>>>>   bool is_init;
>>>>>   bool is_streaming;
>>>>>   bool is_csi2;
>>>>> + enum csi_soc_id soc_id;
>>>>>
>>>>>   struct completion last_eof_completion;
>>>>>  };
>>>>> @@ -548,6 +554,14 @@ static int imx7_csi_pad_link_validate(struct 
>>>>> v4l2_subdev *sd,
>>>>>   if (ret)
>>>>>   return ret;
>>>>>
>>>>> + if (csi->soc_id == IMX6UL) {
>>>>> + mutex_lock(>lock);
>>>>> + csi->is_csi2 = false;
>>>>> + mutex_unlock(>lock);
>>>>> +
>>>>> + return 0;
>>>>> + }
>>>>> +
>>>>>   ret = imx7_csi_get_upstream_endpoint(csi, _ep, true);
>>>>>   if (ret) {
>>>>>   v4l2_err(>sd, "failed to find upstream endpoint\n");
>>>>> @@ -757,6 +771,7 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>>>>>   struct v4l2_pix_format *out_pix = >fmt.fmt.pix;
>>>>>   __u32 in_code = csi->format_mbus[IMX7_CSI_PAD_SINK].code;
>>>>>   u32 cr1, cr18;
>>>>> + int width = out_pix->width;
>>

Re: [PATCH v2 2/3] media: imx7-media-csi: add i.MX6UL support

2019-06-11 Thread Rui Miguel Silva
Hi Sebastien,
On Tue 11 Jun 2019 at 09:16, Sébastien Szymanski wrote:
> Hi Rui,
>
> thanks for the review!
>
> On 6/10/19 12:28 PM, Rui Miguel Silva wrote:
>> Hi Sebastien,
>> Thanks for the patch.
>>
>> On Thu 06 Jun 2019 at 16:38, Sébastien Szymanski wrote:
>>> i.MX7 and i.MX6UL/L have the same CSI controller. So add i.MX6UL/L support
>>> to imx7-media-csi driver.
>>>
>>> Signed-off-by: Sébastien Szymanski 
>>> ---
>>>
>>> Changes for v2:
>>>  - rebase on top of linuxtv/master
>>>  - mention i.MX6UL/L in header and Kconfig help text
>>>  - rename csi_type to csi_soc_id
>>>
>>>  drivers/staging/media/imx/Kconfig  |  4 +-
>>>  drivers/staging/media/imx/imx7-media-csi.c | 62 --
>>>  2 files changed, 49 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/drivers/staging/media/imx/Kconfig 
>>> b/drivers/staging/media/imx/Kconfig
>>> index ad3d7df6bb3c..8b6dc42c39e0 100644
>>> --- a/drivers/staging/media/imx/Kconfig
>>> +++ b/drivers/staging/media/imx/Kconfig
>>> @@ -22,11 +22,11 @@ config VIDEO_IMX_CSI
>>>   A video4linux camera sensor interface driver for i.MX5/6.
>>>
>>>  config VIDEO_IMX7_CSI
>>> -   tristate "i.MX7 Camera Sensor Interface driver"
>>> +   tristate "i.MX6UL/L / i.MX7 Camera Sensor Interface driver"
>>> depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
>>> default y
>>> help
>>>   Enable support for video4linux camera sensor interface driver for
>>> - i.MX7.
>>> + i.MX6UL/L or i.MX7.
>>>  endmenu
>>>  endif
>>> diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
>>> b/drivers/staging/media/imx/imx7-media-csi.c
>>> index 9101566f3f67..902bdce594cf 100644
>>> --- a/drivers/staging/media/imx/imx7-media-csi.c
>>> +++ b/drivers/staging/media/imx/imx7-media-csi.c
>>> @@ -1,6 +1,6 @@
>>>  // SPDX-License-Identifier: GPL-2.0
>>>  /*
>>> - * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC
>>> + * V4L2 Capture CSI Subdev for Freescale i.MX6UL/L / i.MX7 SOC
>>>   *
>>>   * Copyright (c) 2019 Linaro Ltd
>>>   *
>>> @@ -152,6 +152,11 @@
>>>  #define CSI_CSICR180x48
>>>  #define CSI_CSICR190x4c
>>>
>>> +enum csi_soc_id {
>>> +   IMX7,
>>> +   IMX6UL
>>> +};
>>> +
>>>  struct imx7_csi {
>>> struct device *dev;
>>> struct v4l2_subdev sd;
>>> @@ -191,6 +196,7 @@ struct imx7_csi {
>>> bool is_init;
>>> bool is_streaming;
>>> bool is_csi2;
>>> +   enum csi_soc_id soc_id;
>>>
>>> struct completion last_eof_completion;
>>>  };
>>> @@ -548,6 +554,14 @@ static int imx7_csi_pad_link_validate(struct 
>>> v4l2_subdev *sd,
>>> if (ret)
>>> return ret;
>>>
>>> +   if (csi->soc_id == IMX6UL) {
>>> +   mutex_lock(>lock);
>>> +   csi->is_csi2 = false;
>>> +   mutex_unlock(>lock);
>>> +
>>> +   return 0;
>>> +   }
>>> +
>>> ret = imx7_csi_get_upstream_endpoint(csi, _ep, true);
>>> if (ret) {
>>> v4l2_err(>sd, "failed to find upstream endpoint\n");
>>> @@ -757,6 +771,7 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>>> struct v4l2_pix_format *out_pix = >fmt.fmt.pix;
>>> __u32 in_code = csi->format_mbus[IMX7_CSI_PAD_SINK].code;
>>> u32 cr1, cr18;
>>> +   int width = out_pix->width;
>>>
>>> if (out_pix->field == V4L2_FIELD_INTERLACED) {
>>> imx7_csi_deinterlace_enable(csi, true);
>>> @@ -766,15 +781,27 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>>> imx7_csi_buf_stride_set(csi, 0);
>>> }
>>>
>>> -   imx7_csi_set_imagpara(csi, out_pix->width, out_pix->height);
>>> +   cr18 = imx7_csi_reg_read(csi, CSI_CSICR18);
>>> +
>>> +   if (!csi->is_csi2) {
>>> +   if (out_pix->pixelformat == V4L2_PIX_FMT_UYVY ||
>>> +   out_pix->pixelformat == V4L2_PIX_FMT_YUYV)
>>> +   width *= 2;
>>> +
>>> +   imx7_csi_set_imagpara(csi, width, out_pix->height);
>>> +
>>> +   cr18 |= (BIT_B

Re: [PATCH v2 2/3] media: imx7-media-csi: add i.MX6UL support

2019-06-10 Thread Rui Miguel Silva
Hi Randy,
On Fri 07 Jun 2019 at 00:10, Randy Dunlap wrote:
> On 6/6/19 8:38 AM, Sébastien Szymanski wrote:
>> i.MX7 and i.MX6UL/L have the same CSI controller. So add i.MX6UL/L support
>> to imx7-media-csi driver.
>>
>> Signed-off-by: Sébastien Szymanski 
>> ---
>>
>> Changes for v2:
>>  - rebase on top of linuxtv/master
>>  - mention i.MX6UL/L in header and Kconfig help text
>>  - rename csi_type to csi_soc_id
>>
>>  drivers/staging/media/imx/Kconfig  |  4 +-
>>  drivers/staging/media/imx/imx7-media-csi.c | 62 --
>>  2 files changed, 49 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/staging/media/imx/Kconfig 
>> b/drivers/staging/media/imx/Kconfig
>> index ad3d7df6bb3c..8b6dc42c39e0 100644
>> --- a/drivers/staging/media/imx/Kconfig
>> +++ b/drivers/staging/media/imx/Kconfig
>> @@ -22,11 +22,11 @@ config VIDEO_IMX_CSI
>>A video4linux camera sensor interface driver for i.MX5/6.
>>
>>  config VIDEO_IMX7_CSI
>> -tristate "i.MX7 Camera Sensor Interface driver"
>> +tristate "i.MX6UL/L / i.MX7 Camera Sensor Interface driver"
>>  depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
>>  default y
>
> Hi,
> I realize that this "default y" is not part of this patch set, but we have
> pretty strong guidance that a driver should not default to 'y' unless it is
> needed for a system to boot.  If this driver is optional, then please drop
> the 2 occurrences of "default y" in this Kconfig file.

Yeah, even though both depends on imx_media, I agree that they
should not default to y. I will send a patch for this.
Thanks.

---
Cheers,
Rui


>
> thanks.
>>  help
>>Enable support for video4linux camera sensor interface driver for
>> -  i.MX7.
>> +  i.MX6UL/L or i.MX7.
>>  endmenu
>>  endif

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/3] media: imx7-media-csi: add i.MX6UL support

2019-06-10 Thread Rui Miguel Silva
Hi Sebastien,
Thanks for the patch.

On Thu 06 Jun 2019 at 16:38, Sébastien Szymanski wrote:
> i.MX7 and i.MX6UL/L have the same CSI controller. So add i.MX6UL/L support
> to imx7-media-csi driver.
>
> Signed-off-by: Sébastien Szymanski 
> ---
>
> Changes for v2:
>  - rebase on top of linuxtv/master
>  - mention i.MX6UL/L in header and Kconfig help text
>  - rename csi_type to csi_soc_id
>
>  drivers/staging/media/imx/Kconfig  |  4 +-
>  drivers/staging/media/imx/imx7-media-csi.c | 62 --
>  2 files changed, 49 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/staging/media/imx/Kconfig 
> b/drivers/staging/media/imx/Kconfig
> index ad3d7df6bb3c..8b6dc42c39e0 100644
> --- a/drivers/staging/media/imx/Kconfig
> +++ b/drivers/staging/media/imx/Kconfig
> @@ -22,11 +22,11 @@ config VIDEO_IMX_CSI
> A video4linux camera sensor interface driver for i.MX5/6.
>
>  config VIDEO_IMX7_CSI
> - tristate "i.MX7 Camera Sensor Interface driver"
> + tristate "i.MX6UL/L / i.MX7 Camera Sensor Interface driver"
>   depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
>   default y
>   help
> Enable support for video4linux camera sensor interface driver for
> -   i.MX7.
> +   i.MX6UL/L or i.MX7.
>  endmenu
>  endif
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
> b/drivers/staging/media/imx/imx7-media-csi.c
> index 9101566f3f67..902bdce594cf 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC
> + * V4L2 Capture CSI Subdev for Freescale i.MX6UL/L / i.MX7 SOC
>   *
>   * Copyright (c) 2019 Linaro Ltd
>   *
> @@ -152,6 +152,11 @@
>  #define CSI_CSICR18  0x48
>  #define CSI_CSICR19  0x4c
>
> +enum csi_soc_id {
> + IMX7,
> + IMX6UL
> +};
> +
>  struct imx7_csi {
>   struct device *dev;
>   struct v4l2_subdev sd;
> @@ -191,6 +196,7 @@ struct imx7_csi {
>   bool is_init;
>   bool is_streaming;
>   bool is_csi2;
> + enum csi_soc_id soc_id;
>
>   struct completion last_eof_completion;
>  };
> @@ -548,6 +554,14 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev 
> *sd,
>   if (ret)
>   return ret;
>
> + if (csi->soc_id == IMX6UL) {
> + mutex_lock(>lock);
> + csi->is_csi2 = false;
> + mutex_unlock(>lock);
> +
> + return 0;
> + }
> +
>   ret = imx7_csi_get_upstream_endpoint(csi, _ep, true);
>   if (ret) {
>   v4l2_err(>sd, "failed to find upstream endpoint\n");
> @@ -757,6 +771,7 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>   struct v4l2_pix_format *out_pix = >fmt.fmt.pix;
>   __u32 in_code = csi->format_mbus[IMX7_CSI_PAD_SINK].code;
>   u32 cr1, cr18;
> + int width = out_pix->width;
>
>   if (out_pix->field == V4L2_FIELD_INTERLACED) {
>   imx7_csi_deinterlace_enable(csi, true);
> @@ -766,15 +781,27 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>   imx7_csi_buf_stride_set(csi, 0);
>   }
>
> - imx7_csi_set_imagpara(csi, out_pix->width, out_pix->height);
> + cr18 = imx7_csi_reg_read(csi, CSI_CSICR18);
> +
> + if (!csi->is_csi2) {
> + if (out_pix->pixelformat == V4L2_PIX_FMT_UYVY ||
> + out_pix->pixelformat == V4L2_PIX_FMT_YUYV)
> + width *= 2;
> +
> + imx7_csi_set_imagpara(csi, width, out_pix->height);
> +
> + cr18 |= (BIT_BASEADDR_SWITCH_EN | BIT_BASEADDR_SWITCH_SEL |
> + BIT_BASEADDR_CHG_ERR_EN);
> + imx7_csi_reg_write(csi, cr18, CSI_CSICR18);
>
> - if (!csi->is_csi2)
>   return 0;
> + }
> +
> + imx7_csi_set_imagpara(csi, width, out_pix->height);
>
>   cr1 = imx7_csi_reg_read(csi, CSI_CSICR1);
>   cr1 &= ~BIT_GCLK_MODE;
>
> - cr18 = imx7_csi_reg_read(csi, CSI_CSICR18);
>   cr18 &= BIT_MIPI_DATA_FORMAT_MASK;
>   cr18 |= BIT_DATA_FROM_MIPI;
>
> @@ -809,11 +836,9 @@ static void imx7_csi_enable(struct imx7_csi *csi)
>  {
>   imx7_csi_sw_reset(csi);
>
> - if (csi->is_csi2) {
> - imx7_csi_dmareq_rff_enable(csi);
> - imx7_csi_hw_enable_irq(csi);
> - imx7_csi_hw_enable(csi);
> - }
> + imx7_csi_dmareq_rff_enable(csi);
> + imx7_csi_hw_enable_irq(csi);
> + imx7_csi_hw_enable(csi);
>  }
>
>  static void imx7_csi_disable(struct imx7_csi *csi)
> @@ -1166,19 +1191,32 @@ static int imx7_csi_parse_endpoint(struct device *dev,
>   return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL;
>  }
>
> +static const struct of_device_id imx7_csi_of_match[] = {
> + { .compatible = "fsl,imx7-csi", .data = (void *)IMX7 },
> + { .compatible = "fsl,imx6ul-csi", .data = (void *)IMX6UL },

looking at this again I think we can do this is a different way.
Instead 

Re: [PATCH 2/2] media: imx7-media-csi: add i.MX6UL support

2019-05-02 Thread Rui Miguel Silva
Hi Sebastien,
Many thanks for this patch.

Please note that there is another series on top of this code [0],
that turns my patch that you mention below obsolete, maybe you may
want to rebase on top of that. and also a different patch from me
[1].

[0]: 
https://lore.kernel.org/lkml/20190430225018.30252-2-slongerb...@gmail.com/#b
[1]: 
https://lore.kernel.org/linux-media/20190430222523.22814-1-rui.si...@linaro.org/

On Tue 30 Apr 2019 at 08:49, Sébastien Szymanski wrote:
> i.MX7 and i.MX6UL/L have the same CSI controller. So add i.MX6UL/L support
> to imx7-media-csi driver.
>
> Signed-off-by: Sébastien Szymanski 

Can you also add i.MX6UL/L to the header of this file and maybe in
the help string in the Kconfig. That would make it clear that this
is supported also by this driver.

> ---
>  This patch needs the following patch from Rui Miguel Silva:
>  https://patchwork.linuxtv.org/patch/55657/
>
>  I have tested this patch with a OV5640 sensor (8-bit parallel). The pipeline 
> is:
>
>  Device topology
>  - entity 1: csi (2 pads, 2 links)
> type V4L2 subdev subtype Unknown flags 0
> device node name /dev/v4l-subdev0
> pad0: Sink
> [fmt:UYVY8_2X8/640x480 field:none colorspace:smpte170m 
> xfer:709 ycbcr:601 quantization:lim-range]
> <- "ov5640 1-003c":0 [ENABLED]
> pad1: Source
> [fmt:UYVY8_2X8/640x480 field:none colorspace:smpte170m 
> xfer:709 ycbcr:601 quantization:lim-range]
> -> "csi capture":0 [ENABLED]
>
>  - entity 4: csi capture (1 pad, 1 link)
> type Node subtype V4L flags 0
> device node name /dev/video0
> pad0: Sink
> <- "csi":1 [ENABLED]
>
>  - entity 10: ov5640 1-003c (1 pad, 1 link)
>  type V4L2 subdev subtype Sensor flags 0
>  device node name /dev/v4l-subdev1
> pad0: Source
> [fmt:UYVY8_2X8/640x480@1/30 field:none colorspace:srgb 
> xfer:srgb ycbcr:601 quantization:full-range]
> -> "csi":0 [ENABLED]
>
>  drivers/staging/media/imx/imx7-media-csi.c | 61 --
>  1 file changed, 46 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
> b/drivers/staging/media/imx/imx7-media-csi.c
> index a708a0340eb1..ef4534a96fa0 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -154,6 +154,11 @@
>  
>  static const char * const imx7_csi_clk_id[] = {"axi", "dcic", "mclk"};
>  
> +enum csi_type {

maybe here the name could be something along enum csi_device_id, I
don't know, type does not sound good to me??

> + IMX7,
> + IMX6UL
> +};
> +
>  struct imx7_csi {
>   struct device *dev;
>   struct v4l2_subdev sd;
> @@ -195,6 +200,7 @@ struct imx7_csi {
>   bool is_init;
>   bool is_streaming;
>   bool is_csi2;
> + enum csi_type type;

here the same, instead type maybe dev_id?? or dev_type??

>  
>   struct completion last_eof_completion;
>  };
> @@ -554,6 +560,14 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev 
> *sd,
>   if (ret)
>   return ret;
>  
> + if (csi->type == IMX6UL) {
> + mutex_lock(>lock);
> + csi->is_csi2 = false;
> + mutex_unlock(>lock);
> +
> + return 0;
> + }
> +
>   ret = imx7_csi_get_upstream_endpoint(csi, _ep, true);
>   if (ret) {
>   v4l2_err(>sd, "failed to find upstream endpoint\n");
> @@ -763,6 +777,7 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>   struct v4l2_pix_format *out_pix = >fmt.fmt.pix;
>   __u32 in_code = csi->format_mbus[IMX7_CSI_PAD_SINK].code;
>   u32 cr1, cr18;
> + int width = out_pix->width;
>  
>   if (out_pix->field == V4L2_FIELD_INTERLACED) {
>   imx7_csi_deinterlace_enable(csi, true);
> @@ -772,15 +787,27 @@ static int imx7_csi_configure(struct imx7_csi *csi)
>   imx7_csi_buf_stride_set(csi, 0);
>   }
>  
> - imx7_csi_set_imagpara(csi, out_pix->width, out_pix->height);
> + cr18 = imx7_csi_reg_read(csi, CSI_CSICR18);
> +
> + if (!csi->is_csi2) {
> + if (out_pix->pixelformat == V4L2_PIX_FMT_UYVY ||
> + out_pix->pixelformat == V4L2_PIX_FMT_YUYV)
> + width *= 2;
> +
> + imx7_csi_set_imagpara(csi, width, out_pix->height);
> +
> + cr18 |= (BIT_BASEADDR_SWITCH_EN | BIT_BASEADDR_SWITCH_SEL |
> + BIT_B

Re: [PATCH v3 5/8] media: staging/imx: Remove capture_device_set_format

2019-05-02 Thread Rui Miguel Silva
Hi Steve,
Thanks for v3 with bisect fixed.

On Tue 30 Apr 2019 at 23:50, Steve Longerbeam wrote:
> Don't propagate the source pad format to the connected capture device.
> It's now the responsibility of userspace to call VIDIOC_S_FMT on the
> capture device to ensure the capture format and compose rectangle
> are compatible with the connected source. To check this, validate
> the capture format with the source before streaming starts.
>
> Signed-off-by: Steve Longerbeam 
> ---
>  drivers/staging/media/imx/imx-ic-prpencvf.c   | 16 +
>  drivers/staging/media/imx/imx-media-capture.c | 64 +--
>  drivers/staging/media/imx/imx-media-csi.c | 16 +
>  drivers/staging/media/imx/imx-media.h |  2 -
>  drivers/staging/media/imx/imx7-media-csi.c| 17 +
>  5 files changed, 50 insertions(+), 65 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
> b/drivers/staging/media/imx/imx-ic-prpencvf.c
> index afaa3a8b15e9..63334fd61492 100644
> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
> @@ -906,9 +906,7 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>  struct v4l2_subdev_format *sdformat)
>  {
>   struct prp_priv *priv = sd_to_priv(sd);
> - struct imx_media_video_dev *vdev = priv->vdev;
>   const struct imx_media_pixfmt *cc;
> - struct v4l2_pix_format vdev_fmt;
>   struct v4l2_mbus_framefmt *fmt;
>   int ret = 0;
>  
> @@ -945,19 +943,9 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>   priv->cc[PRPENCVF_SRC_PAD] = outcc;
>   }
>  
> - if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY)
> - goto out;
> -
> - priv->cc[sdformat->pad] = cc;
> + if (sdformat->which == V4L2_SUBDEV_FORMAT_ACTIVE)
> + priv->cc[sdformat->pad] = cc;
>  
> - /* propagate output pad format to capture device */
> - imx_media_mbus_fmt_to_pix_fmt(_fmt,
> -   >format_mbus[PRPENCVF_SRC_PAD],
> -   priv->cc[PRPENCVF_SRC_PAD]);
> - mutex_unlock(>lock);
> - imx_media_capture_device_set_format(vdev, _fmt);
> -
> - return 0;
>  out:
>   mutex_unlock(>lock);
>   return ret;
> diff --git a/drivers/staging/media/imx/imx-media-capture.c 
> b/drivers/staging/media/imx/imx-media-capture.c
> index 555f6204660b..b77a67bda47c 100644
> --- a/drivers/staging/media/imx/imx-media-capture.c
> +++ b/drivers/staging/media/imx/imx-media-capture.c
> @@ -205,7 +205,8 @@ static int capture_g_fmt_vid_cap(struct file *file, void 
> *fh,
>  
>  static int __capture_try_fmt_vid_cap(struct capture_priv *priv,
>struct v4l2_subdev_format *fmt_src,
> -  struct v4l2_format *f)
> +  struct v4l2_format *f,
> +  struct v4l2_rect *compose)
>  {
>   const struct imx_media_pixfmt *cc, *cc_src;
>  
> @@ -247,6 +248,13 @@ static int __capture_try_fmt_vid_cap(struct capture_priv 
> *priv,
>  
>   imx_media_mbus_fmt_to_pix_fmt(>fmt.pix, _src->format, cc);
>  
> + if (compose) {
> + compose->left = 0;
> + compose->top = 0;
> + compose->width = fmt_src->format.width;
> + compose->height = fmt_src->format.height;
> + }
> +
>   return 0;
>  }
>  
> @@ -263,7 +271,7 @@ static int capture_try_fmt_vid_cap(struct file *file, 
> void *fh,
>   if (ret)
>   return ret;
>  
> - return __capture_try_fmt_vid_cap(priv, _src, f);
> + return __capture_try_fmt_vid_cap(priv, _src, f, NULL);
>  }
>  
>  static int capture_s_fmt_vid_cap(struct file *file, void *fh,
> @@ -271,6 +279,7 @@ static int capture_s_fmt_vid_cap(struct file *file, void 
> *fh,
>  {
>   struct capture_priv *priv = video_drvdata(file);
>   struct v4l2_subdev_format fmt_src;
> + struct v4l2_rect compose;
>   int ret;
>  
>   if (vb2_is_busy(>q)) {
> @@ -284,17 +293,14 @@ static int capture_s_fmt_vid_cap(struct file *file, 
> void *fh,
>   if (ret)
>   return ret;
>  
> - ret = __capture_try_fmt_vid_cap(priv, _src, f);
> + ret = __capture_try_fmt_vid_cap(priv, _src, f, );
>   if (ret)
>   return ret;
>  
>   priv->vdev.fmt.fmt.pix = f->fmt.pix;
>   priv->vdev.cc = imx_media_find_format(f->fmt.pix.pixelformat,
> CS_SEL_ANY, true);
> - priv->vdev.compose.left = 0;
> - priv->vdev.compose.top = 0;
> - priv->vdev.compose.width = fmt_src.format.width;
> - priv->vdev.compose.height = fmt_src.format.height;
> + priv->vdev.compose = compose;
>  
>   return 0;
>  }
> @@ -524,6 +530,33 @@ static void capture_buf_queue(struct vb2_buffer *vb)
>   spin_unlock_irqrestore(>q_lock, flags);
>  }
>  
> +static int capture_validate_fmt(struct capture_priv *priv)
> +{
> + struct v4l2_subdev_format 

[PATCH] media: imx7_mipi_csis: fix racy entity pads init

2019-04-30 Thread Rui Miguel Silva
Setting the media entity pads after the async register subdev can be
racy with probe complete callback. So, make sure that the media pads
are initialized before the probe complete is called.

For that move the media entity pads initialization to the registered
subdev internal operation.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 24 ++
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
index 19455f425416..042837b8ea28 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -784,6 +784,17 @@ static irqreturn_t mipi_csis_irq_handler(int irq, void 
*dev_id)
return IRQ_HANDLED;
 }
 
+static int mipi_csis_registered(struct v4l2_subdev *mipi_sd)
+{
+   struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
+
+   state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
+   state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
+
+   return media_entity_pads_init(>mipi_sd.entity, CSIS_PADS_NUM,
+ state->pads);
+}
+
 static const struct v4l2_subdev_core_ops mipi_csis_core_ops = {
.log_status = mipi_csis_log_status,
 };
@@ -809,6 +820,10 @@ static const struct v4l2_subdev_ops mipi_csis_subdev_ops = 
{
.pad= _csis_pad_ops,
 };
 
+static const struct v4l2_subdev_internal_ops mipi_csis_internal_ops = {
+   .registered = mipi_csis_registered,
+};
+
 static int mipi_csis_parse_dt(struct platform_device *pdev,
  struct csi_state *state)
 {
@@ -869,6 +884,7 @@ static int mipi_csis_subdev_init(struct v4l2_subdev 
*mipi_sd,
 
mipi_sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
mipi_sd->entity.ops = _csis_entity_ops;
+   mipi_sd->internal_ops = _csis_internal_ops;
 
mipi_sd->dev = >dev;
 
@@ -990,13 +1006,6 @@ static int mipi_csis_probe(struct platform_device *pdev)
if (ret < 0)
goto disable_clock;
 
-   state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-   state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-   ret = media_entity_pads_init(>mipi_sd.entity, CSIS_PADS_NUM,
-state->pads);
-   if (ret < 0)
-   goto unregister_subdev;
-
memcpy(state->events, mipi_csis_events, sizeof(state->events));
 
mipi_csis_debugfs_init(state);
@@ -1016,7 +1025,6 @@ static int mipi_csis_probe(struct platform_device *pdev)
 unregister_all:
mipi_csis_debugfs_exit(state);
media_entity_cleanup(>mipi_sd.entity);
-unregister_subdev:
v4l2_async_unregister_subdev(>mipi_sd);
 disable_clock:
mipi_csis_clk_disable(state);
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 4/8] Revert "media: imx: Set capture compose rectangle in capture_device_set_format"

2019-04-30 Thread Rui Miguel Silva
Hi Steve,
On Sun 28 Apr 2019 at 20:09, Steve Longerbeam wrote:
> Rvert this commit, as imx_media_capture_device_set_format() will be
> removed.
>
> This reverts commit 5964cbd8692252615370b77eb96764dd70c2f837.
>
> Signed-off-by: Steve Longerbeam 
> ---
>  drivers/staging/media/imx/imx-ic-prpencvf.c   |  5 ++--
>  drivers/staging/media/imx/imx-media-capture.c | 24 +--
>  drivers/staging/media/imx/imx-media-csi.c |  5 ++--
>  drivers/staging/media/imx/imx-media-utils.c   | 20 
>  drivers/staging/media/imx/imx-media.h |  6 ++---
>  5 files changed, 23 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
> b/drivers/staging/media/imx/imx-ic-prpencvf.c
> index 8242d88dfb82..afaa3a8b15e9 100644
> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
> @@ -910,7 +910,6 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>   const struct imx_media_pixfmt *cc;
>   struct v4l2_pix_format vdev_fmt;
>   struct v4l2_mbus_framefmt *fmt;
> - struct v4l2_rect vdev_compose;
>   int ret = 0;
>  
>   if (sdformat->pad >= PRPENCVF_NUM_PADS)
> @@ -952,11 +951,11 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>   priv->cc[sdformat->pad] = cc;
>  
>   /* propagate output pad format to capture device */
> - imx_media_mbus_fmt_to_pix_fmt(_fmt, _compose,
> + imx_media_mbus_fmt_to_pix_fmt(_fmt,
> >format_mbus[PRPENCVF_SRC_PAD],
> priv->cc[PRPENCVF_SRC_PAD]);
>   mutex_unlock(>lock);
> - imx_media_capture_device_set_format(vdev, _fmt, _compose);
> + imx_media_capture_device_set_format(vdev, _fmt);
>  
>   return 0;
>  out:
> diff --git a/drivers/staging/media/imx/imx-media-capture.c 
> b/drivers/staging/media/imx/imx-media-capture.c
> index 335084a6b0cd..555f6204660b 100644
> --- a/drivers/staging/media/imx/imx-media-capture.c
> +++ b/drivers/staging/media/imx/imx-media-capture.c
> @@ -205,8 +205,7 @@ static int capture_g_fmt_vid_cap(struct file *file, void 
> *fh,
>  
>  static int __capture_try_fmt_vid_cap(struct capture_priv *priv,
>struct v4l2_subdev_format *fmt_src,
> -  struct v4l2_format *f,
> -  struct v4l2_rect *compose)
> +  struct v4l2_format *f)
>  {
>   const struct imx_media_pixfmt *cc, *cc_src;
>  
> @@ -246,8 +245,7 @@ static int __capture_try_fmt_vid_cap(struct capture_priv 
> *priv,
>   }
>   }
>  
> - imx_media_mbus_fmt_to_pix_fmt(>fmt.pix, compose,
> -   _src->format, cc);
> + imx_media_mbus_fmt_to_pix_fmt(>fmt.pix, _src->format, cc);
>  
>   return 0;
>  }
> @@ -265,7 +263,7 @@ static int capture_try_fmt_vid_cap(struct file *file, 
> void *fh,
>   if (ret)
>   return ret;
>  
> - return __capture_try_fmt_vid_cap(priv, _src, f, NULL);
> + return __capture_try_fmt_vid_cap(priv, _src, f);
>  }
>  
>  static int capture_s_fmt_vid_cap(struct file *file, void *fh,
> @@ -273,7 +271,6 @@ static int capture_s_fmt_vid_cap(struct file *file, void 
> *fh,
>  {
>   struct capture_priv *priv = video_drvdata(file);
>   struct v4l2_subdev_format fmt_src;
> - struct v4l2_rect compose;
>   int ret;
>  
>   if (vb2_is_busy(>q)) {
> @@ -287,14 +284,17 @@ static int capture_s_fmt_vid_cap(struct file *file, 
> void *fh,
>   if (ret)
>   return ret;
>  
> - ret = __capture_try_fmt_vid_cap(priv, _src, f, );
> + ret = __capture_try_fmt_vid_cap(priv, _src, f);
>   if (ret)
>   return ret;
>  
>   priv->vdev.fmt.fmt.pix = f->fmt.pix;
>   priv->vdev.cc = imx_media_find_format(f->fmt.pix.pixelformat,
> CS_SEL_ANY, true);
> - priv->vdev.compose = compose;
> + priv->vdev.compose.left = 0;
> + priv->vdev.compose.top = 0;
> + priv->vdev.compose.width = fmt_src.format.width;
> + priv->vdev.compose.height = fmt_src.format.height;
>  
>   return 0;
>  }
> @@ -655,8 +655,7 @@ static struct video_device capture_videodev = {
>  };
>  
>  void imx_media_capture_device_set_format(struct imx_media_video_dev *vdev,
> -  const struct v4l2_pix_format *pix,
> -  const struct v4l2_rect *compose)
> +  struct v4l2_pix_format *pix)
>  {
>   struct capture_priv *priv = to_capture_priv(vdev);
>  
> @@ -664,7 +663,6 @@ void imx_media_capture_device_set_format(struct 
> imx_media_video_dev *vdev,
>   priv->vdev.fmt.fmt.pix = *pix;
>   priv->vdev.cc = imx_media_find_format(pix->pixelformat, CS_SEL_ANY,
> true);
> - priv->vdev.compose = *compose;
>   mutex_unlock(>mutex);
>  }
>  

Re: [PATCH v2 1/8] media: staging/imx: Switch to sync registration for IPU subdevs

2019-04-30 Thread Rui Miguel Silva
Hi Steve,
On Sun 28 Apr 2019 at 20:09, Steve Longerbeam wrote:
> Because the IPU sub-devices VDIC and IC are not present in the
> device-tree, platform devices were created for them instead. This
> allowed these sub-devices to be added to the media device's async
> notifier and registered asynchronously along with the other
> sub-devices that do have a device-tree presence (CSI and devices
> external to the IPU and SoC).
>
> But that approach isn't really necessary. The IPU sub-devices don't
> actually require a backing device (sd->dev is allowed to be NULL).
> And that approach can't get around the fact that the IPU sub-devices
> are not part of a device hierarchy, which makes it awkward to retrieve
> the parent IPU of these devices.
>
> By registering them synchronously, they can be registered from the CSI
> async bound notifier, so the init function for them can be given the CSI
> subdev, who's dev->parent is the IPU. That is a somewhat cleaner way
> to retrieve the parent IPU.
>
> So convert to synchronous registration for the VDIC and IC task
> sub-devices, at the time a CSI sub-device is bound. There is no longer
> a backing device for them (sd->dev is NULL), but that's ok. Also
> set the VDIC/IC sub-device owner as the IPU, so that a reference can
> be taken on the IPU module.
>
> Signed-off-by: Steve Longerbeam 

I am trying to bisect when my capture starts to fail to work with
this series, since they are so many changes and reorg that I got
lost on some of them. But... see below.

> ---
>  drivers/staging/media/imx/imx-ic-common.c |  70 ++--
>  drivers/staging/media/imx/imx-ic-prp.c|  34 +-
>  drivers/staging/media/imx/imx-ic-prpencvf.c   |  70 ++--
>  drivers/staging/media/imx/imx-ic.h|   7 +-
>  drivers/staging/media/imx/imx-media-capture.c |   7 +-
>  drivers/staging/media/imx/imx-media-csi.c |   2 +-
>  drivers/staging/media/imx/imx-media-dev.c | 121 +-
>  .../staging/media/imx/imx-media-internal-sd.c | 356 --
>  drivers/staging/media/imx/imx-media-of.c  |  38 +-
>  drivers/staging/media/imx/imx-media-vdic.c|  85 ++---
>  drivers/staging/media/imx/imx-media.h |  67 ++--
>  drivers/staging/media/imx/imx7-media-csi.c|   3 +-
>  12 files changed, 325 insertions(+), 535 deletions(-)
>
> + dev_dbg(priv->ipu_dev, "%s: link setup %s -> %s",



> + sd->name, remote->entity->name, local->entity->name);
>  
>   mutex_lock(>lock);
>  
> @@ -864,9 +856,6 @@ static int vdic_registered(struct v4l2_subdev *sd)
>   int i, ret;
>   u32 code;
>  
> - /* get media device */
> - priv->md = dev_get_drvdata(sd->v4l2_dev->dev);
> -
>   for (i = 0; i < VDIC_NUM_PADS; i++) {
>   priv->pad[i].flags = (i == VDIC_SRC_PAD_DIRECT) ?
>   MEDIA_PAD_FL_SOURCE : MEDIA_PAD_FL_SINK;
> @@ -938,77 +927,55 @@ static const struct v4l2_subdev_internal_ops 
> vdic_internal_ops = {
>   .unregistered = vdic_unregistered,
>  };
>  
> -static int imx_vdic_probe(struct platform_device *pdev)
> +struct v4l2_subdev *imx_media_vdic_register(struct imx_media_dev *imxmd,
> + struct device *ipu_dev,
> + struct ipu_soc *ipu,
> + u32 grp_id)
>  {
> - struct imx_media_ipu_internal_sd_pdata *pdata;
> + struct v4l2_device *v4l2_dev = >v4l2_dev;
>   struct vdic_priv *priv;
>   int ret;
>  
> - priv = devm_kzalloc(>dev, sizeof(*priv), GFP_KERNEL);
> + priv = devm_kzalloc(ipu_dev, sizeof(*priv), GFP_KERNEL);
>   if (!priv)
> - return -ENOMEM;
> + return ERR_PTR(-ENOMEM);
>  
> - platform_set_drvdata(pdev, >sd);
> - priv->dev = >dev;
> -
> - pdata = priv->dev->platform_data;
> - priv->ipu_id = pdata->ipu_id;
> + priv->ipu_dev = ipu_dev;
> + priv->ipu = ipu;
> + priv->md = imxmd;
>  
>   v4l2_subdev_init(>sd, _subdev_ops);
>   v4l2_set_subdevdata(>sd, priv);
>   priv->sd.internal_ops = _internal_ops;
>   priv->sd.entity.ops = _entity_ops;
>   priv->sd.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
> - priv->sd.dev = >dev;
> - priv->sd.owner = THIS_MODULE;
> + priv->sd.owner = ipu_dev->driver->owner;
>   priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
> - /* get our group id */
> - priv->sd.grp_id = pdata->grp_id;
> - strscpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name));
> + priv->sd.grp_id = grp_id;
> + imx_media_grp_id_to_sd_name(priv->sd.name, sizeof(priv->sd.name),
> + priv->sd.grp_id, ipu_get_num(ipu));
>  
>   mutex_init(>lock);
>  
> - ret = v4l2_async_register_subdev(>sd);
> + ret = v4l2_device_register_subdev(v4l2_dev, >sd);
>   if (ret)
>   goto free;
>  
> - return 0;
> + return >sd;
>  free:
>   mutex_destroy(>lock);
> - return ret;
> + return 

Re: [PATCH] media: staging/imx: add media device to capture register

2019-04-28 Thread Rui Miguel Silva
Hi Steve,
On Sun 28 Apr 2019 at 19:53, Steve Longerbeam wrote:
> Hi Rui,
>
> On second thought, there is no reason to pass the media device to 
> imx_media_capture_device_register(), because it is already available via 
> v4l2_dev->mdev. I will be posting a patch in v2 of the "Switch to sync 
> registration for IPU subdevs" series that fixes this.

That make sense to me. I've already took a look to v2 and I like
the ideas in there, I will give it a proper test and review
tomorrow. Will send feedback afterwards.

Thanks so much for your work on this.

---
Cheers,
Rui

>
> Steve
>
>
> On 4/12/19 9:44 AM, Rui Miguel Silva wrote:
>> When register the capture media device it is assumed that the device
>> data is the media device. In the imx6 case is but in the imx7 is not
>> case. The device data is the csi structure.
>>
>> Add the explicit argument of the media device that we want to
>> associate with the capture device.
>>
>> Reported-by: Laurent Pinchart 
>> Signed-off-by: Rui Miguel Silva 
>> ---
>>   drivers/staging/media/imx/imx-ic-prpencvf.c   | 2 +-
>>   drivers/staging/media/imx/imx-media-capture.c | 6 +++---
>>   drivers/staging/media/imx/imx-media-csi.c | 2 +-
>>   drivers/staging/media/imx/imx-media.h | 3 ++-
>>   drivers/staging/media/imx/imx7-media-csi.c| 2 +-
>>   5 files changed, 8 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
>> b/drivers/staging/media/imx/imx-ic-prpencvf.c
>> index 5c8e6ad8c025..3ca1422f6154 100644
>> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
>> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
>> @@ -1270,7 +1270,7 @@ static int prp_registered(struct v4l2_subdev *sd)
>>  if (ret)
>>  return ret;
>>   
>> -ret = imx_media_capture_device_register(priv->vdev);
>> +ret = imx_media_capture_device_register(priv->md, priv->vdev);
>>  if (ret)
>>  return ret;
>>   
>> diff --git a/drivers/staging/media/imx/imx-media-capture.c 
>> b/drivers/staging/media/imx/imx-media-capture.c
>> index 9703c85b19c4..7688238a3396 100644
>> --- a/drivers/staging/media/imx/imx-media-capture.c
>> +++ b/drivers/staging/media/imx/imx-media-capture.c
>> @@ -706,7 +706,8 @@ void imx_media_capture_device_error(struct 
>> imx_media_video_dev *vdev)
>>   }
>>   EXPORT_SYMBOL_GPL(imx_media_capture_device_error);
>>   
>> -int imx_media_capture_device_register(struct imx_media_video_dev *vdev)
>> +int imx_media_capture_device_register(struct imx_media_dev *md,
>> +  struct imx_media_video_dev *vdev)
>>   {
>>  struct capture_priv *priv = to_capture_priv(vdev);
>>  struct v4l2_subdev *sd = priv->src_sd;
>> @@ -715,8 +716,7 @@ int imx_media_capture_device_register(struct 
>> imx_media_video_dev *vdev)
>>  struct v4l2_subdev_format fmt_src;
>>  int ret;
>>   
>> -/* get media device */
>> -priv->md = dev_get_drvdata(sd->v4l2_dev->dev);
>> +priv->md = md;
>>   
>>  vfd->v4l2_dev = sd->v4l2_dev;
>>   
>> diff --git a/drivers/staging/media/imx/imx-media-csi.c 
>> b/drivers/staging/media/imx/imx-media-csi.c
>> index 3b7517348666..3408ec023d29 100644
>> --- a/drivers/staging/media/imx/imx-media-csi.c
>> +++ b/drivers/staging/media/imx/imx-media-csi.c
>> @@ -1806,7 +1806,7 @@ static int csi_registered(struct v4l2_subdev *sd)
>>  if (ret)
>>  goto free_fim;
>>   
>> -ret = imx_media_capture_device_register(priv->vdev);
>> +ret = imx_media_capture_device_register(priv->md, priv->vdev);
>>  if (ret)
>>  goto free_fim;
>>   
>> diff --git a/drivers/staging/media/imx/imx-media.h 
>> b/drivers/staging/media/imx/imx-media.h
>> index ae964c8d5be1..c3a8512bd10f 100644
>> --- a/drivers/staging/media/imx/imx-media.h
>> +++ b/drivers/staging/media/imx/imx-media.h
>> @@ -271,7 +271,8 @@ int imx_media_of_add_csi(struct imx_media_dev *imxmd,
>>   struct imx_media_video_dev *
>>   imx_media_capture_device_init(struct v4l2_subdev *src_sd, int pad);
>>   void imx_media_capture_device_remove(struct imx_media_video_dev *vdev);
>> -int imx_media_capture_device_register(struct imx_media_video_dev *vdev);
>> +int imx_media_capture_device_register(struct imx_media_dev *md,
>> +   struct imx_media_video_dev *vdev);
>>   void imx_media_capture_device_unregister(struct imx_media_video_dev *vdev);
>>   

Re: [PATCH v2] staging: greybus: power_supply: use struct_size() helper

2019-04-18 Thread Rui Miguel Silva

Oi Gustavo,
Thanks for the patch, and the rebasing.

On Wed 17 Apr 2019 at 19:44, Gustavo A. R. Silva wrote:
Make use of the struct_size() helper instead of an open-coded 
version
in order to avoid any potential type mistakes, in particular in 
the

context in which this code is being used.

So, replace code of the following form:

sizeof(*resp) + props_count * sizeof(struct 
gb_power_supply_props_desc)


with:

struct_size(resp, props, props_count)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 


Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui



---
Changes in v2:
 - Rebase on top of 47830c1127ef ("staging: greybus: 
 power_supply: fix prop-descriptor request size")


 drivers/staging/greybus/power_supply.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/power_supply.c 
b/drivers/staging/greybus/power_supply.c

index ae5c0285a942..34b40a409ea3 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -520,8 +520,8 @@ static int 
gb_power_supply_prop_descriptors_get(struct gb_power_supply 
*gbpsy)
 
 	op = gb_operation_create(connection,

 GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS,
- sizeof(*req), sizeof(*resp) + 
props_count *
- sizeof(struct 
gb_power_supply_props_desc),

+sizeof(*req),
+ struct_size(resp, props, 
props_count),

 GFP_KERNEL);
if (!op)
return -ENOMEM;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] media: staging/imx: add media device to capture register

2019-04-12 Thread Rui Miguel Silva
When register the capture media device it is assumed that the device
data is the media device. In the imx6 case is but in the imx7 is not
case. The device data is the csi structure.

Add the explicit argument of the media device that we want to
associate with the capture device.

Reported-by: Laurent Pinchart 
Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx-ic-prpencvf.c   | 2 +-
 drivers/staging/media/imx/imx-media-capture.c | 6 +++---
 drivers/staging/media/imx/imx-media-csi.c | 2 +-
 drivers/staging/media/imx/imx-media.h | 3 ++-
 drivers/staging/media/imx/imx7-media-csi.c| 2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 5c8e6ad8c025..3ca1422f6154 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -1270,7 +1270,7 @@ static int prp_registered(struct v4l2_subdev *sd)
if (ret)
return ret;
 
-   ret = imx_media_capture_device_register(priv->vdev);
+   ret = imx_media_capture_device_register(priv->md, priv->vdev);
if (ret)
return ret;
 
diff --git a/drivers/staging/media/imx/imx-media-capture.c 
b/drivers/staging/media/imx/imx-media-capture.c
index 9703c85b19c4..7688238a3396 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -706,7 +706,8 @@ void imx_media_capture_device_error(struct 
imx_media_video_dev *vdev)
 }
 EXPORT_SYMBOL_GPL(imx_media_capture_device_error);
 
-int imx_media_capture_device_register(struct imx_media_video_dev *vdev)
+int imx_media_capture_device_register(struct imx_media_dev *md,
+ struct imx_media_video_dev *vdev)
 {
struct capture_priv *priv = to_capture_priv(vdev);
struct v4l2_subdev *sd = priv->src_sd;
@@ -715,8 +716,7 @@ int imx_media_capture_device_register(struct 
imx_media_video_dev *vdev)
struct v4l2_subdev_format fmt_src;
int ret;
 
-   /* get media device */
-   priv->md = dev_get_drvdata(sd->v4l2_dev->dev);
+   priv->md = md;
 
vfd->v4l2_dev = sd->v4l2_dev;
 
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 3b7517348666..3408ec023d29 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1806,7 +1806,7 @@ static int csi_registered(struct v4l2_subdev *sd)
if (ret)
goto free_fim;
 
-   ret = imx_media_capture_device_register(priv->vdev);
+   ret = imx_media_capture_device_register(priv->md, priv->vdev);
if (ret)
goto free_fim;
 
diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index ae964c8d5be1..c3a8512bd10f 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -271,7 +271,8 @@ int imx_media_of_add_csi(struct imx_media_dev *imxmd,
 struct imx_media_video_dev *
 imx_media_capture_device_init(struct v4l2_subdev *src_sd, int pad);
 void imx_media_capture_device_remove(struct imx_media_video_dev *vdev);
-int imx_media_capture_device_register(struct imx_media_video_dev *vdev);
+int imx_media_capture_device_register(struct imx_media_dev *md,
+  struct imx_media_video_dev *vdev);
 void imx_media_capture_device_unregister(struct imx_media_video_dev *vdev);
 struct imx_media_buffer *
 imx_media_capture_device_next_buf(struct imx_media_video_dev *vdev);
diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
index 3fba7c27c0ec..a907c5feb3eb 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -1124,7 +1124,7 @@ static int imx7_csi_registered(struct v4l2_subdev *sd)
if (ret < 0)
return ret;
 
-   ret = imx_media_capture_device_register(csi->vdev);
+   ret = imx_media_capture_device_register(csi->imxmd, csi->vdev);
if (ret < 0)
return ret;
 
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: power_supply: fix prop-descriptor request size

2019-04-04 Thread Rui Miguel Silva

Hi Johan,
Thanks for the patch.

On Thu 04 Apr 2019 at 07:53, Johan Hovold wrote:

Since moving the message buffers off the stack, the dynamically
allocated get-prop-descriptor request buffer is incorrectly 
sized due to
using the pointer rather than request-struct size when creating 
the

operation.

Fortunately, the pointer size is always larger than this 
one-byte
request, but this could still cause trouble on the remote end 
due to the

unexpected message size.

Fixes: 9d15134d067e ("greybus: power_supply: rework get 
descriptors")

Cc: stable  # 4.9
Cc: Rui Miguel Silva 
Signed-off-by: Johan Hovold 


Nice catch. LGTM.

Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui



---
 drivers/staging/greybus/power_supply.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/power_supply.c 
b/drivers/staging/greybus/power_supply.c

index 0529e5628c24..ae5c0285a942 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -520,7 +520,7 @@ static int 
gb_power_supply_prop_descriptors_get(struct gb_power_supply 
*gbpsy)
 
 	op = gb_operation_create(connection,

 GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS,
- sizeof(req), sizeof(*resp) + 
props_count *
+ sizeof(*req), sizeof(*resp) + 
props_count *
  sizeof(struct 
 gb_power_supply_props_desc),

 GFP_KERNEL);
if (!op)


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: power_supply: Use struct_size() helper

2019-04-04 Thread Rui Miguel Silva

Hi Gustavo,
Thanks a lot for the patch.

On Wed 03 Apr 2019 at 21:58, Gustavo A. R. Silva wrote:
Make use of the struct_size() helper instead of an open-coded 
version
in order to avoid any potential type mistakes, in particular in 
the

context in which this code is being used.

So, replace code of the following form:

sizeof(*resp) + props_count * sizeof(struct 
gb_power_supply_props_desc)


with:

struct_size(resp, props, props_count)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 


What are the odds of 2 people changing same code in greybus in
the same day :).

But it happened, so as Johan asked please rebase on top of his
patch. that would be great.

---
Cheers,
Rui


---
 drivers/staging/greybus/power_supply.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/power_supply.c 
b/drivers/staging/greybus/power_supply.c

index 0529e5628c24..40cc2d462ba0 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -520,8 +520,8 @@ static int 
gb_power_supply_prop_descriptors_get(struct gb_power_supply 
*gbpsy)
 
 	op = gb_operation_create(connection,

 GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS,
- sizeof(req), sizeof(*resp) + 
props_count *
- sizeof(struct 
gb_power_supply_props_desc),

+sizeof(req),
+ struct_size(resp, props, 
props_count),

 GFP_KERNEL);
if (!op)
return -ENOMEM;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/1] staging: media: imx: imx7-mipi-csis: simplify getting .driver_data

2019-03-20 Thread Rui Miguel Silva

Hi Wolfram,
Thanks for the patch.
On Tue 19 Mar 2019 at 16:36, Wolfram Sang wrote:
We should get 'driver_data' from 'struct device' directly. Going 
via

platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang 

Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui


---

Build tested only. buildbot is happy.

 drivers/staging/media/imx/imx7-mipi-csis.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c

index 2ddcc42ab8ff..44569c63e4de 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -1039,8 +1039,7 @@ static int mipi_csis_probe(struct 
platform_device *pdev)
 
 static int mipi_csis_pm_suspend(struct device *dev, bool 
 runtime)

 {
-   struct platform_device *pdev = to_platform_device(dev);
-   struct v4l2_subdev *mipi_sd = platform_get_drvdata(pdev);
+   struct v4l2_subdev *mipi_sd = dev_get_drvdata(dev);
struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
int ret = 0;
 
@@ -1064,8 +1063,7 @@ static int mipi_csis_pm_suspend(struct 
device *dev, bool runtime)
 
 static int mipi_csis_pm_resume(struct device *dev, bool 
 runtime)

 {
-   struct platform_device *pdev = to_platform_device(dev);
-   struct v4l2_subdev *mipi_sd = platform_get_drvdata(pdev);
+   struct v4l2_subdev *mipi_sd = dev_get_drvdata(dev);
struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
int ret = 0;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: media: imx7-mipi-csis: fix debugfs compilation

2019-03-14 Thread Rui Miguel Silva

Hi Arnd,
Thanks for the patch.
On Wed 13 Mar 2019 at 21:17, Arnd Bergmann wrote:

When CONFIG_DEBUGFS is enabled, we get a warning about an
incorrect section annotation that can lead to undefined
behavior:

WARNING: vmlinux.o(.text+0xd3c7c4): Section mismatch in 
reference from the function mipi_csis_probe() to the function 
.init.text:mipi_csis_debugfs_init()

The function mipi_csis_probe() references
the function __init mipi_csis_debugfs_init().
This is often because mipi_csis_probe lacks a __init
annotation or the annotation of mipi_csis_debugfs_init is wrong.

The same function for an unknown reason has a different
version for !CONFIG_DEBUGFS, which does not have this problem,
but behaves the same way otherwise (it does nothing when debugfs
is disabled).
Consolidate the two versions, using the correct section from
one version, and the implementation from the other.

Signed-off-by: Arnd Bergmann 

Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui


---
 drivers/staging/media/imx/imx7-mipi-csis.c | 16 
 ++--

 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c

index 2ddcc42ab8ff..001ce369ec45 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -9,6 +9,7 @@
  */
 
 #include 

+#include 
 #include 
 #include 
 #include 
@@ -889,8 +890,6 @@ static int mipi_csis_subdev_init(struct 
v4l2_subdev *mipi_sd,

return ret;
 }
 
-#ifdef CONFIG_DEBUG_FS

-#include 
 
 static int mipi_csis_dump_regs_show(struct seq_file *m, void 
 *private)

 {
@@ -900,7 +899,7 @@ static int mipi_csis_dump_regs_show(struct 
seq_file *m, void *private)

 }
 DEFINE_SHOW_ATTRIBUTE(mipi_csis_dump_regs);
 
-static int __init_or_module mipi_csis_debugfs_init(struct 
csi_state *state)

+static int mipi_csis_debugfs_init(struct csi_state *state)
 {
struct dentry *d;
 
@@ -934,17 +933,6 @@ static void mipi_csis_debugfs_exit(struct 
csi_state *state)

debugfs_remove_recursive(state->debugfs_root);
 }
 
-#else
-static int mipi_csis_debugfs_init(struct csi_state *state 
__maybe_unused)

-{
-   return 0;
-}
-
-static void mipi_csis_debugfs_exit(struct csi_state *state 
__maybe_unused)

-{
-}
-#endif
-
 static int mipi_csis_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 06/12] media: dt-bindings: add bindings for i.MX7 media driver

2019-03-12 Thread Rui Miguel Silva

Hi Laurent,
On Tue 12 Mar 2019 at 15:10, Laurent Pinchart wrote:

Hi Rui,

On Tue, Mar 12, 2019 at 02:07:02PM +, Rui Miguel Silva 
wrote:

On Sun 10 Mar 2019 at 21:48, Laurent Pinchart wrote:
> On Fri, May 18, 2018 at 09:27:58AM +0100, Rui Miguel Silva 
> wrote:

>> On Fri 18 May 2018 at 06:58, Sakari Ailus wrote:
>>> On Thu, May 17, 2018 at 01:50:27PM +0100, Rui Miguel Silva 
>>> wrote:

>>>> Add bindings documentation for i.MX7 media drivers.
>>>> 
>>>> Signed-off-by: Rui Miguel Silva 

>>>> ---
>>>>  .../devicetree/bindings/media/imx7.txt| 145 
>>>>  ++

>>>>  1 file changed, 145 insertions(+)
>>>>  create mode 100644 
>>>>  Documentation/devicetree/bindings/media/imx7.txt

>>>> 1
>>>> diff --git 
>>>> a/Documentation/devicetree/bindings/media/imx7.txt 
>>>> b/Documentation/devicetree/bindings/media/imx7.txt

>>>> new file mode 100644
>>>> index ..161cff8e6442
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/media/imx7.txt
>>>> @@ -0,0 +1,145 @@
>>>> +Freescale i.MX7 Media Video Device
>>>> +==
>>>> +
>>>> +Video Media Controller node
>>>> +---
>>>
>>> Note that DT bindings document the hardware, they are as 
>>> such 
>>> not Linux dependent.
>> 
>> This was removed in this series, however I removed it in the 
>> wrong
>> patch, If you see patch 11/12 you will see this being 
>> removed. I

>> will fix this in v5. Thanks for notice it.
>> 
>>>> +
>>>> +This is the media controller node for video capture 
>>>> support. It is a
>>>> +virtual device that lists the camera serial interface 
>>>> nodes that the

>>>> +media device will control.
>>>
>>> Ditto.
>>>
>>>> +
>>>> +Required properties:
>>>> +- compatible : "fsl,imx7-capture-subsystem";
>>>> +- ports  : Should contain a list of phandles pointing 
>>>> to camera

>>>> +  sensor interface port of CSI
>>>> +
>>>> +example:
>>>> +
>>>> +capture-subsystem {
>>>
>>> What's the purpose of this node, if you only refer to 
>>> another 
>>> device? This one rather does not look like a real device at 
>>> all.

>>>
>>>> +  compatible = "fsl,imx7-capture-subsystem";
>>>> +  ports = <>;
>>>> +};
>>>> +
>>>> +
>>>> +mipi_csi2 node
>>>> +--
>>>> +
>>>> +This is the device node for the MIPI CSI-2 receiver core 
>>>> in i.MX7 SoC. It is

>>>> +compatible with previous version of Samsung D-phy.
>>>> +
>>>> +Required properties:
>>>> +
>>>> +- compatible: "fsl,imx7-mipi-csi2";
>>>> +- reg   : base address and length of the register 
>>>> set for the device;

>>>> +- interrupts: should contain MIPI CSIS interrupt;
>>>> +- clocks: list of clock specifiers, see
>>>> + 
>>>> Documentation/devicetree/bindings/clock/clock-bindings.txt 
>>>> for details;
>>>> +- clock-names   : must contain "pclk", "wrap" and "phy" 
>>>> entries, matching

>>>> +  entries in the clock property;
>>>> +- power-domains : a phandle to the power domain, see
>>>> + 
>>>> Documentation/devicetree/bindings/power/power_domain.txt 
>>>> for details.

>>>> +- reset-names   : should include following entry "mrst";
>>>> +- resets: a list of phandle, should contain reset 
>>>> entry of

>>>> +  reset-names;
>>>> +- phy-supply: from the generic phy bindings, a 
>>>> phandle to a regulator that

>>>> +provides power to MIPI CSIS core;
>>>> +- bus-width : maximum number of data lanes supported 
>>>> (SoC specific);

>>>> +
>>>> +Optional properties:
>>>> +
>>>> +- clock-frequency : The IP's main (system bus) clock 
>>>> frequency in Hz, default
>>>> +		value when this property is not 
>>>> specified is 166 MHz;

>>&

Re: [PATCH v14 08/13] ARM: dts: imx7: Add video mux, csi and mipi_csi and connections

2019-03-12 Thread Rui Miguel Silva

Hi Laurent,
On Tue 12 Mar 2019 at 14:10, Laurent Pinchart wrote:

Hi Rui,

On Tue, Mar 12, 2019 at 02:05:24PM +, Rui Miguel Silva 
wrote:

On Sun 10 Mar 2019 at 21:41, Laurent Pinchart wrote:
> Hi Rui,
>
> Thank you for the patch.

Where have you been for the latest 14 versions? :)


Elsewhere I suppose :-)


eheh.



This is already merged, but... follow up patches can address 
your

issues bellow.


I saw the driver and DT bindings patches merged in the media 
tree for

v5.2, where have the DT patches been merged ?


Good question, now that you talk I do not think they were merged.



> On Wed, Feb 06, 2019 at 03:13:23PM +, Rui Miguel Silva 
> wrote:
>> This patch adds the device tree nodes for csi, video 
>> multiplexer and mipi-csi besides the graph connecting the 
>> necessary
>> endpoints to make the media capture entities to work in imx7 
>> Warp

>> board.
>> 
>> Signed-off-by: Rui Miguel Silva 

>> ---
>>  arch/arm/boot/dts/imx7s-warp.dts | 51 
>>  

>>  arch/arm/boot/dts/imx7s.dtsi | 27 +
>
> I would have split this in two patches to make backporting 
> easier, but it's not a big deal.

>
> Please see below for a few additional comments.
>
>>  2 files changed, 78 insertions(+)
>> 
>> diff --git a/arch/arm/boot/dts/imx7s-warp.dts 
>> b/arch/arm/boot/dts/imx7s-warp.dts

>> index 23431faecaf4..358bcae7ebaf 100644
>> --- a/arch/arm/boot/dts/imx7s-warp.dts
>> +++ b/arch/arm/boot/dts/imx7s-warp.dts
>> @@ -277,6 +277,57 @@
>>status = "okay";
>>  };
>>  
>> + {

>> +  csi_mux {
>> +  compatible = "video-mux";
>> +  mux-controls = < 0>;
>> +  #address-cells = <1>;
>> +  #size-cells = <0>;
>> +
>> +  port@1 {
>> +  reg = <1>;
>> +
>> +  csi_mux_from_mipi_vc0: endpoint {
>> +remote-endpoint = 
>> <_vc0_to_csi_mux>;

>> +  };
>> +  };
>> +
>> +  port@2 {
>> +  reg = <2>;
>> +
>> +  csi_mux_to_csi: endpoint {
>> +remote-endpoint = 
>> <_from_csi_mux>;

>> +  };
>> +  };
>> +  };
>> +};
>> +
>> + {
>> +  status = "okay";
>> +
>> +  port {
>> +  csi_from_csi_mux: endpoint {
>> +  remote-endpoint = <_mux_to_csi>;
>> +  };
>> +  };
>> +};
>
> Shouldn't these two nodes, as well as port@1 of the mipi_csi 
> node, be moved to imx7d.dtsi ?


Yeah, I guess you are right here.

>
>> +
>> +_csi {
>> +  clock-frequency = <16600>;
>> +  status = "okay";
>> +  #address-cells = <1>;
>> +  #size-cells = <0>;
>> +  fsl,csis-hs-settle = <3>;
>
> Shouldn't this be an endpoint property ? Different sensors 
> connected

> through different endpoints could have different timing
> requirements.

Hum... I see you point, even tho the phy hs-settle is a common
control. 


I suppose we don't need to care about DT backward compatibility 
if we
make changes in the bindings for v5.2 ? Would you fix this, or 
do you

want a patch ?


I will try to take a look at this until end of week.

---
Cheers,
Rui

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 06/12] media: dt-bindings: add bindings for i.MX7 media driver

2019-03-12 Thread Rui Miguel Silva

Hi Laurent,
On Sun 10 Mar 2019 at 21:48, Laurent Pinchart wrote:

Hi Rui,

On Fri, May 18, 2018 at 09:27:58AM +0100, Rui Miguel Silva 
wrote:

Hi Sakari,
Thanks for the review.
On Fri 18 May 2018 at 06:58, Sakari Ailus wrote:
> On Thu, May 17, 2018 at 01:50:27PM +0100, Rui Miguel Silva 
> wrote:

>> Add bindings documentation for i.MX7 media drivers.
>> 
>> Signed-off-by: Rui Miguel Silva 

>> ---
>>  .../devicetree/bindings/media/imx7.txt| 145 
>>  ++

>>  1 file changed, 145 insertions(+)
>>  create mode 100644 
>>  Documentation/devicetree/bindings/media/imx7.txt
>> 
>> diff --git 
>> a/Documentation/devicetree/bindings/media/imx7.txt 
>> b/Documentation/devicetree/bindings/media/imx7.txt

>> new file mode 100644
>> index ..161cff8e6442
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/media/imx7.txt
>> @@ -0,0 +1,145 @@
>> +Freescale i.MX7 Media Video Device
>> +==
>> +
>> +Video Media Controller node
>> +---
>
> Note that DT bindings document the hardware, they are as such 
> not Linux dependent.


This was removed in this series, however I removed it in the 
wrong 
patch, If you see patch 11/12 you will see this being removed. 
I will

fix this in v5. Thanks for notice it.

>> +
>> +This is the media controller node for video capture 
>> support. 
>> It is a
>> +virtual device that lists the camera serial interface nodes 
>> that the

>> +media device will control.
>
> Ditto.
>
>> +
>> +Required properties:
>> +- compatible : "fsl,imx7-capture-subsystem";
>> +- ports  : Should contain a list of phandles pointing 
>> to 
>> camera

>> +  sensor interface port of CSI
>> +
>> +example:
>> +
>> +capture-subsystem {
>
> What's the purpose of this node, if you only refer to another 
> device? This one rather does not look like a real device at 
> all.

>
>> +  compatible = "fsl,imx7-capture-subsystem";
>> +  ports = <>;
>> +};
>> +
>> +
>> +mipi_csi2 node
>> +--
>> +
>> +This is the device node for the MIPI CSI-2 receiver core in 
>> i.MX7 SoC. It is

>> +compatible with previous version of Samsung D-phy.
>> +
>> +Required properties:
>> +
>> +- compatible: "fsl,imx7-mipi-csi2";
>> +- reg   : base address and length of the register 
>> set 
>> for the device;

>> +- interrupts: should contain MIPI CSIS interrupt;
>> +- clocks: list of clock specifiers, see
>> + 
>> Documentation/devicetree/bindings/clock/clock-bindings.txt 
>> for 
>> details;
>> +- clock-names   : must contain "pclk", "wrap" and "phy" 
>> entries, matching

>> +  entries in the clock property;
>> +- power-domains : a phandle to the power domain, see
>> + 
>> Documentation/devicetree/bindings/power/power_domain.txt for 
>> details.

>> +- reset-names   : should include following entry "mrst";
>> +- resets: a list of phandle, should contain reset 
>> entry of

>> +  reset-names;
>> +- phy-supply: from the generic phy bindings, a phandle 
>> to 
>> a regulator that

>> +provides power to MIPI CSIS core;
>> +- bus-width : maximum number of data lanes supported 
>> (SoC 
>> specific);

>> +
>> +Optional properties:
>> +
>> +- clock-frequency : The IP's main (system bus) clock 
>> frequency 
>> in Hz, default
>> +		value when this property is not specified is 
>> 166 MHz;

>> +
>> +port node
>> +-
>> +
>> +- reg		  : (required) can take the values 0 or 1, 
>> where 0 is the
>> + related sink port and port 1 should be 
>> the source one;

>> +
>> +endpoint node
>> +-
>> +
>> +- data-lanes: (required) an array specifying active 
>> physical MIPI-CSI2
>> +		data input lanes and their mapping to logical 
>> lanes; the
>> +		array's content is unused, only its length is 
>> meaningful;

>> +
>> +- fsl,csis-hs-settle : (optional) differential receiver 
>> (HS-RX) settle time;

>
> Could you calculate this, as other drivers do? It probably 
> changes

> depending on the device runtime configuration.

The only reference to possible values to this parameter is 
given 
by table in [0], can you point me out the formula for imx7 in 
the

documentation?

[0] https://community.nxp.com/thread/463777


Can't you use the values from that table ? :-) You can get the 
link

speed by querying the connected subdev and reading its
V4L2_CID_PIXEL_RATE control.


Yeah, I good point to add support for others subdev's. I will try
to add your comments in a follow up series.

---
Cheers,
Rui


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v14 08/13] ARM: dts: imx7: Add video mux, csi and mipi_csi and connections

2019-03-12 Thread Rui Miguel Silva

Hi Laurent,
On Sun 10 Mar 2019 at 21:41, Laurent Pinchart wrote:

Hi Rui,

Thank you for the patch.


Where have you been for the latest 14 versions? :)

This is already merged, but... follow up patches can address your
issues bellow.



On Wed, Feb 06, 2019 at 03:13:23PM +, Rui Miguel Silva 
wrote:
This patch adds the device tree nodes for csi, video 
multiplexer and
mipi-csi besides the graph connecting the necessary endpoints 
to make

the media capture entities to work in imx7 Warp board.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s-warp.dts | 51 
 

 arch/arm/boot/dts/imx7s.dtsi | 27 +


I would have split this in two patches to make backporting 
easier, but

it's not a big deal.

Please see below for a few additional comments.


 2 files changed, 78 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s-warp.dts 
b/arch/arm/boot/dts/imx7s-warp.dts

index 23431faecaf4..358bcae7ebaf 100644
--- a/arch/arm/boot/dts/imx7s-warp.dts
+++ b/arch/arm/boot/dts/imx7s-warp.dts
@@ -277,6 +277,57 @@
status = "okay";
 };
 
+ {

+   csi_mux {
+   compatible = "video-mux";
+   mux-controls = < 0>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@1 {
+   reg = <1>;
+
+   csi_mux_from_mipi_vc0: endpoint {
+remote-endpoint = 
<_vc0_to_csi_mux>;

+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   csi_mux_to_csi: endpoint {
+remote-endpoint = 
<_from_csi_mux>;

+   };
+   };
+   };
+};
+
+ {
+   status = "okay";
+
+   port {
+   csi_from_csi_mux: endpoint {
+   remote-endpoint = <_mux_to_csi>;
+   };
+   };
+};


Shouldn't these two nodes, as well as port@1 of the mipi_csi 
node, be

moved to imx7d.dtsi ?


Yeah, I guess you are right here.




+
+_csi {
+   clock-frequency = <16600>;
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   fsl,csis-hs-settle = <3>;


Shouldn't this be an endpoint property ? Different sensors 
connected
through different endpoints could have different timing 
requirements.


Hum... I see you point, even tho the phy hs-settle is a common
control. 




+
+   port@1 {
+   reg = <1>;
+
+   mipi_vc0_to_csi_mux: endpoint {
+			remote-endpoint = 
<_mux_from_mipi_vc0>;

+   };
+   };
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_wdog>;
diff --git a/arch/arm/boot/dts/imx7s.dtsi 
b/arch/arm/boot/dts/imx7s.dtsi

index 792efcd2caa1..01962f85cab6 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "imx7d-pinfunc.h"
 
 / {

@@ -709,6 +710,17 @@
status = "disabled";
};
 
+			csi: csi@3071 {

+   compatible = "fsl,imx7-csi";
+   reg = <0x3071 0x1>;
+interrupts = IRQ_TYPE_LEVEL_HIGH>;

+   clocks = < IMX7D_CLK_DUMMY>,
+		< 
IMX7D_CSI_MCLK_ROOT_CLK>,
+		< 
IMX7D_CLK_DUMMY>;
+clock-names = "axi", "mclk", 
"dcic";

+   status = "disabled";
+   };
+
lcdif: lcdif@3073 {
 compatible = "fsl,imx7d-lcdif", 
 "fsl,imx28-lcdif";

reg = <0x3073 0x1>;
@@ -718,6 +730,21 @@
clock-names = "pix", "axi";
status = "disabled";
};
+
+   mipi_csi: mipi-csi@3075 {
+   compatible = "fsl,imx7-mipi-csi2";
+   reg = <0x3075 0x1>;
+interrupts = IRQ_TYPE_LEVEL_HIGH>;
+clocks = < 
IMX7D_IPG_ROOT_CLK>,
+	< 
IMX7D_MIPI_CSI_ROOT_CLK>,
+	< 
IMX7D_MIPI_DPHY_ROOT_CLK>;
+clock-names = "pclk", "wrap", 
"phy";

+   power-domains = <_mipi_phy>;
+   phy-supply = <_1p0d>;
+resets = < 
IMX7_RESET_MIPI_PHY_MRST>;

+   reset-names = "mrst";
+   status = "disabled";


How about already declaring port@0 here too (but obviously 
without any

endoint) ?


empty port, do not know if they make much sense.

---
Cheers,
Rui

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] media: a few more typos at staging, pci, platform, radio and usb

2019-03-01 Thread Rui Miguel Silva

Hi Mauro,
On Fri 01 Mar 2019 at 15:03, Mauro Carvalho Chehab wrote:

Those typos were left over from codespell check, on
my first pass or belong to code added after the time I
ran it.

Signed-off-by: Mauro Carvalho Chehab 



For the imx7 part:
Acked-by: Rui Miguel Silva 

Thanks.
---
Cheers,
Rui



---
 drivers/media/pci/cx18/cx18-dvb.c  | 2 +-
 drivers/media/pci/saa7164/saa7164-dvb.c| 2 +-
 drivers/media/platform/ti-vpe/vpdma.c  | 2 +-
 drivers/media/radio/wl128x/fmdrv_common.c  | 2 +-
 drivers/media/usb/au0828/au0828-dvb.c  | 2 +-
 drivers/staging/media/imx/imx7-mipi-csis.c | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-dvb.c 
b/drivers/media/pci/cx18/cx18-dvb.c

index 51ecbe350d0e..61452c50a9c3 100644
--- a/drivers/media/pci/cx18/cx18-dvb.c
+++ b/drivers/media/pci/cx18/cx18-dvb.c
@@ -458,7 +458,7 @@ void cx18_dvb_unregister(struct cx18_stream 
*stream)

dvb_unregister_adapter(dvb_adapter);
 }
 
-/* All the DVB attach calls go here, this function get's 
modified
+/* All the DVB attach calls go here, this function gets 
modified
  * for each new card. cx18_dvb_start_feed() will also need 
  changes.

  */
 static int dvb_register(struct cx18_stream *stream)
diff --git a/drivers/media/pci/saa7164/saa7164-dvb.c 
b/drivers/media/pci/saa7164/saa7164-dvb.c

index dfb118d7d1ec..3e73cb3c7e88 100644
--- a/drivers/media/pci/saa7164/saa7164-dvb.c
+++ b/drivers/media/pci/saa7164/saa7164-dvb.c
@@ -529,7 +529,7 @@ int saa7164_dvb_unregister(struct 
saa7164_port *port)

return 0;
 }
 
-/* All the DVB attach calls go here, this function get's 
modified
+/* All the DVB attach calls go here, this function gets 
modified

  * for each new card.
  */
 int saa7164_dvb_register(struct saa7164_port *port)
diff --git a/drivers/media/platform/ti-vpe/vpdma.c 
b/drivers/media/platform/ti-vpe/vpdma.c

index 1da2cb3aaf0c..78d716c93649 100644
--- a/drivers/media/platform/ti-vpe/vpdma.c
+++ b/drivers/media/platform/ti-vpe/vpdma.c
@@ -1008,7 +1008,7 @@ unsigned int vpdma_get_list_mask(struct 
vpdma_data *vpdma, int irq_num)

 }
 EXPORT_SYMBOL(vpdma_get_list_mask);
 
-/* clear previously occurred list interupts in the LIST_STAT 
register */
+/* clear previously occurred list interrupts in the LIST_STAT 
register */
 void vpdma_clear_list_stat(struct vpdma_data *vpdma, int 
 irq_num,

   int list_num)
 {
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c

index e1c218b23d9e..3c8987af3772 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1047,7 +1047,7 @@ static void 
fm_irq_handle_intmsk_cmd_resp(struct fmdev *fmdev)

clear_bit(FM_INTTASK_RUNNING, >flag);
 }
 
-/* Returns availability of RDS data in internel buffer */

+/* Returns availability of RDS data in internal buffer */
 int fmc_is_rds_data_available(struct fmdev *fmdev, struct file 
 *file,

struct poll_table_struct *pts)
 {
diff --git a/drivers/media/usb/au0828/au0828-dvb.c 
b/drivers/media/usb/au0828/au0828-dvb.c

index d9093a3c57c5..6e43028112d1 100644
--- a/drivers/media/usb/au0828/au0828-dvb.c
+++ b/drivers/media/usb/au0828/au0828-dvb.c
@@ -566,7 +566,7 @@ void au0828_dvb_unregister(struct au0828_dev 
*dev)

dvb->frontend = NULL;
 }
 
-/* All the DVB attach calls go here, this function get's 
modified
+/* All the DVB attach calls go here, this function gets 
modified

  * for each new card. No other function in this file needs
  * to change.
  */
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c

index 75b904d36621..2ddcc42ab8ff 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -822,7 +822,7 @@ static int mipi_csis_parse_dt(struct 
platform_device *pdev,

if (IS_ERR(state->mrst))
return PTR_ERR(state->mrst);
 
-	/* Get MIPI CSI-2 bus configration from the endpoint node. 
*/
+	/* Get MIPI CSI-2 bus configuration from the endpoint 
node. */
 	of_property_read_u32(node, "fsl,csis-hs-settle", 
 >hs_settle);
 
 	return 0;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] media: imx7_mipi_csis: remove internal ops

2019-02-27 Thread Rui Miguel Silva
Remove code that is not called anywhere, just
remove the internal ops.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 27 --
 1 file changed, 27 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
index f4674de09e83..75b904d36621 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -783,29 +783,6 @@ static irqreturn_t mipi_csis_irq_handler(int irq, void 
*dev_id)
return IRQ_HANDLED;
 }
 
-static int mipi_csi_registered(struct v4l2_subdev *mipi_sd)
-{
-   struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
-   unsigned int i;
-   int ret;
-
-   for (i = 0; i < CSIS_PADS_NUM; i++) {
-   state->pads[i].flags = (i == CSIS_PAD_SINK) ?
-   MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE;
-   }
-
-   /* set a default mbus format  */
-   ret = imx_media_init_mbus_fmt(>format_mbus,
- MIPI_CSIS_DEF_PIX_HEIGHT,
- MIPI_CSIS_DEF_PIX_WIDTH, 0,
- V4L2_FIELD_NONE, NULL);
-   if (ret)
-   return ret;
-
-   return media_entity_pads_init(_sd->entity, CSIS_PADS_NUM,
- state->pads);
-}
-
 static const struct v4l2_subdev_core_ops mipi_csis_core_ops = {
.log_status = mipi_csis_log_status,
 };
@@ -831,10 +808,6 @@ static const struct v4l2_subdev_ops mipi_csis_subdev_ops = 
{
.pad= _csis_pad_ops,
 };
 
-static const struct v4l2_subdev_internal_ops mipi_csis_internal_ops = {
-   .registered = mipi_csi_registered,
-};
-
 static int mipi_csis_parse_dt(struct platform_device *pdev,
  struct csi_state *state)
 {
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v14 05/13] media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7

2019-02-20 Thread Rui Miguel Silva

Hi Hans,
On Wed 20 Feb 2019 at 08:56, Hans Verkuil wrote:

On 2/6/19 4:13 PM, Rui Miguel Silva wrote:
Adds MIPI CSI-2 subdev for i.MX7 to connect with sensors with a 
MIPI

CSI-2 interface.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/Makefile |1 +
 drivers/staging/media/imx/imx7-mipi-csis.c | 1186 
 

 2 files changed, 1187 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx7-mipi-csis.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile

index 074f016d3519..d2d909a36239 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += 
imx-media-csi.o

 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
 
 obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o

+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-mipi-csis.o
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c

new file mode 100644
index ..516d308dc44b
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -0,0 +1,1186 @@





+static int mipi_csi_registered(struct v4l2_subdev *mipi_sd)
+{
+   struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
+   unsigned int i;
+   int ret;
+
+   for (i = 0; i < CSIS_PADS_NUM; i++) {
+   state->pads[i].flags = (i == CSIS_PAD_SINK) ?
+   MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE;
+   }
+
+   /* set a default mbus format  */
+   ret = imx_media_init_mbus_fmt(>format_mbus,
+ MIPI_CSIS_DEF_PIX_HEIGHT,
+ MIPI_CSIS_DEF_PIX_WIDTH, 0,
+ V4L2_FIELD_NONE, NULL);
+   if (ret)
+   return ret;
+
+	return media_entity_pads_init(_sd->entity, 
CSIS_PADS_NUM,

+ state->pads);
+}
+
+static const struct v4l2_subdev_core_ops mipi_csis_core_ops = 
{

+   .log_status = mipi_csis_log_status,
+};
+
+static const struct media_entity_operations 
mipi_csis_entity_ops = {

+   .link_setup = mipi_csis_link_setup,
+   .link_validate  = v4l2_subdev_link_validate,
+};
+
+static const struct v4l2_subdev_video_ops mipi_csis_video_ops 
= {

+   .s_stream   = mipi_csis_s_stream,
+};
+
+static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = {
+   .init_cfg   = mipi_csis_init_cfg,
+   .get_fmt= mipi_csis_get_fmt,
+   .set_fmt= mipi_csis_set_fmt,
+};
+
+static const struct v4l2_subdev_ops mipi_csis_subdev_ops = {
+   .core   = _csis_core_ops,
+   .video  = _csis_video_ops,
+   .pad= _csis_pad_ops,
+};
+
+static const struct v4l2_subdev_internal_ops 
mipi_csis_internal_ops = {

+   .registered = mipi_csi_registered,
+};


This struct is not used, and therefor mipi_csi_registered() is 
never called

either. Should it be called or can this be removed?


Good question :), I will get back to you on this one later.

---
Cheers,
Rui

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] media: imx7-media-csi: get rid of unused var

2019-02-20 Thread Rui Miguel Silva

Oi Mauro,
On Tue 19 Feb 2019 at 13:24, Mauro Carvalho Chehab wrote:
	drivers/staging/media/imx/imx7-media-csi.c: In function 
'imx7_csi_enum_mbus_code':
	drivers/staging/media/imx/imx7-media-csi.c:926:33: 
warning: variable 'in_cc' set but not used 
[-Wunused-but-set-variable]

  const struct imx_media_pixfmt *in_cc;
 ^

Signed-off-by: Mauro Carvalho Chehab 



Acked-by: Rui Miguel Silva 

---
Cheers,
Rui


---
 drivers/staging/media/imx/imx7-media-csi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c

index 0b1788d79ce9..3fba7c27c0ec 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -923,7 +923,6 @@ static int imx7_csi_enum_mbus_code(struct 
v4l2_subdev *sd,
    struct 
 v4l2_subdev_mbus_code_enum *code)

 {
struct imx7_csi *csi = v4l2_get_subdevdata(sd);
-   const struct imx_media_pixfmt *in_cc;
struct v4l2_mbus_framefmt *in_fmt;
int ret = 0;
 
@@ -931,8 +930,6 @@ static int imx7_csi_enum_mbus_code(struct 
v4l2_subdev *sd,
 
 	in_fmt = imx7_csi_get_format(csi, cfg, IMX7_CSI_PAD_SINK, 
 code->which);
 
-	in_cc = imx_media_find_mbus_format(in_fmt->code, 
CS_SEL_ANY, true);

-
switch (code->pad) {
case IMX7_CSI_PAD_SINK:
 		ret = imx_media_enum_mbus_format(>code, 
 code->index,


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] media: imx7-media-csi: don't store a floating pointer

2019-02-20 Thread Rui Miguel Silva

Oi Mauro,
On Tue 19 Feb 2019 at 13:24, Mauro Carvalho Chehab wrote:

if imx7_csi_try_fmt() fails, outcc variable won't be
initialized and csi->cc[IMX7_CSI_PAD_SRC] would be pointing
to a random location.

Signed-off-by: Mauro Carvalho Chehab 



Thanks for this, looks good.
Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui


---
 drivers/staging/media/imx/imx7-media-csi.c | 18 
 +++---

 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c

index d775e259fece..0b1788d79ce9 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -980,10 +980,10 @@ static int imx7_csi_get_fmt(struct 
v4l2_subdev *sd,

return ret;
 }
 
-static void imx7_csi_try_fmt(struct imx7_csi *csi,

-struct v4l2_subdev_pad_config *cfg,
-struct v4l2_subdev_format *sdformat,
-const struct imx_media_pixfmt **cc)
+static int imx7_csi_try_fmt(struct imx7_csi *csi,
+   struct v4l2_subdev_pad_config *cfg,
+   struct v4l2_subdev_format *sdformat,
+   const struct imx_media_pixfmt **cc)
 {
const struct imx_media_pixfmt *in_cc;
struct v4l2_mbus_framefmt *in_fmt;
@@ -992,7 +992,7 @@ static void imx7_csi_try_fmt(struct imx7_csi 
*csi,

in_fmt = imx7_csi_get_format(csi, cfg, IMX7_CSI_PAD_SINK,
 sdformat->which);
if (!in_fmt)
-   return;
+   return -EINVAL;
 
 	switch (sdformat->pad) {

case IMX7_CSI_PAD_SRC:
@@ -1023,8 +1023,10 @@ static void imx7_csi_try_fmt(struct 
imx7_csi *csi,

   false);
break;
default:
+   return -EINVAL;
break;
}
+   return 0;
 }
 
 static int imx7_csi_set_fmt(struct v4l2_subdev *sd,
@@ -1067,8 +1069,10 @@ static int imx7_csi_set_fmt(struct 
v4l2_subdev *sd,

format.pad = IMX7_CSI_PAD_SRC;
format.which = sdformat->which;
format.format = sdformat->format;
-   imx7_csi_try_fmt(csi, cfg, , );
-
+   if (imx7_csi_try_fmt(csi, cfg, , )) {
+   ret = -EINVAL;
+   goto out_unlock;
+   }
 		outfmt = imx7_csi_get_format(csi, cfg, 
 IMX7_CSI_PAD_SRC,

 sdformat->which);
*outfmt = format.format;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v14.1] media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7

2019-02-06 Thread Rui Miguel Silva
Adds MIPI CSI-2 subdev for i.MX7 to connect with sensors with a MIPI
CSI-2 interface.

Signed-off-by: Rui Miguel Silva 
---

kbuild-bot:
 - remove __exit from debugfs_exit to solve

tree:   git://linuxtv.org/hverkuil/media_tree.git imx7
head:   a95edaa9069c275170a9ecf5aedc68be974678a2
commit: 4bb816545b626911079514028f0d14891627020c [5/9] media: staging/imx7: add 
MIPI CSI-2 receiver subdev for i.MX7
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 8.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 4bb816545b626911079514028f0d14891627020c
# save the attached .config to linux build tree
GCC_VERSION=8.2.0 make.cross ARCH=ia64 

All warnings (new ones prefixed by >>):

>> WARNING: vmlinux.o(.text+0x8703e02): Section mismatch in reference from the 
>> function mipi_csis_probe() to the function 
>> .exit.text:mipi_csis_debugfs_exit()
   The function mipi_csis_probe() references a function in an exit section.
   Often the function mipi_csis_debugfs_exit() has valid usage outside the exit 
section
   and the fix is to remove the __exit annotation of mipi_csis_debugfs_exit.
--
>> WARNING: vmlinux.o(.text.unlikely+0x147662): Section mismatch in reference 
>> from the function mipi_csis_remove() to the function 
>> .exit.text:mipi_csis_debugfs_exit()
   The function mipi_csis_remove() references a function in an exit section.
   Often the function mipi_csis_debugfs_exit() has valid usage outside the exit 
section
   and the fix is to remove the __exit annotation of mipi_csis_debugfs_exit.

 drivers/staging/media/imx/Makefile |1 +
 drivers/staging/media/imx/imx7-mipi-csis.c | 1186 
 2 files changed, 1187 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx7-mipi-csis.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 074f016d3519..d2d909a36239 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
 
 obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-mipi-csis.o
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
new file mode 100644
index ..c92d18f2194c
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -0,0 +1,1186 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Freescale i.MX7 SoC series MIPI-CSI V3.3 receiver driver
+ *
+ * Copyright (C) 2019 Linaro Ltd
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "imx-media.h"
+
+#define CSIS_DRIVER_NAME   "imx7-mipi-csis"
+#define CSIS_SUBDEV_NAME   CSIS_DRIVER_NAME
+
+#define CSIS_PAD_SINK  0
+#define CSIS_PAD_SOURCE1
+#define CSIS_PADS_NUM  2
+
+#define MIPI_CSIS_DEF_PIX_WIDTH640
+#define MIPI_CSIS_DEF_PIX_HEIGHT   480
+
+/* Register map definition */
+
+/* CSIS common control */
+#define MIPI_CSIS_CMN_CTRL 0x04
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW   BIT(16)
+#define MIPI_CSIS_CMN_CTRL_INTER_MODE  BIT(10)
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW_CTRL  BIT(2)
+#define MIPI_CSIS_CMN_CTRL_RESET   BIT(1)
+#define MIPI_CSIS_CMN_CTRL_ENABLE  BIT(0)
+
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_OFFSET  8
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_MASK(3 << 8)
+
+/* CSIS clock control */
+#define MIPI_CSIS_CLK_CTRL 0x08
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH3(x)((x) << 28)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH2(x)((x) << 24)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH1(x)((x) << 20)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH0(x)((x) << 16)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_EN_MSK  (0xf << 4)
+#define MIPI_CSIS_CLK_CTRL_WCLK_SRCBIT(0)
+
+/* CSIS Interrupt mask */
+#define MIPI_CSIS_INTMSK   0x10
+#define MIPI_CSIS_INTMSK_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTMSK_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTMSK_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTMSK_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTMSK_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTMSK_FRAME_END BIT(20)
+#define MIPI_CSIS_INTMSK_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FE   BIT(8)
+#de

[PATCH v14.1] media: staging/imx: refactor imx media device probe

2019-02-06 Thread Rui Miguel Silva
Refactor and move media device initialization code to a new common
module, so it can be used by other devices, this will allow for example
a near to introduce imx7 CSI driver, to use this media device.

Signed-off-by: Rui Miguel Silva 
---

v14->v14.1:
 - Fix SPDX in dev-common

 drivers/staging/media/imx/Makefile|  1 +
 .../staging/media/imx/imx-media-dev-common.c  | 90 +++
 drivers/staging/media/imx/imx-media-dev.c | 86 --
 drivers/staging/media/imx/imx-media-of.c  |  6 +-
 drivers/staging/media/imx/imx-media.h | 14 +++
 5 files changed, 127 insertions(+), 70 deletions(-)
 create mode 100644 drivers/staging/media/imx/imx-media-dev-common.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 698a4210316e..a30b3033f9a3 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 imx-media-objs := imx-media-dev.o imx-media-internal-sd.o imx-media-of.o
+imx-media-objs += imx-media-dev-common.o
 imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 imx-media-ic-objs := imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.o
 
diff --git a/drivers/staging/media/imx/imx-media-dev-common.c 
b/drivers/staging/media/imx/imx-media-dev-common.c
new file mode 100644
index ..910594125889
--- /dev/null
+++ b/drivers/staging/media/imx/imx-media-dev-common.c
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * V4L2 Media Controller Driver for Freescale common i.MX5/6/7 SOC
+ *
+ * Copyright (c) 2019 Linaro Ltd
+ * Copyright (c) 2016 Mentor Graphics Inc.
+ */
+
+#include 
+#include 
+#include "imx-media.h"
+
+static const struct v4l2_async_notifier_operations imx_media_subdev_ops = {
+   .bound = imx_media_subdev_bound,
+   .complete = imx_media_probe_complete,
+};
+
+static const struct media_device_ops imx_media_md_ops = {
+   .link_notify = imx_media_link_notify,
+};
+
+struct imx_media_dev *imx_media_dev_init(struct device *dev)
+{
+   struct imx_media_dev *imxmd;
+   int ret;
+
+   imxmd = devm_kzalloc(dev, sizeof(*imxmd), GFP_KERNEL);
+   if (!imxmd)
+   return ERR_PTR(-ENOMEM);
+
+   dev_set_drvdata(dev, imxmd);
+
+   strlcpy(imxmd->md.model, "imx-media", sizeof(imxmd->md.model));
+   imxmd->md.ops = _media_md_ops;
+   imxmd->md.dev = dev;
+
+   mutex_init(>mutex);
+
+   imxmd->v4l2_dev.mdev = >md;
+   imxmd->v4l2_dev.notify = imx_media_notify;
+   strlcpy(imxmd->v4l2_dev.name, "imx-media",
+   sizeof(imxmd->v4l2_dev.name));
+
+   media_device_init(>md);
+
+   ret = v4l2_device_register(dev, >v4l2_dev);
+   if (ret < 0) {
+   v4l2_err(>v4l2_dev,
+"Failed to register v4l2_device: %d\n", ret);
+   goto cleanup;
+   }
+
+   dev_set_drvdata(imxmd->v4l2_dev.dev, imxmd);
+
+   INIT_LIST_HEAD(>vdev_list);
+
+   v4l2_async_notifier_init(>notifier);
+
+   return imxmd;
+
+cleanup:
+   media_device_cleanup(>md);
+
+   return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(imx_media_dev_init);
+
+int imx_media_dev_notifier_register(struct imx_media_dev *imxmd)
+{
+   int ret;
+
+   /* no subdevs? just bail */
+   if (list_empty(>notifier.asd_list)) {
+   v4l2_err(>v4l2_dev, "no subdevs\n");
+   return -ENODEV;
+   }
+
+   /* prepare the async subdev notifier and register it */
+   imxmd->notifier.ops = _media_subdev_ops;
+   ret = v4l2_async_notifier_register(>v4l2_dev,
+  >notifier);
+   if (ret) {
+   v4l2_err(>v4l2_dev,
+"v4l2_async_notifier_register failed with %d\n", ret);
+   return ret;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(imx_media_dev_notifier_register);
diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index 25e916562c66..c42bddd78906 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -116,9 +116,9 @@ static int imx_media_get_ipu(struct imx_media_dev *imxmd,
 }
 
 /* async subdev bound notifier */
-static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
- struct v4l2_subdev *sd,
- struct v4l2_async_subdev *asd)
+int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
+  struct v4l2_subdev *sd,
+  struct v4l2_async_subdev *asd)
 {
struct imx_media_dev *imxmd = notifier2dev(notifier);
int ret = 0;
@@ -302,7 +302,7 @@ static int imx_media_create_pad_vdev_lists(struct 
imx_media_dev *imxmd)
 }
 
 /* async subd

[PATCH v14 12/13] media: video-mux: add bayer formats

2019-02-06 Thread Rui Miguel Silva
Add non vendor bayer formats to the  allowed format array.

Signed-off-by: Rui Miguel Silva 
Reviewed-by: Philipp Zabel 
Acked-by: Sakari Ailus 
---
 drivers/media/platform/video-mux.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/media/platform/video-mux.c 
b/drivers/media/platform/video-mux.c
index c33900e3c23e..0ba30756e1e4 100644
--- a/drivers/media/platform/video-mux.c
+++ b/drivers/media/platform/video-mux.c
@@ -263,6 +263,26 @@ static int video_mux_set_format(struct v4l2_subdev *sd,
case MEDIA_BUS_FMT_UYYVYY16_0_5X48:
case MEDIA_BUS_FMT_JPEG_1X8:
case MEDIA_BUS_FMT_AHSV_1X32:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case MEDIA_BUS_FMT_SGBRG10_1X10:
+   case MEDIA_BUS_FMT_SGRBG10_1X10:
+   case MEDIA_BUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR12_1X12:
+   case MEDIA_BUS_FMT_SGBRG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SRGGB12_1X12:
+   case MEDIA_BUS_FMT_SBGGR14_1X14:
+   case MEDIA_BUS_FMT_SGBRG14_1X14:
+   case MEDIA_BUS_FMT_SGRBG14_1X14:
+   case MEDIA_BUS_FMT_SRGGB14_1X14:
+   case MEDIA_BUS_FMT_SBGGR16_1X16:
+   case MEDIA_BUS_FMT_SGBRG16_1X16:
+   case MEDIA_BUS_FMT_SGRBG16_1X16:
+   case MEDIA_BUS_FMT_SRGGB16_1X16:
break;
default:
sdformat->format.code = MEDIA_BUS_FMT_Y8_1X8;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v14 11/13] media: staging/imx: add i.MX7 entries to TODO file

2019-02-06 Thread Rui Miguel Silva
Add some i.MX7 related entries to TODO file.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 drivers/staging/media/imx/TODO | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO
index aeeb15494a49..6f29b5ca5324 100644
--- a/drivers/staging/media/imx/TODO
+++ b/drivers/staging/media/imx/TODO
@@ -45,3 +45,12 @@
 
  Which means a port must not contain mixed-use endpoints, they
  must all refer to media links between V4L2 subdevices.
+
+- i.MX7: all of the above, since it uses the imx media core
+
+- i.MX7: use Frame Interval Monitor
+
+- i.MX7: runtime testing with parallel sensor, links setup and streaming
+
+- i.MX7: runtime testing with different formats, for the time only 10-bit bayer
+  is tested
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v14 10/13] media: imx7.rst: add documentation for i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva
Add rst document to describe the i.MX7 media driver and also a working
example from the Warp7 board usage with a OV2680 sensor.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 Documentation/media/v4l-drivers/imx7.rst  | 159 ++
 Documentation/media/v4l-drivers/index.rst |   1 +
 2 files changed, 160 insertions(+)
 create mode 100644 Documentation/media/v4l-drivers/imx7.rst

diff --git a/Documentation/media/v4l-drivers/imx7.rst 
b/Documentation/media/v4l-drivers/imx7.rst
new file mode 100644
index ..804d900da535
--- /dev/null
+++ b/Documentation/media/v4l-drivers/imx7.rst
@@ -0,0 +1,159 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+i.MX7 Video Capture Driver
+==
+
+Introduction
+
+
+The i.MX7 contrary to the i.MX5/6 family does not contain an Image Processing
+Unit (IPU); because of that the capabilities to perform operations or
+manipulation of the capture frames are less feature rich.
+
+For image capture the i.MX7 has three units:
+- CMOS Sensor Interface (CSI)
+- Video Multiplexer
+- MIPI CSI-2 Receiver
+
+::
+   |\
+   MIPI Camera Input ---> MIPI CSI-2 --- > | \
+   |  \
+   | M |
+   | U | -->  CSI ---> Capture
+   | X |
+   |  /
+   Parallel Camera Input > | /
+   |/
+
+For additional information, please refer to the latest versions of the i.MX7
+reference manual [#f1]_.
+
+Entities
+
+
+imx7-mipi-csi2
+--
+
+This is the MIPI CSI-2 receiver entity. It has one sink pad to receive the 
pixel
+data from MIPI CSI-2 camera sensor. It has one source pad, corresponding to the
+virtual channel 0. This module is compliant to previous version of Samsung
+D-phy, and supports two D-PHY Rx Data lanes.
+
+csi_mux
+---
+
+This is the video multiplexer. It has two sink pads to select from either 
camera
+sensor with a parallel interface or from MIPI CSI-2 virtual channel 0.  It has
+a single source pad that routes to the CSI.
+
+csi
+---
+
+The CSI enables the chip to connect directly to external CMOS image sensor. CSI
+can interface directly with Parallel and MIPI CSI-2 buses. It has 256 x 64 FIFO
+to store received image pixel data and embedded DMA controllers to transfer 
data
+from the FIFO through AHB bus.
+
+This entity has one sink pad that receives from the csi_mux entity and a single
+source pad that routes video frames directly to memory buffers. This pad is
+routed to a capture device node.
+
+Usage Notes
+---
+
+To aid in configuration and for backward compatibility with V4L2 applications
+that access controls only from video device nodes, the capture device 
interfaces
+inherit controls from the active entities in the current pipeline, so controls
+can be accessed either directly from the subdev or from the active capture
+device interface. For example, the sensor controls are available either from 
the
+sensor subdevs or from the active capture device.
+
+Warp7 with OV2680
+-
+
+On this platform an OV2680 MIPI CSI-2 module is connected to the internal MIPI
+CSI-2 receiver. The following example configures a video capture pipeline with
+an output of 800x600, and BGGR 10 bit bayer format:
+
+.. code-block:: none
+   # Setup links
+   media-ctl -l "'ov2680 1-0036':0 -> 'imx7-mipi-csis.0':0[1]"
+   media-ctl -l "'imx7-mipi-csis.0':1 -> 'csi_mux':1[1]"
+   media-ctl -l "'csi_mux':2 -> 'csi':0[1]"
+   media-ctl -l "'csi':1 -> 'csi capture':0[1]"
+
+   # Configure pads for pipeline
+   media-ctl -V "'ov2680 1-0036':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi_mux':1 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi_mux':2 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'imx7-mipi-csis.0':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+
+After this streaming can start. The v4l2-ctl tool can be used to select any of
+the resolutions supported by the sensor.
+
+.. code-block:: none
+root@imx7s-warp:~# media-ctl -p
+Media controller API version 4.17.0
+
+Media device information
+
+driver  imx-media
+model   imx-media
+serial
+bus info
+hw revision 0x0
+driver version  4.17.0
+
+Device topology
+- entity 1: csi (2 pads, 2 links)
+   type V4L2 subdev subtype Unknown flags 0
+   device node name /dev/v4l-subdev0
+   pad0: Sink
+   [fmt:SBGGR10_1X10/800x600 field:none]
+   <- "csi_mux":2 [ENABLED]
+   pad1: S

[PATCH v14 13/13] media: MAINTAINERS: add entry for Freescale i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva
Add maintainer entry for the imx7 media csi, mipi csis driver,
dt-bindings and documentation.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 MAINTAINERS | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3e211916d2bc..d8e0c9040736 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9348,6 +9348,17 @@ T:   git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/platform/imx-pxp.[ch]
 
+MEDIA DRIVERS FOR FREESCALE IMX7
+M: Rui Miguel Silva 
+L: linux-me...@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: Documentation/devicetree/bindings/media/imx7-csi.txt
+F: Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt
+F: Documentation/media/v4l-drivers/imx7.rst
+F: drivers/staging/media/imx/imx7-media-csi.c
+F: drivers/staging/media/imx/imx7-mipi-csis.c
+
 MEDIA DRIVERS FOR HELENE
 M: Abylay Ospan 
 L: linux-me...@vger.kernel.org
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v14 09/13] ARM: dts: imx7s-warp: add ov2680 sensor node

2019-02-06 Thread Rui Miguel Silva
Warp7 comes with a Omnivision OV2680 sensor, add the node here to make
complete the camera data path for this system. Add the needed regulator
to the analog voltage supply, the port and endpoints in mipi_csi node
and the pinctrl for the reset gpio.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s-warp.dts | 44 
 1 file changed, 44 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s-warp.dts b/arch/arm/boot/dts/imx7s-warp.dts
index 358bcae7ebaf..58d1a89ee3e3 100644
--- a/arch/arm/boot/dts/imx7s-warp.dts
+++ b/arch/arm/boot/dts/imx7s-warp.dts
@@ -55,6 +55,14 @@
regulator-always-on;
};
 
+   reg_peri_3p15v: regulator-peri-3p15v {
+   compatible = "regulator-fixed";
+   regulator-name = "peri_3p15v_reg";
+   regulator-min-microvolt = <315>;
+   regulator-max-microvolt = <315>;
+   regulator-always-on;
+   };
+
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "imx7-sgtl5000";
@@ -178,6 +186,27 @@
pinctrl-names = "default";
pinctrl-0 = <_i2c2>;
status = "okay";
+
+   ov2680: camera@36 {
+   compatible = "ovti,ov2680";
+   pinctrl-names = "default";
+   pinctrl-0 = <_ov2680>;
+   reg = <0x36>;
+   clocks = <>;
+   clock-names = "xvclk";
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+   DOVDD-supply = <_reg>;
+   DVDD-supply = <_reg>;
+   AVDD-supply = <_peri_3p15v>;
+
+   port {
+   ov2680_to_mipi: endpoint {
+   remote-endpoint = <_from_sensor>;
+   clock-lanes = <0>;
+   data-lanes = <1>;
+   };
+   };
+   };
 };
 
  {
@@ -319,6 +348,15 @@
#size-cells = <0>;
fsl,csis-hs-settle = <3>;
 
+   port@0 {
+   reg = <0>;
+
+   mipi_from_sensor: endpoint {
+   remote-endpoint = <_to_mipi>;
+   data-lanes = <1>;
+   };
+   };
+
port@1 {
reg = <1>;
 
@@ -382,6 +420,12 @@
>;
};
 
+   pinctrl_ov2680: ov2660grp {
+   fsl,pins = <
+   MX7D_PAD_LPSR_GPIO1_IO03__GPIO1_IO3 0x14
+   >;
+   };
+
pinctrl_sai1: sai1grp {
fsl,pins = <
MX7D_PAD_SAI1_RX_DATA__SAI1_RX_DATA00x1f
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v14 05/13] media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7

2019-02-06 Thread Rui Miguel Silva
Adds MIPI CSI-2 subdev for i.MX7 to connect with sensors with a MIPI
CSI-2 interface.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/Makefile |1 +
 drivers/staging/media/imx/imx7-mipi-csis.c | 1186 
 2 files changed, 1187 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx7-mipi-csis.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 074f016d3519..d2d909a36239 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
 
 obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-mipi-csis.o
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
new file mode 100644
index ..516d308dc44b
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -0,0 +1,1186 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Freescale i.MX7 SoC series MIPI-CSI V3.3 receiver driver
+ *
+ * Copyright (C) 2019 Linaro Ltd
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "imx-media.h"
+
+#define CSIS_DRIVER_NAME   "imx7-mipi-csis"
+#define CSIS_SUBDEV_NAME   CSIS_DRIVER_NAME
+
+#define CSIS_PAD_SINK  0
+#define CSIS_PAD_SOURCE1
+#define CSIS_PADS_NUM  2
+
+#define MIPI_CSIS_DEF_PIX_WIDTH640
+#define MIPI_CSIS_DEF_PIX_HEIGHT   480
+
+/* Register map definition */
+
+/* CSIS common control */
+#define MIPI_CSIS_CMN_CTRL 0x04
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW   BIT(16)
+#define MIPI_CSIS_CMN_CTRL_INTER_MODE  BIT(10)
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW_CTRL  BIT(2)
+#define MIPI_CSIS_CMN_CTRL_RESET   BIT(1)
+#define MIPI_CSIS_CMN_CTRL_ENABLE  BIT(0)
+
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_OFFSET  8
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_MASK(3 << 8)
+
+/* CSIS clock control */
+#define MIPI_CSIS_CLK_CTRL 0x08
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH3(x)((x) << 28)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH2(x)((x) << 24)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH1(x)((x) << 20)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH0(x)((x) << 16)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_EN_MSK  (0xf << 4)
+#define MIPI_CSIS_CLK_CTRL_WCLK_SRCBIT(0)
+
+/* CSIS Interrupt mask */
+#define MIPI_CSIS_INTMSK   0x10
+#define MIPI_CSIS_INTMSK_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTMSK_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTMSK_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTMSK_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTMSK_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTMSK_FRAME_END BIT(20)
+#define MIPI_CSIS_INTMSK_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FE   BIT(8)
+#define MIPI_CSIS_INTMSK_ERR_OVER  BIT(4)
+#define MIPI_CSIS_INTMSK_ERR_WRONG_CFG BIT(3)
+#define MIPI_CSIS_INTMSK_ERR_ECC   BIT(2)
+#define MIPI_CSIS_INTMSK_ERR_CRC   BIT(1)
+#define MIPI_CSIS_INTMSK_ERR_UNKNOWN   BIT(0)
+
+/* CSIS Interrupt source */
+#define MIPI_CSIS_INTSRC   0x14
+#define MIPI_CSIS_INTSRC_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTSRC_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTSRC_EVEN  BIT(30)
+#define MIPI_CSIS_INTSRC_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTSRC_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTSRC_ODD   (0x3 << 28)
+#define MIPI_CSIS_INTSRC_NON_IMAGE_DATA(0xf << 28)
+#define MIPI_CSIS_INTSRC_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTSRC_FRAME_END BIT(20)
+#define MIPI_CSIS_INTSRC_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTSRC_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTSRC_ERR_LOST_FE   BIT(8)
+#define MIPI_CSIS_INTSRC_ERR_OVER  BIT(4)
+#define MIPI_CSIS_INTSRC_ERR_WRONG_CFG BIT(3)
+#define MIPI_CSIS_INTSRC_ERR_ECC   BIT(2)
+#define MIPI_CSIS_INTSRC_ERR_CRC   BIT(1)
+#define MIPI_CSIS_INTSRC_ERR_UNKNOWN   BIT(0)
+#define MIPI_CSIS_INTSRC_ERRORS0xf
+
+/* D-PHY status control */
+#define MIPI_CSIS_DPHYSTATUS   0x20
+#define MIPI_CSIS_DPHYSTATUS_ULPS_DAT  BIT(8)
+#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_DAT BIT(4)
+#define MIPI_CSIS_DPHYSTATUS_ULPS_CLK  BIT(1)
+#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_CLK BIT(0)
+
+/* D-PHY common control */
+#define MIPI_CSIS_DPHYCTRL 0x24
+#define MIPI_CSIS_DPHYCTRL_HSS

[PATCH v14 08/13] ARM: dts: imx7: Add video mux, csi and mipi_csi and connections

2019-02-06 Thread Rui Miguel Silva
This patch adds the device tree nodes for csi, video multiplexer and
mipi-csi besides the graph connecting the necessary endpoints to make
the media capture entities to work in imx7 Warp board.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s-warp.dts | 51 
 arch/arm/boot/dts/imx7s.dtsi | 27 +
 2 files changed, 78 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s-warp.dts b/arch/arm/boot/dts/imx7s-warp.dts
index 23431faecaf4..358bcae7ebaf 100644
--- a/arch/arm/boot/dts/imx7s-warp.dts
+++ b/arch/arm/boot/dts/imx7s-warp.dts
@@ -277,6 +277,57 @@
status = "okay";
 };
 
+ {
+   csi_mux {
+   compatible = "video-mux";
+   mux-controls = < 0>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@1 {
+   reg = <1>;
+
+   csi_mux_from_mipi_vc0: endpoint {
+   remote-endpoint = <_vc0_to_csi_mux>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   csi_mux_to_csi: endpoint {
+   remote-endpoint = <_from_csi_mux>;
+   };
+   };
+   };
+};
+
+ {
+   status = "okay";
+
+   port {
+   csi_from_csi_mux: endpoint {
+   remote-endpoint = <_mux_to_csi>;
+   };
+   };
+};
+
+_csi {
+   clock-frequency = <16600>;
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   fsl,csis-hs-settle = <3>;
+
+   port@1 {
+   reg = <1>;
+
+   mipi_vc0_to_csi_mux: endpoint {
+   remote-endpoint = <_mux_from_mipi_vc0>;
+   };
+   };
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_wdog>;
diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 792efcd2caa1..01962f85cab6 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "imx7d-pinfunc.h"
 
 / {
@@ -709,6 +710,17 @@
status = "disabled";
};
 
+   csi: csi@3071 {
+   compatible = "fsl,imx7-csi";
+   reg = <0x3071 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_CLK_DUMMY>,
+   < IMX7D_CSI_MCLK_ROOT_CLK>,
+   < IMX7D_CLK_DUMMY>;
+   clock-names = "axi", "mclk", "dcic";
+   status = "disabled";
+   };
+
lcdif: lcdif@3073 {
compatible = "fsl,imx7d-lcdif", 
"fsl,imx28-lcdif";
reg = <0x3073 0x1>;
@@ -718,6 +730,21 @@
clock-names = "pix", "axi";
status = "disabled";
};
+
+   mipi_csi: mipi-csi@3075 {
+   compatible = "fsl,imx7-mipi-csi2";
+   reg = <0x3075 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_IPG_ROOT_CLK>,
+   < IMX7D_MIPI_CSI_ROOT_CLK>,
+   < IMX7D_MIPI_DPHY_ROOT_CLK>;
+   clock-names = "pclk", "wrap", "phy";
+   power-domains = <_mipi_phy>;
+   phy-supply = <_1p0d>;
+   resets = < IMX7_RESET_MIPI_PHY_MRST>;
+   reset-names = "mrst";
+   status = "disabled";
+   };
};
 
aips3: aips-bus@3080 {
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v14 02/13] media: staging/imx: rearrange group id to take in account IPU

2019-02-06 Thread Rui Miguel Silva
Some imx system do not have IPU, so prepare the imx media drivers to
support this kind of devices. Rename the group ids to include an _IPU_
prefix, add a new group id to support systems with only a CSI without
IPU, and also rename the create internal links to make it clear that
only systems with IPU have internal subdevices.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 drivers/staging/media/imx/imx-ic-common.c |  6 ++---
 drivers/staging/media/imx/imx-ic-prp.c| 16 ++---
 drivers/staging/media/imx/imx-media-csi.c |  6 ++---
 drivers/staging/media/imx/imx-media-dev.c | 22 ++
 .../staging/media/imx/imx-media-internal-sd.c | 20 
 drivers/staging/media/imx/imx-media-utils.c   | 12 +-
 drivers/staging/media/imx/imx-media.h | 23 ++-
 7 files changed, 55 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-common.c 
b/drivers/staging/media/imx/imx-ic-common.c
index cfdd4900a3be..765919487a73 100644
--- a/drivers/staging/media/imx/imx-ic-common.c
+++ b/drivers/staging/media/imx/imx-ic-common.c
@@ -41,13 +41,13 @@ static int imx_ic_probe(struct platform_device *pdev)
pdata = priv->dev->platform_data;
priv->ipu_id = pdata->ipu_id;
switch (pdata->grp_id) {
-   case IMX_MEDIA_GRP_ID_IC_PRP:
+   case IMX_MEDIA_GRP_ID_IPU_IC_PRP:
priv->task_id = IC_TASK_PRP;
break;
-   case IMX_MEDIA_GRP_ID_IC_PRPENC:
+   case IMX_MEDIA_GRP_ID_IPU_IC_PRPENC:
priv->task_id = IC_TASK_ENCODER;
break;
-   case IMX_MEDIA_GRP_ID_IC_PRPVF:
+   case IMX_MEDIA_GRP_ID_IPU_IC_PRPVF:
priv->task_id = IC_TASK_VIEWFINDER;
break;
default:
diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index 98923fc844ce..2702548f83cf 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -77,7 +77,7 @@ static int prp_start(struct prp_priv *priv)
priv->ipu = priv->md->ipu[ic_priv->ipu_id];
 
/* set IC to receive from CSI or VDI depending on source */
-   src_is_vdic = !!(priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_VDIC);
+   src_is_vdic = !!(priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_IPU_VDIC);
 
ipu_set_ic_src_mux(priv->ipu, priv->csi_id, src_is_vdic);
 
@@ -237,8 +237,8 @@ static int prp_link_setup(struct media_entity *entity,
ret = -EBUSY;
goto out;
}
-   if (priv->sink_sd_prpenc && (remote_sd->grp_id &
-IMX_MEDIA_GRP_ID_VDIC)) {
+   if (priv->sink_sd_prpenc &&
+   (remote_sd->grp_id & IMX_MEDIA_GRP_ID_IPU_VDIC)) {
ret = -EINVAL;
goto out;
}
@@ -259,7 +259,7 @@ static int prp_link_setup(struct media_entity *entity,
goto out;
}
if (priv->src_sd && (priv->src_sd->grp_id &
-IMX_MEDIA_GRP_ID_VDIC)) {
+IMX_MEDIA_GRP_ID_IPU_VDIC)) {
ret = -EINVAL;
goto out;
}
@@ -309,13 +309,13 @@ static int prp_link_validate(struct v4l2_subdev *sd,
return ret;
 
csi = imx_media_find_upstream_subdev(priv->md, _priv->sd.entity,
-IMX_MEDIA_GRP_ID_CSI);
+IMX_MEDIA_GRP_ID_IPU_CSI);
if (IS_ERR(csi))
csi = NULL;
 
mutex_lock(>lock);
 
-   if (priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_VDIC) {
+   if (priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_IPU_VDIC) {
/*
 * the ->PRPENC link cannot be enabled if the source
 * is the VDIC
@@ -334,10 +334,10 @@ static int prp_link_validate(struct v4l2_subdev *sd,
 
if (csi) {
switch (csi->grp_id) {
-   case IMX_MEDIA_GRP_ID_CSI0:
+   case IMX_MEDIA_GRP_ID_IPU_CSI0:
priv->csi_id = 0;
break;
-   case IMX_MEDIA_GRP_ID_CSI1:
+   case IMX_MEDIA_GRP_ID_IPU_CSI1:
priv->csi_id = 1;
break;
default:
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index d851ca2497b4..d957b8aa3ec5 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/me

[PATCH v14 06/13] ARM: dts: imx7s: add mipi phy power domain

2019-02-06 Thread Rui Miguel Silva
Add power domain index 0 related with mipi-phy to imx7s.

While at it rename pcie power-domain node to remove pgc prefix.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s.dtsi | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index e88f53a4c7f4..9a680d3d6424 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -606,7 +606,13 @@
#address-cells = <1>;
#size-cells = <0>;
 
-   pgc_pcie_phy: pgc-power-domain@1 {
+   pgc_mipi_phy: power-domain@0 {
+   #power-domain-cells = <0>;
+   reg = <0>;
+   power-supply = <_1p0d>;
+   };
+
+   pgc_pcie_phy: power-domain@1 {
#power-domain-cells = <0>;
reg = <1>;
power-supply = <_1p0d>;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v14 00/13] media: staging/imx7: add i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva
   info: checking control 'Image Processing Controls' (0x009f0001)
info: checking control 'Test Pattern' (0x009f0903)
test VIDIOC_G/S_CTRL: OK
info: checking extended control 'User Controls' (0x00980001)
info: checking extended control 'Exposure' (0x00980911)
info: checking extended control 'Gain, Automatic' (0x00980912)
info: checking extended control 'Gain' (0x00980913)
info: checking extended control 'Horizontal Flip' (0x00980914)
info: checking extended control 'Vertical Flip' (0x00980915)
info: checking extended control 'Camera Controls' (0x009a0001)
info: checking extended control 'Auto Exposure' (0x009a0901)
info: checking extended control 'Image Processing Controls' 
(0x009f0001)
info: checking extended control 'Test Pattern' (0x009f0903)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
info: checking control event 'User Controls' (0x00980001)
fail: 
../../../../../../../../../../v4l-utils/utils/v4l2-compliance/v4l2-test-controls.cpp(824):
 subscribe event for control 'User Controls' failed
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 10 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not Supported)
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK (Not Supported)
test VIDIOC_TRY_FMT: OK (Not Supported)
test VIDIOC_S_FMT: OK (Not Supported)
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK (Not Supported)
test VIDIOC_EXPBUF: OK (Not Supported)
test Requests: OK (Not Supported)

Total for device /dev/v4l-subdev3: 40, Succeeded: 39, Failed: 1, Warnings: 0

Grand Total for imx7-csi device /dev/media0: 227, Succeeded: 225, Failed: 2, 
Warnings: 0

Rui Miguel Silva (13):
  media: staging/imx: refactor imx media device probe
  media: staging/imx: rearrange group id to take in account IPU
  media: dt-bindings: add bindings for i.MX7 media driver
  media: staging/imx7: add imx7 CSI subdev driver
  media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7
  ARM: dts: imx7s: add mipi phy power domain
  ARM: dts: imx7s: add multiplexer controls
  ARM: dts: imx7: Add video mux, csi and mipi_csi and connections
  ARM: dts: imx7s-warp: add ov2680 sensor node
  media: imx7.rst: add documentation for i.MX7 media driver
  media: staging/imx: add i.MX7 entries to TODO file
  media: video-mux: add bayer formats
  media: MAINTAINERS: add entry for Freescale i.MX7 media driver

 .../devicetree/bindings/media/imx7-csi.txt|   45 +
 .../bindings/media/imx7-mipi-csi2.txt |   90 ++
 Documentation/media/v4l-drivers/imx7.rst  |  159 ++
 Documentation/media/v4l-drivers/index.rst |1 +
 MAINTAINERS   |   11 +
 arch/arm/boot/dts/imx7s-warp.dts  |   95 ++
 arch/arm/boot/dts/imx7s.dtsi  |   44 +-
 drivers/media/platform/video-mux.c|   20 +
 drivers/staging/media/imx/Kconfig |9 +-
 drivers/staging/media/imx/Makefile|4 +
 drivers/staging/media/imx/TODO|9 +
 drivers/staging/media/imx/imx-ic-common.c |6 +-
 drivers/staging/media/imx/imx-ic-prp.c|   16 +-
 drivers/staging/media/imx/imx-media-csi.c |6 +-
 .../staging/media/imx/imx-media-dev-common.c  |   90 ++
 drivers/staging/media/imx/imx-media-dev.c |  108 +-
 .../staging/media/imx/imx-media-internal-sd.c |   20 +-
 drivers/staging/media/imx/imx-media-of.c  |6 +-
 drivers/staging/media/imx/imx-media-utils.c   |   12 +-
 drivers/staging/media/imx/imx-media.h |   37 +-
 drivers/staging/media/imx/imx7-media-csi.c| 1365 +
 drivers/staging/media/imx/imx7-mipi-csis.c| 1186 ++
 22 files changed, 3216 insertions(+), 123 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/imx7-csi.txt
 create mode 100644 Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt
 create mode 100644 Documentation/media/v4l-drivers/imx7.rst
 create mode 100644 drivers/staging/media/imx/imx-media-dev-common.c
 create mode 100644 drivers/staging/media/imx/imx7-media-csi.c
 create mode 100644 drivers/staging/media/imx/imx7-mipi-csis.c

-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.

[PATCH v14 03/13] media: dt-bindings: add bindings for i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva
Add bindings documentation for i.MX7 media drivers.
The imx7 MIPI CSI2 and imx7 CMOS Sensor Interface.

Signed-off-by: Rui Miguel Silva 
Reviewed-by: Rob Herring 
Acked-by: Sakari Ailus 
---
 .../devicetree/bindings/media/imx7-csi.txt| 45 ++
 .../bindings/media/imx7-mipi-csi2.txt | 90 +++
 2 files changed, 135 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx7-csi.txt
 create mode 100644 Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt

diff --git a/Documentation/devicetree/bindings/media/imx7-csi.txt 
b/Documentation/devicetree/bindings/media/imx7-csi.txt
new file mode 100644
index ..3c07bc676bc3
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/imx7-csi.txt
@@ -0,0 +1,45 @@
+Freescale i.MX7 CMOS Sensor Interface
+=
+
+csi node
+
+
+This is device node for the CMOS Sensor Interface (CSI) which enables the chip
+to connect directly to external CMOS image sensors.
+
+Required properties:
+
+- compatible: "fsl,imx7-csi";
+- reg   : base address and length of the register set for the device;
+- interrupts: should contain CSI interrupt;
+- clocks: list of clock specifiers, see
+Documentation/devicetree/bindings/clock/clock-bindings.txt for details;
+- clock-names   : must contain "axi", "mclk" and "dcic" entries, matching
+ entries in the clock property;
+
+The device node shall contain one 'port' child node with one child 'endpoint'
+node, according to the bindings defined in:
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+In the following example a remote endpoint is a video multiplexer.
+
+example:
+
+csi: csi@3071 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+compatible = "fsl,imx7-csi";
+reg = <0x3071 0x1>;
+interrupts = ;
+clocks = < IMX7D_CLK_DUMMY>,
+< IMX7D_CSI_MCLK_ROOT_CLK>,
+< IMX7D_CLK_DUMMY>;
+clock-names = "axi", "mclk", "dcic";
+
+port {
+csi_from_csi_mux: endpoint {
+remote-endpoint = <_mux_to_csi>;
+};
+};
+};
diff --git a/Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt 
b/Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt
new file mode 100644
index ..71fd74ed3ec8
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt
@@ -0,0 +1,90 @@
+Freescale i.MX7 Mipi CSI2
+=
+
+mipi_csi2 node
+--
+
+This is the device node for the MIPI CSI-2 receiver core in i.MX7 SoC. It is
+compatible with previous version of Samsung D-phy.
+
+Required properties:
+
+- compatible: "fsl,imx7-mipi-csi2";
+- reg   : base address and length of the register set for the device;
+- interrupts: should contain MIPI CSIS interrupt;
+- clocks: list of clock specifiers, see
+Documentation/devicetree/bindings/clock/clock-bindings.txt for details;
+- clock-names   : must contain "pclk", "wrap" and "phy" entries, matching
+  entries in the clock property;
+- power-domains : a phandle to the power domain, see
+  Documentation/devicetree/bindings/power/power_domain.txt for details.
+- reset-names   : should include following entry "mrst";
+- resets: a list of phandle, should contain reset entry of
+  reset-names;
+- phy-supply: from the generic phy bindings, a phandle to a regulator that
+ provides power to MIPI CSIS core;
+
+Optional properties:
+
+- clock-frequency : The IP's main (system bus) clock frequency in Hz, default
+   value when this property is not specified is 166 MHz;
+- fsl,csis-hs-settle : differential receiver (HS-RX) settle time;
+
+The device node should contain two 'port' child nodes with one child 'endpoint'
+node, according to the bindings defined in:
+ Documentation/devicetree/bindings/ media/video-interfaces.txt.
+ The following are properties specific to those nodes.
+
+port node
+-
+
+- reg: (required) can take the values 0 or 1, where 0 shall be
+ related to the sink port and port 1 shall be the source
+ one;
+
+endpoint node
+-
+
+- data-lanes: (required) an array specifying active physical MIPI-CSI2
+   data input lanes and their mapping to logical lanes; this
+shall only be app

[PATCH v14 07/13] ARM: dts: imx7s: add multiplexer controls

2019-02-06 Thread Rui Miguel Silva
The IOMUXC General Purpose Register has bitfield to control video bus
multiplexer to control the CSI input between the MIPI-CSI2 and parallel
interface. Add that register and mask.

Signed-off-by: Rui Miguel Silva 
Reviewed-by: Philipp Zabel 
---
 arch/arm/boot/dts/imx7s.dtsi | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 9a680d3d6424..792efcd2caa1 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -497,8 +497,15 @@
 
gpr: iomuxc-gpr@3034 {
compatible = "fsl,imx7d-iomuxc-gpr",
-   "fsl,imx6q-iomuxc-gpr", "syscon";
+   "fsl,imx6q-iomuxc-gpr", "syscon",
+   "simple-mfd";
reg = <0x3034 0x1>;
+
+   mux: mux-controller {
+   compatible = "mmio-mux";
+   #mux-control-cells = <0>;
+   mux-reg-masks = <0x14 0x0010>;
+   };
};
 
ocotp: ocotp-ctrl@3035 {
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v14 04/13] media: staging/imx7: add imx7 CSI subdev driver

2019-02-06 Thread Rui Miguel Silva
This add the media entity subdevice and control driver for the i.MX7
CMOS Sensor Interface.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 drivers/staging/media/imx/Kconfig  |9 +-
 drivers/staging/media/imx/Makefile |2 +
 drivers/staging/media/imx/imx7-media-csi.c | 1365 
 3 files changed, 1375 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/media/imx/imx7-media-csi.c

diff --git a/drivers/staging/media/imx/Kconfig 
b/drivers/staging/media/imx/Kconfig
index bfc17de56b17..36b276ea2ecc 100644
--- a/drivers/staging/media/imx/Kconfig
+++ b/drivers/staging/media/imx/Kconfig
@@ -11,7 +11,7 @@ config VIDEO_IMX_MEDIA
  driver for the i.MX5/6 SOC.
 
 if VIDEO_IMX_MEDIA
-menu "i.MX5/6 Media Sub devices"
+menu "i.MX5/6/7 Media Sub devices"
 
 config VIDEO_IMX_CSI
tristate "i.MX5/6 Camera Sensor Interface driver"
@@ -20,5 +20,12 @@ config VIDEO_IMX_CSI
---help---
  A video4linux camera sensor interface driver for i.MX5/6.
 
+config VIDEO_IMX7_CSI
+   tristate "i.MX7 Camera Sensor Interface driver"
+   depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
+   default y
+   help
+ Enable support for video4linux camera sensor interface driver for
+ i.MX7.
 endmenu
 endif
diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index a30b3033f9a3..074f016d3519 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -12,3 +12,5 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o
 
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
+
+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
new file mode 100644
index ..d5154f032979
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -0,0 +1,1365 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC
+ *
+ * Copyright (c) 2019 Linaro Ltd
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "imx-media.h"
+
+#define IMX7_CSI_PAD_SINK  0
+#define IMX7_CSI_PAD_SRC   1
+#define IMX7_CSI_PADS_NUM  2
+
+/* reset values */
+#define CSICR1_RESET_VAL   0x4800
+#define CSICR2_RESET_VAL   0x0
+#define CSICR3_RESET_VAL   0x0
+
+/* csi control reg 1 */
+#define BIT_SWAP16_EN  BIT(31)
+#define BIT_EXT_VSYNC  BIT(30)
+#define BIT_EOF_INT_EN BIT(29)
+#define BIT_PRP_IF_EN  BIT(28)
+#define BIT_CCIR_MODE  BIT(27)
+#define BIT_COF_INT_EN BIT(26)
+#define BIT_SF_OR_INTENBIT(25)
+#define BIT_RF_OR_INTENBIT(24)
+#define BIT_SFF_DMA_DONE_INTEN  BIT(22)
+#define BIT_STATFF_INTEN   BIT(21)
+#define BIT_FB2_DMA_DONE_INTEN  BIT(20)
+#define BIT_FB1_DMA_DONE_INTEN  BIT(19)
+#define BIT_RXFF_INTEN BIT(18)
+#define BIT_SOF_POLBIT(17)
+#define BIT_SOF_INTEN  BIT(16)
+#define BIT_MCLKDIV(0xF << 12)
+#define BIT_HSYNC_POL  BIT(11)
+#define BIT_CCIR_ENBIT(10)
+#define BIT_MCLKEN BIT(9)
+#define BIT_FCCBIT(8)
+#define BIT_PACK_DIR   BIT(7)
+#define BIT_CLR_STATFIFO   BIT(6)
+#define BIT_CLR_RXFIFO BIT(5)
+#define BIT_GCLK_MODE  BIT(4)
+#define BIT_INV_DATA   BIT(3)
+#define BIT_INV_PCLK   BIT(2)
+#define BIT_REDGE  BIT(1)
+#define BIT_PIXEL_BIT  BIT(0)
+
+#define SHIFT_MCLKDIV  12
+
+/* control reg 3 */
+#define BIT_FRMCNT (0x << 16)
+#define BIT_FRMCNT_RST BIT(15)
+#define BIT_DMA_REFLASH_RFFBIT(14)
+#define BIT_DMA_REFLASH_SFFBIT(13)
+#define BIT_DMA_REQ_EN_RFF BIT(12)
+#define BIT_DMA_REQ_EN_SFF BIT(11)
+#define BIT_STATFF_LEVEL   (0x7 << 8)
+#define BIT_HRESP_ERR_EN   BIT(7)
+#define BIT_RXFF_LEVEL (0x7 << 4)
+#define BIT_TWO_8BIT_SENSORBIT(3)
+#define BIT_ZERO_PACK_EN   BIT(2)
+#define BIT_ECC_INT_EN BIT(1)
+#define BIT_ECC_AUTO_ENBIT(0)
+
+#define SHIFT_FRMCNT   16
+#define SHIFT_RXFIFO_LEVEL 4
+
+/* csi status reg */
+#define BIT_ADDR_CH_ERR_INTBIT(28)
+#define BIT_FIELD0_INT BIT(27)
+#define BIT_FIELD1_INT BIT(26)
+#define BIT_SFF_OR_INT BIT(25)
+#define BIT_RFF_OR_INT BIT(24)
+#define BIT_DMA_TSF_DONE_SFF   BIT(22)
+#define BIT_STATFF_INT BIT(21)
+#define BIT_DMA_TSF_DONE_FB2   BIT(20)
+#define BIT_DMA_TSF_DONE_FB1   BIT(19)
+#define BIT_RXFF_INT   BIT(18)
+#define BIT_EOF_INTBIT(17)
+#define 

[PATCH v14 01/13] media: staging/imx: refactor imx media device probe

2019-02-06 Thread Rui Miguel Silva
Refactor and move media device initialization code to a new common
module, so it can be used by other devices, this will allow for example
a near to introduce imx7 CSI driver, to use this media device.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/Makefile|  1 +
 .../staging/media/imx/imx-media-dev-common.c  | 90 +++
 drivers/staging/media/imx/imx-media-dev.c | 86 --
 drivers/staging/media/imx/imx-media-of.c  |  6 +-
 drivers/staging/media/imx/imx-media.h | 14 +++
 5 files changed, 127 insertions(+), 70 deletions(-)
 create mode 100644 drivers/staging/media/imx/imx-media-dev-common.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 698a4210316e..a30b3033f9a3 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 imx-media-objs := imx-media-dev.o imx-media-internal-sd.o imx-media-of.o
+imx-media-objs += imx-media-dev-common.o
 imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 imx-media-ic-objs := imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.o
 
diff --git a/drivers/staging/media/imx/imx-media-dev-common.c 
b/drivers/staging/media/imx/imx-media-dev-common.c
new file mode 100644
index ..28bcb31cf6ca
--- /dev/null
+++ b/drivers/staging/media/imx/imx-media-dev-common.c
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: GPL
+/*
+ * V4L2 Media Controller Driver for Freescale common i.MX5/6/7 SOC
+ *
+ * Copyright (c) 2019 Linaro Ltd
+ * Copyright (c) 2016 Mentor Graphics Inc.
+ */
+
+#include 
+#include 
+#include "imx-media.h"
+
+static const struct v4l2_async_notifier_operations imx_media_subdev_ops = {
+   .bound = imx_media_subdev_bound,
+   .complete = imx_media_probe_complete,
+};
+
+static const struct media_device_ops imx_media_md_ops = {
+   .link_notify = imx_media_link_notify,
+};
+
+struct imx_media_dev *imx_media_dev_init(struct device *dev)
+{
+   struct imx_media_dev *imxmd;
+   int ret;
+
+   imxmd = devm_kzalloc(dev, sizeof(*imxmd), GFP_KERNEL);
+   if (!imxmd)
+   return ERR_PTR(-ENOMEM);
+
+   dev_set_drvdata(dev, imxmd);
+
+   strlcpy(imxmd->md.model, "imx-media", sizeof(imxmd->md.model));
+   imxmd->md.ops = _media_md_ops;
+   imxmd->md.dev = dev;
+
+   mutex_init(>mutex);
+
+   imxmd->v4l2_dev.mdev = >md;
+   imxmd->v4l2_dev.notify = imx_media_notify;
+   strlcpy(imxmd->v4l2_dev.name, "imx-media",
+   sizeof(imxmd->v4l2_dev.name));
+
+   media_device_init(>md);
+
+   ret = v4l2_device_register(dev, >v4l2_dev);
+   if (ret < 0) {
+   v4l2_err(>v4l2_dev,
+"Failed to register v4l2_device: %d\n", ret);
+   goto cleanup;
+   }
+
+   dev_set_drvdata(imxmd->v4l2_dev.dev, imxmd);
+
+   INIT_LIST_HEAD(>vdev_list);
+
+   v4l2_async_notifier_init(>notifier);
+
+   return imxmd;
+
+cleanup:
+   media_device_cleanup(>md);
+
+   return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(imx_media_dev_init);
+
+int imx_media_dev_notifier_register(struct imx_media_dev *imxmd)
+{
+   int ret;
+
+   /* no subdevs? just bail */
+   if (list_empty(>notifier.asd_list)) {
+   v4l2_err(>v4l2_dev, "no subdevs\n");
+   return -ENODEV;
+   }
+
+   /* prepare the async subdev notifier and register it */
+   imxmd->notifier.ops = _media_subdev_ops;
+   ret = v4l2_async_notifier_register(>v4l2_dev,
+  >notifier);
+   if (ret) {
+   v4l2_err(>v4l2_dev,
+"v4l2_async_notifier_register failed with %d\n", ret);
+   return ret;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(imx_media_dev_notifier_register);
diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index 25e916562c66..c42bddd78906 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -116,9 +116,9 @@ static int imx_media_get_ipu(struct imx_media_dev *imxmd,
 }
 
 /* async subdev bound notifier */
-static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
- struct v4l2_subdev *sd,
- struct v4l2_async_subdev *asd)
+int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
+  struct v4l2_subdev *sd,
+  struct v4l2_async_subdev *asd)
 {
struct imx_media_dev *imxmd = notifier2dev(notifier);
int ret = 0;
@@ -302,7 +302,7 @@ static int imx_media_create_pad_vdev_lists(struct 
imx_media_dev *imxmd)
 }
 
 /* async subdev complete notifier */
-static int imx_media_probe_

Re: [PATCH v13 10/13] media: imx7.rst: add documentation for i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva

Hi Hans,
On Wed 06 Feb 2019 at 10:54, Hans Verkuil wrote:

On 2/6/19 11:25 AM, Rui Miguel Silva wrote:
Add rst document to describe the i.MX7 media driver and also a 
working

example from the Warp7 board usage with a OV2680 sensor.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 


Checkpatch gives me:

Applying: media: imx7.rst: add documentation for i.MX7 media 
driver
WARNING: added, moved or deleted file(s), does MAINTAINERS need 
updating?

#2:
new file mode 100644

WARNING: Missing or malformed SPDX-License-Identifier tag in 
line 1

#7: FILE: Documentation/media/v4l-drivers/imx7.rst:1:
+i.MX7 Video Capture Driver

total: 0 errors, 2 warnings, 164 lines checked


Yeah, I missed checkpatch in the rst file.



Both warnings are valid, so can you make a v13.1 for this patch 
only?

Just include the MAINTAINERS change in this patch.


I will send a complete v14 since I screw up the first patch also.
Thanks any way.

---
Cheers,
Rui



Regards,

Hans


---
 Documentation/media/v4l-drivers/imx7.rst  | 157 
 ++

 Documentation/media/v4l-drivers/index.rst |   1 +
 2 files changed, 158 insertions(+)
 create mode 100644 Documentation/media/v4l-drivers/imx7.rst

diff --git a/Documentation/media/v4l-drivers/imx7.rst 
b/Documentation/media/v4l-drivers/imx7.rst

new file mode 100644
index ..cd1195d391c5
--- /dev/null
+++ b/Documentation/media/v4l-drivers/imx7.rst
@@ -0,0 +1,157 @@
+i.MX7 Video Capture Driver
+==
+
+Introduction
+
+
+The i.MX7 contrary to the i.MX5/6 family does not contain an 
Image Processing
+Unit (IPU); because of that the capabilities to perform 
operations or

+manipulation of the capture frames are less feature rich.
+
+For image capture the i.MX7 has three units:
+- CMOS Sensor Interface (CSI)
+- Video Multiplexer
+- MIPI CSI-2 Receiver
+
+::
+   |\
+   MIPI Camera Input ---> MIPI CSI-2 --- > | \
+   |  \
+   | M |
+   | U | -->  CSI 
---> Capture

+   | X |
+   |  /
+   Parallel Camera Input > | /
+   |/
+
+For additional information, please refer to the latest 
versions of the i.MX7

+reference manual [#f1]_.
+
+Entities
+
+
+imx7-mipi-csi2
+--
+
+This is the MIPI CSI-2 receiver entity. It has one sink pad to 
receive the pixel
+data from MIPI CSI-2 camera sensor. It has one source pad, 
corresponding to the
+virtual channel 0. This module is compliant to previous 
version of Samsung

+D-phy, and supports two D-PHY Rx Data lanes.
+
+csi_mux
+---
+
+This is the video multiplexer. It has two sink pads to select 
from either camera
+sensor with a parallel interface or from MIPI CSI-2 virtual 
channel 0.  It has

+a single source pad that routes to the CSI.
+
+csi
+---
+
+The CSI enables the chip to connect directly to external CMOS 
image sensor. CSI
+can interface directly with Parallel and MIPI CSI-2 buses. It 
has 256 x 64 FIFO
+to store received image pixel data and embedded DMA 
controllers to transfer data

+from the FIFO through AHB bus.
+
+This entity has one sink pad that receives from the csi_mux 
entity and a single
+source pad that routes video frames directly to memory 
buffers. This pad is

+routed to a capture device node.
+
+Usage Notes
+---
+
+To aid in configuration and for backward compatibility with 
V4L2 applications
+that access controls only from video device nodes, the capture 
device interfaces
+inherit controls from the active entities in the current 
pipeline, so controls
+can be accessed either directly from the subdev or from the 
active capture
+device interface. For example, the sensor controls are 
available either from the

+sensor subdevs or from the active capture device.
+
+Warp7 with OV2680
+-
+
+On this platform an OV2680 MIPI CSI-2 module is connected to 
the internal MIPI
+CSI-2 receiver. The following example configures a video 
capture pipeline with

+an output of 800x600, and BGGR 10 bit bayer format:
+
+.. code-block:: none
+   # Setup links
+   media-ctl -l "'ov2680 1-0036':0 -> 'imx7-mipi-csis.0':0[1]"
+   media-ctl -l "'imx7-mipi-csis.0':1 -> 'csi_mux':1[1]"
+   media-ctl -l "'csi_mux':2 -> 'csi':0[1]"
+   media-ctl -l "'csi':1 -> 'csi capture':0[1]"
+
+   # Configure pads for pipeline
+   media-ctl -V "'ov2680 1-0036':0 [fmt:SBGGR10_1X10/800x600 
field:none]"
+   media-ctl -V "'csi_mux':1 [fmt:SBGGR10_1X10/800x600 
field:none]"
+   media-ctl -V "'csi_mux':2 [fmt:SBGGR10_1X10/800x600 
field:none]"
+   media-ctl -V "'imx7-mipi-csis.0':0 
[fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'

[PATCH v13 06/13] ARM: dts: imx7s: add mipi phy power domain

2019-02-06 Thread Rui Miguel Silva
Add power domain index 0 related with mipi-phy to imx7s.

While at it rename pcie power-domain node to remove pgc prefix.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s.dtsi | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index e88f53a4c7f4..9a680d3d6424 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -606,7 +606,13 @@
#address-cells = <1>;
#size-cells = <0>;
 
-   pgc_pcie_phy: pgc-power-domain@1 {
+   pgc_mipi_phy: power-domain@0 {
+   #power-domain-cells = <0>;
+   reg = <0>;
+   power-supply = <_1p0d>;
+   };
+
+   pgc_pcie_phy: power-domain@1 {
#power-domain-cells = <0>;
reg = <1>;
power-supply = <_1p0d>;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v13 07/13] ARM: dts: imx7s: add multiplexer controls

2019-02-06 Thread Rui Miguel Silva
The IOMUXC General Purpose Register has bitfield to control video bus
multiplexer to control the CSI input between the MIPI-CSI2 and parallel
interface. Add that register and mask.

Signed-off-by: Rui Miguel Silva 
Reviewed-by: Philipp Zabel 
---
 arch/arm/boot/dts/imx7s.dtsi | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 9a680d3d6424..792efcd2caa1 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -497,8 +497,15 @@
 
gpr: iomuxc-gpr@3034 {
compatible = "fsl,imx7d-iomuxc-gpr",
-   "fsl,imx6q-iomuxc-gpr", "syscon";
+   "fsl,imx6q-iomuxc-gpr", "syscon",
+   "simple-mfd";
reg = <0x3034 0x1>;
+
+   mux: mux-controller {
+   compatible = "mmio-mux";
+   #mux-control-cells = <0>;
+   mux-reg-masks = <0x14 0x0010>;
+   };
};
 
ocotp: ocotp-ctrl@3035 {
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v13 08/13] ARM: dts: imx7: Add video mux, csi and mipi_csi and connections

2019-02-06 Thread Rui Miguel Silva
This patch adds the device tree nodes for csi, video multiplexer and
mipi-csi besides the graph connecting the necessary endpoints to make
the media capture entities to work in imx7 Warp board.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s-warp.dts | 51 
 arch/arm/boot/dts/imx7s.dtsi | 27 +
 2 files changed, 78 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s-warp.dts b/arch/arm/boot/dts/imx7s-warp.dts
index 23431faecaf4..358bcae7ebaf 100644
--- a/arch/arm/boot/dts/imx7s-warp.dts
+++ b/arch/arm/boot/dts/imx7s-warp.dts
@@ -277,6 +277,57 @@
status = "okay";
 };
 
+ {
+   csi_mux {
+   compatible = "video-mux";
+   mux-controls = < 0>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@1 {
+   reg = <1>;
+
+   csi_mux_from_mipi_vc0: endpoint {
+   remote-endpoint = <_vc0_to_csi_mux>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   csi_mux_to_csi: endpoint {
+   remote-endpoint = <_from_csi_mux>;
+   };
+   };
+   };
+};
+
+ {
+   status = "okay";
+
+   port {
+   csi_from_csi_mux: endpoint {
+   remote-endpoint = <_mux_to_csi>;
+   };
+   };
+};
+
+_csi {
+   clock-frequency = <16600>;
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   fsl,csis-hs-settle = <3>;
+
+   port@1 {
+   reg = <1>;
+
+   mipi_vc0_to_csi_mux: endpoint {
+   remote-endpoint = <_mux_from_mipi_vc0>;
+   };
+   };
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_wdog>;
diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 792efcd2caa1..01962f85cab6 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "imx7d-pinfunc.h"
 
 / {
@@ -709,6 +710,17 @@
status = "disabled";
};
 
+   csi: csi@3071 {
+   compatible = "fsl,imx7-csi";
+   reg = <0x3071 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_CLK_DUMMY>,
+   < IMX7D_CSI_MCLK_ROOT_CLK>,
+   < IMX7D_CLK_DUMMY>;
+   clock-names = "axi", "mclk", "dcic";
+   status = "disabled";
+   };
+
lcdif: lcdif@3073 {
compatible = "fsl,imx7d-lcdif", 
"fsl,imx28-lcdif";
reg = <0x3073 0x1>;
@@ -718,6 +730,21 @@
clock-names = "pix", "axi";
status = "disabled";
};
+
+   mipi_csi: mipi-csi@3075 {
+   compatible = "fsl,imx7-mipi-csi2";
+   reg = <0x3075 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_IPG_ROOT_CLK>,
+   < IMX7D_MIPI_CSI_ROOT_CLK>,
+   < IMX7D_MIPI_DPHY_ROOT_CLK>;
+   clock-names = "pclk", "wrap", "phy";
+   power-domains = <_mipi_phy>;
+   phy-supply = <_1p0d>;
+   resets = < IMX7_RESET_MIPI_PHY_MRST>;
+   reset-names = "mrst";
+   status = "disabled";
+   };
};
 
aips3: aips-bus@3080 {
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v13 12/13] media: video-mux: add bayer formats

2019-02-06 Thread Rui Miguel Silva
Add non vendor bayer formats to the  allowed format array.

Signed-off-by: Rui Miguel Silva 
Reviewed-by: Philipp Zabel 
Acked-by: Sakari Ailus 
---
 drivers/media/platform/video-mux.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/media/platform/video-mux.c 
b/drivers/media/platform/video-mux.c
index c33900e3c23e..0ba30756e1e4 100644
--- a/drivers/media/platform/video-mux.c
+++ b/drivers/media/platform/video-mux.c
@@ -263,6 +263,26 @@ static int video_mux_set_format(struct v4l2_subdev *sd,
case MEDIA_BUS_FMT_UYYVYY16_0_5X48:
case MEDIA_BUS_FMT_JPEG_1X8:
case MEDIA_BUS_FMT_AHSV_1X32:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case MEDIA_BUS_FMT_SGBRG10_1X10:
+   case MEDIA_BUS_FMT_SGRBG10_1X10:
+   case MEDIA_BUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR12_1X12:
+   case MEDIA_BUS_FMT_SGBRG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SRGGB12_1X12:
+   case MEDIA_BUS_FMT_SBGGR14_1X14:
+   case MEDIA_BUS_FMT_SGBRG14_1X14:
+   case MEDIA_BUS_FMT_SGRBG14_1X14:
+   case MEDIA_BUS_FMT_SRGGB14_1X14:
+   case MEDIA_BUS_FMT_SBGGR16_1X16:
+   case MEDIA_BUS_FMT_SGBRG16_1X16:
+   case MEDIA_BUS_FMT_SGRBG16_1X16:
+   case MEDIA_BUS_FMT_SRGGB16_1X16:
break;
default:
sdformat->format.code = MEDIA_BUS_FMT_Y8_1X8;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v13 09/13] ARM: dts: imx7s-warp: add ov2680 sensor node

2019-02-06 Thread Rui Miguel Silva
Warp7 comes with a Omnivision OV2680 sensor, add the node here to make
complete the camera data path for this system. Add the needed regulator
to the analog voltage supply, the port and endpoints in mipi_csi node
and the pinctrl for the reset gpio.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s-warp.dts | 44 
 1 file changed, 44 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s-warp.dts b/arch/arm/boot/dts/imx7s-warp.dts
index 358bcae7ebaf..58d1a89ee3e3 100644
--- a/arch/arm/boot/dts/imx7s-warp.dts
+++ b/arch/arm/boot/dts/imx7s-warp.dts
@@ -55,6 +55,14 @@
regulator-always-on;
};
 
+   reg_peri_3p15v: regulator-peri-3p15v {
+   compatible = "regulator-fixed";
+   regulator-name = "peri_3p15v_reg";
+   regulator-min-microvolt = <315>;
+   regulator-max-microvolt = <315>;
+   regulator-always-on;
+   };
+
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "imx7-sgtl5000";
@@ -178,6 +186,27 @@
pinctrl-names = "default";
pinctrl-0 = <_i2c2>;
status = "okay";
+
+   ov2680: camera@36 {
+   compatible = "ovti,ov2680";
+   pinctrl-names = "default";
+   pinctrl-0 = <_ov2680>;
+   reg = <0x36>;
+   clocks = <>;
+   clock-names = "xvclk";
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+   DOVDD-supply = <_reg>;
+   DVDD-supply = <_reg>;
+   AVDD-supply = <_peri_3p15v>;
+
+   port {
+   ov2680_to_mipi: endpoint {
+   remote-endpoint = <_from_sensor>;
+   clock-lanes = <0>;
+   data-lanes = <1>;
+   };
+   };
+   };
 };
 
  {
@@ -319,6 +348,15 @@
#size-cells = <0>;
fsl,csis-hs-settle = <3>;
 
+   port@0 {
+   reg = <0>;
+
+   mipi_from_sensor: endpoint {
+   remote-endpoint = <_to_mipi>;
+   data-lanes = <1>;
+   };
+   };
+
port@1 {
reg = <1>;
 
@@ -382,6 +420,12 @@
>;
};
 
+   pinctrl_ov2680: ov2660grp {
+   fsl,pins = <
+   MX7D_PAD_LPSR_GPIO1_IO03__GPIO1_IO3 0x14
+   >;
+   };
+
pinctrl_sai1: sai1grp {
fsl,pins = <
MX7D_PAD_SAI1_RX_DATA__SAI1_RX_DATA00x1f
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v13 11/13] media: staging/imx: add i.MX7 entries to TODO file

2019-02-06 Thread Rui Miguel Silva
Add some i.MX7 related entries to TODO file.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 drivers/staging/media/imx/TODO | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO
index aeeb15494a49..6f29b5ca5324 100644
--- a/drivers/staging/media/imx/TODO
+++ b/drivers/staging/media/imx/TODO
@@ -45,3 +45,12 @@
 
  Which means a port must not contain mixed-use endpoints, they
  must all refer to media links between V4L2 subdevices.
+
+- i.MX7: all of the above, since it uses the imx media core
+
+- i.MX7: use Frame Interval Monitor
+
+- i.MX7: runtime testing with parallel sensor, links setup and streaming
+
+- i.MX7: runtime testing with different formats, for the time only 10-bit bayer
+  is tested
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v13 05/13] media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7

2019-02-06 Thread Rui Miguel Silva
Adds MIPI CSI-2 subdev for i.MX7 to connect with sensors with a MIPI
CSI-2 interface.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/Makefile |1 +
 drivers/staging/media/imx/imx7-mipi-csis.c | 1186 
 2 files changed, 1187 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx7-mipi-csis.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 074f016d3519..d2d909a36239 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
 
 obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-mipi-csis.o
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
new file mode 100644
index ..516d308dc44b
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -0,0 +1,1186 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Freescale i.MX7 SoC series MIPI-CSI V3.3 receiver driver
+ *
+ * Copyright (C) 2019 Linaro Ltd
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "imx-media.h"
+
+#define CSIS_DRIVER_NAME   "imx7-mipi-csis"
+#define CSIS_SUBDEV_NAME   CSIS_DRIVER_NAME
+
+#define CSIS_PAD_SINK  0
+#define CSIS_PAD_SOURCE1
+#define CSIS_PADS_NUM  2
+
+#define MIPI_CSIS_DEF_PIX_WIDTH640
+#define MIPI_CSIS_DEF_PIX_HEIGHT   480
+
+/* Register map definition */
+
+/* CSIS common control */
+#define MIPI_CSIS_CMN_CTRL 0x04
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW   BIT(16)
+#define MIPI_CSIS_CMN_CTRL_INTER_MODE  BIT(10)
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW_CTRL  BIT(2)
+#define MIPI_CSIS_CMN_CTRL_RESET   BIT(1)
+#define MIPI_CSIS_CMN_CTRL_ENABLE  BIT(0)
+
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_OFFSET  8
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_MASK(3 << 8)
+
+/* CSIS clock control */
+#define MIPI_CSIS_CLK_CTRL 0x08
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH3(x)((x) << 28)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH2(x)((x) << 24)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH1(x)((x) << 20)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH0(x)((x) << 16)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_EN_MSK  (0xf << 4)
+#define MIPI_CSIS_CLK_CTRL_WCLK_SRCBIT(0)
+
+/* CSIS Interrupt mask */
+#define MIPI_CSIS_INTMSK   0x10
+#define MIPI_CSIS_INTMSK_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTMSK_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTMSK_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTMSK_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTMSK_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTMSK_FRAME_END BIT(20)
+#define MIPI_CSIS_INTMSK_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FE   BIT(8)
+#define MIPI_CSIS_INTMSK_ERR_OVER  BIT(4)
+#define MIPI_CSIS_INTMSK_ERR_WRONG_CFG BIT(3)
+#define MIPI_CSIS_INTMSK_ERR_ECC   BIT(2)
+#define MIPI_CSIS_INTMSK_ERR_CRC   BIT(1)
+#define MIPI_CSIS_INTMSK_ERR_UNKNOWN   BIT(0)
+
+/* CSIS Interrupt source */
+#define MIPI_CSIS_INTSRC   0x14
+#define MIPI_CSIS_INTSRC_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTSRC_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTSRC_EVEN  BIT(30)
+#define MIPI_CSIS_INTSRC_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTSRC_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTSRC_ODD   (0x3 << 28)
+#define MIPI_CSIS_INTSRC_NON_IMAGE_DATA(0xf << 28)
+#define MIPI_CSIS_INTSRC_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTSRC_FRAME_END BIT(20)
+#define MIPI_CSIS_INTSRC_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTSRC_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTSRC_ERR_LOST_FE   BIT(8)
+#define MIPI_CSIS_INTSRC_ERR_OVER  BIT(4)
+#define MIPI_CSIS_INTSRC_ERR_WRONG_CFG BIT(3)
+#define MIPI_CSIS_INTSRC_ERR_ECC   BIT(2)
+#define MIPI_CSIS_INTSRC_ERR_CRC   BIT(1)
+#define MIPI_CSIS_INTSRC_ERR_UNKNOWN   BIT(0)
+#define MIPI_CSIS_INTSRC_ERRORS0xf
+
+/* D-PHY status control */
+#define MIPI_CSIS_DPHYSTATUS   0x20
+#define MIPI_CSIS_DPHYSTATUS_ULPS_DAT  BIT(8)
+#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_DAT BIT(4)
+#define MIPI_CSIS_DPHYSTATUS_ULPS_CLK  BIT(1)
+#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_CLK BIT(0)
+
+/* D-PHY common control */
+#define MIPI_CSIS_DPHYCTRL 0x24
+#define MIPI_CSIS_DPHYCTRL_HSS

[PATCH v13 13/13] media: MAINTAINERS: add entry for Freescale i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva
Add maintainer entry for the imx7 media csi, mipi csis driver,
dt-bindings and documentation.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 MAINTAINERS | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3e211916d2bc..d8e0c9040736 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9348,6 +9348,17 @@ T:   git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/platform/imx-pxp.[ch]
 
+MEDIA DRIVERS FOR FREESCALE IMX7
+M: Rui Miguel Silva 
+L: linux-me...@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: Documentation/devicetree/bindings/media/imx7-csi.txt
+F: Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt
+F: Documentation/media/v4l-drivers/imx7.rst
+F: drivers/staging/media/imx/imx7-media-csi.c
+F: drivers/staging/media/imx/imx7-mipi-csis.c
+
 MEDIA DRIVERS FOR HELENE
 M: Abylay Ospan 
 L: linux-me...@vger.kernel.org
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v13 10/13] media: imx7.rst: add documentation for i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva
Add rst document to describe the i.MX7 media driver and also a working
example from the Warp7 board usage with a OV2680 sensor.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 Documentation/media/v4l-drivers/imx7.rst  | 157 ++
 Documentation/media/v4l-drivers/index.rst |   1 +
 2 files changed, 158 insertions(+)
 create mode 100644 Documentation/media/v4l-drivers/imx7.rst

diff --git a/Documentation/media/v4l-drivers/imx7.rst 
b/Documentation/media/v4l-drivers/imx7.rst
new file mode 100644
index ..cd1195d391c5
--- /dev/null
+++ b/Documentation/media/v4l-drivers/imx7.rst
@@ -0,0 +1,157 @@
+i.MX7 Video Capture Driver
+==
+
+Introduction
+
+
+The i.MX7 contrary to the i.MX5/6 family does not contain an Image Processing
+Unit (IPU); because of that the capabilities to perform operations or
+manipulation of the capture frames are less feature rich.
+
+For image capture the i.MX7 has three units:
+- CMOS Sensor Interface (CSI)
+- Video Multiplexer
+- MIPI CSI-2 Receiver
+
+::
+   |\
+   MIPI Camera Input ---> MIPI CSI-2 --- > | \
+   |  \
+   | M |
+   | U | -->  CSI ---> Capture
+   | X |
+   |  /
+   Parallel Camera Input > | /
+   |/
+
+For additional information, please refer to the latest versions of the i.MX7
+reference manual [#f1]_.
+
+Entities
+
+
+imx7-mipi-csi2
+--
+
+This is the MIPI CSI-2 receiver entity. It has one sink pad to receive the 
pixel
+data from MIPI CSI-2 camera sensor. It has one source pad, corresponding to the
+virtual channel 0. This module is compliant to previous version of Samsung
+D-phy, and supports two D-PHY Rx Data lanes.
+
+csi_mux
+---
+
+This is the video multiplexer. It has two sink pads to select from either 
camera
+sensor with a parallel interface or from MIPI CSI-2 virtual channel 0.  It has
+a single source pad that routes to the CSI.
+
+csi
+---
+
+The CSI enables the chip to connect directly to external CMOS image sensor. CSI
+can interface directly with Parallel and MIPI CSI-2 buses. It has 256 x 64 FIFO
+to store received image pixel data and embedded DMA controllers to transfer 
data
+from the FIFO through AHB bus.
+
+This entity has one sink pad that receives from the csi_mux entity and a single
+source pad that routes video frames directly to memory buffers. This pad is
+routed to a capture device node.
+
+Usage Notes
+---
+
+To aid in configuration and for backward compatibility with V4L2 applications
+that access controls only from video device nodes, the capture device 
interfaces
+inherit controls from the active entities in the current pipeline, so controls
+can be accessed either directly from the subdev or from the active capture
+device interface. For example, the sensor controls are available either from 
the
+sensor subdevs or from the active capture device.
+
+Warp7 with OV2680
+-
+
+On this platform an OV2680 MIPI CSI-2 module is connected to the internal MIPI
+CSI-2 receiver. The following example configures a video capture pipeline with
+an output of 800x600, and BGGR 10 bit bayer format:
+
+.. code-block:: none
+   # Setup links
+   media-ctl -l "'ov2680 1-0036':0 -> 'imx7-mipi-csis.0':0[1]"
+   media-ctl -l "'imx7-mipi-csis.0':1 -> 'csi_mux':1[1]"
+   media-ctl -l "'csi_mux':2 -> 'csi':0[1]"
+   media-ctl -l "'csi':1 -> 'csi capture':0[1]"
+
+   # Configure pads for pipeline
+   media-ctl -V "'ov2680 1-0036':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi_mux':1 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi_mux':2 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'imx7-mipi-csis.0':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+
+After this streaming can start. The v4l2-ctl tool can be used to select any of
+the resolutions supported by the sensor.
+
+.. code-block:: none
+root@imx7s-warp:~# media-ctl -p
+Media controller API version 4.17.0
+
+Media device information
+
+driver  imx-media
+model   imx-media
+serial
+bus info
+hw revision 0x0
+driver version  4.17.0
+
+Device topology
+- entity 1: csi (2 pads, 2 links)
+   type V4L2 subdev subtype Unknown flags 0
+   device node name /dev/v4l-subdev0
+   pad0: Sink
+   [fmt:SBGGR10_1X10/800x600 field:none]
+   <- "csi_mux":2 [ENABLED]
+   pad1: Source
+   [f

[PATCH v13 01/13] media: staging/imx: refactor imx media device probe

2019-02-06 Thread Rui Miguel Silva
Refactor and move media device initialization code to a new common
module, so it can be used by other devices, this will allow for example
a near to introduce imx7 CSI driver, to use this media device.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/Makefile|  1 +
 drivers/staging/media/imx/imx-media-dev.c | 86 +--
 drivers/staging/media/imx/imx-media-of.c  |  6 +-
 drivers/staging/media/imx/imx-media.h | 14 
 4 files changed, 37 insertions(+), 70 deletions(-)

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 698a4210316e..a30b3033f9a3 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 imx-media-objs := imx-media-dev.o imx-media-internal-sd.o imx-media-of.o
+imx-media-objs += imx-media-dev-common.o
 imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 imx-media-ic-objs := imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.o
 
diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index 25e916562c66..c42bddd78906 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -116,9 +116,9 @@ static int imx_media_get_ipu(struct imx_media_dev *imxmd,
 }
 
 /* async subdev bound notifier */
-static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
- struct v4l2_subdev *sd,
- struct v4l2_async_subdev *asd)
+int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
+  struct v4l2_subdev *sd,
+  struct v4l2_async_subdev *asd)
 {
struct imx_media_dev *imxmd = notifier2dev(notifier);
int ret = 0;
@@ -302,7 +302,7 @@ static int imx_media_create_pad_vdev_lists(struct 
imx_media_dev *imxmd)
 }
 
 /* async subdev complete notifier */
-static int imx_media_probe_complete(struct v4l2_async_notifier *notifier)
+int imx_media_probe_complete(struct v4l2_async_notifier *notifier)
 {
struct imx_media_dev *imxmd = notifier2dev(notifier);
int ret;
@@ -326,11 +326,6 @@ static int imx_media_probe_complete(struct 
v4l2_async_notifier *notifier)
return media_device_register(>md);
 }
 
-static const struct v4l2_async_notifier_operations imx_media_subdev_ops = {
-   .bound = imx_media_subdev_bound,
-   .complete = imx_media_probe_complete,
-};
-
 /*
  * adds controls to a video device from an entity subdevice.
  * Continues upstream from the entity's sink pads.
@@ -374,8 +369,8 @@ static int imx_media_inherit_controls(struct imx_media_dev 
*imxmd,
return ret;
 }
 
-static int imx_media_link_notify(struct media_link *link, u32 flags,
-unsigned int notification)
+int imx_media_link_notify(struct media_link *link, u32 flags,
+ unsigned int notification)
 {
struct media_entity *source = link->source->entity;
struct imx_media_pad_vdev *pad_vdev;
@@ -438,13 +433,8 @@ static int imx_media_link_notify(struct media_link *link, 
u32 flags,
return ret;
 }
 
-static const struct media_device_ops imx_media_md_ops = {
-   .link_notify = imx_media_link_notify,
-};
-
-static void imx_media_notify(struct v4l2_subdev *sd,
-unsigned int notification,
-void *arg)
+void imx_media_notify(struct v4l2_subdev *sd, unsigned int notification,
+ void *arg)
 {
struct media_entity *entity = >entity;
int i;
@@ -472,77 +462,37 @@ static int imx_media_probe(struct platform_device *pdev)
struct imx_media_dev *imxmd;
int ret;
 
-   imxmd = devm_kzalloc(dev, sizeof(*imxmd), GFP_KERNEL);
-   if (!imxmd)
-   return -ENOMEM;
-
-   dev_set_drvdata(dev, imxmd);
-
-   strscpy(imxmd->md.model, "imx-media", sizeof(imxmd->md.model));
-   imxmd->md.ops = _media_md_ops;
-   imxmd->md.dev = dev;
-
-   mutex_init(>mutex);
-
-   imxmd->v4l2_dev.mdev = >md;
-   imxmd->v4l2_dev.notify = imx_media_notify;
-   strscpy(imxmd->v4l2_dev.name, "imx-media",
-   sizeof(imxmd->v4l2_dev.name));
-
-   media_device_init(>md);
-
-   ret = v4l2_device_register(dev, >v4l2_dev);
-   if (ret < 0) {
-   v4l2_err(>v4l2_dev,
-"Failed to register v4l2_device: %d\n", ret);
-   goto cleanup;
-   }
-
-   dev_set_drvdata(imxmd->v4l2_dev.dev, imxmd);
-
-   INIT_LIST_HEAD(>vdev_list);
-
-   v4l2_async_notifier_init(>notifier);
+   imxmd = imx_media_dev_init(dev);
+   if (IS_ERR(imxmd))
+   return PTR_ERR(imxmd);
 
ret = imx_media_add_of_subdevs(imxmd, node);
if (ret) {
v4l2_err(>

[PATCH v13 04/13] media: staging/imx7: add imx7 CSI subdev driver

2019-02-06 Thread Rui Miguel Silva
This add the media entity subdevice and control driver for the i.MX7
CMOS Sensor Interface.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 drivers/staging/media/imx/Kconfig  |9 +-
 drivers/staging/media/imx/Makefile |2 +
 drivers/staging/media/imx/imx7-media-csi.c | 1365 
 3 files changed, 1375 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/media/imx/imx7-media-csi.c

diff --git a/drivers/staging/media/imx/Kconfig 
b/drivers/staging/media/imx/Kconfig
index bfc17de56b17..36b276ea2ecc 100644
--- a/drivers/staging/media/imx/Kconfig
+++ b/drivers/staging/media/imx/Kconfig
@@ -11,7 +11,7 @@ config VIDEO_IMX_MEDIA
  driver for the i.MX5/6 SOC.
 
 if VIDEO_IMX_MEDIA
-menu "i.MX5/6 Media Sub devices"
+menu "i.MX5/6/7 Media Sub devices"
 
 config VIDEO_IMX_CSI
tristate "i.MX5/6 Camera Sensor Interface driver"
@@ -20,5 +20,12 @@ config VIDEO_IMX_CSI
---help---
  A video4linux camera sensor interface driver for i.MX5/6.
 
+config VIDEO_IMX7_CSI
+   tristate "i.MX7 Camera Sensor Interface driver"
+   depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
+   default y
+   help
+ Enable support for video4linux camera sensor interface driver for
+ i.MX7.
 endmenu
 endif
diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index a30b3033f9a3..074f016d3519 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -12,3 +12,5 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o
 
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
+
+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
new file mode 100644
index ..d5154f032979
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -0,0 +1,1365 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC
+ *
+ * Copyright (c) 2019 Linaro Ltd
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "imx-media.h"
+
+#define IMX7_CSI_PAD_SINK  0
+#define IMX7_CSI_PAD_SRC   1
+#define IMX7_CSI_PADS_NUM  2
+
+/* reset values */
+#define CSICR1_RESET_VAL   0x4800
+#define CSICR2_RESET_VAL   0x0
+#define CSICR3_RESET_VAL   0x0
+
+/* csi control reg 1 */
+#define BIT_SWAP16_EN  BIT(31)
+#define BIT_EXT_VSYNC  BIT(30)
+#define BIT_EOF_INT_EN BIT(29)
+#define BIT_PRP_IF_EN  BIT(28)
+#define BIT_CCIR_MODE  BIT(27)
+#define BIT_COF_INT_EN BIT(26)
+#define BIT_SF_OR_INTENBIT(25)
+#define BIT_RF_OR_INTENBIT(24)
+#define BIT_SFF_DMA_DONE_INTEN  BIT(22)
+#define BIT_STATFF_INTEN   BIT(21)
+#define BIT_FB2_DMA_DONE_INTEN  BIT(20)
+#define BIT_FB1_DMA_DONE_INTEN  BIT(19)
+#define BIT_RXFF_INTEN BIT(18)
+#define BIT_SOF_POLBIT(17)
+#define BIT_SOF_INTEN  BIT(16)
+#define BIT_MCLKDIV(0xF << 12)
+#define BIT_HSYNC_POL  BIT(11)
+#define BIT_CCIR_ENBIT(10)
+#define BIT_MCLKEN BIT(9)
+#define BIT_FCCBIT(8)
+#define BIT_PACK_DIR   BIT(7)
+#define BIT_CLR_STATFIFO   BIT(6)
+#define BIT_CLR_RXFIFO BIT(5)
+#define BIT_GCLK_MODE  BIT(4)
+#define BIT_INV_DATA   BIT(3)
+#define BIT_INV_PCLK   BIT(2)
+#define BIT_REDGE  BIT(1)
+#define BIT_PIXEL_BIT  BIT(0)
+
+#define SHIFT_MCLKDIV  12
+
+/* control reg 3 */
+#define BIT_FRMCNT (0x << 16)
+#define BIT_FRMCNT_RST BIT(15)
+#define BIT_DMA_REFLASH_RFFBIT(14)
+#define BIT_DMA_REFLASH_SFFBIT(13)
+#define BIT_DMA_REQ_EN_RFF BIT(12)
+#define BIT_DMA_REQ_EN_SFF BIT(11)
+#define BIT_STATFF_LEVEL   (0x7 << 8)
+#define BIT_HRESP_ERR_EN   BIT(7)
+#define BIT_RXFF_LEVEL (0x7 << 4)
+#define BIT_TWO_8BIT_SENSORBIT(3)
+#define BIT_ZERO_PACK_EN   BIT(2)
+#define BIT_ECC_INT_EN BIT(1)
+#define BIT_ECC_AUTO_ENBIT(0)
+
+#define SHIFT_FRMCNT   16
+#define SHIFT_RXFIFO_LEVEL 4
+
+/* csi status reg */
+#define BIT_ADDR_CH_ERR_INTBIT(28)
+#define BIT_FIELD0_INT BIT(27)
+#define BIT_FIELD1_INT BIT(26)
+#define BIT_SFF_OR_INT BIT(25)
+#define BIT_RFF_OR_INT BIT(24)
+#define BIT_DMA_TSF_DONE_SFF   BIT(22)
+#define BIT_STATFF_INT BIT(21)
+#define BIT_DMA_TSF_DONE_FB2   BIT(20)
+#define BIT_DMA_TSF_DONE_FB1   BIT(19)
+#define BIT_RXFF_INT   BIT(18)
+#define BIT_EOF_INTBIT(17)
+#define 

[PATCH v13 02/13] media: staging/imx: rearrange group id to take in account IPU

2019-02-06 Thread Rui Miguel Silva
Some imx system do not have IPU, so prepare the imx media drivers to
support this kind of devices. Rename the group ids to include an _IPU_
prefix, add a new group id to support systems with only a CSI without
IPU, and also rename the create internal links to make it clear that
only systems with IPU have internal subdevices.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 drivers/staging/media/imx/imx-ic-common.c |  6 ++---
 drivers/staging/media/imx/imx-ic-prp.c| 16 ++---
 drivers/staging/media/imx/imx-media-csi.c |  6 ++---
 drivers/staging/media/imx/imx-media-dev.c | 22 ++
 .../staging/media/imx/imx-media-internal-sd.c | 20 
 drivers/staging/media/imx/imx-media-utils.c   | 12 +-
 drivers/staging/media/imx/imx-media.h | 23 ++-
 7 files changed, 55 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-common.c 
b/drivers/staging/media/imx/imx-ic-common.c
index cfdd4900a3be..765919487a73 100644
--- a/drivers/staging/media/imx/imx-ic-common.c
+++ b/drivers/staging/media/imx/imx-ic-common.c
@@ -41,13 +41,13 @@ static int imx_ic_probe(struct platform_device *pdev)
pdata = priv->dev->platform_data;
priv->ipu_id = pdata->ipu_id;
switch (pdata->grp_id) {
-   case IMX_MEDIA_GRP_ID_IC_PRP:
+   case IMX_MEDIA_GRP_ID_IPU_IC_PRP:
priv->task_id = IC_TASK_PRP;
break;
-   case IMX_MEDIA_GRP_ID_IC_PRPENC:
+   case IMX_MEDIA_GRP_ID_IPU_IC_PRPENC:
priv->task_id = IC_TASK_ENCODER;
break;
-   case IMX_MEDIA_GRP_ID_IC_PRPVF:
+   case IMX_MEDIA_GRP_ID_IPU_IC_PRPVF:
priv->task_id = IC_TASK_VIEWFINDER;
break;
default:
diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index 98923fc844ce..2702548f83cf 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -77,7 +77,7 @@ static int prp_start(struct prp_priv *priv)
priv->ipu = priv->md->ipu[ic_priv->ipu_id];
 
/* set IC to receive from CSI or VDI depending on source */
-   src_is_vdic = !!(priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_VDIC);
+   src_is_vdic = !!(priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_IPU_VDIC);
 
ipu_set_ic_src_mux(priv->ipu, priv->csi_id, src_is_vdic);
 
@@ -237,8 +237,8 @@ static int prp_link_setup(struct media_entity *entity,
ret = -EBUSY;
goto out;
}
-   if (priv->sink_sd_prpenc && (remote_sd->grp_id &
-IMX_MEDIA_GRP_ID_VDIC)) {
+   if (priv->sink_sd_prpenc &&
+   (remote_sd->grp_id & IMX_MEDIA_GRP_ID_IPU_VDIC)) {
ret = -EINVAL;
goto out;
}
@@ -259,7 +259,7 @@ static int prp_link_setup(struct media_entity *entity,
goto out;
}
if (priv->src_sd && (priv->src_sd->grp_id &
-IMX_MEDIA_GRP_ID_VDIC)) {
+IMX_MEDIA_GRP_ID_IPU_VDIC)) {
ret = -EINVAL;
goto out;
}
@@ -309,13 +309,13 @@ static int prp_link_validate(struct v4l2_subdev *sd,
return ret;
 
csi = imx_media_find_upstream_subdev(priv->md, _priv->sd.entity,
-IMX_MEDIA_GRP_ID_CSI);
+IMX_MEDIA_GRP_ID_IPU_CSI);
if (IS_ERR(csi))
csi = NULL;
 
mutex_lock(>lock);
 
-   if (priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_VDIC) {
+   if (priv->src_sd->grp_id & IMX_MEDIA_GRP_ID_IPU_VDIC) {
/*
 * the ->PRPENC link cannot be enabled if the source
 * is the VDIC
@@ -334,10 +334,10 @@ static int prp_link_validate(struct v4l2_subdev *sd,
 
if (csi) {
switch (csi->grp_id) {
-   case IMX_MEDIA_GRP_ID_CSI0:
+   case IMX_MEDIA_GRP_ID_IPU_CSI0:
priv->csi_id = 0;
break;
-   case IMX_MEDIA_GRP_ID_CSI1:
+   case IMX_MEDIA_GRP_ID_IPU_CSI1:
priv->csi_id = 1;
break;
default:
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index d851ca2497b4..d957b8aa3ec5 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/me

[PATCH v13 03/13] media: dt-bindings: add bindings for i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva
Add bindings documentation for i.MX7 media drivers.
The imx7 MIPI CSI2 and imx7 CMOS Sensor Interface.

Signed-off-by: Rui Miguel Silva 
Reviewed-by: Rob Herring 
Acked-by: Sakari Ailus 
---
 .../devicetree/bindings/media/imx7-csi.txt| 45 ++
 .../bindings/media/imx7-mipi-csi2.txt | 90 +++
 2 files changed, 135 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx7-csi.txt
 create mode 100644 Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt

diff --git a/Documentation/devicetree/bindings/media/imx7-csi.txt 
b/Documentation/devicetree/bindings/media/imx7-csi.txt
new file mode 100644
index ..3c07bc676bc3
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/imx7-csi.txt
@@ -0,0 +1,45 @@
+Freescale i.MX7 CMOS Sensor Interface
+=
+
+csi node
+
+
+This is device node for the CMOS Sensor Interface (CSI) which enables the chip
+to connect directly to external CMOS image sensors.
+
+Required properties:
+
+- compatible: "fsl,imx7-csi";
+- reg   : base address and length of the register set for the device;
+- interrupts: should contain CSI interrupt;
+- clocks: list of clock specifiers, see
+Documentation/devicetree/bindings/clock/clock-bindings.txt for details;
+- clock-names   : must contain "axi", "mclk" and "dcic" entries, matching
+ entries in the clock property;
+
+The device node shall contain one 'port' child node with one child 'endpoint'
+node, according to the bindings defined in:
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+In the following example a remote endpoint is a video multiplexer.
+
+example:
+
+csi: csi@3071 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+compatible = "fsl,imx7-csi";
+reg = <0x3071 0x1>;
+interrupts = ;
+clocks = < IMX7D_CLK_DUMMY>,
+< IMX7D_CSI_MCLK_ROOT_CLK>,
+< IMX7D_CLK_DUMMY>;
+clock-names = "axi", "mclk", "dcic";
+
+port {
+csi_from_csi_mux: endpoint {
+remote-endpoint = <_mux_to_csi>;
+};
+};
+};
diff --git a/Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt 
b/Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt
new file mode 100644
index ..71fd74ed3ec8
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt
@@ -0,0 +1,90 @@
+Freescale i.MX7 Mipi CSI2
+=
+
+mipi_csi2 node
+--
+
+This is the device node for the MIPI CSI-2 receiver core in i.MX7 SoC. It is
+compatible with previous version of Samsung D-phy.
+
+Required properties:
+
+- compatible: "fsl,imx7-mipi-csi2";
+- reg   : base address and length of the register set for the device;
+- interrupts: should contain MIPI CSIS interrupt;
+- clocks: list of clock specifiers, see
+Documentation/devicetree/bindings/clock/clock-bindings.txt for details;
+- clock-names   : must contain "pclk", "wrap" and "phy" entries, matching
+  entries in the clock property;
+- power-domains : a phandle to the power domain, see
+  Documentation/devicetree/bindings/power/power_domain.txt for details.
+- reset-names   : should include following entry "mrst";
+- resets: a list of phandle, should contain reset entry of
+  reset-names;
+- phy-supply: from the generic phy bindings, a phandle to a regulator that
+ provides power to MIPI CSIS core;
+
+Optional properties:
+
+- clock-frequency : The IP's main (system bus) clock frequency in Hz, default
+   value when this property is not specified is 166 MHz;
+- fsl,csis-hs-settle : differential receiver (HS-RX) settle time;
+
+The device node should contain two 'port' child nodes with one child 'endpoint'
+node, according to the bindings defined in:
+ Documentation/devicetree/bindings/ media/video-interfaces.txt.
+ The following are properties specific to those nodes.
+
+port node
+-
+
+- reg: (required) can take the values 0 or 1, where 0 shall be
+ related to the sink port and port 1 shall be the source
+ one;
+
+endpoint node
+-
+
+- data-lanes: (required) an array specifying active physical MIPI-CSI2
+   data input lanes and their mapping to logical lanes; this
+shall only be app

[PATCH v13 00/13] media: staging/imx7: add i.MX7 media driver

2019-02-06 Thread Rui Miguel Silva
_CTRL: OK
info: checking extended control 'User Controls' (0x00980001)
info: checking extended control 'Exposure' (0x00980911)
info: checking extended control 'Gain, Automatic' (0x00980912)
info: checking extended control 'Gain' (0x00980913)
info: checking extended control 'Horizontal Flip' (0x00980914)
info: checking extended control 'Vertical Flip' (0x00980915)
info: checking extended control 'Camera Controls' (0x009a0001)
info: checking extended control 'Auto Exposure' (0x009a0901)
info: checking extended control 'Image Processing Controls' 
(0x009f0001)
info: checking extended control 'Test Pattern' (0x009f0903)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
info: checking control event 'User Controls' (0x00980001)
fail: 
../../../../../../../../../../v4l-utils/utils/v4l2-compliance/v4l2-test-controls.cpp(824):
 subscribe event for control 'User Controls' failed
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 10 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not Supported)
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK (Not Supported)
test VIDIOC_TRY_FMT: OK (Not Supported)
test VIDIOC_S_FMT: OK (Not Supported)
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK (Not Supported)
test VIDIOC_EXPBUF: OK (Not Supported)
test Requests: OK (Not Supported)

Total for device /dev/v4l-subdev3: 40, Succeeded: 39, Failed: 1, Warnings: 0

Grand Total for imx7-csi device /dev/media0: 227, Succeeded: 225, Failed: 2, 
Warnings: 0

Rui Miguel Silva (13):
  media: staging/imx: refactor imx media device probe
  media: staging/imx: rearrange group id to take in account IPU
  media: dt-bindings: add bindings for i.MX7 media driver
  media: staging/imx7: add imx7 CSI subdev driver
  media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7
  ARM: dts: imx7s: add mipi phy power domain
  ARM: dts: imx7s: add multiplexer controls
  ARM: dts: imx7: Add video mux, csi and mipi_csi and connections
  ARM: dts: imx7s-warp: add ov2680 sensor node
  media: imx7.rst: add documentation for i.MX7 media driver
  media: staging/imx: add i.MX7 entries to TODO file
  media: video-mux: add bayer formats
  media: MAINTAINERS: add entry for Freescale i.MX7 media driver

 .../devicetree/bindings/media/imx7-csi.txt|   45 +
 .../bindings/media/imx7-mipi-csi2.txt |   90 ++
 Documentation/media/v4l-drivers/imx7.rst  |  157 ++
 Documentation/media/v4l-drivers/index.rst |1 +
 MAINTAINERS   |   11 +
 arch/arm/boot/dts/imx7s-warp.dts  |   95 ++
 arch/arm/boot/dts/imx7s.dtsi  |   44 +-
 drivers/media/platform/video-mux.c|   20 +
 drivers/staging/media/imx/Kconfig |9 +-
 drivers/staging/media/imx/Makefile|4 +
 drivers/staging/media/imx/TODO|9 +
 drivers/staging/media/imx/imx-ic-common.c |6 +-
 drivers/staging/media/imx/imx-ic-prp.c|   16 +-
 drivers/staging/media/imx/imx-media-csi.c |6 +-
 drivers/staging/media/imx/imx-media-dev.c |  108 +-
 .../staging/media/imx/imx-media-internal-sd.c |   20 +-
 drivers/staging/media/imx/imx-media-of.c  |6 +-
 drivers/staging/media/imx/imx-media-utils.c   |   12 +-
 drivers/staging/media/imx/imx-media.h |   37 +-
 drivers/staging/media/imx/imx7-media-csi.c| 1365 +
 drivers/staging/media/imx/imx7-mipi-csis.c| 1186 ++
 21 files changed, 3124 insertions(+), 123 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/imx7-csi.txt
 create mode 100644 Documentation/devicetree/bindings/media/imx7-mipi-csi2.txt
 create mode 100644 Documentation/media/v4l-drivers/imx7.rst
 create mode 100644 drivers/staging/media/imx/imx7-media-csi.c
 create mode 100644 drivers/staging/media/imx/imx7-mipi-csis.c

-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v12 00/13] media: staging/imx7: add i.MX7 media driver

2019-02-05 Thread Rui Miguel Silva

Hi Sakari,
On Tue 05 Feb 2019 at 11:14, Sakari Ailus wrote:

Hi Rui,

On Mon, Feb 04, 2019 at 12:00:26PM +, Rui Miguel Silva 
wrote:

Hi,
This series introduces the Media driver to work with the i.MX7 
SoC. it uses the
already existing imx media core drivers but since the i.MX7, 
contrary to
i.MX5/6, do not have an IPU and because of that some changes in 
the imx media

core are made along this series to make it support that case.

This patches adds CSI and MIPI-CSI2 drivers for i.MX7, along 
with several
configurations changes for this to work as a capture subsystem. 
Some bugs are

also fixed along the line. And necessary documentation.

For a more detailed view of the capture paths, pads links in 
the i.MX7 please

take a look at the documentation in PATCH 10.

The system used to test and develop this was the Warp7 board 
with an OV2680
sensor, which output format is 10-bit bayer. So, only MIPI 
interface was

tested, a scenario with an parallel input would nice to have.

Bellow goes an example of the output of the pads and links and 
the output of

v4l2-compliance testing.

The v4l-utils version used is:
v4l2-compliance SHA: 1a6c8fe9a65c26e78ba34bd4aa2df28ede7d00cb, 
32 bits


The Media Driver fail some tests but this failures are coming 
from code out of
scope of this series (imx-capture), and some from the sensor 
OV2680
but that I think not related with the sensor driver but with 
the testing and

core.

The csi and mipi-csi entities pass all compliance tests.

Cheers,
Rui

v11->v12:
  Sakari:
- check v4l2_ctrl_handler_free and init when exposed to 
userspace

- check csi_remove missing v4l2_async_notifier_unregister
- media device unregister before ctrl_handler_free
- GPL => GPL v2
- Fix squash of CSI patches, issue on v11
- add Acked-by: Sakari Ailus  
10--13
- mipi_s_stream check for ret < 0 and call 
pm_runtime_put_noidle

- use __maybe_unused in pm functions
- Extra space before labels


For patches 1, 2 and 4:

Acked-by: Sakari Ailus 


Thanks for all your reviews, I did not add this before, because I
messed the patch order in v11.

---
Cheers,
Rui

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v12 06/13] ARM: dts: imx7s: add mipi phy power domain

2019-02-04 Thread Rui Miguel Silva
Add power domain index 0 related with mipi-phy to imx7s.

While at it rename pcie power-domain node to remove pgc prefix.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s.dtsi | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index e88f53a4c7f4..9a680d3d6424 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -606,7 +606,13 @@
#address-cells = <1>;
#size-cells = <0>;
 
-   pgc_pcie_phy: pgc-power-domain@1 {
+   pgc_mipi_phy: power-domain@0 {
+   #power-domain-cells = <0>;
+   reg = <0>;
+   power-supply = <_1p0d>;
+   };
+
+   pgc_pcie_phy: power-domain@1 {
#power-domain-cells = <0>;
reg = <1>;
power-supply = <_1p0d>;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v12 05/13] media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7

2019-02-04 Thread Rui Miguel Silva
Adds MIPI CSI-2 subdev for i.MX7 to connect with sensors with a MIPI
CSI-2 interface.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/Makefile |1 +
 drivers/staging/media/imx/imx7-mipi-csis.c | 1186 
 2 files changed, 1187 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx7-mipi-csis.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 074f016d3519..d2d909a36239 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
 
 obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-mipi-csis.o
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
new file mode 100644
index ..516d308dc44b
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -0,0 +1,1186 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Freescale i.MX7 SoC series MIPI-CSI V3.3 receiver driver
+ *
+ * Copyright (C) 2019 Linaro Ltd
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "imx-media.h"
+
+#define CSIS_DRIVER_NAME   "imx7-mipi-csis"
+#define CSIS_SUBDEV_NAME   CSIS_DRIVER_NAME
+
+#define CSIS_PAD_SINK  0
+#define CSIS_PAD_SOURCE1
+#define CSIS_PADS_NUM  2
+
+#define MIPI_CSIS_DEF_PIX_WIDTH640
+#define MIPI_CSIS_DEF_PIX_HEIGHT   480
+
+/* Register map definition */
+
+/* CSIS common control */
+#define MIPI_CSIS_CMN_CTRL 0x04
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW   BIT(16)
+#define MIPI_CSIS_CMN_CTRL_INTER_MODE  BIT(10)
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW_CTRL  BIT(2)
+#define MIPI_CSIS_CMN_CTRL_RESET   BIT(1)
+#define MIPI_CSIS_CMN_CTRL_ENABLE  BIT(0)
+
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_OFFSET  8
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_MASK(3 << 8)
+
+/* CSIS clock control */
+#define MIPI_CSIS_CLK_CTRL 0x08
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH3(x)((x) << 28)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH2(x)((x) << 24)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH1(x)((x) << 20)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH0(x)((x) << 16)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_EN_MSK  (0xf << 4)
+#define MIPI_CSIS_CLK_CTRL_WCLK_SRCBIT(0)
+
+/* CSIS Interrupt mask */
+#define MIPI_CSIS_INTMSK   0x10
+#define MIPI_CSIS_INTMSK_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTMSK_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTMSK_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTMSK_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTMSK_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTMSK_FRAME_END BIT(20)
+#define MIPI_CSIS_INTMSK_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FE   BIT(8)
+#define MIPI_CSIS_INTMSK_ERR_OVER  BIT(4)
+#define MIPI_CSIS_INTMSK_ERR_WRONG_CFG BIT(3)
+#define MIPI_CSIS_INTMSK_ERR_ECC   BIT(2)
+#define MIPI_CSIS_INTMSK_ERR_CRC   BIT(1)
+#define MIPI_CSIS_INTMSK_ERR_UNKNOWN   BIT(0)
+
+/* CSIS Interrupt source */
+#define MIPI_CSIS_INTSRC   0x14
+#define MIPI_CSIS_INTSRC_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTSRC_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTSRC_EVEN  BIT(30)
+#define MIPI_CSIS_INTSRC_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTSRC_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTSRC_ODD   (0x3 << 28)
+#define MIPI_CSIS_INTSRC_NON_IMAGE_DATA(0xf << 28)
+#define MIPI_CSIS_INTSRC_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTSRC_FRAME_END BIT(20)
+#define MIPI_CSIS_INTSRC_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTSRC_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTSRC_ERR_LOST_FE   BIT(8)
+#define MIPI_CSIS_INTSRC_ERR_OVER  BIT(4)
+#define MIPI_CSIS_INTSRC_ERR_WRONG_CFG BIT(3)
+#define MIPI_CSIS_INTSRC_ERR_ECC   BIT(2)
+#define MIPI_CSIS_INTSRC_ERR_CRC   BIT(1)
+#define MIPI_CSIS_INTSRC_ERR_UNKNOWN   BIT(0)
+#define MIPI_CSIS_INTSRC_ERRORS0xf
+
+/* D-PHY status control */
+#define MIPI_CSIS_DPHYSTATUS   0x20
+#define MIPI_CSIS_DPHYSTATUS_ULPS_DAT  BIT(8)
+#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_DAT BIT(4)
+#define MIPI_CSIS_DPHYSTATUS_ULPS_CLK  BIT(1)
+#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_CLK BIT(0)
+
+/* D-PHY common control */
+#define MIPI_CSIS_DPHYCTRL 0x24
+#define MIPI_CSIS_DPHYCTRL_HSS

[PATCH v12 10/13] media: imx7.rst: add documentation for i.MX7 media driver

2019-02-04 Thread Rui Miguel Silva
Add rst document to describe the i.MX7 media driver and also a working
example from the Warp7 board usage with a OV2680 sensor.

Signed-off-by: Rui Miguel Silva 
Acked-by: Sakari Ailus 
---
 Documentation/media/v4l-drivers/imx7.rst  | 157 ++
 Documentation/media/v4l-drivers/index.rst |   1 +
 2 files changed, 158 insertions(+)
 create mode 100644 Documentation/media/v4l-drivers/imx7.rst

diff --git a/Documentation/media/v4l-drivers/imx7.rst 
b/Documentation/media/v4l-drivers/imx7.rst
new file mode 100644
index ..cd1195d391c5
--- /dev/null
+++ b/Documentation/media/v4l-drivers/imx7.rst
@@ -0,0 +1,157 @@
+i.MX7 Video Capture Driver
+==
+
+Introduction
+
+
+The i.MX7 contrary to the i.MX5/6 family does not contain an Image Processing
+Unit (IPU); because of that the capabilities to perform operations or
+manipulation of the capture frames are less feature rich.
+
+For image capture the i.MX7 has three units:
+- CMOS Sensor Interface (CSI)
+- Video Multiplexer
+- MIPI CSI-2 Receiver
+
+::
+   |\
+   MIPI Camera Input ---> MIPI CSI-2 --- > | \
+   |  \
+   | M |
+   | U | -->  CSI ---> Capture
+   | X |
+   |  /
+   Parallel Camera Input > | /
+   |/
+
+For additional information, please refer to the latest versions of the i.MX7
+reference manual [#f1]_.
+
+Entities
+
+
+imx7-mipi-csi2
+--
+
+This is the MIPI CSI-2 receiver entity. It has one sink pad to receive the 
pixel
+data from MIPI CSI-2 camera sensor. It has one source pad, corresponding to the
+virtual channel 0. This module is compliant to previous version of Samsung
+D-phy, and supports two D-PHY Rx Data lanes.
+
+csi_mux
+---
+
+This is the video multiplexer. It has two sink pads to select from either 
camera
+sensor with a parallel interface or from MIPI CSI-2 virtual channel 0.  It has
+a single source pad that routes to the CSI.
+
+csi
+---
+
+The CSI enables the chip to connect directly to external CMOS image sensor. CSI
+can interface directly with Parallel and MIPI CSI-2 buses. It has 256 x 64 FIFO
+to store received image pixel data and embedded DMA controllers to transfer 
data
+from the FIFO through AHB bus.
+
+This entity has one sink pad that receives from the csi_mux entity and a single
+source pad that routes video frames directly to memory buffers. This pad is
+routed to a capture device node.
+
+Usage Notes
+---
+
+To aid in configuration and for backward compatibility with V4L2 applications
+that access controls only from video device nodes, the capture device 
interfaces
+inherit controls from the active entities in the current pipeline, so controls
+can be accessed either directly from the subdev or from the active capture
+device interface. For example, the sensor controls are available either from 
the
+sensor subdevs or from the active capture device.
+
+Warp7 with OV2680
+-
+
+On this platform an OV2680 MIPI CSI-2 module is connected to the internal MIPI
+CSI-2 receiver. The following example configures a video capture pipeline with
+an output of 800x600, and BGGR 10 bit bayer format:
+
+.. code-block:: none
+   # Setup links
+   media-ctl -l "'ov2680 1-0036':0 -> 'imx7-mipi-csis.0':0[1]"
+   media-ctl -l "'imx7-mipi-csis.0':1 -> 'csi_mux':1[1]"
+   media-ctl -l "'csi_mux':2 -> 'csi':0[1]"
+   media-ctl -l "'csi':1 -> 'csi capture':0[1]"
+
+   # Configure pads for pipeline
+   media-ctl -V "'ov2680 1-0036':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi_mux':1 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi_mux':2 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'imx7-mipi-csis.0':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+
+After this streaming can start. The v4l2-ctl tool can be used to select any of
+the resolutions supported by the sensor.
+
+.. code-block:: none
+root@imx7s-warp:~# media-ctl -p
+Media controller API version 4.17.0
+
+Media device information
+
+driver  imx-media
+model   imx-media
+serial
+bus info
+hw revision 0x0
+driver version  4.17.0
+
+Device topology
+- entity 1: csi (2 pads, 2 links)
+   type V4L2 subdev subtype Unknown flags 0
+   device node name /dev/v4l-subdev0
+   pad0: Sink
+   [fmt:SBGGR10_1X10/800x600 field:none]
+   <- "csi_mux":2 [ENABLED]
+   pad1: Source
+   [f

[PATCH v12 09/13] ARM: dts: imx7s-warp: add ov2680 sensor node

2019-02-04 Thread Rui Miguel Silva
Warp7 comes with a Omnivision OV2680 sensor, add the node here to make
complete the camera data path for this system. Add the needed regulator
to the analog voltage supply, the port and endpoints in mipi_csi node
and the pinctrl for the reset gpio.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s-warp.dts | 44 
 1 file changed, 44 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s-warp.dts b/arch/arm/boot/dts/imx7s-warp.dts
index 358bcae7ebaf..58d1a89ee3e3 100644
--- a/arch/arm/boot/dts/imx7s-warp.dts
+++ b/arch/arm/boot/dts/imx7s-warp.dts
@@ -55,6 +55,14 @@
regulator-always-on;
};
 
+   reg_peri_3p15v: regulator-peri-3p15v {
+   compatible = "regulator-fixed";
+   regulator-name = "peri_3p15v_reg";
+   regulator-min-microvolt = <315>;
+   regulator-max-microvolt = <315>;
+   regulator-always-on;
+   };
+
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "imx7-sgtl5000";
@@ -178,6 +186,27 @@
pinctrl-names = "default";
pinctrl-0 = <_i2c2>;
status = "okay";
+
+   ov2680: camera@36 {
+   compatible = "ovti,ov2680";
+   pinctrl-names = "default";
+   pinctrl-0 = <_ov2680>;
+   reg = <0x36>;
+   clocks = <>;
+   clock-names = "xvclk";
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+   DOVDD-supply = <_reg>;
+   DVDD-supply = <_reg>;
+   AVDD-supply = <_peri_3p15v>;
+
+   port {
+   ov2680_to_mipi: endpoint {
+   remote-endpoint = <_from_sensor>;
+   clock-lanes = <0>;
+   data-lanes = <1>;
+   };
+   };
+   };
 };
 
  {
@@ -319,6 +348,15 @@
#size-cells = <0>;
fsl,csis-hs-settle = <3>;
 
+   port@0 {
+   reg = <0>;
+
+   mipi_from_sensor: endpoint {
+   remote-endpoint = <_to_mipi>;
+   data-lanes = <1>;
+   };
+   };
+
port@1 {
reg = <1>;
 
@@ -382,6 +420,12 @@
>;
};
 
+   pinctrl_ov2680: ov2660grp {
+   fsl,pins = <
+   MX7D_PAD_LPSR_GPIO1_IO03__GPIO1_IO3 0x14
+   >;
+   };
+
pinctrl_sai1: sai1grp {
fsl,pins = <
MX7D_PAD_SAI1_RX_DATA__SAI1_RX_DATA00x1f
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v12 08/13] ARM: dts: imx7: Add video mux, csi and mipi_csi and connections

2019-02-04 Thread Rui Miguel Silva
This patch adds the device tree nodes for csi, video multiplexer and
mipi-csi besides the graph connecting the necessary endpoints to make
the media capture entities to work in imx7 Warp board.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s-warp.dts | 51 
 arch/arm/boot/dts/imx7s.dtsi | 27 +
 2 files changed, 78 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s-warp.dts b/arch/arm/boot/dts/imx7s-warp.dts
index 23431faecaf4..358bcae7ebaf 100644
--- a/arch/arm/boot/dts/imx7s-warp.dts
+++ b/arch/arm/boot/dts/imx7s-warp.dts
@@ -277,6 +277,57 @@
status = "okay";
 };
 
+ {
+   csi_mux {
+   compatible = "video-mux";
+   mux-controls = < 0>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@1 {
+   reg = <1>;
+
+   csi_mux_from_mipi_vc0: endpoint {
+   remote-endpoint = <_vc0_to_csi_mux>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   csi_mux_to_csi: endpoint {
+   remote-endpoint = <_from_csi_mux>;
+   };
+   };
+   };
+};
+
+ {
+   status = "okay";
+
+   port {
+   csi_from_csi_mux: endpoint {
+   remote-endpoint = <_mux_to_csi>;
+   };
+   };
+};
+
+_csi {
+   clock-frequency = <16600>;
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   fsl,csis-hs-settle = <3>;
+
+   port@1 {
+   reg = <1>;
+
+   mipi_vc0_to_csi_mux: endpoint {
+   remote-endpoint = <_mux_from_mipi_vc0>;
+   };
+   };
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_wdog>;
diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 792efcd2caa1..01962f85cab6 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "imx7d-pinfunc.h"
 
 / {
@@ -709,6 +710,17 @@
status = "disabled";
};
 
+   csi: csi@3071 {
+   compatible = "fsl,imx7-csi";
+   reg = <0x3071 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_CLK_DUMMY>,
+   < IMX7D_CSI_MCLK_ROOT_CLK>,
+   < IMX7D_CLK_DUMMY>;
+   clock-names = "axi", "mclk", "dcic";
+   status = "disabled";
+   };
+
lcdif: lcdif@3073 {
compatible = "fsl,imx7d-lcdif", 
"fsl,imx28-lcdif";
reg = <0x3073 0x1>;
@@ -718,6 +730,21 @@
clock-names = "pix", "axi";
status = "disabled";
};
+
+   mipi_csi: mipi-csi@3075 {
+   compatible = "fsl,imx7-mipi-csi2";
+   reg = <0x3075 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_IPG_ROOT_CLK>,
+   < IMX7D_MIPI_CSI_ROOT_CLK>,
+   < IMX7D_MIPI_DPHY_ROOT_CLK>;
+   clock-names = "pclk", "wrap", "phy";
+   power-domains = <_mipi_phy>;
+   phy-supply = <_1p0d>;
+   resets = < IMX7_RESET_MIPI_PHY_MRST>;
+   reset-names = "mrst";
+   status = "disabled";
+   };
};
 
aips3: aips-bus@3080 {
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v12 12/13] media: video-mux: add bayer formats

2019-02-04 Thread Rui Miguel Silva
Add non vendor bayer formats to the  allowed format array.

Signed-off-by: Rui Miguel Silva 
Reviewed-by: Philipp Zabel 
Acked-by: Sakari Ailus 
---
 drivers/media/platform/video-mux.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/media/platform/video-mux.c 
b/drivers/media/platform/video-mux.c
index c33900e3c23e..0ba30756e1e4 100644
--- a/drivers/media/platform/video-mux.c
+++ b/drivers/media/platform/video-mux.c
@@ -263,6 +263,26 @@ static int video_mux_set_format(struct v4l2_subdev *sd,
case MEDIA_BUS_FMT_UYYVYY16_0_5X48:
case MEDIA_BUS_FMT_JPEG_1X8:
case MEDIA_BUS_FMT_AHSV_1X32:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case MEDIA_BUS_FMT_SGBRG10_1X10:
+   case MEDIA_BUS_FMT_SGRBG10_1X10:
+   case MEDIA_BUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR12_1X12:
+   case MEDIA_BUS_FMT_SGBRG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SRGGB12_1X12:
+   case MEDIA_BUS_FMT_SBGGR14_1X14:
+   case MEDIA_BUS_FMT_SGBRG14_1X14:
+   case MEDIA_BUS_FMT_SGRBG14_1X14:
+   case MEDIA_BUS_FMT_SRGGB14_1X14:
+   case MEDIA_BUS_FMT_SBGGR16_1X16:
+   case MEDIA_BUS_FMT_SGBRG16_1X16:
+   case MEDIA_BUS_FMT_SGRBG16_1X16:
+   case MEDIA_BUS_FMT_SRGGB16_1X16:
break;
default:
sdformat->format.code = MEDIA_BUS_FMT_Y8_1X8;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   3   4   >