Re: [PATCH v5 2/8] [media] stm32-dcmi: STM32 DCMI camera interface driver

2017-05-09 Thread Hugues FRUCHET
Hi Hans,
It's OK, feel free to change.
BR
Hugues.


On 05/06/2017 10:54 AM, Hans Verkuil wrote:
> Hi Hugues,
>
> On 05/05/2017 05:31 PM, Hugues Fruchet wrote:
>> This V4L2 subdev driver enables Digital Camera Memory Interface (DCMI)
>> of STMicroelectronics STM32 SoC series.
>>
>> Reviewed-by: Hans Verkuil 
>> Signed-off-by: Yannick Fertre 
>> Signed-off-by: Hugues Fruchet 
>> ---
>>  drivers/media/platform/Kconfig|   12 +
>>  drivers/media/platform/Makefile   |2 +
>>  drivers/media/platform/stm32/Makefile |1 +
>>  drivers/media/platform/stm32/stm32-dcmi.c | 1403 
>> +
>>  4 files changed, 1418 insertions(+)
>>  create mode 100644 drivers/media/platform/stm32/Makefile
>>  create mode 100644 drivers/media/platform/stm32/stm32-dcmi.c
>>
>> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
>> index ac026ee..de6e18b 100644
>> --- a/drivers/media/platform/Kconfig
>> +++ b/drivers/media/platform/Kconfig
>> @@ -114,6 +114,18 @@ config VIDEO_S3C_CAMIF
>>To compile this driver as a module, choose M here: the module
>>will be called s3c-camif.
>>
>> +config VIDEO_STM32_DCMI
>> +tristate "Digital Camera Memory Interface (DCMI) support"
>
> Is it OK with you if I change this to:
>
>   tristate "STM32 Digital Camera Memory Interface (DCMI) support"
>
> Right now the text gives no indication that this driver is for an STM32 
> platform.
>
> No need to spin a new patch, just let me know you're OK with it and I'll make
> the change.
>
> Regards,
>
>   Hans
>
>> +depends on VIDEO_V4L2 && OF && HAS_DMA
>> +depends on ARCH_STM32 || COMPILE_TEST
>> +select VIDEOBUF2_DMA_CONTIG
>> +---help---
>> +  This module makes the STM32 Digital Camera Memory Interface (DCMI)
>> +  available as a v4l2 device.
>> +
>> +  To compile this driver as a module, choose M here: the module
>> +  will be called stm32-dcmi.
>> +
>>  source "drivers/media/platform/soc_camera/Kconfig"
>>  source "drivers/media/platform/exynos4-is/Kconfig"
>>  source "drivers/media/platform/am437x/Kconfig"

Re: [PATCH v5 2/8] [media] stm32-dcmi: STM32 DCMI camera interface driver

2017-05-06 Thread Hans Verkuil
Hi Hugues,

On 05/05/2017 05:31 PM, Hugues Fruchet wrote:
> This V4L2 subdev driver enables Digital Camera Memory Interface (DCMI)
> of STMicroelectronics STM32 SoC series.
> 
> Reviewed-by: Hans Verkuil 
> Signed-off-by: Yannick Fertre 
> Signed-off-by: Hugues Fruchet 
> ---
>  drivers/media/platform/Kconfig|   12 +
>  drivers/media/platform/Makefile   |2 +
>  drivers/media/platform/stm32/Makefile |1 +
>  drivers/media/platform/stm32/stm32-dcmi.c | 1403 
> +
>  4 files changed, 1418 insertions(+)
>  create mode 100644 drivers/media/platform/stm32/Makefile
>  create mode 100644 drivers/media/platform/stm32/stm32-dcmi.c
> 
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index ac026ee..de6e18b 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -114,6 +114,18 @@ config VIDEO_S3C_CAMIF
> To compile this driver as a module, choose M here: the module
> will be called s3c-camif.
>  
> +config VIDEO_STM32_DCMI
> + tristate "Digital Camera Memory Interface (DCMI) support"

Is it OK with you if I change this to:

tristate "STM32 Digital Camera Memory Interface (DCMI) support"

Right now the text gives no indication that this driver is for an STM32 
platform.

No need to spin a new patch, just let me know you're OK with it and I'll make
the change.

Regards,

Hans

> + depends on VIDEO_V4L2 && OF && HAS_DMA
> + depends on ARCH_STM32 || COMPILE_TEST
> + select VIDEOBUF2_DMA_CONTIG
> + ---help---
> +   This module makes the STM32 Digital Camera Memory Interface (DCMI)
> +   available as a v4l2 device.
> +
> +   To compile this driver as a module, choose M here: the module
> +   will be called stm32-dcmi.
> +
>  source "drivers/media/platform/soc_camera/Kconfig"
>  source "drivers/media/platform/exynos4-is/Kconfig"
>  source "drivers/media/platform/am437x/Kconfig"


[PATCH v5 2/8] [media] stm32-dcmi: STM32 DCMI camera interface driver

2017-05-05 Thread Hugues Fruchet
This V4L2 subdev driver enables Digital Camera Memory Interface (DCMI)
of STMicroelectronics STM32 SoC series.

