Re: [Patch v2 1/2] media: v4l: ti-vpe: Add CAL v4l2 camera capture driver

2015-11-13 Thread Hans Verkuil
On 10/20/2015 09:55 PM, Hans Verkuil wrote:
> On 10/16/2015 05:07 PM, Hans Verkuil wrote:
>> On 09/21/2015 10:04 PM, Benoit Parrot wrote:
>>> The Camera Adaptation Layer (CAL) is a block which consists of a dual
>>> port CSI2/MIPI camera capture engine.
>>> Port #0 can handle CSI2 camera connected to up to 4 data lanes.
>>> Port #1 can handle CSI2 camera connected to up to 2 data lanes.
>>> The driver implements the required API/ioctls to be V4L2 compliant.
>>> Driver supports the following:
>>> - V4L2 API using DMABUF/MMAP buffer access based on videobuf2 api
>>> - Asynchronous sensor sub device registration
>>> - DT support
>>>
>>> Signed-off-by: Benoit Parrot 
>>> ---
>>>  drivers/media/platform/Kconfig   |   12 +
>>>  drivers/media/platform/Makefile  |2 +
>>>  drivers/media/platform/ti-vpe/Makefile   |4 +
>>>  drivers/media/platform/ti-vpe/cal.c  | 2161 
>>> ++
>>>  drivers/media/platform/ti-vpe/cal_regs.h |  779 +++
>>>  5 files changed, 2958 insertions(+)
>>>  create mode 100644 drivers/media/platform/ti-vpe/cal.c
>>>  create mode 100644 drivers/media/platform/ti-vpe/cal_regs.h
>>>
>>> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
>>> index dc75694ac12d..c7f5704c56a2 100644
>>> --- a/drivers/media/platform/Kconfig
>>> +++ b/drivers/media/platform/Kconfig
>>> @@ -120,6 +120,18 @@ source "drivers/media/platform/s5p-tv/Kconfig"
>>>  source "drivers/media/platform/am437x/Kconfig"
>>>  source "drivers/media/platform/xilinx/Kconfig"
>>>  
>>> +config VIDEO_TI_CAL
>>> +   tristate "TI CAL (Camera Adaptation Layer) driver"
>>> +   depends on VIDEO_DEV && VIDEO_V4L2 && SOC_DRA7XX
>>> +   depends on VIDEO_V4L2_SUBDEV_API
>>> +   depends on VIDEOBUF2_DMA_CONTIG
>>
>> This should be:
>>
>>depends on VIDEO_DEV && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
>>depends on SOC_DRA7XX || COMPILE_TEST
>>select VIDEOBUF2_DMA_CONTIG
>>
>>> +   default n
>>> +   ---help---
>>> + Support for the TI CAL (Camera Adaptation Layer) block
>>> + found on DRA72X SoC.
>>> + In TI Technical Reference Manual this module is referred as
>>> + Camera Interface Subsystem (CAMSS).
>>> +
>>>  endif # V4L_PLATFORM_DRIVERS
>>>  
>>>  menuconfig V4L_MEM2MEM_DRIVERS
>>
>> By compiling with COMPILE_TEST I found a number of compile warnings and it 
>> also no
>> longer compiled due to vb2 changes. Both are fixed in the patch below.
>>
>> SoB for the patch: Signed-off-by: Hans Verkuil 
>>
>> That said, I'll postpone merging this until the remainder of the vb2 split 
>> patches
>> have been merged. When that's done this driver will have to be changed some 
>> more.
> 
> OK, the vb2 split patches were just merged. Can you rebase and repost?

Ping!

I'd like to merge this driver, so if you can rebase and take care of the 
trivial comments
I made in my review?

Thanks,

Hans

--
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/2] media: v4l: ti-vpe: Add CAL v4l2 camera capture driver

