Re: [PATCH] libv4l: fixup lfs mismatch in preload libraries

2018-07-12 Thread Baruch Siach


Mauro Carvalho Chehab writes:

> Em Wed, 11 Jul 2018 22:38:56 +0300
> Baruch Siach  escreveu:
>> Added Peter's updated address to Cc.
>>
>> Mauro Carvalho Chehab writes:
>> > Em Wed, 11 Jul 2018 10:22:51 -0300
>> > Ezequiel Garcia  escreveu:
>> >
>> >> From: Peter Korsgaard 
>> >>
>> >> Ensure that the lfs variants are not transparently used instead of the 
>> >> !lfs
>> >> ones so both can be wrapped, independently of any custom CFLAGS/CPPFLAGS.
>> >>
>> >> Without this patch, the following assembler errors appear
>> >> during cross-compiling with Buildroot:
>> >>
>> >> /tmp/ccc3gdJg.s: Assembler messages:
>> >> /tmp/ccc3gdJg.s:67: Error: symbol `open64' is already defined
>> >> /tmp/ccc3gdJg.s:130: Error: symbol `mmap64' is already defined
>> >>
>> >> Signed-off-by: Peter Korsgaard 
>> >> Signed-off-by: Ezequiel Garcia 
>> >> ---
>> >>  lib/libv4l1/v4l1compat.c  | 3 +++
>> >>  lib/libv4l2/v4l2convert.c | 3 +++
>> >>  2 files changed, 6 insertions(+)
>> >>
>> >> diff --git a/lib/libv4l1/v4l1compat.c b/lib/libv4l1/v4l1compat.c
>> >> index cb79629ff88f..e5c9e56261e2 100644
>> >> --- a/lib/libv4l1/v4l1compat.c
>> >> +++ b/lib/libv4l1/v4l1compat.c
>> >> @@ -19,6 +19,9 @@
>> >>  # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  
>> >> 02110-1335  USA
>> >>   */
>> >>
>> >> +/* ensure we see *64 variants and they aren't transparently used */
>> >> +#undef _LARGEFILE_SOURCE
>> >> +#undef _FILE_OFFSET_BITS
>> >
>> > Hmm... shouldn't this be autodetected? I didn't check anything,
>> > but I would be expecting that different distros (and BSD) may be
>> > doing different things here, specially if they use different gcc
>> > versions or even different libc implementations.
>>
>> See Peter's explanation here:
>>
>>   http://lists.busybox.net/pipermail/buildroot/2017-December/210067.html
>
> The link Peter provided seems to be specific to glibc. The main
> point I want to bring is: would this change affect users with
> other setups? There are some users that compile it against FreeBSD
> and Android. Some compile using dietlibc or uclibc. Also, people
> build it against 32-bits and 64-bits on x86, arm and other archs.
>
> So, the question is: are you sure that the above change is also valid for
> *all* other environments? If not, I would be expecting it to be
> attached to some automake test, to be sure that it will be applied
> only to the affected setups.

Buildroot has been carrying this patch since 2012[1] with no one
complaining. Buildroot supports glibc, uClibc, and musl libc on a wide
range of architectures (x86, ARM, MIPS, PowerPC, Sparc, xtensa, arc, and
more) both 32-bit and 64-bit.

I don't know about FreeBSD.

baruch

[1] 
https://git.buildroot.org/buildroot/commit/?id=d059b1cc61dcafde47723c45b834409026a39dbe

>> >>  #define _LARGEFILE64_SOURCE 1
>> >>
>> >>  #include 
>> >> diff --git a/lib/libv4l2/v4l2convert.c b/lib/libv4l2/v4l2convert.c
>> >> index 7c9a04c086ed..13ca4cfb1b08 100644
>> >> --- a/lib/libv4l2/v4l2convert.c
>> >> +++ b/lib/libv4l2/v4l2convert.c
>> >> @@ -23,6 +23,9 @@
>> >>  /* prevent GCC 4.7 inlining error */
>> >>  #undef _FORTIFY_SOURCE
>> >>
>> >> +/* ensure we see *64 variants and they aren't transparently used */
>> >> +#undef _LARGEFILE_SOURCE
>> >> +#undef _FILE_OFFSET_BITS
>> >>  #define _LARGEFILE64_SOURCE 1
>> >>
>> >>  #ifdef ANDROID

--
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH] libv4l: fixup lfs mismatch in preload libraries

2018-07-11 Thread Baruch Siach
Hi Mauro,

Added Peter's updated address to Cc.

Mauro Carvalho Chehab writes:
> Em Wed, 11 Jul 2018 10:22:51 -0300
> Ezequiel Garcia  escreveu:
>
>> From: Peter Korsgaard 
>> 
>> Ensure that the lfs variants are not transparently used instead of the !lfs
>> ones so both can be wrapped, independently of any custom CFLAGS/CPPFLAGS.
>> 
>> Without this patch, the following assembler errors appear
>> during cross-compiling with Buildroot:
>> 
>> /tmp/ccc3gdJg.s: Assembler messages:
>> /tmp/ccc3gdJg.s:67: Error: symbol `open64' is already defined
>> /tmp/ccc3gdJg.s:130: Error: symbol `mmap64' is already defined
>> 
>> Signed-off-by: Peter Korsgaard 
>> Signed-off-by: Ezequiel Garcia 
>> ---
>>  lib/libv4l1/v4l1compat.c  | 3 +++
>>  lib/libv4l2/v4l2convert.c | 3 +++
>>  2 files changed, 6 insertions(+)
>> 
>> diff --git a/lib/libv4l1/v4l1compat.c b/lib/libv4l1/v4l1compat.c
>> index cb79629ff88f..e5c9e56261e2 100644
>> --- a/lib/libv4l1/v4l1compat.c
>> +++ b/lib/libv4l1/v4l1compat.c
>> @@ -19,6 +19,9 @@
>>  # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335  
>> USA
>>   */
>>  
>> +/* ensure we see *64 variants and they aren't transparently used */
>> +#undef _LARGEFILE_SOURCE
>> +#undef _FILE_OFFSET_BITS
>
> Hmm... shouldn't this be autodetected? I didn't check anything,
> but I would be expecting that different distros (and BSD) may be
> doing different things here, specially if they use different gcc
> versions or even different libc implementations.

See Peter's explanation here:

  http://lists.busybox.net/pipermail/buildroot/2017-December/210067.html

baruch

>>  #define _LARGEFILE64_SOURCE 1
>>  
>>  #include 
>> diff --git a/lib/libv4l2/v4l2convert.c b/lib/libv4l2/v4l2convert.c
>> index 7c9a04c086ed..13ca4cfb1b08 100644
>> --- a/lib/libv4l2/v4l2convert.c
>> +++ b/lib/libv4l2/v4l2convert.c
>> @@ -23,6 +23,9 @@
>>  /* prevent GCC 4.7 inlining error */
>>  #undef _FORTIFY_SOURCE
>>  
>> +/* ensure we see *64 variants and they aren't transparently used */
>> +#undef _LARGEFILE_SOURCE
>> +#undef _FILE_OFFSET_BITS
>>  #define _LARGEFILE64_SOURCE 1
>>  
>>  #ifdef ANDROID


-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


[PATCH] media: v4l2-ctrls.h: fix v4l2_ctrl field description typos

2018-07-05 Thread Baruch Siach
Signed-off-by: Baruch Siach 
---
 include/media/v4l2-ctrls.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 5b445b5654f7..f615ba1b29dd 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -181,10 +181,10 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl 
*ctrl, void *priv);
  * not freed when the control is deleted. Should this be needed
  * then a new internal bitfield can be added to tell the framework
  * to free this pointer.
- * @p_cur: The control's current value represented via a union with
+ * @p_cur: The control's current value represented via a union which
  * provides a standard way of accessing control types
  * through a pointer.
- * @p_new: The control's new value represented via a union with provides
+ * @p_new: The control's new value represented via a union which provides
  * a standard way of accessing control types
  * through a pointer.
  */
-- 
2.18.0



Re: [PATCH v6 05/17] media: rkisp1: add Rockchip ISP1 subdev driver

2018-05-24 Thread Baruch Siach
Hi Tomasz,

On Mon, May 07, 2018 at 06:41:50AM +, Tomasz Figa wrote:
> On Mon, May 7, 2018 at 3:38 PM Baruch Siach <bar...@tkos.co.il> wrote:
> > On Mon, May 07, 2018 at 06:13:27AM +, Tomasz Figa wrote:
> > > On Thu, May 3, 2018 at 6:09 PM Baruch Siach <bar...@tkos.co.il> wrote:
> > > > On Thu, Mar 08, 2018 at 05:47:55PM +0800, Jacob Chen wrote:
> > > > > +static int rkisp1_isp_sd_s_power(struct v4l2_subdev *sd, int on)
> > > > > +{
> > > > > + struct rkisp1_device *isp_dev = sd_to_isp_dev(sd);
> > > > > + int ret;
> > > > > +
> > > > > + v4l2_dbg(1, rkisp1_debug, _dev->v4l2_dev, "s_power: %d\n",
> > > on);
> > > > > +
> > > > > + if (on) {
> > > > > + ret = pm_runtime_get_sync(isp_dev->dev);
> > > > > + if (ret < 0)
> > > > > + return ret;
> > > > > +
> > > > > + rkisp1_config_clk(isp_dev);
> > > > > + } else {
> > > > > + ret = pm_runtime_put(isp_dev->dev);
> > >
> > > > I commented this line out to make more than one STREAMON work.
> Otherwise,
> > > > the second STREAMON hangs. I guess the bug is not this driver.
> Probably
> > > > something in drivers/soc/rockchip/pm_domains.c. Just noting that in
> case
> > > > you or someone on Cc would like to investigate it further.
> > > >
> > > > I tested v4.16-rc4 on the Tinkerboard.
> > >
> > > Looks like that version doesn't include the IOMMU PM and clock handling
> > > rework [1], which should fix a lot of runtime PM issues. FWIW,
> linux-next
> > > seems to already include it.
> > >
> > > [1] https://lkml.org/lkml/2018/3/23/44
> 
> > Thanks for the reference.
> 
> > It looks like the iommu driver part is in Linus' tree already. The DT
> part is
> > in the v4.18-armsoc/dts32 branch of Heiko's tree. Am I missing anything?
> 
> You're right, most of the series made it in time for 4.17. However, the DT
> part (precisely, the clocks properties added to IOMMU nodes) is crucial for
> the fixes to be effective.
> 
> > Anyway, I'll take a look.
> 
> Thanks for testing. :) (Forgot to mention in my previous email...)

I finally got around to testing. Unfortunately, kernel v4.17-rc6 with 
cherry-pick of commit c78751f91c0b (ARM: dts: rockchip: add clocks in iommu 
nodes) from Heiko's tree still exhibit the same problem. STREAMON hangs on 
second try. The same workaround "fixes" it.

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH v6 05/17] media: rkisp1: add Rockchip ISP1 subdev driver

2018-05-07 Thread Baruch Siach
Hi Tomasz,

On Mon, May 07, 2018 at 06:13:27AM +, Tomasz Figa wrote:
> On Thu, May 3, 2018 at 6:09 PM Baruch Siach <bar...@tkos.co.il> wrote:
> > On Thu, Mar 08, 2018 at 05:47:55PM +0800, Jacob Chen wrote:
> > > +static int rkisp1_isp_sd_s_power(struct v4l2_subdev *sd, int on)
> > > +{
> > > + struct rkisp1_device *isp_dev = sd_to_isp_dev(sd);
> > > + int ret;
> > > +
> > > + v4l2_dbg(1, rkisp1_debug, _dev->v4l2_dev, "s_power: %d\n",
> on);
> > > +
> > > + if (on) {
> > > + ret = pm_runtime_get_sync(isp_dev->dev);
> > > + if (ret < 0)
> > > + return ret;
> > > +
> > > + rkisp1_config_clk(isp_dev);
> > > + } else {
> > > + ret = pm_runtime_put(isp_dev->dev);
> 
> > I commented this line out to make more than one STREAMON work. Otherwise, 
> > the second STREAMON hangs. I guess the bug is not this driver. Probably
> > something in drivers/soc/rockchip/pm_domains.c. Just noting that in case 
> > you or someone on Cc would like to investigate it further.
> >
> > I tested v4.16-rc4 on the Tinkerboard.
> 
> Looks like that version doesn't include the IOMMU PM and clock handling
> rework [1], which should fix a lot of runtime PM issues. FWIW, linux-next
> seems to already include it.
> 
> [1] https://lkml.org/lkml/2018/3/23/44

Thanks for the reference.

It looks like the iommu driver part is in Linus' tree already. The DT part is 
in the v4.18-armsoc/dts32 branch of Heiko's tree. Am I missing anything?

Anyway, I'll take a look.

Thanks again,
baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH v6 05/17] media: rkisp1: add Rockchip ISP1 subdev driver

2018-05-03 Thread Baruch Siach
Hi Jacob,

On Thu, Mar 08, 2018 at 05:47:55PM +0800, Jacob Chen wrote:
> +static int rkisp1_isp_sd_s_power(struct v4l2_subdev *sd, int on)
> +{
> + struct rkisp1_device *isp_dev = sd_to_isp_dev(sd);
> + int ret;
> +
> + v4l2_dbg(1, rkisp1_debug, _dev->v4l2_dev, "s_power: %d\n", on);
> +
> + if (on) {
> + ret = pm_runtime_get_sync(isp_dev->dev);
> + if (ret < 0)
> + return ret;
> +
> + rkisp1_config_clk(isp_dev);
> + } else {
> + ret = pm_runtime_put(isp_dev->dev);

I commented this line out to make more than one STREAMON work. Otherwise, the 
second STREAMON hangs. I guess the bug is not this driver. Probably something 
in drivers/soc/rockchip/pm_domains.c. Just noting that in case you or someone 
on Cc would like to investigate it further.

I tested v4.16-rc4 on the Tinkerboard.

baruch

> + if (ret < 0)
> + return ret;
> + }
> +
> + return 0;
> +}

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH v6 09/17] media: rkisp1: add rockchip isp1 core driver

2018-03-10 Thread Baruch Siach
Hi Jacob,

On Thu, Mar 08, 2018 at 05:47:59PM +0800, Jacob Chen wrote:
> +config VIDEO_ROCKCHIP_ISP1
> + tristate "Rockchip Image Signal Processing v1 Unit driver"
> + depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
> + depends on ARCH_ROCKCHIP || COMPILE_TEST
> + select VIDEOBUF2_DMA_CONTIG
> + select V4L2_FWNODE
> + default n
> + ---help---
> +   Support for ISP1 on the rockchip SoC.

I added 'select VIDEOBUF2_VMALLOC' here to fix link failure:

drivers/media/platform/rockchip/isp1/isp_stats.o: In function 
`rkisp1_register_stats_vdev':
isp_stats.c:(.text+0x80c): undefined reference to `vb2_vmalloc_memops'
isp_stats.c:(.text+0x814): undefined reference to `vb2_vmalloc_memops'
drivers/media/platform/rockchip/isp1/isp_params.o: In function 
`rkisp1_register_params_vdev':
isp_params.c:(.text+0x29b4): undefined reference to `vb2_vmalloc_memops'
isp_params.c:(.text+0x29bc): undefined reference to `vb2_vmalloc_memops'

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


Re: [PATCH v6 00/17] Rockchip ISP1 Driver

2018-03-08 Thread Baruch Siach
Hi Jacob,

On Fri, Mar 09, 2018 at 01:05:28PM +0800, Jacob Chen wrote:
> 2018-03-09 12:09 GMT+08:00 Baruch Siach <bar...@tkos.co.il>:
> > On Fri, Mar 09, 2018 at 08:53:57AM +0800, Jacob Chen wrote:
> >> 2018-03-08 20:02 GMT+08:00 Baruch Siach <bar...@tkos.co.il>:
> >> > On Thu, Mar 08, 2018 at 05:47:50PM +0800, Jacob Chen wrote:
> >> >> This patch series add a ISP(Camera) v4l2 driver for rockchip 
> >> >> rk3288/rk3399
> >> >> SoC.
> >> >>
> >> >> Wiki Pages:
> >> >> http://opensource.rock-chips.com/wiki_Rockchip-isp1
> >> >>
> >> >> The deprecated g_mbus_config op is not dropped in  V6 because i am 
> >> >> waiting
> >> >> tomasz's patches.
> >> >
> >> > Which tree is this series based on? On top of v4.16-rc4 I get the build
> >> > failure below. The V4L2_BUF_TYPE_META_OUTPUT macro, for example, is not 
> >> > even
> >> > in media_tree.git.
> >>
> >> This series is based on v4.16-rc4 with below patch.
> >> https://patchwork.kernel.org/patch/9792001/
> >
> > This patch does not apply on v4.16-rc4. I also tried v2 of this patch with 
> > the
> > same result:
> >
> >   https://patchwork.linuxtv.org/patch/44682/
> 
> It need resolve merge conflict.
> 
> > Can you push your series to a public git repo branch?
> 
> Sure, I have push it to my github.
> https://github.com/wzyy2/linux/tree/4.16-rc4
> 
> This commit might be a bit of a mess
> https://github.com/wzyy2/linux/commit/ff68323c4804adc10f64836ea1be172c54a9d6c6

Thanks. This is very helpful.

I'm mostly interested in the tinkerboard, so the DT bits in your tree are also 
useful.

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH v6 00/17] Rockchip ISP1 Driver

2018-03-08 Thread Baruch Siach
Hi Jacob,

On Fri, Mar 09, 2018 at 08:53:57AM +0800, Jacob Chen wrote:
> 2018-03-08 20:02 GMT+08:00 Baruch Siach <bar...@tkos.co.il>:
> > On Thu, Mar 08, 2018 at 05:47:50PM +0800, Jacob Chen wrote:
> >> This patch series add a ISP(Camera) v4l2 driver for rockchip rk3288/rk3399
> >> SoC.
> >>
> >> Wiki Pages:
> >> http://opensource.rock-chips.com/wiki_Rockchip-isp1
> >>
> >> The deprecated g_mbus_config op is not dropped in  V6 because i am waiting
> >> tomasz's patches.
> >
> > Which tree is this series based on? On top of v4.16-rc4 I get the build
> > failure below. The V4L2_BUF_TYPE_META_OUTPUT macro, for example, is not even
> > in media_tree.git.
> 
> This series is based on v4.16-rc4 with below patch.
> https://patchwork.kernel.org/patch/9792001/

This patch does not apply on v4.16-rc4. I also tried v2 of this patch with the 
same result:

  https://patchwork.linuxtv.org/patch/44682/

Can you push your series to a public git repo branch?

Thanks,
baruch

> > drivers/media/platform/rockchip/isp1/isp_params.c:1321:3: error: ‘const 
> > struct v4l2_ioctl_ops’ has no member named ‘vidioc_enum_fmt_meta_out’; did 
> > you mean ‘vidioc_enum_fmt_meta_cap’?
> >   .vidioc_enum_fmt_meta_out = rkisp1_params_enum_fmt_meta_out,
> >^~~~
> >vidioc_enum_fmt_meta_cap
> > drivers/media/platform/rockchip/isp1/isp_params.c:1321:30: error: 
> > initialization from incompatible pointer type 
> > [-Werror=incompatible-pointer-types]
> >   .vidioc_enum_fmt_meta_out = rkisp1_params_enum_fmt_meta_out,
> >   ^~~
> > drivers/media/platform/rockchip/isp1/isp_params.c:1321:30: note: (near 
> > initialization for ‘rkisp1_params_ioctl.vidioc_g_std’)
> > drivers/media/platform/rockchip/isp1/isp_params.c:1322:3: error: ‘const 
> > struct v4l2_ioctl_ops’ has no member named ‘vidioc_g_fmt_meta_out’; did you 
> > mean ‘vidioc_g_fmt_meta_cap’?
> >   .vidioc_g_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> >^
> >vidioc_g_fmt_meta_cap
> > drivers/media/platform/rockchip/isp1/isp_params.c:1322:27: error: 
> > initialization from incompatible pointer type 
> > [-Werror=incompatible-pointer-types]
> >   .vidioc_g_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> >^~~~
> > drivers/media/platform/rockchip/isp1/isp_params.c:1322:27: note: (near 
> > initialization for ‘rkisp1_params_ioctl.vidioc_s_std’)
> > drivers/media/platform/rockchip/isp1/isp_params.c:1323:3: error: ‘const 
> > struct v4l2_ioctl_ops’ has no member named ‘vidioc_s_fmt_meta_out’; did you 
> > mean ‘vidioc_s_fmt_meta_cap’?
> >   .vidioc_s_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> >^
> >vidioc_s_fmt_meta_cap
> > drivers/media/platform/rockchip/isp1/isp_params.c:1323:27: error: 
> > initialization from incompatible pointer type 
> > [-Werror=incompatible-pointer-types]
> >   .vidioc_s_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> >^~~~
> > drivers/media/platform/rockchip/isp1/isp_params.c:1323:27: note: (near 
> > initialization for ‘rkisp1_params_ioctl.vidioc_querystd’)
> > drivers/media/platform/rockchip/isp1/isp_params.c:1324:3: error: ‘const 
> > struct v4l2_ioctl_ops’ has no member named ‘vidioc_try_fmt_meta_out’; did 
> > you mean ‘vidioc_try_fmt_meta_cap’?
> >   .vidioc_try_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> >^~~
> >vidioc_try_fmt_meta_cap
> > drivers/media/platform/rockchip/isp1/isp_params.c:1324:29: error: 
> > initialization from incompatible pointer type 
> > [-Werror=incompatible-pointer-types]
> >   .vidioc_try_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> >  ^~~~
> > drivers/media/platform/rockchip/isp1/isp_params.c:1324:29: note: (near 
> > initialization for ‘rkisp1_params_ioctl.vidioc_enum_input’)
> > drivers/media/platform/rockchip/isp1/isp_params.c: In function 
> > ‘rkisp1_params_init_vb2_queue’:
> > drivers/media/platform/rockchip/isp1/isp_params.c:1462:12: error: 
> > ‘V4L2_BUF_TYPE_META_OUTPUT’ undeclared (first use in this function); did 
> > you mean ‘V4L2_BUF_TYPE_SDR_OUTPUT’?
> >   q->type = V4L2_BUF_TYPE_META_OUTPUT;
> > ^
> > V4L2_BUF_TYPE_SDR_OUTPUT
> > drivers/media/platform/rockchip/isp1/isp_params.c:1462:12: note: each 
> &g

Re: [PATCH v6 00/17] Rockchip ISP1 Driver

2018-03-08 Thread Baruch Siach
Hi Jacob,

On Thu, Mar 08, 2018 at 05:47:50PM +0800, Jacob Chen wrote:
> This patch series add a ISP(Camera) v4l2 driver for rockchip rk3288/rk3399 
> SoC.
> 
> Wiki Pages:
> http://opensource.rock-chips.com/wiki_Rockchip-isp1
> 
> The deprecated g_mbus_config op is not dropped in  V6 because i am waiting 
> tomasz's patches.

Which tree is this series based on? On top of v4.16-rc4 I get the build 
failure below. The V4L2_BUF_TYPE_META_OUTPUT macro, for example, is not even 
in media_tree.git.

drivers/media/platform/rockchip/isp1/isp_params.c:1321:3: error: ‘const struct 
v4l2_ioctl_ops’ has no member named ‘vidioc_enum_fmt_meta_out’; did you mean 
‘vidioc_enum_fmt_meta_cap’?
  .vidioc_enum_fmt_meta_out = rkisp1_params_enum_fmt_meta_out,
   ^~~~
   vidioc_enum_fmt_meta_cap
drivers/media/platform/rockchip/isp1/isp_params.c:1321:30: error: 
initialization from incompatible pointer type 
[-Werror=incompatible-pointer-types]
  .vidioc_enum_fmt_meta_out = rkisp1_params_enum_fmt_meta_out,
  ^~~
drivers/media/platform/rockchip/isp1/isp_params.c:1321:30: note: (near 
initialization for ‘rkisp1_params_ioctl.vidioc_g_std’)
drivers/media/platform/rockchip/isp1/isp_params.c:1322:3: error: ‘const struct 
v4l2_ioctl_ops’ has no member named ‘vidioc_g_fmt_meta_out’; did you mean 
‘vidioc_g_fmt_meta_cap’?
  .vidioc_g_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
   ^
   vidioc_g_fmt_meta_cap
drivers/media/platform/rockchip/isp1/isp_params.c:1322:27: error: 
initialization from incompatible pointer type 
[-Werror=incompatible-pointer-types]
  .vidioc_g_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
   ^~~~
drivers/media/platform/rockchip/isp1/isp_params.c:1322:27: note: (near 
initialization for ‘rkisp1_params_ioctl.vidioc_s_std’)
drivers/media/platform/rockchip/isp1/isp_params.c:1323:3: error: ‘const struct 
v4l2_ioctl_ops’ has no member named ‘vidioc_s_fmt_meta_out’; did you mean 
‘vidioc_s_fmt_meta_cap’?
  .vidioc_s_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
   ^
   vidioc_s_fmt_meta_cap
drivers/media/platform/rockchip/isp1/isp_params.c:1323:27: error: 
initialization from incompatible pointer type 
[-Werror=incompatible-pointer-types]
  .vidioc_s_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
   ^~~~
drivers/media/platform/rockchip/isp1/isp_params.c:1323:27: note: (near 
initialization for ‘rkisp1_params_ioctl.vidioc_querystd’)
drivers/media/platform/rockchip/isp1/isp_params.c:1324:3: error: ‘const struct 
v4l2_ioctl_ops’ has no member named ‘vidioc_try_fmt_meta_out’; did you mean 
‘vidioc_try_fmt_meta_cap’?
  .vidioc_try_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
   ^~~
   vidioc_try_fmt_meta_cap
drivers/media/platform/rockchip/isp1/isp_params.c:1324:29: error: 
initialization from incompatible pointer type 
[-Werror=incompatible-pointer-types]
  .vidioc_try_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
 ^~~~
drivers/media/platform/rockchip/isp1/isp_params.c:1324:29: note: (near 
initialization for ‘rkisp1_params_ioctl.vidioc_enum_input’)
drivers/media/platform/rockchip/isp1/isp_params.c: In function 
‘rkisp1_params_init_vb2_queue’:
drivers/media/platform/rockchip/isp1/isp_params.c:1462:12: error: 
‘V4L2_BUF_TYPE_META_OUTPUT’ undeclared (first use in this function); did you 
mean ‘V4L2_BUF_TYPE_SDR_OUTPUT’?
  q->type = V4L2_BUF_TYPE_META_OUTPUT;
^
V4L2_BUF_TYPE_SDR_OUTPUT
drivers/media/platform/rockchip/isp1/isp_params.c:1462:12: note: each 
undeclared identifier is reported only once for each function it appears in
  CC  drivers/media/platform/rockchip/isp1/mipi_dphy_sy.o
drivers/media/platform/rockchip/isp1/isp_params.c: In function 
‘rkisp1_register_params_vdev’:
drivers/media/platform/rockchip/isp1/isp_params.c:1507:43: error: 
‘V4L2_CAP_META_OUTPUT’ undeclared (first use in this function); did you mean 
‘V4L2_CAP_VBI_OUTPUT’?
  vdev->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_META_OUTPUT;
   ^~~~
   V4L2_CAP_VBI_OUTPUT

