Re: [PATCH v5 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-16 Thread Arun Kumar K
Hi Sylwester

On Thu, Aug 15, 2013 at 5:02 PM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi,

 Thanks for the update. I'd like to possibly queue it for 3.12
 once the review comments are addressed and the DT maintainers
 are OK with that.


Thanks. Will post updated patchset today addressing all review comments.

Regards
Arun
--
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 02/13] [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings documentation

2013-08-16 Thread Arun Kumar K
Hi Sylwester,

On Thu, Aug 15, 2013 at 8:39 PM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 W dniu 2013-08-14 06:46, Arun Kumar K pisze:

 The patch adds the DT binding documentation for Samsung
 Exynos5 SoC series imaging subsystem (FIMC-IS).

 Signed-off-by: Arun Kumar K arun...@samsung.com
 Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
 ---
   .../devicetree/bindings/media/exynos5-fimc-is.txt  |   47
 
   1 file changed, 47 insertions(+)
   create mode 100644
 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt

 diff --git a/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 new file mode 100644
 index 000..bfd36df
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 @@ -0,0 +1,47 @@
 +Samsung EXYNOS5 SoC series Imaging Subsystem (FIMC-IS)
 +--
 +
 +The camera subsystem on Samsung Exynos5 SoC has some changes relative
 +to previous SoC versions. Exynos5 has almost similar MIPI-CSIS and
 +FIMC-LITE IPs but has a much improved version of FIMC-IS which can
 +handle sensor controls and camera post-processing operations. The
 +Exynos5 FIMC-IS has a dedicated ARM Cortex A5 processor, many
 +post-processing blocks (ISP, DRC, FD, ODC, DIS, 3DNR) and two
 +dedicated scalers (SCC and SCP).
 +
 +fimc-is node
 +
 +
 +Required properties:
 +
 +- compatible: must be samsung,exynos5250-fimc-is
 +- reg   : physical base address and size of the memory mapped
 +  registers
 +- interrupt-parent  : parent interrupt controller
 +- interrupts: fimc-is interrupt to the parent combiner


 Is it really only one interrupt or two as in case of Exynos4x12 ?
 Also it's probably more appropriate to say interrupt controller
 instead of combiner, not including details of the the FIMC-IS external
 interrupt controller in this binding.


It needs only one interrupt and that is the one from A5 to main ARM processor.
Will change it to controller.


 +- clocks: list of clock specifiers, corresponding to entries
 in
 +  clock-names property;
 +- clock-names   : must contain isp, mcu_isp, isp_div0,
 isp_div1,
 +  isp_divmpwm, mcu_isp_div0, mcu_isp_div1
 entries,
 +  matching entries in the clocks property.
 +- pmu   : phandle to the fimc-is pmu node describing the
 register
 +  base and size for FIMC-IS PMU.


 This property needs to be prefixed with samsung,.


Ok

Regards
Arun
--
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 v6 00/13] Exynos5 IS driver

2013-08-16 Thread Arun Kumar K
The patch series add support for Exynos5 camera subsystem. It
re-uses mipi-csis and fimc-lite from exynos4-is and adds a new
media device and fimc-is device drivers for exynos5.
The media device supports asynchronos subdev registration for the
fimc-is sensors and is tested on top of the patch series from Sylwester
for exynos4-is [1].

[1] http://www.mail-archive.com/linux-media@vger.kernel.org/msg64653.html

Changes from v5
---
- Addressed review comments from Sylwester
http://www.mail-archive.com/linux-media@vger.kernel.org/msg65578.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg65605.html

Changes from v4
---
- Addressed all review comments from Sylwester
- Added separate PMU node as suggested by Stephen Warren
- Added phandle based discovery of subdevs instead of node name

Changes from v3
---
- Dropped the RFC tag
- Addressed all review comments from Sylwester and Sachin
- Removed clock provider for media dev
- Added s5k4e5 sensor devicetree binding doc

Changes from v2
---
- Added exynos5 media device driver from Shaik to this series
- Added ISP pipeline support in media device driver
- Based on Sylwester's latest exynos4-is development
- Asynchronos registration of sensor subdevs
- Made independent IS-sensor support
- Add s5k4e5 sensor driver
- Addressed review comments from Sylwester, Hans, Andrzej, Sachin

Changes from v1
---
- Addressed all review comments from Sylwester
- Made sensor subdevs as independent i2c devices
- Lots of cleanup
- Debugfs support added
- Removed PMU global register access

Arun Kumar K (12):
  [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings
documentation
  [media] exynos5-fimc-is: Add driver core files
  [media] exynos5-fimc-is: Add common driver header files
  [media] exynos5-fimc-is: Add register definition and context header
  [media] exynos5-fimc-is: Add isp subdev
  [media] exynos5-fimc-is: Add scaler subdev
  [media] exynos5-fimc-is: Add sensor interface
  [media] exynos5-fimc-is: Add the hardware pipeline control
  [media] exynos5-fimc-is: Add the hardware interface module
  [media] exynos5-is: Add Kconfig and Makefile
  V4L: s5k6a3: Change sensor min/max resolutions
  V4L: Add driver for s5k4e5 image sensor

Shaik Ameer Basha (1):
  [media] exynos5-is: Adding media device driver for exynos5

 .../devicetree/bindings/media/exynos5-fimc-is.txt  |   47 +
 .../devicetree/bindings/media/exynos5-mdev.txt |  126 ++
 .../devicetree/bindings/media/i2c/s5k4e5.txt   |   43 +
 drivers/media/i2c/Kconfig  |8 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k4e5.c |  361 +
 drivers/media/i2c/s5k6a3.c |   19 +-
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |   20 +
 drivers/media/platform/exynos5-is/Makefile |7 +
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1210 ++
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  126 ++
 drivers/media/platform/exynos5-is/fimc-is-cmd.h|  187 +++
 drivers/media/platform/exynos5-is/fimc-is-core.c   |  413 +
 drivers/media/platform/exynos5-is/fimc-is-core.h   |  132 ++
 drivers/media/platform/exynos5-is/fimc-is-err.h|  257 +++
 .../media/platform/exynos5-is/fimc-is-interface.c  |  810 ++
 .../media/platform/exynos5-is/fimc-is-interface.h  |  125 ++
 drivers/media/platform/exynos5-is/fimc-is-isp.c|  534 ++
 drivers/media/platform/exynos5-is/fimc-is-isp.h|   90 ++
 .../media/platform/exynos5-is/fimc-is-metadata.h   |  767 +
 drivers/media/platform/exynos5-is/fimc-is-param.h  | 1159 ++
 .../media/platform/exynos5-is/fimc-is-pipeline.c   | 1692 
 .../media/platform/exynos5-is/fimc-is-pipeline.h   |  128 ++
 drivers/media/platform/exynos5-is/fimc-is-regs.h   |  105 ++
 drivers/media/platform/exynos5-is/fimc-is-scaler.c |  472 ++
 drivers/media/platform/exynos5-is/fimc-is-scaler.h |  106 ++
 drivers/media/platform/exynos5-is/fimc-is-sensor.c |   45 +
 drivers/media/platform/exynos5-is/fimc-is-sensor.h |   65 +
 drivers/media/platform/exynos5-is/fimc-is.h|  160 ++
 31 files changed, 9209 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 create mode 100644 Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
 create mode 100644 drivers/media/i2c/s5k4e5.c
 create mode 100644 drivers/media/platform/exynos5-is/Kconfig
 create mode 100644 drivers/media/platform/exynos5-is/Makefile
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h
 create mode 100644 drivers/media/platform

[PATCH v6 06/13] [media] exynos5-fimc-is: Add isp subdev

2013-08-16 Thread Arun Kumar K
fimc-is driver takes video data input from the ISP video node
which is added in this patch. This node accepts Bayer input
buffers which is given from the IS sensors.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-isp.c |  534 +++
 drivers/media/platform/exynos5-is/fimc-is-isp.h |   90 
 2 files changed, 624 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-isp.c 
b/drivers/media/platform/exynos5-is/fimc-is-isp.c
new file mode 100644
index 000..882c291
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-isp.c
@@ -0,0 +1,534 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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 media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+
+#define ISP_DRV_NAME fimc-is-isp
+
+static const struct fimc_is_fmt formats[] = {
+   {
+   .name   = Bayer GR-BG 8bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG8,
+   .depth  = { 8 },
+   .num_planes = 1,
+   },
+   {
+   .name   = Bayer GR-BG 10bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG10,
+   .depth  = { 16 },
+   .num_planes = 1,
+   },
+   {
+   .name   = Bayer GR-BG 12bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG12,
+   .depth  = { 16 },
+   .num_planes = 1,
+   },
+};
+#define NUM_FORMATS ARRAY_SIZE(formats)
+
+static const struct fimc_is_fmt *find_format(struct v4l2_format *f)
+{
+   unsigned int i;
+
+   for (i = 0; i  NUM_FORMATS; i++)
+   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
+   return formats[i];
+   return NULL;
+}
+
+static int isp_video_output_start_streaming(struct vb2_queue *vq,
+   unsigned int count)
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+
+   set_bit(STATE_RUNNING, isp-output_state);
+   return 0;
+}
+
+static int isp_video_output_stop_streaming(struct vb2_queue *vq)
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+
+   /* Release unused buffers */
+   while (!list_empty(isp-wait_queue)) {
+   buf = fimc_is_isp_wait_queue_get(isp);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+   while (!list_empty(isp-run_queue)) {
+   buf = fimc_is_isp_run_queue_get(isp);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+
+   clear_bit(STATE_RUNNING, isp-output_state);
+   return 0;
+}
+
+static int isp_video_output_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   const struct fimc_is_fmt *fmt = isp-fmt;
+   unsigned int wh, i;
+
+   if (!fmt)
+   return -EINVAL;
+
+   *num_planes = fmt-num_planes;
+   wh = isp-width * isp-height;
+
+   for (i = 0; i  *num_planes; i++) {
+   allocators[i] = isp-alloc_ctx;
+   sizes[i] = (wh * fmt-depth[i]) / 8;
+   }
+   return 0;
+}
+
+static int isp_video_output_buffer_init(struct vb2_buffer *vb)
+{
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb);
+
+   buf-paddr[0] = vb2_dma_contig_plane_dma_addr(vb, 0);
+   return 0;
+}
+
+static int isp_video_output_buffer_prepare(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   unsigned long size;
+
+   size = (isp-width * isp-height * isp-fmt-depth[0]) / 8;
+   if (vb2_plane_size(vb, 0)  size) {
+   v4l2_err(isp-subdev, User buffer too small (%ld  %ld)\n,
+vb2_plane_size(vb, 0), size);
+   return -EINVAL;
+   }
+   vb2_set_plane_payload(vb, 0, size);
+
+   return 0;
+}
+
+static void isp_video_output_buffer_queue(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb

[PATCH v6 05/13] [media] exynos5-fimc-is: Add register definition and context header

2013-08-16 Thread Arun Kumar K
This patch adds the register definition file for the fimc-is driver
and also the header file containing the main context for the driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-regs.h |  105 ++
 drivers/media/platform/exynos5-is/fimc-is.h  |  160 ++
 2 files changed, 265 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-regs.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-regs.h 
b/drivers/media/platform/exynos5-is/fimc-is-regs.h
new file mode 100644
index 000..06aa466
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-regs.h
@@ -0,0 +1,105 @@
+/*
+ * Samsung Exynos5 SoC series FIMC-IS driver
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd
+ * Arun Kumar K arun...@samsung.com
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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.
+ */
+
+#ifndef FIMC_IS_REGS_H
+#define FIMC_IS_REGS_H
+
+/* WDT_ISP register */
+#define WDT0x0017
+/* MCUCTL register */
+#define MCUCTL 0x0018
+/* MCU Controller Register */
+#define MCUCTLR(MCUCTL+0x00)
+#define MCUCTLR_AXI_ISPX_AWCACHE(x)((x)  16)
+#define MCUCTLR_AXI_ISPX_ARCACHE(x)((x)  12)
+#define MCUCTLR_MSWRST (1  0)
+/* Boot Base OFfset Address Register */
+#define BBOAR  (MCUCTL+0x04)
+#define BBOAR_BBOA(x)  ((x)  0)
+
+/* Interrupt Generation Register 0 from Host CPU to VIC */
+#define INTGR0 (MCUCTL+0x08)
+#define INTGR0_INTGC(n)(1  ((n) + 16))
+#define INTGR0_INTGD(n)(1  (n))
+
+/* Interrupt Clear Register 0 from Host CPU to VIC */
+#define INTCR0 (MCUCTL+0x0c)
+#define INTCR0_INTCC(n)(1  ((n) + 16))
+#define INTCR0_INTCD(n)(1  (n))
+
+/* Interrupt Mask Register 0 from Host CPU to VIC */
+#define INTMR0 (MCUCTL+0x10)
+#define INTMR0_INTMC(n)(1  ((n) + 16))
+#define INTMR0_INTMD(n)(1  (n))
+
+/* Interrupt Status Register 0 from Host CPU to VIC */
+#define INTSR0 (MCUCTL+0x14)
+#define INTSR0_GET_INTSD(n, x) (((x)  (n))  0x1)
+#define INTSR0_GET_INTSC(n, x) (((x)  ((n) + 16))  0x1)
+
+/* Interrupt Mask Status Register 0 from Host CPU to VIC */
+#define INTMSR0(MCUCTL+0x18)
+#define INTMSR0_GET_INTMSD(n, x)   (((x)  (n))  0x1)
+#define INTMSR0_GET_INTMSC(n, x)   (((x)  ((n) + 16))  0x1)
+
+/* Interrupt Generation Register 1 from ISP CPU to Host IC */
+#define INTGR1 (MCUCTL+0x1c)
+#define INTGR1_INTGC(n)(1  (n))
+
+/* Interrupt Clear Register 1 from ISP CPU to Host IC */
+#define INTCR1 (MCUCTL+0x20)
+#define INTCR1_INTCC(n)(1  (n))
+
+/* Interrupt Mask Register 1 from ISP CPU to Host IC */
+#define INTMR1 (MCUCTL+0x24)
+#define INTMR1_INTMC(n)(1  (n))
+
+/* Interrupt Status Register 1 from ISP CPU to Host IC */
+#define INTSR1 (MCUCTL+0x28)
+/* Interrupt Mask Status Register 1 from ISP CPU to Host IC */
+#define INTMSR1(MCUCTL+0x2c)
+/* Interrupt Clear Register 2 from ISP BLK's interrupts to Host IC */
+#define INTCR2 (MCUCTL+0x30)
+#define INTCR2_INTCC(n)(1  (n))
+
+/* Interrupt Mask Register 2 from ISP BLK's interrupts to Host IC */
+#define INTMR2 (MCUCTL+0x34)
+#define INTMR2_INTMCIS(n)  (1  (n))
+
+/* Interrupt Status Register 2 from ISP BLK's interrupts to Host IC */
+#define INTSR2 (MCUCTL+0x38)
+/* Interrupt Mask Status Register 2 from ISP BLK's interrupts to Host IC */
+#define INTMSR2(MCUCTL+0x3c)
+/* General Purpose Output Control Register (0~17) */
+#define GPOCTLR(MCUCTL+0x40)
+#define GPOCTLR_GPOG(n, x) ((x)  (n))
+
+/* General Purpose Pad Output Enable Register (0~17) */
+#define GPOENCTLR  (MCUCTL+0x44)
+#define GPOENCTLR_GPOEN0(n, x) ((x)  (n))
+
+/* General Purpose Input Control Register (0~17) */
+#define GPICTLR(MCUCTL+0x48)
+
+/* IS Shared Registers between ISP CPU and HOST CPU */
+#define ISSR(n)(MCUCTL + 0x80 + (n))
+
+/* PMU for FIMC-IS*/
+#define

[PATCH v6 07/13] [media] exynos5-fimc-is: Add scaler subdev

2013-08-16 Thread Arun Kumar K
FIMC-IS has two hardware scalers named as scaler-codec and
scaler-preview. This patch adds the common code handling the
video nodes and subdevs of both the scalers.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-scaler.c |  472 
 drivers/media/platform/exynos5-is/fimc-is-scaler.h |  106 +
 2 files changed, 578 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-scaler.c 
b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
new file mode 100644
index 000..82ba867
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
@@ -0,0 +1,472 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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 media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+
+#define IS_SCALER_DRV_NAME fimc-is-scaler
+
+static const struct fimc_is_fmt formats[] = {
+   {
+   .name   = YUV 4:2:0 3p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_YUV420M,
+   .depth  = {8, 2, 2},
+   .num_planes = 3,
+   },
+   {
+   .name   = YUV 4:2:0 2p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_NV12M,
+   .depth  = {8, 4},
+   .num_planes = 2,
+   },
+   {
+   .name   = YUV 4:2:2 1p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_NV16,
+   .depth  = {16},
+   .num_planes = 1,
+   },
+};
+#define NUM_FORMATS ARRAY_SIZE(formats)
+
+static const struct fimc_is_fmt *find_format(struct v4l2_format *f)
+{
+   unsigned int i;
+
+   for (i = 0; i  NUM_FORMATS; i++) {
+   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
+   return formats[i];
+   }
+   return NULL;
+}
+
+static int scaler_video_capture_start_streaming(struct vb2_queue *vq,
+   unsigned int count)
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   int ret;
+
+   ret = fimc_is_pipeline_scaler_start(ctx-pipeline,
+   ctx-scaler_id,
+   vq-num_buffers,
+   ctx-fmt-num_planes);
+   if (ret) {
+   v4l2_err(ctx-subdev, Scaler start failed.\n);
+   return -EINVAL;
+   }
+
+   set_bit(STATE_RUNNING, ctx-capture_state);
+   return 0;
+}
+
+static int scaler_video_capture_stop_streaming(struct vb2_queue *vq)
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+   int ret;
+
+   ret = fimc_is_pipeline_scaler_stop(ctx-pipeline, ctx-scaler_id);
+   if (ret)
+   v4l2_info(ctx-subdev, Scaler already stopped.\n);
+
+   /* Release un-used buffers */
+   while (!list_empty(ctx-wait_queue)) {
+   buf = fimc_is_scaler_wait_queue_get(ctx);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+   while (!list_empty(ctx-run_queue)) {
+   buf = fimc_is_scaler_run_queue_get(ctx);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+
+   clear_bit(STATE_RUNNING, ctx-capture_state);
+   return 0;
+}
+
+static int scaler_video_capture_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   const struct fimc_is_fmt *fmt = ctx-fmt;
+   unsigned int wh;
+   int i;
+
+   if (!fmt)
+   return -EINVAL;
+
+   *num_planes = fmt-num_planes;
+   wh = ctx-width * ctx-height;
+
+   for (i = 0; i  *num_planes; i++) {
+   allocators[i] = ctx-alloc_ctx;
+   sizes[i] = (wh * fmt-depth[i]) / 8;
+   }
+   return 0;
+}
+
+static int scaler_video_capture_buffer_init(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb);
+   const struct fimc_is_fmt *fmt;
+   int i;
+
+   fmt = ctx-fmt;
+   for (i = 0; i  fmt-num_planes; i++)
+   buf-paddr[i] = vb2_dma_contig_plane_dma_addr(vb, i

[PATCH v6 03/13] [media] exynos5-fimc-is: Add driver core files

2013-08-16 Thread Arun Kumar K
This driver is for the FIMC-IS IP available in Samsung Exynos5
SoC onwards. This patch adds the core files for the new driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-core.c |  413 ++
 drivers/media/platform/exynos5-is/fimc-is-core.h |  132 +++
 2 files changed, 545 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-core.c 
b/drivers/media/platform/exynos5-is/fimc-is-core.c
new file mode 100644
index 000..6910581
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-core.c
@@ -0,0 +1,413 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Arun Kumar K arun...@samsung.com
+ *
+ * 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 linux/bug.h
+#include linux/ctype.h
+#include linux/device.h
+#include linux/debugfs.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/err.h
+#include linux/firmware.h
+#include linux/fs.h
+#include linux/gpio.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_gpio.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/of_irq.h
+#include linux/pinctrl/consumer.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/types.h
+#include linux/videodev2.h
+
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-mem2mem.h
+#include media/v4l2-of.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+#include fimc-is-i2c.h
+
+#define CLK_MCU_ISP_DIV0_FREQ  (200 * 100)
+#define CLK_MCU_ISP_DIV1_FREQ  (100 * 100)
+#define CLK_ISP_DIV0_FREQ  (134 * 100)
+#define CLK_ISP_DIV1_FREQ  (68 * 100)
+#define CLK_ISP_DIVMPWM_FREQ   (34 * 100)
+
+static const char * const fimc_is_clock_name[] = {
+   [IS_CLK_ISP]= isp,
+   [IS_CLK_MCU_ISP]= mcu_isp,
+   [IS_CLK_ISP_DIV0]   = isp_div0,
+   [IS_CLK_ISP_DIV1]   = isp_div1,
+   [IS_CLK_ISP_DIVMPWM]= isp_divmpwm,
+   [IS_CLK_MCU_ISP_DIV0]   = mcu_isp_div0,
+   [IS_CLK_MCU_ISP_DIV1]   = mcu_isp_div1,
+};
+
+static void fimc_is_put_clocks(struct fimc_is *is)
+{
+   int i;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
+   if (IS_ERR(is-clock[i]))
+   continue;
+   clk_unprepare(is-clock[i]);
+   clk_put(is-clock[i]);
+   is-clock[i] = ERR_PTR(-EINVAL);
+   }
+}
+
+static int fimc_is_get_clocks(struct fimc_is *is)
+{
+   struct device *dev = is-pdev-dev;
+   int i, ret;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
+   is-clock[i] = clk_get(dev, fimc_is_clock_name[i]);
+   if (IS_ERR(is-clock[i]))
+   goto err;
+   ret = clk_prepare(is-clock[i]);
+   if (ret  0) {
+   clk_put(is-clock[i]);
+   is-clock[i] = ERR_PTR(-EINVAL);
+   goto err;
+   }
+   }
+   return 0;
+err:
+   fimc_is_put_clocks(is);
+   pr_err(Failed to get clock: %s\n, fimc_is_clock_name[i]);
+   return -ENXIO;
+}
+
+static int fimc_is_configure_clocks(struct fimc_is *is)
+{
+   int i, ret;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++)
+   is-clock[i] = ERR_PTR(-EINVAL);
+
+   ret = fimc_is_get_clocks(is);
+   if (ret)
+   return ret;
+
+   /* Set rates */
+   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV0],
+   CLK_MCU_ISP_DIV0_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV1],
+   CLK_MCU_ISP_DIV1_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV0], CLK_ISP_DIV0_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV1], CLK_ISP_DIV1_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIVMPWM],
+   CLK_ISP_DIVMPWM_FREQ);
+   return ret;
+}
+
+static void fimc_is_pipelines_destroy(struct fimc_is *is)
+{
+   int i;
+
+   for (i = 0; i  is-drvdata-num_instances; i++)
+   fimc_is_pipeline_destroy(is-pipeline[i]);
+}
+
+static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index

[PATCH v6 02/13] [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings documentation

2013-08-16 Thread Arun Kumar K
The patch adds the DT binding documentation for Samsung
Exynos5 SoC series imaging subsystem (FIMC-IS).

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/media/exynos5-fimc-is.txt  |   47 
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt 
b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
new file mode 100644
index 000..bc279b4
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
@@ -0,0 +1,47 @@
+Samsung EXYNOS5 SoC series Imaging Subsystem (FIMC-IS)
+--
+
+The camera subsystem on Samsung Exynos5 SoC has some changes relative
+to previous SoC versions. Exynos5 has almost similar MIPI-CSIS and
+FIMC-LITE IPs but has a much improved version of FIMC-IS which can
+handle sensor controls and camera post-processing operations. The
+Exynos5 FIMC-IS has a dedicated ARM Cortex A5 processor, many
+post-processing blocks (ISP, DRC, FD, ODC, DIS, 3DNR) and two
+dedicated scalers (SCC and SCP).
+
+fimc-is node
+
+
+Required properties:
+
+- compatible: must be samsung,exynos5250-fimc-is
+- reg   : physical base address and size of the memory mapped
+  registers
+- interrupt-parent  : parent interrupt controller
+- interrupts: fimc-is interrupt to the parent interrupt controller
+- clocks: list of clock specifiers, corresponding to entries in
+  clock-names property;
+- clock-names   : must contain isp, mcu_isp, isp_div0, isp_div1,
+  isp_divmpwm, mcu_isp_div0, mcu_isp_div1 entries,
+  matching entries in the clocks property.
+- samsung,pmu   : phandle to the fimc-is pmu node describing the register
+  base and size for FIMC-IS PMU.
+
+i2c-isp (ISP I2C bus controller) nodes
+--
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-i2c-isp for Exynos4212,
+ Exynos4412 and Exynos5250 SoCs;
+- reg  : physical base address and length of the registers set;
+- clocks   : must contain gate clock specifier for this controller;
+- clock-names  : must contain i2c_isp entry.
+
+For the i2c-isp node, it is required to specify a pinctrl state named 
default,
+according to the pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt.
+
+Device tree nodes of the image sensors controlled directly by the FIMC-IS
+firmware must be child nodes of their corresponding ISP I2C bus controller 
node.
+The data link of these image sensors must be specified using the common video
+interfaces bindings, defined in video-interfaces.txt.
-- 
1.7.9.5

--
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 v6 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-16 Thread Arun Kumar K
From: Shaik Ameer Basha shaik.am...@samsung.com

This patch adds support for media device for EXYNOS5 SoCs.
The current media device supports the following ips to connect
through the media controller framework.

* MIPI-CSIS
  Support interconnection(subdev interface) between devices

* FIMC-LITE
  Support capture interface from device(Sensor, MIPI-CSIS) to memory
  Support interconnection(subdev interface) between devices

* FIMC-IS
  Camera post-processing IP having multiple sub-nodes.

G-Scaler will be added later to the current media device.

The media device creates two kinds of pipelines for connecting
the above mentioned IPs.
The pipeline0 is uses Sensor, MIPI-CSIS and FIMC-LITE which captures
image data and dumps to memory.
Pipeline1 uses FIMC-IS components for doing post-processing
operations on the captured image and give scaled YUV output.

Pipeline0
  ++ +---+ +---+ ++
  | Sensor | -- | MIPI-CSIS | -- | FIMC-LITE | -- | Memory |
  ++ +---+ +---+ ++

Pipeline1
 ++  ++ +---+ +---+
 | Memory | --  |  ISP   | -- |SCC| -- |SCP|
 ++  ++ +---+ +---+

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 .../devicetree/bindings/media/exynos5-mdev.txt |  126 ++
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1210 
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  126 ++
 3 files changed, 1462 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h

diff --git a/Documentation/devicetree/bindings/media/exynos5-mdev.txt 
b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
new file mode 100644
index 000..b1299e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
@@ -0,0 +1,126 @@
+Samsung EXYNOS5 SoC Camera Subsystem
+
+
+The Exynos5 SoC Camera subsystem comprises of multiple sub-devices
+represented by separate device tree nodes. Currently this includes: FIMC-LITE,
+MIPI CSIS and FIMC-IS.
+
+The sub-device nodes are referenced using phandles in the common 'camera' node
+which also includes common properties of the whole subsystem not really
+specific to any single sub-device, like common camera port pins or the common
+camera bus clocks.
+
+Common 'camera' node
+
+
+Required properties:
+
+- compatible   : must be samsung,exynos5250-fimc
+- clocks   : list of clock specifiers, corresponding to entries in
+  the clock-names property;
+- clock-names  : must contain sclk_bayer entry
+- samsung,csis : list of phandles to the mipi-csis device nodes
+- samsung,fimc-lite: list of phandles to the fimc-lite device nodes
+- samsung,fimc-is  : phandle to the fimc-is device node
+
+The pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt must be used
+to define a required pinctrl state named default.
+
+'parallel-ports' node
+-
+
+This node should contain child 'port' nodes specifying active parallel video
+input ports. It includes camera A, camera B and RGB bay inputs.
+'reg' property in the port nodes specifies the input type:
+ 1 - parallel camport A
+ 2 - parallel camport B
+ 5 - RGB camera bay
+
+3, 4 are for MIPI CSI-2 bus and are already described in samsung-mipi-csis.txt
+
+Image sensor nodes
+--
+
+The sensor device nodes should be added to their control bus controller (e.g.
+I2C0) nodes and linked to a port node in the csis or the parallel-ports node,
+using the common video interfaces bindings, defined in video-interfaces.txt.
+
+Example:
+
+   aliases {
+   fimc-lite0 = fimc_lite_0
+   };
+
+   /* Parallel bus IF sensor */
+   i2c_0: i2c@1386 {
+   s5k6aa: sensor@3c {
+   compatible = samsung,s5k6aafx;
+   reg = 0x3c;
+   vddio-supply = ...;
+
+   clock-frequency = 2400;
+   clocks = ...;
+   clock-names = mclk;
+
+   port {
+   s5k6aa_ep: endpoint {
+   remote-endpoint = fimc0_ep;
+   bus-width = 8;
+   hsync-active = 0;
+   vsync-active = 1;
+   pclk-sample = 1;
+   };
+   };
+   };
+   };
+
+   /* MIPI CSI-2 bus IF sensor */
+   s5c73m3: sensor@1a {
+   compatible = samsung,s5c73m3

[PATCH v6 10/13] [media] exynos5-fimc-is: Add the hardware interface module

2013-08-16 Thread Arun Kumar K
The hardware interface module finally sends the commands to the
FIMC-IS firmware and runs the interrupt handler for getting the
responses.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../media/platform/exynos5-is/fimc-is-interface.c  |  810 
 .../media/platform/exynos5-is/fimc-is-interface.h  |  125 +++
 2 files changed, 935 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-interface.c 
b/drivers/media/platform/exynos5-is/fimc-is-interface.c
new file mode 100644
index 000..c5da6ff
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-interface.c
@@ -0,0 +1,810 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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 linux/debugfs.h
+#include linux/seq_file.h
+#include fimc-is.h
+#include fimc-is-cmd.h
+#include fimc-is-regs.h
+
+#define init_request_barrier(itf) mutex_init(itf-request_barrier)
+#define enter_request_barrier(itf) mutex_lock(itf-request_barrier)
+#define exit_request_barrier(itf) mutex_unlock(itf-request_barrier)
+
+static inline void itf_get_cmd(struct fimc_is_interface *itf,
+   struct fimc_is_msg *msg, unsigned int index)
+{
+   struct is_common_reg __iomem *com_regs = itf-com_regs;
+
+   memset(msg, 0, sizeof(*msg));
+
+   switch (index) {
+   case INTR_GENERAL:
+   msg-command = com_regs-ihcmd;
+   msg-instance = com_regs-ihc_sensorid;
+   memcpy(msg-param, com_regs-ihc_param,
+   4 * sizeof(msg-param[0]));
+   break;
+   case INTR_SCC_FDONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-scc_sensor_id;
+   memcpy(msg-param, com_regs-scc_param,
+   3 * sizeof(msg-param[0]));
+   break;
+   case INTR_SCP_FDONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-scp_sensor_id;
+   memcpy(msg-param, com_regs-scp_param,
+   3 * sizeof(msg-param[0]));
+   break;
+   case INTR_META_DONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-meta_sensor_id;
+   msg-param[0] = com_regs-meta_param1;
+   break;
+   case INTR_SHOT_DONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-shot_sensor_id;
+   memcpy(msg-param, com_regs-shot_param,
+   2 * sizeof(msg-param[0]));
+   break;
+   default:
+   dev_err(itf-dev, %s Unknown command\n, __func__);
+   break;
+   }
+}
+
+static inline unsigned int itf_get_intr(struct fimc_is_interface *itf)
+{
+   unsigned int status;
+   struct is_common_reg __iomem *com_regs = itf-com_regs;
+
+   status = readl(itf-regs + INTMSR1) | com_regs-ihcmd_iflag |
+   com_regs-scc_iflag |
+   com_regs-scp_iflag |
+   com_regs-meta_iflag |
+   com_regs-shot_iflag;
+
+   return status;
+}
+
+static void itf_set_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   unsigned long flags;
+   spin_lock_irqsave(itf-slock_state, flags);
+   __set_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+}
+
+static void itf_clr_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   unsigned long flags;
+   spin_lock_irqsave(itf-slock_state, flags);
+   __clear_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+}
+
+static int itf_get_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   int ret = 0;
+   unsigned long flags;
+
+   spin_lock_irqsave(itf-slock_state, flags);
+   ret = test_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+   return ret;
+}
+
+static void itf_init_wakeup(struct fimc_is_interface *itf)
+{
+   itf_set_state(itf, IS_IF_STATE_INIT);
+   wake_up(itf-irq_queue);
+}
+
+void itf_busy_wakeup(struct fimc_is_interface *itf)
+{
+   itf_clr_state(itf, IS_IF_STATE_BUSY);
+   wake_up(itf-irq_queue);
+}
+
+static int itf_wait_hw_ready(struct fimc_is_interface *itf)
+{
+   int t;
+   for (t = TRY_RECV_AWARE_COUNT; t = 0; t--) {
+   unsigned int cfg = readl(itf-regs + INTMSR0

[PATCH v6 09/13] [media] exynos5-fimc-is: Add the hardware pipeline control

2013-08-16 Thread Arun Kumar K
This patch adds the crucial hardware pipeline control for the
fimc-is driver. All the subdev nodes will call this pipeline
interfaces to reach the hardware. Responsibilities of this module
involves configuring and maintaining the hardware pipeline involving
multiple sub-ips like ISP, DRC, Scalers, ODC, 3DNR, FD etc.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../media/platform/exynos5-is/fimc-is-pipeline.c   | 1692 
 .../media/platform/exynos5-is/fimc-is-pipeline.h   |  128 ++
 2 files changed, 1820 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-pipeline.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-pipeline.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-pipeline.c 
b/drivers/media/platform/exynos5-is/fimc-is-pipeline.c
new file mode 100644
index 000..7d91469
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-pipeline.c
@@ -0,0 +1,1692 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Arun Kumar K arun...@samsung.com
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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 fimc-is.h
+#include fimc-is-pipeline.h
+#include fimc-is-metadata.h
+#include fimc-is-regs.h
+#include fimc-is-cmd.h
+#include media/videobuf2-dma-contig.h
+#include linux/delay.h
+
+/* Default setting values */
+#define DEFAULT_PREVIEW_STILL_WIDTH1280
+#define DEFAULT_PREVIEW_STILL_HEIGHT   720
+#define DEFAULT_CAPTURE_VIDEO_WIDTH1920
+#define DEFAULT_CAPTURE_VIDEO_HEIGHT   1080
+#define DEFAULT_CAPTURE_STILL_WIDTH2560
+#define DEFAULT_CAPTURE_STILL_HEIGHT   1920
+#define DEFAULT_CAPTURE_STILL_CROP_WIDTH   2560
+#define DEFAULT_CAPTURE_STILL_CROP_HEIGHT  1440
+#define DEFAULT_PREVIEW_VIDEO_WIDTH640
+#define DEFAULT_PREVIEW_VIDEO_HEIGHT   480
+
+/* Init params for pipeline devices */
+static const struct sensor_param init_sensor_param = {
+   .frame_rate = {
+   .frame_rate = 30,
+   },
+};
+
+static const struct isp_param init_isp_param = {
+   .control = {
+   .cmd = CONTROL_COMMAND_START,
+   .bypass = CONTROL_BYPASS_DISABLE,
+   },
+   .otf_input = {
+   .cmd = OTF_INPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = OTF_INPUT_FORMAT_BAYER,
+   .bitwidth = OTF_INPUT_BIT_WIDTH_10BIT,
+   .order = OTF_INPUT_ORDER_BAYER_GR_BG,
+   .frametime_max = 3,
+   },
+   .dma1_input = {
+   .cmd = DMA_INPUT_COMMAND_DISABLE,
+   },
+   .dma2_input = {
+   .cmd = DMA_INPUT_COMMAND_DISABLE,
+   },
+   .aa = {
+   .cmd = ISP_AA_COMMAND_START,
+   .target = ISP_AA_TARGET_AF | ISP_AA_TARGET_AE |
+   ISP_AA_TARGET_AWB,
+   .mode = ISP_AF_CONTINUOUS,
+   },
+   .flash = {
+   .cmd = ISP_FLASH_COMMAND_DISABLE,
+   .redeye = ISP_FLASH_REDEYE_DISABLE,
+   },
+   .awb = {
+   .cmd = ISP_AWB_COMMAND_AUTO,
+   },
+   .effect = {
+   .cmd = ISP_IMAGE_EFFECT_DISABLE,
+   },
+   .iso = {
+   .cmd = ISP_ISO_COMMAND_AUTO,
+   },
+   .adjust = {
+   .cmd = ISP_ADJUST_COMMAND_AUTO,
+   },
+   .metering = {
+   .cmd = ISP_METERING_COMMAND_CENTER,
+   .win_width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .win_height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   },
+   .afc = {
+   .cmd = ISP_AFC_COMMAND_AUTO,
+   },
+   .otf_output = {
+   .cmd = OTF_OUTPUT_COMMAND_ENABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = OTF_OUTPUT_FORMAT_YUV444,
+   .bitwidth = OTF_OUTPUT_BIT_WIDTH_12BIT,
+   .order = OTF_OUTPUT_ORDER_BAYER_GR_BG,
+   },
+   .dma1_output = {
+   .cmd = DMA_OUTPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = DMA_INPUT_FORMAT_YUV444,
+   .bitwidth = DMA_INPUT_BIT_WIDTH_8BIT,
+   .plane = 1,
+   .order = DMA_INPUT_ORDER_YCBCR,
+   },
+   .dma2_output = {
+   .cmd = DMA_OUTPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT

[PATCH v6 08/13] [media] exynos5-fimc-is: Add sensor interface

2013-08-16 Thread Arun Kumar K
Some sensors to be used with fimc-is are exclusively controlled
by the fimc-is firmware. This minimal sensor driver provides
the required info for the firmware to configure the sensors
sitting on I2C bus.

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-sensor.c |   45 ++
 drivers/media/platform/exynos5-is/fimc-is-sensor.h |   65 
 2 files changed, 110 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.c 
b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
new file mode 100644
index 000..475f1c3
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
@@ -0,0 +1,45 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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 fimc-is-sensor.h
+
+static const struct sensor_drv_data s5k6a3_drvdata = {
+   .id = FIMC_IS_SENSOR_ID_S5K6A3,
+   .open_timeout   = S5K6A3_OPEN_TIMEOUT,
+   .setfile_name   = exynos5_s5k6a3_setfile.bin,
+};
+
+static const struct sensor_drv_data s5k4e5_drvdata = {
+   .id = FIMC_IS_SENSOR_ID_S5K4E5,
+   .open_timeout   = S5K4E5_OPEN_TIMEOUT,
+   .setfile_name   = exynos5_s5k4e5_setfile.bin,
+};
+
+static const struct of_device_id fimc_is_sensor_of_ids[] = {
+   {
+   .compatible = samsung,s5k6a3,
+   .data   = s5k6a3_drvdata,
+   },
+   {
+   .compatible = samsung,s5k4e5,
+   .data   = s5k4e5_drvdata,
+   },
+   {  }
+};
+
+const struct sensor_drv_data *exynos5_is_sensor_get_drvdata(
+   struct device_node *node)
+{
+   const struct of_device_id *of_id;
+
+   of_id = of_match_node(fimc_is_sensor_of_ids, node);
+   return of_id ? of_id-data : NULL;
+}
diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.h 
b/drivers/media/platform/exynos5-is/fimc-is-sensor.h
new file mode 100644
index 000..0ba5733
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.h
@@ -0,0 +1,65 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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.
+ */
+#ifndef FIMC_IS_SENSOR_H_
+#define FIMC_IS_SENSOR_H_
+
+#include linux/of.h
+#include linux/types.h
+
+#define S5K6A3_OPEN_TIMEOUT2000 /* ms */
+#define S5K6A3_SENSOR_WIDTH1392
+#define S5K6A3_SENSOR_HEIGHT   1392
+
+#define S5K4E5_OPEN_TIMEOUT2000 /* ms */
+#define S5K4E5_SENSOR_WIDTH2560
+#define S5K4E5_SENSOR_HEIGHT   1920
+
+#define SENSOR_WIDTH_PADDING   16
+#define SENSOR_HEIGHT_PADDING  10
+
+enum fimc_is_sensor_id {
+   FIMC_IS_SENSOR_ID_S5K3H2 = 1,
+   FIMC_IS_SENSOR_ID_S5K6A3,
+   FIMC_IS_SENSOR_ID_S5K4E5,
+   FIMC_IS_SENSOR_ID_S5K3H7,
+   FIMC_IS_SENSOR_ID_CUSTOM,
+   FIMC_IS_SENSOR_ID_END
+};
+
+struct sensor_drv_data {
+   enum fimc_is_sensor_id id;
+   /* sensor open timeout in ms */
+   unsigned short open_timeout;
+   char *setfile_name;
+};
+
+/**
+ * struct fimc_is_sensor - fimc-is sensor data structure
+ * @drvdata: a pointer to the sensor's parameters data structure
+ * @i2c_bus: ISP I2C bus index (0...1)
+ * @width: sensor active width
+ * @height: sensor active height
+ * @pixel_width: sensor effective pixel width (width + padding)
+ * @pixel_height: sensor effective pixel height (height + padding)
+ */
+struct fimc_is_sensor {
+   const struct sensor_drv_data *drvdata;
+   unsigned int i2c_bus;
+   unsigned int width;
+   unsigned int height;
+   unsigned int pixel_width;
+   unsigned int pixel_height;
+};
+
+const struct sensor_drv_data *exynos5_is_sensor_get_drvdata(
+   struct device_node *node);
+
+#endif /* FIMC_IS_SENSOR_H_ */
-- 
1.7.9.5

--
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 v6 11/13] [media] exynos5-is: Add Kconfig and Makefile

2013-08-16 Thread Arun Kumar K
Adds Kconfig and Makefile for exynos5-is driver files.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |   20 
 drivers/media/platform/exynos5-is/Makefile |7 +++
 4 files changed, 29 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/Kconfig
 create mode 100644 drivers/media/platform/exynos5-is/Makefile

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 08de865..4b0475e 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -123,6 +123,7 @@ config VIDEO_S3C_CAMIF
 
 source drivers/media/platform/soc_camera/Kconfig
 source drivers/media/platform/exynos4-is/Kconfig
+source drivers/media/platform/exynos5-is/Kconfig
 source drivers/media/platform/s5p-tv/Kconfig
 
 endif # V4L_PLATFORM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index eee28dd..40bf09f 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)+= s5p-tv/
 
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)+= s5p-g2d/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_CAMERA) += exynos5-is/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos5-is/Kconfig 
b/drivers/media/platform/exynos5-is/Kconfig
new file mode 100644
index 000..b67d11a
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Kconfig
@@ -0,0 +1,20 @@
+config VIDEO_SAMSUNG_EXYNOS5_CAMERA
+   bool Samsung Exynos5 SoC Camera Media Device driver
+   depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  PM_RUNTIME
+   depends on VIDEO_SAMSUNG_EXYNOS4_IS
+   help
+ This is a V4L2 media device driver for Exynos5 SoC series
+ camera subsystem.
+
+if VIDEO_SAMSUNG_EXYNOS5_CAMERA
+
+config VIDEO_SAMSUNG_EXYNOS5_FIMC_IS
+   tristate Samsung Exynos5 SoC FIMC-IS driver
+   depends on I2C  OF
+   depends on VIDEO_EXYNOS4_FIMC_IS
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ This is a V4L2 driver for Samsung Exynos5 SoC series Imaging
+ Subsystem known as FIMC-IS.
+
+endif #VIDEO_SAMSUNG_EXYNOS5_MDEV
diff --git a/drivers/media/platform/exynos5-is/Makefile 
b/drivers/media/platform/exynos5-is/Makefile
new file mode 100644
index 000..6cdb037
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Makefile
@@ -0,0 +1,7 @@
+ccflags-y += -Idrivers/media/platform/exynos4-is
+exynos5-fimc-is-objs := fimc-is-core.o fimc-is-isp.o fimc-is-scaler.o
+exynos5-fimc-is-objs += fimc-is-pipeline.o fimc-is-interface.o fimc-is-sensor.o
+exynos-mdevice-objs := exynos5-mdev.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_FIMC_IS) += exynos5-fimc-is.o
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_CAMERA) += exynos-mdevice.o
-- 
1.7.9.5

--
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 v6 12/13] V4L: s5k6a3: Change sensor min/max resolutions

2013-08-16 Thread Arun Kumar K
s5k6a3 sensor has actual pixel resolution of 1408x1402 against
the active resolution 1392x1392. The real resolution is needed
when raw sensor SRGB data is dumped to memory by fimc-lite.

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/i2c/s5k6a3.c |   19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index ccbb4fc..34c3165 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -25,10 +25,12 @@
 #include media/v4l2-async.h
 #include media/v4l2-subdev.h
 
-#define S5K6A3_SENSOR_MAX_WIDTH1392
-#define S5K6A3_SENSOR_MAX_HEIGHT   1392
-#define S5K6A3_SENSOR_MIN_WIDTH32
-#define S5K6A3_SENSOR_MIN_HEIGHT   32
+#define S5K6A3_SENSOR_MAX_WIDTH1408
+#define S5K6A3_SENSOR_MAX_HEIGHT   1402
+#define S5K6A3_SENSOR_ACTIVE_WIDTH 1392
+#define S5K6A3_SENSOR_ACTIVE_HEIGHT1392
+#define S5K6A3_SENSOR_MIN_WIDTH(32 + 16)
+#define S5K6A3_SENSOR_MIN_HEIGHT   (32 + 10)
 
 #define S5K6A3_DEF_PIX_WIDTH   1296
 #define S5K6A3_DEF_PIX_HEIGHT  732
@@ -107,10 +109,11 @@ static void s5k6a3_try_format(struct v4l2_mbus_framefmt 
*mf)
 
fmt = find_sensor_format(mf);
mf-code = fmt-code;
-   v4l_bound_align_image(mf-width, S5K6A3_SENSOR_MIN_WIDTH,
- S5K6A3_SENSOR_MAX_WIDTH, 0,
- mf-height, S5K6A3_SENSOR_MIN_HEIGHT,
- S5K6A3_SENSOR_MAX_HEIGHT, 0, 0);
+   v4l_bound_align_image(mf-width,
+   S5K6A3_SENSOR_MIN_WIDTH, S5K6A3_SENSOR_MAX_WIDTH, 0,
+   mf-height,
+   S5K6A3_SENSOR_MIN_HEIGHT, S5K6A3_SENSOR_MAX_HEIGHT, 0,
+   0);
 }
 
 static struct v4l2_mbus_framefmt *__s5k6a3_get_format(
-- 
1.7.9.5

--
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 v6 13/13] V4L: Add driver for s5k4e5 image sensor

2013-08-16 Thread Arun Kumar K
This patch adds subdev driver for Samsung S5K4E5 raw image sensor.
Like s5k6a3, it is also another fimc-is firmware controlled
sensor. This minimal sensor driver doesn't do any I2C communications
as its done by ISP firmware. It can be updated if needed to a
regular sensor driver by adding the I2C communication.

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/media/i2c/s5k4e5.txt   |   43 +++
 drivers/media/i2c/Kconfig  |8 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k4e5.c |  361 
 4 files changed, 413 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
 create mode 100644 drivers/media/i2c/s5k4e5.c

diff --git a/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt 
b/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
new file mode 100644
index 000..5af462c
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
@@ -0,0 +1,43 @@
+* Samsung S5K4E5 Raw Image Sensor
+
+S5K4E5 is a raw image sensor with maximum resolution of 2560x1920
+pixels. Data transfer is carried out via MIPI CSI-2 port and controls
+via I2C bus.
+
+Required Properties:
+- compatible   : must be samsung,s5k4e5
+- reg  : I2C device address
+- gpios: reset gpio pin
+- clocks   : clock specifier for the clock-names property
+- clock-names  : must contain mclk entry
+- svdda-supply : core voltage supply
+- svddio-supply: I/O voltage supply
+
+Optional Properties:
+- clock-frequency : operating frequency for the sensor
+default value will be taken if not provided.
+
+The device node should be added to respective control bus controller
+(e.g. I2C0) nodes and linked to the csis port node, using the common
+video interfaces bindings, defined in video-interfaces.txt.
+
+Example:
+
+   i2c-isp@1313 {
+   s5k4e5@20 {
+   compatible = samsung,s5k4e5;
+   reg = 0x20;
+   gpios = gpx1 2 1;
+   clock-frequency = 2400;
+   clocks = clock 129;
+   clock-names = mclk;
+   svdda-supply = ...;
+   svddio-supply = ...;
+   port {
+   is_s5k4e5_ep: endpoint {
+   data-lanes = 1 2 3 4;
+   remote-endpoint = csis0_ep;
+   };
+   };
+   };
+   };
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index f7e9147..271028b 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -572,6 +572,14 @@ config VIDEO_S5K6A3
  This is a V4L2 sensor-level driver for Samsung S5K6A3 raw
  camera sensor.
 
+config VIDEO_S5K4E5
+   tristate Samsung S5K4E5 sensor support
+   depends on MEDIA_CAMERA_SUPPORT
+   depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  OF
+   ---help---
+ This is a V4L2 sensor-level driver for Samsung S5K4E5 raw
+ camera sensor.
+
 config VIDEO_S5K4ECGX
 tristate Samsung S5K4ECGX sensor support
 depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index cf3cf03..0aeed8e 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
+obj-$(CONFIG_VIDEO_S5K4E5) += s5k4e5.o
 obj-$(CONFIG_VIDEO_S5K4ECGX)   += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_S5C73M3)+= s5c73m3/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
diff --git a/drivers/media/i2c/s5k4e5.c b/drivers/media/i2c/s5k4e5.c
new file mode 100644
index 000..0a6ece6
--- /dev/null
+++ b/drivers/media/i2c/s5k4e5.c
@@ -0,0 +1,361 @@
+/*
+ * Samsung S5K4E5 image sensor driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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 linux/clk.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/gpio.h
+#include linux/i2c.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of_gpio.h
+#include linux/pm_runtime.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+#include linux/videodev2.h
+#include media/v4l2-async.h
+#include media/v4l2-subdev.h
+
+#define S5K4E5_SENSOR_MAX_WIDTH2576
+#define S5K4E5_SENSOR_MAX_HEIGHT   1930

Re: [PATCH v4 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-13 Thread Arun Kumar K
Hi Sylwester,

On Fri, Aug 9, 2013 at 3:38 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 08/07/2013 11:03 AM, Arun Kumar K wrote:

 From: Shaik Ameer Bashashaik.am...@samsung.com

 This patch adds support for media device for EXYNOS5 SoCs.
 The current media device supports the following ips to connect
 through the media controller framework.

 * MIPI-CSIS
Support interconnection(subdev interface) between devices

 * FIMC-LITE
Support capture interface from device(Sensor, MIPI-CSIS) to memory
Support interconnection(subdev interface) between devices

 * FIMC-IS
Camera post-processing IP having multiple sub-nodes.

 G-Scaler will be added later to the current media device.

 The media device creates two kinds of pipelines for connecting
 the above mentioned IPs.
 The pipeline0 is uses Sensor, MIPI-CSIS and FIMC-LITE which captures
 image data and dumps to memory.
 Pipeline1 uses FIMC-IS components for doing post-processing
 operations on the captured image and give scaled YUV output.

 Pipeline0
++ +---+ +---+ ++
| Sensor | --  | MIPI-CSIS | --  | FIMC-LITE | --  | Memory |
++ +---+ +---+ ++

 Pipeline1
   ++  ++ +---+ +---+
   | Memory | --   |  ISP   | --  |SCC| --  |SCP|
   ++  ++ +---+ +---+

 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 Signed-off-by: Arun Kumar Karun...@samsung.com
 ---
   .../devicetree/bindings/media/exynos5-mdev.txt |  148 +++
   drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1189
 
   drivers/media/platform/exynos5-is/exynos5-mdev.h   |  164 +++
   3 files changed, 1501 insertions(+)
   create mode 100644
 Documentation/devicetree/bindings/media/exynos5-mdev.txt
   create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
   create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h

 diff --git a/Documentation/devicetree/bindings/media/exynos5-mdev.txt
 b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
 new file mode 100644
 index 000..8b2ffb9
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
 @@ -0,0 +1,148 @@
 +Samsung EXYNOS5 SoC Camera Subsystem
 +
 +
 +The Exynos5 SoC Camera subsystem comprises of multiple sub-devices
 +represented by separate device tree nodes. Currently this includes:
 FIMC-LITE,
 +MIPI CSIS and FIMC-IS.
 +
 +The sub-subdevices are defined as child nodes of the common 'camera' node
 which
 +also includes common properties of the whole subsystem not really
 specific to
 +any single sub-device, like common camera port pins or the CAMCLK clock
 outputs
 +for external image sensors attached to an SoC.
 +
 +Common 'camera' node
 +
 +
 +Required properties:
 +
 +- compatible   : must be samsung,exynos5-fimc, simple-bus
 +- clocks   : list of clock specifiers, corresponding to entries in
 + the clock-names property;
 +- clock-names  : must contain sclk_bayer entry and matching clock
 property
 +  entry


 I guess and matching clock property entry could be removed.


Ok


 +The pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt must be
 used
 +to define a required pinctrl state named default and optional pinctrl
 states:


 How about only supporting default pinctrl state in this initial DT
 binding/driver
 version ? The optional states could be added later, my concern is that
 except the
 camera port A, B there is also the RGB camera bay. Thus using idle,
 active-a,
 active-b won't work any more. We need to find some better solution for
 that.


Ok will put only default state.

 Besides now when you removed the clock provider, there is not much you could
 do
 with those optional pinctrl states. Those were originally meant to be used
 in
 the clk_prepare/clk_unprepare ops. So, e.g. when sensor disables the clock
 the
 host driver sets a clock output pin into idle state, e.g. input with pull
 down.

 But maybe Exynos5 SoCs got improved comparing to e.g. Exynos4 so the clock
 output
 pin is put into high impedance state when the sclk_cam clock is disabled ?
 However that seems unlikely.


 +idle, active-a, active-b. These optional states can be used to
 switch the
 +camera port pinmux at runtime. The idle state should configure both the
 camera
 +ports A and B into high impedance state, especially the CAMCLK clock
 output
 +should be inactive. For the active-a state the camera port A must be
 activated
 +and the port B deactivated and for the state active-b it should be the
 other
 +way around.
 +
 +The 'camera' node must include at least one 'fimc-lite' child node.


 This shouldn't be necessary, i.e. making the individual device nodes child
 nodes
 of the camera node. Think of GScaler which can be used either by the camera

[PATCH v5 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-13 Thread Arun Kumar K
From: Shaik Ameer Basha shaik.am...@samsung.com

This patch adds support for media device for EXYNOS5 SoCs.
The current media device supports the following ips to connect
through the media controller framework.

* MIPI-CSIS
  Support interconnection(subdev interface) between devices

* FIMC-LITE
  Support capture interface from device(Sensor, MIPI-CSIS) to memory
  Support interconnection(subdev interface) between devices

* FIMC-IS
  Camera post-processing IP having multiple sub-nodes.

G-Scaler will be added later to the current media device.

The media device creates two kinds of pipelines for connecting
the above mentioned IPs.
The pipeline0 is uses Sensor, MIPI-CSIS and FIMC-LITE which captures
image data and dumps to memory.
Pipeline1 uses FIMC-IS components for doing post-processing
operations on the captured image and give scaled YUV output.

Pipeline0
  ++ +---+ +---+ ++
  | Sensor | -- | MIPI-CSIS | -- | FIMC-LITE | -- | Memory |
  ++ +---+ +---+ ++

Pipeline1
 ++  ++ +---+ +---+
 | Memory | --  |  ISP   | -- |SCC| -- |SCP|
 ++  ++ +---+ +---+

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 .../devicetree/bindings/media/exynos5-mdev.txt |  130 +++
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1218 
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  160 +++
 3 files changed, 1508 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h

diff --git a/Documentation/devicetree/bindings/media/exynos5-mdev.txt 
b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
new file mode 100644
index 000..007ce21
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
@@ -0,0 +1,130 @@
+Samsung EXYNOS5 SoC Camera Subsystem
+
+
+The Exynos5 SoC Camera subsystem comprises of multiple sub-devices
+represented by separate device tree nodes. Currently this includes: FIMC-LITE,
+MIPI CSIS and FIMC-IS.
+
+The sub-subdevices are defined as child nodes of the common 'camera' node which
+also includes common properties of the whole subsystem not really specific to
+any single sub-device, like common camera port pins or the CAMCLK clock outputs
+for external image sensors attached to an SoC.
+
+Common 'camera' node
+
+
+Required properties:
+
+- compatible   : must be samsung,exynos5-fimc, simple-bus
+- clocks   : list of clock specifiers, corresponding to entries in
+ the clock-names property;
+- clock-names  : must contain sclk_bayer entry
+- csis : list of phandles to the mipi-csis device nodes
+- fimc-lite: list of phandles to the fimc-lite device nodes
+- fimc-is  : phandle to the fimc-is device node
+
+The pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt must be used
+to define a required pinctrl state named default.
+
+'parallel-ports' node
+-
+
+This node should contain child 'port' nodes specifying active parallel video
+input ports. It includes camera A, camera B, MIPI-CSI2 and RGB bay inputs.
+'reg' property in the port nodes specifies the input type:
+ 1 - parallel camport A
+ 2 - parallel camport B
+ 3 - serial MIPI CSI-2 port 0
+ 4 - serial MIPI CSI-2 port 1
+ 5 - RGB camera bay
+
+3, 4 are already described in samsung-mipi-csis.txt
+
+Image sensor nodes
+--
+
+The sensor device nodes should be added to their control bus controller (e.g.
+I2C0) nodes and linked to a port node in the csis or the parallel-ports node,
+using the common video interfaces bindings, defined in video-interfaces.txt.
+The implementation of this bindings requires clock-frequency property to be
+present in the sensor device nodes.
+
+Example:
+
+   aliases {
+   fimc-lite0 = fimc_lite_0
+   };
+
+   /* Parallel bus IF sensor */
+   i2c_0: i2c@1386 {
+   s5k6aa: sensor@3c {
+   compatible = samsung,s5k6aafx;
+   reg = 0x3c;
+   vddio-supply = ...;
+
+   clock-frequency = 2400;
+   clocks = ...;
+   clock-names = mclk;
+
+   port {
+   s5k6aa_ep: endpoint {
+   remote-endpoint = fimc0_ep;
+   bus-width = 8;
+   hsync-active = 0;
+   vsync-active = 1;
+   pclk-sample = 1

[PATCH v5 07/13] [media] exynos5-fimc-is: Add scaler subdev

2013-08-13 Thread Arun Kumar K
FIMC-IS has two hardware scalers named as scaler-codec and
scaler-preview. This patch adds the common code handling the
video nodes and subdevs of both the scalers.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-scaler.c |  472 
 drivers/media/platform/exynos5-is/fimc-is-scaler.h |  106 +
 2 files changed, 578 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-scaler.c 
b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
new file mode 100644
index 000..82ba867
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
@@ -0,0 +1,472 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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 media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+
+#define IS_SCALER_DRV_NAME fimc-is-scaler
+
+static const struct fimc_is_fmt formats[] = {
+   {
+   .name   = YUV 4:2:0 3p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_YUV420M,
+   .depth  = {8, 2, 2},
+   .num_planes = 3,
+   },
+   {
+   .name   = YUV 4:2:0 2p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_NV12M,
+   .depth  = {8, 4},
+   .num_planes = 2,
+   },
+   {
+   .name   = YUV 4:2:2 1p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_NV16,
+   .depth  = {16},
+   .num_planes = 1,
+   },
+};
+#define NUM_FORMATS ARRAY_SIZE(formats)
+
+static const struct fimc_is_fmt *find_format(struct v4l2_format *f)
+{
+   unsigned int i;
+
+   for (i = 0; i  NUM_FORMATS; i++) {
+   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
+   return formats[i];
+   }
+   return NULL;
+}
+
+static int scaler_video_capture_start_streaming(struct vb2_queue *vq,
+   unsigned int count)
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   int ret;
+
+   ret = fimc_is_pipeline_scaler_start(ctx-pipeline,
+   ctx-scaler_id,
+   vq-num_buffers,
+   ctx-fmt-num_planes);
+   if (ret) {
+   v4l2_err(ctx-subdev, Scaler start failed.\n);
+   return -EINVAL;
+   }
+
+   set_bit(STATE_RUNNING, ctx-capture_state);
+   return 0;
+}
+
+static int scaler_video_capture_stop_streaming(struct vb2_queue *vq)
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+   int ret;
+
+   ret = fimc_is_pipeline_scaler_stop(ctx-pipeline, ctx-scaler_id);
+   if (ret)
+   v4l2_info(ctx-subdev, Scaler already stopped.\n);
+
+   /* Release un-used buffers */
+   while (!list_empty(ctx-wait_queue)) {
+   buf = fimc_is_scaler_wait_queue_get(ctx);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+   while (!list_empty(ctx-run_queue)) {
+   buf = fimc_is_scaler_run_queue_get(ctx);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+
+   clear_bit(STATE_RUNNING, ctx-capture_state);
+   return 0;
+}
+
+static int scaler_video_capture_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   const struct fimc_is_fmt *fmt = ctx-fmt;
+   unsigned int wh;
+   int i;
+
+   if (!fmt)
+   return -EINVAL;
+
+   *num_planes = fmt-num_planes;
+   wh = ctx-width * ctx-height;
+
+   for (i = 0; i  *num_planes; i++) {
+   allocators[i] = ctx-alloc_ctx;
+   sizes[i] = (wh * fmt-depth[i]) / 8;
+   }
+   return 0;
+}
+
+static int scaler_video_capture_buffer_init(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb);
+   const struct fimc_is_fmt *fmt;
+   int i;
+
+   fmt = ctx-fmt;
+   for (i = 0; i  fmt-num_planes; i++)
+   buf-paddr[i] = vb2_dma_contig_plane_dma_addr(vb, i

[PATCH v5 09/13] [media] exynos5-fimc-is: Add the hardware pipeline control

2013-08-13 Thread Arun Kumar K
This patch adds the crucial hardware pipeline control for the
fimc-is driver. All the subdev nodes will call this pipeline
interfaces to reach the hardware. Responsibilities of this module
involves configuring and maintaining the hardware pipeline involving
multiple sub-ips like ISP, DRC, Scalers, ODC, 3DNR, FD etc.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../media/platform/exynos5-is/fimc-is-pipeline.c   | 1692 
 .../media/platform/exynos5-is/fimc-is-pipeline.h   |  128 ++
 2 files changed, 1820 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-pipeline.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-pipeline.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-pipeline.c 
b/drivers/media/platform/exynos5-is/fimc-is-pipeline.c
new file mode 100644
index 000..7d91469
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-pipeline.c
@@ -0,0 +1,1692 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Arun Kumar K arun...@samsung.com
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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 fimc-is.h
+#include fimc-is-pipeline.h
+#include fimc-is-metadata.h
+#include fimc-is-regs.h
+#include fimc-is-cmd.h
+#include media/videobuf2-dma-contig.h
+#include linux/delay.h
+
+/* Default setting values */
+#define DEFAULT_PREVIEW_STILL_WIDTH1280
+#define DEFAULT_PREVIEW_STILL_HEIGHT   720
+#define DEFAULT_CAPTURE_VIDEO_WIDTH1920
+#define DEFAULT_CAPTURE_VIDEO_HEIGHT   1080
+#define DEFAULT_CAPTURE_STILL_WIDTH2560
+#define DEFAULT_CAPTURE_STILL_HEIGHT   1920
+#define DEFAULT_CAPTURE_STILL_CROP_WIDTH   2560
+#define DEFAULT_CAPTURE_STILL_CROP_HEIGHT  1440
+#define DEFAULT_PREVIEW_VIDEO_WIDTH640
+#define DEFAULT_PREVIEW_VIDEO_HEIGHT   480
+
+/* Init params for pipeline devices */
+static const struct sensor_param init_sensor_param = {
+   .frame_rate = {
+   .frame_rate = 30,
+   },
+};
+
+static const struct isp_param init_isp_param = {
+   .control = {
+   .cmd = CONTROL_COMMAND_START,
+   .bypass = CONTROL_BYPASS_DISABLE,
+   },
+   .otf_input = {
+   .cmd = OTF_INPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = OTF_INPUT_FORMAT_BAYER,
+   .bitwidth = OTF_INPUT_BIT_WIDTH_10BIT,
+   .order = OTF_INPUT_ORDER_BAYER_GR_BG,
+   .frametime_max = 3,
+   },
+   .dma1_input = {
+   .cmd = DMA_INPUT_COMMAND_DISABLE,
+   },
+   .dma2_input = {
+   .cmd = DMA_INPUT_COMMAND_DISABLE,
+   },
+   .aa = {
+   .cmd = ISP_AA_COMMAND_START,
+   .target = ISP_AA_TARGET_AF | ISP_AA_TARGET_AE |
+   ISP_AA_TARGET_AWB,
+   .mode = ISP_AF_CONTINUOUS,
+   },
+   .flash = {
+   .cmd = ISP_FLASH_COMMAND_DISABLE,
+   .redeye = ISP_FLASH_REDEYE_DISABLE,
+   },
+   .awb = {
+   .cmd = ISP_AWB_COMMAND_AUTO,
+   },
+   .effect = {
+   .cmd = ISP_IMAGE_EFFECT_DISABLE,
+   },
+   .iso = {
+   .cmd = ISP_ISO_COMMAND_AUTO,
+   },
+   .adjust = {
+   .cmd = ISP_ADJUST_COMMAND_AUTO,
+   },
+   .metering = {
+   .cmd = ISP_METERING_COMMAND_CENTER,
+   .win_width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .win_height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   },
+   .afc = {
+   .cmd = ISP_AFC_COMMAND_AUTO,
+   },
+   .otf_output = {
+   .cmd = OTF_OUTPUT_COMMAND_ENABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = OTF_OUTPUT_FORMAT_YUV444,
+   .bitwidth = OTF_OUTPUT_BIT_WIDTH_12BIT,
+   .order = OTF_OUTPUT_ORDER_BAYER_GR_BG,
+   },
+   .dma1_output = {
+   .cmd = DMA_OUTPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = DMA_INPUT_FORMAT_YUV444,
+   .bitwidth = DMA_INPUT_BIT_WIDTH_8BIT,
+   .plane = 1,
+   .order = DMA_INPUT_ORDER_YCBCR,
+   },
+   .dma2_output = {
+   .cmd = DMA_OUTPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT

[PATCH v5 06/13] [media] exynos5-fimc-is: Add isp subdev

2013-08-13 Thread Arun Kumar K
fimc-is driver takes video data input from the ISP video node
which is added in this patch. This node accepts Bayer input
buffers which is given from the IS sensors.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-isp.c |  534 +++
 drivers/media/platform/exynos5-is/fimc-is-isp.h |   90 
 2 files changed, 624 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-isp.c 
b/drivers/media/platform/exynos5-is/fimc-is-isp.c
new file mode 100644
index 000..882c291
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-isp.c
@@ -0,0 +1,534 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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 media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+
+#define ISP_DRV_NAME fimc-is-isp
+
+static const struct fimc_is_fmt formats[] = {
+   {
+   .name   = Bayer GR-BG 8bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG8,
+   .depth  = { 8 },
+   .num_planes = 1,
+   },
+   {
+   .name   = Bayer GR-BG 10bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG10,
+   .depth  = { 16 },
+   .num_planes = 1,
+   },
+   {
+   .name   = Bayer GR-BG 12bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG12,
+   .depth  = { 16 },
+   .num_planes = 1,
+   },
+};
+#define NUM_FORMATS ARRAY_SIZE(formats)
+
+static const struct fimc_is_fmt *find_format(struct v4l2_format *f)
+{
+   unsigned int i;
+
+   for (i = 0; i  NUM_FORMATS; i++)
+   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
+   return formats[i];
+   return NULL;
+}
+
+static int isp_video_output_start_streaming(struct vb2_queue *vq,
+   unsigned int count)
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+
+   set_bit(STATE_RUNNING, isp-output_state);
+   return 0;
+}
+
+static int isp_video_output_stop_streaming(struct vb2_queue *vq)
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+
+   /* Release unused buffers */
+   while (!list_empty(isp-wait_queue)) {
+   buf = fimc_is_isp_wait_queue_get(isp);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+   while (!list_empty(isp-run_queue)) {
+   buf = fimc_is_isp_run_queue_get(isp);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+
+   clear_bit(STATE_RUNNING, isp-output_state);
+   return 0;
+}
+
+static int isp_video_output_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   const struct fimc_is_fmt *fmt = isp-fmt;
+   unsigned int wh, i;
+
+   if (!fmt)
+   return -EINVAL;
+
+   *num_planes = fmt-num_planes;
+   wh = isp-width * isp-height;
+
+   for (i = 0; i  *num_planes; i++) {
+   allocators[i] = isp-alloc_ctx;
+   sizes[i] = (wh * fmt-depth[i]) / 8;
+   }
+   return 0;
+}
+
+static int isp_video_output_buffer_init(struct vb2_buffer *vb)
+{
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb);
+
+   buf-paddr[0] = vb2_dma_contig_plane_dma_addr(vb, 0);
+   return 0;
+}
+
+static int isp_video_output_buffer_prepare(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   unsigned long size;
+
+   size = (isp-width * isp-height * isp-fmt-depth[0]) / 8;
+   if (vb2_plane_size(vb, 0)  size) {
+   v4l2_err(isp-subdev, User buffer too small (%ld  %ld)\n,
+vb2_plane_size(vb, 0), size);
+   return -EINVAL;
+   }
+   vb2_set_plane_payload(vb, 0, size);
+
+   return 0;
+}
+
+static void isp_video_output_buffer_queue(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb

[PATCH v5 05/13] [media] exynos5-fimc-is: Add register definition and context header

2013-08-13 Thread Arun Kumar K
This patch adds the register definition file for the fimc-is driver
and also the header file containing the main context for the driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-regs.h |  105 ++
 drivers/media/platform/exynos5-is/fimc-is.h  |  160 ++
 2 files changed, 265 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-regs.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-regs.h 
b/drivers/media/platform/exynos5-is/fimc-is-regs.h
new file mode 100644
index 000..06aa466
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-regs.h
@@ -0,0 +1,105 @@
+/*
+ * Samsung Exynos5 SoC series FIMC-IS driver
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd
+ * Arun Kumar K arun...@samsung.com
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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.
+ */
+
+#ifndef FIMC_IS_REGS_H
+#define FIMC_IS_REGS_H
+
+/* WDT_ISP register */
+#define WDT0x0017
+/* MCUCTL register */
+#define MCUCTL 0x0018
+/* MCU Controller Register */
+#define MCUCTLR(MCUCTL+0x00)
+#define MCUCTLR_AXI_ISPX_AWCACHE(x)((x)  16)
+#define MCUCTLR_AXI_ISPX_ARCACHE(x)((x)  12)
+#define MCUCTLR_MSWRST (1  0)
+/* Boot Base OFfset Address Register */
+#define BBOAR  (MCUCTL+0x04)
+#define BBOAR_BBOA(x)  ((x)  0)
+
+/* Interrupt Generation Register 0 from Host CPU to VIC */
+#define INTGR0 (MCUCTL+0x08)
+#define INTGR0_INTGC(n)(1  ((n) + 16))
+#define INTGR0_INTGD(n)(1  (n))
+
+/* Interrupt Clear Register 0 from Host CPU to VIC */
+#define INTCR0 (MCUCTL+0x0c)
+#define INTCR0_INTCC(n)(1  ((n) + 16))
+#define INTCR0_INTCD(n)(1  (n))
+
+/* Interrupt Mask Register 0 from Host CPU to VIC */
+#define INTMR0 (MCUCTL+0x10)
+#define INTMR0_INTMC(n)(1  ((n) + 16))
+#define INTMR0_INTMD(n)(1  (n))
+
+/* Interrupt Status Register 0 from Host CPU to VIC */
+#define INTSR0 (MCUCTL+0x14)
+#define INTSR0_GET_INTSD(n, x) (((x)  (n))  0x1)
+#define INTSR0_GET_INTSC(n, x) (((x)  ((n) + 16))  0x1)
+
+/* Interrupt Mask Status Register 0 from Host CPU to VIC */
+#define INTMSR0(MCUCTL+0x18)
+#define INTMSR0_GET_INTMSD(n, x)   (((x)  (n))  0x1)
+#define INTMSR0_GET_INTMSC(n, x)   (((x)  ((n) + 16))  0x1)
+
+/* Interrupt Generation Register 1 from ISP CPU to Host IC */
+#define INTGR1 (MCUCTL+0x1c)
+#define INTGR1_INTGC(n)(1  (n))
+
+/* Interrupt Clear Register 1 from ISP CPU to Host IC */
+#define INTCR1 (MCUCTL+0x20)
+#define INTCR1_INTCC(n)(1  (n))
+
+/* Interrupt Mask Register 1 from ISP CPU to Host IC */
+#define INTMR1 (MCUCTL+0x24)
+#define INTMR1_INTMC(n)(1  (n))
+
+/* Interrupt Status Register 1 from ISP CPU to Host IC */
+#define INTSR1 (MCUCTL+0x28)
+/* Interrupt Mask Status Register 1 from ISP CPU to Host IC */
+#define INTMSR1(MCUCTL+0x2c)
+/* Interrupt Clear Register 2 from ISP BLK's interrupts to Host IC */
+#define INTCR2 (MCUCTL+0x30)
+#define INTCR2_INTCC(n)(1  (n))
+
+/* Interrupt Mask Register 2 from ISP BLK's interrupts to Host IC */
+#define INTMR2 (MCUCTL+0x34)
+#define INTMR2_INTMCIS(n)  (1  (n))
+
+/* Interrupt Status Register 2 from ISP BLK's interrupts to Host IC */
+#define INTSR2 (MCUCTL+0x38)
+/* Interrupt Mask Status Register 2 from ISP BLK's interrupts to Host IC */
+#define INTMSR2(MCUCTL+0x3c)
+/* General Purpose Output Control Register (0~17) */
+#define GPOCTLR(MCUCTL+0x40)
+#define GPOCTLR_GPOG(n, x) ((x)  (n))
+
+/* General Purpose Pad Output Enable Register (0~17) */
+#define GPOENCTLR  (MCUCTL+0x44)
+#define GPOENCTLR_GPOEN0(n, x) ((x)  (n))
+
+/* General Purpose Input Control Register (0~17) */
+#define GPICTLR(MCUCTL+0x48)
+
+/* IS Shared Registers between ISP CPU and HOST CPU */
+#define ISSR(n)(MCUCTL + 0x80 + (n))
+
+/* PMU for FIMC-IS*/
+#define

[PATCH v5 02/13] [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings documentation

2013-08-13 Thread Arun Kumar K
The patch adds the DT binding documentation for Samsung
Exynos5 SoC series imaging subsystem (FIMC-IS).

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/media/exynos5-fimc-is.txt  |   47 
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt 
b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
new file mode 100644
index 000..bfd36df
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
@@ -0,0 +1,47 @@
+Samsung EXYNOS5 SoC series Imaging Subsystem (FIMC-IS)
+--
+
+The camera subsystem on Samsung Exynos5 SoC has some changes relative
+to previous SoC versions. Exynos5 has almost similar MIPI-CSIS and
+FIMC-LITE IPs but has a much improved version of FIMC-IS which can
+handle sensor controls and camera post-processing operations. The
+Exynos5 FIMC-IS has a dedicated ARM Cortex A5 processor, many
+post-processing blocks (ISP, DRC, FD, ODC, DIS, 3DNR) and two
+dedicated scalers (SCC and SCP).
+
+fimc-is node
+
+
+Required properties:
+
+- compatible: must be samsung,exynos5250-fimc-is
+- reg   : physical base address and size of the memory mapped
+  registers
+- interrupt-parent  : parent interrupt controller
+- interrupts: fimc-is interrupt to the parent combiner
+- clocks: list of clock specifiers, corresponding to entries in
+  clock-names property;
+- clock-names   : must contain isp, mcu_isp, isp_div0, isp_div1,
+  isp_divmpwm, mcu_isp_div0, mcu_isp_div1 entries,
+  matching entries in the clocks property.
+- pmu   : phandle to the fimc-is pmu node describing the register
+  base and size for FIMC-IS PMU.
+
+i2c-isp (ISP I2C bus controller) nodes
+--
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-i2c-isp for Exynos4212,
+ Exynos4412 and Exynos5250 SoCs;
+- reg  : physical base address and length of the registers set;
+- clocks   : must contain gate clock specifier for this controller;
+- clock-names  : must contain i2c_isp entry.
+
+For the i2c-isp node, it is required to specify a pinctrl state named 
default,
+according to the pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt.
+
+Device tree nodes of the image sensors' controlled directly by the FIMC-IS
+firmware must be child nodes of their corresponding ISP I2C bus controller 
node.
+The data link of these image sensors must be specified using the common video
+interfaces bindings, defined in video-interfaces.txt.
-- 
1.7.9.5

--
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 v5 00/13] Exynos5 IS driver

2013-08-13 Thread Arun Kumar K
The patch series add support for Exynos5 camera subsystem. It
re-uses mipi-csis and fimc-lite from exynos4-is and adds a new
media device and fimc-is device drivers for exynos5.
The media device supports asynchronos subdev registration for the
fimc-is sensors and is tested on top of the patch series from Sylwester
for exynos4-is [1].

[1] http://www.mail-archive.com/linux-media@vger.kernel.org/msg64653.html

Changes from v4
---
- Addressed all review comments from Sylwester
- Added separate PMU node as suggested by Stephen Warren
- Added phandle based discovery of subdevs instead of node name

Changes from v3
---
- Dropped the RFC tag
- Addressed all review comments from Sylwester and Sachin
- Removed clock provider for media dev
- Added s5k4e5 sensor devicetree binding doc

Changes from v2
---
- Added exynos5 media device driver from Shaik to this series
- Added ISP pipeline support in media device driver
- Based on Sylwester's latest exynos4-is development
- Asynchronos registration of sensor subdevs
- Made independent IS-sensor support
- Add s5k4e5 sensor driver
- Addressed review comments from Sylwester, Hans, Andrzej, Sachin

Changes from v1
---
- Addressed all review comments from Sylwester
- Made sensor subdevs as independent i2c devices
- Lots of cleanup
- Debugfs support added
- Removed PMU global register access

Arun Kumar K (12):
  [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings
documentation
  [media] exynos5-fimc-is: Add driver core files
  [media] exynos5-fimc-is: Add common driver header files
  [media] exynos5-fimc-is: Add register definition and context header
  [media] exynos5-fimc-is: Add isp subdev
  [media] exynos5-fimc-is: Add scaler subdev
  [media] exynos5-fimc-is: Add sensor interface
  [media] exynos5-fimc-is: Add the hardware pipeline control
  [media] exynos5-fimc-is: Add the hardware interface module
  [media] exynos5-is: Add Kconfig and Makefile
  V4L: s5k6a3: Change sensor min/max resolutions
  V4L: Add driver for s5k4e5 image sensor

Shaik Ameer Basha (1):
  [media] exynos5-is: Adding media device driver for exynos5

 .../devicetree/bindings/media/exynos5-fimc-is.txt  |   47 +
 .../devicetree/bindings/media/exynos5-mdev.txt |  130 ++
 .../devicetree/bindings/media/i2c/s5k4e5.txt   |   43 +
 drivers/media/i2c/Kconfig  |8 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k4e5.c |  361 +
 drivers/media/i2c/s5k6a3.c |   19 +-
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |   20 +
 drivers/media/platform/exynos5-is/Makefile |7 +
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1218 ++
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  160 ++
 drivers/media/platform/exynos5-is/fimc-is-cmd.h|  187 +++
 drivers/media/platform/exynos5-is/fimc-is-core.c   |  413 +
 drivers/media/platform/exynos5-is/fimc-is-core.h   |  132 ++
 drivers/media/platform/exynos5-is/fimc-is-err.h|  257 +++
 .../media/platform/exynos5-is/fimc-is-interface.c  |  810 ++
 .../media/platform/exynos5-is/fimc-is-interface.h  |  125 ++
 drivers/media/platform/exynos5-is/fimc-is-isp.c|  534 ++
 drivers/media/platform/exynos5-is/fimc-is-isp.h|   90 ++
 .../media/platform/exynos5-is/fimc-is-metadata.h   |  767 +
 drivers/media/platform/exynos5-is/fimc-is-param.h  | 1159 ++
 .../media/platform/exynos5-is/fimc-is-pipeline.c   | 1692 
 .../media/platform/exynos5-is/fimc-is-pipeline.h   |  128 ++
 drivers/media/platform/exynos5-is/fimc-is-regs.h   |  105 ++
 drivers/media/platform/exynos5-is/fimc-is-scaler.c |  472 ++
 drivers/media/platform/exynos5-is/fimc-is-scaler.h |  106 ++
 drivers/media/platform/exynos5-is/fimc-is-sensor.c |   45 +
 drivers/media/platform/exynos5-is/fimc-is-sensor.h |   65 +
 drivers/media/platform/exynos5-is/fimc-is.h|  160 ++
 31 files changed, 9255 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 create mode 100644 Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
 create mode 100644 drivers/media/i2c/s5k4e5.c
 create mode 100644 drivers/media/platform/exynos5-is/Kconfig
 create mode 100644 drivers/media/platform/exynos5-is/Makefile
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-cmd.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h
 create mode 100644 drivers/media/platform/exynos5

[PATCH v5 08/13] [media] exynos5-fimc-is: Add sensor interface

2013-08-13 Thread Arun Kumar K
Some sensors to be used with fimc-is are exclusively controlled
by the fimc-is firmware. This minimal sensor driver provides
the required info for the firmware to configure the sensors
sitting on I2C bus.

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-sensor.c |   45 ++
 drivers/media/platform/exynos5-is/fimc-is-sensor.h |   65 
 2 files changed, 110 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.c 
b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
new file mode 100644
index 000..475f1c3
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
@@ -0,0 +1,45 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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 fimc-is-sensor.h
+
+static const struct sensor_drv_data s5k6a3_drvdata = {
+   .id = FIMC_IS_SENSOR_ID_S5K6A3,
+   .open_timeout   = S5K6A3_OPEN_TIMEOUT,
+   .setfile_name   = exynos5_s5k6a3_setfile.bin,
+};
+
+static const struct sensor_drv_data s5k4e5_drvdata = {
+   .id = FIMC_IS_SENSOR_ID_S5K4E5,
+   .open_timeout   = S5K4E5_OPEN_TIMEOUT,
+   .setfile_name   = exynos5_s5k4e5_setfile.bin,
+};
+
+static const struct of_device_id fimc_is_sensor_of_ids[] = {
+   {
+   .compatible = samsung,s5k6a3,
+   .data   = s5k6a3_drvdata,
+   },
+   {
+   .compatible = samsung,s5k4e5,
+   .data   = s5k4e5_drvdata,
+   },
+   {  }
+};
+
+const struct sensor_drv_data *exynos5_is_sensor_get_drvdata(
+   struct device_node *node)
+{
+   const struct of_device_id *of_id;
+
+   of_id = of_match_node(fimc_is_sensor_of_ids, node);
+   return of_id ? of_id-data : NULL;
+}
diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.h 
b/drivers/media/platform/exynos5-is/fimc-is-sensor.h
new file mode 100644
index 000..0ba5733
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.h
@@ -0,0 +1,65 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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.
+ */
+#ifndef FIMC_IS_SENSOR_H_
+#define FIMC_IS_SENSOR_H_
+
+#include linux/of.h
+#include linux/types.h
+
+#define S5K6A3_OPEN_TIMEOUT2000 /* ms */
+#define S5K6A3_SENSOR_WIDTH1392
+#define S5K6A3_SENSOR_HEIGHT   1392
+
+#define S5K4E5_OPEN_TIMEOUT2000 /* ms */
+#define S5K4E5_SENSOR_WIDTH2560
+#define S5K4E5_SENSOR_HEIGHT   1920
+
+#define SENSOR_WIDTH_PADDING   16
+#define SENSOR_HEIGHT_PADDING  10
+
+enum fimc_is_sensor_id {
+   FIMC_IS_SENSOR_ID_S5K3H2 = 1,
+   FIMC_IS_SENSOR_ID_S5K6A3,
+   FIMC_IS_SENSOR_ID_S5K4E5,
+   FIMC_IS_SENSOR_ID_S5K3H7,
+   FIMC_IS_SENSOR_ID_CUSTOM,
+   FIMC_IS_SENSOR_ID_END
+};
+
+struct sensor_drv_data {
+   enum fimc_is_sensor_id id;
+   /* sensor open timeout in ms */
+   unsigned short open_timeout;
+   char *setfile_name;
+};
+
+/**
+ * struct fimc_is_sensor - fimc-is sensor data structure
+ * @drvdata: a pointer to the sensor's parameters data structure
+ * @i2c_bus: ISP I2C bus index (0...1)
+ * @width: sensor active width
+ * @height: sensor active height
+ * @pixel_width: sensor effective pixel width (width + padding)
+ * @pixel_height: sensor effective pixel height (height + padding)
+ */
+struct fimc_is_sensor {
+   const struct sensor_drv_data *drvdata;
+   unsigned int i2c_bus;
+   unsigned int width;
+   unsigned int height;
+   unsigned int pixel_width;
+   unsigned int pixel_height;
+};
+
+const struct sensor_drv_data *exynos5_is_sensor_get_drvdata(
+   struct device_node *node);
+
+#endif /* FIMC_IS_SENSOR_H_ */
-- 
1.7.9.5

--
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 v5 03/13] [media] exynos5-fimc-is: Add driver core files

2013-08-13 Thread Arun Kumar K
This driver is for the FIMC-IS IP available in Samsung Exynos5
SoC onwards. This patch adds the core files for the new driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-core.c |  413 ++
 drivers/media/platform/exynos5-is/fimc-is-core.h |  132 +++
 2 files changed, 545 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-core.c 
b/drivers/media/platform/exynos5-is/fimc-is-core.c
new file mode 100644
index 000..3e7a1ae
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-core.c
@@ -0,0 +1,413 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Arun Kumar K arun...@samsung.com
+ *
+ * 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 linux/bug.h
+#include linux/ctype.h
+#include linux/device.h
+#include linux/debugfs.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/err.h
+#include linux/firmware.h
+#include linux/fs.h
+#include linux/gpio.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_gpio.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/of_irq.h
+#include linux/pinctrl/consumer.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/types.h
+#include linux/videodev2.h
+
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-mem2mem.h
+#include media/v4l2-of.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+#include fimc-is-i2c.h
+
+#define CLK_MCU_ISP_DIV0_FREQ  (200 * 100)
+#define CLK_MCU_ISP_DIV1_FREQ  (100 * 100)
+#define CLK_ISP_DIV0_FREQ  (134 * 100)
+#define CLK_ISP_DIV1_FREQ  (68 * 100)
+#define CLK_ISP_DIVMPWM_FREQ   (34 * 100)
+
+static const char * const fimc_is_clock_name[] = {
+   [IS_CLK_ISP]= isp,
+   [IS_CLK_MCU_ISP]= mcu_isp,
+   [IS_CLK_ISP_DIV0]   = isp_div0,
+   [IS_CLK_ISP_DIV1]   = isp_div1,
+   [IS_CLK_ISP_DIVMPWM]= isp_divmpwm,
+   [IS_CLK_MCU_ISP_DIV0]   = mcu_isp_div0,
+   [IS_CLK_MCU_ISP_DIV1]   = mcu_isp_div1,
+};
+
+static void fimc_is_put_clocks(struct fimc_is *is)
+{
+   int i;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
+   if (IS_ERR(is-clock[i]))
+   continue;
+   clk_unprepare(is-clock[i]);
+   clk_put(is-clock[i]);
+   is-clock[i] = ERR_PTR(-EINVAL);
+   }
+}
+
+static int fimc_is_get_clocks(struct fimc_is *is)
+{
+   struct device *dev = is-pdev-dev;
+   int i, ret;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
+   is-clock[i] = clk_get(dev, fimc_is_clock_name[i]);
+   if (IS_ERR(is-clock[i]))
+   goto err;
+   ret = clk_prepare(is-clock[i]);
+   if (ret  0) {
+   clk_put(is-clock[i]);
+   is-clock[i] = ERR_PTR(-EINVAL);
+   goto err;
+   }
+   }
+   return 0;
+err:
+   fimc_is_put_clocks(is);
+   pr_err(Failed to get clock: %s\n, fimc_is_clock_name[i]);
+   return -ENXIO;
+}
+
+static int fimc_is_configure_clocks(struct fimc_is *is)
+{
+   int i, ret;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++)
+   is-clock[i] = ERR_PTR(-EINVAL);
+
+   ret = fimc_is_get_clocks(is);
+   if (ret)
+   return ret;
+
+   /* Set rates */
+   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV0],
+   CLK_MCU_ISP_DIV0_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV1],
+   CLK_MCU_ISP_DIV1_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV0], CLK_ISP_DIV0_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV1], CLK_ISP_DIV1_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIVMPWM],
+   CLK_ISP_DIVMPWM_FREQ);
+   return ret;
+}
+
+static void fimc_is_pipelines_destroy(struct fimc_is *is)
+{
+   int i;
+
+   for (i = 0; i  is-drvdata-num_instances; i++)
+   fimc_is_pipeline_destroy(is-pipeline[i]);
+}
+
+static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index

[PATCH v5 13/13] V4L: Add driver for s5k4e5 image sensor

2013-08-13 Thread Arun Kumar K
This patch adds subdev driver for Samsung S5K4E5 raw image sensor.
Like s5k6a3, it is also another fimc-is firmware controlled
sensor. This minimal sensor driver doesn't do any I2C communications
as its done by ISP firmware. It can be updated if needed to a
regular sensor driver by adding the I2C communication.

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/media/i2c/s5k4e5.txt   |   43 +++
 drivers/media/i2c/Kconfig  |8 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k4e5.c |  361 
 4 files changed, 413 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
 create mode 100644 drivers/media/i2c/s5k4e5.c

diff --git a/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt 
b/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
new file mode 100644
index 000..5af462c
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
@@ -0,0 +1,43 @@
+* Samsung S5K4E5 Raw Image Sensor
+
+S5K4E5 is a raw image sensor with maximum resolution of 2560x1920
+pixels. Data transfer is carried out via MIPI CSI-2 port and controls
+via I2C bus.
+
+Required Properties:
+- compatible   : must be samsung,s5k4e5
+- reg  : I2C device address
+- gpios: reset gpio pin
+- clocks   : clock specifier for the clock-names property
+- clock-names  : must contain mclk entry
+- svdda-supply : core voltage supply
+- svddio-supply: I/O voltage supply
+
+Optional Properties:
+- clock-frequency : operating frequency for the sensor
+default value will be taken if not provided.
+
+The device node should be added to respective control bus controller
+(e.g. I2C0) nodes and linked to the csis port node, using the common
+video interfaces bindings, defined in video-interfaces.txt.
+
+Example:
+
+   i2c-isp@1313 {
+   s5k4e5@20 {
+   compatible = samsung,s5k4e5;
+   reg = 0x20;
+   gpios = gpx1 2 1;
+   clock-frequency = 2400;
+   clocks = clock 129;
+   clock-names = mclk;
+   svdda-supply = ...;
+   svddio-supply = ...;
+   port {
+   is_s5k4e5_ep: endpoint {
+   data-lanes = 1 2 3 4;
+   remote-endpoint = csis0_ep;
+   };
+   };
+   };
+   };
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index f7e9147..271028b 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -572,6 +572,14 @@ config VIDEO_S5K6A3
  This is a V4L2 sensor-level driver for Samsung S5K6A3 raw
  camera sensor.
 
+config VIDEO_S5K4E5
+   tristate Samsung S5K4E5 sensor support
+   depends on MEDIA_CAMERA_SUPPORT
+   depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  OF
+   ---help---
+ This is a V4L2 sensor-level driver for Samsung S5K4E5 raw
+ camera sensor.
+
 config VIDEO_S5K4ECGX
 tristate Samsung S5K4ECGX sensor support
 depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index cf3cf03..0aeed8e 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
+obj-$(CONFIG_VIDEO_S5K4E5) += s5k4e5.o
 obj-$(CONFIG_VIDEO_S5K4ECGX)   += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_S5C73M3)+= s5c73m3/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
diff --git a/drivers/media/i2c/s5k4e5.c b/drivers/media/i2c/s5k4e5.c
new file mode 100644
index 000..0a6ece6
--- /dev/null
+++ b/drivers/media/i2c/s5k4e5.c
@@ -0,0 +1,361 @@
+/*
+ * Samsung S5K4E5 image sensor driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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 linux/clk.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/gpio.h
+#include linux/i2c.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of_gpio.h
+#include linux/pm_runtime.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+#include linux/videodev2.h
+#include media/v4l2-async.h
+#include media/v4l2-subdev.h
+
+#define S5K4E5_SENSOR_MAX_WIDTH2576
+#define S5K4E5_SENSOR_MAX_HEIGHT   1930

[PATCH v5 11/13] [media] exynos5-is: Add Kconfig and Makefile

2013-08-13 Thread Arun Kumar K
Adds Kconfig and Makefile for exynos5-is driver files.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |   20 
 drivers/media/platform/exynos5-is/Makefile |7 +++
 4 files changed, 29 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/Kconfig
 create mode 100644 drivers/media/platform/exynos5-is/Makefile

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 08de865..4b0475e 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -123,6 +123,7 @@ config VIDEO_S3C_CAMIF
 
 source drivers/media/platform/soc_camera/Kconfig
 source drivers/media/platform/exynos4-is/Kconfig
+source drivers/media/platform/exynos5-is/Kconfig
 source drivers/media/platform/s5p-tv/Kconfig
 
 endif # V4L_PLATFORM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index eee28dd..40bf09f 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)+= s5p-tv/
 
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)+= s5p-g2d/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_CAMERA) += exynos5-is/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos5-is/Kconfig 
b/drivers/media/platform/exynos5-is/Kconfig
new file mode 100644
index 000..b67d11a
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Kconfig
@@ -0,0 +1,20 @@
+config VIDEO_SAMSUNG_EXYNOS5_CAMERA
+   bool Samsung Exynos5 SoC Camera Media Device driver
+   depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  PM_RUNTIME
+   depends on VIDEO_SAMSUNG_EXYNOS4_IS
+   help
+ This is a V4L2 media device driver for Exynos5 SoC series
+ camera subsystem.
+
+if VIDEO_SAMSUNG_EXYNOS5_CAMERA
+
+config VIDEO_SAMSUNG_EXYNOS5_FIMC_IS
+   tristate Samsung Exynos5 SoC FIMC-IS driver
+   depends on I2C  OF
+   depends on VIDEO_EXYNOS4_FIMC_IS
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ This is a V4L2 driver for Samsung Exynos5 SoC series Imaging
+ Subsystem known as FIMC-IS.
+
+endif #VIDEO_SAMSUNG_EXYNOS5_MDEV
diff --git a/drivers/media/platform/exynos5-is/Makefile 
b/drivers/media/platform/exynos5-is/Makefile
new file mode 100644
index 000..6cdb037
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Makefile
@@ -0,0 +1,7 @@
+ccflags-y += -Idrivers/media/platform/exynos4-is
+exynos5-fimc-is-objs := fimc-is-core.o fimc-is-isp.o fimc-is-scaler.o
+exynos5-fimc-is-objs += fimc-is-pipeline.o fimc-is-interface.o fimc-is-sensor.o
+exynos-mdevice-objs := exynos5-mdev.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_FIMC_IS) += exynos5-fimc-is.o
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_CAMERA) += exynos-mdevice.o
-- 
1.7.9.5

--
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 v5 10/13] [media] exynos5-fimc-is: Add the hardware interface module

2013-08-13 Thread Arun Kumar K
The hardware interface module finally sends the commands to the
FIMC-IS firmware and runs the interrupt handler for getting the
responses.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../media/platform/exynos5-is/fimc-is-interface.c  |  810 
 .../media/platform/exynos5-is/fimc-is-interface.h  |  125 +++
 2 files changed, 935 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-interface.c 
b/drivers/media/platform/exynos5-is/fimc-is-interface.c
new file mode 100644
index 000..c5da6ff
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-interface.c
@@ -0,0 +1,810 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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 linux/debugfs.h
+#include linux/seq_file.h
+#include fimc-is.h
+#include fimc-is-cmd.h
+#include fimc-is-regs.h
+
+#define init_request_barrier(itf) mutex_init(itf-request_barrier)
+#define enter_request_barrier(itf) mutex_lock(itf-request_barrier)
+#define exit_request_barrier(itf) mutex_unlock(itf-request_barrier)
+
+static inline void itf_get_cmd(struct fimc_is_interface *itf,
+   struct fimc_is_msg *msg, unsigned int index)
+{
+   struct is_common_reg __iomem *com_regs = itf-com_regs;
+
+   memset(msg, 0, sizeof(*msg));
+
+   switch (index) {
+   case INTR_GENERAL:
+   msg-command = com_regs-ihcmd;
+   msg-instance = com_regs-ihc_sensorid;
+   memcpy(msg-param, com_regs-ihc_param,
+   4 * sizeof(msg-param[0]));
+   break;
+   case INTR_SCC_FDONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-scc_sensor_id;
+   memcpy(msg-param, com_regs-scc_param,
+   3 * sizeof(msg-param[0]));
+   break;
+   case INTR_SCP_FDONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-scp_sensor_id;
+   memcpy(msg-param, com_regs-scp_param,
+   3 * sizeof(msg-param[0]));
+   break;
+   case INTR_META_DONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-meta_sensor_id;
+   msg-param[0] = com_regs-meta_param1;
+   break;
+   case INTR_SHOT_DONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-shot_sensor_id;
+   memcpy(msg-param, com_regs-shot_param,
+   2 * sizeof(msg-param[0]));
+   break;
+   default:
+   dev_err(itf-dev, %s Unknown command\n, __func__);
+   break;
+   }
+}
+
+static inline unsigned int itf_get_intr(struct fimc_is_interface *itf)
+{
+   unsigned int status;
+   struct is_common_reg __iomem *com_regs = itf-com_regs;
+
+   status = readl(itf-regs + INTMSR1) | com_regs-ihcmd_iflag |
+   com_regs-scc_iflag |
+   com_regs-scp_iflag |
+   com_regs-meta_iflag |
+   com_regs-shot_iflag;
+
+   return status;
+}
+
+static void itf_set_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   unsigned long flags;
+   spin_lock_irqsave(itf-slock_state, flags);
+   __set_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+}
+
+static void itf_clr_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   unsigned long flags;
+   spin_lock_irqsave(itf-slock_state, flags);
+   __clear_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+}
+
+static int itf_get_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   int ret = 0;
+   unsigned long flags;
+
+   spin_lock_irqsave(itf-slock_state, flags);
+   ret = test_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+   return ret;
+}
+
+static void itf_init_wakeup(struct fimc_is_interface *itf)
+{
+   itf_set_state(itf, IS_IF_STATE_INIT);
+   wake_up(itf-irq_queue);
+}
+
+void itf_busy_wakeup(struct fimc_is_interface *itf)
+{
+   itf_clr_state(itf, IS_IF_STATE_BUSY);
+   wake_up(itf-irq_queue);
+}
+
+static int itf_wait_hw_ready(struct fimc_is_interface *itf)
+{
+   int t;
+   for (t = TRY_RECV_AWARE_COUNT; t = 0; t--) {
+   unsigned int cfg = readl(itf-regs + INTMSR0

[PATCH v5 12/13] V4L: s5k6a3: Change sensor min/max resolutions

2013-08-13 Thread Arun Kumar K
s5k6a3 sensor has actual pixel resolution of 1408x1402 against
the active resolution 1392x1392. The real resolution is needed
when raw sensor SRGB data is dumped to memory by fimc-lite.

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/i2c/s5k6a3.c |   19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index ccbb4fc..34c3165 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -25,10 +25,12 @@
 #include media/v4l2-async.h
 #include media/v4l2-subdev.h
 
-#define S5K6A3_SENSOR_MAX_WIDTH1392
-#define S5K6A3_SENSOR_MAX_HEIGHT   1392
-#define S5K6A3_SENSOR_MIN_WIDTH32
-#define S5K6A3_SENSOR_MIN_HEIGHT   32
+#define S5K6A3_SENSOR_MAX_WIDTH1408
+#define S5K6A3_SENSOR_MAX_HEIGHT   1402
+#define S5K6A3_SENSOR_ACTIVE_WIDTH 1392
+#define S5K6A3_SENSOR_ACTIVE_HEIGHT1392
+#define S5K6A3_SENSOR_MIN_WIDTH(32 + 16)
+#define S5K6A3_SENSOR_MIN_HEIGHT   (32 + 10)
 
 #define S5K6A3_DEF_PIX_WIDTH   1296
 #define S5K6A3_DEF_PIX_HEIGHT  732
@@ -107,10 +109,11 @@ static void s5k6a3_try_format(struct v4l2_mbus_framefmt 
*mf)
 
fmt = find_sensor_format(mf);
mf-code = fmt-code;
-   v4l_bound_align_image(mf-width, S5K6A3_SENSOR_MIN_WIDTH,
- S5K6A3_SENSOR_MAX_WIDTH, 0,
- mf-height, S5K6A3_SENSOR_MIN_HEIGHT,
- S5K6A3_SENSOR_MAX_HEIGHT, 0, 0);
+   v4l_bound_align_image(mf-width,
+   S5K6A3_SENSOR_MIN_WIDTH, S5K6A3_SENSOR_MAX_WIDTH, 0,
+   mf-height,
+   S5K6A3_SENSOR_MIN_HEIGHT, S5K6A3_SENSOR_MAX_HEIGHT, 0,
+   0);
 }
 
 static struct v4l2_mbus_framefmt *__s5k6a3_get_format(
-- 
1.7.9.5

--
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 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-13 Thread Arun Kumar K
Hi Sachin,

On Wed, Aug 14, 2013 at 10:29 AM, Sachin Kamat sachin.ka...@linaro.org wrote:
 Hi Arun,

 On 14 August 2013 10:16, Arun Kumar K arun...@samsung.com wrote:
 From: Shaik Ameer Basha shaik.am...@samsung.com

 This patch adds support for media device for EXYNOS5 SoCs.
 The current media device supports the following ips to connect
 through the media controller framework.

 * MIPI-CSIS
   Support interconnection(subdev interface) between devices

 * FIMC-LITE
   Support capture interface from device(Sensor, MIPI-CSIS) to memory
   Support interconnection(subdev interface) between devices

 * FIMC-IS
   Camera post-processing IP having multiple sub-nodes.

 G-Scaler will be added later to the current media device.

 The media device creates two kinds of pipelines for connecting
 the above mentioned IPs.
 The pipeline0 is uses Sensor, MIPI-CSIS and FIMC-LITE which captures
 image data and dumps to memory.
 Pipeline1 uses FIMC-IS components for doing post-processing
 operations on the captured image and give scaled YUV output.

 Pipeline0
   ++ +---+ +---+ ++
   | Sensor | -- | MIPI-CSIS | -- | FIMC-LITE | -- | Memory |
   ++ +---+ +---+ ++

 Pipeline1
  ++  ++ +---+ +---+
  | Memory | --  |  ISP   | -- |SCC| -- |SCP|
  ++  ++ +---+ +---+

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 Signed-off-by: Arun Kumar K arun...@samsung.com
 ---
  .../devicetree/bindings/media/exynos5-mdev.txt |  130 +++
  drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1218 
 
  drivers/media/platform/exynos5-is/exynos5-mdev.h   |  160 +++
  3 files changed, 1508 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
  create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
  create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h

 diff --git a/Documentation/devicetree/bindings/media/exynos5-mdev.txt 
 b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
 new file mode 100644
 index 000..007ce21
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
 @@ -0,0 +1,130 @@
 +Samsung EXYNOS5 SoC Camera Subsystem
 +
 +
 +The Exynos5 SoC Camera subsystem comprises of multiple sub-devices
 +represented by separate device tree nodes. Currently this includes: 
 FIMC-LITE,
 +MIPI CSIS and FIMC-IS.
 +
 +The sub-subdevices are defined as child nodes of the common 'camera' node 
 which
 +also includes common properties of the whole subsystem not really specific 
 to
 +any single sub-device, like common camera port pins or the CAMCLK clock 
 outputs
 +for external image sensors attached to an SoC.
 +
 +Common 'camera' node
 +
 +
 +Required properties:
 +
 +- compatible   : must be samsung,exynos5-fimc, simple-bus

 I think it was concluded that this should be samsung,exynos5250-fimc.



Oh yes. Actually I modified it in the code, but missed updating the binding doc.
Thanks for catching it.
Will wait for Sylwester's comments to see if the whole series should
be posted again
or just this change can be made while applying.

Regards
Arun
--
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 v4 02/13] [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings documentation

2013-08-07 Thread Arun Kumar K
The patch adds the DT binding documentation for Samsung
Exynos5 SoC series imaging subsystem (FIMC-IS).

Signed-off-by: Arun Kumar K arun...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/media/exynos5-fimc-is.txt  |   52 
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt 
b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
new file mode 100644
index 000..5e6dee6
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
@@ -0,0 +1,52 @@
+Samsung EXYNOS5 SoC series Imaging Subsystem (FIMC-IS)
+--
+
+The camera subsystem on Samsung Exynos5 SoC has some changes relative
+to previous SoC versions. Exynos5 has almost similar MIPI-CSIS and
+FIMC-LITE IPs but has a much improved version of FIMC-IS which can
+handle sensor controls and camera post-processing operations. The
+Exynos5 FIMC-IS has a dedicated ARM Cortex A5 processor, many
+post-processing blocks (ISP, DRC, FD, ODC, DIS, 3DNR) and two
+dedicated scalers (SCC and SCP).
+
+fimc-is node
+
+
+Required properties:
+
+- compatible: must be samsung,exynos5250-fimc-is
+- reg   : physical base address and size of the memory mapped
+  registers
+- interrupt-parent  : parent interrupt controller
+- interrupts: fimc-is interrupt to the parent combiner
+- clocks: list of clock specifiers, corresponding to entries in
+  clock-names property;
+- clock-names   : must contain isp, mcu_isp, isp_div0, isp_div1,
+  isp_divmpwm, mcu_isp_div0, mcu_isp_div1 entries,
+  matching entries in the clocks property.
+
+pmu subnode
+---
+
+Required properties:
+ - reg : should contain PMU physical base address and size of the memory
+ mapped registers.
+
+i2c-isp (ISP I2C bus controller) nodes
+--
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-i2c-isp for Exynos4212,
+ Exynos4412 and Exynos5250 SoCs;
+- reg  : physical base address and length of the registers set;
+- clocks   : must contain gate clock specifier for this controller;
+- clock-names  : must contain i2c_isp entry.
+
+For the i2c-isp node, it is required to specify a pinctrl state named 
default,
+according to the pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt.
+
+Device tree nodes of the image sensors' controlled directly by the FIMC-IS
+firmware must be child nodes of their corresponding ISP I2C bus controller 
node.
+The data link of these image sensors must be specified using the common video
+interfaces bindings, defined in video-interfaces.txt.
-- 
1.7.9.5

--
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 v4 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-07 Thread Arun Kumar K
From: Shaik Ameer Basha shaik.am...@samsung.com

This patch adds support for media device for EXYNOS5 SoCs.
The current media device supports the following ips to connect
through the media controller framework.

* MIPI-CSIS
  Support interconnection(subdev interface) between devices

* FIMC-LITE
  Support capture interface from device(Sensor, MIPI-CSIS) to memory
  Support interconnection(subdev interface) between devices

* FIMC-IS
  Camera post-processing IP having multiple sub-nodes.

G-Scaler will be added later to the current media device.

The media device creates two kinds of pipelines for connecting
the above mentioned IPs.
The pipeline0 is uses Sensor, MIPI-CSIS and FIMC-LITE which captures
image data and dumps to memory.
Pipeline1 uses FIMC-IS components for doing post-processing
operations on the captured image and give scaled YUV output.

Pipeline0
  ++ +---+ +---+ ++
  | Sensor | -- | MIPI-CSIS | -- | FIMC-LITE | -- | Memory |
  ++ +---+ +---+ ++

Pipeline1
 ++  ++ +---+ +---+
 | Memory | --  |  ISP   | -- |SCC| -- |SCP|
 ++  ++ +---+ +---+

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 .../devicetree/bindings/media/exynos5-mdev.txt |  148 +++
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1189 
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  164 +++
 3 files changed, 1501 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h

diff --git a/Documentation/devicetree/bindings/media/exynos5-mdev.txt 
b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
new file mode 100644
index 000..8b2ffb9
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
@@ -0,0 +1,148 @@
+Samsung EXYNOS5 SoC Camera Subsystem
+
+
+The Exynos5 SoC Camera subsystem comprises of multiple sub-devices
+represented by separate device tree nodes. Currently this includes: FIMC-LITE,
+MIPI CSIS and FIMC-IS.
+
+The sub-subdevices are defined as child nodes of the common 'camera' node which
+also includes common properties of the whole subsystem not really specific to
+any single sub-device, like common camera port pins or the CAMCLK clock outputs
+for external image sensors attached to an SoC.
+
+Common 'camera' node
+
+
+Required properties:
+
+- compatible   : must be samsung,exynos5-fimc, simple-bus
+- clocks   : list of clock specifiers, corresponding to entries in
+ the clock-names property;
+- clock-names  : must contain sclk_bayer entry and matching clock property
+  entry
+
+The pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt must be used
+to define a required pinctrl state named default and optional pinctrl states:
+idle, active-a, active-b. These optional states can be used to switch the
+camera port pinmux at runtime. The idle state should configure both the 
camera
+ports A and B into high impedance state, especially the CAMCLK clock output
+should be inactive. For the active-a state the camera port A must be 
activated
+and the port B deactivated and for the state active-b it should be the other
+way around.
+
+The 'camera' node must include at least one 'fimc-lite' child node.
+
+'parallel-ports' node
+-
+
+This node should contain child 'port' nodes specifying active parallel video
+input ports. It includes camera A and camera B inputs. 'reg' property in the
+port nodes specifies data input - 0, 1 indicates input A, B respectively.
+
+Image sensor nodes
+--
+
+The sensor device nodes should be added to their control bus controller (e.g.
+I2C0) nodes and linked to a port node in the csis or the parallel-ports node,
+using the common video interfaces bindings, defined in video-interfaces.txt.
+The implementation of this bindings requires clock-frequency property to be
+present in the sensor device nodes.
+
+Example:
+
+   aliases {
+   fimc-lite0 = fimc_lite_0
+   };
+
+   /* Parallel bus IF sensor */
+   i2c_0: i2c@1386 {
+   s5k6aa: sensor@3c {
+   compatible = samsung,s5k6aafx;
+   reg = 0x3c;
+   vddio-supply = ...;
+
+   clock-frequency = 2400;
+   clocks = ...;
+   clock-names = mclk;
+
+   port {
+   s5k6aa_ep: endpoint {
+   remote-endpoint = fimc0_ep;
+   bus-width = 8

[PATCH v4 00/13] Exynos5 IS driver

2013-08-07 Thread Arun Kumar K
The patch series add support for Exynos5 camera subsystem. It
re-uses mipi-csis and fimc-lite from exynos4-is and adds a new
media device and fimc-is device drivers for exynos5.
The media device supports asynchronos subdev registration for the
fimc-is sensors and is based on the patch series from Sylwester
for exynos4-is [1].

[1] http://www.mail-archive.com/linux-media@vger.kernel.org/msg64653.html

Changes from v3
---
- Dropped the RFC tag
- Addressed all review comments from Sylwester and Sachin
- Removed clock provider for media dev
- Added s5k4e5 sensor devicetree binding doc

Changes from v2
---
- Added exynos5 media device driver from Shaik to this series
- Added ISP pipeline support in media device driver
- Based on Sylwester's latest exynos4-is development
- Asynchronos registration of sensor subdevs
- Made independent IS-sensor support
- Add s5k4e5 sensor driver
- Addressed review comments from Sylwester, Hans, Andrzej, Sachin

Changes from v1
---
- Addressed all review comments from Sylwester
- Made sensor subdevs as independent i2c devices
- Lots of cleanup
- Debugfs support added
- Removed PMU global register access

Arun Kumar K (12):
  [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings
documentation
  [media] exynos5-fimc-is: Add driver core files
  [media] exynos5-fimc-is: Add common driver header files
  [media] exynos5-fimc-is: Add register definition and context header
  [media] exynos5-fimc-is: Add isp subdev
  [media] exynos5-fimc-is: Add scaler subdev
  [media] exynos5-fimc-is: Add sensor interface
  [media] exynos5-fimc-is: Add the hardware pipeline control
  [media] exynos5-fimc-is: Add the hardware interface module
  [media] exynos5-is: Add Kconfig and Makefile
  V4L: s5k6a3: Change sensor min/max resolutions
  V4L: Add driver for s5k4e5 image sensor

Shaik Ameer Basha (1):
  [media] exynos5-is: Adding media device driver for exynos5

 .../devicetree/bindings/media/exynos5-fimc-is.txt  |   52 +
 .../devicetree/bindings/media/exynos5-mdev.txt |  148 ++
 .../devicetree/bindings/media/i2c/s5k4e5.txt   |   44 +
 drivers/media/i2c/Kconfig  |8 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k4e5.c |  361 +
 drivers/media/i2c/s5k6a3.c |   21 +-
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |   20 +
 drivers/media/platform/exynos5-is/Makefile |7 +
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1189 ++
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  164 ++
 drivers/media/platform/exynos5-is/fimc-is-cmd.h|  187 +++
 drivers/media/platform/exynos5-is/fimc-is-core.c   |  413 +
 drivers/media/platform/exynos5-is/fimc-is-core.h   |  134 ++
 drivers/media/platform/exynos5-is/fimc-is-err.h|  257 +++
 .../media/platform/exynos5-is/fimc-is-interface.c  |  810 ++
 .../media/platform/exynos5-is/fimc-is-interface.h  |  125 ++
 drivers/media/platform/exynos5-is/fimc-is-isp.c|  516 ++
 drivers/media/platform/exynos5-is/fimc-is-isp.h|   90 ++
 .../media/platform/exynos5-is/fimc-is-metadata.h   |  767 +
 drivers/media/platform/exynos5-is/fimc-is-param.h  | 1160 ++
 .../media/platform/exynos5-is/fimc-is-pipeline.c   | 1691 
 .../media/platform/exynos5-is/fimc-is-pipeline.h   |  127 ++
 drivers/media/platform/exynos5-is/fimc-is-regs.h   |  105 ++
 drivers/media/platform/exynos5-is/fimc-is-scaler.c |  449 ++
 drivers/media/platform/exynos5-is/fimc-is-scaler.h |  106 ++
 drivers/media/platform/exynos5-is/fimc-is-sensor.c |   45 +
 drivers/media/platform/exynos5-is/fimc-is-sensor.h |   66 +
 drivers/media/platform/exynos5-is/fimc-is.h|  160 ++
 31 files changed, 9217 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 create mode 100644 Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
 create mode 100644 drivers/media/i2c/s5k4e5.c
 create mode 100644 drivers/media/platform/exynos5-is/Kconfig
 create mode 100644 drivers/media/platform/exynos5-is/Makefile
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-cmd.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-err.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.h
 create mode 100644 drivers/media/platform

[PATCH v4 11/13] [media] exynos5-is: Add Kconfig and Makefile

2013-08-07 Thread Arun Kumar K
Adds Kconfig and Makefile for exynos5-is driver files.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |   20 
 drivers/media/platform/exynos5-is/Makefile |7 +++
 4 files changed, 29 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/Kconfig
 create mode 100644 drivers/media/platform/exynos5-is/Makefile

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 08de865..4b0475e 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -123,6 +123,7 @@ config VIDEO_S3C_CAMIF
 
 source drivers/media/platform/soc_camera/Kconfig
 source drivers/media/platform/exynos4-is/Kconfig
+source drivers/media/platform/exynos5-is/Kconfig
 source drivers/media/platform/s5p-tv/Kconfig
 
 endif # V4L_PLATFORM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index eee28dd..40bf09f 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)+= s5p-tv/
 
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)+= s5p-g2d/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_CAMERA) += exynos5-is/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos5-is/Kconfig 
b/drivers/media/platform/exynos5-is/Kconfig
new file mode 100644
index 000..c872757
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Kconfig
@@ -0,0 +1,20 @@
+config VIDEO_SAMSUNG_EXYNOS5_CAMERA
+   bool Samsung Exynos5 Media Device driver
+   depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  PM_RUNTIME
+   depends on VIDEO_SAMSUNG_EXYNOS4_IS
+   help
+ This is a v4l2 based media controller driver for
+ Exynos5 SoC.
+
+if VIDEO_SAMSUNG_EXYNOS5_CAMERA
+
+config VIDEO_SAMSUNG_EXYNOS5_FIMC_IS
+   tristate Samsung Exynos5 SoC FIMC-IS driver
+   depends on I2C  OF
+   depends on VIDEO_EXYNOS4_FIMC_IS
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ This is a V4L2 driver for Samsung Exynos5 SoC series Imaging
+ Subsystem known as FIMC-IS.
+
+endif #VIDEO_SAMSUNG_EXYNOS5_MDEV
diff --git a/drivers/media/platform/exynos5-is/Makefile 
b/drivers/media/platform/exynos5-is/Makefile
new file mode 100644
index 000..6cdb037
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Makefile
@@ -0,0 +1,7 @@
+ccflags-y += -Idrivers/media/platform/exynos4-is
+exynos5-fimc-is-objs := fimc-is-core.o fimc-is-isp.o fimc-is-scaler.o
+exynos5-fimc-is-objs += fimc-is-pipeline.o fimc-is-interface.o fimc-is-sensor.o
+exynos-mdevice-objs := exynos5-mdev.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_FIMC_IS) += exynos5-fimc-is.o
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_CAMERA) += exynos-mdevice.o
-- 
1.7.9.5

--
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 v4 08/13] [media] exynos5-fimc-is: Add sensor interface

2013-08-07 Thread Arun Kumar K
Some sensors to be used with fimc-is are exclusively controlled
by the fimc-is firmware. This minimal sensor driver provides
the required info for the firmware to configure the sensors
sitting on I2C bus.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-sensor.c |   45 +
 drivers/media/platform/exynos5-is/fimc-is-sensor.h |   66 
 2 files changed, 111 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.c 
b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
new file mode 100644
index 000..7df2b11
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
@@ -0,0 +1,45 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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 fimc-is-sensor.h
+
+static const struct sensor_drv_data s5k6a3_drvdata = {
+   .id = FIMC_IS_SENSOR_ID_S5K6A3,
+   .open_timeout   = S5K6A3_OPEN_TIMEOUT,
+   .setfile_name   = setfile_6a3.bin,
+};
+
+static const struct sensor_drv_data s5k4e5_drvdata = {
+   .id = FIMC_IS_SENSOR_ID_S5K4E5,
+   .open_timeout   = S5K4E5_OPEN_TIMEOUT,
+   .setfile_name   = setfile_4e5.bin,
+};
+
+static const struct of_device_id fimc_is_sensor_of_ids[] = {
+   {
+   .compatible = samsung,s5k6a3,
+   .data   = s5k6a3_drvdata,
+   },
+   {
+   .compatible = samsung,s5k4e5,
+   .data   = s5k4e5_drvdata,
+   },
+   {  }
+};
+
+const struct sensor_drv_data *exynos5_is_sensor_get_drvdata(
+   struct device_node *node)
+{
+   const struct of_device_id *of_id;
+
+   of_id = of_match_node(fimc_is_sensor_of_ids, node);
+   return of_id ? of_id-data : NULL;
+}
diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.h 
b/drivers/media/platform/exynos5-is/fimc-is-sensor.h
new file mode 100644
index 000..736ef16
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.h
@@ -0,0 +1,66 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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.
+ */
+#ifndef FIMC_IS_SENSOR_H_
+#define FIMC_IS_SENSOR_H_
+
+#include linux/of.h
+#include linux/types.h
+
+#define S5K6A3_OPEN_TIMEOUT2000 /* ms */
+#define S5K6A3_SENSOR_WIDTH1392
+#define S5K6A3_SENSOR_HEIGHT   1392
+
+#define S5K4E5_OPEN_TIMEOUT2000 /* ms */
+#define S5K4E5_SENSOR_WIDTH2560
+#define S5K4E5_SENSOR_HEIGHT   1920
+
+#define SENSOR_WIDTH_PADDING   16
+#define SENSOR_HEIGHT_PADDING  10
+
+enum fimc_is_sensor_id {
+   FIMC_IS_SENSOR_ID_S5K3H2 = 1,
+   FIMC_IS_SENSOR_ID_S5K6A3,
+   FIMC_IS_SENSOR_ID_S5K4E5,
+   FIMC_IS_SENSOR_ID_S5K3H7,
+   FIMC_IS_SENSOR_ID_CUSTOM,
+   FIMC_IS_SENSOR_ID_END
+};
+
+struct sensor_drv_data {
+   enum fimc_is_sensor_id id;
+   /* sensor open timeout in ms */
+   unsigned short open_timeout;
+   char *setfile_name;
+};
+
+/**
+ * struct fimc_is_sensor - fimc-is sensor data structure
+ * @drvdata: a pointer to the sensor's parameters data structure
+ * @i2c_bus: ISP I2C bus index (0...1)
+ * @width: sensor active width
+ * @height: sensor active height
+ * @pixel_width: sensor effective pixel width (width + padding)
+ * @pixel_height: sensor effective pixel height (height + padding)
+ */
+struct fimc_is_sensor {
+   const struct sensor_drv_data *drvdata;
+   unsigned int i2c_bus;
+   unsigned int width;
+   unsigned int height;
+   unsigned int pixel_width;
+   unsigned int pixel_height;
+};
+
+const struct sensor_drv_data *exynos5_is_sensor_get_drvdata(
+   struct device_node *node);
+
+#endif /* FIMC_IS_SENSOR_H_ */
-- 
1.7.9.5

--
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 v4 06/13] [media] exynos5-fimc-is: Add isp subdev

2013-08-07 Thread Arun Kumar K
fimc-is driver takes video data input from the ISP video node
which is added in this patch. This node accepts Bayer input
buffers which is given from the IS sensors.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-isp.c |  516 +++
 drivers/media/platform/exynos5-is/fimc-is-isp.h |   90 
 2 files changed, 606 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-isp.c 
b/drivers/media/platform/exynos5-is/fimc-is-isp.c
new file mode 100644
index 000..afbf4a2
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-isp.c
@@ -0,0 +1,516 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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 media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+
+#define ISP_DRV_NAME fimc-is-isp
+
+static const struct fimc_is_fmt formats[] = {
+   {
+   .name   = Bayer GR-BG 8bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG8,
+   .depth  = { 8 },
+   .num_planes = 1,
+   },
+   {
+   .name   = Bayer GR-BG 10bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG10,
+   .depth  = { 16 },
+   .num_planes = 1,
+   },
+   {
+   .name   = Bayer GR-BG 12bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG12,
+   .depth  = { 16 },
+   .num_planes = 1,
+   },
+};
+#define NUM_FORMATS ARRAY_SIZE(formats)
+
+static const struct fimc_is_fmt *find_format(struct v4l2_format *f)
+{
+   unsigned int i;
+
+   for (i = 0; i  NUM_FORMATS; i++)
+   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
+   return formats[i];
+   return NULL;
+}
+
+static int isp_video_output_start_streaming(struct vb2_queue *vq,
+   unsigned int count)
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+
+   set_bit(STATE_RUNNING, isp-output_state);
+   return 0;
+}
+
+static int isp_video_output_stop_streaming(struct vb2_queue *vq)
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+
+   /* Release un-used buffers */
+   while (!list_empty(isp-wait_queue)) {
+   buf = fimc_is_isp_wait_queue_get(isp);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+   while (!list_empty(isp-run_queue)) {
+   buf = fimc_is_isp_run_queue_get(isp);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+
+   clear_bit(STATE_RUNNING, isp-output_state);
+   return 0;
+}
+
+static int isp_video_output_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   const struct fimc_is_fmt *fmt = isp-fmt;
+   unsigned int wh, i;
+
+   if (!fmt)
+   return -EINVAL;
+
+   *num_planes = fmt-num_planes;
+   wh = isp-width * isp-height;
+
+   for (i = 0; i  *num_planes; i++) {
+   allocators[i] = isp-alloc_ctx;
+   sizes[i] = (wh * fmt-depth[i]) / 8;
+   }
+   return 0;
+}
+
+static int isp_video_output_buffer_init(struct vb2_buffer *vb)
+{
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb);
+
+   buf-paddr[0] = vb2_dma_contig_plane_dma_addr(vb, 0);
+   return 0;
+}
+
+static void isp_video_output_buffer_queue(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb);
+
+   fimc_is_pipeline_buf_lock(isp-pipeline);
+   fimc_is_isp_wait_queue_add(isp, buf);
+   fimc_is_pipeline_buf_unlock(isp-pipeline);
+
+   /* Call shot command */
+   fimc_is_pipeline_shot(isp-pipeline);
+}
+
+static const struct vb2_ops isp_video_output_qops = {
+   .queue_setup = isp_video_output_queue_setup,
+   .buf_init= isp_video_output_buffer_init,
+   .buf_queue   = isp_video_output_buffer_queue,
+   .wait_prepare= vb2_ops_wait_prepare,
+   .wait_finish = vb2_ops_wait_finish,
+   .start_streaming = isp_video_output_start_streaming

[PATCH v4 09/13] [media] exynos5-fimc-is: Add the hardware pipeline control

2013-08-07 Thread Arun Kumar K
This patch adds the crucial hardware pipeline control for the
fimc-is driver. All the subdev nodes will call this pipeline
interfaces to reach the hardware. Responsibilities of this module
involves configuring and maintaining the hardware pipeline involving
multiple sub-ips like ISP, DRC, Scalers, ODC, 3DNR, FD etc.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 .../media/platform/exynos5-is/fimc-is-pipeline.c   | 1691 
 .../media/platform/exynos5-is/fimc-is-pipeline.h   |  127 ++
 2 files changed, 1818 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-pipeline.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-pipeline.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-pipeline.c 
b/drivers/media/platform/exynos5-is/fimc-is-pipeline.c
new file mode 100644
index 000..e37ce56
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-pipeline.c
@@ -0,0 +1,1691 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Arun Kumar K arun...@samsung.com
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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 fimc-is.h
+#include fimc-is-pipeline.h
+#include fimc-is-metadata.h
+#include fimc-is-regs.h
+#include fimc-is-cmd.h
+#include media/videobuf2-dma-contig.h
+#include linux/delay.h
+
+/* Default setting values */
+#define DEFAULT_PREVIEW_STILL_WIDTH1280
+#define DEFAULT_PREVIEW_STILL_HEIGHT   720
+#define DEFAULT_CAPTURE_VIDEO_WIDTH1920
+#define DEFAULT_CAPTURE_VIDEO_HEIGHT   1080
+#define DEFAULT_CAPTURE_STILL_WIDTH2560
+#define DEFAULT_CAPTURE_STILL_HEIGHT   1920
+#define DEFAULT_CAPTURE_STILL_CROP_WIDTH   2560
+#define DEFAULT_CAPTURE_STILL_CROP_HEIGHT  1440
+#define DEFAULT_PREVIEW_VIDEO_WIDTH640
+#define DEFAULT_PREVIEW_VIDEO_HEIGHT   480
+
+/* Init params for pipeline devices */
+static const struct sensor_param init_sensor_param = {
+   .frame_rate = {
+   .frame_rate = 30,
+   },
+};
+
+static const struct isp_param init_isp_param = {
+   .control = {
+   .cmd = CONTROL_COMMAND_START,
+   .bypass = CONTROL_BYPASS_DISABLE,
+   },
+   .otf_input = {
+   .cmd = OTF_INPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = OTF_INPUT_FORMAT_BAYER,
+   .bitwidth = OTF_INPUT_BIT_WIDTH_10BIT,
+   .order = OTF_INPUT_ORDER_BAYER_GR_BG,
+   .frametime_max = 3,
+   },
+   .dma1_input = {
+   .cmd = DMA_INPUT_COMMAND_DISABLE,
+   },
+   .dma2_input = {
+   .cmd = DMA_INPUT_COMMAND_DISABLE,
+   },
+   .aa = {
+   .cmd = ISP_AA_COMMAND_START,
+   .target = ISP_AA_TARGET_AF | ISP_AA_TARGET_AE |
+   ISP_AA_TARGET_AWB,
+   .mode = ISP_AF_CONTINUOUS,
+   },
+   .flash = {
+   .cmd = ISP_FLASH_COMMAND_DISABLE,
+   .redeye = ISP_FLASH_REDEYE_DISABLE,
+   },
+   .awb = {
+   .cmd = ISP_AWB_COMMAND_AUTO,
+   },
+   .effect = {
+   .cmd = ISP_IMAGE_EFFECT_DISABLE,
+   },
+   .iso = {
+   .cmd = ISP_ISO_COMMAND_AUTO,
+   },
+   .adjust = {
+   .cmd = ISP_ADJUST_COMMAND_AUTO,
+   },
+   .metering = {
+   .cmd = ISP_METERING_COMMAND_CENTER,
+   .win_width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .win_height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   },
+   .afc = {
+   .cmd = ISP_AFC_COMMAND_AUTO,
+   },
+   .otf_output = {
+   .cmd = OTF_OUTPUT_COMMAND_ENABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = OTF_OUTPUT_FORMAT_YUV444,
+   .bitwidth = OTF_OUTPUT_BIT_WIDTH_12BIT,
+   .order = OTF_OUTPUT_ORDER_BAYER_GR_BG,
+   },
+   .dma1_output = {
+   .cmd = DMA_OUTPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = DMA_INPUT_FORMAT_YUV444,
+   .bitwidth = DMA_INPUT_BIT_WIDTH_8BIT,
+   .plane = 1,
+   .order = DMA_INPUT_ORDER_YCBCR,
+   },
+   .dma2_output = {
+   .cmd = DMA_OUTPUT_COMMAND_DISABLE,
+   .width = DEFAULT_CAPTURE_STILL_WIDTH,
+   .height = DEFAULT_CAPTURE_STILL_HEIGHT,
+   .format = DMA_OUTPUT_FORMAT_BAYER

[PATCH v4 03/13] [media] exynos5-fimc-is: Add driver core files

2013-08-07 Thread Arun Kumar K
This driver is for the FIMC-IS IP available in Samsung Exynos5
SoC onwards. This patch adds the core files for the new driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-core.c |  413 ++
 drivers/media/platform/exynos5-is/fimc-is-core.h |  134 +++
 2 files changed, 547 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-core.c 
b/drivers/media/platform/exynos5-is/fimc-is-core.c
new file mode 100644
index 000..067dea6
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-core.c
@@ -0,0 +1,413 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Arun Kumar K arun...@samsung.com
+ *
+ * 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 linux/bug.h
+#include linux/ctype.h
+#include linux/device.h
+#include linux/debugfs.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/err.h
+#include linux/firmware.h
+#include linux/fs.h
+#include linux/gpio.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/module.h
+#include linux/types.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/videodev2.h
+#include linux/of.h
+#include linux/of_gpio.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/of_irq.h
+#include linux/pinctrl/consumer.h
+
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-mem2mem.h
+#include media/v4l2-of.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+#include fimc-is-i2c.h
+
+#define CLK_MCU_ISP_DIV0_FREQ  (200 * 100)
+#define CLK_MCU_ISP_DIV1_FREQ  (100 * 100)
+#define CLK_ISP_DIV0_FREQ  (134 * 100)
+#define CLK_ISP_DIV1_FREQ  (68 * 100)
+#define CLK_ISP_DIVMPWM_FREQ   (34 * 100)
+
+static char *fimc_is_clock_name[] = {
+   [IS_CLK_ISP]= isp,
+   [IS_CLK_MCU_ISP]= mcu_isp,
+   [IS_CLK_ISP_DIV0]   = isp_div0,
+   [IS_CLK_ISP_DIV1]   = isp_div1,
+   [IS_CLK_ISP_DIVMPWM]= isp_divmpwm,
+   [IS_CLK_MCU_ISP_DIV0]   = mcu_isp_div0,
+   [IS_CLK_MCU_ISP_DIV1]   = mcu_isp_div1,
+};
+
+static void fimc_is_put_clocks(struct fimc_is *is)
+{
+   int i;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
+   if (IS_ERR(is-clock[i]))
+   continue;
+   clk_unprepare(is-clock[i]);
+   clk_put(is-clock[i]);
+   is-clock[i] = NULL;
+   }
+}
+
+static int fimc_is_get_clocks(struct fimc_is *is)
+{
+   struct device *dev = is-pdev-dev;
+   int i, ret;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
+   is-clock[i] = clk_get(dev, fimc_is_clock_name[i]);
+   if (IS_ERR(is-clock[i]))
+   goto err;
+   ret = clk_prepare(is-clock[i]);
+   if (ret  0) {
+   clk_put(is-clock[i]);
+   is-clock[i] = ERR_PTR(-EINVAL);
+   goto err;
+   }
+   }
+   return 0;
+err:
+   fimc_is_put_clocks(is);
+   pr_err(Failed to get clock: %s\n, fimc_is_clock_name[i]);
+   return -ENXIO;
+}
+
+static int fimc_is_configure_clocks(struct fimc_is *is)
+{
+   int i, ret;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++)
+   is-clock[i] = ERR_PTR(-EINVAL);
+
+   ret = fimc_is_get_clocks(is);
+   if (ret)
+   return ret;
+
+   /* Set rates */
+   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV0],
+   CLK_MCU_ISP_DIV0_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV1],
+   CLK_MCU_ISP_DIV1_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV0], CLK_ISP_DIV0_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV1], CLK_ISP_DIV1_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIVMPWM],
+   CLK_ISP_DIVMPWM_FREQ);
+   return ret;
+}
+
+static void fimc_is_pipelines_destroy(struct fimc_is *is)
+{
+   int i;
+
+   for (i = 0; i  is-drvdata-num_instance; i++)
+   fimc_is_pipeline_destroy(is-pipeline[i]);
+}
+
+static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index,
+   struct device_node *node)
+{
+   struct fimc_is_sensor *sensor

[PATCH v4 12/13] V4L: s5k6a3: Change sensor min/max resolutions

2013-08-07 Thread Arun Kumar K
s5k6a3 sensor has actual pixel resolution of 1408x1402 against
the active resolution 1392x1392. The real resolution is needed
when raw sensor SRGB data is dumped to memory by fimc-lite.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/i2c/s5k6a3.c |   21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index ccbb4fc..6dec2ec 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -25,10 +25,14 @@
 #include media/v4l2-async.h
 #include media/v4l2-subdev.h
 
-#define S5K6A3_SENSOR_MAX_WIDTH1392
-#define S5K6A3_SENSOR_MAX_HEIGHT   1392
-#define S5K6A3_SENSOR_MIN_WIDTH32
-#define S5K6A3_SENSOR_MIN_HEIGHT   32
+#define S5K6A3_SENSOR_MAX_WIDTH1408
+#define S5K6A3_SENSOR_MAX_HEIGHT   1408
+
+#define S5K6A3_SENSOR_ACTIVE_WIDTH 1392
+#define S5K6A3_SENSOR_ACTIVE_HEIGHT1392
+
+#define S5K6A3_SENSOR_MIN_WIDTH(32 + 16)
+#define S5K6A3_SENSOR_MIN_HEIGHT   (32 + 10)
 
 #define S5K6A3_DEF_PIX_WIDTH   1296
 #define S5K6A3_DEF_PIX_HEIGHT  732
@@ -107,10 +111,11 @@ static void s5k6a3_try_format(struct v4l2_mbus_framefmt 
*mf)
 
fmt = find_sensor_format(mf);
mf-code = fmt-code;
-   v4l_bound_align_image(mf-width, S5K6A3_SENSOR_MIN_WIDTH,
- S5K6A3_SENSOR_MAX_WIDTH, 0,
- mf-height, S5K6A3_SENSOR_MIN_HEIGHT,
- S5K6A3_SENSOR_MAX_HEIGHT, 0, 0);
+   v4l_bound_align_image(mf-width,
+   S5K6A3_SENSOR_MIN_WIDTH, S5K6A3_SENSOR_MAX_WIDTH, 0,
+   mf-height,
+   S5K6A3_SENSOR_MIN_HEIGHT, S5K6A3_SENSOR_MAX_HEIGHT, 0,
+   0);
 }
 
 static struct v4l2_mbus_framefmt *__s5k6a3_get_format(
-- 
1.7.9.5

--
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 v4 05/13] [media] exynos5-fimc-is: Add register definition and context header

2013-08-07 Thread Arun Kumar K
This patch adds the register definition file for the fimc-is driver
and also the header file containing the main context for the driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-regs.h |  105 ++
 drivers/media/platform/exynos5-is/fimc-is.h  |  160 ++
 2 files changed, 265 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-regs.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-regs.h 
b/drivers/media/platform/exynos5-is/fimc-is-regs.h
new file mode 100644
index 000..06aa466
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-regs.h
@@ -0,0 +1,105 @@
+/*
+ * Samsung Exynos5 SoC series FIMC-IS driver
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd
+ * Arun Kumar K arun...@samsung.com
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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.
+ */
+
+#ifndef FIMC_IS_REGS_H
+#define FIMC_IS_REGS_H
+
+/* WDT_ISP register */
+#define WDT0x0017
+/* MCUCTL register */
+#define MCUCTL 0x0018
+/* MCU Controller Register */
+#define MCUCTLR(MCUCTL+0x00)
+#define MCUCTLR_AXI_ISPX_AWCACHE(x)((x)  16)
+#define MCUCTLR_AXI_ISPX_ARCACHE(x)((x)  12)
+#define MCUCTLR_MSWRST (1  0)
+/* Boot Base OFfset Address Register */
+#define BBOAR  (MCUCTL+0x04)
+#define BBOAR_BBOA(x)  ((x)  0)
+
+/* Interrupt Generation Register 0 from Host CPU to VIC */
+#define INTGR0 (MCUCTL+0x08)
+#define INTGR0_INTGC(n)(1  ((n) + 16))
+#define INTGR0_INTGD(n)(1  (n))
+
+/* Interrupt Clear Register 0 from Host CPU to VIC */
+#define INTCR0 (MCUCTL+0x0c)
+#define INTCR0_INTCC(n)(1  ((n) + 16))
+#define INTCR0_INTCD(n)(1  (n))
+
+/* Interrupt Mask Register 0 from Host CPU to VIC */
+#define INTMR0 (MCUCTL+0x10)
+#define INTMR0_INTMC(n)(1  ((n) + 16))
+#define INTMR0_INTMD(n)(1  (n))
+
+/* Interrupt Status Register 0 from Host CPU to VIC */
+#define INTSR0 (MCUCTL+0x14)
+#define INTSR0_GET_INTSD(n, x) (((x)  (n))  0x1)
+#define INTSR0_GET_INTSC(n, x) (((x)  ((n) + 16))  0x1)
+
+/* Interrupt Mask Status Register 0 from Host CPU to VIC */
+#define INTMSR0(MCUCTL+0x18)
+#define INTMSR0_GET_INTMSD(n, x)   (((x)  (n))  0x1)
+#define INTMSR0_GET_INTMSC(n, x)   (((x)  ((n) + 16))  0x1)
+
+/* Interrupt Generation Register 1 from ISP CPU to Host IC */
+#define INTGR1 (MCUCTL+0x1c)
+#define INTGR1_INTGC(n)(1  (n))
+
+/* Interrupt Clear Register 1 from ISP CPU to Host IC */
+#define INTCR1 (MCUCTL+0x20)
+#define INTCR1_INTCC(n)(1  (n))
+
+/* Interrupt Mask Register 1 from ISP CPU to Host IC */
+#define INTMR1 (MCUCTL+0x24)
+#define INTMR1_INTMC(n)(1  (n))
+
+/* Interrupt Status Register 1 from ISP CPU to Host IC */
+#define INTSR1 (MCUCTL+0x28)
+/* Interrupt Mask Status Register 1 from ISP CPU to Host IC */
+#define INTMSR1(MCUCTL+0x2c)
+/* Interrupt Clear Register 2 from ISP BLK's interrupts to Host IC */
+#define INTCR2 (MCUCTL+0x30)
+#define INTCR2_INTCC(n)(1  (n))
+
+/* Interrupt Mask Register 2 from ISP BLK's interrupts to Host IC */
+#define INTMR2 (MCUCTL+0x34)
+#define INTMR2_INTMCIS(n)  (1  (n))
+
+/* Interrupt Status Register 2 from ISP BLK's interrupts to Host IC */
+#define INTSR2 (MCUCTL+0x38)
+/* Interrupt Mask Status Register 2 from ISP BLK's interrupts to Host IC */
+#define INTMSR2(MCUCTL+0x3c)
+/* General Purpose Output Control Register (0~17) */
+#define GPOCTLR(MCUCTL+0x40)
+#define GPOCTLR_GPOG(n, x) ((x)  (n))
+
+/* General Purpose Pad Output Enable Register (0~17) */
+#define GPOENCTLR  (MCUCTL+0x44)
+#define GPOENCTLR_GPOEN0(n, x) ((x)  (n))
+
+/* General Purpose Input Control Register (0~17) */
+#define GPICTLR(MCUCTL+0x48)
+
+/* IS Shared Registers between ISP CPU and HOST CPU */
+#define ISSR(n)(MCUCTL + 0x80 + (n))
+
+/* PMU for FIMC-IS*/
+#define PMUREG_CMU_RESET_ISP_SYS_PWR_REG   0x1584
+#define

[PATCH v4 07/13] [media] exynos5-fimc-is: Add scaler subdev

2013-08-07 Thread Arun Kumar K
FIMC-IS has two hardware scalers named as scaler-codec and
scaler-preview. This patch adds the common code handling the
video nodes and subdevs of both the scalers.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-scaler.c |  449 
 drivers/media/platform/exynos5-is/fimc-is-scaler.h |  106 +
 2 files changed, 555 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-scaler.c 
b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
new file mode 100644
index 000..c9bd07b
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
@@ -0,0 +1,449 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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 media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+
+#define IS_SCALER_DRV_NAME fimc-is-scaler
+
+static const struct fimc_is_fmt formats[] = {
+   {
+   .name   = YUV 4:2:0 3p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_YUV420M,
+   .depth  = {8, 2, 2},
+   .num_planes = 3,
+   },
+   {
+   .name   = YUV 4:2:0 2p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_NV12M,
+   .depth  = {8, 4},
+   .num_planes = 2,
+   },
+   {
+   .name   = YUV 4:2:2 1p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_NV16,
+   .depth  = {16},
+   .num_planes = 1,
+   },
+};
+#define NUM_FORMATS ARRAY_SIZE(formats)
+
+static const struct fimc_is_fmt *find_format(struct v4l2_format *f)
+{
+   unsigned int i;
+
+   for (i = 0; i  NUM_FORMATS; i++) {
+   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
+   return formats[i];
+   }
+   return NULL;
+}
+
+static int scaler_video_capture_start_streaming(struct vb2_queue *vq,
+   unsigned int count)
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   int ret;
+
+   ret = fimc_is_pipeline_scaler_start(ctx-pipeline,
+   ctx-scaler_id,
+   vq-num_buffers,
+   ctx-fmt-num_planes);
+   if (ret) {
+   v4l2_err(ctx-subdev, Scaler start failed.\n);
+   return -EINVAL;
+   }
+
+   set_bit(STATE_RUNNING, ctx-capture_state);
+   return 0;
+}
+
+static int scaler_video_capture_stop_streaming(struct vb2_queue *vq)
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+   int ret;
+
+   ret = fimc_is_pipeline_scaler_stop(ctx-pipeline, ctx-scaler_id);
+   if (ret)
+   v4l2_info(ctx-subdev, Scaler already stopped.\n);
+
+   /* Release un-used buffers */
+   while (!list_empty(ctx-wait_queue)) {
+   buf = fimc_is_scaler_wait_queue_get(ctx);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+   while (!list_empty(ctx-run_queue)) {
+   buf = fimc_is_scaler_run_queue_get(ctx);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+
+   clear_bit(STATE_RUNNING, ctx-capture_state);
+   return 0;
+}
+
+static int scaler_video_capture_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   const struct fimc_is_fmt *fmt = ctx-fmt;
+   unsigned int wh;
+   int i;
+
+   if (!fmt)
+   return -EINVAL;
+
+   *num_planes = fmt-num_planes;
+   wh = ctx-width * ctx-height;
+
+   for (i = 0; i  *num_planes; i++) {
+   allocators[i] = ctx-alloc_ctx;
+   sizes[i] = (wh * fmt-depth[i]) / 8;
+   }
+   return 0;
+}
+
+static int scaler_video_capture_buffer_init(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf = container_of(vb, struct fimc_is_buf, vb);
+   const struct fimc_is_fmt *fmt;
+   int i;
+
+   fmt = ctx-fmt;
+   for (i = 0; i  fmt-num_planes; i++)
+   buf-paddr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
+
+   return 0;
+}
+
+static void

[PATCH v4 10/13] [media] exynos5-fimc-is: Add the hardware interface module

2013-08-07 Thread Arun Kumar K
The hardware interface module finally sends the commands to the
FIMC-IS firmware and runs the interrupt handler for getting the
responses.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 .../media/platform/exynos5-is/fimc-is-interface.c  |  810 
 .../media/platform/exynos5-is/fimc-is-interface.h  |  125 +++
 2 files changed, 935 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-interface.c 
b/drivers/media/platform/exynos5-is/fimc-is-interface.c
new file mode 100644
index 000..9fcf89d
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-interface.c
@@ -0,0 +1,810 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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 linux/debugfs.h
+#include linux/seq_file.h
+#include fimc-is.h
+#include fimc-is-cmd.h
+#include fimc-is-regs.h
+
+#define init_request_barrier(itf) mutex_init(itf-request_barrier)
+#define enter_request_barrier(itf) mutex_lock(itf-request_barrier)
+#define exit_request_barrier(itf) mutex_unlock(itf-request_barrier)
+
+static inline void itf_get_cmd(struct fimc_is_interface *itf,
+   struct fimc_is_msg *msg, unsigned int index)
+{
+   struct is_common_reg __iomem *com_regs = itf-com_regs;
+
+   memset(msg, 0, sizeof(*msg));
+
+   switch (index) {
+   case INTR_GENERAL:
+   msg-command = com_regs-ihcmd;
+   msg-instance = com_regs-ihc_sensorid;
+   memcpy(msg-param, com_regs-ihc_param,
+   4 * sizeof(msg-param[0]));
+   break;
+   case INTR_SCC_FDONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-scc_sensor_id;
+   memcpy(msg-param, com_regs-scc_param,
+   3 * sizeof(msg-param[0]));
+   break;
+   case INTR_SCP_FDONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-scp_sensor_id;
+   memcpy(msg-param, com_regs-scp_param,
+   3 * sizeof(msg-param[0]));
+   break;
+   case INTR_META_DONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-meta_sensor_id;
+   msg-param[0] = com_regs-meta_param1;
+   break;
+   case INTR_SHOT_DONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-shot_sensor_id;
+   memcpy(msg-param, com_regs-shot_param,
+   2 * sizeof(msg-param[0]));
+   break;
+   default:
+   dev_err(itf-dev, %s Unknown command\n, __func__);
+   break;
+   }
+}
+
+static inline unsigned int itf_get_intr(struct fimc_is_interface *itf)
+{
+   unsigned int status;
+   struct is_common_reg __iomem *com_regs = itf-com_regs;
+
+   status = readl(itf-regs + INTMSR1) | com_regs-ihcmd_iflag |
+   com_regs-scc_iflag |
+   com_regs-scp_iflag |
+   com_regs-meta_iflag |
+   com_regs-shot_iflag;
+
+   return status;
+}
+
+static void itf_set_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   unsigned long flags;
+   spin_lock_irqsave(itf-slock_state, flags);
+   __set_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+}
+
+static void itf_clr_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   unsigned long flags;
+   spin_lock_irqsave(itf-slock_state, flags);
+   __clear_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+}
+
+static int itf_get_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   int ret = 0;
+   unsigned long flags;
+
+   spin_lock_irqsave(itf-slock_state, flags);
+   ret = test_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+   return ret;
+}
+
+static void itf_init_wakeup(struct fimc_is_interface *itf)
+{
+   itf_set_state(itf, IS_IF_STATE_INIT);
+   wake_up(itf-irq_queue);
+}
+
+void itf_busy_wakeup(struct fimc_is_interface *itf)
+{
+   itf_clr_state(itf, IS_IF_STATE_BUSY);
+   wake_up(itf-irq_queue);
+}
+
+static int itf_wait_hw_ready(struct fimc_is_interface *itf)
+{
+   int t;
+   for (t = TRY_RECV_AWARE_COUNT; t = 0; t--) {
+   unsigned int cfg = readl(itf-regs + INTMSR0);
+   if (INTMSR0_GET_INTMSD(0, cfg) == 0

[PATCH v4 13/13] V4L: Add driver for s5k4e5 image sensor

2013-08-07 Thread Arun Kumar K
This patch adds subdev driver for Samsung S5K4E5 raw image sensor.
Like s5k6a3, it is also another fimc-is firmware controlled
sensor. This minimal sensor driver doesn't do any I2C communications
as its done by ISP firmware. It can be updated if needed to a
regular sensor driver by adding the I2C communication.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 .../devicetree/bindings/media/i2c/s5k4e5.txt   |   44 +++
 drivers/media/i2c/Kconfig  |8 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k4e5.c |  361 
 4 files changed, 414 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
 create mode 100644 drivers/media/i2c/s5k4e5.c

diff --git a/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt 
b/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
new file mode 100644
index 000..88dd726
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/s5k4e5.txt
@@ -0,0 +1,44 @@
+* Samsung S5K4E5 Raw Image Sensor
+
+S5K4E5 is a raw image sensor with maximum resolution of 2560x1920
+pixels. Data transfer is carried out via MIPI-CSI2 port and controls
+via I2C bus.
+
+Required Properties:
+- compatible   : must be samsung,s5k4e5
+- reg  : I2C device address
+- gpios: reset gpio pin
+- clocks   : clock specifier for the clock-names property.
+- clock-names  : must contain mclk entry and matching clock property
+  entry.
+- svdda-supply : core voltage supply
+- svddio-supply: I/O voltage supply
+
+Optional Properties:
+- clock-frequency : operating frequency for the sensor
+default value will be taken if not provided.
+
+The device node should be added to their control bus controller (e.g.
+I2C0) nodes and linked to the csis port node, using the common video
+interfaces bindings, defined in video-interfaces.txt.
+
+Example:
+
+   i2c-isp@1313 {
+   s5k4e5@20 {
+   compatible = samsung,s5k4e5;
+   reg = 0x20;
+   gpios = gpx1 2 1;
+   clock-frequency = 2400;
+   clocks = clock 129;
+   clock-names = mclk;
+   svdda-supply = ...;
+   svddio-supply = ...;
+   port {
+   is_s5k4e5_ep: endpoint {
+   data-lanes = 1 2 3 4;
+   remote-endpoint = csis0_ep;
+   };
+   };
+   };
+   };
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index f7e9147..271028b 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -572,6 +572,14 @@ config VIDEO_S5K6A3
  This is a V4L2 sensor-level driver for Samsung S5K6A3 raw
  camera sensor.
 
+config VIDEO_S5K4E5
+   tristate Samsung S5K4E5 sensor support
+   depends on MEDIA_CAMERA_SUPPORT
+   depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  OF
+   ---help---
+ This is a V4L2 sensor-level driver for Samsung S5K4E5 raw
+ camera sensor.
+
 config VIDEO_S5K4ECGX
 tristate Samsung S5K4ECGX sensor support
 depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index cf3cf03..0aeed8e 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
+obj-$(CONFIG_VIDEO_S5K4E5) += s5k4e5.o
 obj-$(CONFIG_VIDEO_S5K4ECGX)   += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_S5C73M3)+= s5c73m3/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
diff --git a/drivers/media/i2c/s5k4e5.c b/drivers/media/i2c/s5k4e5.c
new file mode 100644
index 000..0a6ece6
--- /dev/null
+++ b/drivers/media/i2c/s5k4e5.c
@@ -0,0 +1,361 @@
+/*
+ * Samsung S5K4E5 image sensor driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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 linux/clk.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/gpio.h
+#include linux/i2c.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of_gpio.h
+#include linux/pm_runtime.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+#include linux/videodev2.h
+#include media/v4l2-async.h
+#include media/v4l2-subdev.h
+
+#define S5K4E5_SENSOR_MAX_WIDTH2576
+#define S5K4E5_SENSOR_MAX_HEIGHT   1930

[PATCH] [media] exynos-gsc: fix s2r functionality

2013-08-07 Thread Arun Kumar K
From: Prathyush K prathyus...@samsung.com

When gsc is in runtime suspended state, there is no need to call
m2m_suspend during suspend and similarily, there is no need to call
m2m_resume during resume if already in runtime suspended state. This
patch adds the necessary conditions to achieve this.

Signed-off-by: Prathyush K prathyus...@samsung.com
Signed-off-by: Arun Mankuzhi aru...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-core.c |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index 559fab2..fe69eae 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -1210,12 +1210,12 @@ static int gsc_resume(struct device *dev)
spin_unlock_irqrestore(gsc-slock, flags);
return 0;
}
-   gsc_hw_set_sw_reset(gsc);
-   gsc_wait_reset(gsc);
-
spin_unlock_irqrestore(gsc-slock, flags);
 
-   return gsc_m2m_resume(gsc);
+   if (!pm_runtime_suspended(dev))
+   return gsc_runtime_resume(dev);
+
+   return 0;
 }
 
 static int gsc_suspend(struct device *dev)
@@ -1227,7 +1227,10 @@ static int gsc_suspend(struct device *dev)
if (test_and_set_bit(ST_SUSPEND, gsc-state))
return 0;
 
-   return gsc_m2m_suspend(gsc);
+   if (!pm_runtime_suspended(dev))
+   return gsc_runtime_suspend(dev);
+
+   return 0;
 }
 
 static const struct dev_pm_ops gsc_pm_ops = {
-- 
1.7.9.5

--
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] exynos-gsc: fix s2r functionality

2013-08-07 Thread Arun Kumar K
Hi Sylwester,


On Wed, Aug 7, 2013 at 10:23 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 On 08/07/2013 02:53 PM, Arun Kumar K wrote:
 From: Prathyush K prathyus...@samsung.com

 When gsc is in runtime suspended state, there is no need to call
 m2m_suspend during suspend and similarily, there is no need to call

 s/similarily/similarly. I'll fix that typo when applying.


Thanks.

 m2m_resume during resume if already in runtime suspended state. This
 patch adds the necessary conditions to achieve this.

 Signed-off-by: Prathyush K prathyus...@samsung.com
 Signed-off-by: Arun Mankuzhi aru...@samsung.com
 Signed-off-by: Arun Kumar K arun...@samsung.com

 Thanks, that looks good. I'll queue it for 3.12. We actually have
 similar patch for the exynos4-is fimc-is-i2c driver.

 However this is sort of things that IMO should ideally be handled
 in the PM core.


Yes indeed.

Regards
Arun
--
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: [RFC v3 09/13] [media] exynos5-fimc-is: Add the hardware pipeline control

2013-08-06 Thread Arun Kumar K
Hi Sylwester,

On Sun, Aug 4, 2013 at 8:30 PM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Arun,

 On 08/02/2013 05:02 PM, Arun Kumar K wrote:

 This patch adds the crucial hardware pipeline control for the
 fimc-is driver. All the subdev nodes will call this pipeline
 interfaces to reach the hardware. Responsibilities of this module
 involves configuring and maintaining the hardware pipeline involving
 multiple sub-ips like ISP, DRC, Scalers, ODC, 3DNR, FD etc.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---

[snip]


 +static int fimc_is_pipeline_isp_setparams(struct fimc_is_pipeline
 *pipeline,
 +   unsigned int enable)
 +{
 +   struct isp_param *isp_param =pipeline-is_region-parameter.isp;
 +   struct fimc_is *is = pipeline-is;
 +   unsigned int indexes, lindex, hindex;
 +   unsigned int sensor_width, sensor_height, scc_width, scc_height;
 +   unsigned int crop_x, crop_y, isp_width, isp_height;
 +   unsigned int sensor_ratio, output_ratio;
 +   int ret;
 +
 +   /* Crop calculation */
 +   sensor_width = pipeline-sensor_width;
 +   sensor_height = pipeline-sensor_height;
 +   scc_width = pipeline-scaler_width[SCALER_SCC];
 +   scc_height = pipeline-scaler_height[SCALER_SCC];
 +   isp_width = sensor_width;
 +   isp_height = sensor_height;
 +   crop_x = crop_y = 0;
 +
 +   sensor_ratio = sensor_width * 1000 / sensor_height;
 +   output_ratio = scc_width * 1000 / scc_height;
 +
 +   if (sensor_ratio == output_ratio) {
 +   isp_width = sensor_width;
 +   isp_height = sensor_height;
 +   } else if (sensor_ratio  output_ratio) {
 +   isp_height = (sensor_width * scc_height) / scc_width;
 +   isp_height = ALIGN(isp_height, 2);
 +   crop_y = ((sensor_height - isp_height)  1)  0xFFFE;


 nit: Use ~1U instead of 0xFFFE.


 +   } else {
 +   isp_width = (sensor_height * scc_width) / scc_height;
 +   isp_width = ALIGN(isp_width, 4);
 +   crop_x =  ((sensor_width - isp_width)  1)  0xFFFE;


 Ditto.

 +   }
 +   pipeline-isp_width = isp_width;
 +   pipeline-isp_height = isp_height;
 +
 +   indexes = hindex = lindex = 0;
 +
 +   isp_param-otf_output.cmd = OTF_OUTPUT_COMMAND_ENABLE;
 +   isp_param-otf_output.width = pipeline-sensor_width;
 +   isp_param-otf_output.height = pipeline-sensor_height;
 +   isp_param-otf_output.format = OTF_OUTPUT_FORMAT_YUV444;
 +   isp_param-otf_output.bitwidth = OTF_OUTPUT_BIT_WIDTH_12BIT;
 +   isp_param-otf_output.order = OTF_INPUT_ORDER_BAYER_GR_BG;
 +   lindex |= LOWBIT_OF(PARAM_ISP_OTF_OUTPUT);
 +   hindex |= HIGHBIT_OF(PARAM_ISP_OTF_OUTPUT);
 +   indexes++;


 All right, let's stop this hindex/lindex/indexes madness. I've already
 commented on that IIRC. Nevertheless, this should be replaced with proper
 bitmap operations. A similar issue has been fixed in commit


 +   isp_param-dma1_output.cmd = DMA_OUTPUT_COMMAND_DISABLE;
 +   lindex |= LOWBIT_OF(PARAM_ISP_DMA1_OUTPUT);
 +   hindex |= HIGHBIT_OF(PARAM_ISP_DMA1_OUTPUT);
 +   indexes++;
 +
 +   isp_param-dma2_output.cmd = DMA_OUTPUT_COMMAND_DISABLE;
 +   lindex |= LOWBIT_OF(PARAM_ISP_DMA2_OUTPUT);
 +   hindex |= HIGHBIT_OF(PARAM_ISP_DMA2_OUTPUT);
 +   indexes++;
 +
 +   if (enable)
 +   isp_param-control.bypass = CONTROL_BYPASS_DISABLE;
 +   else
 +   isp_param-control.bypass = CONTROL_BYPASS_ENABLE;
 +   isp_param-control.cmd = CONTROL_COMMAND_START;
 +   isp_param-control.run_mode = 1;
 +   lindex |= LOWBIT_OF(PARAM_ISP_CONTROL);
 +   hindex |= HIGHBIT_OF(PARAM_ISP_CONTROL);
 +   indexes++;
 +
 +   isp_param-dma1_input.cmd = DMA_INPUT_COMMAND_BUF_MNGR;
 +   isp_param-dma1_input.width = sensor_width;
 +   isp_param-dma1_input.height = sensor_height;
 +   isp_param-dma1_input.dma_crop_offset_x = crop_x;
 +   isp_param-dma1_input.dma_crop_offset_y = crop_y;
 +   isp_param-dma1_input.dma_crop_width = isp_width;
 +   isp_param-dma1_input.dma_crop_height = isp_height;
 +   isp_param-dma1_input.bayer_crop_offset_x = 0;
 +   isp_param-dma1_input.bayer_crop_offset_y = 0;
 +   isp_param-dma1_input.bayer_crop_width = 0;
 +   isp_param-dma1_input.bayer_crop_height = 0;
 +   isp_param-dma1_input.user_min_frametime = 0;
 +   isp_param-dma1_input.user_max_frametime = 6;
 +   isp_param-dma1_input.wide_frame_gap = 1;
 +   isp_param-dma1_input.frame_gap = 4096;
 +   isp_param-dma1_input.line_gap = 45;
 +   isp_param-dma1_input.order = DMA_INPUT_ORDER_GR_BG;
 +   isp_param-dma1_input.plane = 1;
 +   isp_param-dma1_input.buffer_number = 1;
 +   isp_param-dma1_input.buffer_address = 0;
 +   isp_param-dma1_input.reserved[1] = 0;
 +   isp_param-dma1_input.reserved

Re: [RFC v3 10/13] [media] exynos5-fimc-is: Add the hardware interface module

2013-08-06 Thread Arun Kumar K
Hi Sylwester,

On Sun, Aug 4, 2013 at 8:33 PM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Arun,


 On 08/02/2013 05:02 PM, Arun Kumar K wrote:

 The hardware interface module finally sends the commands to the
 FIMC-IS firmware and runs the interrupt handler for getting the
 responses.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---

[snip]

 +static int itf_get_state(struct fimc_is_interface *itf,
 +   unsigned long state)
 +{
 +   int ret = 0;
 +   unsigned long flags;
 +
 +   spin_lock_irqsave(itf-slock_state, flags);
 +   ret = test_bit(state,itf-state);


 Shouldn't it be __test_bit() ?


__test_bit() is not availble !
In file include/asm-generic/bitops/non-atomic.h, all other ops
are prefixed with __xxx(), but its just test_bit().

Regards
Arun
--
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: [RFC v3 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-05 Thread Arun Kumar K
Hi Sylwester,

Thank you for the review.
Will address all your review comments.
Some responses below:

[snip]
 +
 +static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
 +{
 +   struct device_node *of_node = fmd-pdev-dev.of_node;
 +   int ret;
 +
 +   /*
 +* Runtime resume one of the FIMC entities to make sure
 +* the sclk_cam clocks are not globally disabled.


 It's a bit mysterious to me, is this requirement still valid on Exynos5 ?
 I glanced over the Exynos5250 datasheet and there seem to be no sclk_cam?
 clocks dependency on any of GScaler clocks. Maybe you don't need a clock
 provider in this driver, perhaps sensor drivers could use sclk_cam clocks
 directly, assigned through dts ?


Yes these clocks can be directly exposed via dt.
I will drop clock provider from this driver.

[snip]

 +/*
 + * The peripheral sensor clock management.
 + */
 +static void fimc_md_put_clocks(struct fimc_md *fmd)
 +{
 +   int i = FIMC_MAX_CAMCLKS;
 +
 +   while (--i= 0) {
 +   if (IS_ERR(fmd-camclk[i].clock))
 +   continue;
 +   clk_put(fmd-camclk[i].clock);
 +   fmd-camclk[i].clock = ERR_PTR(-EINVAL);
 +   }


 Please double check if you need this sclk_cam clocks handling. We could
 simply add a requirement that this driver supports only sensor subdevs
 through the v4l2-async API and which controls their clock themselves.


sclk_cam* handling can be removed and be done from respective
sensors. But I think the sclk_bayer handling needs to be retained in the
media driver.

 +}
 +
 +static int fimc_md_get_clocks(struct fimc_md *fmd)
 +{
 +   struct device *dev = NULL;
 +   char clk_name[32];
 +   struct clk *clock;
 +   int i, ret = 0;
 +
 +   for (i = 0; i  FIMC_MAX_CAMCLKS; i++)
 +   fmd-camclk[i].clock = ERR_PTR(-EINVAL);
 +
 +   if (fmd-pdev-dev.of_node)
 +   dev =fmd-pdev-dev;
 +
 +   for (i = 0; i  SCLK_BAYER; i++) {
 +   snprintf(clk_name, sizeof(clk_name), sclk_cam%u, i);
 +   clock = clk_get(dev, clk_name);
 +
 +   if (IS_ERR(clock)) {
 +   dev_err(fmd-pdev-dev, Failed to get clock:
 %s\n,
 +   clk_name);
 +   ret = PTR_ERR(clock);
 +   break;
 +   }
 +   fmd-camclk[i].clock = clock;
 +   }
 +   if (ret)
 +   fimc_md_put_clocks(fmd);
 +
 +   /* Prepare bayer clk */
 +   clock = clk_get(dev, sclk_bayer);
 +
 +   if (IS_ERR(clock)) {
 +   dev_err(fmd-pdev-dev, Failed to get clock: %s\n,
 +   clk_name);


 Wrong error message.

 +   ret = PTR_ERR(clock);
 +   goto err_exit;
 +   }
 +   ret = clk_prepare(clock);
 +   if (ret  0) {
 +   clk_put(clock);
 +   fmd-camclk[SCLK_BAYER].clock = ERR_PTR(-EINVAL);
 +   goto err_exit;
 +   }
 +   fmd-camclk[SCLK_BAYER].clock = clock;


 Could you explain a bit how is this SCLK_BAYER clock used ? Is it routed
 to external image sensor, or is it used only inside an SoC ?


It is not defined properly in the manual, but I suppose its the bus clock
for the bayer rgb data bus. So for proper sensor functionality, we need this
sclk_bayer in addition to the external sensor clks (sclk_cam*). Isn't
exynos5 media driver is the best place to handle such clocks?

 +   return 0;
 +err_exit:
 +   fimc_md_put_clocks(fmd);
 +   return ret;
 +}
 +

Regards
Arun
--
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: [RFC v3 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-05 Thread Arun Kumar K
Hi Sachin,

Thank you for the review.

On Mon, Aug 5, 2013 at 10:51 AM, Sachin Kamat sachin.ka...@linaro.org wrote:
 On 2 August 2013 20:32, Arun Kumar K arun...@samsung.com wrote:
 From: Shaik Ameer Basha shaik.am...@samsung.com

 This patch adds support for media device for EXYNOS5 SoCs.
 The current media device supports the following ips to connect
 through the media controller framework.

 * MIPI-CSIS
   Support interconnection(subdev interface) between devices

 * FIMC-LITE
   Support capture interface from device(Sensor, MIPI-CSIS) to memory
   Support interconnection(subdev interface) between devices

 * FIMC-IS
   Camera post-processing IP having multiple sub-nodes.

 G-Scaler will be added later to the current media device.

 The media device creates two kinds of pipelines for connecting
 the above mentioned IPs.
 The pipeline0 is uses Sensor, MIPI-CSIS and FIMC-LITE which captures
 image data and dumps to memory.
 Pipeline1 uses FIMC-IS components for doing post-processing
 operations on the captured image and give scaled YUV output.

 Pipeline0
   ++ +---+ +---+ ++
   | Sensor | -- | MIPI-CSIS | -- | FIMC-LITE | -- | Memory |
   ++ +---+ +---+ ++

 Pipeline1
  ++  ++ +---+ +---+
  | Memory | --  |  ISP   | -- |SCC| -- |SCP|
  ++  ++ +---+ +---+

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 Signed-off-by: Arun Kumar K arun...@samsung.com

 [snip]

 +
 +Common 'camera' node
 +
 +
 +Required properties:
 +
 +- compatible   : must be samsung,exynos5-fimc, simple-bus

 I am not sure if this point was discusssed during the previous
 versions. samsung,exynos5-fimc seems a bit generic.
 The compatible string should generally point to a specific SoC (the
 first one to have this IP), something like samsung,exynos5250-fimc.


Yes will make it samsung,exynos5250-fimc

 +- clocks   : list of clock specifiers, corresponding to entries in
 + the clock-names property;
 +- clock-names  : must contain sclk_cam0, sclk_cam1 entries,
 + matching entries in the clocks property.
 +

 [snip]

 +Example:
 +
 +   aliases {
 +   fimc-lite0 = fimc_lite_0
 +   };
 +
 +   /* Parallel bus IF sensor */
 +   i2c_0: i2c@1386 {
 +   s5k6aa: sensor@3c {
 +   compatible = samsung,s5k6aafx;
 +   reg = 0x3c;
 +   vddio-supply = ...;
 +
 +   clock-frequency = 2400;
 +   clocks = ...;
 +   clock-names = mclk;
 +
 +   port {
 +   s5k6aa_ep: endpoint {
 +   remote-endpoint = fimc0_ep;
 +   bus-width = 8;
 +   hsync-active = 0;
 +   vsync-active = 1;
 +   pclk-sample = 1;
 +   };
 +   };
 +   };
 +   };
 +
 +   /* MIPI CSI-2 bus IF sensor */
 +   s5c73m3: sensor@0x1a {

 0x not needed.


Ok.

Regards
Arun
--
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: [RFC v3 03/13] [media] exynos5-fimc-is: Add driver core files

2013-08-05 Thread Arun Kumar K
Hi Sylwester,

On Sun, Aug 4, 2013 at 3:12 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 08/02/2013 05:02 PM, Arun Kumar K wrote:

 This driver is for the FIMC-IS IP available in Samsung Exynos5
 SoC onwards. This patch adds the core files for the new driver.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---
   drivers/media/platform/exynos5-is/fimc-is-core.c |  394
 ++
   drivers/media/platform/exynos5-is/fimc-is-core.h |  122 +++
   2 files changed, 516 insertions(+)
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h

 diff --git a/drivers/media/platform/exynos5-is/fimc-is-core.c
 b/drivers/media/platform/exynos5-is/fimc-is-core.c
 new file mode 100644
 index 000..7b7762b
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/fimc-is-core.c
 @@ -0,0 +1,394 @@
 +/*
 + * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
 +*
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + * Arun Kumar Karun...@samsung.com
 + *
 + * 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.
 + */
 +
 +#includelinux/bug.h
 +#includelinux/ctype.h
 +#includelinux/device.h
 +#includelinux/debugfs.h
 +#includelinux/delay.h
 +#includelinux/errno.h
 +#includelinux/err.h
 +#includelinux/firmware.h
 +#includelinux/fs.h
 +#includelinux/gpio.h
 +#includelinux/interrupt.h
 +#includelinux/kernel.h
 +#includelinux/list.h
 +#includelinux/module.h
 +#includelinux/types.h
 +#includelinux/platform_device.h
 +#includelinux/pm_runtime.h
 +#includelinux/slab.h
 +#includelinux/videodev2.h
 +#includelinux/of.h
 +#includelinux/of_gpio.h
 +#includelinux/of_address.h
 +#includelinux/of_platform.h
 +#includelinux/of_irq.h
 +#includelinux/pinctrl/consumer.h
 +
 +#includemedia/v4l2-device.h
 +#includemedia/v4l2-ioctl.h
 +#includemedia/v4l2-mem2mem.h
 +#includemedia/v4l2-of.h
 +#includemedia/videobuf2-core.h
 +#includemedia/videobuf2-dma-contig.h
 +
 +#include fimc-is.h
 +#include fimc-is-i2c.h
 +
 +#define CLK_MCU_ISP_DIV0_FREQ  (200 * 100)
 +#define CLK_MCU_ISP_DIV1_FREQ  (100 * 100)
 +#define CLK_ISP_DIV0_FREQ  (134 * 100)
 +#define CLK_ISP_DIV1_FREQ  (68 * 100)
 +#define CLK_ISP_DIVMPWM_FREQ   (34 * 100)
 +
 +static char *fimc_is_clock_name[] = {
 +   [IS_CLK_ISP]= isp,
 +   [IS_CLK_MCU_ISP]= mcu_isp,
 +   [IS_CLK_ISP_DIV0]   = isp_div0,
 +   [IS_CLK_ISP_DIV1]   = isp_div1,
 +   [IS_CLK_ISP_DIVMPWM]= isp_divmpwm,
 +   [IS_CLK_MCU_ISP_DIV0]   = mcu_isp_div0,
 +   [IS_CLK_MCU_ISP_DIV1]   = mcu_isp_div1,
 +};
 +
 +static void fimc_is_put_clocks(struct fimc_is *is)
 +{
 +   int i;
 +
 +   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
 +   if (IS_ERR(is-clock[i]))
 +   continue;
 +   clk_unprepare(is-clock[i]);
 +   clk_put(is-clock[i]);
 +   is-clock[i] = NULL;
 +   }
 +}
 +
 +static int fimc_is_get_clocks(struct fimc_is *is)
 +{
 +   struct device *dev =is-pdev-dev;

 +   int i, ret;
 +
 +   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
 +   is-clock[i] = clk_get(dev, fimc_is_clock_name[i]);
 +   if (IS_ERR(is-clock[i]))
 +   goto err;
 +   ret = clk_prepare(is-clock[i]);
 +   if (ret  0) {
 +   clk_put(is-clock[i]);
 +   is-clock[i] = ERR_PTR(-EINVAL);
 +   goto err;
 +   }
 +   }
 +   return 0;
 +err:
 +   fimc_is_put_clocks(is);
 +   pr_err(Failed to get clock: %s\n, fimc_is_clock_name[i]);
 +   return -ENXIO;
 +}
 +
 +static int fimc_is_configure_clocks(struct fimc_is *is)
 +{
 +   int i, ret;
 +
 +   for (i = 0; i  IS_CLK_MAX_NUM; i++)
 +   is-clock[i] = ERR_PTR(-EINVAL);
 +
 +   ret = fimc_is_get_clocks(is);
 +   if (ret)
 +   return ret;
 +
 +   /* Set rates */
 +   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV0],
 +   CLK_MCU_ISP_DIV0_FREQ);
 +   if (ret)
 +   return ret;
 +   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV1],
 +   CLK_MCU_ISP_DIV1_FREQ);
 +   if (ret)
 +   return ret;
 +   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV0], CLK_ISP_DIV0_FREQ);
 +   if (ret)
 +   return ret;
 +   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV1], CLK_ISP_DIV1_FREQ);
 +   if (ret)
 +   return ret;
 +   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIVMPWM],
 +   CLK_ISP_DIVMPWM_FREQ);
 +   return ret;
 +}
 +
 +static void fimc_is_pipelines_destroy(struct fimc_is *is)
 +{
 +   int i;
 +
 +   for (i = 0; i  is-num_instance; i

Re: [RFC v3 04/13] [media] exynos5-fimc-is: Add common driver header files

2013-08-05 Thread Arun Kumar K
Hi Sylwester,

On Sun, Aug 4, 2013 at 3:13 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 08/02/2013 05:02 PM, Arun Kumar K wrote:

 This patch adds all the common header files used by the fimc-is
 driver. It includes the commands for interfacing with the firmware
 and error codes from IS firmware, metadata and command parameter
 definitions.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---
   drivers/media/platform/exynos5-is/fimc-is-cmd.h|  187 +++
   drivers/media/platform/exynos5-is/fimc-is-err.h|  257 +
   .../media/platform/exynos5-is/fimc-is-metadata.h   |  767 +
   drivers/media/platform/exynos5-is/fimc-is-param.h  | 1212
 
   4 files changed, 2423 insertions(+)
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-cmd.h
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-err.h
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-metadata.h
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-param.h


[snip]

 +
 +struct camera2_tonemap_dm {
 +   enum tonemap_mode   mode;
 +   /* assuming maxCurvePoints = 64 */
 +   float   curve_red[64];
 +   float   curve_green[64];
 +   float   curve_blue[64];


 So all those floating point numbers are now not really used in
 the driver but we need them for proper data structures/offsets
 declarations of the firmware interface ?


Yes. Same floats are used in firmware internal data structures
also and the driver should assign these values when these parameters
are to be changed.

 +};
 +

[snip]

 +/* --  Effect
 --- */
 +enum isp_imageeffect_command {
 +   ISP_IMAGE_EFFECT_DISABLE= 0,
 +   ISP_IMAGE_EFFECT_MONOCHROME = 1,
 +   ISP_IMAGE_EFFECT_NEGATIVE_MONO  = 2,
 +   ISP_IMAGE_EFFECT_NEGATIVE_COLOR = 3,
 +   ISP_IMAGE_EFFECT_SEPIA  = 4,
 +   ISP_IMAGE_EFFECT_AQUA   = 5,
 +   ISP_IMAGE_EFFECT_EMBOSS = 6,
 +   ISP_IMAGE_EFFECT_EMBOSS_MONO= 7,
 +   ISP_IMAGE_EFFECT_SKETCH = 8,
 +   ISP_IMAGE_EFFECT_RED_YELLOW_POINT   = 9,
 +   ISP_IMAGE_EFFECT_GREEN_POINT= 10,
 +   ISP_IMAGE_EFFECT_BLUE_POINT = 11,
 +   ISP_IMAGE_EFFECT_MAGENTA_POINT  = 12,
 +   ISP_IMAGE_EFFECT_WARM_VINTAGE   = 13,
 +   ISP_IMAGE_EFFECT_COLD_VINTAGE   = 14,
 +   ISP_IMAGE_EFFECT_POSTERIZE  = 15,
 +   ISP_IMAGE_EFFECT_SOLARIZE   = 16,
 +   ISP_IMAGE_EFFECT_WASHED = 17,
 +   ISP_IMAGE_EFFECT_CCM= 18,
 +};


 Hmm, I guess we will need a private v4l2 control for those.


Yes. I am planning to add the controls after the basic support
gets merged.

Regards
Arun
--
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: [RFC v3 00/13] Exynos5 IS driver

2013-08-04 Thread Arun Kumar K
Hi Sylwester,

On Sun, Aug 4, 2013 at 3:10 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Arun,


 On 08/02/2013 05:02 PM, Arun Kumar K wrote:

 The patch series add support for Exynos5 camera subsystem. It
 re-uses mipi-csis and fimc-lite from exynos4-is and adds a new
 media device and fimc-is device drivers for exynos5.
 The media device supports asynchronos subdev registration for the
 fimc-is sensors and is based on the patch series from Sylwester
 for exynos4-is [1].

 [1]http://www.mail-archive.com/linux-media@vger.kernel.org/msg64653.html

 Changes from v2
 ---
 - Added exynos5 media device driver from Shaik to this series
 - Added ISP pipeline support in media device driver
 - Based on Sylwester's latest exynos4-is development
 - Asynchronos registration of sensor subdevs
 - Made independent IS-sensor support
 - Add s5k4e5 sensor driver
 - Addressed review comments from Sylwester, Hans, Andrzej, Sachin


 This is starting to look pretty good to me, I hope we can merge this
 patch set for v3.12. Let use coming two weeks for one or two review/
 corrections round.

Sure. I will address the review comments quickly and send v4 version.

 In the meantime I've done numerous fixes to the patch series [1],
 especially the clock provider code was pretty buggy on the clean up
 paths. Let's go through the patches and see what can be improved yet.


Ok. Is the updated version available in your git repository
git://linuxtv.org/snawrocki/samsung.git?

Regards
Arun
--
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


[RFC v3 00/13] Exynos5 IS driver

2013-08-02 Thread Arun Kumar K
The patch series add support for Exynos5 camera subsystem. It
re-uses mipi-csis and fimc-lite from exynos4-is and adds a new
media device and fimc-is device drivers for exynos5.
The media device supports asynchronos subdev registration for the
fimc-is sensors and is based on the patch series from Sylwester
for exynos4-is [1].

[1] http://www.mail-archive.com/linux-media@vger.kernel.org/msg64653.html

Changes from v2
---
- Added exynos5 media device driver from Shaik to this series
- Added ISP pipeline support in media device driver
- Based on Sylwester's latest exynos4-is development
- Asynchronos registration of sensor subdevs
- Made independent IS-sensor support
- Add s5k4e5 sensor driver
- Addressed review comments from Sylwester, Hans, Andrzej, Sachin

Changes from v1
---
- Addressed all review comments from Sylwester
- Made sensor subdevs as independent i2c devices
- Lots of cleanup
- Debugfs support added
- Removed PMU global register access

Arun Kumar K (12):
  [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings
documentation
  [media] exynos5-fimc-is: Add driver core files
  [media] exynos5-fimc-is: Add common driver header files
  [media] exynos5-fimc-is: Add register definition and context header
  [media] exynos5-fimc-is: Add isp subdev
  [media] exynos5-fimc-is: Add scaler subdev
  [media] exynos5-fimc-is: Add sensor interface
  [media] exynos5-fimc-is: Add the hardware pipeline control
  [media] exynos5-fimc-is: Add the hardware interface module
  [media] exynos5-is: Add Kconfig and Makefile
  V4L: s5k6a3: Change sensor min/max resolutions
  V4L: Add driver for s5k4e5 image sensor

Shaik Ameer Basha (1):
  [media] exynos5-is: Adding media device driver for exynos5

 .../devicetree/bindings/media/exynos5-fimc-is.txt  |   52 +
 .../devicetree/bindings/media/exynos5-mdev.txt |  153 ++
 drivers/media/i2c/Kconfig  |8 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k4e5.c |  362 
 drivers/media/i2c/s5k6a3.c |   14 +-
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |   19 +
 drivers/media/platform/exynos5-is/Makefile |7 +
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1471 +++
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  199 ++
 drivers/media/platform/exynos5-is/fimc-is-cmd.h|  187 ++
 drivers/media/platform/exynos5-is/fimc-is-core.c   |  394 
 drivers/media/platform/exynos5-is/fimc-is-core.h   |  122 ++
 drivers/media/platform/exynos5-is/fimc-is-err.h|  257 +++
 .../media/platform/exynos5-is/fimc-is-interface.c  |  861 +
 .../media/platform/exynos5-is/fimc-is-interface.h  |  128 ++
 drivers/media/platform/exynos5-is/fimc-is-isp.c|  509 +
 drivers/media/platform/exynos5-is/fimc-is-isp.h|   93 +
 .../media/platform/exynos5-is/fimc-is-metadata.h   |  767 
 drivers/media/platform/exynos5-is/fimc-is-param.h  | 1212 
 .../media/platform/exynos5-is/fimc-is-pipeline.c   | 1961 
 .../media/platform/exynos5-is/fimc-is-pipeline.h   |  129 ++
 drivers/media/platform/exynos5-is/fimc-is-regs.h   |  105 ++
 drivers/media/platform/exynos5-is/fimc-is-scaler.c |  458 +
 drivers/media/platform/exynos5-is/fimc-is-scaler.h |  112 ++
 drivers/media/platform/exynos5-is/fimc-is-sensor.c |   46 +
 drivers/media/platform/exynos5-is/fimc-is-sensor.h |   69 +
 drivers/media/platform/exynos5-is/fimc-is.h|  153 ++
 30 files changed, 9847 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 create mode 100644 drivers/media/i2c/s5k4e5.c
 create mode 100644 drivers/media/platform/exynos5-is/Kconfig
 create mode 100644 drivers/media/platform/exynos5-is/Makefile
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-cmd.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-err.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-metadata.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-param.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-pipeline.c
 create mode 100644 drivers/media

[RFC v3 02/13] [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings documentation

2013-08-02 Thread Arun Kumar K
The patch adds the DT binding documentation for Samsung
Exynos5 SoC series imaging subsystem (FIMC-IS).

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 .../devicetree/bindings/media/exynos5-fimc-is.txt  |   52 
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt 
b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
new file mode 100644
index 000..49a373a
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
@@ -0,0 +1,52 @@
+Samsung EXYNOS5 SoC series Imaging Subsystem (FIMC-IS)
+--
+
+The camera subsystem on Samsung Exynos5 SoC has some changes relative
+to previous SoC versions. Exynos5 has almost similar MIPI-CSIS and
+FIMC-LITE IPs but has a much improved version of FIMC-IS which can
+handle sensor controls and camera post-processing operations. The
+Exynos5 FIMC-IS has a dedicated ARM Cortex A5 processor, many
+post-processing blocks (ISP, DRC, FD, ODC, DIS, 3DNR) and two
+dedicated scalers (SCC and SCP).
+
+fimc-is node
+
+
+Required properties:
+
+- compatible: must be samsung,exynos5250-fimc-is
+- reg   : physical base address and size of the memory mapped
+  registers
+- interrupt-parent  : Parent interrupt controller
+- interrupts: fimc-is interrupt to the parent combiner
+- clocks: list of clock specifiers, corresponding to entries in
+  clock-names property;
+- clock-names   : must contain isp, mcu_isp, isp_div0, isp_div1,
+  isp_divmpwm, mcu_isp_div0, mcu_isp_div1 entries,
+  matching entries in the clocks property.
+
+pmu subnode
+---
+
+Required properties:
+ - reg : should contain PMU physical base address and size of the memory
+ mapped registers.
+
+i2c-isp (ISP I2C bus controller) nodes
+--
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-i2c-isp for Exynos4212,
+ Exynos4412 and Exynos5250 SoCs;
+- reg  : physical base address and length of the registers set;
+- clocks   : must contain gate clock specifier for this controller;
+- clock-names  : must contain i2c_isp entry.
+
+For the above nodes it is required to specify a pinctrl state named default,
+according to the pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt.
+
+Device tree nodes of the image sensors' controlled directly by the FIMC-IS
+firmware must be child nodes of their corresponding ISP I2C bus controller 
node.
+The data link of these image sensors must be specified using the common video
+interfaces bindings, defined in video-interfaces.txt.
-- 
1.7.9.5

--
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


[RFC v3 06/13] [media] exynos5-fimc-is: Add isp subdev

2013-08-02 Thread Arun Kumar K
fimc-is driver takes video data input from the ISP video node
which is added in this patch. This node accepts Bayer input
buffers which is given from the IS sensors.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-isp.c |  509 +++
 drivers/media/platform/exynos5-is/fimc-is-isp.h |   93 +
 2 files changed, 602 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-isp.c 
b/drivers/media/platform/exynos5-is/fimc-is-isp.c
new file mode 100644
index 000..e97e473
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-isp.c
@@ -0,0 +1,509 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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 media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+
+#define ISP_DRV_NAME fimc-is-isp
+
+static const struct fimc_is_fmt formats[] = {
+   {
+   .name   = Bayer GR-BG 8bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG8,
+   .depth  = { 8 },
+   .num_planes = 1,
+   },
+   {
+   .name   = Bayer GR-BG 10bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG10,
+   .depth  = { 16 },
+   .num_planes = 1,
+   },
+   {
+   .name   = Bayer GR-BG 12bits,
+   .fourcc = V4L2_PIX_FMT_SGRBG12,
+   .depth  = { 16 },
+   .num_planes = 1,
+   },
+};
+#define NUM_FORMATS ARRAY_SIZE(formats)
+
+static const struct fimc_is_fmt *find_format(struct v4l2_format *f)
+{
+   unsigned int i;
+
+   for (i = 0; i  NUM_FORMATS; i++) {
+   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
+   return formats[i];
+   }
+   return NULL;
+}
+
+static int isp_video_output_start_streaming(struct vb2_queue *vq,
+   unsigned int count)
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+
+   set_bit(STATE_RUNNING, isp-output_state);
+   return 0;
+}
+
+static int isp_video_output_stop_streaming(struct vb2_queue *vq)
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+
+   clear_bit(STATE_RUNNING, isp-output_state);
+   return 0;
+}
+
+static int isp_video_output_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   const struct fimc_is_fmt *fmt = isp-fmt;
+   unsigned int wh, i;
+
+   if (!fmt)
+   return -EINVAL;
+
+   *num_planes = fmt-num_planes;
+   wh = isp-width * isp-height;
+
+   for (i = 0; i  *num_planes; i++) {
+   allocators[i] = isp-alloc_ctx;
+   sizes[i] = (wh * fmt-depth[i]) / 8;
+   }
+   return 0;
+}
+
+static int isp_video_output_buffer_init(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+
+   buf = isp-output_bufs[vb-v4l2_buf.index];
+   /* Initialize buffer */
+   buf-vb = vb;
+   buf-paddr[0] = vb2_dma_contig_plane_dma_addr(vb, 0);
+   isp-out_buf_cnt++;
+   return 0;
+}
+
+static void isp_video_output_buffer_queue(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+
+   buf = isp-output_bufs[vb-v4l2_buf.index];
+
+   fimc_is_pipeline_buf_lock(isp-pipeline);
+   fimc_is_isp_wait_queue_add(isp, buf);
+   fimc_is_pipeline_buf_unlock(isp-pipeline);
+
+   /* Call shot command */
+   fimc_is_pipeline_shot(isp-pipeline);
+}
+
+static const struct vb2_ops isp_video_output_qops = {
+   .queue_setup = isp_video_output_queue_setup,
+   .buf_init= isp_video_output_buffer_init,
+   .buf_queue   = isp_video_output_buffer_queue,
+   .wait_prepare= vb2_ops_wait_prepare,
+   .wait_finish = vb2_ops_wait_finish,
+   .start_streaming = isp_video_output_start_streaming,
+   .stop_streaming  = isp_video_output_stop_streaming,
+};
+
+static const struct v4l2_file_operations isp_video_output_fops = {
+   .owner  = THIS_MODULE,
+   .open   = v4l2_fh_open

[RFC v3 01/13] [media] exynos5-is: Adding media device driver for exynos5

2013-08-02 Thread Arun Kumar K
From: Shaik Ameer Basha shaik.am...@samsung.com

This patch adds support for media device for EXYNOS5 SoCs.
The current media device supports the following ips to connect
through the media controller framework.

* MIPI-CSIS
  Support interconnection(subdev interface) between devices

* FIMC-LITE
  Support capture interface from device(Sensor, MIPI-CSIS) to memory
  Support interconnection(subdev interface) between devices

* FIMC-IS
  Camera post-processing IP having multiple sub-nodes.

G-Scaler will be added later to the current media device.

The media device creates two kinds of pipelines for connecting
the above mentioned IPs.
The pipeline0 is uses Sensor, MIPI-CSIS and FIMC-LITE which captures
image data and dumps to memory.
Pipeline1 uses FIMC-IS components for doing post-processing
operations on the captured image and give scaled YUV output.

Pipeline0
  ++ +---+ +---+ ++
  | Sensor | -- | MIPI-CSIS | -- | FIMC-LITE | -- | Memory |
  ++ +---+ +---+ ++

Pipeline1
 ++  ++ +---+ +---+
 | Memory | --  |  ISP   | -- |SCC| -- |SCP|
 ++  ++ +---+ +---+

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 .../devicetree/bindings/media/exynos5-mdev.txt |  153 ++
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1471 
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  199 +++
 3 files changed, 1823 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.c
 create mode 100644 drivers/media/platform/exynos5-is/exynos5-mdev.h

diff --git a/Documentation/devicetree/bindings/media/exynos5-mdev.txt 
b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
new file mode 100644
index 000..d7d419b
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-mdev.txt
@@ -0,0 +1,153 @@
+Samsung EXYNOS5 SoC Camera Subsystem (FIMC)
+--
+
+The Exynos5 SoC Camera subsystem comprises of multiple sub-devices
+represented by separate device tree nodes. Currently this includes: FIMC-LITE,
+MIPI CSIS and FIMC-IS.
+
+The sub-subdevices are defined as child nodes of the common 'camera' node which
+also includes common properties of the whole subsystem not really specific to
+any single sub-device, like common camera port pins or the CAMCLK clock outputs
+for external image sensors attached to an SoC.
+
+Common 'camera' node
+
+
+Required properties:
+
+- compatible   : must be samsung,exynos5-fimc, simple-bus
+- clocks   : list of clock specifiers, corresponding to entries in
+ the clock-names property;
+- clock-names  : must contain sclk_cam0, sclk_cam1 entries,
+ matching entries in the clocks property.
+
+The pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt must be used
+to define a required pinctrl state named default and optional pinctrl states:
+idle, active-a, active-b. These optional states can be used to switch the
+camera port pinmux at runtime. The idle state should configure both the 
camera
+ports A and B into high impedance state, especially the CAMCLK clock output
+should be inactive. For the active-a state the camera port A must be 
activated
+and the port B deactivated and for the state active-b it should be the other
+way around.
+
+The 'camera' node must include at least one 'fimc-lite' child node.
+
+'parallel-ports' node
+-
+
+This node should contain child 'port' nodes specifying active parallel video
+input ports. It includes camera A and camera B inputs. 'reg' property in the
+port nodes specifies data input - 0, 1 indicates input A, B respectively.
+
+Optional properties
+
+- samsung,camclk-out : specifies clock output for remote sensor,
+  0 - CAM_A_CLKOUT, 1 - CAM_B_CLKOUT;
+
+Image sensor nodes
+--
+
+The sensor device nodes should be added to their control bus controller (e.g.
+I2C0) nodes and linked to a port node in the csis or the parallel-ports node,
+using the common video interfaces bindings, defined in video-interfaces.txt.
+The implementation of this bindings requires clock-frequency property to be
+present in the sensor device nodes.
+
+Example:
+
+   aliases {
+   fimc-lite0 = fimc_lite_0
+   };
+
+   /* Parallel bus IF sensor */
+   i2c_0: i2c@1386 {
+   s5k6aa: sensor@3c {
+   compatible = samsung,s5k6aafx;
+   reg = 0x3c;
+   vddio-supply = ...;
+
+   clock-frequency = 2400;
+   clocks = ...;
+   clock-names = mclk;
+
+   port

[RFC v3 08/13] [media] exynos5-fimc-is: Add sensor interface

2013-08-02 Thread Arun Kumar K
Some sensors to be used with fimc-is are exclusively controlled
by the fimc-is firmware. This minimal sensor driver provides
the required info for the firmware to configure the sensors
sitting on I2C bus.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-sensor.c |   46 +
 drivers/media/platform/exynos5-is/fimc-is-sensor.h |   69 
 2 files changed, 115 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.c 
b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
new file mode 100644
index 000..3e4aae9
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
@@ -0,0 +1,46 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Authors:  Sylwester Nawrocki s.nawro...@samsung.com
+ *   Arun Kumar K arun...@samsung.com
+ *
+ * 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 fimc-is-sensor.h
+
+static const struct sensor_drv_data s5k6a3_drvdata = {
+   .id = FIMC_IS_SENSOR_ID_S5K6A3,
+   .open_timeout   = S5K6A3_OPEN_TIMEOUT,
+   .setfile_name   = setfile_6a3.bin,
+};
+
+static const struct sensor_drv_data s5k4e5_drvdata = {
+   .id = FIMC_IS_SENSOR_ID_S5K4E5,
+   .open_timeout   = S5K4E5_OPEN_TIMEOUT,
+   .setfile_name   = setfile_4e5.bin,
+};
+
+static const struct of_device_id fimc_is_sensor_of_ids[] = {
+   {
+   .compatible = samsung,s5k6a3,
+   .data   = s5k6a3_drvdata,
+   },
+   {
+   .compatible = samsung,s5k4e5,
+   .data   = s5k4e5_drvdata,
+   },
+   {  }
+};
+
+const struct sensor_drv_data *exynos5_is_sensor_get_drvdata(
+   struct device_node *node)
+{
+   const struct of_device_id *of_id;
+
+   of_id = of_match_node(fimc_is_sensor_of_ids, node);
+   return of_id ? of_id-data : NULL;
+}
diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.h 
b/drivers/media/platform/exynos5-is/fimc-is-sensor.h
new file mode 100644
index 000..51e18ea
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.h
@@ -0,0 +1,69 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Authors:  Sylwester Nawrocki s.nawro...@samsung.com
+ *  Younghwan Joo yhwan@samsung.com
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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.
+ */
+#ifndef FIMC_IS_SENSOR_H_
+#define FIMC_IS_SENSOR_H_
+
+#include linux/of.h
+#include linux/types.h
+
+#define S5K6A3_OPEN_TIMEOUT2000 /* ms */
+#define S5K6A3_SENSOR_WIDTH1392
+#define S5K6A3_SENSOR_HEIGHT   1392
+
+#define S5K4E5_OPEN_TIMEOUT2000 /* ms */
+#define S5K4E5_SENSOR_WIDTH2560
+#define S5K4E5_SENSOR_HEIGHT   1920
+
+#define SENSOR_WIDTH_PADDING   16
+#define SENSOR_HEIGHT_PADDING  10
+
+enum fimc_is_sensor_id {
+   FIMC_IS_SENSOR_ID_S5K3H2 = 1,
+   FIMC_IS_SENSOR_ID_S5K6A3,
+   FIMC_IS_SENSOR_ID_S5K4E5,
+   FIMC_IS_SENSOR_ID_S5K3H7,
+   FIMC_IS_SENSOR_ID_CUSTOM,
+   FIMC_IS_SENSOR_ID_END
+};
+
+#define IS_SENSOR_CTRL_BUS_I2C00
+#define IS_SENSOR_CTRL_BUS_I2C11
+
+struct sensor_drv_data {
+   enum fimc_is_sensor_id id;
+   /* sensor open timeout in ms */
+   unsigned short open_timeout;
+   char *setfile_name;
+};
+
+/**
+ * struct fimc_is_sensor - fimc-is sensor data structure
+ * @drvdata: a pointer to the sensor's parameters data structure
+ * @i2c_bus: ISP I2C bus index (0...1)
+ * @test_pattern: true to enable video test pattern
+ */
+struct fimc_is_sensor {
+   const struct sensor_drv_data *drvdata;
+   unsigned int i2c_bus;
+   unsigned int width;
+   unsigned int height;
+   unsigned int pixel_width;
+   unsigned int pixel_height;
+   u8 test_pattern;
+};
+
+const struct sensor_drv_data *exynos5_is_sensor_get_drvdata(
+   struct device_node *node);
+
+#endif /* FIMC_IS_SENSOR_H_ */
-- 
1.7.9.5

--
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


[RFC v3 07/13] [media] exynos5-fimc-is: Add scaler subdev

2013-08-02 Thread Arun Kumar K
FIMC-IS has two hardware scalers named as scaler-codec and
scaler-preview. This patch adds the common code handling the
video nodes and subdevs of both the scalers.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-scaler.c |  458 
 drivers/media/platform/exynos5-is/fimc-is-scaler.h |  112 +
 2 files changed, 570 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-scaler.c 
b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
new file mode 100644
index 000..7cff186
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
@@ -0,0 +1,458 @@
+/*
+ * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *  Arun Kumar K arun...@samsung.com
+ *
+ * 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 media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+
+#define IS_SCALER_DRV_NAME fimc-is-scaler
+
+static const struct fimc_is_fmt formats[] = {
+   {
+   .name   = YUV 4:2:0 3p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_YUV420M,
+   .depth  = {8, 2, 2},
+   .num_planes = 3,
+   },
+   {
+   .name   = YUV 4:2:0 2p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_NV12M,
+   .depth  = {8, 4},
+   .num_planes = 2,
+   },
+   {
+   .name   = YUV 4:2:2 1p MultiPlanar,
+   .fourcc = V4L2_PIX_FMT_NV16,
+   .depth  = {16},
+   .num_planes = 1,
+   },
+};
+#define NUM_FORMATS ARRAY_SIZE(formats)
+
+static const struct fimc_is_fmt *find_format(struct v4l2_format *f)
+{
+   unsigned int i;
+
+   for (i = 0; i  NUM_FORMATS; i++) {
+   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
+   return formats[i];
+   }
+   return NULL;
+}
+
+static int scaler_video_capture_start_streaming(struct vb2_queue *vq,
+   unsigned int count)
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   int ret;
+
+   /* Scaler start */
+   ret = fimc_is_pipeline_scaler_start(ctx-pipeline,
+   ctx-scaler_id,
+   (unsigned int **)ctx-buf_paddr,
+   vq-num_buffers,
+   ctx-fmt-num_planes);
+   if (ret) {
+   pr_err(Scaler start failed.\n);
+   return -EINVAL;
+   }
+
+   set_bit(STATE_RUNNING, ctx-capture_state);
+   return 0;
+}
+
+static int scaler_video_capture_stop_streaming(struct vb2_queue *vq)
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   int ret;
+
+   /* Scaler stop */
+   ret = fimc_is_pipeline_scaler_stop(ctx-pipeline, ctx-scaler_id);
+   if (ret)
+   pr_debug(Scaler already stopped.\n);
+
+   clear_bit(STATE_RUNNING, ctx-capture_state);
+   return 0;
+}
+
+static int scaler_video_capture_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   const struct fimc_is_fmt *fmt = ctx-fmt;
+   unsigned int wh;
+   int i;
+
+   if (!fmt)
+   return -EINVAL;
+
+   *num_planes = fmt-num_planes;
+   wh = ctx-width * ctx-height;
+
+   for (i = 0; i  *num_planes; i++) {
+   allocators[i] = ctx-alloc_ctx;
+   sizes[i] = (wh * fmt-depth[i]) / 8;
+   }
+   return 0;
+}
+
+static int scaler_video_capture_buffer_init(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+   const struct fimc_is_fmt *fmt;
+   int i;
+
+   buf = ctx-capture_bufs[vb-v4l2_buf.index];
+   /* Initialize buffer */
+   buf-vb = vb;
+   fmt = ctx-fmt;
+   for (i = 0; i  fmt-num_planes; i++)
+   buf-paddr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
+
+   ctx-cap_buf_cnt++;
+   return 0;
+}
+
+static void scaler_video_capture_buffer_queue(struct vb2_buffer *vb)
+{
+   struct vb2_queue *vq = vb-vb2_queue;
+   struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
+   struct fimc_is_buf *buf;
+
+   buf = ctx-capture_bufs[vb-v4l2_buf.index];
+
+   /* Add buffer

[RFC v3 03/13] [media] exynos5-fimc-is: Add driver core files

2013-08-02 Thread Arun Kumar K
This driver is for the FIMC-IS IP available in Samsung Exynos5
SoC onwards. This patch adds the core files for the new driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-core.c |  394 ++
 drivers/media/platform/exynos5-is/fimc-is-core.h |  122 +++
 2 files changed, 516 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-core.c 
b/drivers/media/platform/exynos5-is/fimc-is-core.c
new file mode 100644
index 000..7b7762b
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-core.c
@@ -0,0 +1,394 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Arun Kumar K arun...@samsung.com
+ *
+ * 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 linux/bug.h
+#include linux/ctype.h
+#include linux/device.h
+#include linux/debugfs.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/err.h
+#include linux/firmware.h
+#include linux/fs.h
+#include linux/gpio.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/module.h
+#include linux/types.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/videodev2.h
+#include linux/of.h
+#include linux/of_gpio.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/of_irq.h
+#include linux/pinctrl/consumer.h
+
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-mem2mem.h
+#include media/v4l2-of.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+#include fimc-is-i2c.h
+
+#define CLK_MCU_ISP_DIV0_FREQ  (200 * 100)
+#define CLK_MCU_ISP_DIV1_FREQ  (100 * 100)
+#define CLK_ISP_DIV0_FREQ  (134 * 100)
+#define CLK_ISP_DIV1_FREQ  (68 * 100)
+#define CLK_ISP_DIVMPWM_FREQ   (34 * 100)
+
+static char *fimc_is_clock_name[] = {
+   [IS_CLK_ISP]= isp,
+   [IS_CLK_MCU_ISP]= mcu_isp,
+   [IS_CLK_ISP_DIV0]   = isp_div0,
+   [IS_CLK_ISP_DIV1]   = isp_div1,
+   [IS_CLK_ISP_DIVMPWM]= isp_divmpwm,
+   [IS_CLK_MCU_ISP_DIV0]   = mcu_isp_div0,
+   [IS_CLK_MCU_ISP_DIV1]   = mcu_isp_div1,
+};
+
+static void fimc_is_put_clocks(struct fimc_is *is)
+{
+   int i;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
+   if (IS_ERR(is-clock[i]))
+   continue;
+   clk_unprepare(is-clock[i]);
+   clk_put(is-clock[i]);
+   is-clock[i] = NULL;
+   }
+}
+
+static int fimc_is_get_clocks(struct fimc_is *is)
+{
+   struct device *dev = is-pdev-dev;
+   int i, ret;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
+   is-clock[i] = clk_get(dev, fimc_is_clock_name[i]);
+   if (IS_ERR(is-clock[i]))
+   goto err;
+   ret = clk_prepare(is-clock[i]);
+   if (ret  0) {
+   clk_put(is-clock[i]);
+   is-clock[i] = ERR_PTR(-EINVAL);
+   goto err;
+   }
+   }
+   return 0;
+err:
+   fimc_is_put_clocks(is);
+   pr_err(Failed to get clock: %s\n, fimc_is_clock_name[i]);
+   return -ENXIO;
+}
+
+static int fimc_is_configure_clocks(struct fimc_is *is)
+{
+   int i, ret;
+
+   for (i = 0; i  IS_CLK_MAX_NUM; i++)
+   is-clock[i] = ERR_PTR(-EINVAL);
+
+   ret = fimc_is_get_clocks(is);
+   if (ret)
+   return ret;
+
+   /* Set rates */
+   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV0],
+   CLK_MCU_ISP_DIV0_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV1],
+   CLK_MCU_ISP_DIV1_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV0], CLK_ISP_DIV0_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIV1], CLK_ISP_DIV1_FREQ);
+   if (ret)
+   return ret;
+   ret = clk_set_rate(is-clock[IS_CLK_ISP_DIVMPWM],
+   CLK_ISP_DIVMPWM_FREQ);
+   return ret;
+}
+
+static void fimc_is_pipelines_destroy(struct fimc_is *is)
+{
+   int i;
+
+   for (i = 0; i  is-num_instance; i++)
+   fimc_is_pipeline_destroy(is-pipeline[i]);
+}
+
+static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index,
+   struct device_node *node)
+{
+   struct fimc_is_sensor *sensor = is-sensor

[RFC v3 05/13] [media] exynos5-fimc-is: Add register definition and context header

2013-08-02 Thread Arun Kumar K
This patch adds the register definition file for the fimc-is driver
and also the header file containing the main context for the driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 drivers/media/platform/exynos5-is/fimc-is-regs.h |  105 +++
 drivers/media/platform/exynos5-is/fimc-is.h  |  153 ++
 2 files changed, 258 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-regs.h
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-regs.h 
b/drivers/media/platform/exynos5-is/fimc-is-regs.h
new file mode 100644
index 000..06aa466
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-regs.h
@@ -0,0 +1,105 @@
+/*
+ * Samsung Exynos5 SoC series FIMC-IS driver
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd
+ * Arun Kumar K arun...@samsung.com
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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.
+ */
+
+#ifndef FIMC_IS_REGS_H
+#define FIMC_IS_REGS_H
+
+/* WDT_ISP register */
+#define WDT0x0017
+/* MCUCTL register */
+#define MCUCTL 0x0018
+/* MCU Controller Register */
+#define MCUCTLR(MCUCTL+0x00)
+#define MCUCTLR_AXI_ISPX_AWCACHE(x)((x)  16)
+#define MCUCTLR_AXI_ISPX_ARCACHE(x)((x)  12)
+#define MCUCTLR_MSWRST (1  0)
+/* Boot Base OFfset Address Register */
+#define BBOAR  (MCUCTL+0x04)
+#define BBOAR_BBOA(x)  ((x)  0)
+
+/* Interrupt Generation Register 0 from Host CPU to VIC */
+#define INTGR0 (MCUCTL+0x08)
+#define INTGR0_INTGC(n)(1  ((n) + 16))
+#define INTGR0_INTGD(n)(1  (n))
+
+/* Interrupt Clear Register 0 from Host CPU to VIC */
+#define INTCR0 (MCUCTL+0x0c)
+#define INTCR0_INTCC(n)(1  ((n) + 16))
+#define INTCR0_INTCD(n)(1  (n))
+
+/* Interrupt Mask Register 0 from Host CPU to VIC */
+#define INTMR0 (MCUCTL+0x10)
+#define INTMR0_INTMC(n)(1  ((n) + 16))
+#define INTMR0_INTMD(n)(1  (n))
+
+/* Interrupt Status Register 0 from Host CPU to VIC */
+#define INTSR0 (MCUCTL+0x14)
+#define INTSR0_GET_INTSD(n, x) (((x)  (n))  0x1)
+#define INTSR0_GET_INTSC(n, x) (((x)  ((n) + 16))  0x1)
+
+/* Interrupt Mask Status Register 0 from Host CPU to VIC */
+#define INTMSR0(MCUCTL+0x18)
+#define INTMSR0_GET_INTMSD(n, x)   (((x)  (n))  0x1)
+#define INTMSR0_GET_INTMSC(n, x)   (((x)  ((n) + 16))  0x1)
+
+/* Interrupt Generation Register 1 from ISP CPU to Host IC */
+#define INTGR1 (MCUCTL+0x1c)
+#define INTGR1_INTGC(n)(1  (n))
+
+/* Interrupt Clear Register 1 from ISP CPU to Host IC */
+#define INTCR1 (MCUCTL+0x20)
+#define INTCR1_INTCC(n)(1  (n))
+
+/* Interrupt Mask Register 1 from ISP CPU to Host IC */
+#define INTMR1 (MCUCTL+0x24)
+#define INTMR1_INTMC(n)(1  (n))
+
+/* Interrupt Status Register 1 from ISP CPU to Host IC */
+#define INTSR1 (MCUCTL+0x28)
+/* Interrupt Mask Status Register 1 from ISP CPU to Host IC */
+#define INTMSR1(MCUCTL+0x2c)
+/* Interrupt Clear Register 2 from ISP BLK's interrupts to Host IC */
+#define INTCR2 (MCUCTL+0x30)
+#define INTCR2_INTCC(n)(1  (n))
+
+/* Interrupt Mask Register 2 from ISP BLK's interrupts to Host IC */
+#define INTMR2 (MCUCTL+0x34)
+#define INTMR2_INTMCIS(n)  (1  (n))
+
+/* Interrupt Status Register 2 from ISP BLK's interrupts to Host IC */
+#define INTSR2 (MCUCTL+0x38)
+/* Interrupt Mask Status Register 2 from ISP BLK's interrupts to Host IC */
+#define INTMSR2(MCUCTL+0x3c)
+/* General Purpose Output Control Register (0~17) */
+#define GPOCTLR(MCUCTL+0x40)
+#define GPOCTLR_GPOG(n, x) ((x)  (n))
+
+/* General Purpose Pad Output Enable Register (0~17) */
+#define GPOENCTLR  (MCUCTL+0x44)
+#define GPOENCTLR_GPOEN0(n, x) ((x)  (n))
+
+/* General Purpose Input Control Register (0~17) */
+#define GPICTLR(MCUCTL+0x48)
+
+/* IS Shared Registers between ISP CPU and HOST CPU */
+#define ISSR(n)(MCUCTL + 0x80 + (n))
+
+/* PMU for FIMC-IS*/
+#define PMUREG_CMU_RESET_ISP_SYS_PWR_REG   0x1584
+#define

[RFC v3 12/13] V4L: s5k6a3: Change sensor min/max resolutions

2013-08-02 Thread Arun Kumar K
s5k6a3 sensor has actual pixel resolution of 1408x1402 against
the active resolution 1392x1392. The real resolution is needed
when raw sensor SRGB data is dumped to memory by fimc-lite.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/i2c/s5k6a3.c |   14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index ccbb4fc..d81638d 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -30,6 +30,9 @@
 #define S5K6A3_SENSOR_MIN_WIDTH32
 #define S5K6A3_SENSOR_MIN_HEIGHT   32
 
+#define S5K6A3_WIDTH_PADDING   16
+#define S5K6A3_HEIGHT_PADDING  10
+
 #define S5K6A3_DEF_PIX_WIDTH   1296
 #define S5K6A3_DEF_PIX_HEIGHT  732
 
@@ -107,10 +110,13 @@ static void s5k6a3_try_format(struct v4l2_mbus_framefmt 
*mf)
 
fmt = find_sensor_format(mf);
mf-code = fmt-code;
-   v4l_bound_align_image(mf-width, S5K6A3_SENSOR_MIN_WIDTH,
- S5K6A3_SENSOR_MAX_WIDTH, 0,
- mf-height, S5K6A3_SENSOR_MIN_HEIGHT,
- S5K6A3_SENSOR_MAX_HEIGHT, 0, 0);
+   v4l_bound_align_image(mf-width,
+   S5K6A3_SENSOR_MIN_WIDTH + S5K6A3_WIDTH_PADDING,
+   S5K6A3_SENSOR_MAX_WIDTH + S5K6A3_WIDTH_PADDING, 0,
+   mf-height,
+   S5K6A3_SENSOR_MIN_HEIGHT + S5K6A3_HEIGHT_PADDING,
+   S5K6A3_SENSOR_MAX_HEIGHT + S5K6A3_HEIGHT_PADDING, 0,
+   0);
 }
 
 static struct v4l2_mbus_framefmt *__s5k6a3_get_format(
-- 
1.7.9.5

--
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


[RFC v3 13/13] V4L: Add driver for s5k4e5 image sensor

2013-08-02 Thread Arun Kumar K
This patch adds subdev driver for Samsung S5K4E5 raw image sensor.
Like s5k6a3, it is also another fimc-is firmware controlled
sensor. This minimal sensor driver doesn't do any I2C communications
as its done by ISP firmware. It can be updated if needed to a
regular sensor driver by adding the I2C communication.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/i2c/Kconfig  |8 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k4e5.c |  362 
 3 files changed, 371 insertions(+)
 create mode 100644 drivers/media/i2c/s5k4e5.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index f7e9147..271028b 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -572,6 +572,14 @@ config VIDEO_S5K6A3
  This is a V4L2 sensor-level driver for Samsung S5K6A3 raw
  camera sensor.
 
+config VIDEO_S5K4E5
+   tristate Samsung S5K4E5 sensor support
+   depends on MEDIA_CAMERA_SUPPORT
+   depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  OF
+   ---help---
+ This is a V4L2 sensor-level driver for Samsung S5K4E5 raw
+ camera sensor.
+
 config VIDEO_S5K4ECGX
 tristate Samsung S5K4ECGX sensor support
 depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index cf3cf03..0aeed8e 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_SR030PC30) += sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)+= noon010pc30.o
 obj-$(CONFIG_VIDEO_S5K6AA) += s5k6aa.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
+obj-$(CONFIG_VIDEO_S5K4E5) += s5k4e5.o
 obj-$(CONFIG_VIDEO_S5K4ECGX)   += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_S5C73M3)+= s5c73m3/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
diff --git a/drivers/media/i2c/s5k4e5.c b/drivers/media/i2c/s5k4e5.c
new file mode 100644
index 000..a713c6a
--- /dev/null
+++ b/drivers/media/i2c/s5k4e5.c
@@ -0,0 +1,362 @@
+/*
+ * Samsung S5K4E5 image sensor driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Arun Kumar K arun...@samsung.com
+ *
+ * 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 linux/clk.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/gpio.h
+#include linux/i2c.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of_gpio.h
+#include linux/pm_runtime.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+#include linux/videodev2.h
+#include media/v4l2-async.h
+#include media/v4l2-subdev.h
+
+#define S5K4E5_SENSOR_MAX_WIDTH2560
+#define S5K4E5_SENSOR_MAX_HEIGHT   1920
+#define S5K4E5_SENSOR_MIN_WIDTH32
+#define S5K4E5_SENSOR_MIN_HEIGHT   32
+
+#define S5K4E5_WIDTH_PADDING   16
+#define S5K4E5_HEIGHT_PADDING  10
+
+#define S5K4E5_DEF_PIX_WIDTH   1296
+#define S5K4E5_DEF_PIX_HEIGHT  732
+
+#define S5K4E5_DRV_NAMES5K4E5
+#define S5K4E5_CLK_NAMEmclk
+
+#define S5K4E5_NUM_SUPPLIES2
+
+/**
+ * struct s5k4e5 - fimc-is sensor data structure
+ * @dev: pointer to this I2C client device structure
+ * @subdev: the image sensor's v4l2 subdev
+ * @pad: subdev media source pad
+ * @supplies: image sensor's voltage regulator supplies
+ * @gpio_reset: GPIO connected to the sensor's reset pin
+ * @lock: mutex protecting the structure's members below
+ * @format: media bus format at the sensor's source pad
+ */
+struct s5k4e5 {
+   struct device *dev;
+   struct v4l2_subdev subdev;
+   struct media_pad pad;
+   struct regulator_bulk_data supplies[S5K4E5_NUM_SUPPLIES];
+   int gpio_reset;
+   struct mutex lock;
+   struct v4l2_mbus_framefmt format;
+   struct clk *clock;
+   u32 clock_frequency;
+};
+
+static const char * const s5k4e5_supply_names[] = {
+   svdda,
+   svddio
+};
+
+static inline struct s5k4e5 *sd_to_s5k4e5(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct s5k4e5, subdev);
+}
+
+static const struct v4l2_mbus_framefmt s5k4e5_formats[] = {
+   {
+   .code = V4L2_MBUS_FMT_SGRBG10_1X10,
+   .colorspace = V4L2_COLORSPACE_SRGB,
+   .field = V4L2_FIELD_NONE,
+   }
+};
+
+static const struct v4l2_mbus_framefmt *find_sensor_format(
+   struct v4l2_mbus_framefmt *mf)
+{
+   int i;
+
+   for (i = 0; i  ARRAY_SIZE(s5k4e5_formats); i++)
+   if (mf-code == s5k4e5_formats[i].code)
+   return s5k4e5_formats[i];
+
+   return s5k4e5_formats[0];
+}
+
+static int s5k4e5_enum_mbus_code(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh

[RFC v3 10/13] [media] exynos5-fimc-is: Add the hardware interface module

2013-08-02 Thread Arun Kumar K
The hardware interface module finally sends the commands to the
FIMC-IS firmware and runs the interrupt handler for getting the
responses.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
---
 .../media/platform/exynos5-is/fimc-is-interface.c  |  861 
 .../media/platform/exynos5-is/fimc-is-interface.h  |  128 +++
 2 files changed, 989 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.c
 create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.h

diff --git a/drivers/media/platform/exynos5-is/fimc-is-interface.c 
b/drivers/media/platform/exynos5-is/fimc-is-interface.c
new file mode 100644
index 000..12073be
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/fimc-is-interface.c
@@ -0,0 +1,861 @@
+/*
+ * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
+*
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Kil-yeon Lim kilyeon...@samsung.com
+ *
+ * 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 linux/debugfs.h
+#include linux/seq_file.h
+#include fimc-is.h
+#include fimc-is-cmd.h
+#include fimc-is-regs.h
+
+#define init_request_barrier(itf) mutex_init(itf-request_barrier)
+#define enter_request_barrier(itf) mutex_lock(itf-request_barrier)
+#define exit_request_barrier(itf) mutex_unlock(itf-request_barrier)
+
+static inline void itf_get_cmd(struct fimc_is_interface *itf,
+   struct fimc_is_msg *msg, unsigned int index)
+{
+   struct is_common_reg __iomem *com_regs = itf-com_regs;
+
+   memset(msg, 0, sizeof(*msg));
+
+   switch (index) {
+   case INTR_GENERAL:
+   msg-command = com_regs-ihcmd;
+   msg-instance = com_regs-ihc_sensorid;
+   msg-param[0] = com_regs-ihc_param[0];
+   msg-param[1] = com_regs-ihc_param[1];
+   msg-param[2] = com_regs-ihc_param[2];
+   msg-param[3] = com_regs-ihc_param[3];
+   break;
+   case INTR_SCC_FDONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-scc_sensor_id;
+   msg-param[0] = com_regs-scc_param[0];
+   msg-param[1] = com_regs-scc_param[1];
+   msg-param[2] = com_regs-scc_param[2];
+   break;
+   case INTR_SCP_FDONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-scp_sensor_id;
+   msg-param[0] = com_regs-scp_param[0];
+   msg-param[1] = com_regs-scp_param[1];
+   msg-param[2] = com_regs-scp_param[2];
+   break;
+   case INTR_META_DONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-meta_sensor_id;
+   msg-param[0] = com_regs-meta_param1;
+   break;
+   case INTR_SHOT_DONE:
+   msg-command = IHC_FRAME_DONE;
+   msg-instance = com_regs-shot_sensor_id;
+   msg-param[0] = com_regs-shot_param[0];
+   msg-param[1] = com_regs-shot_param[1];
+   break;
+   default:
+   pr_err(unknown command getting\n);
+   break;
+   }
+}
+
+static inline unsigned int itf_get_intr(struct fimc_is_interface *itf)
+{
+   unsigned int status;
+   struct is_common_reg __iomem *com_regs = itf-com_regs;
+
+   status = readl(itf-regs + INTMSR1) | com_regs-ihcmd_iflag |
+   com_regs-scc_iflag |
+   com_regs-scp_iflag |
+   com_regs-meta_iflag |
+   com_regs-shot_iflag;
+
+   return status;
+}
+
+static void itf_set_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   unsigned long flags;
+   spin_lock_irqsave(itf-slock_state, flags);
+   __set_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+}
+
+static void itf_clr_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   unsigned long flags;
+   spin_lock_irqsave(itf-slock_state, flags);
+   __clear_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+}
+
+static int itf_get_state(struct fimc_is_interface *itf,
+   unsigned long state)
+{
+   int ret = 0;
+   unsigned long flags;
+
+   spin_lock_irqsave(itf-slock_state, flags);
+   ret = test_bit(state, itf-state);
+   spin_unlock_irqrestore(itf-slock_state, flags);
+   return ret;
+}
+
+static void itf_init_wakeup(struct fimc_is_interface *itf)
+{
+   itf_set_state(itf, IS_IF_STATE_INIT);
+   wake_up(itf-irq_queue);
+}
+
+void itf_busy_wakeup(struct fimc_is_interface *itf)
+{
+   itf_clr_state(itf, IS_IF_STATE_BUSY);
+   wake_up(itf-irq_queue);
+}
+
+static int itf_wait_hw_ready(struct fimc_is_interface *itf)
+{
+   int t

[RFC v3 11/13] [media] exynos5-is: Add Kconfig and Makefile

2013-08-02 Thread Arun Kumar K
Adds Kconfig and Makefile for exynos5-is driver files.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Kilyeon Im kilyeon...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |   19 +++
 drivers/media/platform/exynos5-is/Makefile |7 +++
 4 files changed, 28 insertions(+)
 create mode 100644 drivers/media/platform/exynos5-is/Kconfig
 create mode 100644 drivers/media/platform/exynos5-is/Makefile

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 08de865..4b0475e 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -123,6 +123,7 @@ config VIDEO_S3C_CAMIF
 
 source drivers/media/platform/soc_camera/Kconfig
 source drivers/media/platform/exynos4-is/Kconfig
+source drivers/media/platform/exynos5-is/Kconfig
 source drivers/media/platform/s5p-tv/Kconfig
 
 endif # V4L_PLATFORM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index eee28dd..b1225e5 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)+= s5p-tv/
 
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)+= s5p-g2d/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_MDEV)   += exynos5-is/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos5-is/Kconfig 
b/drivers/media/platform/exynos5-is/Kconfig
new file mode 100644
index 000..99d5edf
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Kconfig
@@ -0,0 +1,19 @@
+config VIDEO_SAMSUNG_EXYNOS5_MDEV
+   bool Samsung Exynos5 Media Device driver
+   depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  PM_RUNTIME  
VIDEO_SAMSUNG_EXYNOS4_IS
+   help
+ This is a v4l2 based media controller driver for
+ Exynos5 SoC.
+
+if VIDEO_SAMSUNG_EXYNOS5_MDEV
+
+config VIDEO_SAMSUNG_EXYNOS5_FIMC_IS
+   tristate Samsung Exynos5 SoC FIMC-IS driver
+   depends on I2C  OF
+   depends on VIDEO_EXYNOS4_FIMC_IS
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ This is a V4L2 driver for Samsung Exynos5 SoC series Imaging
+ Subsystem known as FIMC-IS.
+
+endif #VIDEO_SAMSUNG_EXYNOS5_MDEV
diff --git a/drivers/media/platform/exynos5-is/Makefile 
b/drivers/media/platform/exynos5-is/Makefile
new file mode 100644
index 000..c4e37e0
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Makefile
@@ -0,0 +1,7 @@
+ccflags-y += -Idrivers/media/platform/exynos4-is
+exynos5-fimc-is-objs := fimc-is-core.o fimc-is-isp.o fimc-is-scaler.o
+exynos5-fimc-is-objs += fimc-is-pipeline.o fimc-is-interface.o fimc-is-sensor.o
+exynos-mdevice-objs := exynos5-mdev.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_FIMC_IS) += exynos5-fimc-is.o
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_MDEV) += exynos-mdevice.o
-- 
1.7.9.5

--
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: [RFC v2 06/10] exynos5-fimc-is: Adds isp subdev

2013-08-01 Thread Arun Kumar K
Hi Sylwester,

On Fri, Jun 21, 2013 at 4:55 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 05/31/2013 03:03 PM, Arun Kumar K wrote:

 fimc-is driver takes video data input from the ISP video node
 which is added in this patch. This node accepts Bayer input
 buffers which is given from the IS sensors.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---
   drivers/media/platform/exynos5-is/fimc-is-isp.c |  438
 +++
   drivers/media/platform/exynos5-is/fimc-is-isp.h |   89 +
   2 files changed, 527 insertions(+)
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.c
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.h


[snip]

 + * Video node ioctl operations
 + */
 +static int isp_querycap_output(struct file *file, void *priv,
 +   struct v4l2_capability *cap)
 +{
 +   strncpy(cap-driver, ISP_DRV_NAME, sizeof(cap-driver) - 1);
 +   strncpy(cap-card, ISP_DRV_NAME, sizeof(cap-card) - 1);
 +   strncpy(cap-bus_info, ISP_DRV_NAME, sizeof(cap-bus_info) - 1);
 +   cap-capabilities = V4L2_CAP_STREAMING |
 V4L2_CAP_VIDEO_OUTPUT_MPLANE;
 +   cap-device_caps = V4L2_CAP_STREAMING |
 V4L2_CAP_VIDEO_OUTPUT_MPLANE;


 cap-capabilities = V4L2_CAP_STREAMING;

 cap-device_caps = V4L2_CAP_STREAMING |
 V4L2_CAP_VIDEO_OUTPUT_MPLANE;

 This should be:

 cap-device_caps = V4L2_CAP_STREAMING;
 cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;

 Media Controller device nodes must not use V4L2_CAP_VIDEO_{OUTPUT,
 CAPTURE}_(_MPLANE)
 capability flags.


If I dont provide any video capabilities, the v4l2-compliance tool
gives a fail :

 fail: v4l2-compliance.cpp(298) : node-is_video  !(dcaps  video_caps)
test VIDIOC_QUERYCAP: FAIL

This error doesn't come if I give V4L2_CAP_VIDEO_OUTPUT_MPLANE capability.

One more related error compliance tool gives is :

   fail: v4l2-test-formats.cpp(286): Video Output Multiplanar cap not
set, but Video Output Multiplanar formats defined
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL

Shall these errors be ignored?

Regards
Arun
--
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: [REVIEW PATCH 0/6] exynos4-is: Asynchronous subdev registration support

2013-07-28 Thread Arun Kumar K
Hi Sylwester,

On Wed, Jul 24, 2013 at 12:09 AM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 This patch series is a refactoring of the exynos4-is driver to get rid
 of the common fimc-is-sensor driver and to adapt it to use standard
 sensor subdev drivers, one per each image sensor type.
 Then a clock provider is added to the exynos4-is driver and the s5k6a3
 subdev is modified to use one of the clocks registered by exynos4-is.

 Arun, I think you could reuse the s5k6a3 sensor for your work on the
 Exynos5 FIMC-IS driver. One advantage of separate sensor drivers is
 that the power on/off sequences can be written specifically for each
 sensor. We are probably going to need such sequences per board in
 future. Also having the clock control inside the sensor subdev allows
 to better match the hardware power on/off sequence requirements,
 however the S5K6A3 sensor can have active clock signal on its clock
 input pin even when all its power supplies are turned off.

 I'm posting this series before having a proper implementation for
 clk_unregister() in the clock framework, so you are not blocked with
 your Exynos5 FIMC-IS works.



Thank you for the patches. I am modifying exynos5-is based on
the same design.

Thanks  Regards
Arun
--
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: [REVIEW PATCH 4/6] exynos4-is: Add clock provider for the external clocks

2013-07-28 Thread Arun Kumar K
Hi Sylwester,

On Wed, Jul 24, 2013 at 12:09 AM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 This patch adds clock provider to expose the sclk_cam0/1 clocks
 for image sensor subdevs.

 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  .../devicetree/bindings/media/samsung-fimc.txt |   17 +++-
  drivers/media/platform/exynos4-is/media-dev.c  |   92 
 
  drivers/media/platform/exynos4-is/media-dev.h  |   19 +++-
  3 files changed, 125 insertions(+), 3 deletions(-)

 diff --git a/Documentation/devicetree/bindings/media/samsung-fimc.txt 
 b/Documentation/devicetree/bindings/media/samsung-fimc.txt
 index 96312f6..04a2b87 100644
 --- a/Documentation/devicetree/bindings/media/samsung-fimc.txt
 +++ b/Documentation/devicetree/bindings/media/samsung-fimc.txt
 @@ -91,6 +91,15 @@ Optional properties
  - samsung,camclk-out : specifies clock output for remote sensor,
0 - CAM_A_CLKOUT, 1 - CAM_B_CLKOUT;

 +'clock-controller' node (optional)
 +--
 +
 +The purpose of this node is to define a clock provider for external image
 +sensors and link any of the CAM_?_CLKOUT clock outputs with related external
 +clock consumer device. Properties specific to this node are described in
 +../clock/clock-bindings.txt.
 +
 +
  Image sensor nodes
  --

 @@ -114,7 +123,7 @@ Example:
 vddio-supply = ...;

 clock-frequency = 2400;
 -   clocks = ...;
 +   clocks = camclk 1;
 clock-names = mclk;

 port {
 @@ -135,7 +144,7 @@ Example:
 vddio-supply = ...;

 clock-frequency = 2400;
 -   clocks = ...;
 +   clocks = camclk 0;
 clock-names = mclk;

 port {
 @@ -156,6 +165,10 @@ Example:
 pinctrl-names = default;
 pinctrl-0 = cam_port_a_clk_active;

 +   camclk: clock-controller {
 +  #clock-cells = 1;

Isn't it
  #clock-cells = 1;
?

 +   };
 +


Regards
Arun
--
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] exynos-gsc: Register v4l2 device

2013-07-26 Thread Arun Kumar K
Gscaler video device registration was happening without
reference to a parent v4l2_dev causing probe to fail.
The patch creates a parent v4l2 device and uses it for
gsc m2m video device registration.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-core.c |9 -
 drivers/media/platform/exynos-gsc/gsc-core.h |1 +
 drivers/media/platform/exynos-gsc/gsc-m2m.c  |1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index 559fab2..1ec60264 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -1122,10 +1122,14 @@ static int gsc_probe(struct platform_device *pdev)
goto err_clk;
}
 
-   ret = gsc_register_m2m_device(gsc);
+   ret = v4l2_device_register(dev, gsc-v4l2_dev);
if (ret)
goto err_clk;
 
+   ret = gsc_register_m2m_device(gsc);
+   if (ret)
+   goto err_v4l2;
+
platform_set_drvdata(pdev, gsc);
pm_runtime_enable(dev);
ret = pm_runtime_get_sync(pdev-dev);
@@ -1147,6 +1151,8 @@ err_pm:
pm_runtime_put(dev);
 err_m2m:
gsc_unregister_m2m_device(gsc);
+err_v4l2:
+   v4l2_device_unregister(gsc-v4l2_dev);
 err_clk:
gsc_clk_put(gsc);
return ret;
@@ -1157,6 +1163,7 @@ static int gsc_remove(struct platform_device *pdev)
struct gsc_dev *gsc = platform_get_drvdata(pdev);
 
gsc_unregister_m2m_device(gsc);
+   v4l2_device_unregister(gsc-v4l2_dev);
 
vb2_dma_contig_cleanup_ctx(gsc-alloc_ctx);
pm_runtime_disable(pdev-dev);
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h 
b/drivers/media/platform/exynos-gsc/gsc-core.h
index cc19bba..76435d3 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/exynos-gsc/gsc-core.h
@@ -343,6 +343,7 @@ struct gsc_dev {
unsigned long   state;
struct vb2_alloc_ctx*alloc_ctx;
struct video_device vdev;
+   struct v4l2_device  v4l2_dev;
 };
 
 /**
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 40a73f7..e576ff2 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -751,6 +751,7 @@ int gsc_register_m2m_device(struct gsc_dev *gsc)
gsc-vdev.release   = video_device_release_empty;
gsc-vdev.lock  = gsc-lock;
gsc-vdev.vfl_dir   = VFL_DIR_M2M;
+   gsc-vdev.v4l2_dev  = gsc-v4l2_dev;
snprintf(gsc-vdev.name, sizeof(gsc-vdev.name), %s.%d:m2m,
GSC_MODULE_NAME, gsc-id);
 
-- 
1.7.9.5

--
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: [RFC v2 05/10] exynos5-fimc-is: Adds the sensor subdev

2013-07-17 Thread Arun Kumar K
Hi Sylwester,

On Wed, Jul 17, 2013 at 7:44 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 On 07/17/2013 06:55 AM, Arun Kumar K wrote:
 On Wed, Jul 17, 2013 at 3:33 AM, Sylwester Nawrocki
 sylvester.nawro...@gmail.com wrote:
 On 07/09/2013 02:04 PM, Arun Kumar K wrote:

 On Wed, Jun 26, 2013 at 12:57 PM, Hans Verkuilhverk...@xs4all.nl  wrote:

 On Fri May 31 2013 15:03:23 Arun Kumar K wrote:

 FIMC-IS uses certain sensors which are exclusively controlled
 from the IS firmware. This patch adds the sensor subdev for the
 fimc-is sensors.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com


 Not surprisingly I really hate the idea of sensor drivers that are tied
 to
 a specific SoC, since it completely destroys the reusability of such
 drivers.


 Yes agree to it.

 I understand that you have little choice to do something special here,
 but
 I was wondering whether there is a way of keeping things as generic as
 possible.

 I'm just brainstorming here, but as far as I can see this driver is
 basically
 a partial sensor driver: it handles the clock, the format negotiation and
 power management. Any sensor driver needs that.

 What would be nice is if the fmic specific parts are replaced by
 callbacks
 into the bridge driver using v4l2_subdev_notify().

 The platform data (or DT) can also state if this sensor is firmware
 controlled
 or not. If not, then the missing bits can be implemented in the future by
 someone who needs that.

 That way the driver itself remains independent from fimc.

 And existing sensor drivers can be adapted to be usable with fimc as well
 by
 adding support for the notify callback.

 Would a scheme along those lines work?


 Yes this should make the implementation very generic.
 Will check the feasibility of this approach.


 Is I suggested earlier, you likely could do without this call back to the
 FIMC-IS from within the sensor subdev. Look at your call chain right now:

  /dev/video? media-dev-driversensor-subdev FIMC-IS
 | |   |  |
 | VIDIOC_STREAMON |   |  |
 |# s_stream()|  |
 | #--# pipeline_open()  |
 | |   # |
 | |   # pipeline_start() |
 | |   # |
 | |   |  |

 Couldn't you move pipeline_open(), pipeline_start() to s_stream handler
 of the ISP subdev ? It is currently empty. The media device driver could
 call s_stream on the ISP subdev each time it sees s_stream request on
 the sensor subdev. And you wouldn't need any hacks to get the pipeline
 pointer in the sensor subdev. Then it would be something like:

  /dev/video? media-dev-driversensor-subdev  FIMC-IS-ISP-subdev
 | |   | |
 | VIDIOC_STREAMON |   | |
 |# s_stream()| |
 | #--| |
 | # s_stream()| |
 | #---+# pipeline_open()
 | |   | # pipeline_start()
 | |   | #

 I suppose pipeline_open() is better candidate for the s_power callback.
 It just needs to be ensured at the media device level the subdev
 operations sequences are correct.


 It can be done this way. But my intention of putting these calls in
 the sensor subdev was to use the sensor subdev independent of
 isp subdev. This is for the usecase where the pipeline will only contain

 is-sensor -- mipi-csis -- fimc-lite --- memory

 This way you can capture the bayer rgb data from sensor without using
 any isp components at all.

 The second pipeline which is isp -- scc -- scp
 can be used for processing the sensor data and can be created and
 used if needed.

 In the method you mentioned, the isp subdev has to be used even
 when it is not part of the pipeline. Is that allowed?
 If its allowed as per media pipeline guidelines, then this definitely
 is a better approach. Please suggest on this.

 Sure, I'm aware of those two relatively separate pipelines. s_power,
 s_stream callbacks belong to the kernel so I don't think it would be
 an issue to do it as I described. Please note s_power, s_stream are
 normally reference counted.
 Alternatively you could create a separate subdev for the FIMC-IS
 firmware interface. Such subdev wouldn't be exposing device node
 and would be used by the media pipeline controller driver to ensure
 proper hardware configuration sequences. I don't know the Exynos5
 FIMC-IS firmware architecture very well so I'm not sure if it is
 worth to create such a separate

Re: [RFC v2 01/10] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings documentation

2013-07-16 Thread Arun Kumar K
Hi Sylwester,

On Wed, Jul 17, 2013 at 2:53 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Arun,


 On 07/09/2013 01:08 PM, Arun Kumar K wrote:

 On Fri, Jun 21, 2013 at 4:15 AM, Sylwester Nawrocki
 sylvester.nawro...@gmail.com  wrote:

 On 05/31/2013 03:03 PM, Arun Kumar K wrote:

 [...]

 Signed-off-by: Arun Kumar Karun...@samsung.com
 ---
.../devicetree/bindings/media/exynos5-fimc-is.txt  |   41
 
1 file changed, 41 insertions(+)
create mode 100644
 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt

 diff --git a/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 new file mode 100644
 index 000..9fd4646
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 @@ -0,0 +1,41 @@

 [...]

 +---
 +
 +The camera subsystem on Samsung Exynos5 SoC has some changes relative
 +to previous SoC versions. Exynos5 has almost similar MIPI-CSIS and
 +FIMC-LITE IPs but has a much improved version of FIMC-IS which can
 +handle sensor controls and camera post-processing operations. The
 +Exynos5 FIMC-IS has a dedicated ARM Cortex A5 processor, many
 +post-processing blocks (ISP, DRC, FD, ODC, DIS, 3DNR) and two
 +dedicated scalers (SCC and SCP).
 +
 +fimc-is node
 +
 +
 +Required properties:
 +
 +- compatible: must be samsung,exynos5250-fimc-is
 +- reg   : physical base address and size of the memory
 mapped
 +  registers
 +- interrupt-parent  : Parent interrupt controller
 +- interrupts: fimc-is interrupt to the parent combiner
 +- clocks: list of clock specifiers, corresponding to
 entries
 in
 +  clock-names property;
 +- clock-names   : must contain isp, mcu_isp, isp_div0,
 isp_div1,
 +  isp_divmpwm, mcu_isp_div0, mcu_isp_div1
 entries,
 +  matching entries in the clocks property.
 +
 +
 +Board specific properties:
 +
 +- pinctrl-names: pinctrl names for camera port pinmux control, at
 least
 +default needs to be specified.
 +- pinctrl-0...N   : pinctrl properties corresponding to
 pinctrl-names



 What pins exactly are supposed to be covered by these properties ? For
 what
 devices ? Aren't the camera port pins supposed to be specified at the
 common
 'camera' node ? I believe the camera ports are not specific to the
 FIMC-IS.


 These are for the sensor controls (especially clock lines).
 I think I should move these to the sensor node.


 This doesn't sound right either. These pins are not a property of an
 external
 image sensor device, they are specific to the AP SoC. So IMO these pinctrl
 properties belong to some SoC's internal device node.


Ok. Time being I will move it to the camera node pinctrl properties.

 I think we could add a clock provider for the sclk_cam clocks and then the
 pinmux of those clock outputs could be configurable from with the clock ops.
 E.g. we set the pinumx into CAM_?_CLKOUT function only when a clock is
 enabled.
 Disabling a clock would put CLKOUT pin pinmux e.g. into input with pull down
 state. This would ensure proper CLKOUT pin configuration when image sensor
 is
 suspended or entirely powered off. I'm working on something like this for
 exynos4.


Ok that would be great. I will refer your exynos4 implementation for doing this.


 +pmu subnode
 +---
 +
 +Required properties:
 + - reg : should contain PMU physical base address and size of the
 memory
 + mapped registers.



 What about other devices, like ISP I2C, SPI ? Don't you want to list at
 least
 the ones currently used (I2C bus controllers) ?


 The present driver doesnt make use of the SPI bus as its used only
 for sensor calibration which is not yet added.


 Is it only going to be used by the Cortex-A5 firmware, similarly to the
 I2C bus ? If so then it is likely not needed to specify it here right now.
 But I believe for complete H/W description we should reserve a possibility
 to add those various peripheral device nodes here.


Yes its going to be used  by the firmware and is done for sensor
calibration. The sensor works well even without it and so I didnt
include it in my initial patchset and kept it as a todo.


 I2C bus is used by the sensor which has its own node. May be I should
 explain one of the sensor nodes over here?


 I would describe at least I2C bus controller node and add a note that image
 sensor nodes can be specified there.


I havent created a dummy i2c device driver for handling the i2c clock
part and everything was handled in the fimc-is-sensor itself.
I was checking your exynos4 implementation and will try to do in similar
lines.

 Also, it would be good to start adding separate sensor drivers for each
 sensor, like s5k6a3, s5k4e3, etc. Ideally we should not have duplicated
 fimc-is-sensor.[ch] that would handle various

Re: [RFC v2 06/10] exynos5-fimc-is: Adds isp subdev

2013-07-16 Thread Arun Kumar K
Hi Sylwester,

On Wed, Jul 17, 2013 at 3:41 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 07/09/2013 01:42 PM, Arun Kumar K wrote:

 +   /* Check if same as sensor width   height */
 
   +   sensor_width = p-sensor-drvdata-pixel_width;
   +   sensor_height = p-sensor-drvdata-pixel_height;
   +   if ((sensor_width != f-fmt.pix_mp.width) ||
   +   (sensor_height != f-fmt.pix_mp.height)) {

 
 
   What's the point of this check ?
 

 Check was added to ensure ISP input width and height is
 set same as the sensor output or not.
 But yes this cannot be extended to generic (non-IS controlled) sensors.
 Will drop this check and let media controller take care.

 

   +   f-fmt.pix_mp.width = sensor_width;
   +   f-fmt.pix_mp.height = sensor_height;
   +   }


 I meant that you could do the assignment unconditionally, since you
 always end up with sensor_width/height assigned to pix_mp.width/height.
 Indeed, this should be handled by subdev ioctls, and any discrepancies
 should be detected while starting streaming and reported to user space.


Ok I got it. Will modify accordingly

Thanks  Regards
Arun
--
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: [RFC v2 05/10] exynos5-fimc-is: Adds the sensor subdev

2013-07-16 Thread Arun Kumar K
Hi Sylwester,


On Wed, Jul 17, 2013 at 3:33 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Arun,


 On 07/09/2013 02:04 PM, Arun Kumar K wrote:

 On Wed, Jun 26, 2013 at 12:57 PM, Hans Verkuilhverk...@xs4all.nl  wrote:

 On Fri May 31 2013 15:03:23 Arun Kumar K wrote:

 FIMC-IS uses certain sensors which are exclusively controlled
 from the IS firmware. This patch adds the sensor subdev for the
 fimc-is sensors.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com


 Not surprisingly I really hate the idea of sensor drivers that are tied
 to
 a specific SoC, since it completely destroys the reusability of such
 drivers.


 Yes agree to it.

 I understand that you have little choice to do something special here,
 but
 I was wondering whether there is a way of keeping things as generic as
 possible.

 I'm just brainstorming here, but as far as I can see this driver is
 basically
 a partial sensor driver: it handles the clock, the format negotiation and
 power management. Any sensor driver needs that.

 What would be nice is if the fmic specific parts are replaced by
 callbacks
 into the bridge driver using v4l2_subdev_notify().

 The platform data (or DT) can also state if this sensor is firmware
 controlled
 or not. If not, then the missing bits can be implemented in the future by
 someone who needs that.

 That way the driver itself remains independent from fimc.

 And existing sensor drivers can be adapted to be usable with fimc as well
 by
 adding support for the notify callback.

 Would a scheme along those lines work?


 Yes this should make the implementation very generic.
 Will check the feasibility of this approach.


 Is I suggested earlier, you likely could do without this call back to the
 FIMC-IS from within the sensor subdev. Look at your call chain right now:

  /dev/video? media-dev-driversensor-subdev FIMC-IS
 | |   |  |
 | VIDIOC_STREAMON |   |  |
 |# s_stream()|  |
 | #--# pipeline_open()  |
 | |   # |
 | |   # pipeline_start() |
 | |   # |
 | |   |  |

 Couldn't you move pipeline_open(), pipeline_start() to s_stream handler
 of the ISP subdev ? It is currently empty. The media device driver could
 call s_stream on the ISP subdev each time it sees s_stream request on
 the sensor subdev. And you wouldn't need any hacks to get the pipeline
 pointer in the sensor subdev. Then it would be something like:

  /dev/video? media-dev-driversensor-subdev  FIMC-IS-ISP-subdev
 | |   | |
 | VIDIOC_STREAMON |   | |
 |# s_stream()| |
 | #--| |
 | # s_stream()| |
 | #---+# pipeline_open()
 | |   | # pipeline_start()
 | |   | #

 I suppose pipeline_open() is better candidate for the s_power callback.
 It just needs to be ensured at the media device level the subdev
 operations sequences are correct.


It can be done this way. But my intention of putting these calls in
the sensor subdev was to use the sensor subdev independent of
isp subdev. This is for the usecase where the pipeline will only contain

is-sensor -- mipi-csis -- fimc-lite --- memory

This way you can capture the bayer rgb data from sensor without using
any isp components at all.

The second pipeline which is isp -- scc -- scp
can be used for processing the sensor data and can be created and
used if needed.

In the method you mentioned, the isp subdev has to be used even
when it is not part of the pipeline. Is that allowed?
If its allowed as per media pipeline guidelines, then this definitely
is a better approach. Please suggest on this.

Regards
Arun
--
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] exynos4-is: Fix fimc-lite bayer formats

2013-07-15 Thread Arun Kumar K
The 10bit and 12bit bayer output formats supported
by fimc-lite actually uses 16bits where the extra
bits are padded with zeros. The patch corrects this
by modifying depth field of these two formats.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index 08fbfed..e85dc4f 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -90,7 +90,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.name   = RAW10 (GRBG),
.fourcc = V4L2_PIX_FMT_SGRBG10,
.colorspace = V4L2_COLORSPACE_SRGB,
-   .depth  = { 10 },
+   .depth  = { 16 },
.color  = FIMC_FMT_RAW10,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_SGRBG10_1X10,
@@ -99,7 +99,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.name   = RAW12 (GRBG),
.fourcc = V4L2_PIX_FMT_SGRBG12,
.colorspace = V4L2_COLORSPACE_SRGB,
-   .depth  = { 12 },
+   .depth  = { 16 },
.color  = FIMC_FMT_RAW12,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_SGRBG12_1X12,
-- 
1.7.9.5

--
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: [RFC v2 01/10] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings documentation

2013-07-09 Thread Arun Kumar K
Hi Sylwester,

Thank you for the review and sorry for the delayed response.

On Fri, Jun 21, 2013 at 4:15 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Arun,

 On 05/31/2013 03:03 PM, Arun Kumar K wrote:

 Please add at least one sentence here. All in all this patch
 adds DT binding documentation for a fairly complex subsystem.

 And please Cc devicetree-disc...@lists.ozlabs.org next time.


Ok will do that.


 Signed-off-by: Arun Kumar Karun...@samsung.com
 ---
   .../devicetree/bindings/media/exynos5-fimc-is.txt  |   41
 
   1 file changed, 41 insertions(+)
   create mode 100644
 Documentation/devicetree/bindings/media/exynos5-fimc-is.txt

 diff --git a/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 new file mode 100644
 index 000..9fd4646
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/exynos5-fimc-is.txt
 @@ -0,0 +1,41 @@
 +Samsung EXYNOS SoC Camera Subsystem


 Shouldn't it be, e.g.:

 Samsung EXYNOS5 SoC series Imaging Subsystem (FIMC-IS)

 Or do you intend this file to be describing also the other sub-devices,
 like GScaler ?


Probably not. WIll change it to Imaging subsystem.


 +---
 +
 +The camera subsystem on Samsung Exynos5 SoC has some changes relative
 +to previous SoC versions. Exynos5 has almost similar MIPI-CSIS and
 +FIMC-LITE IPs but has a much improved version of FIMC-IS which can
 +handle sensor controls and camera post-processing operations. The
 +Exynos5 FIMC-IS has a dedicated ARM Cortex A5 processor, many
 +post-processing blocks (ISP, DRC, FD, ODC, DIS, 3DNR) and two
 +dedicated scalers (SCC and SCP).
 +
 +fimc-is node
 +
 +
 +Required properties:
 +
 +- compatible: must be samsung,exynos5250-fimc-is
 +- reg   : physical base address and size of the memory mapped
 +  registers
 +- interrupt-parent  : Parent interrupt controller
 +- interrupts: fimc-is interrupt to the parent combiner
 +- clocks: list of clock specifiers, corresponding to entries
 in
 +  clock-names property;
 +- clock-names   : must contain isp, mcu_isp, isp_div0,
 isp_div1,
 +  isp_divmpwm, mcu_isp_div0, mcu_isp_div1
 entries,
 +  matching entries in the clocks property.
 +
 +
 +Board specific properties:
 +
 +- pinctrl-names: pinctrl names for camera port pinmux control, at
 least
 +default needs to be specified.
 +- pinctrl-0...N   : pinctrl properties corresponding to
 pinctrl-names


 What pins exactly are supposed to be covered by these properties ? For what
 devices ? Aren't the camera port pins supposed to be specified at the common
 'camera' node ? I believe the camera ports are not specific to the FIMC-IS.


These are for the sensor controls (especially clock lines).
I think I should move these to the sensor node.


 +pmu subnode
 +---
 +
 +Required properties:
 + - reg : should contain PMU physical base address and size of the memory
 + mapped registers.


 What about other devices, like ISP I2C, SPI ? Don't you want to list at
 least
 the ones currently used (I2C bus controllers) ?


The present driver doesnt make use of the SPI bus as its used only
for sensor calibration which is not yet added.
I2C bus is used by the sensor which has its own node. May be I should
explain one of the sensor nodes over here?

Regards
Arun
--
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: [RFC v2 02/10] exynos5-fimc-is: Adds fimc-is driver core files

2013-07-09 Thread Arun Kumar K
Hi Sylwester,

Will make all the changes you suggested.

Thanks and regards
Arun

On Fri, Jun 21, 2013 at 4:16 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 05/31/2013 03:03 PM, Arun Kumar K wrote:

 This driver is for the FIMC-IS IP available in Samsung Exynos5
 SoC onwards. This patch adds the core files for the new driver.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---
   drivers/media/platform/exynos5-is/fimc-is-core.c |  304
 ++
   drivers/media/platform/exynos5-is/fimc-is-core.h |  126 +
   2 files changed, 430 insertions(+)
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.c
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-core.h

 diff --git a/drivers/media/platform/exynos5-is/fimc-is-core.c
 b/drivers/media/platform/exynos5-is/fimc-is-core.c
 new file mode 100644
 index 000..d24b634
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/fimc-is-core.c
 @@ -0,0 +1,304 @@
 +/*
 + * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
 +*
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + * Arun Kumar Karun...@samsung.com
 + *
 + * 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.
 + */
 +
 +#includelinux/bug.h
 +#includelinux/ctype.h
 +#includelinux/device.h
 +#includelinux/debugfs.h
 +#includelinux/delay.h
 +#includelinux/errno.h
 +#includelinux/firmware.h
 +#includelinux/fs.h
 +#includelinux/gpio.h
 +#includelinux/interrupt.h
 +#includelinux/kernel.h
 +#includelinux/list.h
 +#includelinux/module.h
 +#includelinux/types.h
 +#includelinux/platform_device.h
 +#includelinux/pm_runtime.h
 +#includelinux/slab.h
 +#includelinux/videodev2.h
 +#includelinux/of.h
 +#includelinux/of_gpio.h
 +#includelinux/of_address.h
 +#includelinux/of_platform.h
 +#includelinux/of_irq.h
 +#includelinux/pinctrl/consumer.h
 +
 +#includemedia/v4l2-device.h
 +#includemedia/v4l2-ioctl.h
 +#includemedia/v4l2-mem2mem.h
 +#includemedia/v4l2-of.h
 +#includemedia/videobuf2-core.h
 +#includemedia/videobuf2-dma-contig.h
 +
 +#include fimc-is.h
 +
 +static char *fimc_is_clock_name[] = {
 +   [IS_CLK_ISP]= isp,
 +   [IS_CLK_MCU_ISP]= mcu_isp,
 +   [IS_CLK_ISP_DIV0]   = isp_div0,
 +   [IS_CLK_ISP_DIV1]   = isp_div1,
 +   [IS_CLK_ISP_DIVMPWM]= isp_divmpwm,
 +   [IS_CLK_MCU_ISP_DIV0]   = mcu_isp_div0,
 +   [IS_CLK_MCU_ISP_DIV1]   = mcu_isp_div1,
 +};
 +
 +static void fimc_is_clk_put(struct fimc_is *is)


 nit: fimc_is_put_clocks() would be probably a better name for this function.


 +{
 +   int i;
 +
 +   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
 +   if (IS_ERR_OR_NULL(is-clock[i]))
 +   continue;
 +   clk_unprepare(is-clock[i]);
 +   clk_put(is-clock[i]);
 +   is-clock[i] = NULL;
 +   }
 +}
 +
 +static int fimc_is_clk_get(struct fimc_is *is)


 nit: fimc_is_get_clocks() ?

 +{
 +   struct device *dev =is-pdev-dev;

 +   int i, ret;
 +
 +   for (i = 0; i  IS_CLK_MAX_NUM; i++) {
 +   is-clock[i] = clk_get(dev, fimc_is_clock_name[i]);
 +   if (IS_ERR(is-clock[i]))
 +   goto err;
 +   ret = clk_prepare(is-clock[i]);
 +   if (ret  0) {
 +   clk_put(is-clock[i]);
 +   is-clock[i] = NULL;
 +   goto err;
 +   }
 +   }
 +   return 0;
 +err:
 +   fimc_is_clk_put(is);
 +   pr_err(Failed to get clock: %s\n, fimc_is_clock_name[i]);
 +   return -ENXIO;
 +}
 +
 +static int fimc_is_clk_cfg(struct fimc_is *is)


 nit: fimc_is_configure_clocks() ?


 +{
 +   int ret;
 +
 +   ret = fimc_is_clk_get(is);
 +   if (ret)
 +   return ret;
 +
 +   /* Set rates */
 +   ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV0], 200 * 100);
 +   ret |= clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV1], 100 *
 100);
 +   ret |= clk_set_rate(is-clock[IS_CLK_ISP_DIV0], 134 * 100);
 +   ret |= clk_set_rate(is-clock[IS_CLK_ISP_DIV1], 68 * 100);
 +   ret |= clk_set_rate(is-clock[IS_CLK_ISP_DIVMPWM], 34 * 100);


 Please do not obfuscate return value like this.


 ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV0], 200 * 100);
 if (ret)

 ret = clk_set_rate(is-clock[IS_CLK_MCU_ISP_DIV1], 100 *
 100);
 ...

 And how about adding macro definitions for the frequencies, rather
 than using magic numbers in the code ?

 +   if (ret)
 +   return -EINVAL;
 +
 +   return 0;
 +}
 +
 +static int fimc_is_probe(struct platform_device *pdev)
 +{
 +   struct device *dev =pdev-dev;

 +   struct resource res;
 +   struct fimc_is *is;
 +   struct pinctrl *pctrl;
 +   void

Re: [RFC v2 03/10] exynos5-fimc-is: Adds common driver header files

2013-07-09 Thread Arun Kumar K
Hi Sylwester,

Thank you for the review.

On Fri, Jun 21, 2013 at 4:16 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 05/31/2013 03:03 PM, Arun Kumar K wrote:

 This patch adds all the common header files used by the fimc-is
 driver. It includes the commands for interfacing with the firmware
 and error codes from IS firmware, metadata and command parameter
 definitions.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---
   drivers/media/platform/exynos5-is/fimc-is-cmd.h|  201 
   drivers/media/platform/exynos5-is/fimc-is-err.h|  261 
   .../media/platform/exynos5-is/fimc-is-metadata.h   |  771 
   drivers/media/platform/exynos5-is/fimc-is-param.h  | 1259
 
   4 files changed, 2492 insertions(+)
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-cmd.h
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-err.h
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-metadata.h
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-param.h

 diff --git a/drivers/media/platform/exynos5-is/fimc-is-cmd.h
 b/drivers/media/platform/exynos5-is/fimc-is-cmd.h
 new file mode 100644
 index 000..4adf832
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/fimc-is-cmd.h
 @@ -0,0 +1,201 @@
 +/*
 + * Samsung Exynos5 SoC series FIMC-IS driver
 + *
 + * Copyright (c) 2013 Samsung Electronics Co., Ltd
 + * Kil-yeon Limkilyeon...@samsung.com
 + *
 + * 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.
 + */
 +
 +#ifndef FIMC_IS_CMD_H
 +#define FIMC_IS_CMD_H
 +
 +#define IS_COMMAND_VER 122 /* IS COMMAND VERSION 1.22 */
 +
 +enum is_cmd {
 +   /* HOST -  IS */
 +   HIC_PREVIEW_STILL = 0x1,
 +   HIC_PREVIEW_VIDEO,
 +   HIC_CAPTURE_STILL,
 +   HIC_CAPTURE_VIDEO,
 +   HIC_PROCESS_START,
 +   HIC_PROCESS_STOP,
 +   HIC_STREAM_ON,
 +   HIC_STREAM_OFF,
 +   HIC_SHOT,
 +   HIC_GET_STATIC_METADATA,
 +   HIC_SET_CAM_CONTROL,
 +   HIC_GET_CAM_CONTROL,
 +   HIC_SET_PARAMETER,
 +   HIC_GET_PARAMETER,
 +   HIC_SET_A5_MEM_ACCESS,
 +   RESERVED2,
 +   HIC_GET_STATUS,
 +   /* SENSOR PART*/
 +   HIC_OPEN_SENSOR,
 +   HIC_CLOSE_SENSOR,
 +   HIC_SIMMIAN_INIT,
 +   HIC_SIMMIAN_WRITE,
 +   HIC_SIMMIAN_READ,
 +   HIC_POWER_DOWN,
 +   HIC_GET_SET_FILE_ADDR,
 +   HIC_LOAD_SET_FILE,
 +   HIC_MSG_CONFIG,
 +   HIC_MSG_TEST,
 +   /* IS -  HOST */
 +   IHC_GET_SENSOR_NUMBER = 0x1000,
 +   /* Parameter1 : Address of space to copy a setfile */
 +   /* Parameter2 : Space szie */
 +   IHC_SET_SHOT_MARK,
 +   /* PARAM1 : a frame number */
 +   /* PARAM2 : confidence level(smile 0~100) */
 +   /* PARMA3 : confidence level(blink 0~100) */
 +   IHC_SET_FACE_MARK,
 +   /* PARAM1 : coordinate count */
 +   /* PARAM2 : coordinate buffer address */
 +   IHC_FRAME_DONE,
 +   /* PARAM1 : frame start number */
 +   /* PARAM2 : frame count */
 +   IHC_AA_DONE,
 +   IHC_NOT_READY,
 +   IHC_FLASH_READY
 +};
 +
 +enum is_reply {
 +   ISR_DONE= 0x2000,
 +   ISR_NDONE
 +};
 +
 +enum is_scenario_id {
 +   ISS_PREVIEW_STILL,
 +   ISS_PREVIEW_VIDEO,
 +   ISS_CAPTURE_STILL,
 +   ISS_CAPTURE_VIDEO,
 +   ISS_END
 +};
 +
 +enum is_subscenario_id {
 +   ISS_SUB_SCENARIO_STILL,
 +   ISS_SUB_SCENARIO_VIDEO,
 +   ISS_SUB_SCENARIO_SCENE1,
 +   ISS_SUB_SCENARIO_SCENE2,
 +   ISS_SUB_SCENARIO_SCENE3,
 +   ISS_SUB_END
 +};
 +
 +struct is_setfile_header_element {
 +   u32 binary_addr;
 +   u32 binary_size;
 +};
 +
 +struct is_setfile_header {
 +   struct is_setfile_header_element isp[ISS_END];
 +   struct is_setfile_header_element drc[ISS_END];
 +   struct is_setfile_header_element fd[ISS_END];
 +};
 +
 +struct is_common_reg {
 +   u32 hicmd;
 +   u32 hic_sensorid;
 +   u32 hic_param1;
 +   u32 hic_param2;
 +   u32 hic_param3;
 +   u32 hic_param4;


 How about replacing the above 4 fields with

 u32 hic_param[4];

 ?

Ok.


 +   u32 reserved1[3];
 +
 +   u32 ihcmd_iflag;
 +   u32 ihcmd;
 +   u32 ihc_sensorid;
 +   u32 ihc_param1;
 +   u32 ihc_param2;
 +   u32 ihc_param3;
 +   u32 ihc_param4;


 Similarly,

 u32 ihc_param[4];

 and for other groups of fields below ?


Will make this change.

 +
 +   u32 reserved2[3];
 +
 +   u32 isp_bayer_iflag;
 +   u32 isp_bayer_sensor_id;
 diff --git a/drivers/media/platform/exynos5-is/fimc-is-err.h
 b/drivers/media/platform/exynos5-is/fimc-is-err.h
 new file mode 100644
 index 000..49d7cf5
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/fimc-is-err.h
 @@ -0,0 +1,261 @@
 +/*
 + * Samsung Exynos5 SoC series FIMC

Re: [RFC v2 09/10] exynos5-fimc-is: Adds the hardware interface module

2013-07-09 Thread Arun Kumar K
Hi Andrzej,

Thank you for the review.

On Fri, Jun 21, 2013 at 4:53 PM, Andrzej Hajda a.ha...@samsung.com wrote:
 Hi Arun,

 My few comments.

 On 05/31/2013 03:03 PM, Arun Kumar K wrote:
 The hardware interface module finally sends the commands to the
 FIMC-IS firmware and runs the interrupt handler for getting the
 responses.

 Signed-off-by: Arun Kumar K arun...@samsung.com
 Signed-off-by: Kilyeon Im kilyeon...@samsung.com
 ---
  .../media/platform/exynos5-is/fimc-is-interface.c  | 1025 
 
  .../media/platform/exynos5-is/fimc-is-interface.h  |  131 +++
  2 files changed, 1156 insertions(+)
  create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.c
  create mode 100644 drivers/media/platform/exynos5-is/fimc-is-interface.h

 diff --git a/drivers/media/platform/exynos5-is/fimc-is-interface.c 
 b/drivers/media/platform/exynos5-is/fimc-is-interface.c
 new file mode 100644
 index 000..63176fa
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/fimc-is-interface.c
 @@ -0,0 +1,1025 @@
 +/*
 + * Samsung EXYNOS5 FIMC-IS (Imaging Subsystem) driver
 +*
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + * Kil-yeon Lim kilyeon...@samsung.com
 + *
 + * 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 linux/debugfs.h
 +#include linux/seq_file.h
 +#include fimc-is.h
 +#include fimc-is-cmd.h
 +#include fimc-is-regs.h
 +
 +#define init_request_barrier(itf) mutex_init(itf-request_barrier)
 +#define enter_request_barrier(itf) mutex_lock(itf-request_barrier)
 +#define exit_request_barrier(itf) mutex_unlock(itf-request_barrier)
 +
 +static inline void itf_get_cmd(struct fimc_is_interface *itf,
 + struct fimc_is_msg *msg, unsigned int index)
 +{
 + struct is_common_reg __iomem *com_regs = itf-com_regs;
 +
 + switch (index) {
 + case INTR_GENERAL:
 + msg-id = 0;
 + msg-command = com_regs-ihcmd;
 + msg-instance = com_regs-ihc_sensorid;
 + msg-parameter1 = com_regs-ihc_param1;
 + msg-parameter2 = com_regs-ihc_param2;
 + msg-parameter3 = com_regs-ihc_param3;
 + msg-parameter4 = com_regs-ihc_param4;
 + break;
 + case INTR_SCC_FDONE:
 + msg-id = 0;
 + msg-command = IHC_FRAME_DONE;
 + msg-instance = com_regs-scc_sensor_id;
 + msg-parameter1 = com_regs-scc_param1;
 + msg-parameter2 = com_regs-scc_param2;
 + msg-parameter3 = com_regs-scc_param3;
 + msg-parameter4 = 0;
 + break;
 + case INTR_SCP_FDONE:
 + msg-id = 0;
 + msg-command = IHC_FRAME_DONE;
 + msg-instance = com_regs-scp_sensor_id;
 + msg-parameter1 = com_regs-scp_param1;
 + msg-parameter2 = com_regs-scp_param2;
 + msg-parameter3 = com_regs-scp_param3;
 + msg-parameter4 = 0;
 + break;
 + case INTR_META_DONE:
 + msg-id = 0;
 + msg-command = IHC_FRAME_DONE;
 + msg-instance = com_regs-meta_sensor_id;
 + msg-parameter1 = com_regs-meta_param1;
 + msg-parameter2 = 0;
 + msg-parameter3 = 0;
 + msg-parameter4 = 0;
 + break;
 + case INTR_SHOT_DONE:
 + msg-id = 0;
 + msg-command = IHC_FRAME_DONE;
 + msg-instance = com_regs-shot_sensor_id;
 + msg-parameter1 = com_regs-shot_param1;
 + msg-parameter2 = com_regs-shot_param2;
 + msg-parameter3 = 0;
 + msg-parameter4 = 0;
 + break;
 + default:
 + msg-id = 0;
 + msg-command = 0;
 + msg-instance = 0;
 + msg-parameter1 = 0;
 + msg-parameter2 = 0;
 + msg-parameter3 = 0;
 + msg-parameter4 = 0;
 + pr_err(unknown command getting\n);
 + break;
 + }
 +}

 If you memset(msg, 0, sizeof(*msg)) at the beginning of the function,
 you can remove all zero assignements and the switch statement will
 become much shorter.


Yes will do that.

 +
 +static inline unsigned int itf_get_intr(struct fimc_is_interface *itf)
 +{
 + unsigned int status;
 + struct is_common_reg __iomem *com_regs = itf-com_regs;
 +
 + status = readl(itf-regs + INTMSR1) | com_regs-ihcmd_iflag |
 + com_regs-scc_iflag |
 + com_regs-scp_iflag |
 + com_regs-meta_iflag |
 + com_regs-shot_iflag;
 +
 + return status;
 +}
 +
 +static void itf_set_state(struct fimc_is_interface *itf,
 + unsigned long state)
 +{
 + unsigned long flags;
 + spin_lock_irqsave(itf-slock_state, flags);
 + __set_bit(state, itf-state);
 + spin_unlock_irqrestore(itf-slock_state, flags);
 +}
 +
 +static void

Re: [RFC v2 07/10] exynos5-fimc-is: Adds scaler subdev

2013-07-09 Thread Arun Kumar K
Hi Hans,

Thank you for the review.

On Wed, Jun 26, 2013 at 12:43 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 On Fri May 31 2013 15:03:25 Arun Kumar K wrote:
 FIMC-IS has two hardware scalers named as scaler-codec and
 scaler-preview. This patch adds the common code handling the
 video nodes and subdevs of both the scalers.

 Signed-off-by: Arun Kumar K arun...@samsung.com
 Signed-off-by: Kilyeon Im kilyeon...@samsung.com
 ---
  drivers/media/platform/exynos5-is/fimc-is-scaler.c |  492 
 
  drivers/media/platform/exynos5-is/fimc-is-scaler.h |  107 +
  2 files changed, 599 insertions(+)
  create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.c
  create mode 100644 drivers/media/platform/exynos5-is/fimc-is-scaler.h

 diff --git a/drivers/media/platform/exynos5-is/fimc-is-scaler.c 
 b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
 new file mode 100644
 index 000..b4f3f5c
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/fimc-is-scaler.c
 @@ -0,0 +1,492 @@
 +/*
 + * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
 + *
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + *  Arun Kumar K arun...@samsung.com
 + *
 + * 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 media/v4l2-ioctl.h
 +#include media/videobuf2-dma-contig.h
 +
 +#include fimc-is.h
 +
 +#define IS_SCALER_DRV_NAME fimc-is-scaler
 +
 +static const struct fimc_is_fmt formats[] = {
 + {
 + .name   = YUV 4:2:0 3p MultiPlanar,
 + .fourcc = V4L2_PIX_FMT_YUV420M,
 + .depth  = {8, 2, 2},
 + .num_planes = 3,
 + },
 + {
 + .name   = YUV 4:2:0 2p MultiPlanar,
 + .fourcc = V4L2_PIX_FMT_NV12M,
 + .depth  = {8, 4},
 + .num_planes = 2,
 + },
 + {
 + .name   = YUV 4:2:2 1p MultiPlanar,
 + .fourcc = V4L2_PIX_FMT_NV16,
 + .depth  = {16},
 + .num_planes = 1,
 + },
 +};
 +#define NUM_FORMATS ARRAY_SIZE(formats)
 +
 +static struct fimc_is_fmt *find_format(struct v4l2_format *f)
 +{
 + unsigned int i;
 +
 + for (i = 0; i  NUM_FORMATS; i++) {
 + if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
 + return (struct fimc_is_fmt *) formats[i];
 + }
 + return NULL;
 +}
 +
 +static int scaler_video_capture_start_streaming(struct vb2_queue *vq,
 + unsigned int count)
 +{
 + struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
 + int ret;
 +
 + /* Scaler start */
 + ret = fimc_is_pipeline_scaler_start(ctx-pipeline,
 + ctx-scaler_id,
 + (unsigned int **)ctx-buf_paddr,
 + ctx-num_buffers,
 + ctx-fmt-num_planes);
 + if (ret) {
 + pr_err(Scaler start failed.\n);
 + return -EINVAL;
 + }
 +
 + set_bit(STATE_RUNNING, ctx-capture_state);
 + return 0;
 +}
 +
 +static int scaler_video_capture_stop_streaming(struct vb2_queue *vq)
 +{
 + struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
 + int ret;
 +
 + /* Scaler stop */
 + ret = fimc_is_pipeline_scaler_stop(ctx-pipeline, ctx-scaler_id);
 + if (ret)
 + pr_debug(Scaler already stopped.\n);
 +
 + clear_bit(STATE_RUNNING, ctx-capture_state);
 + return 0;
 +}
 +
 +static int scaler_video_capture_queue_setup(struct vb2_queue *vq,
 + const struct v4l2_format *pfmt,
 + unsigned int *num_buffers, unsigned int *num_planes,
 + unsigned int sizes[], void *allocators[])
 +{
 + struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
 + struct fimc_is_fmt *fmt = ctx-fmt;
 + unsigned int wh;
 + int i;
 +
 + if (!fmt)
 + return -EINVAL;
 +
 + *num_planes = fmt-num_planes;
 + wh = ctx-width * ctx-height;
 +
 + for (i = 0; i  *num_planes; i++) {
 + allocators[i] = ctx-alloc_ctx;
 + sizes[i] = (wh * fmt-depth[i]) / 8;
 + }
 + return 0;
 +}
 +
 +static int scaler_video_capture_buffer_init(struct vb2_buffer *vb)
 +{
 + struct vb2_queue *vq = vb-vb2_queue;
 + struct fimc_is_scaler *ctx = vb2_get_drv_priv(vq);
 + struct fimc_is_buf *buf;
 + struct fimc_is_fmt *fmt;
 + int i;
 +
 + buf = ctx-capture_bufs[vb-v4l2_buf.index];
 + /* Initialize buffer */
 + buf-vb = vb;
 + fmt = ctx-fmt;
 + for (i = 0; i  fmt-num_planes; i++)
 + buf-paddr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
 +
 + ctx-cap_buf_cnt++;
 + return 0;
 +}
 +
 +static void scaler_video_capture_buffer_queue(struct vb2_buffer *vb)
 +{
 + struct vb2_queue *vq = vb-vb2_queue;
 + struct

Re: [RFC v2 06/10] exynos5-fimc-is: Adds isp subdev

2013-07-09 Thread Arun Kumar K
Hi Sylwester,

On Fri, Jun 21, 2013 at 4:55 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 05/31/2013 03:03 PM, Arun Kumar K wrote:

 fimc-is driver takes video data input from the ISP video node
 which is added in this patch. This node accepts Bayer input
 buffers which is given from the IS sensors.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---
   drivers/media/platform/exynos5-is/fimc-is-isp.c |  438
 +++
   drivers/media/platform/exynos5-is/fimc-is-isp.h |   89 +
   2 files changed, 527 insertions(+)
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.c
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.h

 diff --git a/drivers/media/platform/exynos5-is/fimc-is-isp.c
 b/drivers/media/platform/exynos5-is/fimc-is-isp.c
 new file mode 100644
 index 000..2890f17
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/fimc-is-isp.c
 @@ -0,0 +1,438 @@
 +/*
 + * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
 + *
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + *  Arun Kumar Karun...@samsung.com
 + *
 + * 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.
 + */
 +
 +#includemedia/v4l2-ioctl.h
 +#includemedia/videobuf2-dma-contig.h
 +
 +#include fimc-is.h
 +
 +#define ISP_DRV_NAME fimc-is-isp
 +
 +static const struct fimc_is_fmt formats[] = {
 +   {
 +   .name   = Bayer GR-BG 8bits,
 +   .fourcc = V4L2_PIX_FMT_SGRBG8,
 +   .depth  = {8},


 Please add spaces betwen {} and the number.


Ok


 +   .num_planes = 1,
 +   },
 +   {
 +   .name   = Bayer GR-BG 10bits,
 +   .fourcc = V4L2_PIX_FMT_SGRBG10,
 +   .depth  = {10},
 +   .num_planes = 1,
 +   },
 +   {
 +   .name   = Bayer GR-BG 12bits,
 +   .fourcc = V4L2_PIX_FMT_SGRBG12,
 +   .depth  = {12},
 +   .num_planes = 1,
 +   },
 +};
 +#define NUM_FORMATS ARRAY_SIZE(formats)
 +
 +static struct fimc_is_fmt *find_format(struct v4l2_format *f)


 Make the return value 'const'...


Ok


 +{
 +   unsigned int i;
 +
 +   for (i = 0; i  NUM_FORMATS; i++) {
 +   if (formats[i].fourcc == f-fmt.pix_mp.pixelformat)
 +   return (struct fimc_is_fmt *)formats[i];


 and drop the casting here.


Ok


 +   }
 +   return NULL;
 +}
 +
 +static int isp_video_output_start_streaming(struct vb2_queue *vq,
 +   unsigned int count)
 +{
 +   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
 +
 +   /* Set state to RUNNING */


 This comment doesn't add any value.


Yes :) will remove.

 +   set_bit(STATE_RUNNING,isp-output_state);

 +   return 0;
 +}
 +
 +static int isp_video_output_stop_streaming(struct vb2_queue *vq)
 +{
 +   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
 +
 +   clear_bit(STATE_RUNNING,isp-output_state);

 +   return 0;
 +}
 +
 +static int isp_video_output_queue_setup(struct vb2_queue *vq,
 +   const struct v4l2_format *pfmt,
 +   unsigned int *num_buffers, unsigned int
 *num_planes,
 +   unsigned int sizes[], void *allocators[])
 +{
 +   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
 +   struct fimc_is_fmt *fmt = isp-fmt;
 +   unsigned int wh, i;
 +
 +   if (!fmt)
 +   return -EINVAL;
 +
 +   *num_planes = fmt-num_planes;
 +   wh = isp-width * isp-height;
 +
 +   for (i = 0; i  *num_planes; i++) {
 +   allocators[i] = isp-alloc_ctx;
 +   sizes[i] = (wh * fmt-depth[i]) / 8;
 +   }
 +   return 0;
 +}
 +
 +static int isp_video_output_buffer_init(struct vb2_buffer *vb)
 +{
 +   struct vb2_queue *vq = vb-vb2_queue;
 +   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
 +   struct fimc_is_buf *buf;
 +
 +   buf =isp-output_bufs[vb-v4l2_buf.index];

 +   /* Initialize buffer */
 +   buf-vb = vb;
 +   buf-paddr[0] = vb2_dma_contig_plane_dma_addr(vb, 0);
 +   isp-out_buf_cnt++;
 +   return 0;
 +}
 +
 +static void isp_video_output_buffer_queue(struct vb2_buffer *vb)
 +{
 +   struct vb2_queue *vq = vb-vb2_queue;
 +   struct fimc_is_isp *isp = vb2_get_drv_priv(vq);
 +   struct fimc_is_buf *buf;
 +
 +   buf =isp-output_bufs[vb-v4l2_buf.index];

 +
 +   fimc_is_pipeline_buf_lock(isp-pipeline);
 +   fimc_is_isp_wait_queue_add(isp, buf);
 +   fimc_is_pipeline_buf_unlock(isp-pipeline);
 +
 +   /* Call shot command */
 +   fimc_is_pipeline_shot(isp-pipeline);
 +}
 +
 +static void isp_lock(struct vb2_queue *vq)
 +{
 +   struct fimc_is_isp *isp

Re: [RFC v2 06/10] exynos5-fimc-is: Adds isp subdev

2013-07-09 Thread Arun Kumar K
Hi Hans,

On Wed, Jun 26, 2013 at 12:45 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 On Fri May 31 2013 15:03:24 Arun Kumar K wrote:
 fimc-is driver takes video data input from the ISP video node
 which is added in this patch. This node accepts Bayer input
 buffers which is given from the IS sensors.

 Signed-off-by: Arun Kumar K arun...@samsung.com
 Signed-off-by: Kilyeon Im kilyeon...@samsung.com
 ---
  drivers/media/platform/exynos5-is/fimc-is-isp.c |  438 
 +++
  drivers/media/platform/exynos5-is/fimc-is-isp.h |   89 +
  2 files changed, 527 insertions(+)
  create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.c
  create mode 100644 drivers/media/platform/exynos5-is/fimc-is-isp.h


 The same comments I made for the scaler subdev apply here as well.

 Regards,

 Hans


Yes will take care of it in next patchset.

Thanks  Regards
Arun
--
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: [RFC v2 05/10] exynos5-fimc-is: Adds the sensor subdev

2013-07-09 Thread Arun Kumar K
Hi Sylwester,

Thank you for the review.

On Fri, Jun 21, 2013 at 4:34 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 05/31/2013 03:03 PM, Arun Kumar K wrote:

 FIMC-IS uses certain sensors which are exclusively controlled
 from the IS firmware. This patch adds the sensor subdev for the
 fimc-is sensors.

 Signed-off-by: Arun Kumar Karun...@samsung.com
 Signed-off-by: Kilyeon Imkilyeon...@samsung.com
 ---
   drivers/media/platform/exynos5-is/fimc-is-sensor.c |  463
 
   drivers/media/platform/exynos5-is/fimc-is-sensor.h |  168 +++
   2 files changed, 631 insertions(+)
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.c
   create mode 100644 drivers/media/platform/exynos5-is/fimc-is-sensor.h

 diff --git a/drivers/media/platform/exynos5-is/fimc-is-sensor.c
 b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
 new file mode 100644
 index 000..b8fb834
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/fimc-is-sensor.c
 @@ -0,0 +1,463 @@
 +/*
 + * Samsung EXYNOS5250 FIMC-IS (Imaging Subsystem) driver
 + *
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + * Arun Kumar Karun...@samsung.com
 + * Kil-yeon Limkilyeon...@samsung.com
 + *
 + * 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.
 + */
 +
 +#includelinux/gpio.h
 +#includelinux/of_gpio.h
 +#includelinux/i2c.h
 +#includelinux/of.h
 +#includelinux/of_platform.h
 +#includemedia/v4l2-of.h
 +#include fimc-is-sensor.h
 +#include fimc-is.h
 +
 +#define DRIVER_NAME fimc-is-sensor
 +
 +static char *sensor_clock_name[] = {
 +   [SCLK_BAYER]= sclk_bayer,
 +   [SCLK_CAM0] = sclk_cam0,
 +   [SCLK_CAM1] = sclk_cam1,
 +};
 +
 +/* Sensor supported formats */
 +static struct v4l2_mbus_framefmt sensor_formats[FIMC_IS_MAX_SENSORS] = {
 +   [SENSOR_S5K4E5] = {
 +   .width  = SENSOR_4E5_WIDTH + 16,
 +   .height = SENSOR_4E5_HEIGHT + 10,
 +   .code   = V4L2_MBUS_FMT_SGRBG10_1X10,
 +   .field  = V4L2_FIELD_NONE,
 +   .colorspace = V4L2_COLORSPACE_SRGB,
 +   },
 +   [SENSOR_S5K6A3] = {
 +   .width  = SENSOR_6A3_WIDTH + 16,
 +   .height = SENSOR_6A3_HEIGHT + 10,
 +   .code   = V4L2_MBUS_FMT_SGRBG10_1X10,
 +   .field  = V4L2_FIELD_NONE,
 +   .colorspace = V4L2_COLORSPACE_SRGB,
 +   },
 +};
 +
 +static struct fimc_is_sensor *sd_to_fimc_is_sensor(struct v4l2_subdev
 *sd)
 +{
 +   return container_of(sd, struct fimc_is_sensor, subdev);
 +}
 +
 +static void sensor_clk_put(struct fimc_is_sensor *sensor)
 +{
 +   int i;
 +
 +   for (i = 0; i  SCLK_MAX_NUM; i++) {
 +   if (IS_ERR(sensor-clock[i]))
 +   continue;
 +   clk_unprepare(sensor-clock[i]);
 +   clk_put(sensor-clock[i]);
 +   sensor-clock[i] = ERR_PTR(-EINVAL);
 +   }
 +}
 +
 +static int sensor_clk_init(struct fimc_is_sensor *sensor)
 +{
 +   int i, ret;
 +
 +   /* Get CAM clocks */
 +   for (i = 0; i  SCLK_MAX_NUM; i++) {
 +   sensor-clock[i] = clk_get(NULL, sensor_clock_name[i]);
 +   if (IS_ERR(sensor-clock[i]))
 +   goto err;
 +   ret = clk_prepare(sensor-clock[i]);
 +   if (ret  0) {
 +   clk_put(sensor-clock[i]);
 +   sensor-clock[i] = ERR_PTR(-EINVAL);
 +   goto err;
 +   }
 +   }
 +
 +   /* Set clock rates */
 +   ret = clk_set_rate(sensor-clock[SCLK_CAM0], 24 * 100);
 +   ret |= clk_set_rate(sensor-clock[SCLK_BAYER], 24 * 100);


 Please don't obfuscate the return value.



Ok

 +   if (ret) {
 +   pr_err(Failed to set cam clock rates\n);
 +   goto err;
 +   }
 +   return 0;
 +err:
 +   sensor_clk_put(sensor);
 +   pr_err(Failed to init sensor clock\n);
 +   return -ENXIO;


 +}
 +
 +static int sensor_clk_enable(struct fimc_is_sensor *sensor)
 +{
 +   int ret = 0, i;
 +
 +   for (i = 0; i  SCLK_MAX_NUM; i++) {
 +   ret = clk_enable(sensor-clock[i]);
 +   if (ret)
 +   return ret;
 +   }


 Oh, so you enable all clocks in this driver ? Is it really flexible
 enough ? What if one of these clocks is connected to some external
 sensor with an ISP ? Are this clocks going to be managed/exposed by
 the media device driver as well ?


I was hoping that this driver can handle all its clocks as exposed
from the DT. I can see that in exynos4, the media device enables the
cam clocks. In exynos5, there are multiple frequency settings
possible on these clocks depending on modes of operation.
So isn't it better that the sensor driver

Re: [RFC v2 05/10] exynos5-fimc-is: Adds the sensor subdev

2013-07-09 Thread Arun Kumar K
Hi Hans,

Thanks for the review.

On Wed, Jun 26, 2013 at 12:57 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 On Fri May 31 2013 15:03:23 Arun Kumar K wrote:
 FIMC-IS uses certain sensors which are exclusively controlled
 from the IS firmware. This patch adds the sensor subdev for the
 fimc-is sensors.

 Signed-off-by: Arun Kumar K arun...@samsung.com
 Signed-off-by: Kilyeon Im kilyeon...@samsung.com

 Not surprisingly I really hate the idea of sensor drivers that are tied to
 a specific SoC, since it completely destroys the reusability of such drivers.


Yes agree to it.

 I understand that you have little choice to do something special here, but
 I was wondering whether there is a way of keeping things as generic as
 possible.

 I'm just brainstorming here, but as far as I can see this driver is basically
 a partial sensor driver: it handles the clock, the format negotiation and
 power management. Any sensor driver needs that.

 What would be nice is if the fmic specific parts are replaced by callbacks
 into the bridge driver using v4l2_subdev_notify().

 The platform data (or DT) can also state if this sensor is firmware controlled
 or not. If not, then the missing bits can be implemented in the future by
 someone who needs that.

 That way the driver itself remains independent from fimc.

 And existing sensor drivers can be adapted to be usable with fimc as well by
 adding support for the notify callback.

 Would a scheme along those lines work?


Yes this should make the implementation very generic.
Will check the feasibility of this approach.

Thanks  Regards
Arun
--
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 7/8] [media] V4L: Add VP8 encoder controls

2013-07-08 Thread Arun Kumar K
Hi Hans

On Fri, Jun 28, 2013 at 7:55 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 Hi Arun,

 As promised, here is my review.


Thank you :). Sorry for the delay in response.

 I have been thinking a bit more about whether or not a VPX control class
 should be added, and in my opinion it shouldn't. These controls should be
 part of the MPEG control class, as the VPX encoder shares a lot of general
 encoding parameters, just like h264 and mpeg4.

 It is unfortunate that all the defines contain the MPEG name, and I take
 the blame for that since I came up with these defines originally.

 That said, there are some things that can be done to make it less confusing:

 - Clearly state in v4l2-controls.h and v4l2-ctrls.c that the MPEG controls
   are really Codec Controls, so not MPEG specific, and that the 'MPEG' part of
   the define is historical.

Ok will do that.


 - Currently the V4L2_CID_MPEG_CLASS name in v4l2-ctrls.c is MPEG Encoder 
 Controls.
   This should be changed to Codec Controls, since the controls in this 
 class are
   neither MPEG specific, nor are they encoder specific as there are also 
 controls
   related to the decoder.

 - Update the DocBook section for the MPEG controls accordingly: change 'MPEG' 
 in
   the text to 'Codec' and add a note explaining why all the defines are 
 prefixed
   with V4L2_CID_MPEG/V4L2_MPEG instead of _CODEC.


Ok will do these changes.

 I did toy with the idea of adding aliases in v4l2-controls.h replacing MPEG 
 with
 CODEC, but that really is too messy. I think if you can take care of the three
 points mentioned above we should be OK.

 This also means that in this patch the V4L2_CID_VPX_ prefix changes to
 V4L2_CID_MPEG_VIDEO_VPX_ as that is consistent with the current naming 
 convention
 in v4l2-controls.h: V4L2_CID_MPEG_VIDEO_H264_ASO, 
 V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL.


Ok.

 Enums use V4L2_MPEG_VIDEO_VPX_ prefix.

 Yes, I know, this will make the names quite a bit longer, but it is important 
 for
 consistency. Codecs are likely to have lots of controls since there are lots 
 of
 knobs you can tweak. So using a systematic naming scheme will prevent it from
 descending into chaos...

 On Tue June 25 2013 12:57:14 Arun Kumar K wrote:
 This patch adds new V4L controls for VP8 encoding.

 Signed-off-by: Kiran AVND avnd.ki...@samsung.com
 Signed-off-by: Arun Kumar K arun...@samsung.com
 ---
  Documentation/DocBook/media/v4l/controls.xml |  150 
 ++
  drivers/media/v4l2-core/v4l2-ctrls.c |   33 ++
  include/uapi/linux/v4l2-controls.h   |   29 -
  3 files changed, 210 insertions(+), 2 deletions(-)

 diff --git a/Documentation/DocBook/media/v4l/controls.xml 
 b/Documentation/DocBook/media/v4l/controls.xml
 index 8d7a779..736c991 100644
 --- a/Documentation/DocBook/media/v4l/controls.xml
 +++ b/Documentation/DocBook/media/v4l/controls.xml
 @@ -3009,6 +3009,156 @@ in by the application. 0 = do not insert, 1 = insert 
 packets./entry
 /tgroup
   /table
/section
 +
 +section
 +  titleVPX Control Reference/title
 +
 +  paraThe VPX controls include controls for encoding parameters
 +  of VPx video codec./para
 +
 +  table pgwide=1 frame=none id=vpx-control-id
 +  titleVPX Control IDs/title
 +
 +  tgroup cols=4
 +colspec colname=c1 colwidth=1* /
 +colspec colname=c2 colwidth=6* /
 +colspec colname=c3 colwidth=2* /
 +colspec colname=c4 colwidth=6* /
 +spanspec namest=c1 nameend=c2 spanname=id /
 +spanspec namest=c2 nameend=c4 spanname=descr /
 +thead
 +  row
 +entry spanname=id align=leftID/entry
 +entry align=leftType/entry
 +  /rowrow rowsep=1entry spanname=descr 
 align=leftDescription/entry
 +  /row
 +/thead
 +tbody valign=top
 +  rowentry/entry/row
 +
 +   rowentry/entry/row
 +   row id=v4l2-vpx-num-partitions
 + entry 
 spanname=idconstantV4L2_CID_VPX_NUM_PARTITIONS/constant/entry
 + entryenum v4l2_vp8_num_partitions/entry
 +   /row
 +   rowentry spanname=descrThe number of token partitions to 
 use in VP8 encoder.
 +Possible values are:/entry
 +   /row
 +   row
 + entrytbl spanname=descr cols=2
 +   tbody valign=top
 + row
 +   entryconstantV4L2_VPX_1_PARTITION/constant/entry
 +   entry1 coefficient partition/entry
 + /row
 + row
 +   entryconstantV4L2_VPX_2_PARTITIONS/constant/entry
 +   entry2 partitions/entry

 Add 'coefficient' for the other cases as well in the description. At least, I 
 think
 this should be '2 coefficient partitions'.


Ok.

 + /row
 + row
 +   entryconstantV4L2_VPX_4_PARTITIONS/constant/entry
 +   entry4 partitions/entry
 + /row

[PATCH v4 0/8] Add support for MFC v7 firmware

2013-07-08 Thread Arun Kumar K
This patch series adds MFC v7 firmware support to the Exynos
MFC driver. MFC v7 is present in 5420 SoC which has support
for VP8 encoding and many other features.

Changes from v3:
- Addressed review comments from Hans
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63893.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63905.html
- Addressed comments from Kamil
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63747.html

Changes from v2:
- Addressed review comments from Sylwester
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63676.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63677.html

Changes from v1:
- Addressed review comments from Hans and Sylwester
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63148.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63311.html
- Modified IS_MFCV6 macro to IS_MFCV6_PLUS to include v7 also

Arun Kumar K (7):
  [media] s5p-mfc: Update v6 encoder buffer sizes
  [media] s5p-mfc: Rename IS_MFCV6 macro
  [media] s5p-mfc: Add register definition file for MFC v7
  [media] s5p-mfc: Core support for MFC v7
  [media] s5p-mfc: Update driver for v7 firmware
  [media] V4L: Add VP8 encoder controls
  [media] s5p-mfc: Add support for VP8 encoder

Sylwester Nawrocki (1):
  [media] V4L: Add support for integer menu controls with standard menu
items

 Documentation/DocBook/media/v4l/controls.xml   |  168 +++-
 .../devicetree/bindings/media/s5p-mfc.txt  |1 +
 Documentation/video4linux/v4l2-controls.txt|   21 +--
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h   |4 +-
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h   |   61 +++
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |   32 
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c   |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c|3 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|   23 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c  |   12 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |   18 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   |  107 -
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.c   |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c|  149 +++--
 drivers/media/v4l2-core/v4l2-ctrls.c   |   67 +++-
 include/uapi/linux/v4l2-controls.h |   33 +++-
 16 files changed, 643 insertions(+), 60 deletions(-)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v7.h

-- 
1.7.9.5

--
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 v4 6/8] [media] V4L: Add support for integer menu controls with standard menu items

2013-07-08 Thread Arun Kumar K
From: Sylwester Nawrocki s.nawro...@samsung.com

The patch modifies the helper function v4l2_ctrl_new_std_menu
to accept integer menu controls with standard menu items.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/v4l2-controls.txt |   21 ++--
 drivers/media/v4l2-core/v4l2-ctrls.c|   28 ---
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/Documentation/video4linux/v4l2-controls.txt 
b/Documentation/video4linux/v4l2-controls.txt
index 676f873..06cf3ac 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -124,26 +124,27 @@ You add non-menu controls by calling v4l2_ctrl_new_std:
const struct v4l2_ctrl_ops *ops,
u32 id, s32 min, s32 max, u32 step, s32 def);
 
-Menu controls are added by calling v4l2_ctrl_new_std_menu:
+Menu and integer menu controls are added by calling v4l2_ctrl_new_std_menu:
 
struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, s32 max, s32 skip_mask, s32 def);
 
-Or alternatively for integer menu controls, by calling v4l2_ctrl_new_int_menu:
+Menu controls with a driver specific menu are added by calling
+v4l2_ctrl_new_std_menu_items:
+
+   struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(
+   struct v4l2_ctrl_handler *hdl,
+   const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
+   s32 skip_mask, s32 def, const char * const *qmenu);
+
+Integer menu controls with a driver specific menu can be added by calling
+v4l2_ctrl_new_int_menu:
 
struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, s32 max, s32 def, const s64 *qmenu_int);
 
-Standard menu controls with a driver specific menu are added by calling
-v4l2_ctrl_new_std_menu_items:
-
-   struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(
-   struct v4l2_ctrl_handler *hdl,
-   const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
-   s32 skip_mask, s32 def, const char * const *qmenu);
-
 These functions are typically called right after the v4l2_ctrl_handler_init:
 
static const s64 exp_bias_qmenu[] = {
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index fccd08b..e03a2e8 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -552,6 +552,20 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 }
 EXPORT_SYMBOL(v4l2_ctrl_get_menu);
 
+/*
+ * Returns NULL or an s64 type array containing the menu for given
+ * control ID. The total number of the menu items is returned in @len.
+ */
+const s64 const *v4l2_ctrl_get_int_menu(u32 id, u32 *len)
+{
+   switch (id) {
+   default:
+   *len = 0;
+   return NULL;
+   };
+}
+EXPORT_SYMBOL(v4l2_ctrl_get_int_menu);
+
 /* Return the control name. */
 const char *v4l2_ctrl_get_name(u32 id)
 {
@@ -1712,20 +1726,28 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct 
v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, s32 max, s32 mask, s32 def)
 {
-   const char * const *qmenu = v4l2_ctrl_get_menu(id);
+   const char * const *qmenu = NULL;
+   const s64 *qmenu_int = NULL;
const char *name;
enum v4l2_ctrl_type type;
+   unsigned int qmenu_int_len;
s32 min;
s32 step;
u32 flags;
 
v4l2_ctrl_fill(id, name, type, min, max, step, def, flags);
-   if (type != V4L2_CTRL_TYPE_MENU) {
+
+   if (type == V4L2_CTRL_TYPE_MENU)
+   qmenu = v4l2_ctrl_get_menu(id);
+   else if (type == V4L2_CTRL_TYPE_INTEGER_MENU)
+   qmenu_int = v4l2_ctrl_get_int_menu(id, qmenu_int_len);
+
+   if ((!qmenu  !qmenu_int) || (qmenu_int  max  qmenu_int_len)) {
handler_set_err(hdl, -EINVAL);
return NULL;
}
return v4l2_ctrl_new(hdl, ops, id, name, type,
-0, max, mask, def, flags, qmenu, NULL, NULL);
+0, max, mask, def, flags, qmenu, qmenu_int, NULL);
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);
 
-- 
1.7.9.5

--
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 v4 8/8] [media] s5p-mfc: Add support for VP8 encoder

2013-07-08 Thread Arun Kumar K
MFC v7 supports VP8 encoding and this patch adds support
for it in the driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c |3 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |   19 -
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   90 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   90 +++
 4 files changed, 200 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
index 5708fc3..db796c8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
@@ -108,6 +108,9 @@ static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
case S5P_MFC_CODEC_H263_ENC:
codec_type = S5P_FIMV_CODEC_H263_ENC_V6;
break;
+   case S5P_MFC_CODEC_VP8_ENC:
+   codec_type = S5P_FIMV_CODEC_VP8_ENC_V7;
+   break;
default:
codec_type = S5P_FIMV_CODEC_NONE_V6;
};
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 17545d7..6920b54 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -65,7 +65,7 @@ static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
 #define MFC_ENC_CAP_PLANE_COUNT1
 #define MFC_ENC_OUT_PLANE_COUNT2
 #define STUFF_BYTE 4
-#define MFC_MAX_CTRLS  70
+#define MFC_MAX_CTRLS  77
 
 #define S5P_MFC_CODEC_NONE -1
 #define S5P_MFC_CODEC_H264_DEC 0
@@ -81,6 +81,7 @@ static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
 #define S5P_MFC_CODEC_H264_MVC_ENC 21
 #define S5P_MFC_CODEC_MPEG4_ENC22
 #define S5P_MFC_CODEC_H263_ENC 23
+#define S5P_MFC_CODEC_VP8_ENC  24
 
 #define S5P_MFC_R2H_CMD_EMPTY  0
 #define S5P_MFC_R2H_CMD_SYS_INIT_RET   1
@@ -409,6 +410,21 @@ struct s5p_mfc_mpeg4_enc_params {
 };
 
 /**
+ * struct s5p_mfc_vp8_enc_params - encoding parameters for vp8
+ */
+struct s5p_mfc_vp8_enc_params {
+   u8 imd_4x4;
+   enum v4l2_vp8_num_partitions num_partitions;
+   enum v4l2_vp8_num_ref_frames num_ref;
+   u8 filter_level;
+   u8 filter_sharpness;
+   u32 golden_frame_ref_period;
+   enum v4l2_vp8_golden_frame_sel golden_frame_sel;
+   u8 hier_layer;
+   u8 hier_layer_qp[3];
+};
+
+/**
  * struct s5p_mfc_enc_params - general encoding parameters
  */
 struct s5p_mfc_enc_params {
@@ -442,6 +458,7 @@ struct s5p_mfc_enc_params {
struct {
struct s5p_mfc_h264_enc_params h264;
struct s5p_mfc_mpeg4_enc_params mpeg4;
+   struct s5p_mfc_vp8_enc_params vp8;
} codec;
 
 };
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 6dafe96..fb077b3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -84,6 +84,13 @@ static struct s5p_mfc_fmt formats[] = {
.type   = MFC_FMT_ENC,
.num_planes = 1,
},
+   {
+   .name   = VP8 Encoded Stream,
+   .fourcc = V4L2_PIX_FMT_VP8,
+   .codec_mode = S5P_MFC_CODEC_VP8_ENC,
+   .type   = MFC_FMT_ENC,
+   .num_planes = 1,
+   },
 };
 
 #define NUM_FORMATS ARRAY_SIZE(formats)
@@ -557,6 +564,60 @@ static struct mfc_control controls[] = {
.step = 1,
.default_value = 0,
},
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS,
+   .type = V4L2_CTRL_TYPE_INTEGER_MENU,
+   .maximum = V4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS,
+   .default_value = V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION,
+   .menu_skip_mask = 0,
+   },
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4,
+   .type = V4L2_CTRL_TYPE_BOOLEAN,
+   .minimum = 0,
+   .maximum = 1,
+   .step = 1,
+   .default_value = 0,
+   },
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES,
+   .type = V4L2_CTRL_TYPE_INTEGER_MENU,
+   .maximum = V4L2_CID_MPEG_VIDEO_VPX_2_REF_FRAME,
+   .default_value = V4L2_CID_MPEG_VIDEO_VPX_1_REF_FRAME,
+   .menu_skip_mask = 0,
+   },
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL,
+   .type = V4L2_CTRL_TYPE_INTEGER,
+   .minimum = 0,
+   .maximum = 63,
+   .step = 1,
+   .default_value = 0,
+   },
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS,
+   .type

[PATCH v4 3/8] [media] s5p-mfc: Add register definition file for MFC v7

2013-07-08 Thread Arun Kumar K
The patch adds the register definition file for new firmware
version v7 for MFC. New firmware supports VP8 encoding along with
many other features.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h |   58 ++
 1 file changed, 58 insertions(+)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v7.h

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
new file mode 100644
index 000..24dba69
--- /dev/null
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
@@ -0,0 +1,58 @@
+/*
+ * Register definition file for Samsung MFC V7.x Interface (FIMV) driver
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/
+ *
+ * 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.
+ */
+
+#ifndef _REGS_MFC_V7_H
+#define _REGS_MFC_V7_H
+
+#include regs-mfc-v6.h
+
+/* Additional features of v7 */
+#define S5P_FIMV_CODEC_VP8_ENC_V7  25
+
+/* Additional registers for v7 */
+#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V7  0xf47c
+
+#define S5P_FIMV_E_SOURCE_FIRST_ADDR_V70xf9e0
+#define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7   0xf9e4
+#define S5P_FIMV_E_SOURCE_THIRD_ADDR_V70xf9e8
+#define S5P_FIMV_E_SOURCE_FIRST_STRIDE_V7  0xf9ec
+#define S5P_FIMV_E_SOURCE_SECOND_STRIDE_V7 0xf9f0
+#define S5P_FIMV_E_SOURCE_THIRD_STRIDE_V7  0xf9f4
+
+#define S5P_FIMV_E_ENCODED_SOURCE_FIRST_ADDR_V70xfa70
+#define S5P_FIMV_E_ENCODED_SOURCE_SECOND_ADDR_V7   0xfa74
+
+#define S5P_FIMV_E_VP8_OPTIONS_V7  0xfdb0
+#define S5P_FIMV_E_VP8_FILTER_OPTIONS_V7   0xfdb4
+#define S5P_FIMV_E_VP8_GOLDEN_FRAME_OPTION_V7  0xfdb8
+#define S5P_FIMV_E_VP8_NUM_T_LAYER_V7  0xfdc4
+
+/* MFCv7 variant defines */
+#define MAX_FW_SIZE_V7 (SZ_1M) /* 1MB */
+#define MAX_CPB_SIZE_V7(3 * SZ_1M) /* 3MB */
+#define MFC_VERSION_V7 0x72
+#define MFC_NUM_PORTS_V7   1
+
+/* MFCv7 Context buffer sizes */
+#define MFC_CTX_BUF_SIZE_V7(30 * SZ_1K)/*  30KB */
+#define MFC_H264_DEC_CTX_BUF_SIZE_V7   (2 * SZ_1M) /*  2MB */
+#define MFC_OTHER_DEC_CTX_BUF_SIZE_V7  (20 * SZ_1K)/*  20KB */
+#define MFC_H264_ENC_CTX_BUF_SIZE_V7   (100 * SZ_1K)   /* 100KB */
+#define MFC_OTHER_ENC_CTX_BUF_SIZE_V7  (10 * SZ_1K)/*  10KB */
+
+/* Buffer size defines */
+#define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V7(w, h) \
+   (SZ_1M + ((w) * 144) + (8192 * (h)) + 49216)
+
+#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V7(w, h) \
+   (((w) * 48) + (((w) + 1) / 2 * 128) + 144 + 8192)
+
+#endif /*_REGS_MFC_V7_H*/
-- 
1.7.9.5

--
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 v4 5/8] [media] s5p-mfc: Update driver for v7 firmware

2013-07-08 Thread Arun Kumar K
Firmware version v7 is mostly similar to v6 in terms
of hardware specific controls and commands. So the hardware
specific opr_v6 and cmd_v6 are re-used for v7 also. This patch
updates the v6 files to handle v7 version also.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h|3 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   59 +++
 3 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
index 24dba69..ea5ec2a 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
@@ -41,6 +41,9 @@
 #define MFC_VERSION_V7 0x72
 #define MFC_NUM_PORTS_V7   1
 
+#define MFC_LUMA_PAD_BYTES_V7  256
+#define MFC_CHROMA_PAD_BYTES_V7128
+
 /* MFCv7 Context buffer sizes */
 #define MFC_CTX_BUF_SIZE_V7(30 * SZ_1K)/*  30KB */
 #define MFC_H264_DEC_CTX_BUF_SIZE_V7   (2 * SZ_1M) /*  2MB */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index f734ccc..6dafe96 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1665,6 +1665,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
 
psize[0] = ctx-luma_size;
psize[1] = ctx-chroma_size;
+
if (IS_MFCV6_PLUS(dev)) {
allocators[0] =
ctx-dev-alloc_ctx[MFC_BANK1_ALLOC_CTX];
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 7d4c5e1..3440317 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -80,6 +80,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
ctx-tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V6(mb_width, mb_height),
S5P_FIMV_TMV_BUFFER_ALIGN_V6);
+
ctx-luma_dpb_size = ALIGN((mb_width * mb_height) *
S5P_FIMV_LUMA_MB_TO_PIXEL_V6,
S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6);
@@ -112,10 +113,18 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
(ctx-mv_count * ctx-mv_size);
break;
case S5P_MFC_CODEC_MPEG4_DEC:
-   ctx-scratch_buf_size =
-   S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(
-   mb_width,
-   mb_height);
+   if (IS_MFCV7(dev)) {
+   ctx-scratch_buf_size =
+   S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V7(
+   mb_width,
+   mb_height);
+   } else {
+   ctx-scratch_buf_size =
+   S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(
+   mb_width,
+   mb_height);
+   }
+
ctx-scratch_buf_size = ALIGN(ctx-scratch_buf_size,
S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
ctx-bank1.size = ctx-scratch_buf_size;
@@ -329,6 +338,12 @@ static void s5p_mfc_enc_calc_src_size_v6(struct 
s5p_mfc_ctx *ctx)
ctx-buf_width = ALIGN(ctx-img_width, S5P_FIMV_NV12M_HALIGN_V6);
ctx-luma_size = ALIGN((mb_width * mb_height) * 256, 256);
ctx-chroma_size = ALIGN((mb_width * mb_height) * 128, 256);
+
+   /* MFCv7 needs pad bytes for Luma and Chroma */
+   if (IS_MFCV7(ctx-dev)) {
+   ctx-luma_size += MFC_LUMA_PAD_BYTES_V7;
+   ctx-chroma_size += MFC_CHROMA_PAD_BYTES_V7;
+   }
 }
 
 /* Set registers for decoding stream buffer */
@@ -453,8 +468,13 @@ static void s5p_mfc_set_enc_frame_buffer_v6(struct 
s5p_mfc_ctx *ctx,
 {
struct s5p_mfc_dev *dev = ctx-dev;
 
-   WRITEL(y_addr, S5P_FIMV_E_SOURCE_LUMA_ADDR_V6); /* 256B align */
-   WRITEL(c_addr, S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6);
+   if (IS_MFCV7(dev)) {
+   WRITEL(y_addr, S5P_FIMV_E_SOURCE_FIRST_ADDR_V7);
+   WRITEL(c_addr, S5P_FIMV_E_SOURCE_SECOND_ADDR_V7);
+   } else {
+   WRITEL(y_addr, S5P_FIMV_E_SOURCE_LUMA_ADDR_V6);
+   WRITEL(c_addr, S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6);
+   }
 
mfc_debug(2, enc src y buf addr: 0x%08lx\n, y_addr);
mfc_debug(2, enc src c buf addr: 0x%08lx\n, c_addr);
@@ -466,8 +486,13 @@ static void s5p_mfc_get_enc_frame_buffer_v6(struct 
s5p_mfc_ctx *ctx,
struct s5p_mfc_dev *dev = ctx-dev

[PATCH v4 1/8] [media] s5p-mfc: Update v6 encoder buffer sizes

2013-07-08 Thread Arun Kumar K
The patch updates few encoder buffer sizes for MFC v6.5
as per the udpdated user manual. The same buffer sizes
holds good for v7 firmware also.

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Kiran AVND avnd.ki...@samsung.com
---
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index 363a97c..2398cdf 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -374,9 +374,9 @@
 #define S5P_FIMV_NUM_PIXELS_IN_MB_COL_V6   16
 
 /* Buffer size requirements defined by hardware */
-#define S5P_FIMV_TMV_BUFFER_SIZE_V6(w, h)  (((w) + 1) * ((h) + 1) * 8)
+#define S5P_FIMV_TMV_BUFFER_SIZE_V6(w, h)  (((w) + 1) * ((h) + 3) * 8)
 #define S5P_FIMV_ME_BUFFER_SIZE_V6(imw, imh, mbw, mbh) \
-   ((DIV_ROUND_UP(imw, 64) *  DIV_ROUND_UP(imh, 64) * 256) + \
+   (imw + 127) / 64) * 16) *  DIV_ROUND_UP(imh, 64) * 256) + \
 (DIV_ROUND_UP((mbw) * (mbh), 32) * 16))
 #define S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V6(w, h)(((w) * 192) + 64)
 #define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(w, h) \
-- 
1.7.9.5

--
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 v4 7/8] [media] V4L: Add VP8 encoder controls

2013-07-08 Thread Arun Kumar K
This patch adds new V4L controls for VP8 encoding.

Signed-off-by: Kiran AVND avnd.ki...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 Documentation/DocBook/media/v4l/controls.xml |  168 +-
 drivers/media/v4l2-core/v4l2-ctrls.c |   39 +-
 include/uapi/linux/v4l2-controls.h   |   33 -
 3 files changed, 230 insertions(+), 10 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 8d7a779..4bcedbf 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -722,17 +722,22 @@ for more details./para
 /section
 
 section id=mpeg-controls
-  titleMPEG Control Reference/title
+  titleCodec Control Reference/title
 
-  paraBelow all controls within the MPEG control class are
+  paraBelow all controls within the Codec control class are
 described. First the generic controls, then controls specific for
 certain hardware./para
 
+  paraNote: These controls are applicable all codecs and
+not just MPEG. The defines are prefixed with V4L2_CID_MPEG/V4L2_MPEG
+as the controls were originally made for MPEG class and later
+extended to cover all encoding formats./para
+
   section
-   titleGeneric MPEG Controls/title
+   titleGeneric Codec Controls/title
 
table pgwide=1 frame=none id=mpeg-control-id
- titleMPEG Control IDs/title
+ titleCodec Control IDs/title
  tgroup cols=4
colspec colname=c1 colwidth=1* /
colspec colname=c2 colwidth=6* /
@@ -752,7 +757,7 @@ certain hardware./para
  row
entry 
spanname=idconstantV4L2_CID_MPEG_CLASS/constantnbsp;/entry
entryclass/entry
- /rowrowentry spanname=descrThe MPEG class
+ /rowrowentry spanname=descrThe Codec class
 descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
 description of this control class. This description can be used as the
 caption of a Tab page in a GUI, for example./entry
@@ -3009,6 +3014,159 @@ in by the application. 0 = do not insert, 1 = insert 
packets./entry
  /tgroup
/table
   /section
+
+section
+  titleVPX Control Reference/title
+
+  paraThe VPX controls include controls for encoding parameters
+  of VPx video codec./para
+
+  table pgwide=1 frame=none id=vpx-control-id
+  titleVPX Control IDs/title
+
+  tgroup cols=4
+colspec colname=c1 colwidth=1* /
+colspec colname=c2 colwidth=6* /
+colspec colname=c3 colwidth=2* /
+colspec colname=c4 colwidth=6* /
+spanspec namest=c1 nameend=c2 spanname=id /
+spanspec namest=c2 nameend=c4 spanname=descr /
+thead
+  row
+entry spanname=id align=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+
+ rowentry/entry/row
+ row id=v4l2-vpx-num-partitions
+   entry 
spanname=idconstantV4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS/constant/entry
+   entryenum v4l2_vp8_num_partitions/entry
+ /row
+ rowentry spanname=descrThe number of token partitions to 
use in VP8 encoder.
+Possible values are:/entry
+ /row
+ row
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ 
entryconstantV4L2_CID_MPEG_VIDEO_VPX_1_PARTITION/constant/entry
+ entry1 coefficient partition/entry
+   /row
+   row
+ 
entryconstantV4L2_CID_MPEG_VIDEO_VPX_2_PARTITIONS/constant/entry
+ entry2 coefficient partitions/entry
+   /row
+   row
+ 
entryconstantV4L2_CID_MPEG_VIDEO_VPX_4_PARTITIONS/constant/entry
+ entry4 coefficient partitions/entry
+   /row
+   row
+ 
entryconstantV4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS/constant/entry
+ entry8 coefficient partitions/entry
+   /row
+  /tbody
+   /entrytbl
+ /row
+
+ rowentry/entry/row
+ row
+   entry 
spanname=idconstantV4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4/constant/entry
+   entryboolean/entry
+ /row
+ rowentry spanname=descrSetting this prevents intra 4x4 mode 
in the intra mode decision./entry
+ /row
+
+ rowentry/entry/row
+ row id=v4l2-vpx-num-ref-frames
+   entry 
spanname=idconstantV4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES/constant/entry
+   entryenum v4l2_vp8_num_ref_frames/entry

[PATCH v4 2/8] [media] s5p-mfc: Rename IS_MFCV6 macro

2013-07-08 Thread Arun Kumar K
The MFC v6 specific code holds good for MFC v7 also as
the v7 version is a superset of v6 and the HW interface
remains more or less similar. This patch renames the macro
IS_MFCV6() to IS_MFCV6_PLUS() so that it can be used
for v7 also.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c|2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   12 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|   18 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   16 +---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.c|2 +-
 6 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c
index f0a41c9..242c033 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c
@@ -20,7 +20,7 @@ static struct s5p_mfc_hw_cmds *s5p_mfc_cmds;
 
 void s5p_mfc_init_hw_cmds(struct s5p_mfc_dev *dev)
 {
-   if (IS_MFCV6(dev))
+   if (IS_MFCV6_PLUS(dev))
s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v6();
else
s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v5();
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index ef4074c..d47016d 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -683,6 +683,6 @@ void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
 #define HAS_PORTNUM(dev)   (dev ? (dev-variant ? \
(dev-variant-port_num ? 1 : 0) : 0) : 0)
 #define IS_TWOPORT(dev)(dev-variant-port_num == 2 ? 1 : 0)
-#define IS_MFCV6(dev)  (dev-variant-version = 0x60 ? 1 : 0)
+#define IS_MFCV6_PLUS(dev) (dev-variant-version = 0x60 ? 1 : 0)
 
 #endif /* S5P_MFC_COMMON_H_ */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index dc1fc94..7cab684 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -164,7 +164,7 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev)
 
mfc_debug_enter();
 
-   if (IS_MFCV6(dev)) {
+   if (IS_MFCV6_PLUS(dev)) {
/* Reset IP */
/*  except RISC, reset */
mfc_write(dev, 0xFEE, S5P_FIMV_MFC_RESET_V6);
@@ -213,7 +213,7 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev)
 
 static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev)
 {
-   if (IS_MFCV6(dev)) {
+   if (IS_MFCV6_PLUS(dev)) {
mfc_write(dev, dev-bank1, S5P_FIMV_RISC_BASE_ADDRESS_V6);
mfc_debug(2, Base Address : %08x\n, dev-bank1);
} else {
@@ -226,7 +226,7 @@ static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev 
*dev)
 
 static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev)
 {
-   if (IS_MFCV6(dev)) {
+   if (IS_MFCV6_PLUS(dev)) {
/* Zero initialization should be done before RESET.
 * Nothing to do here. */
} else {
@@ -264,7 +264,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
s5p_mfc_clear_cmds(dev);
/* 3. Release reset signal to the RISC */
s5p_mfc_clean_dev_int_flags(dev);
-   if (IS_MFCV6(dev))
+   if (IS_MFCV6_PLUS(dev))
mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
@@ -301,7 +301,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
s5p_mfc_clock_off();
return -EIO;
}
-   if (IS_MFCV6(dev))
+   if (IS_MFCV6_PLUS(dev))
ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
else
ver = mfc_read(dev, S5P_FIMV_FW_VERSION);
@@ -380,7 +380,7 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
return ret;
}
/* 4. Release reset signal to the RISC */
-   if (IS_MFCV6(dev))
+   if (IS_MFCV6_PLUS(dev))
mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 00b0703..56a1d3b 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -382,7 +382,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, 
struct v4l2_format *f)
mfc_err(Unsupported format for source.\n);
return -EINVAL;
}
-   if (!IS_MFCV6(dev)  (fmt-fourcc == V4L2_PIX_FMT_VP8)) {
+   if (!IS_MFCV6_PLUS(dev)  (fmt-fourcc == V4L2_PIX_FMT_VP8)) {
mfc_err(Not supported format.\n);
return -EINVAL

[PATCH v4 4/8] [media] s5p-mfc: Core support for MFC v7

2013-07-08 Thread Arun Kumar K
Adds variant data and core support for the MFC v7 firmware

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 .../devicetree/bindings/media/s5p-mfc.txt  |1 +
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |   32 
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|2 ++
 3 files changed, 35 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/s5p-mfc.txt 
b/Documentation/devicetree/bindings/media/s5p-mfc.txt
index 67ec3d4..cb9c5bc 100644
--- a/Documentation/devicetree/bindings/media/s5p-mfc.txt
+++ b/Documentation/devicetree/bindings/media/s5p-mfc.txt
@@ -10,6 +10,7 @@ Required properties:
   - compatible : value should be either one among the following
(a) samsung,mfc-v5 for MFC v5 present in Exynos4 SoCs
(b) samsung,mfc-v6 for MFC v6 present in Exynos5 SoCs
+   (b) samsung,mfc-v7 for MFC v7 present in Exynos5420 SoC
 
   - reg : Physical base address of the IP registers and length of memory
  mapped region.
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index d12faa6..d6be52f 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1391,6 +1391,32 @@ static struct s5p_mfc_variant mfc_drvdata_v6 = {
.fw_name= s5p-mfc-v6.fw,
 };
 
+struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
+   .dev_ctx= MFC_CTX_BUF_SIZE_V7,
+   .h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V7,
+   .other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V7,
+   .h264_enc_ctx   = MFC_H264_ENC_CTX_BUF_SIZE_V7,
+   .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V7,
+};
+
+struct s5p_mfc_buf_size buf_size_v7 = {
+   .fw = MAX_FW_SIZE_V7,
+   .cpb= MAX_CPB_SIZE_V7,
+   .priv   = mfc_buf_size_v7,
+};
+
+struct s5p_mfc_buf_align mfc_buf_align_v7 = {
+   .base = 0,
+};
+
+static struct s5p_mfc_variant mfc_drvdata_v7 = {
+   .version= MFC_VERSION_V7,
+   .port_num   = MFC_NUM_PORTS_V7,
+   .buf_size   = buf_size_v7,
+   .buf_align  = mfc_buf_align_v7,
+   .fw_name= s5p-mfc-v7.fw,
+};
+
 static struct platform_device_id mfc_driver_ids[] = {
{
.name = s5p-mfc,
@@ -1401,6 +1427,9 @@ static struct platform_device_id mfc_driver_ids[] = {
}, {
.name = s5p-mfc-v6,
.driver_data = (unsigned long)mfc_drvdata_v6,
+   }, {
+   .name = s5p-mfc-v7,
+   .driver_data = (unsigned long)mfc_drvdata_v7,
},
{},
 };
@@ -1413,6 +1442,9 @@ static const struct of_device_id exynos_mfc_match[] = {
}, {
.compatible = samsung,mfc-v6,
.data = mfc_drvdata_v6,
+   }, {
+   .compatible = samsung,mfc-v7,
+   .data = mfc_drvdata_v7,
},
{},
 };
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index d47016d..17545d7 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -24,6 +24,7 @@
 #include media/videobuf2-core.h
 #include regs-mfc.h
 #include regs-mfc-v6.h
+#include regs-mfc-v7.h
 
 /* Definitions related to MFC memory */
 
@@ -684,5 +685,6 @@ void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
(dev-variant-port_num ? 1 : 0) : 0) : 0)
 #define IS_TWOPORT(dev)(dev-variant-port_num == 2 ? 1 : 0)
 #define IS_MFCV6_PLUS(dev) (dev-variant-version = 0x60 ? 1 : 0)
+#define IS_MFCV7(dev)  (dev-variant-version = 0x70 ? 1 : 0)
 
 #endif /* S5P_MFC_COMMON_H_ */
-- 
1.7.9.5

--
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 v4 7/8] [media] V4L: Add VP8 encoder controls

2013-07-08 Thread Arun Kumar K
Hi Hans,

On Mon, Jul 8, 2013 at 6:21 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 Hi Arun,

 A few small comments below. After fixing that you can add my:

 Acked-by: Hans Verkuil hans.verk...@cisco.com

 for this patch.


Thank you for your review. Will post the updated patch with your ack.

Regards
Arun
--
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 v5 1/8] [media] s5p-mfc: Update v6 encoder buffer sizes

2013-07-08 Thread Arun Kumar K
The patch updates few encoder buffer sizes for MFC v6.5
as per the udpdated user manual. The same buffer sizes
holds good for v7 firmware also.

Signed-off-by: Kiran AVND avnd.ki...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index 363a97c..2398cdf 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -374,9 +374,9 @@
 #define S5P_FIMV_NUM_PIXELS_IN_MB_COL_V6   16
 
 /* Buffer size requirements defined by hardware */
-#define S5P_FIMV_TMV_BUFFER_SIZE_V6(w, h)  (((w) + 1) * ((h) + 1) * 8)
+#define S5P_FIMV_TMV_BUFFER_SIZE_V6(w, h)  (((w) + 1) * ((h) + 3) * 8)
 #define S5P_FIMV_ME_BUFFER_SIZE_V6(imw, imh, mbw, mbh) \
-   ((DIV_ROUND_UP(imw, 64) *  DIV_ROUND_UP(imh, 64) * 256) + \
+   (imw + 127) / 64) * 16) *  DIV_ROUND_UP(imh, 64) * 256) + \
 (DIV_ROUND_UP((mbw) * (mbh), 32) * 16))
 #define S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V6(w, h)(((w) * 192) + 64)
 #define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(w, h) \
-- 
1.7.9.5

--
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 v5 2/8] [media] s5p-mfc: Rename IS_MFCV6 macro

2013-07-08 Thread Arun Kumar K
The MFC v6 specific code holds good for MFC v7 also as
the v7 version is a superset of v6 and the HW interface
remains more or less similar. This patch renames the macro
IS_MFCV6() to IS_MFCV6_PLUS() so that it can be used
for v7 also.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c|2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   12 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|   18 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   16 +---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.c|2 +-
 6 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c
index f0a41c9..242c033 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c
@@ -20,7 +20,7 @@ static struct s5p_mfc_hw_cmds *s5p_mfc_cmds;
 
 void s5p_mfc_init_hw_cmds(struct s5p_mfc_dev *dev)
 {
-   if (IS_MFCV6(dev))
+   if (IS_MFCV6_PLUS(dev))
s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v6();
else
s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v5();
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index ef4074c..d47016d 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -683,6 +683,6 @@ void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
 #define HAS_PORTNUM(dev)   (dev ? (dev-variant ? \
(dev-variant-port_num ? 1 : 0) : 0) : 0)
 #define IS_TWOPORT(dev)(dev-variant-port_num == 2 ? 1 : 0)
-#define IS_MFCV6(dev)  (dev-variant-version = 0x60 ? 1 : 0)
+#define IS_MFCV6_PLUS(dev) (dev-variant-version = 0x60 ? 1 : 0)
 
 #endif /* S5P_MFC_COMMON_H_ */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index dc1fc94..7cab684 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -164,7 +164,7 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev)
 
mfc_debug_enter();
 
-   if (IS_MFCV6(dev)) {
+   if (IS_MFCV6_PLUS(dev)) {
/* Reset IP */
/*  except RISC, reset */
mfc_write(dev, 0xFEE, S5P_FIMV_MFC_RESET_V6);
@@ -213,7 +213,7 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev)
 
 static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev)
 {
-   if (IS_MFCV6(dev)) {
+   if (IS_MFCV6_PLUS(dev)) {
mfc_write(dev, dev-bank1, S5P_FIMV_RISC_BASE_ADDRESS_V6);
mfc_debug(2, Base Address : %08x\n, dev-bank1);
} else {
@@ -226,7 +226,7 @@ static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev 
*dev)
 
 static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev)
 {
-   if (IS_MFCV6(dev)) {
+   if (IS_MFCV6_PLUS(dev)) {
/* Zero initialization should be done before RESET.
 * Nothing to do here. */
} else {
@@ -264,7 +264,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
s5p_mfc_clear_cmds(dev);
/* 3. Release reset signal to the RISC */
s5p_mfc_clean_dev_int_flags(dev);
-   if (IS_MFCV6(dev))
+   if (IS_MFCV6_PLUS(dev))
mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
@@ -301,7 +301,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
s5p_mfc_clock_off();
return -EIO;
}
-   if (IS_MFCV6(dev))
+   if (IS_MFCV6_PLUS(dev))
ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
else
ver = mfc_read(dev, S5P_FIMV_FW_VERSION);
@@ -380,7 +380,7 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
return ret;
}
/* 4. Release reset signal to the RISC */
-   if (IS_MFCV6(dev))
+   if (IS_MFCV6_PLUS(dev))
mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 00b0703..56a1d3b 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -382,7 +382,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, 
struct v4l2_format *f)
mfc_err(Unsupported format for source.\n);
return -EINVAL;
}
-   if (!IS_MFCV6(dev)  (fmt-fourcc == V4L2_PIX_FMT_VP8)) {
+   if (!IS_MFCV6_PLUS(dev)  (fmt-fourcc == V4L2_PIX_FMT_VP8)) {
mfc_err(Not supported format.\n);
return -EINVAL

[PATCH v5 3/8] [media] s5p-mfc: Add register definition file for MFC v7

2013-07-08 Thread Arun Kumar K
The patch adds the register definition file for new firmware
version v7 for MFC. New firmware supports VP8 encoding along with
many other features.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h |   58 ++
 1 file changed, 58 insertions(+)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v7.h

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
new file mode 100644
index 000..24dba69
--- /dev/null
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
@@ -0,0 +1,58 @@
+/*
+ * Register definition file for Samsung MFC V7.x Interface (FIMV) driver
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/
+ *
+ * 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.
+ */
+
+#ifndef _REGS_MFC_V7_H
+#define _REGS_MFC_V7_H
+
+#include regs-mfc-v6.h
+
+/* Additional features of v7 */
+#define S5P_FIMV_CODEC_VP8_ENC_V7  25
+
+/* Additional registers for v7 */
+#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V7  0xf47c
+
+#define S5P_FIMV_E_SOURCE_FIRST_ADDR_V70xf9e0
+#define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7   0xf9e4
+#define S5P_FIMV_E_SOURCE_THIRD_ADDR_V70xf9e8
+#define S5P_FIMV_E_SOURCE_FIRST_STRIDE_V7  0xf9ec
+#define S5P_FIMV_E_SOURCE_SECOND_STRIDE_V7 0xf9f0
+#define S5P_FIMV_E_SOURCE_THIRD_STRIDE_V7  0xf9f4
+
+#define S5P_FIMV_E_ENCODED_SOURCE_FIRST_ADDR_V70xfa70
+#define S5P_FIMV_E_ENCODED_SOURCE_SECOND_ADDR_V7   0xfa74
+
+#define S5P_FIMV_E_VP8_OPTIONS_V7  0xfdb0
+#define S5P_FIMV_E_VP8_FILTER_OPTIONS_V7   0xfdb4
+#define S5P_FIMV_E_VP8_GOLDEN_FRAME_OPTION_V7  0xfdb8
+#define S5P_FIMV_E_VP8_NUM_T_LAYER_V7  0xfdc4
+
+/* MFCv7 variant defines */
+#define MAX_FW_SIZE_V7 (SZ_1M) /* 1MB */
+#define MAX_CPB_SIZE_V7(3 * SZ_1M) /* 3MB */
+#define MFC_VERSION_V7 0x72
+#define MFC_NUM_PORTS_V7   1
+
+/* MFCv7 Context buffer sizes */
+#define MFC_CTX_BUF_SIZE_V7(30 * SZ_1K)/*  30KB */
+#define MFC_H264_DEC_CTX_BUF_SIZE_V7   (2 * SZ_1M) /*  2MB */
+#define MFC_OTHER_DEC_CTX_BUF_SIZE_V7  (20 * SZ_1K)/*  20KB */
+#define MFC_H264_ENC_CTX_BUF_SIZE_V7   (100 * SZ_1K)   /* 100KB */
+#define MFC_OTHER_ENC_CTX_BUF_SIZE_V7  (10 * SZ_1K)/*  10KB */
+
+/* Buffer size defines */
+#define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V7(w, h) \
+   (SZ_1M + ((w) * 144) + (8192 * (h)) + 49216)
+
+#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V7(w, h) \
+   (((w) * 48) + (((w) + 1) / 2 * 128) + 144 + 8192)
+
+#endif /*_REGS_MFC_V7_H*/
-- 
1.7.9.5

--
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 v5 0/8] Add support for MFC v7 firmware

2013-07-08 Thread Arun Kumar K
This patch series adds MFC v7 firmware support to the Exynos
MFC driver. MFC v7 is present in 5420 SoC which has support
for VP8 encoding and many other features.

Changes from v4:
- Addressed review comments from Hans and added ack
http://www.mail-archive.com/linux-media@vger.kernel.org/msg64101.html

Changes from v3:
- Addressed review comments from Hans
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63893.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63905.html
- Addressed comments from Kamil
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63747.html

Changes from v2:
- Addressed review comments from Sylwester
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63676.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63677.html

Changes from v1:
- Addressed review comments from Hans and Sylwester
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63148.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg63311.html
- Modified IS_MFCV6 macro to IS_MFCV6_PLUS to include v7 also

Arun Kumar K (7):
  [media] s5p-mfc: Update v6 encoder buffer sizes
  [media] s5p-mfc: Rename IS_MFCV6 macro
  [media] s5p-mfc: Add register definition file for MFC v7
  [media] s5p-mfc: Core support for MFC v7
  [media] s5p-mfc: Update driver for v7 firmware
  [media] V4L: Add VP8 encoder controls
  [media] s5p-mfc: Add support for VP8 encoder

Sylwester Nawrocki (1):
  [media] V4L: Add support for integer menu controls with standard menu
items

 Documentation/DocBook/media/v4l/controls.xml   |  168 +++-
 .../devicetree/bindings/media/s5p-mfc.txt  |1 +
 Documentation/video4linux/v4l2-controls.txt|   21 +--
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h   |4 +-
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h   |   61 +++
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |   32 
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c   |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c|3 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|   23 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c  |   12 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |   18 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   |  107 -
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.c   |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c|  149 +++--
 drivers/media/v4l2-core/v4l2-ctrls.c   |   67 +++-
 include/uapi/linux/v4l2-controls.h |   29 
 16 files changed, 642 insertions(+), 57 deletions(-)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v7.h

-- 
1.7.9.5

--
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 v5 5/8] [media] s5p-mfc: Update driver for v7 firmware

2013-07-08 Thread Arun Kumar K
Firmware version v7 is mostly similar to v6 in terms
of hardware specific controls and commands. So the hardware
specific opr_v6 and cmd_v6 are re-used for v7 also. This patch
updates the v6 files to handle v7 version also.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h|3 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   59 +++
 3 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
index 24dba69..ea5ec2a 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
@@ -41,6 +41,9 @@
 #define MFC_VERSION_V7 0x72
 #define MFC_NUM_PORTS_V7   1
 
+#define MFC_LUMA_PAD_BYTES_V7  256
+#define MFC_CHROMA_PAD_BYTES_V7128
+
 /* MFCv7 Context buffer sizes */
 #define MFC_CTX_BUF_SIZE_V7(30 * SZ_1K)/*  30KB */
 #define MFC_H264_DEC_CTX_BUF_SIZE_V7   (2 * SZ_1M) /*  2MB */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index f734ccc..6dafe96 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1665,6 +1665,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
 
psize[0] = ctx-luma_size;
psize[1] = ctx-chroma_size;
+
if (IS_MFCV6_PLUS(dev)) {
allocators[0] =
ctx-dev-alloc_ctx[MFC_BANK1_ALLOC_CTX];
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 7d4c5e1..3440317 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -80,6 +80,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
ctx-tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V6(mb_width, mb_height),
S5P_FIMV_TMV_BUFFER_ALIGN_V6);
+
ctx-luma_dpb_size = ALIGN((mb_width * mb_height) *
S5P_FIMV_LUMA_MB_TO_PIXEL_V6,
S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6);
@@ -112,10 +113,18 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
(ctx-mv_count * ctx-mv_size);
break;
case S5P_MFC_CODEC_MPEG4_DEC:
-   ctx-scratch_buf_size =
-   S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(
-   mb_width,
-   mb_height);
+   if (IS_MFCV7(dev)) {
+   ctx-scratch_buf_size =
+   S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V7(
+   mb_width,
+   mb_height);
+   } else {
+   ctx-scratch_buf_size =
+   S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(
+   mb_width,
+   mb_height);
+   }
+
ctx-scratch_buf_size = ALIGN(ctx-scratch_buf_size,
S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
ctx-bank1.size = ctx-scratch_buf_size;
@@ -329,6 +338,12 @@ static void s5p_mfc_enc_calc_src_size_v6(struct 
s5p_mfc_ctx *ctx)
ctx-buf_width = ALIGN(ctx-img_width, S5P_FIMV_NV12M_HALIGN_V6);
ctx-luma_size = ALIGN((mb_width * mb_height) * 256, 256);
ctx-chroma_size = ALIGN((mb_width * mb_height) * 128, 256);
+
+   /* MFCv7 needs pad bytes for Luma and Chroma */
+   if (IS_MFCV7(ctx-dev)) {
+   ctx-luma_size += MFC_LUMA_PAD_BYTES_V7;
+   ctx-chroma_size += MFC_CHROMA_PAD_BYTES_V7;
+   }
 }
 
 /* Set registers for decoding stream buffer */
@@ -453,8 +468,13 @@ static void s5p_mfc_set_enc_frame_buffer_v6(struct 
s5p_mfc_ctx *ctx,
 {
struct s5p_mfc_dev *dev = ctx-dev;
 
-   WRITEL(y_addr, S5P_FIMV_E_SOURCE_LUMA_ADDR_V6); /* 256B align */
-   WRITEL(c_addr, S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6);
+   if (IS_MFCV7(dev)) {
+   WRITEL(y_addr, S5P_FIMV_E_SOURCE_FIRST_ADDR_V7);
+   WRITEL(c_addr, S5P_FIMV_E_SOURCE_SECOND_ADDR_V7);
+   } else {
+   WRITEL(y_addr, S5P_FIMV_E_SOURCE_LUMA_ADDR_V6);
+   WRITEL(c_addr, S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6);
+   }
 
mfc_debug(2, enc src y buf addr: 0x%08lx\n, y_addr);
mfc_debug(2, enc src c buf addr: 0x%08lx\n, c_addr);
@@ -466,8 +486,13 @@ static void s5p_mfc_get_enc_frame_buffer_v6(struct 
s5p_mfc_ctx *ctx,
struct s5p_mfc_dev *dev = ctx-dev

[PATCH v5 8/8] [media] s5p-mfc: Add support for VP8 encoder

2013-07-08 Thread Arun Kumar K
MFC v7 supports VP8 encoding and this patch adds support
for it in the driver.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c |3 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |   19 -
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   90 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   90 +++
 4 files changed, 200 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
index 5708fc3..db796c8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
@@ -108,6 +108,9 @@ static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
case S5P_MFC_CODEC_H263_ENC:
codec_type = S5P_FIMV_CODEC_H263_ENC_V6;
break;
+   case S5P_MFC_CODEC_VP8_ENC:
+   codec_type = S5P_FIMV_CODEC_VP8_ENC_V7;
+   break;
default:
codec_type = S5P_FIMV_CODEC_NONE_V6;
};
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 17545d7..6920b54 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -65,7 +65,7 @@ static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
 #define MFC_ENC_CAP_PLANE_COUNT1
 #define MFC_ENC_OUT_PLANE_COUNT2
 #define STUFF_BYTE 4
-#define MFC_MAX_CTRLS  70
+#define MFC_MAX_CTRLS  77
 
 #define S5P_MFC_CODEC_NONE -1
 #define S5P_MFC_CODEC_H264_DEC 0
@@ -81,6 +81,7 @@ static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
 #define S5P_MFC_CODEC_H264_MVC_ENC 21
 #define S5P_MFC_CODEC_MPEG4_ENC22
 #define S5P_MFC_CODEC_H263_ENC 23
+#define S5P_MFC_CODEC_VP8_ENC  24
 
 #define S5P_MFC_R2H_CMD_EMPTY  0
 #define S5P_MFC_R2H_CMD_SYS_INIT_RET   1
@@ -409,6 +410,21 @@ struct s5p_mfc_mpeg4_enc_params {
 };
 
 /**
+ * struct s5p_mfc_vp8_enc_params - encoding parameters for vp8
+ */
+struct s5p_mfc_vp8_enc_params {
+   u8 imd_4x4;
+   enum v4l2_vp8_num_partitions num_partitions;
+   enum v4l2_vp8_num_ref_frames num_ref;
+   u8 filter_level;
+   u8 filter_sharpness;
+   u32 golden_frame_ref_period;
+   enum v4l2_vp8_golden_frame_sel golden_frame_sel;
+   u8 hier_layer;
+   u8 hier_layer_qp[3];
+};
+
+/**
  * struct s5p_mfc_enc_params - general encoding parameters
  */
 struct s5p_mfc_enc_params {
@@ -442,6 +458,7 @@ struct s5p_mfc_enc_params {
struct {
struct s5p_mfc_h264_enc_params h264;
struct s5p_mfc_mpeg4_enc_params mpeg4;
+   struct s5p_mfc_vp8_enc_params vp8;
} codec;
 
 };
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 6dafe96..fb077b3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -84,6 +84,13 @@ static struct s5p_mfc_fmt formats[] = {
.type   = MFC_FMT_ENC,
.num_planes = 1,
},
+   {
+   .name   = VP8 Encoded Stream,
+   .fourcc = V4L2_PIX_FMT_VP8,
+   .codec_mode = S5P_MFC_CODEC_VP8_ENC,
+   .type   = MFC_FMT_ENC,
+   .num_planes = 1,
+   },
 };
 
 #define NUM_FORMATS ARRAY_SIZE(formats)
@@ -557,6 +564,60 @@ static struct mfc_control controls[] = {
.step = 1,
.default_value = 0,
},
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS,
+   .type = V4L2_CTRL_TYPE_INTEGER_MENU,
+   .maximum = V4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS,
+   .default_value = V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION,
+   .menu_skip_mask = 0,
+   },
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4,
+   .type = V4L2_CTRL_TYPE_BOOLEAN,
+   .minimum = 0,
+   .maximum = 1,
+   .step = 1,
+   .default_value = 0,
+   },
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES,
+   .type = V4L2_CTRL_TYPE_INTEGER_MENU,
+   .maximum = V4L2_CID_MPEG_VIDEO_VPX_2_REF_FRAME,
+   .default_value = V4L2_CID_MPEG_VIDEO_VPX_1_REF_FRAME,
+   .menu_skip_mask = 0,
+   },
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL,
+   .type = V4L2_CTRL_TYPE_INTEGER,
+   .minimum = 0,
+   .maximum = 63,
+   .step = 1,
+   .default_value = 0,
+   },
+   {
+   .id = V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS,
+   .type

[PATCH v5 6/8] [media] V4L: Add support for integer menu controls with standard menu items

2013-07-08 Thread Arun Kumar K
From: Sylwester Nawrocki s.nawro...@samsung.com

The patch modifies the helper function v4l2_ctrl_new_std_menu
to accept integer menu controls with standard menu items.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/v4l2-controls.txt |   21 ++--
 drivers/media/v4l2-core/v4l2-ctrls.c|   28 ---
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/Documentation/video4linux/v4l2-controls.txt 
b/Documentation/video4linux/v4l2-controls.txt
index 676f873..06cf3ac 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -124,26 +124,27 @@ You add non-menu controls by calling v4l2_ctrl_new_std:
const struct v4l2_ctrl_ops *ops,
u32 id, s32 min, s32 max, u32 step, s32 def);
 
-Menu controls are added by calling v4l2_ctrl_new_std_menu:
+Menu and integer menu controls are added by calling v4l2_ctrl_new_std_menu:
 
struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, s32 max, s32 skip_mask, s32 def);
 
-Or alternatively for integer menu controls, by calling v4l2_ctrl_new_int_menu:
+Menu controls with a driver specific menu are added by calling
+v4l2_ctrl_new_std_menu_items:
+
+   struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(
+   struct v4l2_ctrl_handler *hdl,
+   const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
+   s32 skip_mask, s32 def, const char * const *qmenu);
+
+Integer menu controls with a driver specific menu can be added by calling
+v4l2_ctrl_new_int_menu:
 
struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, s32 max, s32 def, const s64 *qmenu_int);
 
-Standard menu controls with a driver specific menu are added by calling
-v4l2_ctrl_new_std_menu_items:
-
-   struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(
-   struct v4l2_ctrl_handler *hdl,
-   const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
-   s32 skip_mask, s32 def, const char * const *qmenu);
-
 These functions are typically called right after the v4l2_ctrl_handler_init:
 
static const s64 exp_bias_qmenu[] = {
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index fccd08b..e03a2e8 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -552,6 +552,20 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 }
 EXPORT_SYMBOL(v4l2_ctrl_get_menu);
 
+/*
+ * Returns NULL or an s64 type array containing the menu for given
+ * control ID. The total number of the menu items is returned in @len.
+ */
+const s64 const *v4l2_ctrl_get_int_menu(u32 id, u32 *len)
+{
+   switch (id) {
+   default:
+   *len = 0;
+   return NULL;
+   };
+}
+EXPORT_SYMBOL(v4l2_ctrl_get_int_menu);
+
 /* Return the control name. */
 const char *v4l2_ctrl_get_name(u32 id)
 {
@@ -1712,20 +1726,28 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct 
v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, s32 max, s32 mask, s32 def)
 {
-   const char * const *qmenu = v4l2_ctrl_get_menu(id);
+   const char * const *qmenu = NULL;
+   const s64 *qmenu_int = NULL;
const char *name;
enum v4l2_ctrl_type type;
+   unsigned int qmenu_int_len;
s32 min;
s32 step;
u32 flags;
 
v4l2_ctrl_fill(id, name, type, min, max, step, def, flags);
-   if (type != V4L2_CTRL_TYPE_MENU) {
+
+   if (type == V4L2_CTRL_TYPE_MENU)
+   qmenu = v4l2_ctrl_get_menu(id);
+   else if (type == V4L2_CTRL_TYPE_INTEGER_MENU)
+   qmenu_int = v4l2_ctrl_get_int_menu(id, qmenu_int_len);
+
+   if ((!qmenu  !qmenu_int) || (qmenu_int  max  qmenu_int_len)) {
handler_set_err(hdl, -EINVAL);
return NULL;
}
return v4l2_ctrl_new(hdl, ops, id, name, type,
-0, max, mask, def, flags, qmenu, NULL, NULL);
+0, max, mask, def, flags, qmenu, qmenu_int, NULL);
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);
 
-- 
1.7.9.5

--
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


<    1   2   3   4   5   >