2015-10-20 Thread Hans Verkuil
On 10/16/2015 05:07 PM, Hans Verkuil wrote:
> On 09/21/2015 10:04 PM, Benoit Parrot wrote:
>> The Camera Adaptation Layer (CAL) is a block which consists of a dual
>> port CSI2/MIPI camera capture engine.
>> Port #0 can handle CSI2 camera connected to up to 4 data lanes.
>> Port #1 can handle CSI2 camera connected to up to 2 data lanes.
>> The driver implements the required API/ioctls to be V4L2 compliant.
>> Driver supports the following:
>> - V4L2 API using DMABUF/MMAP buffer access based on videobuf2 api
>> - Asynchronous sensor sub device registration
>> - DT support
>>
>> Signed-off-by: Benoit Parrot 
>> ---
>>  drivers/media/platform/Kconfig   |   12 +
>>  drivers/media/platform/Makefile  |2 +
>>  drivers/media/platform/ti-vpe/Makefile   |4 +
>>  drivers/media/platform/ti-vpe/cal.c  | 2161 
>> ++
>>  drivers/media/platform/ti-vpe/cal_regs.h |  779 +++
>>  5 files changed, 2958 insertions(+)
>>  create mode 100644 drivers/media/platform/ti-vpe/cal.c
>>  create mode 100644 drivers/media/platform/ti-vpe/cal_regs.h
>>
>> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
>> index dc75694ac12d..c7f5704c56a2 100644
>> --- a/drivers/media/platform/Kconfig
>> +++ b/drivers/media/platform/Kconfig
>> @@ -120,6 +120,18 @@ source "drivers/media/platform/s5p-tv/Kconfig"
>>  source "drivers/media/platform/am437x/Kconfig"
>>  source "drivers/media/platform/xilinx/Kconfig"
>>  
>> +config VIDEO_TI_CAL
>> +tristate "TI CAL (Camera Adaptation Layer) driver"
>> +depends on VIDEO_DEV && VIDEO_V4L2 && SOC_DRA7XX
>> +depends on VIDEO_V4L2_SUBDEV_API
>> +depends on VIDEOBUF2_DMA_CONTIG
> 
> This should be:
> 
>depends on VIDEO_DEV && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
>depends on SOC_DRA7XX || COMPILE_TEST
>select VIDEOBUF2_DMA_CONTIG
> 
>> +default n
>> +---help---
>> +  Support for the TI CAL (Camera Adaptation Layer) block
>> +  found on DRA72X SoC.
>> +  In TI Technical Reference Manual this module is referred as
>> +  Camera Interface Subsystem (CAMSS).
>> +
>>  endif # V4L_PLATFORM_DRIVERS
>>  
>>  menuconfig V4L_MEM2MEM_DRIVERS
> 
> By compiling with COMPILE_TEST I found a number of compile warnings and it 
> also no
> longer compiled due to vb2 changes. Both are fixed in the patch below.
> 
> SoB for the patch: Signed-off-by: Hans Verkuil 
> 
> That said, I'll postpone merging this until the remainder of the vb2 split 
> patches
> have been merged. When that's done this driver will have to be changed some 
> more.

OK, the vb2 split patches were just merged. Can you rebase and repost?

Thanks,

Hans
--
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/2] media: v4l: ti-vpe: Add CAL v4l2 camera capture driver

2015-10-16 Thread Hans Verkuil
On 09/21/2015 10:04 PM, Benoit Parrot wrote:
> The Camera Adaptation Layer (CAL) is a block which consists of a dual
> port CSI2/MIPI camera capture engine.
> Port #0 can handle CSI2 camera connected to up to 4 data lanes.
> Port #1 can handle CSI2 camera connected to up to 2 data lanes.
> The driver implements the required API/ioctls to be V4L2 compliant.
> Driver supports the following:
> - V4L2 API using DMABUF/MMAP buffer access based on videobuf2 api
> - Asynchronous sensor sub device registration
> - DT support
> 
> Signed-off-by: Benoit Parrot 
> ---
>  drivers/media/platform/Kconfig   |   12 +
>  drivers/media/platform/Makefile  |2 +
>  drivers/media/platform/ti-vpe/Makefile   |4 +
>  drivers/media/platform/ti-vpe/cal.c  | 2161 
> ++
>  drivers/media/platform/ti-vpe/cal_regs.h |  779 +++
>  5 files changed, 2958 insertions(+)
>  create mode 100644 drivers/media/platform/ti-vpe/cal.c
>  create mode 100644 drivers/media/platform/ti-vpe/cal_regs.h
> 
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index dc75694ac12d..c7f5704c56a2 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -120,6 +120,18 @@ source "drivers/media/platform/s5p-tv/Kconfig"
>  source "drivers/media/platform/am437x/Kconfig"
>  source "drivers/media/platform/xilinx/Kconfig"
>  
> +config VIDEO_TI_CAL
> + tristate "TI CAL (Camera Adaptation Layer) driver"
> + depends on VIDEO_DEV && VIDEO_V4L2 && SOC_DRA7XX
> + depends on VIDEO_V4L2_SUBDEV_API
> + depends on VIDEOBUF2_DMA_CONTIG