Thanks,
baruch

> Jacob Chen (12):
>   media: doc: add document for rkisp1 meta buffer format
>   media: rkisp1: add Rockchip MIPI Synopsys DPHY driver
>   media: rkisp1: add Rockchip ISP1 subdev driver
>   media: rkisp1: add ISP1 statistics driver
>   media: rkisp1: add ISP1 params driver
>   media: rkisp1: add capture device driver
>   media: rkisp1: add rockchip isp1 core driver
>   dt-bindings: Document the Rockchip ISP1 bindings
>   dt-bindings: Document the Rockchip MIPI RX D-PHY bindings
>   ARM: dts: rockchip: add isp node for rk3288
>   ARM: dts: rockchip: add rx0 mipi-phy for rk3288
>   MAINTAINERS: add entry for Rockchip ISP1 driver
> 
> Jeffy Chen (1):
>   

Re: v4l-utils fails to build against musl libc (with patch)

2018-03-07 Thread Baruch Siach
Hi Bjorn,

On Wed, Mar 07, 2018 at 12:14:05PM -0500, Bjorn Pagen wrote:
> Here's the link again and it's tinyurl, since the link seems to be
> borked because of line wraparounds:
> 
> https://git.alpinelinux.org/cgit/aports/tree/community/v4l-utils/0001-ir-ctl-fixes-for-musl-compile.patch
> https://tinyurl.com/y7gr6eju

Peter Seiderer posted a fix for that to the list a few days ago.

  https://www.mail-archive.com/linux-media@vger.kernel.org/msg127134.html

baruch

> On Wed, Mar 7, 2018 at 12:11 PM,   wrote:
> > Hey all,
> >
> > v4l-utils currently fails to build against musl libc, since musl, and
> > POSIX, both do not define TEMP_FAILURE_RETRY() or strndupa().
> >
> > This can be fixed with a small patch from https://git.alpinelinux.org/c
> > git/aports/tree/community/v4l-utils/0001-ir-ctl-fixes-for-musl-compile.
> > patch.
> >
> > Please email me back with any questions or concerns about the patch or
> > musl.
> >
> > Thanks,
> > Bjorn Pagen

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH v4 2/5] media: ov5695: add support for OV5695 sensor

2018-01-09 Thread Baruch Siach
Hi Shunqian Zheng,

On Tue, Jan 09, 2018 at 10:48:21PM +0800, Shunqian Zheng wrote:
> +static int ov5695_write_array(struct i2c_client *client,
> +   const struct regval *regs)
> +{
> + u32 i;
> + int ret = 0;
> +
> + for (i = 0; ret == 0 && regs[i].addr != REG_NULL; i++)
> + ret = ov5695_write_reg(client, regs[i].addr,
> +OV5695_REG_VALUE_08BIT, regs[i].val);

This loop should stop on first failure, and return the error value. With 
current code a register write failure is masked by following writes.

> +
> + return ret;
> +}

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH v3] media: ABS macro parameter parenthesization

2017-12-24 Thread Baruch Siach
Hi Dan,

On Sun, Dec 24, 2017 at 11:03:08PM -0500, Dan Gopstein wrote:
> From: Dan Gopstein 
> 
> Replace usages of the locally defined ABS() macro with calls to the
> canonical abs() from kernel.h and remove the old definitions of ABS()

The note about some wrong ABS() macro implementations that the previous patch 
version had is still useful, I believe.

baruch