Reviewed-by: Hans Verkuil 
Signed-off-by: Yannick Fertre 
Signed-off-by: Hugues Fruchet 
---
 drivers/media/platform/Kconfig|   12 +
 drivers/media/platform/Makefile   |2 +
 drivers/media/platform/stm32/Makefile |1 +
 drivers/media/platform/stm32/stm32-dcmi.c | 1403 +
 4 files changed, 1418 insertions(+)
 create mode 100644 drivers/media/platform/stm32/Makefile
 create mode 100644 drivers/media/platform/stm32/stm32-dcmi.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index ac026ee..de6e18b 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -114,6 +114,18 @@ config VIDEO_S3C_CAMIF
  To compile this driver as a module, choose M here: the module
  will be called s3c-camif.
 
+config VIDEO_STM32_DCMI
+   tristate "Digital Camera Memory Interface (DCMI) support"
+   depends on VIDEO_V4L2 && OF && HAS_DMA
+   depends on ARCH_STM32 || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   ---help---
+ This module makes the STM32 Digital Camera Memory Interface (DCMI)
+ available as a v4l2 device.
+
+ To compile this driver as a module, choose M here: the module
+ will be called stm32-dcmi.
+
 source "drivers/media/platform/soc_camera/Kconfig"
 source "drivers/media/platform/exynos4-is/Kconfig"
 source "drivers/media/platform/am437x/Kconfig"
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 63303d6..231f3c2 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -68,6 +68,8 @@ obj-$(CONFIG_VIDEO_RCAR_VIN)  += rcar-vin/
 obj-$(CONFIG_VIDEO_ATMEL_ISC)  += atmel/
 obj-$(CONFIG_VIDEO_ATMEL_ISI)  += atmel/
 
+obj-$(CONFIG_VIDEO_STM32_DCMI) += stm32/
+
 ccflags-y += -I$(srctree)/drivers/media/i2c
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
diff --git a/drivers/media/platform/stm32/Makefile 
b/drivers/media/platform/stm32/Makefile
new file mode 100644
index 000..9b606a7
--- /dev/null
+++ b/drivers/media/platform/stm32/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_STM32_DCMI) += stm32-dcmi.o
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c 
b/drivers/media/platform/stm32/stm32-dcmi.c
new file mode 100644
index 000..348f025
--- /dev/null
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -0,0 +1,1403 @@
+/*
+ * Driver for STM32 Digital Camera Memory Interface
+ *
+ * Copyright (C) STMicroelectronics SA 2017
+ * Authors: Yannick Fertre 
+ *  Hugues Fruchet 
+ *  for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ *
+ * This driver is based on atmel_isi.c
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRV_NAME "stm32-dcmi"
+
+/* Registers offset for DCMI */
+#define DCMI_CR0x00 /* Control Register */
+#define DCMI_SR0x04 /* Status Register */
+#define DCMI_RIS   0x08 /* Raw Interrupt Status register */
+#define DCMI_IER   0x0C /* Interrupt Enable Register */
+#define DCMI_MIS   0x10 /* Masked Interrupt Status register */
+#define DCMI_ICR   0x14 /* Interrupt Clear Register */
+#define DCMI_ESCR  0x18 /* Embedded Synchronization Code Register */
+#define DCMI_ESUR  0x1C /* Embedded Synchronization Unmask Register */
+#define DCMI_CWSTRT0x20 /* Crop Window STaRT */
+#define DCMI_CWSIZE0x24 /* Crop Window SIZE */
+#define DCMI_DR0x28 /* Data Register */
+#define DCMI_IDR   0x2C /* IDentifier Register */
+
+/* Bits definition for control register (DCMI_CR) */
+#define CR_CAPTURE BIT(0)
+#define CR_CM  BIT(1)
+#define CR_CROPBIT(2)
+#define CR_JPEGBIT(3)
+#define CR_ESS BIT(4)
+#define CR_PCKPOL  BIT(5)
+#define CR_HSPOL   BIT(6)
+#define CR_VSPOL   BIT(7)
+#define CR_FCRC_0  BIT(8)
+#define CR_FCRC_1  BIT(9)
+#define CR_EDM_0   BIT(10)
+#define CR_EDM_1   BIT(11)
+#define CR_ENABLE  BIT(14)
+
+/* Bits definition for status register (DCMI_SR) */
+#define SR_HSYNC   BIT(0)
+#define SR_VSYNC   BIT(1)
+#define SR_FNE BIT(2)
+
+/*
+ * Bits definition for interrupt registers
+ * (DCMI_RIS, DCMI_IER, DCMI_MIS, DCMI_ICR)
+ */
+#define IT_FRAME   BIT(0)
+#define IT_OVR BIT(1)
+#define IT_ERR BIT(2)
+#define IT_VSYNC   BIT(3)
+#define IT_LINEBIT(4)
+
+enum state {
+   STOPPED = 0,
+   RUNNING,
+   STOPPING,
+};
+
+#define MIN_WIDTH  16U
+#define MAX_WIDTH  2048U
+#define MIN_HEIGHT 16U
+#define MAX_HEIGHT 2048U
+
+#define TIM