This should be:

   depends on VIDEO_DEV && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
   depends on SOC_DRA7XX || COMPILE_TEST
   select VIDEOBUF2_DMA_CONTIG

> + default n
> + ---help---
> +   Support for the TI CAL (Camera Adaptation Layer) block
> +   found on DRA72X SoC.
> +   In TI Technical Reference Manual this module is referred as
> +   Camera Interface Subsystem (CAMSS).
> +
>  endif # V4L_PLATFORM_DRIVERS
>  
>  menuconfig V4L_MEM2MEM_DRIVERS

By compiling with COMPILE_TEST I found a number of compile warnings and it also 
no
longer compiled due to vb2 changes. Both are fixed in the patch below.

SoB for the patch: Signed-off-by: Hans Verkuil 

That said, I'll postpone merging this until the remainder of the vb2 split 
patches
have been merged. When that's done this driver will have to be changed some 
more.

BTW, I see one 'f->fmt.pix.priv = 0;' line in cal_try_fmt_vid_cap(): this can 
be removed,
it's no longer needed.

Regards,

Hans

diff --git a/drivers/media/platform/ti-vpe/cal.c 
b/drivers/media/platform/ti-vpe/cal.c
index 2516756..4d4564d 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -200,7 +200,7 @@ static char *fourcc_to_str(u32 fmt)
 /* buffer for one video frame */
 struct cal_buffer {
/* common v4l buffer stuff -- must be first */
-   struct vb2_buffer   vb;
+   struct vb2_v4l2_buffer  vb;
struct list_headlist;
const struct cal_fmt*fmt;
 };
@@ -400,8 +400,8 @@ static struct cm_data *cm_create(struct cal_dev *dev)
return cm->base;
}
 
-   cal_dbg(1, dev, "ioresource %s at  %x - %x\n",
-   cm->res->name, cm->res->start, cm->res->end);
+   cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
+   cm->res->name, >res->start, >res->end);
 
return cm;
 }
@@ -510,8 +510,8 @@ static struct cc_data *cc_create(struct cal_dev *dev, 
unsigned int core)
return cc->base;
}
 
-   cal_dbg(1, dev, "ioresource %s at  %x - %x\n",
-   cc->res->name, cc->res->start, cc->res->end);
+   cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
+   cc->res->name, >res->start, >res->end);
 
return cc;
 }
@@ -565,13 +565,13 @@ static void cal_top_reset(struct cal_dev *dev)
 
 static void cal_quickdump_regs(struct cal_dev *dev)
 {
-   cal_info(dev, "CAL Registers @ 0x%08x:\n", dev->res->start);
+   cal_info(dev, "CAL Registers @ 0x%pa:\n", >res->start);
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
   dev->base, (dev->res->end - dev->res->start + 1), false);
 