> 
> Signed-off-by: Dan Gopstein 
> ---
> v2->v3:
> * replace local ABS() with kernel's abs()
> 
> v1->v2:
> * unmangled the patch
> * added example to commit text
> 
>  drivers/media/dvb-frontends/dib0090.c| 4 ++--
>  drivers/media/dvb-frontends/dib7000p.c   | 2 +-
>  drivers/media/dvb-frontends/dib8000.c| 2 +-
>  drivers/media/dvb-frontends/dibx000_common.h | 2 --
>  drivers/media/dvb-frontends/mb86a16.c| 8 +++-
>  drivers/media/dvb-frontends/stv0367_priv.h   | 1 -
>  drivers/media/dvb-frontends/stv0900_priv.h   | 1 -
>  drivers/media/dvb-frontends/stv0900_sw.c | 6 +++---
>  8 files changed, 10 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/dib0090.c 
> b/drivers/media/dvb-frontends/dib0090.c
> index d9d730d..633a961 100644
> --- a/drivers/media/dvb-frontends/dib0090.c
> +++ b/drivers/media/dvb-frontends/dib0090.c
> @@ -1285,7 +1285,7 @@ int dib0090_gain_control(struct dvb_frontend *fe)
>  #endif
>  
>   if (*tune_state == CT_AGC_STEP_1) { /* quickly go 
> to the correct range of the ADC power */
> - if (ABS(adc_error) < 50 || state->agc_step++ > 
> 5) {
> + if (abs(adc_error) < 50 || state->agc_step++ > 
> 5) {
>  
>  #ifdef CONFIG_STANDARD_DAB
>   if 
> (state->fe->dtv_property_cache.delivery_system == STANDARD_DAB) {
> @@ -1754,7 +1754,7 @@ static int dib0090_dc_offset_calibration(struct 
> dib0090_state *state, enum front
>   *tune_state = CT_TUNER_STEP_1;
>   } else {
>   /* the minimum was what we have seen in the step before 
> */
> - if (ABS(state->adc_diff) > ABS(state->min_adc_diff)) {
> + if (abs(state->adc_diff) > abs(state->min_adc_diff)) {
>   dprintk("Since adc_diff N = %d  > adc_diff step 
> N-1 = %d, Come back one step\n", state->adc_diff, state->min_adc_diff);
>   state->step--;
>   }
> diff --git a/drivers/media/dvb-frontends/dib7000p.c 
> b/drivers/media/dvb-frontends/dib7000p.c
> index 0fbaabe..6fc34b3 100644
> --- a/drivers/media/dvb-frontends/dib7000p.c
> +++ b/drivers/media/dvb-frontends/dib7000p.c
> @@ -809,7 +809,7 @@ static int dib7000p_set_dds(struct dib7000p_state *state, 
> s32 offset_khz)
>  {
>   u32 internal = dib7000p_get_internal_freq(state);
>   s32 unit_khz_dds_val;
> - u32 abs_offset_khz = ABS(offset_khz);
> + u32 abs_offset_khz = abs(offset_khz);
>   u32 dds = state->cfg.bw->ifreq & 0x1ff;
>   u8 invert = !!(state->cfg.bw->ifreq & (1 << 25));
>   if (internal == 0) {
> diff --git a/drivers/media/dvb-frontends/dib8000.c 
> b/drivers/media/dvb-frontends/dib8000.c
> index 5d93815..4680a8b 100644
> --- a/drivers/media/dvb-frontends/dib8000.c
> +++ b/drivers/media/dvb-frontends/dib8000.c
> @@ -2677,7 +2677,7 @@ static void dib8000_viterbi_state(struct dib8000_state 
> *state, u8 onoff)
>  static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz)
>  {
>   s16 unit_khz_dds_val;
> - u32 abs_offset_khz = ABS(offset_khz);
> + u32 abs_offset_khz = abs(offset_khz);
>   u32 dds = state->cfg.pll->ifreq & 0x1ff;
>   u8 invert = !!(state->cfg.pll->ifreq & (1 << 25));
>   u8 ratio;
> diff --git a/drivers/media/dvb-frontends/dibx000_common.h 
> b/drivers/media/dvb-frontends/dibx000_common.h
> index 8784af9..12b58f5 100644
> --- a/drivers/media/dvb-frontends/dibx000_common.h
> +++ b/drivers/media/dvb-frontends/dibx000_common.h
> @@ -223,8 +223,6 @@ struct dvb_frontend_parametersContext {
>  
>  #define FE_CALLBACK_TIME_NEVER 0x
>  
> -#define ABS(x) ((x < 0) ? (-x) : (x))
> -
>  #define DATA_BUS_ACCESS_MODE_8BIT 0x01
>  #define DATA_BUS_ACCESS_MODE_16BIT0x02
>  #define DATA_BUS_ACCESS_MODE_NO_ADDRESS_INCREMENT 0x10
> diff --git a/drivers/media/dvb-frontends/mb86a16.c 
> b/drivers/media/dvb-frontends/mb86a16.c
> index dfe322e..ced59f9 100644
> --- a/drivers/media/dvb-frontends/mb86a16.c
> +++ b/drivers/media/dvb-frontends/mb86a16.c
> @@ -31,8 +31,6 @@
>  static unsigned int verbose = 5;
>  module_param(verbose, int, 0644);
>  
> -#define ABS(x)   ((x) < 0 ? (-x) : (x))
> -
>  struct mb86a16_state {
>   struct i2c_adapter  *i2c_adap;
>   const struct mb86a16_config *config;
> @@ -1201,12 +1199,12 @@ static int mb86a16_set_fe(struct mb86a16_state *state)
>  
>   signal_dupl = 0;

Re: [PATCH 1/2] media: dt-bindings: coda: Add compatible for CodaHx4 on i.MX51

2017-12-13 Thread Baruch Siach
Hi Philipp,

On Wed, Dec 13, 2017 at 03:09:17PM +0100, Philipp Zabel wrote:
> Add a compatible for the CodaHx4 VPU used on i.MX51.
> 
> Signed-off-by: Philipp Zabel 
> ---
>  Documentation/devicetree/bindings/media/coda.txt | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/coda.txt 
> b/Documentation/devicetree/bindings/media/coda.txt
> index 2865d04e40305..660f5ecf2a23b 100644
> --- a/Documentation/devicetree/bindings/media/coda.txt
> +++ b/Documentation/devicetree/bindings/media/coda.txt
> @@ -7,6 +7,7 @@ called VPU (Video Processing Unit).
>  Required properties:
>  - compatible : should be "fsl,-src" for i.MX SoCs:
>(a) "fsl,imx27-vpu" for CodaDx6 present in i.MX27
> +  (a) "fsl,imx51-vpu" for CodaHx4 present in i.MX51

Renumbering the strings might be useful.

>(b) "fsl,imx53-vpu" for CODA7541 present in i.MX53
>(c) "fsl,imx6q-vpu" for CODA960 present in i.MX6q
>  - reg: should be register base and length as documented in the

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


Re: [PATCH] media: ABS macro parameter parenthesization

2017-11-16 Thread Baruch Siach
Hi Dan,

On Thu, Nov 16, 2017 at 06:09:20PM -0500, Dan Gopstein wrote:
> From: Dan Gopstein 
> 
> Two definitions of the ABS (absolute value) macro fail to parenthesize their
> parameter properly. This can lead to a bad expansion for low-precedence
> expression arguments. Add parens to protect against troublesome arguments.
> 
> Signed-off-by: Dan Gopstein 
> ---
> See an example bad usage in
> drivers/media/dvb-frontends/mb86a16.c b/drivers/media/dvb-frontends/mb86a16.c
> on line 1204:
> 
> ABS(prev_swp_freq[j] - swp_freq)
>
> For example: ABS(1-2) currently expands to ((1-2) < 0 ? (-1-2) : (1-2)) which
> evaluates to -3. But the correct expansion would be ((1-2) < 0 ? -(1-2) : 
> (1-2))
> which evaluates to 1.

This example would be nice to have in the commit log.

> I found this issue as part of the "Atoms of Confusion" research at NYU's 
> Secure
> Systems Lab. As the work continues, hopefully we'll be able to find more 
> issues
> like this one.
> 
> diff --git a/drivers/media/dvb-frontends/dibx000_common.h
> b/drivers/media/dvb-frontends/dibx000_common.h

Unfortunately, your email client (gmail?) mangled the patch by splitting lines 
like the above. So 'git am', or the 'patch' utility can't apply your patch as 
is.

I suggest you to use 'git send-email' to send patches. You can find gmail 
specific setup instructions in the git-send-email man page[1] under EXAMPLE.

[1] https://git-scm.com/docs/git-send-email

baruch

> index 8784af9..ae60f5d 100644
> --- a/drivers/media/dvb-frontends/dibx000_common.h
> +++ b/drivers/media/dvb-frontends/dibx000_common.h
> @@ -223,7 +223,7 @@ struct dvb_frontend_parametersContext {
> 
> #define FE_CALLBACK_TIME_NEVER 0x
> 
> -#define ABS(x) ((x < 0) ? (-x) : (x))
> +#define ABS(x) (((x) < 0) ? -(x) : (x))
> 
> #define DATA_BUS_ACCESS_MODE_8BIT 0x01
> #define DATA_BUS_ACCESS_MODE_16BIT0x02
> diff --git a/drivers/media/dvb-frontends/mb86a16.c
> b/drivers/media/dvb-frontends/mb86a16.c
> index dfe322e..2d921c7 100644
> --- a/drivers/media/dvb-frontends/mb86a16.c
> +++ b/drivers/media/dvb-frontends/mb86a16.c
> @@ -31,7 +31,7 @@
> static unsigned int verbose = 5;
> module_param(verbose, int, 0644);
> 
> -#define ABS(x) ((x) < 0 ? (-x) : (x))
> +#define ABS(x) ((x) < 0 ? -(x) : (x))
> 
> struct mb86a16_state {
> struct i2c_adapter  *i2c_adap;

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


[PATCH 2/3] edid-decode: detailed_block: fix maybe uninitialized warning

2017-09-26 Thread Baruch Siach
Fix the following warnings:

edid-decode.c: In function ‘detailed_block’:
edid-decode.c:394:2: warning: ‘width’ may be used uninitialized in this 
function [-Wmaybe-uninitialized]
edid-decode.c:394:2: warning: ‘ratio’ may be used uninitialized in this 
function [-Wmaybe-uninitialized]

Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
 edid-decode.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/edid-decode.c b/edid-decode.c
index 3df35ec6d07f..4abd79333d61 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -348,6 +348,10 @@ detailed_cvt_descriptor(unsigned char *x, int first)
width = 8 * (((height * 15) / 9) / 8);
ratio = "15:9";
break;
+default:
+   width = 0;
+   ratio = "unknown";
+   break;
 }
 
 if (x[1] & 0x03)
-- 
2.14.1



[PATCH 1/3] edid-decode: parse_cta: fix maybe uninitialized warning

2017-09-26 Thread Baruch Siach
Fix the following warning:

edid-decode.c: In function ‘parse_cta’:
edid-decode.c:142:5: warning: ‘v’ may be used uninitialized in this function 
[-Wmaybe-uninitialized]

Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
 edid-decode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 5592227d1db5..3df35ec6d07f 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -124,7 +124,7 @@ struct field {
 static void
 decode_value(struct field *field, int val, const char *prefix)
 {
-struct value *v;
+struct value *v = NULL;
 int i;
 
 for (i = 0; i < field->n_values; i++) {
@@ -139,7 +139,8 @@ decode_value(struct field *field, int val, const char 
*prefix)
return;
 }
 
-printf("%s%s: %s (%d)\n", prefix, field->name, v->description, val);
+printf("%s%s: %s (%d)\n", prefix, field->name,
+ v ? v->description : "unknown", val);
 }
 
 static void
-- 
2.14.1



[PATCH 3/3] edid-decode: parse_extension: fix maybe uninitialized warning

2017-09-26 Thread Baruch Siach
Fix the following warning:

edid-decode.c: In function ‘main’:
edid-decode.c:2962:26: warning: ‘conformant_extension’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
 edid-decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/edid-decode.c b/edid-decode.c
index 4abd79333d61..d3aafa926900 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -2397,7 +2397,7 @@ extension_version(unsigned char *x)
 static int
 parse_extension(unsigned char *x)
 {
-int conformant_extension;
+int conformant_extension = 0;
 printf("\n");
 
 switch(x[0]) {
-- 
2.14.1



Re: [PATCH v2 1/3] media: V3s: Add support for Allwinner CSI.

2017-07-30 Thread Baruch Siach
Hi Yong,

On Mon, Jul 31, 2017 at 09:48:06AM +0800, Yong wrote:
> On Sun, 30 Jul 2017 09:08:01 +0300
> Baruch Siach <bar...@tkos.co.il> wrote:
> > On Fri, Jul 28, 2017 at 06:02:33PM +0200, Maxime Ripard wrote:
> > > On Thu, Jul 27, 2017 at 01:01:35PM +0800, Yong Deng wrote:
> > > > +   regmap_write(sdev->regmap, CSI_CH_F0_BUFA_REG,
> > > > +(bus_addr + sdev->planar_offset[0]) >> 2);
> > 
> > Why do you need the bit shift? Does that work for you?
> > 
> > The User Manuals of both the V3s and the and the A33 (AKA R16) state that 
> > the 
> > BUFA field size in this register is 31:00, that is 32bit. I have found no 
> > indication of this bit shift in the Olimex provided sunxi-vfe[1] driver. On 
> > the A33 I have found that only after removing the bit-shift, (some sort of) 
> > data started to appear in the buffer.
> > 
> > [1] 
> > https://github.com/hehopmajieh/a33_linux/tree/master/drivers/media/video/sunxi-vfe
> 
> The Users Manuals do not document this bit shift. You should see line 10 to
> 32 in 
> https://github.com/hehopmajieh/a33_linux/blob/master/drivers/media/video/sunxi-vfe/csi/csi_reg.c

Thanks. So for my reference, the SoCs that don't need bit shift are A31, A23, 
and A33. SoCs that need bit shift are A80, A83, H3, and V3s (AKA V30).

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH v2 1/3] media: V3s: Add support for Allwinner CSI.

2017-07-30 Thread Baruch Siach
Hi Maxime, Yong,

On Fri, Jul 28, 2017 at 06:02:33PM +0200, Maxime Ripard wrote:
> Hi, 
> 
> Thanks for the second iteration!
> 
> On Thu, Jul 27, 2017 at 01:01:35PM +0800, Yong Deng wrote:
> > Allwinner V3s SoC have two CSI module. CSI0 is used for MIPI interface
> > and CSI1 is used for parallel interface. This is not documented in
> > datasheet but by testing and guess.
> > 
> > This patch implement a v4l2 framework driver for it.
> > 
> > Currently, the driver only support the parallel interface. MIPI-CSI2,
> > ISP's support are not included in this patch.
> > 
> > Signed-off-by: Yong Deng 

[...]

> > +#ifdef DEBUG
> > +static void sun6i_csi_dump_regs(struct sun6i_csi_dev *sdev)
> > +{
> > +   struct regmap *regmap = sdev->regmap;
> > +   u32 val;
> > +
> > +   regmap_read(regmap, CSI_EN_REG, );
> > +   printk("CSI_EN_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_IF_CFG_REG, );
> > +   printk("CSI_IF_CFG_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CAP_REG, );
> > +   printk("CSI_CAP_REG=0x%x\n",val);
> > +   regmap_read(regmap, CSI_SYNC_CNT_REG, );
> > +   printk("CSI_SYNC_CNT_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_FIFO_THRS_REG, );
> > +   printk("CSI_FIFO_THRS_REG=0x%x\n",  val);
> > +   regmap_read(regmap, CSI_PTN_LEN_REG, );
> > +   printk("CSI_PTN_LEN_REG=0x%x\n",val);
> > +   regmap_read(regmap, CSI_PTN_ADDR_REG, );
> > +   printk("CSI_PTN_ADDR_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_VER_REG, );
> > +   printk("CSI_VER_REG=0x%x\n",val);
> > +   regmap_read(regmap, CSI_CH_CFG_REG, );
> > +   printk("CSI_CH_CFG_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_SCALE_REG, );
> > +   printk("CSI_CH_SCALE_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_F0_BUFA_REG, );
> > +   printk("CSI_CH_F0_BUFA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_F1_BUFA_REG, );
> > +   printk("CSI_CH_F1_BUFA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_F2_BUFA_REG, );
> > +   printk("CSI_CH_F2_BUFA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_STA_REG, );
> > +   printk("CSI_CH_STA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_INT_EN_REG, );
> > +   printk("CSI_CH_INT_EN_REG=0x%x\n",  val);
> > +   regmap_read(regmap, CSI_CH_INT_STA_REG, );
> > +   printk("CSI_CH_INT_STA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_FLD1_VSIZE_REG, );
> > +   printk("CSI_CH_FLD1_VSIZE_REG=0x%x\n",  val);
> > +   regmap_read(regmap, CSI_CH_HSIZE_REG, );
> > +   printk("CSI_CH_HSIZE_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_VSIZE_REG, );
> > +   printk("CSI_CH_VSIZE_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_BUF_LEN_REG, );
> > +   printk("CSI_CH_BUF_LEN_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_FLIP_SIZE_REG, );
> > +   printk("CSI_CH_FLIP_SIZE_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_FRM_CLK_CNT_REG, );
> > +   printk("CSI_CH_FRM_CLK_CNT_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_ACC_ITNL_CLK_CNT_REG, );
> > +   printk("CSI_CH_ACC_ITNL_CLK_CNT_REG=0x%x\n",val);
> > +   regmap_read(regmap, CSI_CH_FIFO_STAT_REG, );
> > +   printk("CSI_CH_FIFO_STAT_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_PCLK_STAT_REG, );
> > +   printk("CSI_CH_PCLK_STAT_REG=0x%x\n",   val);
> > +}
> > +#endif
> 
> You can already dump a regmap through debugfs, that's redundant.

The advantage of in-code registers dump routine is the ability to synchronize 
the snapshot with the driver code execution. This is particularly important 
for the capture statistics registers. I have found it useful here.

[...]

> > +static int update_buf_addr(struct sun6i_csi *csi, dma_addr_t addr)
> > +{
> > +   struct sun6i_csi_dev *sdev = sun6i_csi_to_dev(csi);
> > +   /* transform physical address to bus address */
> > +   dma_addr_t bus_addr = addr - 0x4000;
> 
> Like Baruch noticed, you should use PHYS_OFFSET here. The A80 for
> example has a different RAM base address.
> 
> > +
> > +   regmap_write(sdev->regmap, CSI_CH_F0_BUFA_REG,
> > +(bus_addr + sdev->planar_offset[0]) >> 2);

Why do you need the bit shift? Does that work for you?

The User Manuals of both the V3s and the and the A33 (AKA R16) state that the 
BUFA field size in this register is 31:00, that is 32bit. I have found no 
indication of this bit shift in the Olimex provided sunxi-vfe[1] driver. On 
the A33 I have found that only after removing the bit-shift, (some sort of) 
data started to appear in the buffer.

[1] 
https://github.com/hehopmajieh/a33_linux/tree/master/drivers/media/video/sunxi-vfe

[...]

> > +static irqreturn_t sun6i_csi_isr(int irq, void *dev_id)
> > +{
> > +   struct sun6i_csi_dev *sdev = (struct sun6i_csi_dev *)dev_id;
> > +   struct regmap *regmap = sdev->regmap;
> > +   u32 status;
> > +
> > +   regmap_read(regmap, CSI_CH_INT_STA_REG, );
> > +
> > +   if ((status & 

Re: [PATCH v2 1/3] media: V3s: Add support for Allwinner CSI.

2017-07-27 Thread Baruch Siach
Hi Yong,

I managed to get the Frame Done interrupt with the previous version of this 
driver on the A33 OLinuXino. No data yet (all zeros). I'm still working on it.

One comment below.

On Thu, Jul 27, 2017 at 01:01:35PM +0800, Yong Deng wrote:
> Allwinner V3s SoC have two CSI module. CSI0 is used for MIPI interface
> and CSI1 is used for parallel interface. This is not documented in
> datasheet but by testing and guess.
> 
> This patch implement a v4l2 framework driver for it.
> 
> Currently, the driver only support the parallel interface. MIPI-CSI2,
> ISP's support are not included in this patch.
> 
> Signed-off-by: Yong Deng 
> ---

[...]

> +static int update_buf_addr(struct sun6i_csi *csi, dma_addr_t addr)
> +{
> + struct sun6i_csi_dev *sdev = sun6i_csi_to_dev(csi);
> + /* transform physical address to bus address */
> + dma_addr_t bus_addr = addr - 0x4000;

What is the source of this magic number? Is it platform dependent? Are there 
other devices doing DMA that need this adjustment?

baruch

> +
> + regmap_write(sdev->regmap, CSI_CH_F0_BUFA_REG,
> +  (bus_addr + sdev->planar_offset[0]) >> 2);
> + if (sdev->planar_offset[1] != -1)
> + regmap_write(sdev->regmap, CSI_CH_F1_BUFA_REG,
> +  (bus_addr + sdev->planar_offset[1]) >> 2);
> + if (sdev->planar_offset[2] != -1)
> + regmap_write(sdev->regmap, CSI_CH_F2_BUFA_REG,
> +  (bus_addr + sdev->planar_offset[2]) >> 2);
> +
> + return 0;
> +}

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH RFC 2/2] dt-bindings: add binding documentation for Allwinner CSI

2017-07-19 Thread Baruch Siach
Hi Yong,

On Wed, Jul 19, 2017 at 02:21:20PM +0800, Yong wrote:
> On Wed, 19 Jul 2017 07:49:23 +0300
> Baruch Siach <bar...@tkos.co.il> wrote:
> > On Wed, Jul 19, 2017 at 09:22:49AM +0800, Yong wrote:
> > > I am waiting for more comments for the sunxi-csi.h. It's pleasure if
> > > you have any suggestions about it.
> > 
> > You mean sunxi_csi.h, right?
> 
> Yes. My spelling mistake.
> 
> > Why do you need the sunxi_csi_ops indirection? Do you expect to add 
> > alternative implementations of these ops at some point?
> 
> I want to seperate the sunxi_video.c and sunxi_csi_v3s.c. 
> sunxi_csi_v3s.c is Soc specific. Maybe there will be sunxi_csi_r40.c
> in the futrue. But the sunxi_video.c and sunxi_csi.c are common.

I'd say it is a premature optimization. The file separation is fine, IMO, but 
the added csi_ops indirection makes the code less readable. Someone with 
access to R40 hardware with CSI setup would be a better position to abstract 
the platform specific code.

But I'd defer to the media maintainers on that.

Thanks,
baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


Re: [PATCH RFC 2/2] dt-bindings: add binding documentation for Allwinner CSI

2017-07-18 Thread Baruch Siach
Hi Yong,

On Wed, Jul 19, 2017 at 09:22:49AM +0800, Yong wrote:
> On Tue, 18 Jul 2017 14:55:30 +0300
> Baruch Siach <bar...@tkos.co.il> wrote:
> > I am trying to get this driver working on the Olimex A33 OLinuXino. I 
> > didn't get it working yet, but I had some progress. See the comment below 
> > on one issue I encountered.
> > 
> > On Tue, Jun 27, 2017 at 07:07:34PM +0800, Yong Deng wrote:
> > > Add binding documentation for Allwinner CSI.
> > > 
> > > Signed-off-by: Yong Deng <yong.d...@magewell.com>
> > > ---

[...]

> > > +Example:
> > > +
> > > + csi1: csi@01cb4000 {
> > > + compatible = "allwinner,sun8i-v3s-csi";
> > > + reg = <0x01cb4000 0x1000>;
> > 
> > You use platform_get_resource_byname() to get this IO resource. This 
> > requires 
> > adding mandatory
> > 
> >   reg-names = "csi";
> > 
> > But is it actually needed? Wouldn't a simple platform_get_resource() be 
> > enough?
> 
> You are right.
> This will be fixed in the next version.
> I am waiting for more comments for the sunxi-csi.h. It's pleasure if
> you have any suggestions about it.

You mean sunxi_csi.h, right?

Why do you need the sunxi_csi_ops indirection? Do you expect to add 
alternative implementations of these ops at some point?

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


Re: [PATCH RFC 2/2] dt-bindings: add binding documentation for Allwinner CSI

2017-07-18 Thread Baruch Siach
Hi Yong,

I am trying to get this driver working on the Olimex A33 OLinuXino. I didn't 
get it working yet, but I had some progress. See the comment below on one 
issue I encountered.

On Tue, Jun 27, 2017 at 07:07:34PM +0800, Yong Deng wrote:
> Add binding documentation for Allwinner CSI.
> 
> Signed-off-by: Yong Deng 
> ---
>  .../devicetree/bindings/media/sunxi-csi.txt| 51 
> ++
>  1 file changed, 51 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/sunxi-csi.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/sunxi-csi.txt 
> b/Documentation/devicetree/bindings/media/sunxi-csi.txt
> new file mode 100644
> index 000..770be0e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/sunxi-csi.txt
> @@ -0,0 +1,51 @@
> +Allwinner V3s Camera Sensor Interface
> +--
> +
> +Required properties:
> +  - compatible: value must be "allwinner,sun8i-v3s-csi"
> +  - reg: base address and size of the memory-mapped region.
> +  - interrupts: interrupt associated to this IP
> +  - clocks: phandles to the clocks feeding the CSI
> +* ahb: the CSI interface clock
> +* mod: the CSI module clock
> +* ram: the CSI DRAM clock
> +  - clock-names: the clock names mentioned above
> +  - resets: phandles to the reset line driving the CSI
> +
> +- ports: A ports node with endpoint definitions as defined in
> +  Documentation/devicetree/bindings/media/video-interfaces.txt. The
> +  first port should be the input endpoints, the second one the outputs
> +
> +Example:
> +
> + csi1: csi@01cb4000 {
> + compatible = "allwinner,sun8i-v3s-csi";
> + reg = <0x01cb4000 0x1000>;

You use platform_get_resource_byname() to get this IO resource. This requires 
adding mandatory

  reg-names = "csi";

But is it actually needed? Wouldn't a simple platform_get_resource() be 
enough?

Thanks,
baruch

> + interrupts = ;
> + clocks = < CLK_BUS_CSI>,
> +  < CLK_CSI1_SCLK>,
> +  < CLK_DRAM_CSI>;
> + clock-names = "ahb", "mod", "ram";
> + resets = < RST_BUS_CSI>;
> +
> + port {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + /* Parallel bus endpoint */
> + csi1_0: endpoint@0 {
> + reg = <0>;
> + remote = <_1>;
> + bus-width = <16>;
> + data-shift = <0>;
> +
> + /* If hsync-active/vsync-active are missing,
> +embedded BT.656 sync is used */
> + hsync-active = <0>; /* Active low */
> + vsync-active = <0>; /* Active low */
> + data-active = <1>;  /* Active high */
> + pclk-sample = <1>;  /* Rising */
> + };
> + };
> + };
> +

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH] radio: wl1273: add check on core->write() return value

2017-06-21 Thread Baruch Siach
Hi Gustavi,

On Wed, Jun 21, 2017 at 11:01:22PM -0500, Gustavo A. R. Silva wrote:
> Check return value from call to core->write(), so in case of
> error print error message, jump to goto label fail and eventually
> return.
> 
> Addresses-Coverity-ID: 1226943
> Signed-off-by: Gustavo A. R. Silva 
> ---
>  drivers/media/radio/radio-wl1273.c | 15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/radio/radio-wl1273.c 
> b/drivers/media/radio/radio-wl1273.c
> index 7240223..17e82a9 100644
> --- a/drivers/media/radio/radio-wl1273.c
> +++ b/drivers/media/radio/radio-wl1273.c
> @@ -610,10 +610,21 @@ static int wl1273_fm_start(struct wl1273_device *radio, 
> int new_mode)
>   }
>   }
>  
> - if (radio->rds_on)
> + if (radio->rds_on) {
>   r = core->write(core, WL1273_RDS_DATA_ENB, 1);
> - else
> + if (r) {
> + dev_err(dev, "%s: RDS_DATA_ENB ON fails\n",
> + __func__);
> + goto fail;
> + }
> + } else {
>   r = core->write(core, WL1273_RDS_DATA_ENB, 0);
> + if (r) {
> + dev_err(dev, "%s: RDS_DATA_ENB OFF fails\n",
> + __func__);
> + goto fail;
> + }
> + }
>   } else {
>   dev_warn(dev, "%s: Illegal mode.\n", __func__);
>   }

An alternative that duplicates less code (untested):

r = core->write(core, WL1273_RDS_DATA_ENB, !!radio->rds_on);
if (r) {
dev_err(dev, "%s: RDS_DATA_ENB %s fails\n",
__func__, radio->rds_on ? "ON" : "OFF");
goto fail;
}

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


[PATCH] [media] doc: kapi: fix typo

2017-03-15 Thread Baruch Siach
Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
 Documentation/media/kapi/v4l2-core.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/media/kapi/v4l2-core.rst 
b/Documentation/media/kapi/v4l2-core.rst
index e9677150ed99..d8f6c46d26d5 100644
--- a/Documentation/media/kapi/v4l2-core.rst
+++ b/Documentation/media/kapi/v4l2-core.rst
@@ -1,4 +1,4 @@
-Video2Linux devices
+Video4Linux devices
 ---
 
 .. toctree::
-- 
2.11.0



Re: [PATCH] [media] coda: restore original firmware locations

2017-03-01 Thread Baruch Siach
Hi Philipp,

On Wed, Mar 01, 2017 at 04:36:25PM +0100, Philipp Zabel wrote:
> Recently, an unfinished patch was merged that added a third entry to the
> beginning of the array of firmware locations without changing the code
> to also look at the third element, thus pushing an old firmware location
> off the list.
> 
> Fixes: 8af7779f3cbc ("[media] coda: add Freescale firmware compatibility 
> location")
> Cc: Baruch Siach <bar...@tkos.co.il>
> Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>

Thanks for cleaning up after me.

Acked-by: Baruch Siach <bar...@tkos.co.il>

[snip]

> - if (dev->firmware == 1) {
> + if (dev->firmware > 0) {
>   /*
>* Since we can't suppress warnings for failed asynchronous
>* firmware requests, report that the fallback firmware was

I still think this is ugly, though.

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: PATCH: v4l-utils/utils/ir-ctl/irc-ctl.c: fix musl build

2017-02-20 Thread Baruch Siach
Hi Francesco,

On Mon, Feb 20, 2017 at 12:33:14PM +0100, Francesco wrote:
> This is my fist attempt to send a patch for v4l-utils project.
> I maintain v4l-utils package for Alpine Linux (www.alpinelinux.org), a
> musl-based distro.
> 
> This patch allows the build for v4l-utils by allowing alternatives to GLIBC
> assumptions.
> 
> Thanks for considering.

> From 71f399cb1399c35ff4ce165c2cec0fcd3256d34e Mon Sep 17 00:00:00 2001
> From: Francesco Colista 
> Date: Mon, 20 Feb 2017 10:16:01 +0100
> Subject: [PATCH] utils/ir-ctl/ir-ctl.c: fix build with musl library
> 
> This patch allows to build correctly v4l-utils on musl-based distributions.
> It provides alternative to glibc assumptions.
> ---
>  utils/ir-ctl/ir-ctl.c | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
> index bc58cee0..0bd0ddcc 100644
> --- a/utils/ir-ctl/ir-ctl.c
> +++ b/utils/ir-ctl/ir-ctl.c
> @@ -42,6 +42,20 @@
>  # define _(string) string
>  #endif
>  
> +#if !defined(__GLIBC__)

This might break other libc implementations. Instead, do

  #ifndef TEMP_FAILURE_RETRY

See 
https://git.busybox.net/buildroot/tree/package/libv4l/0002-ir-ctl-fixes-for-musl-compile.patch

> +
> +/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
> +   set to EINTR.  */
> +
> +# define TEMP_FAILURE_RETRY(expression) \
> +  (__extension__ 
>  \
> +({ long int __result;
>  \
> +   do __result = (long int) (expression);
>  \
> +   while (__result == -1L && errno == EINTR);
>  \
> +   __result; }))
> +
> +#endif
> +
>  # define N_(string) string

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH v3] [media] coda: add Freescale firmware compatibility location

2017-01-19 Thread Baruch Siach
Hi Philipp,

(Adding firmware loader maintainers to Cc).

On Thu, Jan 19, 2017 at 10:44:54AM +0100, Philipp Zabel wrote:
> On Wed, 2017-01-18 at 21:33 +0200, Baruch Siach wrote:
> > > - if (dev->firmware == 1) {
> > > + if (dev->firmware > 0) {
> > 
> > Why would vpu/vpu_fw_*.bin and v4l-coda960-*.bin be considered fallback 
> > firmware?
> 
> That was meant in the sense of a firmware loaded from fallback location.
> 
> See the comment below, I needed a string to tell the user that the
> preceding firmware not found error messages can be safely ignored. If
> you have an idea for better wording, feel free submit a change.
> 
> > >   /*  
> > >   
> > >* Since we can't suppress warnings for failed asynchronous
> > >* firmware requests, report that the fallback firmware was
> > >* found.
> > >*/
> > >   dev_info(>dev, "Using fallback firmware %s\n",
> > >dev->devtype->firmware[dev->firmware]);
> > >   }

For the context, we are talking about these boot time messages:

[2.152822] coda 204.vpu: Direct firmware load for vpu_fw_imx6q.bin 
failed with error -2
[2.162669] coda 204.vpu: Using fallback firmware vpu/vpu_fw_imx6q.bin

Looks bad. There must be a better way to load a firmware file from a few 
optional locations. Actually, this use of the 'cont' parameter of 
request_firmware_nowait() to retry firmware load does not look like the 
intended use for the callback.

How about extending the firmware loader to accept multiple possible firmware 
locations?

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] [media] coda: add Freescale firmware compatibility location

2017-01-18 Thread Baruch Siach
Hi Philipp,

On Wed, Jan 18, 2017 at 12:30:29PM +0100, Philipp Zabel wrote:
> On Sun, 2017-01-15 at 12:33 +0200, Baruch Siach wrote:
> > The Freescale provided imx-vpu looks for firmware files under 
> > /lib/firmware/vpu
> > by default. Make coda look there for firmware files to ease the update path.
> > 
> > Cc: Fabio Estevam <feste...@gmail.com>
> > Signed-off-by: Baruch Siach <bar...@tkos.co.il>
> > ---
> > v3: adjust the number of firmware locations in coda_devtype (kbuild test 
> > robot)
> > 
> > v2: add compatibility path; don't change existing path (Fabio)
> > ---
> >  drivers/media/platform/coda/coda-common.c | 4 
> >  drivers/media/platform/coda/coda.h| 2 +-
> >  2 files changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/platform/coda/coda-common.c 
> > b/drivers/media/platform/coda/coda-common.c
> > index 9e6bdafa16f5..ce0d00f3f3ba 100644
> > --- a/drivers/media/platform/coda/coda-common.c
> > +++ b/drivers/media/platform/coda/coda-common.c
> > @@ -2079,6 +2079,7 @@ static const struct coda_devtype coda_devdata[] = {
> > [CODA_IMX27] = {
> > .firmware = {
> > "vpu_fw_imx27_TO2.bin",
> > +   "vpu/vpu_fw_imx27_TO2.bin",
> > "v4l-codadx6-imx27.bin"
> > },
> > .product  = CODA_DX6,
> > @@ -2092,6 +2093,7 @@ static const struct coda_devtype coda_devdata[] = {
> > [CODA_IMX53] = {
> > .firmware = {
> > "vpu_fw_imx53.bin",
> > +   "vpu/vpu_fw_imx53.bin",
> > "v4l-coda7541-imx53.bin"
> > },
> > .product  = CODA_7541,
> > @@ -2106,6 +2108,7 @@ static const struct coda_devtype coda_devdata[] = {
> > [CODA_IMX6Q] = {
> > .firmware = {
> > "vpu_fw_imx6q.bin",
> > +   "vpu/vpu_fw_imx6q.bin",
> > "v4l-coda960-imx6q.bin"
> > },
> > .product  = CODA_960,
> > @@ -2120,6 +2123,7 @@ static const struct coda_devtype coda_devdata[] = {
> > [CODA_IMX6DL] = {
> > .firmware = {
> > "vpu_fw_imx6d.bin",
> > +   "vpu/vpu_fw_imx6d.bin",
> > "v4l-coda960-imx6dl.bin"
> > },
> > .product  = CODA_960,
> > diff --git a/drivers/media/platform/coda/coda.h 
> > b/drivers/media/platform/coda/coda.h
> > index 53f96661683c..8490bcb1fde2 100644
> > --- a/drivers/media/platform/coda/coda.h
> > +++ b/drivers/media/platform/coda/coda.h
> > @@ -50,7 +50,7 @@ enum coda_product {
> >  struct coda_video_device;
> >  
> >  struct coda_devtype {
> > -   char*firmware[2];
> > +   char*firmware[3];
> > enum coda_product   product;
> > const struct coda_codec *codecs;
> > unsigned intnum_codecs;
> 
> To increase the number of firmware paths, coda_fw_callback has to be
> modified, too. Otherwise it will just ignore firmware[2]:

Thanks for catching that. But shouldn't we make the firmware files list a NULL 
terminated array instead of spreading the array size knowledge all over the 
code?

I have one more question below.

>  static void coda_fw_callback(const struct firmware *fw, void *context)
>  {
>   struct coda_dev *dev = context;
>   struct platform_device *pdev = dev->plat_dev;
>   int i, ret;
> 
> - if (!fw && dev->firmware == 1) {
> + if (!fw && dev->firmware == 2) {
>   v4l2_err(>v4l2_dev, "firmware request failed\n");
>   goto put_pm;
>   }
>   if (!fw) {
> - dev->firmware = 1;
> + dev->firmware++;
>   coda_firmware_request(dev);
>   return;
>   }
> - if (dev->firmware == 1) {
> + if (dev->firmware > 0) {

Why would vpu/vpu_fw_*.bin and v4l-coda960-*.bin be considered fallback 
firmware?

>   /*  
>   
>* Since we can't suppress warnings for failed asynchronous
>* firmware requests, report that the fallback firmware was
>* found.
>*/
>   dev_info(>dev, "Using fallback firmware %s\n",
>dev->devtype->firmware[dev->firmware]);
>   }

Thanks,
baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] [media] coda: add Freescale firmware compatibility location

2017-01-15 Thread Baruch Siach
The Freescale provided imx-vpu looks for firmware files under /lib/firmware/vpu
by default. Make coda look there for firmware files to ease the update path.

Cc: Fabio Estevam <feste...@gmail.com>
Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
v3: adjust the number of firmware locations in coda_devtype (kbuild test robot)

v2: add compatibility path; don't change existing path (Fabio)
---
 drivers/media/platform/coda/coda-common.c | 4 
 drivers/media/platform/coda/coda.h| 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 9e6bdafa16f5..ce0d00f3f3ba 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -2079,6 +2079,7 @@ static const struct coda_devtype coda_devdata[] = {
[CODA_IMX27] = {
.firmware = {
"vpu_fw_imx27_TO2.bin",
+   "vpu/vpu_fw_imx27_TO2.bin",
"v4l-codadx6-imx27.bin"
},
.product  = CODA_DX6,
@@ -2092,6 +2093,7 @@ static const struct coda_devtype coda_devdata[] = {
[CODA_IMX53] = {
.firmware = {
"vpu_fw_imx53.bin",
+   "vpu/vpu_fw_imx53.bin",
"v4l-coda7541-imx53.bin"
},
.product  = CODA_7541,
@@ -2106,6 +2108,7 @@ static const struct coda_devtype coda_devdata[] = {
[CODA_IMX6Q] = {
.firmware = {
"vpu_fw_imx6q.bin",
+   "vpu/vpu_fw_imx6q.bin",
"v4l-coda960-imx6q.bin"
},
.product  = CODA_960,
@@ -2120,6 +2123,7 @@ static const struct coda_devtype coda_devdata[] = {
[CODA_IMX6DL] = {
.firmware = {
"vpu_fw_imx6d.bin",
+   "vpu/vpu_fw_imx6d.bin",
"v4l-coda960-imx6dl.bin"
},
.product  = CODA_960,
diff --git a/drivers/media/platform/coda/coda.h 
b/drivers/media/platform/coda/coda.h
index 53f96661683c..8490bcb1fde2 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -50,7 +50,7 @@ enum coda_product {
 struct coda_video_device;
 
 struct coda_devtype {
-   char*firmware[2];
+   char*firmware[3];
enum coda_product   product;
const struct coda_codec *codecs;
unsigned intnum_codecs;
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] [media] coda: add Freescale firmware compatibility location

2017-01-15 Thread Baruch Siach
The Freescale provided imx-vpu looks for firmware files under /lib/firmware/vpu
by default. Make coda look there for firmware files to ease the update path.

Cc: Fabio Estevam <feste...@gmail.com>
Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
v2: add compatibility path; don't change existing path (Fabio)
---
 drivers/media/platform/coda/coda-common.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 9e6bdafa16f5..ce0d00f3f3ba 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -2079,6 +2079,7 @@ static const struct coda_devtype coda_devdata[] = {
[CODA_IMX27] = {
.firmware = {
"vpu_fw_imx27_TO2.bin",
+   "vpu/vpu_fw_imx27_TO2.bin",
"v4l-codadx6-imx27.bin"
},
.product  = CODA_DX6,
@@ -2092,6 +2093,7 @@ static const struct coda_devtype coda_devdata[] = {
[CODA_IMX53] = {
.firmware = {
"vpu_fw_imx53.bin",
+   "vpu/vpu_fw_imx53.bin",
"v4l-coda7541-imx53.bin"
},
.product  = CODA_7541,
@@ -2106,6 +2108,7 @@ static const struct coda_devtype coda_devdata[] = {
[CODA_IMX6Q] = {
.firmware = {
"vpu_fw_imx6q.bin",
+   "vpu/vpu_fw_imx6q.bin",
"v4l-coda960-imx6q.bin"
},
.product  = CODA_960,
@@ -2120,6 +2123,7 @@ static const struct coda_devtype coda_devdata[] = {
[CODA_IMX6DL] = {
.firmware = {
"vpu_fw_imx6d.bin",
+   "vpu/vpu_fw_imx6d.bin",
"v4l-coda960-imx6dl.bin"
},
.product  = CODA_960,
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2] dt: bindings: Add support for CSI1 bus

2017-01-12 Thread Baruch Siach
Hi Pavel,

On Wed, Jan 11, 2017 at 11:53:35PM +0100, Pavel Machek wrote:
> From: Sakari Ailus 
> 
> In the vast majority of cases the bus type is known to the driver(s)
> since a receiver or transmitter can only support a single one. There
> are cases however where different options are possible.
> 
> The existing V4L2 OF support tries to figure out the bus type and
> parse the bus parameters based on that. This does not scale too well
> as there are multiple serial busses that share common properties.
> 
> Some hardware also supports multiple types of busses on the same
> interfaces.
> 
> Document the CSI1/CCP2 property strobe. It signifies the clock or
> strobe mode.
>  
> Signed-off-by: Sakari Ailus 
> Signed-off-by: Ivaylo Dimitrov 
> Signed-off-by: Pavel Machek 
> 
> diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
> b/Documentation/devicetree/bindings/media/video-interfaces.txt
> index 9cd2a36..08c4498 100644
> --- a/Documentation/devicetree/bindings/media/video-interfaces.txt
> +++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
> @@ -76,6 +76,11 @@ Optional endpoint properties
>mode horizontal and vertical synchronization signals are provided to the
>slave device (data source) by the master device (data sink). In the master
>mode the data source device is also the source of the synchronization 
> signals.
> +- bus-type: data bus type. Possible values are:
> +  0 - MIPI CSI2
> +  1 - parallel / Bt656

Why not have separate values for parallel and BT.656?

baruch

> +  2 - MIPI CSI1
> +  3 - CCP2
>  - bus-width: number of data lines actively used, valid for the parallel 
> busses.
>  - data-shift: on the parallel data busses, if bus-width is used to specify 
> the
>number of data lines, data-shift can be used to specify which data lines 
> are
> @@ -112,7 +117,8 @@ Optional endpoint properties
>should be the combined length of data-lanes and clock-lanes properties.
>If the lane-polarities property is omitted, the value must be interpreted
>as 0 (normal). This property is valid for serial busses only.
> -
> +- strobe: Whether the clock signal is used as clock or strobe. Used
> +  with CCP2, for instance.
>  
>  Example
>  ---

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] v4l2-subdev.h: fix v4l2_subdev_pad_config documentation

2017-01-04 Thread Baruch Siach
The fields of v4l2_subdev_pad_config are not pointers.

Fixes: 21c29de1d09 ("[media] v4l2-subdev.h: Improve documentation")
Cc: Mauro Carvalho Chehab <mche...@s-opensource.com>
Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
 include/media/v4l2-subdev.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index cf778c5dca18..0ab1c5df6fac 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -592,9 +592,9 @@ struct v4l2_subdev_ir_ops {
 /**
  * struct v4l2_subdev_pad_config - Used for storing subdev pad information.
  *
- * @try_fmt: pointer to  v4l2_mbus_framefmt
- * @try_crop: pointer to  v4l2_rect to be used for crop
- * @try_compose: pointer to  v4l2_rect to be used for compose
+ * @try_fmt:  v4l2_mbus_framefmt
+ * @try_crop:  v4l2_rect to be used for crop
+ * @try_compose:  v4l2_rect to be used for compose
  *
  * This structure only needs to be passed to the pad op if the 'which' field
  * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] adv7170: drop redundant ret local

2017-01-03 Thread Baruch Siach
Simplifies return value logic of adv7170_set_fmt().

Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
 drivers/media/i2c/adv7170.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index fc9ec0f3679c..9b0d6a4973c0 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -302,7 +302,6 @@ static int adv7170_set_fmt(struct v4l2_subdev *sd,
 {
struct v4l2_mbus_framefmt *mf = >format;
u8 val = adv7170_read(sd, 0x7);
-   int ret = 0;
 
if (format->pad)
return -EINVAL;
@@ -323,9 +322,9 @@ static int adv7170_set_fmt(struct v4l2_subdev *sd,
}
 
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
-   ret = adv7170_write(sd, 0x7, val);
+   return adv7170_write(sd, 0x7, val);
 
-   return ret;
+   return 0;
 }
 
 /* --- */
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] ov2659: remove NOP assignment

2017-01-03 Thread Baruch Siach
The loop over the ov2659_formats[] array just a few line above verifies that
mf->code matches the selected array entry.

Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
 drivers/media/i2c/ov2659.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 1f999e9c0118..6e6367214d40 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1121,7 +1121,6 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
return -EINVAL;
 
mf->colorspace = V4L2_COLORSPACE_SRGB;
-   mf->code = ov2659_formats[index].code;
mf->field = V4L2_FIELD_NONE;
 
mutex_lock(>lock);
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] coda: fix Freescale firmware location

2016-12-27 Thread Baruch Siach
Hi Fabio,

On Tue, Dec 27, 2016 at 09:26:16AM -0200, Fabio Estevam wrote:
> 2016-12-27 8:06 GMT-02:00 Baruch Siach <bar...@tkos.co.il>:
> > The Freescale provided imx-vpu looks for firmware files under 
> > /lib/firmware/vpu
> > by default. Make coda conform with that to ease the update path.
> >
> > Signed-off-by: Baruch Siach <bar...@tkos.co.il>
> > ---
> >  drivers/media/platform/coda/coda-common.c | 8 
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/platform/coda/coda-common.c 
> > b/drivers/media/platform/coda/coda-common.c
> > index 9e6bdafa16f5..140c02715855 100644
> > --- a/drivers/media/platform/coda/coda-common.c
> > +++ b/drivers/media/platform/coda/coda-common.c
> > @@ -2078,7 +2078,7 @@ enum coda_platform {
> >  static const struct coda_devtype coda_devdata[] = {
> > [CODA_IMX27] = {
> > .firmware = {
> > -   "vpu_fw_imx27_TO2.bin",
> > +   "vpu/vpu_fw_imx27_TO2.bin",
> > "v4l-codadx6-imx27.bin"
> > },
> 
> What about just adding the new path without removing the original one?
> This way we avoid breakage for the users that use
> "vpu_fw_imx27_TO2.bin" path.

I considered that. Support for Freescale provided firmware is quite new 
(v4.6+), so I was not sure that supporting the current location is worth the 
bloat. What do others think?

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] coda: fix Freescale firmware location

2016-12-27 Thread Baruch Siach
The Freescale provided imx-vpu looks for firmware files under /lib/firmware/vpu
by default. Make coda conform with that to ease the update path.

Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
 drivers/media/platform/coda/coda-common.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 9e6bdafa16f5..140c02715855 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -2078,7 +2078,7 @@ enum coda_platform {
 static const struct coda_devtype coda_devdata[] = {
[CODA_IMX27] = {
.firmware = {
-   "vpu_fw_imx27_TO2.bin",
+   "vpu/vpu_fw_imx27_TO2.bin",
"v4l-codadx6-imx27.bin"
},
.product  = CODA_DX6,
@@ -2091,7 +2091,7 @@ static const struct coda_devtype coda_devdata[] = {
},
[CODA_IMX53] = {
.firmware = {
-   "vpu_fw_imx53.bin",
+   "vpu/vpu_fw_imx53.bin",
"v4l-coda7541-imx53.bin"
},
.product  = CODA_7541,
@@ -2105,7 +2105,7 @@ static const struct coda_devtype coda_devdata[] = {
},
[CODA_IMX6Q] = {
.firmware = {
-   "vpu_fw_imx6q.bin",
+   "vpu/vpu_fw_imx6q.bin",
"v4l-coda960-imx6q.bin"
},
.product  = CODA_960,
@@ -2119,7 +2119,7 @@ static const struct coda_devtype coda_devdata[] = {
},
[CODA_IMX6DL] = {
.firmware = {
-   "vpu_fw_imx6d.bin",
+   "vpu/vpu_fw_imx6d.bin",
"v4l-coda960-imx6dl.bin"
},
.product  = CODA_960,
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] v4l2grab: print function name and ioctl number on failure

2015-08-12 Thread Baruch Siach
This makes the failure error message a little more useful.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 contrib/test/v4l2grab.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/test/v4l2grab.c b/contrib/test/v4l2grab.c
index 3e1be3de6353..778c51cc391a 100644
--- a/contrib/test/v4l2grab.c
+++ b/contrib/test/v4l2grab.c
@@ -43,7 +43,8 @@ static void xioctl(int fh, unsigned long int request, void 
*arg)
} while (r == -1  ((errno == EINTR) || (errno == EAGAIN)));
 
if (r == -1) {
-   fprintf(stderr, error %d, %s\n, errno, strerror(errno));
+   fprintf(stderr, %s(%lu): error %d, %s\n, __func__,
+   _IOC_NR(request), errno, strerror(errno));
exit(EXIT_FAILURE);
}
 }
-- 
2.5.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 04/10] V4L: Add driver for s5k6a3 image sensor

2014-02-25 Thread Baruch Siach
Hi Sylwester,

On Tue, Feb 25, 2014 at 10:46:58AM +0100, Sylwester Nawrocki wrote:
 On 24/02/14 20:38, Baruch Siach wrote:
  On Mon, Feb 24, 2014 at 06:35:16PM +0100, Sylwester Nawrocki wrote:
   This patch adds subdev driver for Samsung S5K6A3 raw image sensor.
   As it is intended at the moment to be used only with the Exynos
   FIMC-IS (camera ISP) subsystem it is pretty minimal subdev driver.
   It doesn't do any I2C communication since the sensor is controlled
   by the ISP and its own firmware.
   This driver, if needed, can be updated in future into a regular
   subdev driver where the main CPU communicates with the sensor
   directly.
   
   Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
   Acked-by: Kyungmin Park kyungmin.p...@samsung.com
 
  [...]
  
   +static int s5k6a3_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh 
   *fh)
   +{
   +struct v4l2_mbus_framefmt *format = 
   v4l2_subdev_get_try_format(fh, 0);
   +
   +*format = s5k6a3_formats[0];
   +format-width   = S5K6A3_DEFAULT_WIDTH;
   +format-height  = S5K6A3_DEFAULT_HEIGHT;
   +
   +return 0;
   +}
   +
   +static const struct v4l2_subdev_internal_ops s5k6a3_sd_internal_ops = {
   +.open = s5k6a3_open,
   +};
 
  Where is this used?
 
 This will be called when user process opens the corresponding /dev/v4l-subdev*
 device node. More details on the v4l2 sub-device interface can be found at 
 [1],
 [2]. The device node is created by an aggregate media device driver, once all
 required sub-devices are registered to it.
 The above v4l2_subdev_internal_ops::open() implementation is pretty simple,
 it just sets V4L2_SUBDEV_FORMAT_TRY format to some initial default value.
 That's a per file handle value, so each process opening a set of sub-devices
 can try pipeline configuration independently. 
 
 [1] http://linuxtv.org/downloads/v4l-dvb-apis/subdev.html
 [2] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-subdev-g-fmt.html

Thanks for the explanation. However, I've found no reference to the 
s5k6a3_sd_internal_ops struct in the driver code. There surly has to be at 
least one reference for the upper layer to access these ops.

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 04/10] V4L: Add driver for s5k6a3 image sensor

2014-02-24 Thread Baruch Siach
Hi Sylwester,

On Mon, Feb 24, 2014 at 06:35:16PM +0100, Sylwester Nawrocki wrote:
 This patch adds subdev driver for Samsung S5K6A3 raw image sensor.
 As it is intended at the moment to be used only with the Exynos
 FIMC-IS (camera ISP) subsystem it is pretty minimal subdev driver.
 It doesn't do any I2C communication since the sensor is controlled
 by the ISP and its own firmware.
 This driver, if needed, can be updated in future into a regular
 subdev driver where the main CPU communicates with the sensor
 directly.
 
 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Acked-by: Kyungmin Park kyungmin.p...@samsung.com

[...]

 +static int s5k6a3_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 +{
 + struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(fh, 0);
 +
 + *format = s5k6a3_formats[0];
 + format-width   = S5K6A3_DEFAULT_WIDTH;
 + format-height  = S5K6A3_DEFAULT_HEIGHT;
 +
 + return 0;
 +}
 +
 +static const struct v4l2_subdev_internal_ops s5k6a3_sd_internal_ops = {
 + .open = s5k6a3_open,
 +};

Where is this used?

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [v3] i.MX27: Fix emma-prp clocks in mx2_camera.c

2012-07-09 Thread Baruch Siach
Hi Javier,

On Mon, Jul 09, 2012 at 09:46:03AM +0200, javier Martin wrote:
 On 9 July 2012 09:43, Sascha Hauer s.ha...@pengutronix.de wrote:
  On Mon, Jul 09, 2012 at 09:37:25AM +0200, javier Martin wrote:
  On 9 July 2012 09:28, Sascha Hauer s.ha...@pengutronix.de wrote:
   On Fri, Jul 06, 2012 at 12:56:02PM +0200, Javier Martin wrote:
   This driver wasn't converted to the new clock changes
   (clk_prepare_enable/clk_disable_unprepare). Also naming
   of emma-prp related clocks for the i.MX27 was not correct.
   ---
   Enable clocks only for i.MX27.
  
   Indeed,
  
   - pcdev-clk_csi = clk_get(pdev-dev, NULL);
   - if (IS_ERR(pcdev-clk_csi)) {
   - dev_err(pdev-dev, Could not get csi clock\n);
   - err = PTR_ERR(pcdev-clk_csi);
   - goto exit_kfree;
   + if (cpu_is_mx27()) {
   + pcdev-clk_csi = devm_clk_get(pdev-dev, ahb);
   + if (IS_ERR(pcdev-clk_csi)) {
   + dev_err(pdev-dev, Could not get csi clock\n);
   + err = PTR_ERR(pcdev-clk_csi);
   + goto exit_kfree;
   + }
  
   but why? Now the i.MX25 won't get a clock anymore.
 
  What are the clocks needed by i.MX25? csi only?
 
  By the way, is anybody using this driver with i.MX25?
 
  It seems Baruch (added to Cc) has used it on an i.MX25.
 could you tell us what are the clocks needed by i.MX25?

According to the code the csi clock is sufficient for i.MX25. Unfortunately I 
don't have access to a running system anymore, so I can't test current code.

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] i.MX27: visstrim_m10: Remove use of MX2_CAMERA_SWAP16.

2012-03-26 Thread Baruch Siach
Hi Javier,

On Mon, Mar 26, 2012 at 01:20:04PM +0200, Javier Martin wrote:
 
 Signed-off-by: Javier Martin javier.mar...@vista-silicon.com
 ---
  arch/arm/mach-imx/mach-imx27_visstrim_m10.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c 
 b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
 index 3128cfe..4db00c6 100644
 --- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
 +++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
 @@ -164,7 +164,7 @@ static struct platform_device visstrim_tvp5150 = {
  
  
  static struct mx2_camera_platform_data visstrim_camera = {
 - .flags = MX2_CAMERA_CCIR | MX2_CAMERA_CCIR_INTERLACE | 
 MX2_CAMERA_SWAP16 | MX2_CAMERA_PCLK_SAMPLE_RISING,
 + .flags = MX2_CAMERA_CCIR | MX2_CAMERA_CCIR_INTERLACE | 
 MX2_CAMERA_PCLK_SAMPLE_RISING,
   .clk = 10,
  };

The order of the last two patches in this series should be switched to 
preserve bisectability.

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] media: video: mx2_camera: Remove ifdef's

2012-02-16 Thread Baruch Siach
Hi Fabio,

On Thu, Feb 16, 2012 at 04:25:39PM -0200, Fabio Estevam wrote:
 As we are able to build a same kernel that supports both mx27 and mx25, we 
 should remove
 the ifdef's for CONFIG_MACH_MX27 in the mx2_camera driver.
 
 Signed-off-by: Fabio Estevam fabio.este...@freescale.com

Acked-by: Baruch Siach bar...@tkos.co.il

baruch 

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] media i.MX27 camera: remove legacy dma support

2011-08-28 Thread Baruch Siach
Hi Guennadi,

On Wed, Aug 24, 2011 at 09:19:24AM +0200, Guennadi Liakhovetski wrote:
[snip]
 On Wed, 24 Aug 2011, Sascha Hauer wrote:
  The i.MX27 dma support was introduced with the initial commit of
  this driver and originally created by me. However, I never got
  this stable due to the racy dma engine and used the EMMA engine
  instead. As the DMA support is most probably unused and broken in
  its current state, remove it. This also helps us to get rid of
  another user of the legacy i.MX DMA support,
  Also, remove the dependency on ARCH_MX* macros as these are scheduled
  for removal.
  
  Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
  Cc: Baruch Siach bar...@tkos.co.il
  Cc: linux-media@vger.kernel.org
  Cc: Guennadi Liakhovetski g.liakhovet...@gmx.de
  ---

[snip]

 Baruch, any comment?

No comment so far. Thanks for your continued maintenance. I wish I could do 
the videobuf2 migration of this driver.

baruch

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mx2_camera: fix pixel clock polarity configuration

2010-12-02 Thread Baruch Siach
Hi Guennadi,

On Wed, Nov 17, 2010 at 08:09:09AM +0100, Guennadi Liakhovetski wrote:
 On Wed, 10 Nov 2010, Baruch Siach wrote:
  Guennadi Liakhovetski g.liakhovetski at gmx.de writes:
   On Wed, 27 Oct 2010, Baruch Siach wrote:
When SOCAM_PCLK_SAMPLE_FALLING, just leave CSICR1_REDGE unset, 
otherwise we get
the inverted behaviour.
   Seems logical to me, that if this is true, then you need the inverse:
   
 if (!(common_flags  SOCAM_PCLK_SAMPLE_FALLING))
 csicr1 |= CSICR1_INV_PCLK;
  
  No. Doing so you'll get the inverted behaviour of SAMPLE_RISING. When
  common_flags have SAMPLE_RISING set and SAMPLE_FALLING unset you get
  CSICR1_REDGE set, which triggers on the rising edge, and then also
  CSICR1_INV_PCLK set, which invert this. Thus you get the expected 
  behaviour of SAMPLE_FALLING.
  
  Currently you get the inverted behaviour only for SAMPLE_FALLING.
  
  IMO, we should just use CSICR1_REDGE to set the sample timing, and leave
  CSICR1_INV_PCLK alone.
 
 Ah, right, of course, I've overlooked that CSICR1_REDGE flag. Then yes, 
 your patch makes sense and should go in for 2.6.37.

Thanks. I now see that this patch is queued in the staging/for_v2.6.38 branch 
of media_tree.git. Is there any chance of seeing this fix in .37-rc?

Once this gets merged I want to forward it to .36 stable.

baruch

if (common_flags  SOCAM_PCLK_SAMPLE_RISING)
csicr1 |= CSICR1_REDGE;
-   if (common_flags  SOCAM_PCLK_SAMPLE_FALLING)
-   csicr1 |= CSICR1_INV_PCLK;
if (common_flags  SOCAM_VSYNC_ACTIVE_HIGH)
csicr1 |= CSICR1_SOF_POL;
if (common_flags  SOCAM_HSYNC_ACTIVE_HIGH)

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 38/51] ARM: imx: move mx25 support to mach-imx

2010-11-17 Thread Baruch Siach
Hi Uwe,

Tanks for all this work.

Once this get merged we can get rid of the ugly '#ifdef CONFIG_MACH_MX27' in 
drivers/media/video/mx2_camera.c. Should such a patch go via Sascha's tree or 
the V4L tree?

baruch

On Wed, Nov 17, 2010 at 10:30:06PM +0100, Uwe Kleine-König wrote:
 Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de
 ---
  arch/arm/Makefile  |2 +-
  arch/arm/mach-imx/Kconfig  |   85 +--
  arch/arm/mach-imx/Makefile |6 +
  arch/arm/mach-imx/Makefile.boot|4 +
  arch/arm/mach-imx/clock-imx25.c|  332 
 
  arch/arm/mach-imx/devices-imx25.h  |   86 ++
  arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c |  296 +
  arch/arm/mach-imx/mach-eukrea_cpuimx25.c   |  161 
  arch/arm/mach-imx/mach-mx25_3ds.c  |  223 
  arch/arm/mach-imx/mm-imx25.c   |   62 +
  arch/arm/mach-mx25/Kconfig |   43 ---
  arch/arm/mach-mx25/Makefile|5 -
  arch/arm/mach-mx25/Makefile.boot   |3 -
  arch/arm/mach-mx25/clock.c |  332 
 
  arch/arm/mach-mx25/devices-imx25.h |   86 --
  arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c  |  296 -
  arch/arm/mach-mx25/mach-cpuimx25.c |  161 
  arch/arm/mach-mx25/mach-mx25_3ds.c |  223 
  arch/arm/mach-mx25/mm.c|   62 -
  arch/arm/plat-mxc/Kconfig  |5 -
  20 files changed, 1240 insertions(+), 1233 deletions(-)
  create mode 100644 arch/arm/mach-imx/clock-imx25.c
  create mode 100644 arch/arm/mach-imx/devices-imx25.h
  create mode 100644 arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c
  create mode 100644 arch/arm/mach-imx/mach-eukrea_cpuimx25.c
  create mode 100644 arch/arm/mach-imx/mach-mx25_3ds.c
  create mode 100644 arch/arm/mach-imx/mm-imx25.c
  delete mode 100644 arch/arm/mach-mx25/Kconfig
  delete mode 100644 arch/arm/mach-mx25/Makefile
  delete mode 100644 arch/arm/mach-mx25/Makefile.boot
  delete mode 100644 arch/arm/mach-mx25/clock.c
  delete mode 100644 arch/arm/mach-mx25/devices-imx25.h
  delete mode 100644 arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
  delete mode 100644 arch/arm/mach-mx25/mach-cpuimx25.c
  delete mode 100644 arch/arm/mach-mx25/mach-mx25_3ds.c
  delete mode 100644 arch/arm/mach-mx25/mm.c

[snip]

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mx2_camera: fix pixel clock polarity configuration

2010-11-10 Thread Baruch Siach
Hi linux-media,

On Wed, Oct 27, 2010 at 09:03:52AM +0200, Baruch Siach wrote:
 When SOCAM_PCLK_SAMPLE_FALLING, just leave CSICR1_REDGE unset, otherwise we 
 get
 the inverted behaviour.
 
 Signed-off-by: Baruch Siach bar...@tkos.co.il

Trying my luck again. Now adding Guennadi to Cc.

This is a real bug fix, BTW.

baruch

 ---
  drivers/media/video/mx2_camera.c |2 --
  1 files changed, 0 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/video/mx2_camera.c 
 b/drivers/media/video/mx2_camera.c
 index 3ea2ec0..02f144f 100644
 --- a/drivers/media/video/mx2_camera.c
 +++ b/drivers/media/video/mx2_camera.c
 @@ -811,8 +811,6 @@ static int mx2_camera_set_bus_param(struct 
 soc_camera_device *icd,
  
   if (common_flags  SOCAM_PCLK_SAMPLE_RISING)
   csicr1 |= CSICR1_REDGE;
 - if (common_flags  SOCAM_PCLK_SAMPLE_FALLING)
 - csicr1 |= CSICR1_INV_PCLK;
   if (common_flags  SOCAM_VSYNC_ACTIVE_HIGH)
   csicr1 |= CSICR1_SOF_POL;
   if (common_flags  SOCAM_HSYNC_ACTIVE_HIGH)
 -- 

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mx2_camera: fix pixel clock polarity configuration

2010-11-10 Thread Baruch Siach
Guennadi Liakhovetski g.liakhovetski at gmx.de writes:

 On Wed, 27 Oct 2010, Baruch Siach wrote:
  When SOCAM_PCLK_SAMPLE_FALLING, just leave CSICR1_REDGE unset, 
  otherwise we get
  the inverted behaviour.
 Seems logical to me, that if this is true, then you need the inverse:
 
   if (!(common_flags  SOCAM_PCLK_SAMPLE_FALLING))
   csicr1 |= CSICR1_INV_PCLK;

No. Doing so you'll get the inverted behaviour of SAMPLE_RISING. When
common_flags have SAMPLE_RISING set and SAMPLE_FALLING unset you get
CSICR1_REDGE set, which triggers on the rising edge, and then also
CSICR1_INV_PCLK set, which invert this. Thus you get the expected 
behaviour of SAMPLE_FALLING.

Currently you get the inverted behaviour only for SAMPLE_FALLING.

IMO, we should just use CSICR1_REDGE to set the sample timing, and leave
CSICR1_INV_PCLK alone.

baruch

  if (common_flags  SOCAM_PCLK_SAMPLE_RISING)
  csicr1 |= CSICR1_REDGE;
  -   if (common_flags  SOCAM_PCLK_SAMPLE_FALLING)
  -   csicr1 |= CSICR1_INV_PCLK;
  if (common_flags  SOCAM_VSYNC_ACTIVE_HIGH)
  csicr1 |= CSICR1_SOF_POL;
  if (common_flags  SOCAM_HSYNC_ACTIVE_HIGH)


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] soc-camera: Compile fixes for mx2-camera

2010-11-08 Thread Baruch Siach
Hi Sascha,

On Mon, Nov 08, 2010 at 09:52:45PM +0100, Sascha Hauer wrote:
 mx2-camera got broken during the last merge window. This patch
 fixes this and removes some unused variables.
 
 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
 ---
  drivers/media/video/mx2_camera.c |   13 +
  1 files changed, 5 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/media/video/mx2_camera.c 
 b/drivers/media/video/mx2_camera.c
 index 4a27862..072bd2d 100644
 --- a/drivers/media/video/mx2_camera.c
 +++ b/drivers/media/video/mx2_camera.c
 @@ -31,6 +31,7 @@
  
  #include media/v4l2-common.h
  #include media/v4l2-dev.h
 +#include media/videobuf-core.h

What is this needed for? The driver seems to build without this hunk.

Other than that:

Acked-by: Baruch Siach bar...@tkos.co.il

  #include media/videobuf-dma-contig.h
  #include media/soc_camera.h
  #include media/soc_mediabus.h
 @@ -903,8 +904,6 @@ static int mx2_camera_set_crop(struct soc_camera_device 
 *icd,
  static int mx2_camera_set_fmt(struct soc_camera_device *icd,
  struct v4l2_format *f)
  {
 - struct soc_camera_host *ici = to_soc_camera_host(icd-dev.parent);
 - struct mx2_camera_dev *pcdev = ici-priv;
   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
   const struct soc_camera_format_xlate *xlate;
   struct v4l2_pix_format *pix = f-fmt.pix;
 @@ -943,8 +942,6 @@ static int mx2_camera_set_fmt(struct soc_camera_device 
 *icd,
  static int mx2_camera_try_fmt(struct soc_camera_device *icd,
 struct v4l2_format *f)
  {
 - struct soc_camera_host *ici = to_soc_camera_host(icd-dev.parent);
 - struct mx2_camera_dev *pcdev = ici-priv;
   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
   const struct soc_camera_format_xlate *xlate;
   struct v4l2_pix_format *pix = f-fmt.pix;
 @@ -1024,13 +1021,13 @@ static int mx2_camera_querycap(struct soc_camera_host 
 *ici,
   return 0;
  }
  
 -static int mx2_camera_reqbufs(struct soc_camera_file *icf,
 +static int mx2_camera_reqbufs(struct soc_camera_device *icd,
 struct v4l2_requestbuffers *p)
  {
   int i;
  
   for (i = 0; i  p-count; i++) {
 - struct mx2_buffer *buf = container_of(icf-vb_vidq.bufs[i],
 + struct mx2_buffer *buf = container_of(icd-vb_vidq.bufs[i],
 struct mx2_buffer, vb);
   INIT_LIST_HEAD(buf-vb.queue);
   }
 @@ -1151,9 +1148,9 @@ err_out:
  
  static unsigned int mx2_camera_poll(struct file *file, poll_table *pt)
  {
 - struct soc_camera_file *icf = file-private_data;
 + struct soc_camera_device *icd = file-private_data;
  
 - return videobuf_poll_stream(file, icf-vb_vidq, pt);
 + return videobuf_poll_stream(file, icd-vb_vidq, pt);
  }
  
  static struct soc_camera_host_ops mx2_soc_camera_host_ops = {
 -- 

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mx2_camera: fix pixel clock polarity configuration

2010-10-27 Thread Baruch Siach
When SOCAM_PCLK_SAMPLE_FALLING, just leave CSICR1_REDGE unset, otherwise we get
the inverted behaviour.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 drivers/media/video/mx2_camera.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 3ea2ec0..02f144f 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -811,8 +811,6 @@ static int mx2_camera_set_bus_param(struct 
soc_camera_device *icd,
 
if (common_flags  SOCAM_PCLK_SAMPLE_RISING)
csicr1 |= CSICR1_REDGE;
-   if (common_flags  SOCAM_PCLK_SAMPLE_FALLING)
-   csicr1 |= CSICR1_INV_PCLK;
if (common_flags  SOCAM_VSYNC_ACTIVE_HIGH)
csicr1 |= CSICR1_SOF_POL;
if (common_flags  SOCAM_HSYNC_ACTIVE_HIGH)
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] mx2_camera: implement forced termination of active buffer for mx25

2010-08-29 Thread Baruch Siach
Hi Guennadi,

On Fri, Aug 27, 2010 at 11:07:31AM +0200, Guennadi Liakhovetski wrote:
 On Tue, 27 Jul 2010, Baruch Siach wrote:
  This allows userspace to terminate a capture without waiting for the 
  current
  frame to complete.
 
 This is an improvement, not a fix, right? Without this patch the 
 termination just have to wait a couple of ms longer? so, it is ok to 
 schedule it for 2.6.37?

In my situation the image data source may stop sending data in the middle of a 
frame.  In this case userspace is stuck forever. So, this is a real fix for 
me. This is not the usual use case, I guess, so I leave it for you to decide.

baruch

  Signed-off-by: Baruch Siach bar...@tkos.co.il
  ---
   drivers/media/video/mx2_camera.c |   20 
   1 files changed, 16 insertions(+), 4 deletions(-)
  
  diff --git a/drivers/media/video/mx2_camera.c 
  b/drivers/media/video/mx2_camera.c
  index d327d11..396542b 100644
  --- a/drivers/media/video/mx2_camera.c
  +++ b/drivers/media/video/mx2_camera.c
  @@ -648,15 +648,27 @@ static void mx2_videobuf_release(struct 
  videobuf_queue *vq,
   * Terminate only queued but inactive buffers. Active buffers are
   * released when they become inactive after videobuf_waiton().
   *
  -* FIXME: implement forced termination of active buffers, so that the
  -* user won't get stuck in an uninterruptible state. This requires a
  -* specific handling for each of the three DMA types that this driver
  -* supports.
  +* FIXME: implement forced termination of active buffers for mx27 and 
  +* mx27 eMMA, so that the user won't get stuck in an uninterruptible
  +* state. This requires a specific handling for each of the these DMA
  +* types.
   */
  spin_lock_irqsave(pcdev-lock, flags);
  if (vb-state == VIDEOBUF_QUEUED) {
  list_del(vb-queue);
  vb-state = VIDEOBUF_ERROR;
  +   } else if (cpu_is_mx25()  vb-state == VIDEOBUF_ACTIVE) {
  +   if (pcdev-fb1_active == buf) {
  +   pcdev-csicr1 = ~CSICR1_FB1_DMA_INTEN;
  +   writel(0, pcdev-base_csi + CSIDMASA_FB1);
  +   pcdev-fb1_active = NULL;
  +   } else if (pcdev-fb2_active == buf) {
  +   pcdev-csicr1 = ~CSICR1_FB2_DMA_INTEN;
  +   writel(0, pcdev-base_csi + CSIDMASA_FB2);
  +   pcdev-fb2_active = NULL;
  +   }
  +   writel(pcdev-csicr1, pcdev-base_csi + CSICR1);
  +   vb-state = VIDEOBUF_ERROR;
  }
  spin_unlock_irqrestore(pcdev-lock, flags);
   
  -- 
  1.7.1
  
  --
  To unsubscribe from this list: send the line unsubscribe linux-media in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
 
 ---
 Guennadi Liakhovetski, Ph.D.
 Freelance Open-Source Software Developer
 http://www.open-technology.de/

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] mx2_camera: return IRQ_NONE when doing nothing

2010-08-09 Thread Baruch Siach
Hi Guennadi,

On Wed, Jul 28, 2010 at 01:25:27PM +0200, Guennadi Liakhovetski wrote:
 A general comment to your patches: the actual driver is going to be merged 
 via the ARM tree, all other your incremental patches should rather go via 
 the v4l tree. So, we'll have to synchronise with ARM, let's hope ARM 
 patches go in early enough.

Since the driver is now merged upstream this series can go via the v4l tree.

 On Tue, 27 Jul 2010, Baruch Siach wrote:
 
  Signed-off-by: Baruch Siach bar...@tkos.co.il
  ---
   drivers/media/video/mx2_camera.c |8 +---
   1 files changed, 5 insertions(+), 3 deletions(-)
  
  diff --git a/drivers/media/video/mx2_camera.c 
  b/drivers/media/video/mx2_camera.c
  index 1536bd4..b42ad8d 100644
  --- a/drivers/media/video/mx2_camera.c
  +++ b/drivers/media/video/mx2_camera.c
  @@ -420,15 +420,17 @@ static irqreturn_t mx25_camera_irq(int irq_csi, void 
  *data)
  struct mx2_camera_dev *pcdev = data;
  u32 status = readl(pcdev-base_csi + CSISR);
   
  -   if (status  CSISR_DMA_TSF_FB1_INT)
  +   writel(status, pcdev-base_csi + CSISR);
  +
  +   if (!(status  (CSISR_DMA_TSF_FB1_INT | CSISR_DMA_TSF_FB2_INT)))
  +   return IRQ_NONE;
  +   else if (status  CSISR_DMA_TSF_FB1_INT)
  mx25_camera_frame_done(pcdev, 1, VIDEOBUF_DONE);
  else if (status  CSISR_DMA_TSF_FB2_INT)
  mx25_camera_frame_done(pcdev, 2, VIDEOBUF_DONE);
   
  /* FIXME: handle CSISR_RFF_OR_INT */
   
  -   writel(status, pcdev-base_csi + CSISR);
  -
  return IRQ_HANDLED;
   }
 
 I don't think this is correct. You should return IRQ_NONE if this is not 
 an interrupt from your device at all. In this case you don't have to ack 
 your interrupts, which, I presume, is what the write to CSISR is doing. 
 OTOH, if this is an interrupt from your device, but you're just not 
 interested in it, you should ack it and return IRQ_HANDLED. So, the 
 original behaviour was more correct, than what this your patch is doing. 
 The only improvement I can think of is, that you can return IRQ_NONE if 
 status is 0, but then you don't have to ack it.

OK. Drop this one, then. Patches in this series are independent from each 
other, so the others can go in.

baruch

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] mx2_camera: mx25 fixes and enhancements

2010-07-27 Thread Baruch Siach
The first 3 pathces in this series are fixes for the mx2_camera driver which is 
going upstream via the imx git tree. The last patch implements forced active 
buffer termination on mx25.

Baruch Siach (4):
  mx2_camera: fix a race causing NULL dereference
  mx2_camera: return IRQ_NONE when doing nothing
  mx2_camera: fix comment typo
  mx2_camera: implement forced termination of active buffer for mx25

 drivers/media/video/mx2_camera.c |   34 ++
 1 files changed, 26 insertions(+), 8 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] mx2_camera: fix a race causing NULL dereference

2010-07-27 Thread Baruch Siach
The mx25_camera_irq irq handler may get called after the camera has been
deactivated (from mx2_camera_deactivate). Detect this situation, and bail out.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 drivers/media/video/mx2_camera.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 881d5d8..1536bd4 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -384,6 +384,9 @@ static void mx25_camera_frame_done(struct mx2_camera_dev 
*pcdev, int fb,
 
spin_lock_irqsave(pcdev-lock, flags);
 
+   if (*fb_active == NULL)
+   goto out;
+
vb = (*fb_active)-vb;
dev_dbg(pcdev-dev, %s (vb=0x%p) 0x%08lx %d\n, __func__,
vb, vb-baddr, vb-bsize);
@@ -408,6 +411,7 @@ static void mx25_camera_frame_done(struct mx2_camera_dev 
*pcdev, int fb,
 
*fb_active = buf;
 
+out:
spin_unlock_irqrestore(pcdev-lock, flags);
 }
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] mx2_camera: fix comment typo

2010-07-27 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 drivers/media/video/mx2_camera.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index b42ad8d..d327d11 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -469,7 +469,7 @@ static void free_buffer(struct videobuf_queue *vq, struct 
mx2_buffer *buf)
 
/*
 * This waits until this buffer is out of danger, i.e., until it is no
-* longer in STATE_QUEUED or STATE_ACTIVE
+* longer in state VIDEOBUF_QUEUED or VIDEOBUF_ACTIVE
 */
videobuf_waiton(vb, 0, 0);
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] mx2_camera: return IRQ_NONE when doing nothing

2010-07-27 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 drivers/media/video/mx2_camera.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 1536bd4..b42ad8d 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -420,15 +420,17 @@ static irqreturn_t mx25_camera_irq(int irq_csi, void 
*data)
struct mx2_camera_dev *pcdev = data;
u32 status = readl(pcdev-base_csi + CSISR);
 
-   if (status  CSISR_DMA_TSF_FB1_INT)
+   writel(status, pcdev-base_csi + CSISR);
+
+   if (!(status  (CSISR_DMA_TSF_FB1_INT | CSISR_DMA_TSF_FB2_INT)))
+   return IRQ_NONE;
+   else if (status  CSISR_DMA_TSF_FB1_INT)
mx25_camera_frame_done(pcdev, 1, VIDEOBUF_DONE);
else if (status  CSISR_DMA_TSF_FB2_INT)
mx25_camera_frame_done(pcdev, 2, VIDEOBUF_DONE);
 
/* FIXME: handle CSISR_RFF_OR_INT */
 
-   writel(status, pcdev-base_csi + CSISR);
-
return IRQ_HANDLED;
 }
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] mx2_camera: implement forced termination of active buffer for mx25

2010-07-27 Thread Baruch Siach
This allows userspace to terminate a capture without waiting for the current
frame to complete.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 drivers/media/video/mx2_camera.c |   20 
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index d327d11..396542b 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -648,15 +648,27 @@ static void mx2_videobuf_release(struct videobuf_queue 
*vq,
 * Terminate only queued but inactive buffers. Active buffers are
 * released when they become inactive after videobuf_waiton().
 *
-* FIXME: implement forced termination of active buffers, so that the
-* user won't get stuck in an uninterruptible state. This requires a
-* specific handling for each of the three DMA types that this driver
-* supports.
+* FIXME: implement forced termination of active buffers for mx27 and 
+* mx27 eMMA, so that the user won't get stuck in an uninterruptible
+* state. This requires a specific handling for each of the these DMA
+* types.
 */
spin_lock_irqsave(pcdev-lock, flags);
if (vb-state == VIDEOBUF_QUEUED) {
list_del(vb-queue);
vb-state = VIDEOBUF_ERROR;
+   } else if (cpu_is_mx25()  vb-state == VIDEOBUF_ACTIVE) {
+   if (pcdev-fb1_active == buf) {
+   pcdev-csicr1 = ~CSICR1_FB1_DMA_INTEN;
+   writel(0, pcdev-base_csi + CSIDMASA_FB1);
+   pcdev-fb1_active = NULL;
+   } else if (pcdev-fb2_active == buf) {
+   pcdev-csicr1 = ~CSICR1_FB2_DMA_INTEN;
+   writel(0, pcdev-base_csi + CSIDMASA_FB2);
+   pcdev-fb2_active = NULL;
+   }
+   writel(pcdev-csicr1, pcdev-base_csi + CSICR1);
+   vb-state = VIDEOBUF_ERROR;
}
spin_unlock_irqrestore(pcdev-lock, flags);
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-07-15 Thread Baruch Siach
Hi,

On Sun, Jul 04, 2010 at 07:55:10AM +0300, Baruch Siach wrote:
 This is the soc_camera support developed by Sascha Hauer for the i.MX27.  Alan
 Carvalho de Assis modified the original driver to get it working on more 
 recent
 kernels. I modified it further to add support for i.MX25. This driver has been
 tested on i.MX25 and i.MX27 based platforms.
 
 Signed-off-by: Baruch Siach bar...@tkos.co.il
 Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---

Ping?

I'm currently working on a series of some small fixes and tweaks, but first I 
want to see the main code getting into mainline.

baruch

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv6] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-07-03 Thread Baruch Siach
This is the soc_camera support developed by Sascha Hauer for the i.MX27.  Alan
Carvalho de Assis modified the original driver to get it working on more recent
kernels. I modified it further to add support for i.MX25. This driver has been
tested on i.MX25 and i.MX27 based platforms.

Signed-off-by: Baruch Siach bar...@tkos.co.il
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
Changes v5 - v6

Typo fix: s/CONFIG_MX2_VIDEO/CONFIG_VIDEO_MX2_HOSTSUPPORT/

Changes v4 - v5
Comments from Uwe Kleine-König:

Enclose mx27 DMA related stuff in #ifdefs since the dma-mx1-mx2.h is no 
longer accessible to mx25 builds

s/MX2_VIDEO/VIDEO_MX2_HOSTSUPPORT/

Changes v3 - v4
Address more comments from Guennadi Liakhovetski, including:

* Fix the double trigger handling of mx27 eMMA

* Add a FIXME comment in the code of eMMA overflow handling

Changes v2 - v3
Address more comments from Guennadi Liakhovetski.

Applied part of Sashca's patch that I forgot in v2.

Changes v1 - v2
Addressed the comments of Guennadi Liakhovetski except from the following:

1. The mclk_get_divisor implementation, since I don't know what this code 
   is good for

2. mx2_videobuf_release should not set pcdev-active on i.MX27, because 
   mx27_camera_frame_done needs this pointer

3. In mx27_camera_emma_buf_init I don't know the meaning of those hard 
   coded magic numbers

Applied i.MX27 fixes from Sascha.

 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
 drivers/media/video/Kconfig  |   13 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1513 ++
 5 files changed, 1575 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index c4b40c3..564ec9d 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -44,12 +44,12 @@
  */
 #define CONSISTENT_DMA_SIZE SZ_8M
 
-#elif defined(CONFIG_MX1_VIDEO)
+#elif defined(CONFIG_MX1_VIDEO) || defined(CONFIG_VIDEO_MX2_HOSTSUPPORT)
 /*
  * Increase size of DMA-consistent memory region.
  * This is required for i.MX camera driver to capture at least four VGA frames.
  */
 #define CONSISTENT_DMA_SIZE SZ_4M
-#endif /* CONFIG_MX1_VIDEO */
+#endif /* CONFIG_MX1_VIDEO || CONFIG_VIDEO_MX2_HOSTSUPPORT */
 
 #endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h 
b/arch/arm/plat-mxc/include/mach/mx2_cam.h
new file mode 100644
index 000..3c080a3
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h
@@ -0,0 +1,46 @@
+/*
+ * mx2-cam.h - i.MX27/i.MX25 camera driver header file
+ *
+ * Copyright (C) 2003, Intel Corporation
+ * Copyright (C) 2008, Sascha Hauer s.ha...@pengutronix.de
+ * Copyright (C) 2010, Baruch Siach bar...@tkos.co.il
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __MACH_MX2_CAM_H_
+#define __MACH_MX2_CAM_H_
+
+#define MX2_CAMERA_SWAP16  (1  0)
+#define MX2_CAMERA_EXT_VSYNC   (1  1)
+#define MX2_CAMERA_CCIR(1  2)
+#define MX2_CAMERA_CCIR_INTERLACE  (1  3)
+#define MX2_CAMERA_HSYNC_HIGH  (1  4)
+#define MX2_CAMERA_GATED_CLOCK (1  5)
+#define MX2_CAMERA_INV_DATA(1  6)
+#define MX2_CAMERA_PCLK_SAMPLE_RISING  (1  7)
+#define MX2_CAMERA_PACK_DIR_MSB(1  8)
+
+/**
+ * struct mx2_camera_platform_data - optional platform data for mx2_camera
+ * @flags: any combination of MX2_CAMERA_*
+ * @clk: clock rate of the csi block / 2
+ */
+struct mx2_camera_platform_data {
+   unsigned long flags;
+   unsigned long clk;
+};
+
+#endif /* __MACH_MX2_CAM_H_ */
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index bdbc9d3..27e2acc 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -969,6 +969,19 @@ config VIDEO_OMAP2
---help---
  This is a v4l2 driver for the TI OMAP2 camera capture interface
 
+config VIDEO_MX2_HOSTSUPPORT
+bool
+
+config VIDEO_MX2
+   tristate i.MX27/i.MX25

[PATCHv5] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-07-01 Thread Baruch Siach
This is the soc_camera support developed by Sascha Hauer for the i.MX27.  Alan
Carvalho de Assis modified the original driver to get it working on more recent
kernels. I modified it further to add support for i.MX25. This driver has been
tested on i.MX25 and i.MX27 based platforms.

Signed-off-by: Baruch Siach bar...@tkos.co.il
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
Changes v4 - v5
Comments from Uwe Kleine-König:

Enclose mx27 DMA related stuff in #ifdefs since the dma-mx1-mx2.h is no 
longer accessible to mx25 builds

s/MX2_VIDEO/VIDEO_MX2_HOSTSUPPORT/

Changes v3 - v4
Address more comments from Guennadi Liakhovetski, including:

* Fix the double trigger handling of mx27 eMMA

* Add a FIXME comment in the code of eMMA overflow handling

Changes v2 - v3
Address more comments from Guennadi Liakhovetski.

Applied part of Sashca's patch that I forgot in v2.

Changes v1 - v2
Addressed the comments of Guennadi Liakhovetski except from the following:

1. The mclk_get_divisor implementation, since I don't know what this code 
   is good for

2. mx2_videobuf_release should not set pcdev-active on i.MX27, because 
   mx27_camera_frame_done needs this pointer

3. In mx27_camera_emma_buf_init I don't know the meaning of those hard 
   coded magic numbers

Applied i.MX27 fixes from Sascha.

 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
 drivers/media/video/Kconfig  |   13 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1513 ++
 5 files changed, 1575 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index c4b40c3..849d891 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -44,12 +44,12 @@
  */
 #define CONSISTENT_DMA_SIZE SZ_8M
 
-#elif defined(CONFIG_MX1_VIDEO)
+#elif defined(CONFIG_MX1_VIDEO) || defined(CONFIG_VIDEO_MX2_HOSTSUPPORT)
 /*
  * Increase size of DMA-consistent memory region.
  * This is required for i.MX camera driver to capture at least four VGA frames.
  */
 #define CONSISTENT_DMA_SIZE SZ_4M
-#endif /* CONFIG_MX1_VIDEO */
+#endif /* CONFIG_MX1_VIDEO || CONFIG_MX2_VIDEO */
 
 #endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h 
b/arch/arm/plat-mxc/include/mach/mx2_cam.h
new file mode 100644
index 000..3c080a3
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h
@@ -0,0 +1,46 @@
+/*
+ * mx2-cam.h - i.MX27/i.MX25 camera driver header file
+ *
+ * Copyright (C) 2003, Intel Corporation
+ * Copyright (C) 2008, Sascha Hauer s.ha...@pengutronix.de
+ * Copyright (C) 2010, Baruch Siach bar...@tkos.co.il
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __MACH_MX2_CAM_H_
+#define __MACH_MX2_CAM_H_
+
+#define MX2_CAMERA_SWAP16  (1  0)
+#define MX2_CAMERA_EXT_VSYNC   (1  1)
+#define MX2_CAMERA_CCIR(1  2)
+#define MX2_CAMERA_CCIR_INTERLACE  (1  3)
+#define MX2_CAMERA_HSYNC_HIGH  (1  4)
+#define MX2_CAMERA_GATED_CLOCK (1  5)
+#define MX2_CAMERA_INV_DATA(1  6)
+#define MX2_CAMERA_PCLK_SAMPLE_RISING  (1  7)
+#define MX2_CAMERA_PACK_DIR_MSB(1  8)
+
+/**
+ * struct mx2_camera_platform_data - optional platform data for mx2_camera
+ * @flags: any combination of MX2_CAMERA_*
+ * @clk: clock rate of the csi block / 2
+ */
+struct mx2_camera_platform_data {
+   unsigned long flags;
+   unsigned long clk;
+};
+
+#endif /* __MACH_MX2_CAM_H_ */
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index bdbc9d3..27e2acc 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -969,6 +969,19 @@ config VIDEO_OMAP2
---help---
  This is a v4l2 driver for the TI OMAP2 camera capture interface
 
+config VIDEO_MX2_HOSTSUPPORT
+bool
+
+config VIDEO_MX2
+   tristate i.MX27/i.MX25 Camera Sensor Interface driver
+   depends on VIDEO_DEV  SOC_CAMERA  (MACH_MX27

Re: [PATCHv5] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-07-01 Thread Baruch Siach
Hi Uwe,

On Thu, Jul 01, 2010 at 02:28:03PM +0200, Uwe Kleine-König wrote:
 On Thu, Jul 01, 2010 at 02:03:19PM +0300, Baruch Siach wrote:
  This is the soc_camera support developed by Sascha Hauer for the i.MX27.  
  Alan
  Carvalho de Assis modified the original driver to get it working on more 
  recent
  kernels. I modified it further to add support for i.MX25. This driver has 
  been
  tested on i.MX25 and i.MX27 based platforms.
  
  Signed-off-by: Baruch Siach bar...@tkos.co.il
  Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
  ---
  Changes v4 - v5
  Comments from Uwe Kleine-König:
  
  Enclose mx27 DMA related stuff in #ifdefs since the dma-mx1-mx2.h is no 
  longer accessible to mx25 builds
  
  s/MX2_VIDEO/VIDEO_MX2_HOSTSUPPORT/
  
  Changes v3 - v4
  Address more comments from Guennadi Liakhovetski, including:
  
  * Fix the double trigger handling of mx27 eMMA
  
  * Add a FIXME comment in the code of eMMA overflow handling
  
  Changes v2 - v3
  Address more comments from Guennadi Liakhovetski.
  
  Applied part of Sashca's patch that I forgot in v2.
  
  Changes v1 - v2
  Addressed the comments of Guennadi Liakhovetski except from the 
  following:
  
  1. The mclk_get_divisor implementation, since I don't know what this 
  code 
 is good for
  
  2. mx2_videobuf_release should not set pcdev-active on i.MX27, because 
 mx27_camera_frame_done needs this pointer
  
  3. In mx27_camera_emma_buf_init I don't know the meaning of those hard 
 coded magic numbers
  
  Applied i.MX27 fixes from Sascha.
  
   arch/arm/plat-mxc/include/mach/memory.h  |4 +-
   arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
   drivers/media/video/Kconfig  |   13 +
   drivers/media/video/Makefile |1 +
   drivers/media/video/mx2_camera.c | 1513 
  ++
   5 files changed, 1575 insertions(+), 2 deletions(-)
   create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
   create mode 100644 drivers/media/video/mx2_camera.c
  
  diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
  b/arch/arm/plat-mxc/include/mach/memory.h
  index c4b40c3..849d891 100644
  --- a/arch/arm/plat-mxc/include/mach/memory.h
  +++ b/arch/arm/plat-mxc/include/mach/memory.h
  @@ -44,12 +44,12 @@
*/
   #define CONSISTENT_DMA_SIZE SZ_8M
   
  -#elif defined(CONFIG_MX1_VIDEO)
  +#elif defined(CONFIG_MX1_VIDEO) || defined(CONFIG_VIDEO_MX2_HOSTSUPPORT)
   /*
* Increase size of DMA-consistent memory region.
* This is required for i.MX camera driver to capture at least four VGA 
  frames.
*/
   #define CONSISTENT_DMA_SIZE SZ_4M
  -#endif /* CONFIG_MX1_VIDEO */
  +#endif /* CONFIG_MX1_VIDEO || CONFIG_MX2_VIDEO */
 s/CONFIG_MX2_VIDEO/CONFIG_VIDEO_MX2_HOSTSUPPORT/ please

Oops. Will fix.

   #endif /* __ASM_ARCH_MXC_MEMORY_H__ */
  diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h 
  b/arch/arm/plat-mxc/include/mach/mx2_cam.h
  new file mode 100644
  index 000..3c080a3
  --- /dev/null
  +++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h
 Do you expect users of this header other than your driver?  If not you
 can fold it into the latter.

This header contains mx2_camera_platform_data. Platform code needs this.

 [...snip...]
 
  diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
  index bdbc9d3..27e2acc 100644
  --- a/drivers/media/video/Kconfig
  +++ b/drivers/media/video/Kconfig
  @@ -969,6 +969,19 @@ config VIDEO_OMAP2
  ---help---
This is a v4l2 driver for the TI OMAP2 camera capture interface
   
  +config VIDEO_MX2_HOSTSUPPORT
  +bool
  +
  +config VIDEO_MX2
  +   tristate i.MX27/i.MX25 Camera Sensor Interface driver
  +   depends on VIDEO_DEV  SOC_CAMERA  (MACH_MX27 || ARCH_MX25)
  +   select VIDEOBUF_DMA_CONTIG
 CONTIG?

This selects the physically contiguous DMA implementation of the videobuf API.  
See drivers/media/video/videobuf-dma-contig.c.

 [...snap...]
 
  diff --git a/drivers/media/video/mx2_camera.c 
  b/drivers/media/video/mx2_camera.c
  new file mode 100644
  index 000..98c93fa
  --- /dev/null
  +++ b/drivers/media/video/mx2_camera.c
  @@ -0,0 +1,1513 @@
 
 [...snip...]
 
  +static int __devexit mx2_camera_remove(struct platform_device *pdev)
  +{
  +   struct soc_camera_host *soc_host = to_soc_camera_host(pdev-dev);
  +   struct mx2_camera_dev *pcdev = container_of(soc_host,
  +   struct mx2_camera_dev, soc_host);
  +   struct resource *res;
  +
  +   clk_put(pcdev-clk_csi);
  +#ifdef CONFIG_MACH_MX27
  +   if (cpu_is_mx27())
  +   imx_dma_free(pcdev-dma);
  +#endif /* CONFIG_MACH_MX27 */
  +   free_irq(pcdev-irq_csi, pcdev);
  +   if (mx27_camera_emma(pcdev))
  +   free_irq(pcdev-irq_emma, pcdev);
  +
  +   soc_camera_host_unregister(pcdev-soc_host);
  +
  +   iounmap(pcdev-base_csi);
  +
  +   if (mx27_camera_emma(pcdev)) {
  +   clk_disable(pcdev-clk_emma);
  +   clk_put

Re: [PATCHv4 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-06-29 Thread Baruch Siach
On Tue, Jun 29, 2010 at 09:47:42PM +0200, Guennadi Liakhovetski wrote:
 On Mon, 21 Jun 2010, Baruch Siach wrote:
 
  This is the soc_camera support developed by Sascha Hauer for the i.MX27.  
  Alan
  Carvalho de Assis modified the original driver to get it working on more 
  recent
  kernels. I modified it further to add support for i.MX25. This driver has 
  been
  tested on i.MX25 and i.MX27 based platforms.
 
 This looks good to me, thanks! Overflow on eMMA is, probably, still 
 broken, but it will, most probably, remain so, until someone tests and 
 fixes it. One question though: do you know whether this imx/mxc overhaul: 
 http://lists.infradead.org/pipermail/linux-arm-kernel/2010-June/thread.html#18844
  
 affects your driver?

I tested this yesterday, and, unfortunately, it does :(. See 
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-June/019111.html.  
However, this issue does not affect mx27 builds. So I think this should not 
stop the merge of this driver, for now. I hope Uwe and I will find an 
acceptable solution before the .36 merge window opens.

baruch

 I can ask Uwe, but maybe you have an idea or could test your patches with 
 Uwe's git tree?
 
 Thanks
 Guennadi
 
  
  Signed-off-by: Baruch Siach bar...@tkos.co.il
  ---

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-06-20 Thread Baruch Siach
Hi Guennadi,

On Sat, Jun 19, 2010 at 04:13:31PM +0200, Guennadi Liakhovetski wrote:
 On Wed, 26 May 2010, Baruch Siach wrote:
 
  This is the soc_camera support developed by Sascha Hauer for the i.MX27.  
  Alan
  Carvalho de Assis modified the original driver to get it working on more 
  recent
  kernels. I modified it further to add support for i.MX25. This driver has 
  been
  tested on i.MX25 and i.MX27 based platforms.

Tanks for your review. I'll send v4 shortly.

baruch

 I hoped, this would be the final version, but if I'm not mistaken, you've 
 introduced an error, which we better fix before committing. And as we anyway 
 will likely need a v4, I'll also ask you to improve a couple of stylistic 
 issues, which otherwise I'd just fix myself with your permission.
 
  Signed-off-by: Baruch Siach bar...@tkos.co.il
  ---
   arch/arm/plat-mxc/include/mach/memory.h  |4 +-
   arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
   drivers/media/video/Kconfig  |   13 +
   drivers/media/video/Makefile |1 +
   drivers/media/video/mx2_camera.c | 1488 
  ++
   5 files changed, 1550 insertions(+), 2 deletions(-)
   create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
   create mode 100644 drivers/media/video/mx2_camera.c
  
  diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
  b/arch/arm/plat-mxc/include/mach/memory.h
  index c4b40c3..5803836 100644
  --- a/arch/arm/plat-mxc/include/mach/memory.h
  +++ b/arch/arm/plat-mxc/include/mach/memory.h
 
 [snip]
 
  +static void mx2_videobuf_queue(struct videobuf_queue *vq,
  +  struct videobuf_buffer *vb)
  +{
  +   struct soc_camera_device *icd = vq-priv_data;
  +   struct soc_camera_host *ici =
  +   to_soc_camera_host(icd-dev.parent);
  +   struct mx2_camera_dev *pcdev = ici-priv;
  +   struct mx2_buffer *buf = container_of(vb, struct mx2_buffer, vb);
  +   unsigned long flags;
  +   int ret;
  +
  +   dev_dbg(icd-dev, %s (vb=0x%p) 0x%08lx %d\n, __func__,
  +   vb, vb-baddr, vb-bsize);
  +
  +   spin_lock_irqsave(pcdev-lock, flags);
  +
  +   vb-state = VIDEOBUF_QUEUED;
  +   list_add_tail(vb-queue, pcdev-capture);
  +
  +   if (mx27_camera_emma(pcdev))
  +   goto out;
  +   else if (cpu_is_mx27()) {
 
 One of the minor ones - please, add braces in the if case.
 
 [snip]
 
  +static irqreturn_t mx27_camera_emma_irq(int irq_emma, void *data)
  +{
  +   struct mx2_camera_dev *pcdev = data;
  +   unsigned int status = readl(pcdev-base_emma + PRP_INTRSTATUS);
  +   struct mx2_buffer *buf;
  +
  +   if ((status  (3  5)) == (3  5)
  +!list_empty(pcdev-active_bufs)) {
  +   /*
  +* Both buffers have triggered, process the one we're expecting
  +* to first
  +*/
  +   buf = list_entry(pcdev-active_bufs.next,
  +   struct mx2_buffer, vb.queue);
  +   mx27_camera_frame_done_emma(pcdev, buf-bufnum, VIDEOBUF_DONE);
  +   }
  +   if (status  (1  6))
  +   mx27_camera_frame_done_emma(pcdev, 0, VIDEOBUF_DONE);
  +   if (status  (1  5))
  +   mx27_camera_frame_done_emma(pcdev, 1, VIDEOBUF_DONE);
 
 Now, this is the important one. In my review of v2 I proposed the above 
 fix for the both-bits-set case. But, I think, your implementation is not 
 correct. Don't you have to clear the expected buffer number, so that you 
 don't process it twice? Something like
 
   status = ~(1  6 - buf-bufnum);
 
 anywhere inside the first of the three ifs?
 
  +   if (status  (1  7)) {
 
 Bit 7 is overflow. A correct handling could be resetting the buffer, 
 returning an error frame and continuing with the next one. However, I 
 understand, that you do not have a chance to implement this properly 
 now. So, please, at least add a FIXME comment, explaining, what should 
 be done here. Besides, error states are normally checked before normal 
 data processing. So, either mention this in the comment too, or move this 
 above the buffer completion processing.
 
 Thanks
 Guennadi
 ---
 Guennadi Liakhovetski, Ph.D.
 Freelance Open-Source Software Developer
 http://www.open-technology.de/

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv4 0/3] Driver for the i.MX2x CMOS Sensor Interface

2010-06-20 Thread Baruch Siach
This series contains a soc_camera driver for the i.MX25/i.MX27 CSI device, and
platform code for the i.MX25 and i.MX27 chips. This driver is based on a 
driver for i.MX27 CSI from Sascha Hauer, that  Alan Carvalho de Assis has 
posted in linux-media last December[1]. I tested the mx2_camera driver on the 
i.MX25 PDK. Sascha Hauer has tested a earlier version of this driver on an 
i.MX27 based board. I included in this version some fixes from Sascha that 
enable i.MX27 support.

[1] https://patchwork.kernel.org/patch/67636/

Changes v3 - v4
Address more comments from Guennadi Liakhovetski, including:

* Fix the double trigger handling of mx27 eMMA

* Add a FIXME comment in the code of eMMA overflow handling

Changes v2 - v3
Address more comments from Guennadi Liakhovetski.

Applied part of Sashca's patch that I forgot in v2.

Changes v1 - v2
Addressed the comments of Guennadi Liakhovetski except from the following:

1. The mclk_get_divisor implementation, since I don't know what this code 
   is good for

2. mx2_videobuf_release should not set pcdev-active on i.MX27, because 
   mx27_camera_frame_done needs this pointer

3. In mx27_camera_emma_buf_init I don't know the meaning of those hard 
   coded magic numbers

Applied i.MX27 fixes from Sascha.

Baruch Siach (3):
  mx2_camera: Add soc_camera support for i.MX25/i.MX27
  mx27: add support for the CSI device
  mx25: add support for the CSI device

 arch/arm/mach-mx2/clock_imx27.c  |2 +-
 arch/arm/mach-mx2/devices.c  |   31 +
 arch/arm/mach-mx2/devices.h  |1 +
 arch/arm/mach-mx25/clock.c   |   14 +-
 arch/arm/mach-mx25/devices.c |   22 +
 arch/arm/mach-mx25/devices.h |1 +
 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx25.h|2 +
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
 drivers/media/video/Kconfig  |   13 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1493 ++
 12 files changed, 1625 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv4 2/3] mx27: add support for the CSI device

2010-06-20 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/mach-mx2/clock_imx27.c |2 +-
 arch/arm/mach-mx2/devices.c |   31 +++
 arch/arm/mach-mx2/devices.h |1 +
 3 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-mx2/clock_imx27.c b/arch/arm/mach-mx2/clock_imx27.c
index 0f0823c..5a1aa15 100644
--- a/arch/arm/mach-mx2/clock_imx27.c
+++ b/arch/arm/mach-mx2/clock_imx27.c
@@ -644,7 +644,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(spi_imx.1, NULL, cspi2_clk)
_REGISTER_CLOCK(spi_imx.2, NULL, cspi3_clk)
_REGISTER_CLOCK(imx-fb.0, NULL, lcdc_clk)
-   _REGISTER_CLOCK(NULL, csi, csi_clk)
+   _REGISTER_CLOCK(mx2-camera.0, NULL, csi_clk)
_REGISTER_CLOCK(fsl-usb2-udc, usb, usb_clk)
_REGISTER_CLOCK(fsl-usb2-udc, usb_ahb, usb_clk1)
_REGISTER_CLOCK(mxc-ehci.0, usb, usb_clk)
diff --git a/arch/arm/mach-mx2/devices.c b/arch/arm/mach-mx2/devices.c
index a0aeb8a..08201f5 100644
--- a/arch/arm/mach-mx2/devices.c
+++ b/arch/arm/mach-mx2/devices.c
@@ -40,6 +40,37 @@
 
 #include devices.h
 
+#ifdef CONFIG_MACH_MX27
+static struct resource mx27_camera_resources[] = {
+   {
+  .start = MX27_CSI_BASE_ADDR,
+  .end = MX27_CSI_BASE_ADDR + 0x1f,
+  .flags = IORESOURCE_MEM,
+   }, {
+  .start = MX27_EMMA_PRP_BASE_ADDR,
+  .end = MX27_EMMA_PRP_BASE_ADDR + 0x1f,
+  .flags = IORESOURCE_MEM,
+   }, {
+  .start = MX27_INT_CSI,
+  .end = MX27_INT_CSI,
+  .flags = IORESOURCE_IRQ,
+   },{
+  .start = MX27_INT_EMMAPRP,
+  .end = MX27_INT_EMMAPRP,
+  .flags = IORESOURCE_IRQ,
+   },
+};
+struct platform_device mx27_camera_device = {
+   .name = mx2-camera,
+   .id = 0,
+   .num_resources = ARRAY_SIZE(mx27_camera_resources),
+   .resource = mx27_camera_resources,
+   .dev = {
+   .coherent_dma_mask = 0x,
+   },
+};
+#endif
+
 /*
  * SPI master controller
  *
diff --git a/arch/arm/mach-mx2/devices.h b/arch/arm/mach-mx2/devices.h
index 84ed513..8bdf018 100644
--- a/arch/arm/mach-mx2/devices.h
+++ b/arch/arm/mach-mx2/devices.h
@@ -29,6 +29,7 @@ extern struct platform_device mxc_i2c_device1;
 extern struct platform_device mxc_sdhc_device0;
 extern struct platform_device mxc_sdhc_device1;
 extern struct platform_device mxc_otg_udc_device;
+extern struct platform_device mx27_camera_device;
 extern struct platform_device mxc_otg_host;
 extern struct platform_device mxc_usbh1;
 extern struct platform_device mxc_usbh2;
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv4 3/3] mx25: add support for the CSI device

2010-06-20 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/mach-mx25/clock.c|   14 --
 arch/arm/mach-mx25/devices.c  |   22 ++
 arch/arm/mach-mx25/devices.h  |1 +
 arch/arm/plat-mxc/include/mach/mx25.h |2 ++
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 1550149..7a98d18 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -129,6 +129,11 @@ static unsigned long get_rate_lcdc(struct clk *clk)
return get_rate_per(7);
 }
 
+static unsigned long get_rate_csi(struct clk *clk)
+{
+   return get_rate_per(0);
+}
+
 static unsigned long get_rate_otg(struct clk *clk)
 {
return 4800; /* FIXME */
@@ -174,6 +179,8 @@ DEFINE_CLOCK(cspi3_clk,  0, CCM_CGCR1,  7, get_rate_ipg, 
NULL, NULL);
 DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL,   NULL, NULL);
 DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL,  NULL, NULL);
 DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0,  7, NULL,  NULL, lcdc_ahb_clk);
+DEFINE_CLOCK(csi_ahb_clk, 0, CCM_CGCR0, 18, get_rate_csi, NULL, NULL);
+DEFINE_CLOCK(csi_per_clk, 0, CCM_CGCR0, 0, get_rate_csi, NULL, csi_ahb_clk);
 DEFINE_CLOCK(uart1_clk,  0, CCM_CGCR2, 14, get_rate_uart, NULL, uart_per_clk);
 DEFINE_CLOCK(uart2_clk,  0, CCM_CGCR2, 15, get_rate_uart, NULL, uart_per_clk);
 DEFINE_CLOCK(uart3_clk,  0, CCM_CGCR2, 16, get_rate_uart, NULL, uart_per_clk);
@@ -191,6 +198,7 @@ DEFINE_CLOCK(i2c_clk,0, CCM_CGCR0,  6, 
get_rate_i2c, NULL, NULL);
 DEFINE_CLOCK(fec_clk,   0, CCM_CGCR1, 15, get_rate_ipg, NULL, fec_ahb_clk);
 DEFINE_CLOCK(dryice_clk, 0, CCM_CGCR1,  8, get_rate_ipg, NULL, NULL);
 DEFINE_CLOCK(lcdc_clk,  0, CCM_CGCR1, 29, get_rate_lcdc, NULL, lcdc_per_clk);
+DEFINE_CLOCK(csi_clk,0, CCM_CGCR1,  4, get_rate_csi, NULL,  csi_per_clk);
 
 #define _REGISTER_CLOCK(d, n, c)   \
{   \
@@ -225,6 +233,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(fec.0, NULL, fec_clk)
_REGISTER_CLOCK(imxdi_rtc.0, NULL, dryice_clk)
_REGISTER_CLOCK(imx-fb.0, NULL, lcdc_clk)
+   _REGISTER_CLOCK(mx2-camera.0, NULL, csi_clk)
 };
 
 int __init mx25_clocks_init(void)
@@ -239,8 +248,9 @@ int __init mx25_clocks_init(void)
__raw_writel((0xf  16) | (3  26), CRM_BASE + CCM_CGCR1);
__raw_writel((1  5), CRM_BASE + CCM_CGCR2);
 
-   /* Clock source for lcdc is upll */
-   __raw_writel(__raw_readl(CRM_BASE+0x64) | (1  7), CRM_BASE + 0x64);
+   /* Clock source for lcdc and csi is upll */
+   __raw_writel(__raw_readl(CRM_BASE+0x64) | (1  7) | (1  0),
+   CRM_BASE + 0x64);
 
mxc_timer_init(gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54);
 
diff --git a/arch/arm/mach-mx25/devices.c b/arch/arm/mach-mx25/devices.c
index 3a405fa..cbecbe1 100644
--- a/arch/arm/mach-mx25/devices.c
+++ b/arch/arm/mach-mx25/devices.c
@@ -515,3 +515,25 @@ struct platform_device mxc_wdt = {
.num_resources = ARRAY_SIZE(mxc_wdt_resources),
.resource = mxc_wdt_resources,
 };
+
+static struct resource mx25_csi_resources[] = {
+   {
+   .start  = MX25_CSI_BASE_ADDR,
+   .end= MX25_CSI_BASE_ADDR + 0xfff,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = MX25_INT_CSI,
+   .flags  = IORESOURCE_IRQ
+   },
+};
+
+struct platform_device mx25_csi_device = {
+   .name   = mx2-camera,
+   .id = 0,
+   .num_resources  = ARRAY_SIZE(mx25_csi_resources),
+   .resource   = mx25_csi_resources,
+   .dev= {
+   .coherent_dma_mask = 0x,
+   },
+};
diff --git a/arch/arm/mach-mx25/devices.h b/arch/arm/mach-mx25/devices.h
index cee12c0..b46f122 100644
--- a/arch/arm/mach-mx25/devices.h
+++ b/arch/arm/mach-mx25/devices.h
@@ -22,3 +22,4 @@ extern struct platform_device mxc_nand_device;
 extern struct platform_device mx25_rtc_device;
 extern struct platform_device mx25_fb_device;
 extern struct platform_device mxc_wdt;
+extern struct platform_device mx25_csi_device;
diff --git a/arch/arm/plat-mxc/include/mach/mx25.h 
b/arch/arm/plat-mxc/include/mach/mx25.h
index 4eb6e33..5e6a8b5 100644
--- a/arch/arm/plat-mxc/include/mach/mx25.h
+++ b/arch/arm/plat-mxc/include/mach/mx25.h
@@ -34,11 +34,13 @@
 #define MX25_NFC_BASE_ADDR 0xbb00
 #define MX25_DRYICE_BASE_ADDR  0x53ffc000
 #define MX25_LCDC_BASE_ADDR0x53fbc000
+#define MX25_CSI_BASE_ADDR 0x53ff8000
 
 #define MX25_INT_DRYICE25
 #define MX25_INT_FEC   57
 #define MX25_INT_NANDFC33
 #define MX25_INT_LCDC  39
+#define MX25_INT_CSI   17
 
 #if defined(IMX_NEEDS_DEPRECATED_SYMBOLS)
 #define UART1_BASE_ADDRMX25_UART1_BASE_ADDR
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord

[PATCHv4 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-06-20 Thread Baruch Siach
This is the soc_camera support developed by Sascha Hauer for the i.MX27.  Alan
Carvalho de Assis modified the original driver to get it working on more recent
kernels. I modified it further to add support for i.MX25. This driver has been
tested on i.MX25 and i.MX27 based platforms.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
 drivers/media/video/Kconfig  |   13 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1493 ++
 5 files changed, 1555 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index c4b40c3..5803836 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -44,12 +44,12 @@
  */
 #define CONSISTENT_DMA_SIZE SZ_8M
 
-#elif defined(CONFIG_MX1_VIDEO)
+#elif defined(CONFIG_MX1_VIDEO) || defined(CONFIG_MX2_VIDEO)
 /*
  * Increase size of DMA-consistent memory region.
  * This is required for i.MX camera driver to capture at least four VGA frames.
  */
 #define CONSISTENT_DMA_SIZE SZ_4M
-#endif /* CONFIG_MX1_VIDEO */
+#endif /* CONFIG_MX1_VIDEO || CONFIG_MX2_VIDEO */
 
 #endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h 
b/arch/arm/plat-mxc/include/mach/mx2_cam.h
new file mode 100644
index 000..3c080a3
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h
@@ -0,0 +1,46 @@
+/*
+ * mx2-cam.h - i.MX27/i.MX25 camera driver header file
+ *
+ * Copyright (C) 2003, Intel Corporation
+ * Copyright (C) 2008, Sascha Hauer s.ha...@pengutronix.de
+ * Copyright (C) 2010, Baruch Siach bar...@tkos.co.il
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __MACH_MX2_CAM_H_
+#define __MACH_MX2_CAM_H_
+
+#define MX2_CAMERA_SWAP16  (1  0)
+#define MX2_CAMERA_EXT_VSYNC   (1  1)
+#define MX2_CAMERA_CCIR(1  2)
+#define MX2_CAMERA_CCIR_INTERLACE  (1  3)
+#define MX2_CAMERA_HSYNC_HIGH  (1  4)
+#define MX2_CAMERA_GATED_CLOCK (1  5)
+#define MX2_CAMERA_INV_DATA(1  6)
+#define MX2_CAMERA_PCLK_SAMPLE_RISING  (1  7)
+#define MX2_CAMERA_PACK_DIR_MSB(1  8)
+
+/**
+ * struct mx2_camera_platform_data - optional platform data for mx2_camera
+ * @flags: any combination of MX2_CAMERA_*
+ * @clk: clock rate of the csi block / 2
+ */
+struct mx2_camera_platform_data {
+   unsigned long flags;
+   unsigned long clk;
+};
+
+#endif /* __MACH_MX2_CAM_H_ */
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index bdbc9d3..47bf6e6 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -969,6 +969,19 @@ config VIDEO_OMAP2
---help---
  This is a v4l2 driver for the TI OMAP2 camera capture interface
 
+config MX2_VIDEO
+bool
+
+config VIDEO_MX2
+   tristate i.MX27/i.MX25 Camera Sensor Interface driver
+   depends on VIDEO_DEV  SOC_CAMERA  (MACH_MX27 || ARCH_MX25)
+   select VIDEOBUF_DMA_CONTIG
+   select MX2_VIDEO
+   ---help---
+ This is a v4l2 driver for the i.MX27 and the i.MX25 Camera Sensor
+ Interface
+
+
 #
 # USB Multimedia device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index cc93859..b08bd2b 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -162,6 +162,7 @@ obj-$(CONFIG_SOC_CAMERA)+= soc_camera.o 
soc_mediabus.o
 obj-$(CONFIG_SOC_CAMERA_PLATFORM)  += soc_camera_platform.o
 # soc-camera host drivers have to be linked after camera drivers
 obj-$(CONFIG_VIDEO_MX1)+= mx1_camera.o
+obj-$(CONFIG_VIDEO_MX2)+= mx2_camera.o
 obj-$(CONFIG_VIDEO_MX3)+= mx3_camera.o
 obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
 obj-$(CONFIG_VIDEO_SH_MOBILE_CEU)  += sh_mobile_ceu_camera.o
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
new file mode 100644
index 000..79ad522
--- /dev/null
+++ b

[PATCH] soc_camera_platform: add set_fmt callback

2010-06-20 Thread Baruch Siach
This allows the platform camera to arrange a change in the capture format.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 drivers/media/video/soc_camera_platform.c |3 +++
 include/media/soc_camera_platform.h   |2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/soc_camera_platform.c 
b/drivers/media/video/soc_camera_platform.c
index 248c986..208fd42 100644
--- a/drivers/media/video/soc_camera_platform.c
+++ b/drivers/media/video/soc_camera_platform.c
@@ -61,6 +61,9 @@ static int soc_camera_platform_try_fmt(struct v4l2_subdev *sd,
 {
struct soc_camera_platform_info *p = v4l2_get_subdevdata(sd);
 
+   if (p-try_fmt)
+   return p-try_fmt(p, mf);
+
mf-width   = p-format.width;
mf-height  = p-format.height;
mf-code= p-format.code;
diff --git a/include/media/soc_camera_platform.h 
b/include/media/soc_camera_platform.h
index 0ecefe2..0558ffc 100644
--- a/include/media/soc_camera_platform.h
+++ b/include/media/soc_camera_platform.h
@@ -22,6 +22,8 @@ struct soc_camera_platform_info {
struct v4l2_mbus_framefmt format;
unsigned long bus_param;
struct device *dev;
+   int (*try_fmt)(struct soc_camera_platform_info *info,
+   struct v4l2_mbus_framefmt *mf);
int (*set_capture)(struct soc_camera_platform_info *info, int enable);
 };
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/3] Driver for the i.MX2x CMOS Sensor Interface

2010-06-09 Thread Baruch Siach
Hi linux-media list,

Ping?
Any news on this?

baruch

On Wed, May 26, 2010 at 12:13:15PM +0300, Baruch Siach wrote:
 This series contains a soc_camera driver for the i.MX25/i.MX27 CSI device, and
 platform code for the i.MX25 and i.MX27 chips. This driver is based on a 
 driver for i.MX27 CSI from Sascha Hauer, that  Alan Carvalho de Assis has 
 posted in linux-media last December[1]. I tested the mx2_camera driver on the 
 i.MX25 PDK. Sascha Hauer has tested a earlier version of this driver on an 
 i.MX27 based board. I included in this version some fixes from Sascha that 
 enable i.MX27 support.
 
 [1] https://patchwork.kernel.org/patch/67636/
 
 Changes v2 - v3
 Address more comments from Guennadi Liakhovetski.
 
 Applied part of Sashca's patch that I forgot in v2.
 
 Changes v1 - v2
 Addressed the comments of Guennadi Liakhovetski except from the following:
 
 1. The mclk_get_divisor implementation, since I don't know what this code 
is good for
 
 2. mx2_videobuf_release should not set pcdev-active on i.MX27, because 
mx27_camera_frame_done needs this pointer
 
 3. In mx27_camera_emma_buf_init I don't know the meaning of those hard 
coded magic numbers
 
 Applied i.MX27 fixes from Sascha.
 
 Baruch Siach (3):
   mx2_camera: Add soc_camera support for i.MX25/i.MX27
   mx27: add support for the CSI device
   mx25: add support for the CSI device
 
  arch/arm/mach-mx2/clock_imx27.c  |2 +-
  arch/arm/mach-mx2/devices.c  |   31 +
  arch/arm/mach-mx2/devices.h  |1 +
  arch/arm/mach-mx25/clock.c   |   14 +-
  arch/arm/mach-mx25/devices.c |   22 +
  arch/arm/mach-mx25/devices.h |1 +
  arch/arm/plat-mxc/include/mach/memory.h  |4 +-
  arch/arm/plat-mxc/include/mach/mx25.h|2 +
  arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
  drivers/media/video/Kconfig  |   13 +
  drivers/media/video/Makefile |1 +
  drivers/media/video/mx2_camera.c | 1488 
 ++
  12 files changed, 1620 insertions(+), 5 deletions(-)
  create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
  create mode 100644 drivers/media/video/mx2_camera.c
 

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-05-26 Thread Baruch Siach
Hi Guennadi,

Thanks for your comments. A question below.

On Tue, May 25, 2010 at 05:34:52PM +0200, Guennadi Liakhovetski wrote:
 On Mon, 24 May 2010, Baruch Siach wrote:

[snip]

  +static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev)
  +{
  +   unsigned long flags;
  +
  +   clk_disable(pcdev-clk_csi);
  +   writel(0, pcdev-base_csi + CSICR1);
  +   if (mx27_camera_emma(pcdev))
  +   writel(0, pcdev-base_emma + PRP_CNTL);
  +   else if (cpu_is_mx25()) {
 
 Missing braces in the if case.

Which braces are missing?

  +   spin_lock_irqsave(pcdev-lock, flags);
  +   pcdev-fb1_active = NULL;
  +   pcdev-fb2_active = NULL;
  +   writel(0, pcdev-base_csi + CSIDMASA_FB1);
  +   writel(0, pcdev-base_csi + CSIDMASA_FB2);
  +   spin_unlock_irqrestore(pcdev-lock, flags);
  +   }
  +}

[snip]

  +static void mx2_videobuf_queue(struct videobuf_queue *vq,
  +  struct videobuf_buffer *vb)
  +{
  +   struct soc_camera_device *icd = vq-priv_data;
  +   struct soc_camera_host *ici =
  +   to_soc_camera_host(icd-dev.parent);
  +   struct mx2_camera_dev *pcdev = ici-priv;
  +   struct mx2_buffer *buf = container_of(vb, struct mx2_buffer, vb);
  +   unsigned long flags;
  +   int ret;
  +
  +   dev_dbg(icd-dev, %s (vb=0x%p) 0x%08lx %d\n, __func__,
  +   vb, vb-baddr, vb-bsize);
  +
  +   spin_lock_irqsave(pcdev-lock, flags);
  +
  +   vb-state = VIDEOBUF_QUEUED;
  +   list_add_tail(vb-queue, pcdev-capture);
  +
  +   if (mx27_camera_emma(pcdev))
  +   goto out;
  +   else if (cpu_is_mx27()) {
  +   if (pcdev-active != NULL) {
 
 In v1 you had
 
  +   if (!pcdev-active) {
 
 i.e., opposite logic. v2 seems to be wrong.

Right. I'll fix this.

  +   ret = imx_dma_setup_single(pcdev-dma,
  +   videobuf_to_dma_contig(vb), vb-size,
  +   (u32)pcdev-base_dma + 0x10,
  +   DMA_MODE_READ);
  +   if (ret) {
  +   vb-state = VIDEOBUF_ERROR;
  +   wake_up(vb-done);
  +   goto out;
  +   }
  +
  +   vb-state = VIDEOBUF_ACTIVE;
 
 This is different from v1 of your patch. I meant not below this if, but 3 
 lines down:
 
  +   pcdev-active = buf;
  +   }
 
 ...here. Otherwise, if you don't enter the active == NULL if, your state 
 remains at QUEUED. OTOH, maybe this is deliberate and you want to only 
 set the buffer to ACTIVE if it's really becomming active?

Yes, this is intentional.

  +   } else { /* cpu_is_mx25() */

baruch

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/3] Driver for the i.MX2x CMOS Sensor Interface

2010-05-26 Thread Baruch Siach
This series contains a soc_camera driver for the i.MX25/i.MX27 CSI device, and
platform code for the i.MX25 and i.MX27 chips. This driver is based on a 
driver for i.MX27 CSI from Sascha Hauer, that  Alan Carvalho de Assis has 
posted in linux-media last December[1]. I tested the mx2_camera driver on the 
i.MX25 PDK. Sascha Hauer has tested a earlier version of this driver on an 
i.MX27 based board. I included in this version some fixes from Sascha that 
enable i.MX27 support.

[1] https://patchwork.kernel.org/patch/67636/

Changes v2 - v3
Address more comments from Guennadi Liakhovetski.

Applied part of Sashca's patch that I forgot in v2.

Changes v1 - v2
Addressed the comments of Guennadi Liakhovetski except from the following:

1. The mclk_get_divisor implementation, since I don't know what this code 
   is good for

2. mx2_videobuf_release should not set pcdev-active on i.MX27, because 
   mx27_camera_frame_done needs this pointer

3. In mx27_camera_emma_buf_init I don't know the meaning of those hard 
   coded magic numbers

Applied i.MX27 fixes from Sascha.

Baruch Siach (3):
  mx2_camera: Add soc_camera support for i.MX25/i.MX27
  mx27: add support for the CSI device
  mx25: add support for the CSI device

 arch/arm/mach-mx2/clock_imx27.c  |2 +-
 arch/arm/mach-mx2/devices.c  |   31 +
 arch/arm/mach-mx2/devices.h  |1 +
 arch/arm/mach-mx25/clock.c   |   14 +-
 arch/arm/mach-mx25/devices.c |   22 +
 arch/arm/mach-mx25/devices.h |1 +
 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx25.h|2 +
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
 drivers/media/video/Kconfig  |   13 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1488 ++
 12 files changed, 1620 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/3] mx27: add support for the CSI device

2010-05-26 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/mach-mx2/clock_imx27.c |2 +-
 arch/arm/mach-mx2/devices.c |   31 +++
 arch/arm/mach-mx2/devices.h |1 +
 3 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-mx2/clock_imx27.c b/arch/arm/mach-mx2/clock_imx27.c
index 0f0823c..5a1aa15 100644
--- a/arch/arm/mach-mx2/clock_imx27.c
+++ b/arch/arm/mach-mx2/clock_imx27.c
@@ -644,7 +644,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(spi_imx.1, NULL, cspi2_clk)
_REGISTER_CLOCK(spi_imx.2, NULL, cspi3_clk)
_REGISTER_CLOCK(imx-fb.0, NULL, lcdc_clk)
-   _REGISTER_CLOCK(NULL, csi, csi_clk)
+   _REGISTER_CLOCK(mx2-camera.0, NULL, csi_clk)
_REGISTER_CLOCK(fsl-usb2-udc, usb, usb_clk)
_REGISTER_CLOCK(fsl-usb2-udc, usb_ahb, usb_clk1)
_REGISTER_CLOCK(mxc-ehci.0, usb, usb_clk)
diff --git a/arch/arm/mach-mx2/devices.c b/arch/arm/mach-mx2/devices.c
index b91e412..6a49c79 100644
--- a/arch/arm/mach-mx2/devices.c
+++ b/arch/arm/mach-mx2/devices.c
@@ -40,6 +40,37 @@
 
 #include devices.h
 
+#ifdef CONFIG_MACH_MX27
+static struct resource mx27_camera_resources[] = {
+   {
+  .start = MX27_CSI_BASE_ADDR,
+  .end = MX27_CSI_BASE_ADDR + 0x1f,
+  .flags = IORESOURCE_MEM,
+   }, {
+  .start = MX27_EMMA_PRP_BASE_ADDR,
+  .end = MX27_EMMA_PRP_BASE_ADDR + 0x1f,
+  .flags = IORESOURCE_MEM,
+   }, {
+  .start = MX27_INT_CSI,
+  .end = MX27_INT_CSI,
+  .flags = IORESOURCE_IRQ,
+   },{
+  .start = MX27_INT_EMMAPRP,
+  .end = MX27_INT_EMMAPRP,
+  .flags = IORESOURCE_IRQ,
+   },
+};
+struct platform_device mx27_camera_device = {
+   .name = mx2-camera,
+   .id = 0,
+   .num_resources = ARRAY_SIZE(mx27_camera_resources),
+   .resource = mx27_camera_resources,
+   .dev = {
+   .coherent_dma_mask = 0x,
+   },
+};
+#endif
+
 /*
  * SPI master controller
  *
diff --git a/arch/arm/mach-mx2/devices.h b/arch/arm/mach-mx2/devices.h
index 84ed513..8bdf018 100644
--- a/arch/arm/mach-mx2/devices.h
+++ b/arch/arm/mach-mx2/devices.h
@@ -29,6 +29,7 @@ extern struct platform_device mxc_i2c_device1;
 extern struct platform_device mxc_sdhc_device0;
 extern struct platform_device mxc_sdhc_device1;
 extern struct platform_device mxc_otg_udc_device;
+extern struct platform_device mx27_camera_device;
 extern struct platform_device mxc_otg_host;
 extern struct platform_device mxc_usbh1;
 extern struct platform_device mxc_usbh2;
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/3] mx25: add support for the CSI device

2010-05-26 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/mach-mx25/clock.c|   14 --
 arch/arm/mach-mx25/devices.c  |   22 ++
 arch/arm/mach-mx25/devices.h  |1 +
 arch/arm/plat-mxc/include/mach/mx25.h |2 ++
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 1550149..7a98d18 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -129,6 +129,11 @@ static unsigned long get_rate_lcdc(struct clk *clk)
return get_rate_per(7);
 }
 
+static unsigned long get_rate_csi(struct clk *clk)
+{
+   return get_rate_per(0);
+}
+
 static unsigned long get_rate_otg(struct clk *clk)
 {
return 4800; /* FIXME */
@@ -174,6 +179,8 @@ DEFINE_CLOCK(cspi3_clk,  0, CCM_CGCR1,  7, get_rate_ipg, 
NULL, NULL);
 DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL,   NULL, NULL);
 DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL,  NULL, NULL);
 DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0,  7, NULL,  NULL, lcdc_ahb_clk);
+DEFINE_CLOCK(csi_ahb_clk, 0, CCM_CGCR0, 18, get_rate_csi, NULL, NULL);
+DEFINE_CLOCK(csi_per_clk, 0, CCM_CGCR0, 0, get_rate_csi, NULL, csi_ahb_clk);
 DEFINE_CLOCK(uart1_clk,  0, CCM_CGCR2, 14, get_rate_uart, NULL, uart_per_clk);
 DEFINE_CLOCK(uart2_clk,  0, CCM_CGCR2, 15, get_rate_uart, NULL, uart_per_clk);
 DEFINE_CLOCK(uart3_clk,  0, CCM_CGCR2, 16, get_rate_uart, NULL, uart_per_clk);
@@ -191,6 +198,7 @@ DEFINE_CLOCK(i2c_clk,0, CCM_CGCR0,  6, 
get_rate_i2c, NULL, NULL);
 DEFINE_CLOCK(fec_clk,   0, CCM_CGCR1, 15, get_rate_ipg, NULL, fec_ahb_clk);
 DEFINE_CLOCK(dryice_clk, 0, CCM_CGCR1,  8, get_rate_ipg, NULL, NULL);
 DEFINE_CLOCK(lcdc_clk,  0, CCM_CGCR1, 29, get_rate_lcdc, NULL, lcdc_per_clk);
+DEFINE_CLOCK(csi_clk,0, CCM_CGCR1,  4, get_rate_csi, NULL,  csi_per_clk);
 
 #define _REGISTER_CLOCK(d, n, c)   \
{   \
@@ -225,6 +233,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(fec.0, NULL, fec_clk)
_REGISTER_CLOCK(imxdi_rtc.0, NULL, dryice_clk)
_REGISTER_CLOCK(imx-fb.0, NULL, lcdc_clk)
+   _REGISTER_CLOCK(mx2-camera.0, NULL, csi_clk)
 };
 
 int __init mx25_clocks_init(void)
@@ -239,8 +248,9 @@ int __init mx25_clocks_init(void)
__raw_writel((0xf  16) | (3  26), CRM_BASE + CCM_CGCR1);
__raw_writel((1  5), CRM_BASE + CCM_CGCR2);
 
-   /* Clock source for lcdc is upll */
-   __raw_writel(__raw_readl(CRM_BASE+0x64) | (1  7), CRM_BASE + 0x64);
+   /* Clock source for lcdc and csi is upll */
+   __raw_writel(__raw_readl(CRM_BASE+0x64) | (1  7) | (1  0),
+   CRM_BASE + 0x64);
 
mxc_timer_init(gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54);
 
diff --git a/arch/arm/mach-mx25/devices.c b/arch/arm/mach-mx25/devices.c
index 3f4b8a0..bc6d189 100644
--- a/arch/arm/mach-mx25/devices.c
+++ b/arch/arm/mach-mx25/devices.c
@@ -500,3 +500,25 @@ struct platform_device mx25_fb_device = {
.coherent_dma_mask = 0x,
},
 };
+
+static struct resource mx25_csi_resources[] = {
+   {
+   .start  = MX25_CSI_BASE_ADDR,
+   .end= MX25_CSI_BASE_ADDR + 0xfff,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = MX25_INT_CSI,
+   .flags  = IORESOURCE_IRQ
+   },
+};
+
+struct platform_device mx25_csi_device = {
+   .name   = mx2-camera,
+   .id = 0,
+   .num_resources  = ARRAY_SIZE(mx25_csi_resources),
+   .resource   = mx25_csi_resources,
+   .dev= {
+   .coherent_dma_mask = 0x,
+   },
+};
diff --git a/arch/arm/mach-mx25/devices.h b/arch/arm/mach-mx25/devices.h
index 39560e1..1e80ac2 100644
--- a/arch/arm/mach-mx25/devices.h
+++ b/arch/arm/mach-mx25/devices.h
@@ -21,3 +21,4 @@ extern struct platform_device mx25_fec_device;
 extern struct platform_device mxc_nand_device;
 extern struct platform_device mx25_rtc_device;
 extern struct platform_device mx25_fb_device;
+extern struct platform_device mx25_csi_device;
diff --git a/arch/arm/plat-mxc/include/mach/mx25.h 
b/arch/arm/plat-mxc/include/mach/mx25.h
index 4eb6e33..5e6a8b5 100644
--- a/arch/arm/plat-mxc/include/mach/mx25.h
+++ b/arch/arm/plat-mxc/include/mach/mx25.h
@@ -34,11 +34,13 @@
 #define MX25_NFC_BASE_ADDR 0xbb00
 #define MX25_DRYICE_BASE_ADDR  0x53ffc000
 #define MX25_LCDC_BASE_ADDR0x53fbc000
+#define MX25_CSI_BASE_ADDR 0x53ff8000
 
 #define MX25_INT_DRYICE25
 #define MX25_INT_FEC   57
 #define MX25_INT_NANDFC33
 #define MX25_INT_LCDC  39
+#define MX25_INT_CSI   17
 
 #if defined(IMX_NEEDS_DEPRECATED_SYMBOLS)
 #define UART1_BASE_ADDRMX25_UART1_BASE_ADDR
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More

[PATCH v3 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-05-26 Thread Baruch Siach
This is the soc_camera support developed by Sascha Hauer for the i.MX27.  Alan
Carvalho de Assis modified the original driver to get it working on more recent
kernels. I modified it further to add support for i.MX25. This driver has been
tested on i.MX25 and i.MX27 based platforms.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
 drivers/media/video/Kconfig  |   13 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1488 ++
 5 files changed, 1550 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index c4b40c3..5803836 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -44,12 +44,12 @@
  */
 #define CONSISTENT_DMA_SIZE SZ_8M
 
-#elif defined(CONFIG_MX1_VIDEO)
+#elif defined(CONFIG_MX1_VIDEO) || defined(CONFIG_MX2_VIDEO)
 /*
  * Increase size of DMA-consistent memory region.
  * This is required for i.MX camera driver to capture at least four VGA frames.
  */
 #define CONSISTENT_DMA_SIZE SZ_4M
-#endif /* CONFIG_MX1_VIDEO */
+#endif /* CONFIG_MX1_VIDEO || CONFIG_MX2_VIDEO */
 
 #endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h 
b/arch/arm/plat-mxc/include/mach/mx2_cam.h
new file mode 100644
index 000..3c080a3
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h
@@ -0,0 +1,46 @@
+/*
+ * mx2-cam.h - i.MX27/i.MX25 camera driver header file
+ *
+ * Copyright (C) 2003, Intel Corporation
+ * Copyright (C) 2008, Sascha Hauer s.ha...@pengutronix.de
+ * Copyright (C) 2010, Baruch Siach bar...@tkos.co.il
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __MACH_MX2_CAM_H_
+#define __MACH_MX2_CAM_H_
+
+#define MX2_CAMERA_SWAP16  (1  0)
+#define MX2_CAMERA_EXT_VSYNC   (1  1)
+#define MX2_CAMERA_CCIR(1  2)
+#define MX2_CAMERA_CCIR_INTERLACE  (1  3)
+#define MX2_CAMERA_HSYNC_HIGH  (1  4)
+#define MX2_CAMERA_GATED_CLOCK (1  5)
+#define MX2_CAMERA_INV_DATA(1  6)
+#define MX2_CAMERA_PCLK_SAMPLE_RISING  (1  7)
+#define MX2_CAMERA_PACK_DIR_MSB(1  8)
+
+/**
+ * struct mx2_camera_platform_data - optional platform data for mx2_camera
+ * @flags: any combination of MX2_CAMERA_*
+ * @clk: clock rate of the csi block / 2
+ */
+struct mx2_camera_platform_data {
+   unsigned long flags;
+   unsigned long clk;
+};
+
+#endif /* __MACH_MX2_CAM_H_ */
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9644cf7..73b87a9 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -949,6 +949,19 @@ config VIDEO_OMAP2
---help---
  This is a v4l2 driver for the TI OMAP2 camera capture interface
 
+config MX2_VIDEO
+bool
+
+config VIDEO_MX2
+   tristate i.MX27/i.MX25 Camera Sensor Interface driver
+   depends on VIDEO_DEV  SOC_CAMERA  (MACH_MX27 || ARCH_MX25)
+   select VIDEOBUF_DMA_CONTIG
+   select MX2_VIDEO
+   ---help---
+ This is a v4l2 driver for the i.MX27 and the i.MX25 Camera Sensor
+ Interface
+
+
 #
 # USB Multimedia device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index c51c386..72615fd 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -156,6 +156,7 @@ obj-$(CONFIG_SOC_CAMERA)+= soc_camera.o 
soc_mediabus.o
 obj-$(CONFIG_SOC_CAMERA_PLATFORM)  += soc_camera_platform.o
 # soc-camera host drivers have to be linked after camera drivers
 obj-$(CONFIG_VIDEO_MX1)+= mx1_camera.o
+obj-$(CONFIG_VIDEO_MX2)+= mx2_camera.o
 obj-$(CONFIG_VIDEO_MX3)+= mx3_camera.o
 obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
 obj-$(CONFIG_VIDEO_SH_MOBILE_CEU)  += sh_mobile_ceu_camera.o
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
new file mode 100644
index 000..9bacfb2
--- /dev/null
+++ b

Re: [PATCH v2 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-05-25 Thread Baruch Siach
Hi Sascha,

On Tue, May 25, 2010 at 03:16:24PM +0200, Sascha Hauer wrote:
 On Mon, May 24, 2010 at 04:20:39PM +0300, Baruch Siach wrote:
  This is the soc_camera support developed by Sascha Hauer for the i.MX27.  
  Alan
  Carvalho de Assis modified the original driver to get it working on more 
  recent
  kernels. I modified it further to add support for i.MX25. This driver has 
  been
  tested on i.MX25 and i.MX27 based platforms.
  
  Signed-off-by: Baruch Siach bar...@tkos.co.il
  ---
   arch/arm/plat-mxc/include/mach/memory.h  |4 +-
   arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
   drivers/media/video/Kconfig  |   13 +
   drivers/media/video/Makefile |1 +
   drivers/media/video/mx2_camera.c | 1471 
  ++
   5 files changed, 1533 insertions(+), 2 deletions(-)
   create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
   create mode 100644 drivers/media/video/mx2_camera.c
  
 
 [snip]
 
  +
  +static int mclk_get_divisor(struct mx2_camera_dev *pcdev)
  +{
  +   dev_info(pcdev-dev, %s not implemented. Running at max speed\n,
  +   __func__);
  +
  +#if 0
  +   unsigned int mclk = pcdev-pdata-clk_csi;
  +   unsigned int pclk = clk_get_rate(pcdev-clk_csi);
  +   int i;
  +
  +   dev_dbg(pcdev-dev, %s: %ld %ld\n, __func__, mclk, pclk);
  +
  +   for (i = 0; i  0xf; i++)
  +   if ((i + 1) * 2 * mclk = pclk)
  +   break;
  +   return i;
  +#endif
  +   return 0;
  +}
 
 This function, if implemented properly, can be used to add an additional
 divider for the sensors master clock. On i.MX27 we can adjust the master
 clock using the clk_set_rate below which is sufficient, so you can
 remove this function completely.

Very good. I'll do this in the next version of this driver.

I guess I can also remove the mclk_get_divisor call at mx2_camera_add_device 
and just leave:

csicr1 = CSICR1_MCLKEN;

Right?

baruch

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/3] mx27: add support for the CSI device

2010-05-24 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/mach-mx2/clock_imx27.c |2 +-
 arch/arm/mach-mx2/devices.c |   31 +++
 arch/arm/mach-mx2/devices.h |1 +
 3 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-mx2/clock_imx27.c b/arch/arm/mach-mx2/clock_imx27.c
index 0f0823c..5a1aa15 100644
--- a/arch/arm/mach-mx2/clock_imx27.c
+++ b/arch/arm/mach-mx2/clock_imx27.c
@@ -644,7 +644,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(spi_imx.1, NULL, cspi2_clk)
_REGISTER_CLOCK(spi_imx.2, NULL, cspi3_clk)
_REGISTER_CLOCK(imx-fb.0, NULL, lcdc_clk)
-   _REGISTER_CLOCK(NULL, csi, csi_clk)
+   _REGISTER_CLOCK(mx2-camera.0, NULL, csi_clk)
_REGISTER_CLOCK(fsl-usb2-udc, usb, usb_clk)
_REGISTER_CLOCK(fsl-usb2-udc, usb_ahb, usb_clk1)
_REGISTER_CLOCK(mxc-ehci.0, usb, usb_clk)
diff --git a/arch/arm/mach-mx2/devices.c b/arch/arm/mach-mx2/devices.c
index b91e412..6a49c79 100644
--- a/arch/arm/mach-mx2/devices.c
+++ b/arch/arm/mach-mx2/devices.c
@@ -40,6 +40,37 @@
 
 #include devices.h
 
+#ifdef CONFIG_MACH_MX27
+static struct resource mx27_camera_resources[] = {
+   {
+  .start = MX27_CSI_BASE_ADDR,
+  .end = MX27_CSI_BASE_ADDR + 0x1f,
+  .flags = IORESOURCE_MEM,
+   }, {
+  .start = MX27_EMMA_PRP_BASE_ADDR,
+  .end = MX27_EMMA_PRP_BASE_ADDR + 0x1f,
+  .flags = IORESOURCE_MEM,
+   }, {
+  .start = MX27_INT_CSI,
+  .end = MX27_INT_CSI,
+  .flags = IORESOURCE_IRQ,
+   },{
+  .start = MX27_INT_EMMAPRP,
+  .end = MX27_INT_EMMAPRP,
+  .flags = IORESOURCE_IRQ,
+   },
+};
+struct platform_device mx27_camera_device = {
+   .name = mx2-camera,
+   .id = 0,
+   .num_resources = ARRAY_SIZE(mx27_camera_resources),
+   .resource = mx27_camera_resources,
+   .dev = {
+   .coherent_dma_mask = 0x,
+   },
+};
+#endif
+
 /*
  * SPI master controller
  *
diff --git a/arch/arm/mach-mx2/devices.h b/arch/arm/mach-mx2/devices.h
index 84ed513..8bdf018 100644
--- a/arch/arm/mach-mx2/devices.h
+++ b/arch/arm/mach-mx2/devices.h
@@ -29,6 +29,7 @@ extern struct platform_device mxc_i2c_device1;
 extern struct platform_device mxc_sdhc_device0;
 extern struct platform_device mxc_sdhc_device1;
 extern struct platform_device mxc_otg_udc_device;
+extern struct platform_device mx27_camera_device;
 extern struct platform_device mxc_otg_host;
 extern struct platform_device mxc_usbh1;
 extern struct platform_device mxc_usbh2;
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/3] mx25: add support for the CSI device

2010-05-24 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/mach-mx25/clock.c|   14 --
 arch/arm/mach-mx25/devices.c  |   22 ++
 arch/arm/mach-mx25/devices.h  |1 +
 arch/arm/plat-mxc/include/mach/mx25.h |2 ++
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 1550149..7a98d18 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -129,6 +129,11 @@ static unsigned long get_rate_lcdc(struct clk *clk)
return get_rate_per(7);
 }
 
+static unsigned long get_rate_csi(struct clk *clk)
+{
+   return get_rate_per(0);
+}
+
 static unsigned long get_rate_otg(struct clk *clk)
 {
return 4800; /* FIXME */
@@ -174,6 +179,8 @@ DEFINE_CLOCK(cspi3_clk,  0, CCM_CGCR1,  7, get_rate_ipg, 
NULL, NULL);
 DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL,   NULL, NULL);
 DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL,  NULL, NULL);
 DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0,  7, NULL,  NULL, lcdc_ahb_clk);
+DEFINE_CLOCK(csi_ahb_clk, 0, CCM_CGCR0, 18, get_rate_csi, NULL, NULL);
+DEFINE_CLOCK(csi_per_clk, 0, CCM_CGCR0, 0, get_rate_csi, NULL, csi_ahb_clk);
 DEFINE_CLOCK(uart1_clk,  0, CCM_CGCR2, 14, get_rate_uart, NULL, uart_per_clk);
 DEFINE_CLOCK(uart2_clk,  0, CCM_CGCR2, 15, get_rate_uart, NULL, uart_per_clk);
 DEFINE_CLOCK(uart3_clk,  0, CCM_CGCR2, 16, get_rate_uart, NULL, uart_per_clk);
@@ -191,6 +198,7 @@ DEFINE_CLOCK(i2c_clk,0, CCM_CGCR0,  6, 
get_rate_i2c, NULL, NULL);
 DEFINE_CLOCK(fec_clk,   0, CCM_CGCR1, 15, get_rate_ipg, NULL, fec_ahb_clk);
 DEFINE_CLOCK(dryice_clk, 0, CCM_CGCR1,  8, get_rate_ipg, NULL, NULL);
 DEFINE_CLOCK(lcdc_clk,  0, CCM_CGCR1, 29, get_rate_lcdc, NULL, lcdc_per_clk);
+DEFINE_CLOCK(csi_clk,0, CCM_CGCR1,  4, get_rate_csi, NULL,  csi_per_clk);
 
 #define _REGISTER_CLOCK(d, n, c)   \
{   \
@@ -225,6 +233,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(fec.0, NULL, fec_clk)
_REGISTER_CLOCK(imxdi_rtc.0, NULL, dryice_clk)
_REGISTER_CLOCK(imx-fb.0, NULL, lcdc_clk)
+   _REGISTER_CLOCK(mx2-camera.0, NULL, csi_clk)
 };
 
 int __init mx25_clocks_init(void)
@@ -239,8 +248,9 @@ int __init mx25_clocks_init(void)
__raw_writel((0xf  16) | (3  26), CRM_BASE + CCM_CGCR1);
__raw_writel((1  5), CRM_BASE + CCM_CGCR2);
 
-   /* Clock source for lcdc is upll */
-   __raw_writel(__raw_readl(CRM_BASE+0x64) | (1  7), CRM_BASE + 0x64);
+   /* Clock source for lcdc and csi is upll */
+   __raw_writel(__raw_readl(CRM_BASE+0x64) | (1  7) | (1  0),
+   CRM_BASE + 0x64);
 
mxc_timer_init(gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54);
 
diff --git a/arch/arm/mach-mx25/devices.c b/arch/arm/mach-mx25/devices.c
index 3f4b8a0..bc6d189 100644
--- a/arch/arm/mach-mx25/devices.c
+++ b/arch/arm/mach-mx25/devices.c
@@ -500,3 +500,25 @@ struct platform_device mx25_fb_device = {
.coherent_dma_mask = 0x,
},
 };
+
+static struct resource mx25_csi_resources[] = {
+   {
+   .start  = MX25_CSI_BASE_ADDR,
+   .end= MX25_CSI_BASE_ADDR + 0xfff,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = MX25_INT_CSI,
+   .flags  = IORESOURCE_IRQ
+   },
+};
+
+struct platform_device mx25_csi_device = {
+   .name   = mx2-camera,
+   .id = 0,
+   .num_resources  = ARRAY_SIZE(mx25_csi_resources),
+   .resource   = mx25_csi_resources,
+   .dev= {
+   .coherent_dma_mask = 0x,
+   },
+};
diff --git a/arch/arm/mach-mx25/devices.h b/arch/arm/mach-mx25/devices.h
index 39560e1..1e80ac2 100644
--- a/arch/arm/mach-mx25/devices.h
+++ b/arch/arm/mach-mx25/devices.h
@@ -21,3 +21,4 @@ extern struct platform_device mx25_fec_device;
 extern struct platform_device mxc_nand_device;
 extern struct platform_device mx25_rtc_device;
 extern struct platform_device mx25_fb_device;
+extern struct platform_device mx25_csi_device;
diff --git a/arch/arm/plat-mxc/include/mach/mx25.h 
b/arch/arm/plat-mxc/include/mach/mx25.h
index 4eb6e33..5e6a8b5 100644
--- a/arch/arm/plat-mxc/include/mach/mx25.h
+++ b/arch/arm/plat-mxc/include/mach/mx25.h
@@ -34,11 +34,13 @@
 #define MX25_NFC_BASE_ADDR 0xbb00
 #define MX25_DRYICE_BASE_ADDR  0x53ffc000
 #define MX25_LCDC_BASE_ADDR0x53fbc000
+#define MX25_CSI_BASE_ADDR 0x53ff8000
 
 #define MX25_INT_DRYICE25
 #define MX25_INT_FEC   57
 #define MX25_INT_NANDFC33
 #define MX25_INT_LCDC  39
+#define MX25_INT_CSI   17
 
 #if defined(IMX_NEEDS_DEPRECATED_SYMBOLS)
 #define UART1_BASE_ADDRMX25_UART1_BASE_ADDR
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More

[PATCH v2 0/3] Driver for the i.MX2x CMOS Sensor Interface

2010-05-24 Thread Baruch Siach
This series contains a soc_camera driver for the i.MX25/i.MX27 CSI device, and
platform code for the i.MX25 and i.MX27 chips. This driver is based on a 
driver for i.MX27 CSI from Sascha Hauer, that  Alan Carvalho de Assis has 
posted in linux-media last December[1]. I tested the mx2_camera driver on the 
i.MX25 PDK. Sascha Hauer has tested a earlier version of this driver on an 
i.MX27 based board. I included in this version some fixes from Sascha that 
enable i.MX27 support.

[1] https://patchwork.kernel.org/patch/67636/

Changes v1 - v2
Addressed the comments of Guennadi Liakhovetski except from the following:

1. The mclk_get_divisor implementation, since I don't know what this code 
   is good for

2. mx2_videobuf_release should not set pcdev-active on i.MX27, because 
   mx27_camera_frame_done needs this pointer

3. In mx27_camera_emma_buf_init I don't know the meaning of those hard 
   coded magic numbers

Applied i.MX27 fixes from Sascha.

Baruch Siach (3):
  mx2_camera: Add soc_camera support for i.MX25/i.MX27
  mx27: add support for the CSI device
  mx25: add support for the CSI device

 arch/arm/mach-mx2/clock_imx27.c  |2 +-
 arch/arm/mach-mx2/devices.c  |   31 +
 arch/arm/mach-mx2/devices.h  |1 +
 arch/arm/mach-mx25/clock.c   |   14 +-
 arch/arm/mach-mx25/devices.c |   22 +
 arch/arm/mach-mx25/devices.h |1 +
 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx25.h|2 +
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
 drivers/media/video/Kconfig  |   13 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1471 ++
 12 files changed, 1603 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-05-24 Thread Baruch Siach
This is the soc_camera support developed by Sascha Hauer for the i.MX27.  Alan
Carvalho de Assis modified the original driver to get it working on more recent
kernels. I modified it further to add support for i.MX25. This driver has been
tested on i.MX25 and i.MX27 based platforms.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
 drivers/media/video/Kconfig  |   13 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1471 ++
 5 files changed, 1533 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index c4b40c3..5803836 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -44,12 +44,12 @@
  */
 #define CONSISTENT_DMA_SIZE SZ_8M
 
-#elif defined(CONFIG_MX1_VIDEO)
+#elif defined(CONFIG_MX1_VIDEO) || defined(CONFIG_MX2_VIDEO)
 /*
  * Increase size of DMA-consistent memory region.
  * This is required for i.MX camera driver to capture at least four VGA frames.
  */
 #define CONSISTENT_DMA_SIZE SZ_4M
-#endif /* CONFIG_MX1_VIDEO */
+#endif /* CONFIG_MX1_VIDEO || CONFIG_MX2_VIDEO */
 
 #endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h 
b/arch/arm/plat-mxc/include/mach/mx2_cam.h
new file mode 100644
index 000..3c080a3
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h
@@ -0,0 +1,46 @@
+/*
+ * mx2-cam.h - i.MX27/i.MX25 camera driver header file
+ *
+ * Copyright (C) 2003, Intel Corporation
+ * Copyright (C) 2008, Sascha Hauer s.ha...@pengutronix.de
+ * Copyright (C) 2010, Baruch Siach bar...@tkos.co.il
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __MACH_MX2_CAM_H_
+#define __MACH_MX2_CAM_H_
+
+#define MX2_CAMERA_SWAP16  (1  0)
+#define MX2_CAMERA_EXT_VSYNC   (1  1)
+#define MX2_CAMERA_CCIR(1  2)
+#define MX2_CAMERA_CCIR_INTERLACE  (1  3)
+#define MX2_CAMERA_HSYNC_HIGH  (1  4)
+#define MX2_CAMERA_GATED_CLOCK (1  5)
+#define MX2_CAMERA_INV_DATA(1  6)
+#define MX2_CAMERA_PCLK_SAMPLE_RISING  (1  7)
+#define MX2_CAMERA_PACK_DIR_MSB(1  8)
+
+/**
+ * struct mx2_camera_platform_data - optional platform data for mx2_camera
+ * @flags: any combination of MX2_CAMERA_*
+ * @clk: clock rate of the csi block / 2
+ */
+struct mx2_camera_platform_data {
+   unsigned long flags;
+   unsigned long clk;
+};
+
+#endif /* __MACH_MX2_CAM_H_ */
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9644cf7..73b87a9 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -949,6 +949,19 @@ config VIDEO_OMAP2
---help---
  This is a v4l2 driver for the TI OMAP2 camera capture interface
 
+config MX2_VIDEO
+bool
+
+config VIDEO_MX2
+   tristate i.MX27/i.MX25 Camera Sensor Interface driver
+   depends on VIDEO_DEV  SOC_CAMERA  (MACH_MX27 || ARCH_MX25)
+   select VIDEOBUF_DMA_CONTIG
+   select MX2_VIDEO
+   ---help---
+ This is a v4l2 driver for the i.MX27 and the i.MX25 Camera Sensor
+ Interface
+
+
 #
 # USB Multimedia device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index c51c386..72615fd 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -156,6 +156,7 @@ obj-$(CONFIG_SOC_CAMERA)+= soc_camera.o 
soc_mediabus.o
 obj-$(CONFIG_SOC_CAMERA_PLATFORM)  += soc_camera_platform.o
 # soc-camera host drivers have to be linked after camera drivers
 obj-$(CONFIG_VIDEO_MX1)+= mx1_camera.o
+obj-$(CONFIG_VIDEO_MX2)+= mx2_camera.o
 obj-$(CONFIG_VIDEO_MX3)+= mx3_camera.o
 obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
 obj-$(CONFIG_VIDEO_SH_MOBILE_CEU)  += sh_mobile_ceu_camera.o
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
new file mode 100644
index 000..d0a3950
--- /dev/null
+++ b

Re: [PATCH v2 0/3] Driver for the i.MX2x CMOS Sensor Interface

2010-05-24 Thread Baruch Siach
Hi Guennadi,

On Mon, May 24, 2010 at 03:34:32PM +0200, Guennadi Liakhovetski wrote:
 On Mon, 24 May 2010, Baruch Siach wrote:
 
  This series contains a soc_camera driver for the i.MX25/i.MX27 CSI device, 
  and
  platform code for the i.MX25 and i.MX27 chips. This driver is based on a 
  driver for i.MX27 CSI from Sascha Hauer, that  Alan Carvalho de Assis has 
  posted in linux-media last December[1]. I tested the mx2_camera driver on 
  the 
  i.MX25 PDK. Sascha Hauer has tested a earlier version of this driver on an 
  i.MX27 based board. I included in this version some fixes from Sascha that 
  enable i.MX27 support.
  
  [1] https://patchwork.kernel.org/patch/67636/
 
 Thanks for the patches! I'll have a look at them in the next couple of 
 days. I presume, you do not expect this driver to make it into 2.6.35? rc1 
 is expected any time now, so, we'll take our time and prepare it for 
 2.6.36, right?

I don't expect this driver to be in 2.6.35. It's not that urgent. This code 
should also do some time in -next.

Thanks for your continued support.

baruch

  
  Changes v1 - v2
  Addressed the comments of Guennadi Liakhovetski except from the 
  following:
  
  1. The mclk_get_divisor implementation, since I don't know what this 
  code 
 is good for
  
  2. mx2_videobuf_release should not set pcdev-active on i.MX27, because 
 mx27_camera_frame_done needs this pointer
  
  3. In mx27_camera_emma_buf_init I don't know the meaning of those hard 
 coded magic numbers
  
  Applied i.MX27 fixes from Sascha.
  
  Baruch Siach (3):
mx2_camera: Add soc_camera support for i.MX25/i.MX27
mx27: add support for the CSI device
mx25: add support for the CSI device
  
   arch/arm/mach-mx2/clock_imx27.c  |2 +-
   arch/arm/mach-mx2/devices.c  |   31 +
   arch/arm/mach-mx2/devices.h  |1 +
   arch/arm/mach-mx25/clock.c   |   14 +-
   arch/arm/mach-mx25/devices.c |   22 +
   arch/arm/mach-mx25/devices.h |1 +
   arch/arm/plat-mxc/include/mach/memory.h  |4 +-
   arch/arm/plat-mxc/include/mach/mx25.h|2 +
   arch/arm/plat-mxc/include/mach/mx2_cam.h |   46 +
   drivers/media/video/Kconfig  |   13 +
   drivers/media/video/Makefile |1 +
   drivers/media/video/mx2_camera.c | 1471 
  ++
   12 files changed, 1603 insertions(+), 5 deletions(-)
   create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
   create mode 100644 drivers/media/video/mx2_camera.c
  
 
 ---
 Guennadi Liakhovetski, Ph.D.
 Freelance Open-Source Software Developer
 http://www.open-technology.de/

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] Driver for the i.MX2x CMOS Sensor Interface

2010-05-21 Thread Baruch Siach
Hi Sascha,

On Fri, May 21, 2010 at 09:20:45AM +0200, Sascha Hauer wrote:
 On Thu, May 06, 2010 at 04:09:38PM +0300, Baruch Siach wrote:
  This series contains a soc_camera driver for the i.MX25/i.MX27 CSI device, 
  and 
  platform code for the i.MX25 and i.MX27 chips. This driver is based on a 
  driver 
  for i.MX27 CSI from Sascha Hauer, that  Alan Carvalho de Assis has posted 
  in 
  linux-media last December[1]. Since all I have is a i.MX25 PDK paltform I 
  can't 
  test the mx27 specific code. Testers and comment are welcome.
  
  [1] https://patchwork.kernel.org/patch/67636/
  
  Baruch Siach (3):
mx2_camera: Add soc_camera support for i.MX25/i.MX27
mx27: add support for the CSI device
mx25: add support for the CSI device
 
 With the two additions I sent I can confirm this working on i.MX27, so
 no need to remove the related code.

Thanks. I'll add your patches to my queue and resend the series next week.

baruch

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-05-17 Thread Baruch Siach
Hi Sascha,

Thanks for your comments.

On Mon, May 17, 2010 at 09:27:20AM +0200, Sascha Hauer wrote:
 On Wed, May 12, 2010 at 09:02:29PM +0200, Guennadi Liakhovetski wrote:
  Hi Baruch
  
  Thanks for eventually mainlining this driver! A couple of comments below. 
  Sascha, would be great, if you could get it tested on imx27 with and 
  without emma.
 
 I will see what I can do. Testing and probably breathing life into a
 camera driver usually takes me two days given that the platform support
 is very outdated. I hope our customer is interested in this, then it
 would be possible to test it.
 
  BTW, if you say, that you use emma to avoid using the 
  standard DMA controller, why would anyone want not to use emma? Resource 
  conflict? There is also a question for you down in the comments, please, 
  skim over.
 
 I originally did not know how all the components should work together.
 Now I think it's the right way to use the EMMA to be able to scale
 images and to do colour conversions (which does not work with our Bayer
 format cameras, so I cannot test it).

So can I remove the non EMMA code from this driver? This will simplify the 
code quite a bit.

[snip]

   +static int mclk_get_divisor(struct mx2_camera_dev *pcdev)
   +{
   + dev_info(pcdev-dev, %s not implemented. Running at max speed\n,
   + __func__);
  
  Hm, why is this unimplemented?
  
   +
   +#if 0
   + unsigned int mclk = pcdev-pdata-clk_csi;
   + unsigned int pclk = clk_get_rate(pcdev-clk_csi);
   + int i;
   +
   + dev_dbg(pcdev-dev, %s: %ld %ld\n, __func__, mclk, pclk);
   +
   + for (i = 0; i  0xf; i++)
   + if ((i + 1) * 2 * mclk = pclk)
   + break;
  
  This doesn't look right. You increment the counter i, and terminate the
  loop as soon as (i + 1) * 2 * mclk = pclk. Obviously, if 2 * mclk = 
  pclk,
  this will terminate immediately, otherwise it will run until the end and
  return 0xf without satisfying the condition. What exactly are you trying to
  achieve? Find the _largest_ i, such that (i + 1) * 2 * mclk = pclk? Then
  why not just do i = pclk / 2 / mclk - 1?
  
   + return i;
   +#endif
   + return 0;
   +}

Can you shed some light on this?

Thanks,
baruch

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-05-12 Thread Baruch Siach
Hi Guennadi,
On Wed, May 12, 2010 at 09:02:29PM +0200, Guennadi Liakhovetski wrote:
 Thanks for eventually mainlining this driver! A couple of comments below.  
 Sascha, would be great, if you could get it tested on imx27 with and without 
 emma. BTW, if you say, that you use emma to avoid using the standard DMA 
 controller, why would anyone want not to use emma? Resource conflict? There 
 is also a question for you down in the comments, please, skim over.

Thank you very much for your detailed review and informative comments. I'll 
fix the problems that you've found, and post up updated patch after getting 
Sascha comments on the mx27 specific code.

baruch

 On Thu, 6 May 2010, Baruch Siach wrote:
 
  This is the soc_camera support developed by Sascha Hauer for the i.MX27.  
  Alan
  Carvalho de Assis modified the original driver to get it working on more 
  recent
  kernels. I modified it further to add support for i.MX25. This driver has 
  only
  been tested on the i.MX25 platform.
  
  Signed-off-by: Baruch Siach bar...@tkos.co.il
  ---

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] mx2_camera: Add soc_camera support for i.MX25/i.MX27

2010-05-06 Thread Baruch Siach
This is the soc_camera support developed by Sascha Hauer for the i.MX27.  Alan
Carvalho de Assis modified the original driver to get it working on more recent
kernels. I modified it further to add support for i.MX25. This driver has only
been tested on the i.MX25 platform.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   41 +
 drivers/media/video/Kconfig  |   14 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1396 ++
 5 files changed, 1454 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index c4b40c3..5803836 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -44,12 +44,12 @@
  */
 #define CONSISTENT_DMA_SIZE SZ_8M
 
-#elif defined(CONFIG_MX1_VIDEO)
+#elif defined(CONFIG_MX1_VIDEO) || defined(CONFIG_MX2_VIDEO)
 /*
  * Increase size of DMA-consistent memory region.
  * This is required for i.MX camera driver to capture at least four VGA frames.
  */
 #define CONSISTENT_DMA_SIZE SZ_4M
-#endif /* CONFIG_MX1_VIDEO */
+#endif /* CONFIG_MX1_VIDEO || CONFIG_MX2_VIDEO */
 
 #endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h 
b/arch/arm/plat-mxc/include/mach/mx2_cam.h
new file mode 100644
index 000..01b3bdc
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h
@@ -0,0 +1,41 @@
+/*
+mx2-cam.h - i.MX27/i.MX25 camera driver header file
+
+Copyright (C) 2003, Intel Corporation
+Copyright (C) 2008, Sascha Hauer s.ha...@pengutronix.de
+Copyright (C) 2010, Baruch Siach bar...@tkos.co.il
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __MACH_MX2_CAM_H_
+#define __MACH_MX2_CAM_H_
+
+#define MX2_CAMERA_SWAP16  (1  0)
+#define MX2_CAMERA_EXT_VSYNC   (1  1)
+#define MX2_CAMERA_CCIR(1  2)
+#define MX2_CAMERA_CCIR_INTERLACE  (1  3)
+#define MX2_CAMERA_HSYNC_HIGH  (1  4)
+#define MX2_CAMERA_GATED_CLOCK (1  5)
+#define MX2_CAMERA_INV_DATA(1  6)
+#define MX2_CAMERA_PCLK_SAMPLE_RISING  (1  7)
+#define MX2_CAMERA_PACK_DIR_MSB(1  8)
+
+struct mx2_camera_platform_data {
+   unsigned long flags;
+   unsigned long clk;
+};
+
+#endif /* __MACH_MX2_CAM_H_ */
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index f8fc865..4e230b8 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -949,6 +949,20 @@ config VIDEO_OMAP2
---help---
  This is a v4l2 driver for the TI OMAP2 camera capture interface
 
+config MX2_VIDEO
+bool
+
+config VIDEO_MX2
+   tristate i.MX27/i.MX25 Camera Sensor Interface driver
+   depends on VIDEO_DEV  (MACH_MX27 || ARCH_MX25)
+   select SOC_CAMERA
+   select VIDEOBUF_DMA_CONTIG
+   select MX2_VIDEO
+   ---help---
+ This is a v4l2 driver for the i.MX27 and the i.MX25 Camera Sensor
+ Interface
+
+
 #
 # USB Multimedia device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index b88b617..177af1a 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -156,6 +156,7 @@ obj-$(CONFIG_SOC_CAMERA)+= soc_camera.o 
soc_mediabus.o
 obj-$(CONFIG_SOC_CAMERA_PLATFORM)  += soc_camera_platform.o
 # soc-camera host drivers have to be linked after camera drivers
 obj-$(CONFIG_VIDEO_MX1)+= mx1_camera.o
+obj-$(CONFIG_VIDEO_MX2)+= mx2_camera.o
 obj-$(CONFIG_VIDEO_MX3)+= mx3_camera.o
 obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
 obj-$(CONFIG_VIDEO_SH_MOBILE_CEU)  += sh_mobile_ceu_camera.o
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
new file mode 100644
index 000..5d6fb08
--- /dev/null
+++ b/drivers/media/video/mx2_camera.c
@@ -0,0 +1,1396 @@
+/*
+ * V4L2 Driver for i.MX27/i.MX25 camera host
+ *
+ * Copyright (C) 2008, Sascha Hauer, Pengutronix

[PATCH 0/3] Driver for the i.MX2x CMOS Sensor Interface

2010-05-06 Thread Baruch Siach
This series contains a soc_camera driver for the i.MX25/i.MX27 CSI device, and 
platform code for the i.MX25 and i.MX27 chips. This driver is based on a driver 
for i.MX27 CSI from Sascha Hauer, that  Alan Carvalho de Assis has posted in 
linux-media last December[1]. Since all I have is a i.MX25 PDK paltform I can't 
test the mx27 specific code. Testers and comment are welcome.

[1] https://patchwork.kernel.org/patch/67636/

Baruch Siach (3):
  mx2_camera: Add soc_camera support for i.MX25/i.MX27
  mx27: add support for the CSI device
  mx25: add support for the CSI device

 arch/arm/mach-mx2/clock_imx27.c  |2 +-
 arch/arm/mach-mx2/devices.c  |   31 +
 arch/arm/mach-mx2/devices.h  |1 +
 arch/arm/mach-mx25/clock.c   |   14 +-
 arch/arm/mach-mx25/devices.c |   22 +
 arch/arm/mach-mx25/devices.h |1 +
 arch/arm/plat-mxc/include/mach/memory.h  |4 +-
 arch/arm/plat-mxc/include/mach/mx25.h|2 +
 arch/arm/plat-mxc/include/mach/mx2_cam.h |   41 +
 drivers/media/video/Kconfig  |   14 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/mx2_camera.c | 1396 ++
 12 files changed, 1524 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/mx2_cam.h
 create mode 100644 drivers/media/video/mx2_camera.c

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] mx27: add support for the CSI device

2010-05-06 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/mach-mx2/clock_imx27.c |2 +-
 arch/arm/mach-mx2/devices.c |   31 +++
 arch/arm/mach-mx2/devices.h |1 +
 3 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-mx2/clock_imx27.c b/arch/arm/mach-mx2/clock_imx27.c
index 0f0823c..5a1aa15 100644
--- a/arch/arm/mach-mx2/clock_imx27.c
+++ b/arch/arm/mach-mx2/clock_imx27.c
@@ -644,7 +644,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(spi_imx.1, NULL, cspi2_clk)
_REGISTER_CLOCK(spi_imx.2, NULL, cspi3_clk)
_REGISTER_CLOCK(imx-fb.0, NULL, lcdc_clk)
-   _REGISTER_CLOCK(NULL, csi, csi_clk)
+   _REGISTER_CLOCK(mx2-camera.0, NULL, csi_clk)
_REGISTER_CLOCK(fsl-usb2-udc, usb, usb_clk)
_REGISTER_CLOCK(fsl-usb2-udc, usb_ahb, usb_clk1)
_REGISTER_CLOCK(mxc-ehci.0, usb, usb_clk)
diff --git a/arch/arm/mach-mx2/devices.c b/arch/arm/mach-mx2/devices.c
index b91e412..de501ac 100644
--- a/arch/arm/mach-mx2/devices.c
+++ b/arch/arm/mach-mx2/devices.c
@@ -40,6 +40,37 @@
 
 #include devices.h
 
+#ifdef CONFIG_MACH_MX27
+static struct resource mx27_camera_resources[] = {
+   {
+  .start = CSI_BASE_ADDR,
+  .end = CSI_BASE_ADDR + 0x1f,
+  .flags = IORESOURCE_MEM,
+   }, {
+  .start = EMMA_PRP_BASE_ADDR,
+  .end = EMMA_PRP_BASE_ADDR + 0x1f,
+  .flags = IORESOURCE_MEM,
+   }, {
+  .start = MXC_INT_CSI,
+  .end = MXC_INT_CSI,
+  .flags = IORESOURCE_IRQ,
+   },{
+  .start = MXC_INT_EMMAPRP,
+  .end = MXC_INT_EMMAPRP,
+  .flags = IORESOURCE_IRQ,
+   },
+};
+struct platform_device mx27_camera_device = {
+   .name = mx2-camera,
+   .id = 0,
+   .num_resources = ARRAY_SIZE(mx27_camera_resources),
+   .resource = mx27_camera_resources,
+   .dev = {
+   .coherent_dma_mask = 0x,
+   },
+};
+#endif
+
 /*
  * SPI master controller
  *
diff --git a/arch/arm/mach-mx2/devices.h b/arch/arm/mach-mx2/devices.h
index 84ed513..8bdf018 100644
--- a/arch/arm/mach-mx2/devices.h
+++ b/arch/arm/mach-mx2/devices.h
@@ -29,6 +29,7 @@ extern struct platform_device mxc_i2c_device1;
 extern struct platform_device mxc_sdhc_device0;
 extern struct platform_device mxc_sdhc_device1;
 extern struct platform_device mxc_otg_udc_device;
+extern struct platform_device mx27_camera_device;
 extern struct platform_device mxc_otg_host;
 extern struct platform_device mxc_usbh1;
 extern struct platform_device mxc_usbh2;
-- 
1.7.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] mx25: add support for the CSI device

2010-05-06 Thread Baruch Siach
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 arch/arm/mach-mx25/clock.c|   14 --
 arch/arm/mach-mx25/devices.c  |   22 ++
 arch/arm/mach-mx25/devices.h  |1 +
 arch/arm/plat-mxc/include/mach/mx25.h |2 ++
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 1550149..7a98d18 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -129,6 +129,11 @@ static unsigned long get_rate_lcdc(struct clk *clk)
return get_rate_per(7);
 }
 
+static unsigned long get_rate_csi(struct clk *clk)
+{
+   return get_rate_per(0);
+}
+
 static unsigned long get_rate_otg(struct clk *clk)
 {
return 4800; /* FIXME */
@@ -174,6 +179,8 @@ DEFINE_CLOCK(cspi3_clk,  0, CCM_CGCR1,  7, get_rate_ipg, 
NULL, NULL);
 DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL,   NULL, NULL);
 DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL,  NULL, NULL);
 DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0,  7, NULL,  NULL, lcdc_ahb_clk);
+DEFINE_CLOCK(csi_ahb_clk, 0, CCM_CGCR0, 18, get_rate_csi, NULL, NULL);
+DEFINE_CLOCK(csi_per_clk, 0, CCM_CGCR0, 0, get_rate_csi, NULL, csi_ahb_clk);
 DEFINE_CLOCK(uart1_clk,  0, CCM_CGCR2, 14, get_rate_uart, NULL, uart_per_clk);
 DEFINE_CLOCK(uart2_clk,  0, CCM_CGCR2, 15, get_rate_uart, NULL, uart_per_clk);
 DEFINE_CLOCK(uart3_clk,  0, CCM_CGCR2, 16, get_rate_uart, NULL, uart_per_clk);
@@ -191,6 +198,7 @@ DEFINE_CLOCK(i2c_clk,0, CCM_CGCR0,  6, 
get_rate_i2c, NULL, NULL);
 DEFINE_CLOCK(fec_clk,   0, CCM_CGCR1, 15, get_rate_ipg, NULL, fec_ahb_clk);
 DEFINE_CLOCK(dryice_clk, 0, CCM_CGCR1,  8, get_rate_ipg, NULL, NULL);
 DEFINE_CLOCK(lcdc_clk,  0, CCM_CGCR1, 29, get_rate_lcdc, NULL, lcdc_per_clk);
+DEFINE_CLOCK(csi_clk,0, CCM_CGCR1,  4, get_rate_csi, NULL,  csi_per_clk);
 
 #define _REGISTER_CLOCK(d, n, c)   \
{   \
@@ -225,6 +233,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(fec.0, NULL, fec_clk)
_REGISTER_CLOCK(imxdi_rtc.0, NULL, dryice_clk)
_REGISTER_CLOCK(imx-fb.0, NULL, lcdc_clk)
+   _REGISTER_CLOCK(mx2-camera.0, NULL, csi_clk)
 };
 
 int __init mx25_clocks_init(void)
@@ -239,8 +248,9 @@ int __init mx25_clocks_init(void)
__raw_writel((0xf  16) | (3  26), CRM_BASE + CCM_CGCR1);
__raw_writel((1  5), CRM_BASE + CCM_CGCR2);
 
-   /* Clock source for lcdc is upll */
-   __raw_writel(__raw_readl(CRM_BASE+0x64) | (1  7), CRM_BASE + 0x64);
+   /* Clock source for lcdc and csi is upll */
+   __raw_writel(__raw_readl(CRM_BASE+0x64) | (1  7) | (1  0),
+   CRM_BASE + 0x64);
 
mxc_timer_init(gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54);
 
diff --git a/arch/arm/mach-mx25/devices.c b/arch/arm/mach-mx25/devices.c
index 3f4b8a0..bc6d189 100644
--- a/arch/arm/mach-mx25/devices.c
+++ b/arch/arm/mach-mx25/devices.c
@@ -500,3 +500,25 @@ struct platform_device mx25_fb_device = {
.coherent_dma_mask = 0x,
},
 };
+
+static struct resource mx25_csi_resources[] = {
+   {
+   .start  = MX25_CSI_BASE_ADDR,
+   .end= MX25_CSI_BASE_ADDR + 0xfff,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = MX25_INT_CSI,
+   .flags  = IORESOURCE_IRQ
+   },
+};
+
+struct platform_device mx25_csi_device = {
+   .name   = mx2-camera,
+   .id = 0,
+   .num_resources  = ARRAY_SIZE(mx25_csi_resources),
+   .resource   = mx25_csi_resources,
+   .dev= {
+   .coherent_dma_mask = 0x,
+   },
+};
diff --git a/arch/arm/mach-mx25/devices.h b/arch/arm/mach-mx25/devices.h
index 39560e1..1e80ac2 100644
--- a/arch/arm/mach-mx25/devices.h
+++ b/arch/arm/mach-mx25/devices.h
@@ -21,3 +21,4 @@ extern struct platform_device mx25_fec_device;
 extern struct platform_device mxc_nand_device;
 extern struct platform_device mx25_rtc_device;
 extern struct platform_device mx25_fb_device;
+extern struct platform_device mx25_csi_device;
diff --git a/arch/arm/plat-mxc/include/mach/mx25.h 
b/arch/arm/plat-mxc/include/mach/mx25.h
index 4eb6e33..5e6a8b5 100644
--- a/arch/arm/plat-mxc/include/mach/mx25.h
+++ b/arch/arm/plat-mxc/include/mach/mx25.h
@@ -34,11 +34,13 @@
 #define MX25_NFC_BASE_ADDR 0xbb00
 #define MX25_DRYICE_BASE_ADDR  0x53ffc000
 #define MX25_LCDC_BASE_ADDR0x53fbc000
+#define MX25_CSI_BASE_ADDR 0x53ff8000
 
 #define MX25_INT_DRYICE25
 #define MX25_INT_FEC   57
 #define MX25_INT_NANDFC33
 #define MX25_INT_LCDC  39
+#define MX25_INT_CSI   17
 
 #if defined(IMX_NEEDS_DEPRECATED_SYMBOLS)
 #define UART1_BASE_ADDRMX25_UART1_BASE_ADDR
-- 
1.7.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More

Re: [PATCH] v4l: soc_camera: fix bound checking of mbus_fmt[] index

2010-02-20 Thread Baruch Siach
Hi Guennadi,

On Fri, Feb 19, 2010 at 06:26:06PM +0100, Guennadi Liakhovetski wrote:
 On Thu, 18 Feb 2010, Baruch Siach wrote:
 
 Thanks for the patch, but I decided to improve it a bit. In fact, the only 
 case my original version was missing was code == V4L2_MBUS_FMT_FIXED, the 
 correct test would be
 
 (unsigned int)(code - V4L2_MBUS_FMT_FIXED -1) = ARRAY_SIZE(mbus_fmt)
 
 but to make it simple we can indeed break this into two tests, the 
 compiler will optimise it for us. So, if you agree, I'll push the version 
 of your patch, attached at the bottom of this mail, for 2.6.33, so, please 
 reply asap...

That's OK by me.

baruch

  When code = V4L2_MBUS_FMT_FIXED soc_mbus_get_fmtdesc returns a pointer to
  mbus_fmt[x], where x  0. Fix this.
  
  Signed-off-by: Baruch Siach bar...@tkos.co.il
  ---
   drivers/media/video/soc_mediabus.c |2 ++
   1 files changed, 2 insertions(+), 0 deletions(-)
  
  diff --git a/drivers/media/video/soc_mediabus.c 
  b/drivers/media/video/soc_mediabus.c
  index f8d5c87..a2808e2 100644
  --- a/drivers/media/video/soc_mediabus.c
  +++ b/drivers/media/video/soc_mediabus.c
  @@ -136,6 +136,8 @@ const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
   {
  if ((unsigned int)(code - V4L2_MBUS_FMT_FIXED)  ARRAY_SIZE(mbus_fmt))
  return NULL;
  +   if ((unsigned int)code = V4L2_MBUS_FMT_FIXED)
  +   return NULL;
  return mbus_fmt + code - V4L2_MBUS_FMT_FIXED - 1;
   }
   EXPORT_SYMBOL(soc_mbus_get_fmtdesc);
  -- 
  1.6.6.1
  
 
 ---
 Guennadi Liakhovetski, Ph.D.
 Freelance Open-Source Software Developer
 http://www.open-technology.de/
 
 
 From 00109d655b4b8cf25bc68a215966be810e372e87 Mon Sep 17 00:00:00 2001
 From: Baruch Siach bar...@tkos.co.il
 Date: Fri, 19 Feb 2010 18:09:25 +0100
 Subject: [PATCH] v4l: soc_camera: fix bound checking of mbus_fmt[] index
 
 When code = V4L2_MBUS_FMT_FIXED soc_mbus_get_fmtdesc returns a pointer to
 mbus_fmt[x], where x  0. Fix this.
 
 Signed-off-by: Baruch Siach bar...@tkos.co.il
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
  drivers/media/video/soc_mediabus.c |3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/media/video/soc_mediabus.c 
 b/drivers/media/video/soc_mediabus.c
 index f8d5c87..a4c0ef4 100644
 --- a/drivers/media/video/soc_mediabus.c
 +++ b/drivers/media/video/soc_mediabus.c
 @@ -134,7 +134,8 @@ EXPORT_SYMBOL(soc_mbus_bytes_per_line);
  const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
   enum v4l2_mbus_pixelcode code)
  {
 - if ((unsigned int)(code - V4L2_MBUS_FMT_FIXED)  ARRAY_SIZE(mbus_fmt))
 + if (code - V4L2_MBUS_FMT_FIXED  ARRAY_SIZE(mbus_fmt) ||
 + code = V4L2_MBUS_FMT_FIXED)
   return NULL;
   return mbus_fmt + code - V4L2_MBUS_FMT_FIXED - 1;
  }
 -- 
 1.6.2.4
 

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] v4l: soc_camera: fix bound checking of mbus_fmt[] index

2010-02-17 Thread Baruch Siach
When code = V4L2_MBUS_FMT_FIXED soc_mbus_get_fmtdesc returns a pointer to
mbus_fmt[x], where x  0. Fix this.

Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 drivers/media/video/soc_mediabus.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/soc_mediabus.c 
b/drivers/media/video/soc_mediabus.c
index f8d5c87..a2808e2 100644
--- a/drivers/media/video/soc_mediabus.c
+++ b/drivers/media/video/soc_mediabus.c
@@ -136,6 +136,8 @@ const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
 {
if ((unsigned int)(code - V4L2_MBUS_FMT_FIXED)  ARRAY_SIZE(mbus_fmt))
return NULL;
+   if ((unsigned int)code = V4L2_MBUS_FMT_FIXED)
+   return NULL;
return mbus_fmt + code - V4L2_MBUS_FMT_FIXED - 1;
 }
 EXPORT_SYMBOL(soc_mbus_get_fmtdesc);
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] RFC: mx27: Add soc_camera support

2010-02-04 Thread Baruch Siach
Hi Alan,

On Tue, Dec 15, 2009 at 12:07:43PM -0200, Alan Carvalho de Assis wrote:
 Please note: I just get it compiling and loaded correctly on the
 mainline kernel.
 
 If you have a board powered by i.MX27 and with a camera supported by
 soc_camera driver, I will be glad case you can do a try.

I'm now in the process of making this driver work on i.MX25. The CSI hardware 
of the i.MX25 is very similar to the i.MX27 one. If you have any updates for 
this driver please let me know.

baruch

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html