if (!dev->ctx[0]) {
-   cal_info(dev, "CSI2 Core 0 Registers @ 0x%08x:\n",
-dev->ctx[0]->cc->res->start);
+   cal_info(dev, "CSI2 Core 0 Registers @ %pa:\n",
+>ctx[0]->cc->res->start);
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
   dev->ctx[0]->cc->base,
   (dev->ctx[0]->cc->res->end -
@@ -580,8 +580,8 @@ static void cal_quickdump_regs(struct cal_dev *dev)
}
 
if (!dev->ctx[1]) {
-   cal_info(dev, "CSI2 Core 1 Registers @ 

[Patch v2 1/2] media: v4l: ti-vpe: Add CAL v4l2 camera capture driver

2015-09-21 Thread Benoit Parrot
The Camera Adaptation Layer (CAL) is a block which consists of a dual
port CSI2/MIPI camera capture engine.
Port #0 can handle CSI2 camera connected to up to 4 data lanes.
Port #1 can handle CSI2 camera connected to up to 2 data lanes.
The driver implements the required API/ioctls to be V4L2 compliant.
Driver supports the following:
- V4L2 API using DMABUF/MMAP buffer access based on videobuf2 api
- Asynchronous sensor sub device registration
- DT support

Signed-off-by: Benoit Parrot 
---
 drivers/media/platform/Kconfig   |   12 +
 drivers/media/platform/Makefile  |2 +
 drivers/media/platform/ti-vpe/Makefile   |4 +
 drivers/media/platform/ti-vpe/cal.c  | 2161 ++
 drivers/media/platform/ti-vpe/cal_regs.h |  779 +++
 5 files changed, 2958 insertions(+)
 create mode 100644 drivers/media/platform/ti-vpe/cal.c
 create mode 100644 drivers/media/platform/ti-vpe/cal_regs.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index dc75694ac12d..c7f5704c56a2 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -120,6 +120,18 @@ source "drivers/media/platform/s5p-tv/Kconfig"
 source "drivers/media/platform/am437x/Kconfig"
 source "drivers/media/platform/xilinx/Kconfig"
 
+config VIDEO_TI_CAL
+   tristate "TI CAL (Camera Adaptation Layer) driver"
+   depends on VIDEO_DEV && VIDEO_V4L2 && SOC_DRA7XX
+   depends on VIDEO_V4L2_SUBDEV_API
+   depends on VIDEOBUF2_DMA_CONTIG
+   default n
+   ---help---
+ Support for the TI CAL (Camera Adaptation Layer) block
+ found on DRA72X SoC.
+ In TI Technical Reference Manual this module is referred as
+ Camera Interface Subsystem (CAMSS).
+
 endif # V4L_PLATFORM_DRIVERS
 
 menuconfig V4L_MEM2MEM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index efa0295af87b..028a7233096b 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -18,6 +18,8 @@ obj-$(CONFIG_VIDEO_VIM2M) += vim2m.o
 
 obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/
 
+obj-$(CONFIG_VIDEO_TI_CAL) += ti-vpe/
+
 obj-$(CONFIG_VIDEO_MX2_EMMAPRP)+= mx2_emmaprp.o
 obj-$(CONFIG_VIDEO_CODA)   += coda/
 
diff --git a/drivers/media/platform/ti-vpe/Makefile 
b/drivers/media/platform/ti-vpe/Makefile
index be680f839e77..e236059a60ad 100644
--- a/drivers/media/platform/ti-vpe/Makefile
+++ b/drivers/media/platform/ti-vpe/Makefile
@@ -3,3 +3,7 @@ obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o
 ti-vpe-y := vpe.o sc.o csc.o vpdma.o
 
 ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
+
+obj-$(CONFIG_VIDEO_TI_CAL) += ti-cal.o
+
+ti-cal-y := cal.o
diff --git a/drivers/media/platform/ti-vpe/cal.c 
b/drivers/media/platform/ti-vpe/cal.c
new file mode 100644
index ..25167566be91
--- /dev/null
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -0,0 +1,2161 @@
+/*
+ * TI CAL camera interface driver
+ *
+ * Copyright (c) 2015 Texas Instruments Inc.
+ * Benoit Parrot, 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "cal_regs.h"
+
+#define CAL_MODULE_NAME "cal"
+
+#define MAX_WIDTH 1920
+#define MAX_HEIGHT 1200
+
+#define CAL_VERSION "0.1.0"
+
+MODULE_DESCRIPTION("TI CAL driver");
+MODULE_AUTHOR("Benoit Parrot, ");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(CAL_VERSION);
+
+static unsigned video_nr = -1;
+module_param(video_nr, uint, 0644);
+MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
+
+static unsigned debug;
+module_param(debug, uint, 0644);
+MODULE_PARM_DESC(debug, "activates debug info");
+
+/* timeperframe: min/max and default */
+static const struct v4l2_fract
+   tpf_default = {.numerator = 1001,   .denominator = 3};
+
+#define cal_dbg(level, caldev, fmt, arg...)\
+   v4l2_dbg(level, debug, >v4l2_dev, fmt, ##arg)
+#define cal_info(caldev, fmt, arg...)  \
+   v4l2_info(>v4l2_dev, fmt, ##arg)
+#define cal_err(caldev, fmt, arg...)   \
+   v4l2_err(>v4l2_dev, fmt, ##arg)
+
+#define ctx_dbg(level, ctx, fmt, arg...)   \
+   v4l2_dbg(level, debug, >v4l2_dev, fmt, ##arg)
+#define ctx_info(ctx, fmt, arg...) \
+   v4l2_info(>v4l2_dev, fmt, ##arg)
+#define ctx_err(ctx, fmt, arg...)  \
+   v4l2_err(>v4l2_dev, fmt, ##arg)
+
+#define CAL_NUM_INPUT 1
+#define CAL_NUM_CONTEXT 2
+
+/* --
+