Re: [PATCH] [media] exynos-gsc: Remove PM_RUNTIME dependency

2014-07-22 Thread Shaik Ameer Basha
Hi Sachin,

Thanks for testing.

Even I tested with both PM enable/disable with EXYNOS_IOMMU. I didn't
face any issues.
Let me check with out IOMMU. I will update the status soon.

Regards,
Shaik Ameer Basha

On Tue, Jul 22, 2014 at 10:31 AM, Sachin Kamat spk.li...@gmail.com wrote:
 Hi Shaik,

 On Mon, Jul 21, 2014 at 10:24 AM, Shaik Ameer Basha
 shaik.am...@samsung.com wrote:
 1] Currently Gscaler clock is enabled only inside pm_runtime callbacks.
If PM_RUNTIME is disabled, driver hangs. This patch removes the
PM_RUNTIME dependency by keeping the clock enable/disable functions
in m2m start/stop streaming callbacks.

 2] For Exynos5420/5800, Gscaler clock has to be Turned ON before powering
on/off the Gscaler power domain. This dependency is taken care by
this patch at driver level.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/exynos-gsc/gsc-core.c |   10 ++
  drivers/media/platform/exynos-gsc/gsc-m2m.c  |   13 +
  2 files changed, 15 insertions(+), 8 deletions(-)

 diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
 b/drivers/media/platform/exynos-gsc/gsc-core.c
 index 9d0cc04..39c0953 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-core.c
 +++ b/drivers/media/platform/exynos-gsc/gsc-core.c
 @@ -1132,23 +1132,17 @@ static int gsc_probe(struct platform_device *pdev)

 platform_set_drvdata(pdev, gsc);
 pm_runtime_enable(dev);
 -   ret = pm_runtime_get_sync(pdev-dev);
 -   if (ret  0)
 -   goto err_m2m;

 /* Initialize continious memory allocator */
 gsc-alloc_ctx = vb2_dma_contig_init_ctx(dev);
 if (IS_ERR(gsc-alloc_ctx)) {
 ret = PTR_ERR(gsc-alloc_ctx);
 -   goto err_pm;
 +   goto err_m2m;
 }

 dev_dbg(dev, gsc-%d registered successfully\n, gsc-id);
 -
 -   pm_runtime_put(dev);
 return 0;
 -err_pm:
 -   pm_runtime_put(dev);
 +
  err_m2m:
 gsc_unregister_m2m_device(gsc);
  err_v4l2:
 diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
 b/drivers/media/platform/exynos-gsc/gsc-m2m.c
 index e434f1f0..a98462c 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
 +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
 @@ -60,19 +60,32 @@ static void __gsc_m2m_job_abort(struct gsc_ctx *ctx)
  static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
  {
 struct gsc_ctx *ctx = q-drv_priv;
 +   struct gsc_dev *gsc = ctx-gsc_dev;
 int ret;

 +   ret = clk_enable(gsc-clock);
 +   if (ret)
 +   return ret;
 +
 ret = pm_runtime_get_sync(ctx-gsc_dev-pdev-dev);
 +
 +   if (!pm_runtime_enabled(gsc-pdev-dev)) {
 +   gsc_hw_set_sw_reset(gsc);
 +   gsc_wait_reset(gsc);
 +   }
 +
 return ret  0 ? 0 : ret;
  }

  static void gsc_m2m_stop_streaming(struct vb2_queue *q)
  {
 struct gsc_ctx *ctx = q-drv_priv;
 +   struct gsc_dev *gsc = ctx-gsc_dev;

 __gsc_m2m_job_abort(ctx);

 pm_runtime_put(ctx-gsc_dev-pdev-dev);
 +   clk_disable(gsc-clock);
  }

  void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
 --
 1.7.9.5


 Looks like there is some issue while runtime PM is disabled. The
 conversion operation hangs. Tested on 5420 based Arndale Octa
 board with latest next kernel.

 --
 Regards,
 Sachin.
--
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: Remove PM_RUNTIME dependency

2014-07-20 Thread Shaik Ameer Basha
1] Currently Gscaler clock is enabled only inside pm_runtime callbacks.
   If PM_RUNTIME is disabled, driver hangs. This patch removes the
   PM_RUNTIME dependency by keeping the clock enable/disable functions
   in m2m start/stop streaming callbacks.

2] For Exynos5420/5800, Gscaler clock has to be Turned ON before powering
   on/off the Gscaler power domain. This dependency is taken care by
   this patch at driver level.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-core.c |   10 ++
 drivers/media/platform/exynos-gsc/gsc-m2m.c  |   13 +
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index 9d0cc04..39c0953 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -1132,23 +1132,17 @@ static int gsc_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, gsc);
pm_runtime_enable(dev);
-   ret = pm_runtime_get_sync(pdev-dev);
-   if (ret  0)
-   goto err_m2m;
 
/* Initialize continious memory allocator */
gsc-alloc_ctx = vb2_dma_contig_init_ctx(dev);
if (IS_ERR(gsc-alloc_ctx)) {
ret = PTR_ERR(gsc-alloc_ctx);
-   goto err_pm;
+   goto err_m2m;
}
 
dev_dbg(dev, gsc-%d registered successfully\n, gsc-id);
-
-   pm_runtime_put(dev);
return 0;
-err_pm:
-   pm_runtime_put(dev);
+
 err_m2m:
gsc_unregister_m2m_device(gsc);
 err_v4l2:
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index e434f1f0..a98462c 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -60,19 +60,32 @@ static void __gsc_m2m_job_abort(struct gsc_ctx *ctx)
 static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
 {
struct gsc_ctx *ctx = q-drv_priv;
+   struct gsc_dev *gsc = ctx-gsc_dev;
int ret;
 
+   ret = clk_enable(gsc-clock);
+   if (ret)
+   return ret;
+
ret = pm_runtime_get_sync(ctx-gsc_dev-pdev-dev);
+
+   if (!pm_runtime_enabled(gsc-pdev-dev)) {
+   gsc_hw_set_sw_reset(gsc);
+   gsc_wait_reset(gsc);
+   }
+
return ret  0 ? 0 : ret;
 }
 
 static void gsc_m2m_stop_streaming(struct vb2_queue *q)
 {
struct gsc_ctx *ctx = q-drv_priv;
+   struct gsc_dev *gsc = ctx-gsc_dev;
 
__gsc_m2m_job_abort(ctx);
 
pm_runtime_put(ctx-gsc_dev-pdev-dev);
+   clk_disable(gsc-clock);
 }
 
 void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
-- 
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 3/4] gsc-m2m: report correct format bytesperline and sizeimage

2014-04-08 Thread Shaik Ameer Basha
));
 -   else /* 422 */
 -   addr-cr = (dma_addr_t)(addr-cb
 -   + (pix_size  1));
 -   break;
 -   default:
 -   pr_err(Invalid the number of color planes);
 -   return -EINVAL;
 +   addr-cb = 0;
 +   addr-cr = 0;
 +
 +   if (fmt-num_planes == 1) {
 +   if (fmt-num_comp = 2) {
 +   addr-cb = (dma_addr_t)(addr-y +
 +   ((pix_size * fmt-depth[0]) /
 +   (fmt-sampling[0][0] *
 +fmt-sampling[0][1]) / 8));
 +   }
 +   if (fmt-num_comp = 3) {
 +   addr-cr = (dma_addr_t)(addr-cb +
 +   ((pix_size * fmt-depth[1]) /
 +   (fmt-sampling[1][0] *
 +fmt-sampling[1][1]) / 8));
 }
 } else {
 -   if (frame-fmt-num_planes = 2)
 +   if (fmt-num_comp = 2)
 addr-cb = vb2_dma_contig_plane_dma_addr(vb, 1);
 -
 -   if (frame-fmt-num_planes == 3)
 +   if (fmt-num_comp == 3)
 addr-cr = vb2_dma_contig_plane_dma_addr(vb, 2);
 }

 -   if ((frame-fmt-pixelformat == V4L2_PIX_FMT_VYUY) ||
 -   (frame-fmt-pixelformat == V4L2_PIX_FMT_YVYU) ||
 -   (frame-fmt-pixelformat == V4L2_PIX_FMT_NV61) ||
 -   (frame-fmt-pixelformat == V4L2_PIX_FMT_YVU420) ||
 -   (frame-fmt-pixelformat == V4L2_PIX_FMT_NV21) ||
 -   (frame-fmt-pixelformat == V4L2_PIX_FMT_YVU420M))
 +   if (fmt-corder == GSC_CRCB)

if ((fmt-corder == GSC_CRCB)  (fmt-num_planes == 3))

I think it shoud only applicable to 3 component formats.
for example, Incase of two component formats like V4L2_PIX_FMT_NV61,
chroma base address becomes zero.


Regards,
Shaik Ameer Basha

 swap(addr-cb, addr-cr);

 pr_debug(ADDR: y= 0x%X  cb= 0x%X cr= 0x%X ret= %d,
 diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h 
 b/drivers/media/platform/exynos-gsc/gsc-core.h
 index ef0a6564..8fb07e0d 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-core.h
 +++ b/drivers/media/platform/exynos-gsc/gsc-core.h
 @@ -106,27 +106,27 @@ enum gsc_yuv_fmt {
 container_of((__ctrl)-handler, struct gsc_ctx, ctrl_handler)
  /**
   * struct gsc_fmt - the driver's internal color format data
 - * @mbus_code: Media Bus pixel code, -1 if not applicable
   * @name: format description
   * @pixelformat: the fourcc code for this format, 0 if not applicable
   * @yorder: Y/C order
   * @corder: Chrominance order control
   * @num_planes: number of physically non-contiguous data planes
 - * @nr_comp: number of physically contiguous data planes
 - * @depth: per plane driver's private 'number of bits per pixel'
 - * @flags: flags indicating which operation mode format applies to
 + * @num_comp: number of physically contiguous data planes
 + * @depth: bit depth of each component
 + * @sampling: sampling frequency of each components, X and Y
 + * @mbus_code: Media Bus pixel code, -1 if not applicable
   */
  struct gsc_fmt {
 -   enum v4l2_mbus_pixelcode mbus_code;
 char*name;
 u32 pixelformat;
 u32 color;
 u32 yorder;
 u32 corder;
 -   u16 num_planes;
 -   u16 num_comp;
 +   u8  num_planes;
 +   u8  num_comp;
 u8  depth[VIDEO_MAX_PLANES];
 -   u32 flags;
 +   u8  sampling[VIDEO_MAX_PLANES][2];
 +   enum v4l2_mbus_pixelcode mbus_code;
  };

  /**
 diff --git a/drivers/media/platform/exynos-gsc/gsc-regs.c 
 b/drivers/media/platform/exynos-gsc/gsc-regs.c
 index e22d147a..a8d6c90b 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-regs.c
 +++ b/drivers/media/platform/exynos-gsc/gsc-regs.c
 @@ -167,6 +167,7 @@ void gsc_hw_set_in_image_format(struct gsc_ctx *ctx)
  {
 struct gsc_dev *dev = ctx-gsc_dev;
 struct gsc_frame *frame = ctx-s_frame;
 +   const struct gsc_fmt *fmt = frame-fmt;
 u32 i, depth = 0;
 u32 cfg;

 @@ -176,21 +177,22 @@ void gsc_hw_set_in_image_format(struct gsc_ctx *ctx)
  GSC_IN_TILE_TYPE_MASK | GSC_IN_TILE_MODE);
 writel(cfg, dev-regs + GSC_IN_CON);

 -   if (is_rgb(frame-fmt-color)) {
 +   if (is_rgb(fmt-color)) {
 gsc_hw_set_in_image_rgb(ctx);
 return;
 }
 -   for (i = 0; i  frame-fmt-num_planes; i++)
 -   depth += frame-fmt-depth[i];
 +   for (i = 0; i  fmt-num_comp; i++)
 +   depth += fmt-depth[i] /
 +   (fmt-sampling[i][0] * fmt-sampling[i][1]);

 -   switch (frame-fmt-num_comp) {
 +   switch (fmt-num_comp) {
 case 1:
 cfg |= GSC_IN_YUV422_1P

Re: [PATCH 3/4] gsc-m2m: report correct format bytesperline and sizeimage

2014-04-08 Thread Shaik Ameer Basha
On Tue, Apr 8, 2014 at 12:26 PM, Shaik Ameer Basha
shaik.sams...@gmail.com wrote:
 Hi John Sheu,

 Thanks for the patch.
 Please find the review comments inline.

 On Wed, Mar 12, 2014 at 4:22 AM, John Sheu s...@google.com wrote:
 Explicitly specify sampling period for subsampled chroma formats, so
 stride and image size are properly reported through VIDIOC_{S,G}_FMT.

 Signed-off-by: John Sheu s...@google.com
 ---
  drivers/media/platform/exynos-gsc/gsc-core.c | 154 
 +++
  drivers/media/platform/exynos-gsc/gsc-core.h |  16 +--
  drivers/media/platform/exynos-gsc/gsc-regs.c |  40 +++
  drivers/media/platform/exynos-gsc/gsc-regs.h |   4 +-
  4 files changed, 116 insertions(+), 98 deletions(-)

 diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
 b/drivers/media/platform/exynos-gsc/gsc-core.c
 index 9d0cc04d..c02addef 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-core.c
 +++ b/drivers/media/platform/exynos-gsc/gsc-core.c
 @@ -34,167 +34,185 @@ static const struct gsc_fmt gsc_formats[] = {
 {
 .name   = RGB565,
 .pixelformat= V4L2_PIX_FMT_RGB565X,
 -   .depth  = { 16 },
 .color  = GSC_RGB,
 .num_planes = 1,
 .num_comp   = 1,
 +   .depth  = { 16 },
 +   .sampling   = { { 1, 1 } },
 }, {
 .name   = XRGB-8-8-8-8, 32 bpp,
 .pixelformat= V4L2_PIX_FMT_RGB32,
 -   .depth  = { 32 },
 .color  = GSC_RGB,
 .num_planes = 1,
 .num_comp   = 1,
 +   .depth  = { 32 },
 +   .sampling   = { { 1, 1 } },
 }, {
 .name   = YUV 4:2:2 packed, YCbYCr,
 .pixelformat= V4L2_PIX_FMT_YUYV,
 -   .depth  = { 16 },
 .color  = GSC_YUV422,
 .yorder = GSC_LSB_Y,
 .corder = GSC_CBCR,
 .num_planes = 1,
 .num_comp   = 1,
 +   .depth  = { 16 },
 +   .sampling   = { { 1, 1 } },
 .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
 }, {
 .name   = YUV 4:2:2 packed, CbYCrY,
 .pixelformat= V4L2_PIX_FMT_UYVY,
 -   .depth  = { 16 },
 .color  = GSC_YUV422,
 .yorder = GSC_LSB_C,
 .corder = GSC_CBCR,
 .num_planes = 1,
 .num_comp   = 1,
 +   .depth  = { 16 },
 +   .sampling   = { { 1, 1 } },
 .mbus_code  = V4L2_MBUS_FMT_UYVY8_2X8,
 }, {
 .name   = YUV 4:2:2 packed, CrYCbY,
 .pixelformat= V4L2_PIX_FMT_VYUY,
 -   .depth  = { 16 },
 .color  = GSC_YUV422,
 .yorder = GSC_LSB_C,
 .corder = GSC_CRCB,
 .num_planes = 1,
 .num_comp   = 1,
 +   .depth  = { 16 },
 +   .sampling   = { { 1, 1 } },
 .mbus_code  = V4L2_MBUS_FMT_VYUY8_2X8,
 }, {
 .name   = YUV 4:2:2 packed, YCrYCb,
 .pixelformat= V4L2_PIX_FMT_YVYU,
 -   .depth  = { 16 },
 .color  = GSC_YUV422,
 .yorder = GSC_LSB_Y,
 .corder = GSC_CRCB,
 .num_planes = 1,
 .num_comp   = 1,
 +   .depth  = { 16 },
 +   .sampling   = { { 1, 1 } },
 .mbus_code  = V4L2_MBUS_FMT_YVYU8_2X8,
 }, {
 .name   = YUV 4:4:4 planar, YCbYCr,
 .pixelformat= V4L2_PIX_FMT_YUV32,
 -   .depth  = { 32 },
 .color  = GSC_YUV444,
 .yorder = GSC_LSB_Y,
 .corder = GSC_CBCR,
 .num_planes = 1,
 .num_comp   = 1,
 +   .depth  = { 32 },
 +   .sampling   = { { 1, 1 } },
 }, {
 .name   = YUV 4:2:2 planar, Y/Cb/Cr,
 .pixelformat= V4L2_PIX_FMT_YUV422P,
 -   .depth  = { 16 },
 .color  = GSC_YUV422,
 .yorder = GSC_LSB_Y,
 .corder = GSC_CBCR,
 .num_planes = 1,
 .num_comp   = 3,
 +   .depth  = { 8, 8, 8 },
 +   .sampling   = { { 1, 1 }, { 2, 1 }, { 2, 1 } },
 }, {
 .name   = YUV 4:2:2 planar, Y

Re: [PATCH v6 3/4] [media] exynos-scaler: Add m2m functionality for the SCALER driver

2014-03-20 Thread Shaik Ameer Basha
Hi Hans,

Thanks for the review comments.

Frankly, I was not following the recent changes related to vb2 framework.
And I didn't tested the driver for v4l2-compliance :(

Will try to address all your comments in the next version of posting
and this time with v4l2-compliance :)

Regards,
Shaik Ameer Basha

On Wed, Mar 19, 2014 at 1:19 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 Thanks for this patch series!

 I've got some comments below...

 Regards,

 Hans

 On 03/19/2014 08:13 AM, Shaik Ameer Basha wrote:
 This patch adds memory to memory (m2m) interface functionality
 for the SCALER driver.

 [arun...@samsung.com: fix compilation issues]

 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/exynos-scaler/scaler-m2m.c |  788 
 +
  1 file changed, 788 insertions(+)
  create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c

 diff --git a/drivers/media/platform/exynos-scaler/scaler-m2m.c 
 b/drivers/media/platform/exynos-scaler/scaler-m2m.c
 new file mode 100644
 index 000..7b21a17
 --- /dev/null
 +++ b/drivers/media/platform/exynos-scaler/scaler-m2m.c
 @@ -0,0 +1,788 @@
 +/*
 + * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 + *   http://www.samsung.com
 + *
 + * Samsung EXYNOS5 SoC series SCALER driver
 + *
 + * 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/module.h
 +#include linux/pm_runtime.h
 +#include linux/slab.h
 +
 +#include media/v4l2-ioctl.h
 +
 +#include scaler-regs.h
 +
 +#define SCALER_DEF_PIX_FMT   V4L2_PIX_FMT_RGB32
 +#define SCALER_DEF_WIDTH 1280
 +#define SCALER_DEF_HEIGHT720
 +
 +static int scaler_m2m_ctx_stop_req(struct scaler_ctx *ctx)
 +{
 + struct scaler_ctx *curr_ctx;
 + struct scaler_dev *scaler = ctx-scaler_dev;
 + int ret;
 +
 + curr_ctx = v4l2_m2m_get_curr_priv(scaler-m2m.m2m_dev);
 + if (!scaler_m2m_pending(scaler) || (curr_ctx != ctx))
 + return 0;
 +
 + scaler_ctx_state_lock_set(SCALER_CTX_STOP_REQ, ctx);
 + ret = wait_event_timeout(scaler-irq_queue,
 + !scaler_ctx_state_is_set(SCALER_CTX_STOP_REQ, ctx),
 + SCALER_SHUTDOWN_TIMEOUT);
 +
 + return ret == 0 ? -ETIMEDOUT : ret;
 +}
 +
 +static int scaler_m2m_start_streaming(struct vb2_queue *q, unsigned int 
 count)
 +{
 + struct scaler_ctx *ctx = q-drv_priv;
 + int ret;
 +
 + ret = pm_runtime_get_sync(ctx-scaler_dev-pdev-dev);
 +
 + return ret  0 ? 0 : ret;
 +}

 If an error occurs, then all queued buffers must be returned to the vb2
 core with vb2_buffer_done with state VB2_BUF_STATE_QUEUED. A lot of vb2
 instrumentation has been added in recent weeks to check for correct
 buffer handling, and this was one of the corner cases that was never
 handled correctly. If you compile with the VIDEO_ADV_DEBUG config option
 you'll see warnings appearing if this function returns an error and the
 buffers aren't requeued. It's a good test to do.

 +
 +static int scaler_m2m_stop_streaming(struct vb2_queue *q)
 +{
 + struct scaler_ctx *ctx = q-drv_priv;
 + int ret;
 +
 + ret = scaler_m2m_ctx_stop_req(ctx);
 + if (ret  0)
 + scaler_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
 +
 + pm_runtime_put(ctx-scaler_dev-pdev-dev);
 +
 + return 0;
 +}
 +
 +void scaler_m2m_job_finish(struct scaler_ctx *ctx, int vb_state)
 +{
 + struct vb2_buffer *src_vb, *dst_vb;
 +
 + if (!ctx || !ctx-m2m_ctx)
 + return;
 +
 + src_vb = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
 + dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
 +
 + if (src_vb  dst_vb) {
 + v4l2_m2m_buf_done(src_vb, vb_state);
 + v4l2_m2m_buf_done(dst_vb, vb_state);
 +
 + v4l2_m2m_job_finish(ctx-scaler_dev-m2m.m2m_dev,
 + ctx-m2m_ctx);
 + }
 +}
 +
 +static void scaler_m2m_job_abort(void *priv)
 +{
 + struct scaler_ctx *ctx = priv;
 + int ret;
 +
 + ret = scaler_m2m_ctx_stop_req(ctx);
 + if (ret  0)
 + scaler_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
 +}
 +
 +static int scaler_get_bufs(struct scaler_ctx *ctx)
 +{
 + struct scaler_frame *s_frame, *d_frame;
 + struct vb2_buffer *src_vb, *dst_vb;
 + int ret;
 +
 + s_frame = ctx-s_frame;
 + d_frame = ctx-d_frame;
 +
 + src_vb = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
 + ret = scaler_prepare_addr(ctx, src_vb, s_frame, s_frame-addr);
 + if (ret  0)
 + return ret;
 +
 + dst_vb = v4l2_m2m_next_dst_buf(ctx-m2m_ctx);
 + ret = scaler_prepare_addr(ctx, dst_vb, d_frame, d_frame-addr);
 + if (ret  0)
 + return ret;
 +
 + dst_vb-v4l2_buf.timestamp = src_vb

[PATCH v6 0/4] Exynos5 Series SCALER Driver

2014-03-19 Thread Shaik Ameer Basha
This patch adds support for SCALER device which is a
new device for scaling, blending, color fill  and color space
conversion on EXYNOS5410/5420 SoCs.

This device supports the following as key features.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size - Exynos5420
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
Size - Exynos5410
- Input/Output: 4x4 to 4096x4096
alpha blending, color fill

Rebased on:
---
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git:master

Changes from v5:
---
Addressed review comments from, Bartlomiej Zolnierkiewicz and Tomasz Figa
Links to the review comments:
1] https://linuxtv.org/patch/21512/
2] https://linuxtv.org/patch/21513/
3] https://linuxtv.org/patch/21514/

Changes from v4:
---
Addressed review comments from, Sylwester Nawrocki and Mauro Carvalho Chehab
Links to the review comments:
1] https://linuxtv.org/patch/20307/
2] https://linuxtv.org/patch/20308/
3] https://linuxtv.org/patch/20451/

Changes from v3:
---
Addressed review comments from, Sylwester Nawrocki and Hans Verkuil.
Links to the review comments:
1] https://linuxtv.org/patch/20072/
2] https://linuxtv.org/patch/20073/

Changes from v2:
---
Addressed review comments from, Inki Dae, Hans Verkuil and Sylwester Nawrocki.
Links to the review comments:
1] https://linuxtv.org/patch/19783/
2] https://linuxtv.org/patch/19784/
3] https://linuxtv.org/patch/19785/
4] https://linuxtv.org/patch/19786/
5] https://linuxtv.org/patch/19787/

Changes from v1:
---
1] Split the previous single patch into multiple patches.
2] Added DT binding documentation.
3] Removed the unnecessary header file inclusions.
4] Fix the condition check in mscl_prepare_address for swapping cb/cr addresses.

Shaik Ameer Basha (4):
  [media] exynos-scaler: Add DT bindings for SCALER driver
  [media] exynos-scaler: Add new driver for Exynos5 SCALER
  [media] exynos-scaler: Add m2m functionality for the SCALER driver
  [media] exynos-scaler: Add core functionality for the SCALER driver

 .../devicetree/bindings/media/exynos5-scaler.txt   |   24 +
 drivers/media/platform/Kconfig |8 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos-scaler/Makefile  |3 +
 drivers/media/platform/exynos-scaler/scaler-m2m.c  |  788 +
 drivers/media/platform/exynos-scaler/scaler-regs.c |  337 ++
 drivers/media/platform/exynos-scaler/scaler-regs.h |  331 ++
 drivers/media/platform/exynos-scaler/scaler.c  | 1235 
 drivers/media/platform/exynos-scaler/scaler.h  |  376 ++
 9 files changed, 3103 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-scaler.txt
 create mode 100644 drivers/media/platform/exynos-scaler/Makefile
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.h
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.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 1/4] [media] exynos-scaler: Add DT bindings for SCALER driver

2014-03-19 Thread Shaik Ameer Basha
This patch adds the DT binding documentation for the Exynos5420/5410
based SCALER device driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/media/exynos5-scaler.txt   |   24 
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-scaler.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-scaler.txt 
b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
new file mode 100644
index 000..e1dd465
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
@@ -0,0 +1,24 @@
+* Samsung Exynos5 SCALER device
+
+SCALER is used for scaling, blending, color fill and color space
+conversion on EXYNOS[5420/5410] SoCs.
+
+Required properties:
+- compatible: should be samsung,exynos5420-scaler or
+   samsung,exynos5410-scaler
+- reg: should contain SCALER physical address location and length
+- interrupts: should contain SCALER interrupt specifier
+- clocks: should contain the SCALER clock phandle and specifier pair for
+   each clock listed in clock-names property, according to
+   the common clock bindings
+- clock-names: should contain exactly one entry
+   - scaler - IP bus clock
+
+Example:
+   scaler_0: scaler@1280 {
+   compatible = samsung,exynos5420-scaler;
+   reg = 0x1280 0x1000;
+   interrupts = 0 220 0;
+   clocks = clock 381;
+   clock-names = scaler;
+   };
-- 
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 3/4] [media] exynos-scaler: Add m2m functionality for the SCALER driver

2014-03-19 Thread Shaik Ameer Basha
This patch adds memory to memory (m2m) interface functionality
for the SCALER driver.

[arun...@samsung.com: fix compilation issues]

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/exynos-scaler/scaler-m2m.c |  788 +
 1 file changed, 788 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c

diff --git a/drivers/media/platform/exynos-scaler/scaler-m2m.c 
b/drivers/media/platform/exynos-scaler/scaler-m2m.c
new file mode 100644
index 000..7b21a17
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler-m2m.c
@@ -0,0 +1,788 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/module.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+
+#include media/v4l2-ioctl.h
+
+#include scaler-regs.h
+
+#define SCALER_DEF_PIX_FMT V4L2_PIX_FMT_RGB32
+#define SCALER_DEF_WIDTH   1280
+#define SCALER_DEF_HEIGHT  720
+
+static int scaler_m2m_ctx_stop_req(struct scaler_ctx *ctx)
+{
+   struct scaler_ctx *curr_ctx;
+   struct scaler_dev *scaler = ctx-scaler_dev;
+   int ret;
+
+   curr_ctx = v4l2_m2m_get_curr_priv(scaler-m2m.m2m_dev);
+   if (!scaler_m2m_pending(scaler) || (curr_ctx != ctx))
+   return 0;
+
+   scaler_ctx_state_lock_set(SCALER_CTX_STOP_REQ, ctx);
+   ret = wait_event_timeout(scaler-irq_queue,
+   !scaler_ctx_state_is_set(SCALER_CTX_STOP_REQ, ctx),
+   SCALER_SHUTDOWN_TIMEOUT);
+
+   return ret == 0 ? -ETIMEDOUT : ret;
+}
+
+static int scaler_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
+{
+   struct scaler_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = pm_runtime_get_sync(ctx-scaler_dev-pdev-dev);
+
+   return ret  0 ? 0 : ret;
+}
+
+static int scaler_m2m_stop_streaming(struct vb2_queue *q)
+{
+   struct scaler_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = scaler_m2m_ctx_stop_req(ctx);
+   if (ret  0)
+   scaler_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+   pm_runtime_put(ctx-scaler_dev-pdev-dev);
+
+   return 0;
+}
+
+void scaler_m2m_job_finish(struct scaler_ctx *ctx, int vb_state)
+{
+   struct vb2_buffer *src_vb, *dst_vb;
+
+   if (!ctx || !ctx-m2m_ctx)
+   return;
+
+   src_vb = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
+   dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
+
+   if (src_vb  dst_vb) {
+   v4l2_m2m_buf_done(src_vb, vb_state);
+   v4l2_m2m_buf_done(dst_vb, vb_state);
+
+   v4l2_m2m_job_finish(ctx-scaler_dev-m2m.m2m_dev,
+   ctx-m2m_ctx);
+   }
+}
+
+static void scaler_m2m_job_abort(void *priv)
+{
+   struct scaler_ctx *ctx = priv;
+   int ret;
+
+   ret = scaler_m2m_ctx_stop_req(ctx);
+   if (ret  0)
+   scaler_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+}
+
+static int scaler_get_bufs(struct scaler_ctx *ctx)
+{
+   struct scaler_frame *s_frame, *d_frame;
+   struct vb2_buffer *src_vb, *dst_vb;
+   int ret;
+
+   s_frame = ctx-s_frame;
+   d_frame = ctx-d_frame;
+
+   src_vb = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
+   ret = scaler_prepare_addr(ctx, src_vb, s_frame, s_frame-addr);
+   if (ret  0)
+   return ret;
+
+   dst_vb = v4l2_m2m_next_dst_buf(ctx-m2m_ctx);
+   ret = scaler_prepare_addr(ctx, dst_vb, d_frame, d_frame-addr);
+   if (ret  0)
+   return ret;
+
+   dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+
+   return 0;
+}
+
+static void scaler_m2m_device_run(void *priv)
+{
+   struct scaler_ctx *ctx = priv;
+   struct scaler_dev *scaler;
+   unsigned long flags;
+   int ret;
+   bool is_stopped;
+
+   if (WARN(!ctx, Null hardware context\n))
+   return;
+
+   scaler = ctx-scaler_dev;
+   spin_lock_irqsave(scaler-slock, flags);
+
+   set_bit(ST_M2M_PEND, scaler-state);
+
+   /* Reconfigure hardware if the context has changed. */
+   if (scaler-m2m.ctx != ctx) {
+   scaler_dbg(scaler, scaler-m2m.ctx = 0x%p, current_ctx = 0x%p,
+   scaler-m2m.ctx, ctx);
+   ctx-state |= SCALER_PARAMS;
+   scaler-m2m.ctx = ctx;
+   }
+
+   is_stopped = ctx-state  SCALER_CTX_STOP_REQ;
+   ctx-state = ~SCALER_CTX_STOP_REQ;
+   if (is_stopped) {
+   wake_up(scaler-irq_queue);
+   goto unlock;
+   }
+
+   ret = scaler_get_bufs(ctx);
+   if (ret  0

[PATCH v6 4/4] [media] exynos-scaler: Add core functionality for the SCALER driver

2014-03-19 Thread Shaik Ameer Basha
This patch adds the Makefile and core functionality for the SCALER driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/Kconfig|8 +
 drivers/media/platform/Makefile   |1 +
 drivers/media/platform/exynos-scaler/Makefile |3 +
 drivers/media/platform/exynos-scaler/scaler.c | 1235 +
 drivers/media/platform/exynos-scaler/scaler.h |  376 
 5 files changed, 1623 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/Makefile
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index c137abf..7cdec24 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -196,6 +196,14 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
  This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
+config VIDEO_SAMSUNG_EXYNOS_SCALER
+   tristate Samsung Exynos SCALER driver
+   depends on VIDEO_DEV  VIDEO_V4L2  (SOC_EXYNOS5410 || SOC_EXYNOS5420)
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+ This is a v4l2 driver for Samsung EXYNOS5410/5420 SoC SCALER.
+
 config VIDEO_SH_VEU
tristate SuperH VEU mem2mem video processing driver
depends on VIDEO_DEV  VIDEO_V4L2  HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index e5269da..0f774ba 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -36,6 +36,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_EXYNOS_SCALER)  += exynos-scaler/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos-scaler/Makefile 
b/drivers/media/platform/exynos-scaler/Makefile
new file mode 100644
index 000..6c8a25b
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/Makefile
@@ -0,0 +1,3 @@
+exynos-scaler-objs := scaler.o scaler-m2m.o scaler-regs.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_SCALER)  += exynos-scaler.o
diff --git a/drivers/media/platform/exynos-scaler/scaler.c 
b/drivers/media/platform/exynos-scaler/scaler.c
new file mode 100644
index 000..6005651
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler.c
@@ -0,0 +1,1235 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/interrupt.h
+#include linux/module.h
+#include linux/of_platform.h
+#include linux/pm_runtime.h
+
+#include scaler-regs.h
+
+#define SCALER_CLOCK_GATE_NAME scaler
+
+static const struct scaler_fmt scaler_formats[] = {
+   {
+   .name   = YUV 4:2:0 non-contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12M,
+   .depth  = { 8, 4 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+
+   }, {
+   .name   = YUV 4:2:0 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12,
+   .depth  = { 12 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+   }, {
+   .name   = YUV 4:2:0 n.c. 2p, Y/CbCr tiled,
+   .pixelformat= V4L2_PIX_FMT_NV12MT_16X16,
+   .depth  = { 8, 4 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_TILED,
+   }, {
+   .name   = YUV 4:2:2 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV16,
+   .depth  = { 16 },
+   .color  = SCALER_YUV422,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color

[PATCH v6 2/4] [media] exynos-scaler: Add new driver for Exynos5 SCALER

2014-03-19 Thread Shaik Ameer Basha
This patch adds support for SCALER device which is a new device
for scaling, blending, color fill  and color space conversion
on EXYNOS5410 and EXYNOS5420 SoCs.

This device supports the followings as key feature.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size - Exynos5420
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
Size - Exynos5410
- Input/Output: 4x4 to 4096x4096
alpha blending, color fill

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos-scaler/scaler-regs.c |  337 
 drivers/media/platform/exynos-scaler/scaler-regs.h |  331 +++
 2 files changed, 668 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.h

diff --git a/drivers/media/platform/exynos-scaler/scaler-regs.c 
b/drivers/media/platform/exynos-scaler/scaler-regs.c
new file mode 100644
index 000..e9e8a60
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler-regs.c
@@ -0,0 +1,337 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/delay.h
+#include linux/platform_device.h
+
+#include scaler-regs.h
+
+/* Scaler reset timeout in milliseconds */
+#define SCALER_RESET_TIMEOUT   5
+
+void scaler_hw_set_sw_reset(struct scaler_dev *dev)
+{
+   u32 cfg;
+
+   cfg = scaler_read(dev, SCALER_CFG);
+   cfg |= SCALER_CFG_SOFT_RESET;
+
+   scaler_write(dev, SCALER_CFG, cfg);
+}
+
+int scaler_wait_reset(struct scaler_dev *dev)
+{
+   unsigned long end = jiffies + msecs_to_jiffies(SCALER_RESET_TIMEOUT);
+   u32 cfg, reset_done = 0;
+
+   while (time_is_after_jiffies(end)) {
+   cfg = scaler_read(dev, SCALER_CFG);
+   if (!(cfg  SCALER_CFG_SOFT_RESET)) {
+   reset_done = 1;
+   break;
+   }
+   usleep_range(100, 200);
+   }
+
+   if (!reset_done)
+   return -EBUSY;
+
+   /*
+* Write any value to read/write register and read it back.
+* If the write and read value matches, then the reset process is
+* succeeded.
+*/
+   end = jiffies + msecs_to_jiffies(SCALER_RESET_TIMEOUT);
+   while (time_is_after_jiffies(end)) {
+   scaler_write(dev, SCALER_CFG_SOFT_RESET_CHECK_REG,
+   SCALER_CFG_SOFT_RESET_CHECK_VAL);
+   if (SCALER_CFG_SOFT_RESET_CHECK_VAL ==
+   scaler_read(dev, SCALER_CFG_SOFT_RESET_CHECK_REG))
+   return 0;
+   usleep_range(9000, 1);
+   }
+
+   return -EBUSY;
+}
+
+void scaler_hw_set_irq(struct scaler_dev *dev, int irq_num, bool enable)
+{
+   u32 cfg;
+
+   if ((irq_num  SCALER_INT_FRAME_END) ||
+   (irq_num  SCALER_INT_TIMEOUT))
+   return;
+
+   cfg = scaler_read(dev, SCALER_INT_EN);
+   if (enable)
+   cfg |= 1  irq_num;
+   else
+   cfg = ~(1  irq_num);
+   scaler_write(dev, SCALER_INT_EN, cfg);
+}
+
+void scaler_hw_set_input_addr(struct scaler_dev *dev, struct scaler_addr *addr)
+{
+   scaler_dbg(dev, src_buf: 0x%x, cb: 0x%x, cr: 0x%x,
+   addr-y, addr-cb, addr-cr);
+   scaler_write(dev, SCALER_SRC_Y_BASE, addr-y);
+   scaler_write(dev, SCALER_SRC_CB_BASE, addr-cb);
+   scaler_write(dev, SCALER_SRC_CR_BASE, addr-cr);
+}
+
+void scaler_hw_set_output_addr(struct scaler_dev *dev,
+struct scaler_addr *addr)
+{
+   scaler_dbg(dev, dst_buf: 0x%x, cb: 0x%x, cr: 0x%x,
+   addr-y, addr-cb, addr-cr);
+   scaler_write(dev, SCALER_DST_Y_BASE, addr-y);
+   scaler_write(dev, SCALER_DST_CB_BASE, addr-cb);
+   scaler_write(dev, SCALER_DST_CR_BASE, addr-cr);
+}
+
+void scaler_hw_set_in_size(struct scaler_ctx *ctx)
+{
+   struct scaler_dev *dev = ctx-scaler_dev;
+   struct scaler_frame

Re: [PATCH v5 4/4] [media] exynos-scaler: Add DT bindings for SCALER driver

2014-01-30 Thread Shaik Ameer Basha
Hi Tomasz,

Thanks for the review.
Will consider all your comments in the next version of patch series.

Regards,
Shaik Ameer Basha

On Sat, Jan 25, 2014 at 1:09 AM, Tomasz Figa t.f...@samsung.com wrote:
 Hi Shaik,


 On 09.01.2014 04:28, Shaik Ameer Basha wrote:

 This patch adds the DT binding documentation for the
 Exynos5420/5410 based SCALER device driver.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
 ---
   .../devicetree/bindings/media/exynos5-scaler.txt   |   22
 
   1 file changed, 22 insertions(+)
   create mode 100644
 Documentation/devicetree/bindings/media/exynos5-scaler.txt

 diff --git a/Documentation/devicetree/bindings/media/exynos5-scaler.txt
 b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
 new file mode 100644
 index 000..9328e7d
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
 @@ -0,0 +1,22 @@
 +* Samsung Exynos5 SCALER device
 +
 +SCALER is used for scaling, blending, color fill and color space
 +conversion on EXYNOS[5420/5410] SoCs.
 +
 +Required properties:
 +- compatible: should be samsung,exynos5420-scaler or
 +   samsung,exynos5410-scaler
 +- reg: should contain SCALER physical address location and length
 +- interrupts: should contain SCALER interrupt number


 s/number/specifier/


 +- clocks: should contain the SCALER clock specifier, from the
 +   common clock bindings


 s/specifier/phandle and specifier pair for each clock listed in clock-names
 property/

 s/from/according to/


 +- clock-names: should be scaler


 should contain exactly one entry:
  - scaler - IP bus clock.

 Also this patch should be first in the series to let the driver added in
 further patches use already present bindings.

 Best regards,
 Tomasz
 --
 To unsubscribe from this list: send the line unsubscribe linux-samsung-soc
 in

 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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 4/4] [media] exynos-scaler: Add DT bindings for SCALER driver

2014-01-20 Thread Shaik Ameer Basha
Hi Bartlomiej,

Thanks for the review.

Yes you are right. I didn't add the users for this driver.
Once the driver gets merged, I will send more patches with the users.
Already this driver merge is pending on DT maintainers ack and  I
don't want to complex it more by adding DT patches :)

Definitely, I will send the users patches once the driver gets merged.
And I will address all your comments in next version of patch series.


Regards,
Shaik Ameer Basha

On Thu, Jan 9, 2014 at 6:20 PM, Bartlomiej Zolnierkiewicz
b.zolnier...@samsung.com wrote:

 Hi,

 On Thursday, January 09, 2014 08:58:14 AM Shaik Ameer Basha wrote:
 This patch adds the DT binding documentation for the
 Exynos5420/5410 based SCALER device driver.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
 ---
  .../devicetree/bindings/media/exynos5-scaler.txt   |   22 
 
  1 file changed, 22 insertions(+)
  create mode 100644 
 Documentation/devicetree/bindings/media/exynos5-scaler.txt

 diff --git a/Documentation/devicetree/bindings/media/exynos5-scaler.txt 
 b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
 new file mode 100644
 index 000..9328e7d
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
 @@ -0,0 +1,22 @@
 +* Samsung Exynos5 SCALER device
 +
 +SCALER is used for scaling, blending, color fill and color space
 +conversion on EXYNOS[5420/5410] SoCs.
 +
 +Required properties:
 +- compatible: should be samsung,exynos5420-scaler or
 + samsung,exynos5410-scaler
 +- reg: should contain SCALER physical address location and length
 +- interrupts: should contain SCALER interrupt number
 +- clocks: should contain the SCALER clock specifier, from the
 + common clock bindings
 +- clock-names: should be scaler
 +
 +Example:
 + scaler_0: scaler@1280 {
 + compatible = samsung,exynos5420-scaler;
 + reg = 0x1280 0x1000;
 + interrupts = 0 220 0;
 + clocks = clock 381;
 + clock-names = scaler;
 + };

 Your patchset adds support for EXYNOS5 SCALER but doesn't add any real
 users of it yet.  Could you please explain why?

 Best regards,
 --
 Bartlomiej Zolnierkiewicz
 Samsung RD Institute Poland
 Samsung Electronics

 --
 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
--
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/4] [media] exynos-scaler: Add new driver for Exynos5 SCALER

2014-01-08 Thread Shaik Ameer Basha
This patch adds support for SCALER device which is a new device
for scaling, blending, color fill  and color space conversion
on EXYNOS5410 and EXYNOS5420 SoCs.

This device supports the followings as key feature.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size - Exynos5420
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
Size - Exynos5410
- Input/Output: 4x4 to 4096x4096
alpha blending, color fill

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos-scaler/scaler-regs.c |  337 
 drivers/media/platform/exynos-scaler/scaler-regs.h |  331 +++
 2 files changed, 668 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.h

diff --git a/drivers/media/platform/exynos-scaler/scaler-regs.c 
b/drivers/media/platform/exynos-scaler/scaler-regs.c
new file mode 100644
index 000..8f5076a
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler-regs.c
@@ -0,0 +1,337 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/delay.h
+#include linux/platform_device.h
+
+#include scaler-regs.h
+
+/* Scaler reset timeout in milliseconds */
+#define SCALER_RESET_TIMEOUT   5
+
+void scaler_hw_set_sw_reset(struct scaler_dev *dev)
+{
+   u32 cfg;
+
+   cfg = scaler_read(dev, SCALER_CFG);
+   cfg |= SCALER_CFG_SOFT_RESET;
+
+   scaler_write(dev, SCALER_CFG, cfg);
+}
+
+int scaler_wait_reset(struct scaler_dev *dev)
+{
+   unsigned long end = jiffies + msecs_to_jiffies(SCALER_RESET_TIMEOUT);
+   u32 cfg, reset_done = 0;
+
+   while (time_is_after_jiffies(end)) {
+   cfg = scaler_read(dev, SCALER_CFG);
+   if (!(cfg  SCALER_CFG_SOFT_RESET)) {
+   reset_done = 1;
+   break;
+   }
+   usleep_range(100, 200);
+   }
+
+   if (!reset_done)
+   return -EBUSY;
+
+   /*
+* Write any value to read/write register and read it back.
+* If the write and read value matches, then the reset process is
+* succeeded.
+*/
+   end = jiffies + msecs_to_jiffies(SCALER_RESET_TIMEOUT);
+   while (time_is_after_jiffies(end)) {
+   scaler_write(dev, SCALER_CFG_SOFT_RESET_CHECK_REG,
+   SCALER_CFG_SOFT_RESET_CHECK_VAL);
+   if (SCALER_CFG_SOFT_RESET_CHECK_VAL ==
+   scaler_read(dev, SCALER_CFG_SOFT_RESET_CHECK_REG))
+   return 0;
+   usleep_range(9000, 1);
+   }
+
+   return -EBUSY;
+}
+
+void scaler_hw_set_irq(struct scaler_dev *dev, int irq_num, bool enable)
+{
+   u32 cfg;
+
+   if ((irq_num  SCALER_INT_FRAME_END) ||
+   (irq_num  SCALER_INT_TIMEOUT))
+   return;
+
+   cfg = scaler_read(dev, SCALER_INT_EN);
+   if (enable)
+   cfg |= 1  irq_num;
+   else
+   cfg = ~(1  irq_num);
+   scaler_write(dev, SCALER_INT_EN, cfg);
+}
+
+void scaler_hw_set_input_addr(struct scaler_dev *dev, struct scaler_addr *addr)
+{
+   scaler_dbg(dev, src_buf: 0x%x, cb: 0x%x, cr: 0x%x,
+   addr-y, addr-cb, addr-cr);
+   scaler_write(dev, SCALER_SRC_Y_BASE, addr-y);
+   scaler_write(dev, SCALER_SRC_CB_BASE, addr-cb);
+   scaler_write(dev, SCALER_SRC_CR_BASE, addr-cr);
+}
+
+void scaler_hw_set_output_addr(struct scaler_dev *dev,
+struct scaler_addr *addr)
+{
+   scaler_dbg(dev, dst_buf: 0x%x, cb: 0x%x, cr: 0x%x,
+   addr-y, addr-cb, addr-cr);
+   scaler_write(dev, SCALER_DST_Y_BASE, addr-y);
+   scaler_write(dev, SCALER_DST_CB_BASE, addr-cb);
+   scaler_write(dev, SCALER_DST_CR_BASE, addr-cr);
+}
+
+void scaler_hw_set_in_size(struct scaler_ctx *ctx)
+{
+   struct scaler_dev *dev = ctx-scaler_dev;
+   struct scaler_frame

[PATCH v5 3/4] [media] exynos-scaler: Add m2m functionality for the SCALER driver

2014-01-08 Thread Shaik Ameer Basha
This patch adds the Makefile and memory to memory (m2m) interface
functionality for the SCALER driver.

[arun...@samsung.com: fix compilation issues]

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|8 +
 drivers/media/platform/Makefile   |1 +
 drivers/media/platform/exynos-scaler/Makefile |3 +
 drivers/media/platform/exynos-scaler/scaler-m2m.c |  788 +
 4 files changed, 800 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/Makefile
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index b2a4403..aec5b80 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -196,6 +196,14 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
  This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
+config VIDEO_SAMSUNG_EXYNOS_SCALER
+   tristate Samsung Exynos SCALER driver
+   depends on OF  VIDEO_DEV  VIDEO_V4L2  ARCH_EXYNOS5
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+ This is a v4l2 driver for Samsung EXYNOS5410/5420 SoC SCALER.
+
 config VIDEO_SH_VEU
tristate SuperH VEU mem2mem video processing driver
depends on VIDEO_DEV  VIDEO_V4L2  HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index e5269da..0f774ba 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -36,6 +36,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_EXYNOS_SCALER)  += exynos-scaler/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos-scaler/Makefile 
b/drivers/media/platform/exynos-scaler/Makefile
new file mode 100644
index 000..6c8a25b
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/Makefile
@@ -0,0 +1,3 @@
+exynos-scaler-objs := scaler.o scaler-m2m.o scaler-regs.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_SCALER)  += exynos-scaler.o
diff --git a/drivers/media/platform/exynos-scaler/scaler-m2m.c 
b/drivers/media/platform/exynos-scaler/scaler-m2m.c
new file mode 100644
index 000..892b93b
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler-m2m.c
@@ -0,0 +1,788 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/module.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+
+#include media/v4l2-ioctl.h
+
+#include scaler-regs.h
+
+#define SCALER_DEF_PIX_FMT V4L2_PIX_FMT_RGB32
+#define SCALER_DEF_WIDTH   1280
+#define SCALER_DEF_HEIGHT  720
+
+static int scaler_m2m_ctx_stop_req(struct scaler_ctx *ctx)
+{
+   struct scaler_ctx *curr_ctx;
+   struct scaler_dev *scaler = ctx-scaler_dev;
+   int ret;
+
+   curr_ctx = v4l2_m2m_get_curr_priv(scaler-m2m.m2m_dev);
+   if (!scaler_m2m_pending(scaler) || (curr_ctx != ctx))
+   return 0;
+
+   scaler_ctx_state_lock_set(SCALER_CTX_STOP_REQ, ctx);
+   ret = wait_event_timeout(scaler-irq_queue,
+   !scaler_ctx_state_is_set(SCALER_CTX_STOP_REQ, ctx),
+   SCALER_SHUTDOWN_TIMEOUT);
+
+   return ret == 0 ? -ETIMEDOUT : ret;
+}
+
+static int scaler_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
+{
+   struct scaler_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = pm_runtime_get_sync(ctx-scaler_dev-pdev-dev);
+
+   return ret  0 ? 0 : ret;
+}
+
+static int scaler_m2m_stop_streaming(struct vb2_queue *q)
+{
+   struct scaler_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = scaler_m2m_ctx_stop_req(ctx);
+   if (ret  0)
+   scaler_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+   pm_runtime_put(ctx-scaler_dev-pdev-dev);
+
+   return 0;
+}
+
+void scaler_m2m_job_finish(struct scaler_ctx *ctx, int vb_state)
+{
+   struct vb2_buffer *src_vb, *dst_vb;
+
+   if (!ctx || !ctx-m2m_ctx)
+   return;
+
+   src_vb = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
+   dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
+
+   if (src_vb  dst_vb) {
+   v4l2_m2m_buf_done(src_vb, vb_state);
+   v4l2_m2m_buf_done(dst_vb, vb_state);
+
+   v4l2_m2m_job_finish(ctx-scaler_dev-m2m.m2m_dev,
+   ctx-m2m_ctx);
+   }
+}
+
+static void scaler_m2m_job_abort(void

[PATCH v5 2/4] [media] exynos-scaler: Add core functionality for the SCALER driver

2014-01-08 Thread Shaik Ameer Basha
This patch adds the core functionality for the SCALER driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/platform/exynos-scaler/scaler.c | 1231 +
 drivers/media/platform/exynos-scaler/scaler.h |  376 
 2 files changed, 1607 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.h

diff --git a/drivers/media/platform/exynos-scaler/scaler.c 
b/drivers/media/platform/exynos-scaler/scaler.c
new file mode 100644
index 000..db2cad1
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler.c
@@ -0,0 +1,1231 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/interrupt.h
+#include linux/module.h
+#include linux/of_platform.h
+#include linux/pm_runtime.h
+
+#include scaler-regs.h
+
+#define SCALER_CLOCK_GATE_NAME scaler
+
+static const struct scaler_fmt scaler_formats[] = {
+   {
+   .name   = YUV 4:2:0 non-contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12M,
+   .depth  = { 8, 4 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+
+   }, {
+   .name   = YUV 4:2:0 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12,
+   .depth  = { 12 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+   }, {
+   .name   = YUV 4:2:0 n.c. 2p, Y/CbCr tiled,
+   .pixelformat= V4L2_PIX_FMT_NV12MT_16X16,
+   .depth  = { 8, 4 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_TILED,
+   }, {
+   .name   = YUV 4:2:2 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV16,
+   .depth  = { 16 },
+   .color  = SCALER_YUV422,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV422_2P_Y_UV,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+   }, {
+   .name   = YUV 4:4:4 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV24,
+   .depth  = { 24 },
+   .color  = SCALER_YUV444,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV444_2P_Y_UV,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+   }, {
+   .name   = RGB565,
+   .pixelformat= V4L2_PIX_FMT_RGB565X,
+   .depth  = { 16 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_RGB565,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+   }, {
+   .name   = XRGB-1555, 16 bpp,
+   .pixelformat= V4L2_PIX_FMT_RGB555,
+   .depth  = { 16 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_ARGB1555,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+   }, {
+   .name   = XRGB-, 32 bpp,
+   .pixelformat= V4L2_PIX_FMT_RGB32,
+   .depth  = { 32 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_ARGB,
+   .flags  = SCALER_FMT_SRC | SCALER_FMT_DST,
+   }, {
+   .name   = YUV 4:2:2 packed, YCrYCb,
+   .pixelformat= V4L2_PIX_FMT_YVYU

[PATCH v5 0/4] Exynos5 Series SCALER Driver

2014-01-08 Thread Shaik Ameer Basha
This patch adds support for SCALER device which is a
new device for scaling, blending, color fill  and color space
conversion on EXYNOS5410/5420 SoCs.

This device supports the following as key features.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size - Exynos5420
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
Size - Exynos5410
- Input/Output: 4x4 to 4096x4096
alpha blending, color fill

Rebased on:
---
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git:master

Changes from v4:
---
Addressed review comments from, Sylwester Nawrocki and Mauro Carvalho Chehab
Links to the review comments:
1] https://linuxtv.org/patch/20307/
2] https://linuxtv.org/patch/20308/
3] https://linuxtv.org/patch/20451/

Changes from v3:
---
Addressed review comments from, Sylwester Nawrocki and Hans Verkuil.
Links to the review comments:
1] https://linuxtv.org/patch/20072/
2] https://linuxtv.org/patch/20073/

Changes from v2:
---
Addressed review comments from, Inki Dae, Hans Verkuil and Sylwester Nawrocki.
Links to the review comments:
1] https://linuxtv.org/patch/19783/
2] https://linuxtv.org/patch/19784/
3] https://linuxtv.org/patch/19785/
4] https://linuxtv.org/patch/19786/
5] https://linuxtv.org/patch/19787/

Changes from v1:
---
1] Split the previous single patch into multiple patches.
2] Added DT binding documentation.
3] Removed the unnecessary header file inclusions.
4] Fix the condition check in mscl_prepare_address for swapping cb/cr addresses.

Shaik Ameer Basha (4):
  [media] exynos-scaler: Add new driver for Exynos5 SCALER
  [media] exynos-scaler: Add core functionality for the SCALER driver
  [media] exynos-scaler: Add m2m functionality for the SCALER driver
  [media] exynos-scaler: Add DT bindings for SCALER driver

 .../devicetree/bindings/media/exynos5-scaler.txt   |   22 +
 drivers/media/platform/Kconfig |8 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos-scaler/Makefile  |3 +
 drivers/media/platform/exynos-scaler/scaler-m2m.c  |  788 +
 drivers/media/platform/exynos-scaler/scaler-regs.c |  337 ++
 drivers/media/platform/exynos-scaler/scaler-regs.h |  331 ++
 drivers/media/platform/exynos-scaler/scaler.c  | 1231 
 drivers/media/platform/exynos-scaler/scaler.h  |  376 ++
 9 files changed, 3097 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-scaler.txt
 create mode 100644 drivers/media/platform/exynos-scaler/Makefile
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.h
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.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 4/4] [media] exynos-scaler: Add DT bindings for SCALER driver

2014-01-08 Thread Shaik Ameer Basha
This patch adds the DT binding documentation for the
Exynos5420/5410 based SCALER device driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/media/exynos5-scaler.txt   |   22 
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-scaler.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-scaler.txt 
b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
new file mode 100644
index 000..9328e7d
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
@@ -0,0 +1,22 @@
+* Samsung Exynos5 SCALER device
+
+SCALER is used for scaling, blending, color fill and color space
+conversion on EXYNOS[5420/5410] SoCs.
+
+Required properties:
+- compatible: should be samsung,exynos5420-scaler or
+   samsung,exynos5410-scaler
+- reg: should contain SCALER physical address location and length
+- interrupts: should contain SCALER interrupt number
+- clocks: should contain the SCALER clock specifier, from the
+   common clock bindings
+- clock-names: should be scaler
+
+Example:
+   scaler_0: scaler@1280 {
+   compatible = samsung,exynos5420-scaler;
+   reg = 0x1280 0x1000;
+   interrupts = 0 220 0;
+   clocks = clock 381;
+   clock-names = scaler;
+   };
-- 
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 1/4] [media] exynos-scaler: Add new driver for Exynos5 SCALER

2014-01-06 Thread Shaik Ameer Basha
Hi Mauro,

Thanks for the review comments.

On Fri, Jan 3, 2014 at 1:48 AM, Mauro Carvalho Chehab
m.che...@samsung.com wrote:
 Em Fri,  4 Oct 2013 17:56:31 +0530
 Shaik Ameer Basha shaik.am...@samsung.com escreveu:

 This patch adds support for SCALER device which is a new device
 for scaling, blending, color fill  and color space conversion
 on EXYNOS5410 and EXYNOS5420 SoCs.

 This device supports the followings as key feature.
 input image format
 - YCbCr420 2P(UV/VU), 3P
 - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
 - YCbCr444 2P(UV,VU), 3P
 - RGB565, ARGB1555, ARGB, ARGB, RGBA
 - Pre-multiplexed ARGB, L8A8 and L8
 output image format
 - YCbCr420 2P(UV/VU), 3P
 - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
 - YCbCr444 2P(UV,VU), 3P
 - RGB565, ARGB1555, ARGB, ARGB, RGBA
 - Pre-multiplexed ARGB
 input rotation
 - 0/90/180/270 degree, X/Y/XY Flip
 scale ratio
 - 1/4 scale down to 16 scale up
 color space conversion
 - RGB to YUV / YUV to RGB
 Size - Exynos5420
 - Input : 16x16 to 8192x8192
 - Output:   4x4 to 8192x8192
 Size - Exynos5410
 - Input/Output: 4x4 to 4096x4096
 alpha blending, color fill

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/exynos-scaler/scaler-regs.c |  336 
 
  drivers/media/platform/exynos-scaler/scaler-regs.h |  331 
 +++
  2 files changed, 667 insertions(+)
  create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.c
  create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.h

 diff --git a/drivers/media/platform/exynos-scaler/scaler-regs.c 
 b/drivers/media/platform/exynos-scaler/scaler-regs.c
 new file mode 100644
 index 000..ae4a548
 --- /dev/null
 +++ b/drivers/media/platform/exynos-scaler/scaler-regs.c
 @@ -0,0 +1,336 @@
 +/*
 + * Copyright (c) 2013 Samsung Electronics Co., Ltd.
 + *   http://www.samsung.com
 + *
 + * Samsung EXYNOS5 SoC series SCALER driver
 + *
 + * 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/delay.h
 +#include linux/platform_device.h
 +
 +#include scaler-regs.h
 +
 +/* Scaler reset timeout in milliseconds */
 +#define SCALER_RESET_TIMEOUT 50
 +
 +void scaler_hw_set_sw_reset(struct scaler_dev *dev)
 +{
 + u32 cfg;
 +
 + cfg = scaler_read(dev, SCALER_CFG);
 + cfg |= SCALER_CFG_SOFT_RESET;
 +
 + scaler_write(dev, SCALER_CFG, cfg);
 +}
 +
 +int scaler_wait_reset(struct scaler_dev *dev)
 +{
 + unsigned long end = jiffies + msecs_to_jiffies(SCALER_RESET_TIMEOUT);
 + u32 cfg, reset_done = 0;
 +
 + while (time_before(jiffies, end)) {
 + cfg = scaler_read(dev, SCALER_CFG);
 + if (!(cfg  SCALER_CFG_SOFT_RESET)) {
 + reset_done = 1;
 + break;
 + }
 + usleep_range(10, 20);

 Hmm... that doesn't seem right... the timeout can take up to 50,000 us, and
 you're sleeping from 10 to 20us... that means that this loop can have up to
 5000 interactions... It seems that you're wasting power here without need.

 I suspect that you should consider sleeping for a longer time here.

I will check what is the average time taken for the reset process.
If it is much more than 20us then i will increase this sleeping time.


 Btw, instead of using time_before(jiffies, end), you could do:
 time_is_after_jiffies(end)


Ok. I will modify.

 As, from jiffies.h:
 /* time_is_after_jiffies(a) return true if a is after jiffies */
 #define time_is_after_jiffies(a) time_before(jiffies, a)

 + }
 +
 + /*
 +  * Write any value to read/write register and read it back.
 +  * If the written and read value matches, then the reset process is
 +  * succeeded.
 +  */
 + while (reset_done) {

 This is tricky. If the reset fail, it will return busy. Otherwise, it
 can loop forever here. Worse than that, you're don't even sleeping
 before retries, again wasting power.

 Why don't you just change it to something similar to:

 if (!reset_done)
 return -EBUSY;

 end = jiffies + msecs_to_jiffies(SCALER_RESET_TIMEOUT);
 while (time_is_after_jiffies(end)) {
 scaler_write(dev, SCALER_CFG_SOFT_RESET_CHECK_REG,
 SCALER_CFG_SOFT_RESET_CHECK_VAL);
 if (SCALER_CFG_SOFT_RESET_CHECK_VAL ==
 scaler_read(dev, SCALER_CFG_SOFT_RESET_CHECK_REG))
 return 0;
 msleep(10);
 }


My Intention is to complete the reset process ASAP.
Again I need to check the average time here. As per you comments if
the time taken is more
then I

Re: [PATCH v4 2/4] [media] exynos-scaler: Add core functionality for the SCALER driver

2014-01-06 Thread Shaik Ameer Basha
Hi Mauro,

Thanks for the reveiw.

On Fri, Jan 3, 2014 at 1:55 AM, Mauro Carvalho Chehab
m.che...@samsung.com wrote:
 Em Fri,  4 Oct 2013 17:56:32 +0530
 Shaik Ameer Basha shaik.am...@samsung.com escreveu:

 This patch adds the core functionality for the SCALER driver.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/exynos-scaler/scaler.c | 1238 
 +
  drivers/media/platform/exynos-scaler/scaler.h |  375 
  2 files changed, 1613 insertions(+)
  create mode 100644 drivers/media/platform/exynos-scaler/scaler.c
  create mode 100644 drivers/media/platform/exynos-scaler/scaler.h

 diff --git a/drivers/media/platform/exynos-scaler/scaler.c 
 b/drivers/media/platform/exynos-scaler/scaler.c
 new file mode 100644
 index 000..57635f2
 --- /dev/null
 +++ b/drivers/media/platform/exynos-scaler/scaler.c
 @@ -0,0 +1,1238 @@
 +/*
 + * Copyright (c) 2013 Samsung Electronics Co., Ltd.
 + *   http://www.samsung.com
 + *
 + * Samsung EXYNOS5 SoC series SCALER driver
 + *
 + * 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/interrupt.h
 +#include linux/module.h
 +#include linux/of_platform.h
 +#include linux/pm_runtime.h
 +
 +#include scaler-regs.h
 +
 +#define SCALER_CLOCK_GATE_NAME   scaler
 +
 +static const struct scaler_fmt scaler_formats[] = {
 + {
 + .name   = YUV 4:2:0 non-contig. 2p, Y/CbCr,
 + .pixelformat= V4L2_PIX_FMT_NV12M,
 + .depth  = { 8, 4 },
 + .color  = SCALER_YUV420,
 + .color_order= SCALER_CBCR,
 + .num_planes = 2,
 + .num_comp   = 2,
 + .scaler_color   = SCALER_YUV420_2P_Y_UV,
 + .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),

 Not a big deal, but you don't need parenthesis for any of those .flags
 initialization.


Ok. I will fix this. and all other comments given by you in this patch series.

Regards,
Shaik Ameer Basha


[...] Snip


 --

 Cheers,
 Mauro
 --
 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
--
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 1/4] [media] exynos-scaler: Add new driver for Exynos5 SCALER

2013-10-20 Thread Shaik Ameer Basha
Hi Sylwester,

On Fri, Oct 18, 2013 at 5:57 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 Hi,

 I have couple minor comments. These could be addressed in follow up
 patches, it you won't manage to do it today. Sorry for being late with
 this.

Sorry for the late reply.

Currently I am on travel and I don't have the environment to rebase
and test this driver.
I will address your comments in follow up patches.

Can you please queue this driver to your branch and send a pull
request for 3.13 ?

Regards,
Shaik Ameer Basha


 On 04/10/13 14:26, Shaik Ameer Basha wrote:
 This patch adds support for SCALER device which is a new device
 for scaling, blending, color fill  and color space conversion
 on EXYNOS5410 and EXYNOS5420 SoCs.

 This device supports the followings as key feature.
 input image format
 - YCbCr420 2P(UV/VU), 3P
 - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
 - YCbCr444 2P(UV,VU), 3P
 - RGB565, ARGB1555, ARGB, ARGB, RGBA
 - Pre-multiplexed ARGB, L8A8 and L8
 output image format
 - YCbCr420 2P(UV/VU), 3P
 - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
 - YCbCr444 2P(UV,VU), 3P
 - RGB565, ARGB1555, ARGB, ARGB, RGBA
 - Pre-multiplexed ARGB
 input rotation
 - 0/90/180/270 degree, X/Y/XY Flip
 scale ratio
 - 1/4 scale down to 16 scale up
 color space conversion
 - RGB to YUV / YUV to RGB
 Size - Exynos5420
 - Input : 16x16 to 8192x8192
 - Output:   4x4 to 8192x8192
 Size - Exynos5410
 - Input/Output: 4x4 to 4096x4096
 alpha blending, color fill

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com

 Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com

 +void scaler_hw_set_in_size(struct scaler_ctx *ctx)
 +{
 + struct scaler_dev *dev = ctx-scaler_dev;
 + struct scaler_frame *frame = ctx-s_frame;
 + u32 cfg;
 +
 + /* set input pixel offset */
 + cfg = (frame-selection.left  SCALER_SRC_YH_POS_MASK) 
 +   SCALER_SRC_YH_POS_SHIFT;
 + cfg |= ((frame-selection.top  SCALER_SRC_YV_POS_MASK) 
 +SCALER_SRC_YV_POS_SHIFT);
 + scaler_write(dev, SCALER_SRC_Y_POS, cfg);
 +
 + /* TODO: calculate 'C' plane h/v offset using 'Y' plane h/v offset */
 +
 + /* Set input span */
 + cfg = (frame-f_width  SCALER_SRC_Y_SPAN_MASK) 
 + SCALER_SRC_Y_SPAN_SHIFT;
 + if (is_yuv420_2p(frame-fmt))
 + cfg |= ((frame-f_width  SCALER_SRC_C_SPAN_MASK) 
 +   SCALER_SRC_C_SPAN_SHIFT);
 + else /* TODO: Verify */
 + cfg |= ((frame-f_width  SCALER_SRC_C_SPAN_MASK) 
 +   SCALER_SRC_C_SPAN_SHIFT);
 +
 + scaler_write(dev, SCALER_SRC_SPAN, cfg);
 +
 + /* Set input cropped size */
 + cfg = (frame-selection.width  SCALER_SRC_WIDTH_MASK) 
 +SCALER_SRC_WIDTH_SHIFT;
 + cfg |= ((frame-selection.height  SCALER_SRC_HEIGHT_MASK) 
 +   SCALER_SRC_HEIGHT_SHIFT);
 + scaler_write(dev, SCALER_SRC_WH, cfg);
 +
 + scaler_dbg(dev, src: posx: %d, posY: %d, spanY: %d, spanC: %d, cropX: 
 %d, cropY: %d\n,

 This could be broken into two lines, it's just a debug print.

 + frame-selection.left, frame-selection.top,
 + frame-f_width, frame-f_width, frame-selection.width,
 + frame-selection.height);
 +}
 +
 +void scaler_hw_set_in_image_format(struct scaler_ctx *ctx)
 +{
 + struct scaler_dev *dev = ctx-scaler_dev;
 + struct scaler_frame *frame = ctx-s_frame;
 + u32 cfg;
 +
 + cfg = scaler_read(dev, SCALER_SRC_CFG);
 + cfg = ~(SCALER_SRC_COLOR_FORMAT_MASK  
 SCALER_SRC_COLOR_FORMAT_SHIFT);
 + cfg |= ((frame-fmt-scaler_color  SCALER_SRC_COLOR_FORMAT_MASK) 
 +SCALER_SRC_COLOR_FORMAT_SHIFT);
 +
 + /* Setting tiled/linear format */
 + if (is_tiled_fmt(frame-fmt))
 + cfg |= SCALER_SRC_TILE_EN;
 + else
 + cfg = ~SCALER_SRC_TILE_EN;
 +
 + scaler_write(dev, SCALER_SRC_CFG, cfg);
 +}
 +
 +void scaler_hw_set_out_size(struct scaler_ctx *ctx)
 +{
 + struct scaler_dev *dev = ctx-scaler_dev;
 + struct scaler_frame *frame = ctx-d_frame;
 + u32 cfg;
 +
 + /* Set output pixel offset */
 + cfg = (frame-selection.left  SCALER_DST_H_POS_MASK) 
 +   SCALER_DST_H_POS_SHIFT;
 + cfg |= (frame-selection.top  SCALER_DST_V_POS_MASK) 
 +   SCALER_DST_V_POS_SHIFT;
 + scaler_write(dev, SCALER_DST_POS, cfg);
 +
 + /* Set output span */
 + cfg = (frame-f_width  SCALER_DST_Y_SPAN_MASK) 
 + SCALER_DST_Y_SPAN_SHIFT;
 + if (is_yuv420_2p(frame-fmt))
 + cfg |= (((frame-f_width / 2)  SCALER_DST_C_SPAN_MASK

[PATCH v4 0/4] Exynos5 Series SCALER Driver

2013-10-04 Thread Shaik Ameer Basha
This patch adds support for SCALER device which is a
new device for scaling, blending, color fill  and color space
conversion on EXYNOS5410/5420 SoCs.

This device supports the following as key features.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size - Exynos5420
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
Size - Exynos5410
- Input/Output: 4x4 to 4096x4096
alpha blending, color fill

Rebased on:
---
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git:master

Changes from v3:
---
Addressed review comments from, Sylwester Nawrocki and Hans Verkuil.
Links to the review comments:
1] https://linuxtv.org/patch/20072/
2] https://linuxtv.org/patch/20073/

Changes from v2:
---
Addressed review comments from, Inki Dae, Hans Verkuil and Sylwester Nawrocki.
Links to the review comments:
1] https://linuxtv.org/patch/19783/
2] https://linuxtv.org/patch/19784/
3] https://linuxtv.org/patch/19785/
4] https://linuxtv.org/patch/19786/
5] https://linuxtv.org/patch/19787/

Changes from v1:
---
1] Split the previous single patch into multiple patches.
2] Added DT binding documentation.
3] Removed the unnecessary header file inclusions.
4] Fix the condition check in mscl_prepare_address for swapping cb/cr addresses.

Shaik Ameer Basha (4):
  [media] exynos-scaler: Add new driver for Exynos5 SCALER
  [media] exynos-scaler: Add core functionality for the SCALER driver
  [media] exynos-scaler: Add m2m functionality for the SCALER driver
  [media] exynos-scaler: Add DT bindings for SCALER driver

 .../devicetree/bindings/media/exynos5-scaler.txt   |   22 +
 drivers/media/platform/Kconfig |8 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos-scaler/Makefile  |3 +
 drivers/media/platform/exynos-scaler/scaler-m2m.c  |  786 +
 drivers/media/platform/exynos-scaler/scaler-regs.c |  336 ++
 drivers/media/platform/exynos-scaler/scaler-regs.h |  331 ++
 drivers/media/platform/exynos-scaler/scaler.c  | 1238 
 drivers/media/platform/exynos-scaler/scaler.h  |  375 ++
 9 files changed, 3100 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-scaler.txt
 create mode 100644 drivers/media/platform/exynos-scaler/Makefile
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.h
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.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 4/4] [media] exynos-scaler: Add DT bindings for SCALER driver

2013-10-04 Thread Shaik Ameer Basha
This patch adds the DT binding documentation for the
Exynos5420/5410 based SCALER device driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 .../devicetree/bindings/media/exynos5-scaler.txt   |   22 
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-scaler.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-scaler.txt 
b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
new file mode 100644
index 000..f620baf
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
@@ -0,0 +1,22 @@
+* Samsung Exynos5 SCALER device
+
+SCALER is used for scaling, blending, color fill and color space
+conversion on EXYNOS[5420/5410] SoCs.
+
+Required properties:
+- compatible: should be samsung,exynos5420-scaler or
+   samsung,exynos5410-scaler
+- reg: should contain SCALER physical address location and length.
+- interrupts: should contain SCALER interrupt number
+- clocks: should contain the SCALER clock specifier, from the
+   common clock bindings
+- clock-names: should be scaler
+
+Example:
+   scaler_0: scaler@0x1280 {
+   compatible = samsung,exynos5420-scaler;
+   reg = 0x1280 0x1000;
+   interrupts = 0 220 0;
+   clocks = clock 381;
+   clock-names = scaler;
+   };
-- 
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 3/4] [media] exynos-scaler: Add m2m functionality for the SCALER driver

2013-10-04 Thread Shaik Ameer Basha
This patch adds the Makefile and memory to memory (m2m) interface
functionality for the SCALER driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/Kconfig|8 +
 drivers/media/platform/Makefile   |1 +
 drivers/media/platform/exynos-scaler/Makefile |3 +
 drivers/media/platform/exynos-scaler/scaler-m2m.c |  786 +
 4 files changed, 798 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/Makefile
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 8068d7b..339d3ba 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -201,6 +201,14 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
  This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
+config VIDEO_SAMSUNG_EXYNOS_SCALER
+   tristate Samsung Exynos SCALER driver
+   depends on OF  VIDEO_DEV  VIDEO_V4L2  ARCH_EXYNOS5
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+ This is a v4l2 driver for Samsung EXYNOS5410/5420 SoC SCALER.
+
 config VIDEO_SH_VEU
tristate SuperH VEU mem2mem video processing driver
depends on VIDEO_DEV  VIDEO_V4L2  GENERIC_HARDIRQS  HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 4e4da48..14cdad5 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_EXYNOS_SCALER)  += exynos-scaler/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos-scaler/Makefile 
b/drivers/media/platform/exynos-scaler/Makefile
new file mode 100644
index 000..6c8a25b
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/Makefile
@@ -0,0 +1,3 @@
+exynos-scaler-objs := scaler.o scaler-m2m.o scaler-regs.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_SCALER)  += exynos-scaler.o
diff --git a/drivers/media/platform/exynos-scaler/scaler-m2m.c 
b/drivers/media/platform/exynos-scaler/scaler-m2m.c
new file mode 100644
index 000..eb3af85
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler-m2m.c
@@ -0,0 +1,786 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/module.h
+#include linux/pm_runtime.h
+
+#include media/v4l2-ioctl.h
+
+#include scaler-regs.h
+
+#define SCALER_DEF_PIX_FMT V4L2_PIX_FMT_RGB32
+#define SCALER_DEF_WIDTH   1280
+#define SCALER_DEF_HEIGHT  720
+
+static int scaler_m2m_ctx_stop_req(struct scaler_ctx *ctx)
+{
+   struct scaler_ctx *curr_ctx;
+   struct scaler_dev *scaler = ctx-scaler_dev;
+   int ret;
+
+   curr_ctx = v4l2_m2m_get_curr_priv(scaler-m2m.m2m_dev);
+   if (!scaler_m2m_pending(scaler) || (curr_ctx != ctx))
+   return 0;
+
+   scaler_ctx_state_lock_set(SCALER_CTX_STOP_REQ, ctx);
+   ret = wait_event_timeout(scaler-irq_queue,
+   !scaler_ctx_state_is_set(SCALER_CTX_STOP_REQ, ctx),
+   SCALER_SHUTDOWN_TIMEOUT);
+
+   return ret == 0 ? -ETIMEDOUT : ret;
+}
+
+static int scaler_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
+{
+   struct scaler_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = pm_runtime_get_sync(ctx-scaler_dev-pdev-dev);
+
+   return ret  0 ? 0 : ret;
+}
+
+static int scaler_m2m_stop_streaming(struct vb2_queue *q)
+{
+   struct scaler_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = scaler_m2m_ctx_stop_req(ctx);
+   if (ret  0)
+   scaler_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+   pm_runtime_put(ctx-scaler_dev-pdev-dev);
+
+   return 0;
+}
+
+void scaler_m2m_job_finish(struct scaler_ctx *ctx, int vb_state)
+{
+   struct vb2_buffer *src_vb, *dst_vb;
+
+   if (!ctx || !ctx-m2m_ctx)
+   return;
+
+   src_vb = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
+   dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
+
+   if (src_vb  dst_vb) {
+   v4l2_m2m_buf_done(src_vb, vb_state);
+   v4l2_m2m_buf_done(dst_vb, vb_state);
+
+   v4l2_m2m_job_finish(ctx-scaler_dev-m2m.m2m_dev,
+   ctx-m2m_ctx);
+   }
+}
+
+static void scaler_m2m_job_abort(void *priv)
+{
+   struct scaler_ctx *ctx = priv;
+   int ret;
+
+   ret = scaler_m2m_ctx_stop_req(ctx);
+   if (ret  0

[PATCH v4 1/4] [media] exynos-scaler: Add new driver for Exynos5 SCALER

2013-10-04 Thread Shaik Ameer Basha
This patch adds support for SCALER device which is a new device
for scaling, blending, color fill  and color space conversion
on EXYNOS5410 and EXYNOS5420 SoCs.

This device supports the followings as key feature.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size - Exynos5420
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
Size - Exynos5410
- Input/Output: 4x4 to 4096x4096
alpha blending, color fill

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-scaler/scaler-regs.c |  336 
 drivers/media/platform/exynos-scaler/scaler-regs.h |  331 +++
 2 files changed, 667 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.h

diff --git a/drivers/media/platform/exynos-scaler/scaler-regs.c 
b/drivers/media/platform/exynos-scaler/scaler-regs.c
new file mode 100644
index 000..ae4a548
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler-regs.c
@@ -0,0 +1,336 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/delay.h
+#include linux/platform_device.h
+
+#include scaler-regs.h
+
+/* Scaler reset timeout in milliseconds */
+#define SCALER_RESET_TIMEOUT   50
+
+void scaler_hw_set_sw_reset(struct scaler_dev *dev)
+{
+   u32 cfg;
+
+   cfg = scaler_read(dev, SCALER_CFG);
+   cfg |= SCALER_CFG_SOFT_RESET;
+
+   scaler_write(dev, SCALER_CFG, cfg);
+}
+
+int scaler_wait_reset(struct scaler_dev *dev)
+{
+   unsigned long end = jiffies + msecs_to_jiffies(SCALER_RESET_TIMEOUT);
+   u32 cfg, reset_done = 0;
+
+   while (time_before(jiffies, end)) {
+   cfg = scaler_read(dev, SCALER_CFG);
+   if (!(cfg  SCALER_CFG_SOFT_RESET)) {
+   reset_done = 1;
+   break;
+   }
+   usleep_range(10, 20);
+   }
+
+   /*
+* Write any value to read/write register and read it back.
+* If the written and read value matches, then the reset process is
+* succeeded.
+*/
+   while (reset_done) {
+
+   /*
+* TODO: need to define number of tries before returning
+* -EBUSY to the caller
+*/
+
+   scaler_write(dev, SCALER_CFG_SOFT_RESET_CHECK_REG,
+   SCALER_CFG_SOFT_RESET_CHECK_VAL);
+   if (SCALER_CFG_SOFT_RESET_CHECK_VAL ==
+   scaler_read(dev, SCALER_CFG_SOFT_RESET_CHECK_REG))
+   return 0;
+   }
+
+   return -EBUSY;
+}
+
+void scaler_hw_set_irq(struct scaler_dev *dev, int irq_num, bool enable)
+{
+   u32 cfg;
+
+   if ((irq_num  SCALER_INT_FRAME_END) ||
+   (irq_num  SCALER_INT_TIMEOUT))
+   return;
+
+   cfg = scaler_read(dev, SCALER_INT_EN);
+   if (enable)
+   cfg |= (1  irq_num);
+   else
+   cfg = ~(1  irq_num);
+   scaler_write(dev, SCALER_INT_EN, cfg);
+}
+
+void scaler_hw_set_input_addr(struct scaler_dev *dev, struct scaler_addr *addr)
+{
+   scaler_dbg(dev, src_buf: 0x%x, cb: 0x%x, cr: 0x%x,
+   addr-y, addr-cb, addr-cr);
+   scaler_write(dev, SCALER_SRC_Y_BASE, addr-y);
+   scaler_write(dev, SCALER_SRC_CB_BASE, addr-cb);
+   scaler_write(dev, SCALER_SRC_CR_BASE, addr-cr);
+}
+
+void scaler_hw_set_output_addr(struct scaler_dev *dev,
+struct scaler_addr *addr)
+{
+   scaler_dbg(dev, dst_buf: 0x%x, cb: 0x%x, cr: 0x%x,
+   addr-y, addr-cb, addr-cr);
+   scaler_write(dev, SCALER_DST_Y_BASE, addr-y);
+   scaler_write(dev, SCALER_DST_CB_BASE, addr-cb);
+   scaler_write(dev, SCALER_DST_CR_BASE, addr-cr);
+}
+
+void scaler_hw_set_in_size(struct scaler_ctx *ctx)
+{
+   struct scaler_dev *dev = ctx-scaler_dev;
+   struct scaler_frame *frame = ctx-s_frame;
+   u32 cfg;
+
+   /* set input pixel offset

[PATCH v4 2/4] [media] exynos-scaler: Add core functionality for the SCALER driver

2013-10-04 Thread Shaik Ameer Basha
This patch adds the core functionality for the SCALER driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-scaler/scaler.c | 1238 +
 drivers/media/platform/exynos-scaler/scaler.h |  375 
 2 files changed, 1613 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.h

diff --git a/drivers/media/platform/exynos-scaler/scaler.c 
b/drivers/media/platform/exynos-scaler/scaler.c
new file mode 100644
index 000..57635f2
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler.c
@@ -0,0 +1,1238 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/interrupt.h
+#include linux/module.h
+#include linux/of_platform.h
+#include linux/pm_runtime.h
+
+#include scaler-regs.h
+
+#define SCALER_CLOCK_GATE_NAME scaler
+
+static const struct scaler_fmt scaler_formats[] = {
+   {
+   .name   = YUV 4:2:0 non-contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12M,
+   .depth  = { 8, 4 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+
+   }, {
+   .name   = YUV 4:2:0 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12,
+   .depth  = { 12 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = YUV 4:2:0 n.c. 2p, Y/CbCr tiled,
+   .pixelformat= V4L2_PIX_FMT_NV12MT_16X16,
+   .depth  = { 8, 4 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_TILED),
+   }, {
+   .name   = YUV 4:2:2 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV16,
+   .depth  = { 16 },
+   .color  = SCALER_YUV422,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV422_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = YUV 4:4:4 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV24,
+   .depth  = { 24 },
+   .color  = SCALER_YUV444,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV444_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = RGB565,
+   .pixelformat= V4L2_PIX_FMT_RGB565X,
+   .depth  = { 16 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_RGB565,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = XRGB-1555, 16 bpp,
+   .pixelformat= V4L2_PIX_FMT_RGB555,
+   .depth  = { 16 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_ARGB1555,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = XRGB-, 32 bpp,
+   .pixelformat= V4L2_PIX_FMT_RGB32,
+   .depth  = { 32 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_ARGB,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = YUV 4:2:2 packed, YCrYCb,
+   .pixelformat= V4L2_PIX_FMT_YVYU,
+   .depth  = { 16

Re: [PATCH v3 3/4] [media] exynos-scaler: Add m2m functionality for the SCALER driver

2013-09-30 Thread Shaik Ameer Basha
Hi Hans,

Thanks for pointing it out.


On Mon, Sep 30, 2013 at 1:38 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 Hi Shaik,

 I have a few questions regarding the selection part...

 On 09/12/2013 03:09 PM, Shaik Ameer Basha wrote:
 This patch adds the Makefile and memory to memory (m2m) interface
 functionality for the SCALER driver.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/Kconfig|8 +
  drivers/media/platform/Makefile   |1 +
  drivers/media/platform/exynos-scaler/Makefile |3 +
  drivers/media/platform/exynos-scaler/scaler-m2m.c |  781 
 +
  4 files changed, 793 insertions(+)
  create mode 100644 drivers/media/platform/exynos-scaler/Makefile
  create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c




[...]


 +
 +static int scaler_m2m_s_selection(struct file *file, void *fh,
 + struct v4l2_selection *s)
 +{
 + struct scaler_frame *frame;
 + struct scaler_ctx *ctx = fh_to_ctx(fh);
 + struct v4l2_crop cr;
 + struct scaler_variant *variant = ctx-scaler_dev-variant;
 + int ret;
 +
 + cr.type = s-type;
 + cr.c = s-r;
 +
 + if ((s-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) 
 + (s-type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE))
 + return -EINVAL;
 +
 + ret = scaler_try_crop(ctx, cr);
 + if (ret  0)
 + return ret;
 +
 + if (s-flags  V4L2_SEL_FLAG_LE 
 + !is_rectangle_enclosed(cr.c, s-r))
 + return -ERANGE;
 +
 + if (s-flags  V4L2_SEL_FLAG_GE 
 + !is_rectangle_enclosed(s-r, cr.c))
 + return -ERANGE;
 +
 + s-r = cr.c;
 +
 + switch (s-target) {
 + case V4L2_SEL_TGT_COMPOSE_BOUNDS:
 + case V4L2_SEL_TGT_COMPOSE_DEFAULT:
 + case V4L2_SEL_TGT_COMPOSE:
 + frame = ctx-s_frame;
 + break;
 +
 + case V4L2_SEL_TGT_CROP_BOUNDS:
 + case V4L2_SEL_TGT_CROP:
 + case V4L2_SEL_TGT_CROP_DEFAULT:
 + frame = ctx-d_frame;
 + break;

 Similar problems as with g_selection above. Tomasz mentioned to me that the 
 selection
 API is not implemented correctly in m2m Samsung drivers. It looks like this 
 code is
 copied-and-pasted from other drivers, so it seems he was right.

Sorry, after going through the documentation, I have to agree with you...
As you mentioned, this part of the code was copied while implementing
the G-Scaler driver :)

I will change the above implementation for M2M devices (GScaler and
SCALER) as below,
I will only allow all V4L2_SEL_TGT_COMPOSE_* target requests if
's-type' is equal to V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE.
and all V4L2_SEL_TGT_CROP_* target requests if 's-type' is equal to
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE.

I hope with the above two checkings taken in to care, there should not
be any issues with using selection APIs here.

Thanks,
Shaik Ameer Basha


 The selection API for m2m devices will be discussed during the upcoming V4L2 
 mini-summit
 since the API may actually need some adjustments to have it work the way it 
 should.

 As requested above, if you can explain the exact functionality you are trying 
 to
 implement here, then I can look over this code carefully and see how it 
 should be done.

 Thanks!

 Hans

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


Re: [PATCH v3 3/4] [media] exynos-scaler: Add m2m functionality for the SCALER driver

2013-09-30 Thread Shaik Ameer Basha
Hi Hans,


On Mon, Sep 30, 2013 at 4:02 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 On 09/30/2013 11:32 AM, Shaik Ameer Basha wrote:
 Hi Hans,

 Thanks for pointing it out.


 On Mon, Sep 30, 2013 at 1:38 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 Hi Shaik,

 I have a few questions regarding the selection part...

 On 09/12/2013 03:09 PM, Shaik Ameer Basha wrote:
 This patch adds the Makefile and memory to memory (m2m) interface
 functionality for the SCALER driver.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/Kconfig|8 +
  drivers/media/platform/Makefile   |1 +
  drivers/media/platform/exynos-scaler/Makefile |3 +
  drivers/media/platform/exynos-scaler/scaler-m2m.c |  781 
 +
  4 files changed, 793 insertions(+)
  create mode 100644 drivers/media/platform/exynos-scaler/Makefile
  create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c




 [...]


 +
 +static int scaler_m2m_s_selection(struct file *file, void *fh,
 + struct v4l2_selection *s)
 +{
 + struct scaler_frame *frame;
 + struct scaler_ctx *ctx = fh_to_ctx(fh);
 + struct v4l2_crop cr;
 + struct scaler_variant *variant = ctx-scaler_dev-variant;
 + int ret;
 +
 + cr.type = s-type;
 + cr.c = s-r;
 +
 + if ((s-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) 
 + (s-type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE))
 + return -EINVAL;
 +
 + ret = scaler_try_crop(ctx, cr);
 + if (ret  0)
 + return ret;
 +
 + if (s-flags  V4L2_SEL_FLAG_LE 
 + !is_rectangle_enclosed(cr.c, s-r))
 + return -ERANGE;
 +
 + if (s-flags  V4L2_SEL_FLAG_GE 
 + !is_rectangle_enclosed(s-r, cr.c))
 + return -ERANGE;
 +
 + s-r = cr.c;
 +
 + switch (s-target) {
 + case V4L2_SEL_TGT_COMPOSE_BOUNDS:
 + case V4L2_SEL_TGT_COMPOSE_DEFAULT:
 + case V4L2_SEL_TGT_COMPOSE:
 + frame = ctx-s_frame;
 + break;
 +
 + case V4L2_SEL_TGT_CROP_BOUNDS:
 + case V4L2_SEL_TGT_CROP:
 + case V4L2_SEL_TGT_CROP_DEFAULT:
 + frame = ctx-d_frame;
 + break;

 Similar problems as with g_selection above. Tomasz mentioned to me that the 
 selection
 API is not implemented correctly in m2m Samsung drivers. It looks like this 
 code is
 copied-and-pasted from other drivers, so it seems he was right.

 Sorry, after going through the documentation, I have to agree with you...
 As you mentioned, this part of the code was copied while implementing
 the G-Scaler driver :)

 I will change the above implementation for M2M devices (GScaler and
 SCALER) as below,
 I will only allow all V4L2_SEL_TGT_COMPOSE_* target requests if
 's-type' is equal to V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE.
 and all V4L2_SEL_TGT_CROP_* target requests if 's-type' is equal to
 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE.

 I hope with the above two checkings taken in to care, there should not
 be any issues with using selection APIs here.

 Well, that depends on what the hardware does.

 Using compose with a capture buffer means that the frame as delivered by
 the hardware is composed into a larger buffer. E.g. the hardware gives
 you 1280x720 which is composed into a buffer of size 1920x1080.

 Using crop with an output buffer means that the hardware gets a cropped
 part of a larger frame. E.g. you give a 1280x720 crop from a larger 1920x1080
 buffer.

 I suspect however, that in this case the hardware does the opposite for
 capture: you really want to crop with a capture buffer (e.g. the hardware
 delivers a 1280x720 frame which is cropped before DMA to 640x360).

 I'm not sure what you want to do with an output buffer: cropping or composing.

 Tomasz mentioned that the M2M + selection API was screwy, and this seems to
 be to be the case indeed.

 Which is also why I would like to know exactly what this hardware does.

This hardware is just a M2M device.
It accepts one source buffer at a time and does some operations on
that and saves to the destination buffer.
Operations like Rotation, Cropping, Scaling, Color Space Conversion
etc are possible.

Here when I provide the Output buffer (source buffer), I can apply all
V4L2_SEL_TGT_CROP_* targets on it.
That means I can select the whole buffer for processing or apply some
crop and select that area for further processing.

similarly, On the capture buffer (output buffer), I can apply
V4L2_SEL_TGT_COMPOSE_* targets.
That means I can compose the final output to the complete capture
frame (dst frame), or I can choose some part of the destination frame.

Regards,
Shaik Ameer Basha



 Regards,

 Hans


 Thanks,
 Shaik Ameer Basha


 The selection API for m2m devices will be discussed during the upcoming 
 V4L2 mini-summit
 since the API may actually need some adjustments to have it work the way it 
 should.

 As requested above, if you can explain the exact functionality

Re: [PATCH v3 3/4] [media] exynos-scaler: Add m2m functionality for the SCALER driver

2013-09-30 Thread Shaik Ameer Basha
On Mon, Sep 30, 2013 at 4:18 PM, Shaik Ameer Basha
shaik.sams...@gmail.com wrote:
 Hi Hans,


 On Mon, Sep 30, 2013 at 4:02 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 On 09/30/2013 11:32 AM, Shaik Ameer Basha wrote:
 Hi Hans,

 Thanks for pointing it out.


 On Mon, Sep 30, 2013 at 1:38 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 Hi Shaik,

 I have a few questions regarding the selection part...

 On 09/12/2013 03:09 PM, Shaik Ameer Basha wrote:
 This patch adds the Makefile and memory to memory (m2m) interface
 functionality for the SCALER driver.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/Kconfig|8 +
  drivers/media/platform/Makefile   |1 +
  drivers/media/platform/exynos-scaler/Makefile |3 +
  drivers/media/platform/exynos-scaler/scaler-m2m.c |  781 
 +
  4 files changed, 793 insertions(+)
  create mode 100644 drivers/media/platform/exynos-scaler/Makefile
  create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c




 [...]


 +
 +static int scaler_m2m_s_selection(struct file *file, void *fh,
 + struct v4l2_selection *s)
 +{
 + struct scaler_frame *frame;
 + struct scaler_ctx *ctx = fh_to_ctx(fh);
 + struct v4l2_crop cr;
 + struct scaler_variant *variant = ctx-scaler_dev-variant;
 + int ret;
 +
 + cr.type = s-type;
 + cr.c = s-r;
 +
 + if ((s-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) 
 + (s-type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE))
 + return -EINVAL;
 +
 + ret = scaler_try_crop(ctx, cr);
 + if (ret  0)
 + return ret;
 +
 + if (s-flags  V4L2_SEL_FLAG_LE 
 + !is_rectangle_enclosed(cr.c, s-r))
 + return -ERANGE;
 +
 + if (s-flags  V4L2_SEL_FLAG_GE 
 + !is_rectangle_enclosed(s-r, cr.c))
 + return -ERANGE;
 +
 + s-r = cr.c;
 +
 + switch (s-target) {
 + case V4L2_SEL_TGT_COMPOSE_BOUNDS:
 + case V4L2_SEL_TGT_COMPOSE_DEFAULT:
 + case V4L2_SEL_TGT_COMPOSE:
 + frame = ctx-s_frame;
 + break;
 +
 + case V4L2_SEL_TGT_CROP_BOUNDS:
 + case V4L2_SEL_TGT_CROP:
 + case V4L2_SEL_TGT_CROP_DEFAULT:
 + frame = ctx-d_frame;
 + break;

 Similar problems as with g_selection above. Tomasz mentioned to me that 
 the selection
 API is not implemented correctly in m2m Samsung drivers. It looks like 
 this code is
 copied-and-pasted from other drivers, so it seems he was right.

 Sorry, after going through the documentation, I have to agree with you...
 As you mentioned, this part of the code was copied while implementing
 the G-Scaler driver :)

 I will change the above implementation for M2M devices (GScaler and
 SCALER) as below,
 I will only allow all V4L2_SEL_TGT_COMPOSE_* target requests if
 's-type' is equal to V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE.
 and all V4L2_SEL_TGT_CROP_* target requests if 's-type' is equal to
 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE.

 I hope with the above two checkings taken in to care, there should not
 be any issues with using selection APIs here.

 Well, that depends on what the hardware does.

 Using compose with a capture buffer means that the frame as delivered by
 the hardware is composed into a larger buffer. E.g. the hardware gives
 you 1280x720 which is composed into a buffer of size 1920x1080.

 Using crop with an output buffer means that the hardware gets a cropped
 part of a larger frame. E.g. you give a 1280x720 crop from a larger 1920x1080
 buffer.

 I suspect however, that in this case the hardware does the opposite for
 capture: you really want to crop with a capture buffer (e.g. the hardware
 delivers a 1280x720 frame which is cropped before DMA to 640x360).

 I'm not sure what you want to do with an output buffer: cropping or 
 composing.

 Tomasz mentioned that the M2M + selection API was screwy, and this seems to
 be to be the case indeed.

 Which is also why I would like to know exactly what this hardware does.

 This hardware is just a M2M device.
 It accepts one source buffer at a time and does some operations on
 that and saves to the destination buffer.
 Operations like Rotation, Cropping, Scaling, Color Space Conversion
 etc are possible.

 Here when I provide the Output buffer (source buffer), I can apply all
 V4L2_SEL_TGT_CROP_* targets on it.
 That means I can select the whole buffer for processing or apply some
 crop and select that area for further processing.

 similarly, On the capture buffer (output buffer), I can apply

similarly, On the capture buffer (destination buffer), I can apply

 V4L2_SEL_TGT_COMPOSE_* targets.
 That means I can compose the final output to the complete capture
 frame (dst frame), or I can choose some part of the destination frame.

 Regards,
 Shaik Ameer Basha



 Regards,

 Hans


 Thanks,
 Shaik Ameer Basha


 The selection API for m2m devices will be discussed during the upcoming

[PATCH] [media] v4l2-mem2mem: Don't schedule the context if abort job is called

2013-09-20 Thread Shaik Ameer Basha
When the current context is running,
1] If release is called, it waits until the job is finished.
2] As soon as the job is finished, v4l2_mem_ctx_release()tries to
   release the vb2 queues.
3] But if the current context can be scheduled in the v4l2_m2m_job_finish()
   it schedules the context and tries to call device_run().
4] As the release() and device_run() sequence can't be predicted sometimes
   device_run() may get empty vb2 buffers.

This patch adds the ABORT state to the job_flags. Once the job_abort() or
release() is called on the context, the same context will not be scheduled in
the v4l2_m2m_job_finish().

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/v4l2-core/v4l2-mem2mem.c |   12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c 
b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 7c43712..d5741be 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -41,6 +41,8 @@ module_param(debug, bool, 0644);
 #define TRANS_QUEUED   (1  0)
 /* Instance is currently running in hardware */
 #define TRANS_RUNNING  (1  1)
+/* Instance is currently aborting */
+#define TRANS_ABORT(1  2)
 
 
 /* Offset base for buffers on the destination queue - used to distinguish
@@ -221,6 +223,14 @@ static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx 
*m2m_ctx)
}
 
spin_lock_irqsave(m2m_dev-job_spinlock, flags_job);
+
+   /* If the context is aborted then don't schedule it */
+   if (m2m_ctx-job_flags  TRANS_ABORT) {
+   spin_unlock_irqrestore(m2m_dev-job_spinlock, flags_job);
+   dprintk(Aborted context\n);
+   return;
+   }
+
if (m2m_ctx-job_flags  TRANS_QUEUED) {
spin_unlock_irqrestore(m2m_dev-job_spinlock, flags_job);
dprintk(On job queue already\n);
@@ -280,6 +290,8 @@ static void v4l2_m2m_cancel_job(struct v4l2_m2m_ctx 
*m2m_ctx)
 
m2m_dev = m2m_ctx-m2m_dev;
spin_lock_irqsave(m2m_dev-job_spinlock, flags);
+
+   m2m_ctx-job_flags |= TRANS_ABORT;
if (m2m_ctx-job_flags  TRANS_RUNNING) {
spin_unlock_irqrestore(m2m_dev-job_spinlock, flags);
m2m_dev-m2m_ops-job_abort(m2m_ctx-priv);
-- 
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] [media] exynos-gsc: Handle ctx job finish when aborted

2013-09-20 Thread Shaik Ameer Basha
When the current context is running,
1] If release() or streamoff() is called on the current context,
   it waits until the job is aborted or finished.
2] If the job is finished, driver will call the v4l2_m2m_job_finish().
3] If the job is aborted inside device_run callback, then driver
   has to inform the v4l2 mem2mem framework about the same by calling
   v4l2_m2m_job_finish() with VB2_BUF_STATE_ERROR.

The current code doesn't call v4l2_m2m_job_finish() in the case, where
the job is aborted from the device_run callback. This scenerio is
producing a hang as the other queued contexts are not getting scheduled.

By adding the ABORT state, driver can understand the current job
is aborted and not finished. By checking this flag, driver can call
v4l2_m2m_job_finish() with VB2_BUF_STATE_ERROR.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: avnd kiran avnd.ki...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-core.h |1 +
 drivers/media/platform/exynos-gsc/gsc-m2m.c  |   29 ++
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h 
b/drivers/media/platform/exynos-gsc/gsc-core.h
index 76435d3..ef0a656 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/exynos-gsc/gsc-core.h
@@ -45,6 +45,7 @@
 #define GSC_DST_FMT(1  2)
 #define GSC_CTX_M2M(1  3)
 #define GSC_CTX_STOP_REQ   (1  6)
+#defineGSC_CTX_ABORT   (1  7)
 
 enum gsc_dev_flags {
/* for global */
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index e576ff2..810c3e1 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -46,6 +46,17 @@ static int gsc_m2m_ctx_stop_req(struct gsc_ctx *ctx)
return ret == 0 ? -ETIMEDOUT : ret;
 }
 
+static void __gsc_m2m_job_abort(struct gsc_ctx *ctx)
+{
+   int ret;
+
+   ret = gsc_m2m_ctx_stop_req(ctx);
+   if ((ret == -ETIMEDOUT) || (ctx-state  GSC_CTX_ABORT)) {
+   gsc_ctx_state_lock_clear(GSC_CTX_STOP_REQ | GSC_CTX_ABORT, ctx);
+   gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+   }
+}
+
 static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
 {
struct gsc_ctx *ctx = q-drv_priv;
@@ -58,11 +69,8 @@ static int gsc_m2m_start_streaming(struct vb2_queue *q, 
unsigned int count)
 static int gsc_m2m_stop_streaming(struct vb2_queue *q)
 {
struct gsc_ctx *ctx = q-drv_priv;
-   int ret;
 
-   ret = gsc_m2m_ctx_stop_req(ctx);
-   if (ret == -ETIMEDOUT)
-   gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+   __gsc_m2m_job_abort(ctx);
 
pm_runtime_put(ctx-gsc_dev-pdev-dev);
 
@@ -91,15 +99,9 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
}
 }
 
-
 static void gsc_m2m_job_abort(void *priv)
 {
-   struct gsc_ctx *ctx = priv;
-   int ret;
-
-   ret = gsc_m2m_ctx_stop_req(ctx);
-   if (ret == -ETIMEDOUT)
-   gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+   __gsc_m2m_job_abort((struct gsc_ctx *)priv);
 }
 
 static int gsc_get_bufs(struct gsc_ctx *ctx)
@@ -150,9 +152,10 @@ static void gsc_m2m_device_run(void *priv)
gsc-m2m.ctx = ctx;
}
 
-   is_set = (ctx-state  GSC_CTX_STOP_REQ) ? 1 : 0;
-   ctx-state = ~GSC_CTX_STOP_REQ;
+   is_set = ctx-state  GSC_CTX_STOP_REQ;
if (is_set) {
+   ctx-state = ~GSC_CTX_STOP_REQ;
+   ctx-state |= GSC_CTX_ABORT;
wake_up(gsc-irq_queue);
goto put_device;
}
-- 
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 v3 2/4] [media] exynos-scaler: Add core functionality for the SCALER driver

2013-09-17 Thread Shaik Ameer Basha
Hi Sylwester,

Thanks for the comments.

On Mon, Sep 16, 2013 at 3:58 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Shaik,

 Thanks for addressing my comments, it really looks much better now.
 I have few more comments, mostly minor issues.

[...]

 +
 +const struct scaler_fmt *scaler_find_fmt(u32 *pixelformat,
 +   u32 *mbus_code, u32 index)
 +{
 +   const struct scaler_fmt *fmt, *def_fmt = NULL;
 +   unsigned int i;
 +
 +   if (index= ARRAY_SIZE(scaler_formats))
 +   return NULL;
 +
 +   for (i = 0; i  ARRAY_SIZE(scaler_formats); ++i) {
 +   fmt = scaler_get_format(i);
 +   if (pixelformat  fmt-pixelformat == *pixelformat)
 +   return fmt;


 +   if (mbus_code  fmt-mbus_code == *mbus_code)
 +   return fmt;


 is mbus_code ever used ?

Yes. Currently not used. Will remove this field for now..


 +   if (index == i)
 +   def_fmt = fmt;
 +   }
 +
 +   return def_fmt;
 +}

[...]

 +
 +int scaler_try_fmt_mplane(struct scaler_ctx *ctx, struct v4l2_format *f)
 +{
 +   struct scaler_dev *scaler = ctx-scaler_dev;
 +   struct device *dev =scaler-pdev-dev;

 +   struct scaler_variant *variant = scaler-variant;
 +   struct v4l2_pix_format_mplane *pix_mp =f-fmt.pix_mp;


[...]

 +
 +   /*
 +* Nothing mentioned about the colorspace in SCALER. Default value
 is
 +* set to V4L2_COLORSPACE_REC709.
 +*/


 Isn't scaler_hw_set_csc_coef() function configuring the colorspace ?

Actually speaking this function should do the color space setting part.
What the SCALER ip supports is CSC offset value for Y

YCbCr to RGB : Zero offset of -16 offset for input
RGB to YCbCr : Zero offset of +16 offset for output

I think user should provide this information through some controls.
Anyways, will take it later.


 +   pix_mp-colorspace = V4L2_COLORSPACE_REC709;
 +
 +   for (i = 0; i  pix_mp-num_planes; ++i) {
 +   int bpl = (pix_mp-width * fmt-depth[i])  3;
 +   pix_mp-plane_fmt[i].bytesperline = bpl;
 +   pix_mp-plane_fmt[i].sizeimage = bpl * pix_mp-height;
 +
 +   scaler_dbg(scaler, [%d]: bpl: %d, sizeimage: %d,
 +   i, bpl, pix_mp-plane_fmt[i].sizeimage);
 +   }
 +
 +   return 0;
 +}
 +

[...]

 +static int scaler_runtime_resume(struct device *dev)
 +{
 +   struct scaler_dev *scaler = dev_get_drvdata(dev);
 +   int ret = 0;
 +   scaler_dbg(scaler, state: 0x%lx, scaler-state);
 +
 +   ret = clk_enable(scaler-clock);
 +   if (ret  0)
 +   return ret;
 +
 +   scaler_sw_reset(scaler);
 +
 +   return scaler_m2m_resume(scaler);


 Shouldn't there be clk_disable() when this function fails ?

this funciton scaler_m2m_resume() never fails.


Regards,
Shaik Ameer Basha
--
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 2/4] [media] exynos-scaler: Add core functionality for the SCALER driver

2013-09-17 Thread Shaik Ameer Basha
Hi sylwester,



 Isn't scaler_hw_set_csc_coef() function configuring the colorspace ?

 Actually speaking this function should do the color space setting part.
 What the SCALER ip supports is CSC offset value for Y

 YCbCr to RGB : Zero offset of -16 offset for input
 RGB to YCbCr : Zero offset of +16 offset for output

small spelling mistake here..

YCbCr to RGB : Zero offset or -16 offset for input
RGB to YCbCr : Zero offset or +16 offset for output

Regards,
Shaik Ameer Basha


 I think user should provide this information through some controls.
 Anyways, will take it later.


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


Re: [PATCH RFC 6/7] exynos-gsc: Use mem-to-mem ioctl helpers

2013-09-13 Thread Shaik Ameer Basha
() has some buffer count related checks.

Regards,
Shaik Ameer Basha

 +   .vidioc_querybuf= v4l2_m2m_ioctl_querybuf,
 +   .vidioc_expbuf  = v4l2_m2m_ioctl_expbuf,
 +   .vidioc_qbuf= v4l2_m2m_ioctl_qbuf,
 +   .vidioc_dqbuf   = v4l2_m2m_ioctl_dqbuf,
 +
 +   .vidioc_streamon= v4l2_m2m_ioctl_streamon,
 +   .vidioc_streamoff   = v4l2_m2m_ioctl_streamoff,
 .vidioc_g_selection = gsc_m2m_g_selection,
 .vidioc_s_selection = gsc_m2m_s_selection
  };
 @@ -588,6 +539,7 @@ static int queue_init(void *priv, struct vb2_queue 
 *src_vq,
 src_vq-mem_ops = vb2_dma_contig_memops;
 src_vq-buf_struct_size = sizeof(struct v4l2_m2m_buffer);
 src_vq-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 +   src_vq-lock = ctx-gsc_dev-lock;

 ret = vb2_queue_init(src_vq);
 if (ret)
 @@ -601,6 +553,7 @@ static int queue_init(void *priv, struct vb2_queue 
 *src_vq,
 dst_vq-mem_ops = vb2_dma_contig_memops;
 dst_vq-buf_struct_size = sizeof(struct v4l2_m2m_buffer);
 dst_vq-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 +   dst_vq-lock = ctx-gsc_dev-lock;

 return vb2_queue_init(dst_vq);
  }
 @@ -648,6 +601,7 @@ static int gsc_m2m_open(struct file *file)
 ret = PTR_ERR(ctx-m2m_ctx);
 goto error_ctrls;
 }
 +   ctx-fh.m2m_ctx = ctx-m2m_ctx;

 if (gsc-m2m.refcnt++ == 0)
 set_bit(ST_M2M_OPEN, gsc-state);
 @@ -691,44 +645,13 @@ static int gsc_m2m_release(struct file *file)
 return 0;
  }

 -static unsigned int gsc_m2m_poll(struct file *file,
 -   struct poll_table_struct *wait)
 -{
 -   struct gsc_ctx *ctx = fh_to_ctx(file-private_data);
 -   struct gsc_dev *gsc = ctx-gsc_dev;
 -   int ret;
 -
 -   if (mutex_lock_interruptible(gsc-lock))
 -   return -ERESTARTSYS;
 -
 -   ret = v4l2_m2m_poll(file, ctx-m2m_ctx, wait);
 -   mutex_unlock(gsc-lock);
 -
 -   return ret;
 -}
 -
 -static int gsc_m2m_mmap(struct file *file, struct vm_area_struct *vma)
 -{
 -   struct gsc_ctx *ctx = fh_to_ctx(file-private_data);
 -   struct gsc_dev *gsc = ctx-gsc_dev;
 -   int ret;
 -
 -   if (mutex_lock_interruptible(gsc-lock))
 -   return -ERESTARTSYS;
 -
 -   ret = v4l2_m2m_mmap(file, ctx-m2m_ctx, vma);
 -   mutex_unlock(gsc-lock);
 -
 -   return ret;
 -}
 -
  static const struct v4l2_file_operations gsc_m2m_fops = {
 .owner  = THIS_MODULE,
 .open   = gsc_m2m_open,
 .release= gsc_m2m_release,
 -   .poll   = gsc_m2m_poll,
 +   .poll   = v4l2_m2m_fop_poll,
 .unlocked_ioctl = video_ioctl2,
 -   .mmap   = gsc_m2m_mmap,
 +   .mmap   = v4l2_m2m_fop_mmap,
  };

  static struct v4l2_m2m_ops gsc_m2m_ops = {
 --
 1.7.9.5

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


[PATCH v3 2/4] [media] exynos-scaler: Add core functionality for the SCALER driver

2013-09-12 Thread Shaik Ameer Basha
This patch adds the core functionality for the SCALER driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-scaler/scaler.c | 1261 +
 drivers/media/platform/exynos-scaler/scaler.h |  385 
 2 files changed, 1646 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler.h

diff --git a/drivers/media/platform/exynos-scaler/scaler.c 
b/drivers/media/platform/exynos-scaler/scaler.c
new file mode 100644
index 000..c22707c
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler.c
@@ -0,0 +1,1261 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/interrupt.h
+#include linux/module.h
+#include linux/of_platform.h
+#include linux/pm_runtime.h
+
+#include scaler-regs.h
+
+#define SCALER_CLOCK_GATE_NAME scaler
+
+static const struct scaler_fmt scaler_formats[] = {
+   {
+   .name   = YUV 4:2:0 non-contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12M,
+   .depth  = { 8, 4 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+
+   }, {
+   .name   = YUV 4:2:0 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12,
+   .depth  = { 12 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = YUV 4:2:0 n.c. 2p, Y/CbCr tiled,
+   .pixelformat= V4L2_PIX_FMT_NV12MT_16X16,
+   .depth  = { 8, 4 },
+   .color  = SCALER_YUV420,
+   .color_order= SCALER_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV420_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_TILED),
+   }, {
+   .name   = YUV 4:2:2 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV16,
+   .depth  = { 16 },
+   .color  = SCALER_YUV422,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV422_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = YUV 4:4:4 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV24,
+   .depth  = { 24 },
+   .color  = SCALER_YUV444,
+   .color_order= SCALER_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .scaler_color   = SCALER_YUV444_2P_Y_UV,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = RGB565,
+   .pixelformat= V4L2_PIX_FMT_RGB565X,
+   .depth  = { 16 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_RGB565,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = XRGB-1555, 16 bpp,
+   .pixelformat= V4L2_PIX_FMT_RGB555,
+   .depth  = { 16 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_ARGB1555,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = XRGB-, 32 bpp,
+   .pixelformat= V4L2_PIX_FMT_RGB32,
+   .depth  = { 32 },
+   .color  = SCALER_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .scaler_color   = SCALER_ARGB,
+   .flags  = (SCALER_FMT_SRC | SCALER_FMT_DST),
+   }, {
+   .name   = YUV 4:2:2 packed, YCrYCb,
+   .pixelformat= V4L2_PIX_FMT_YVYU,
+   .depth  = { 16

[PATCH v3 4/4] [media] exynos-scaler: Add DT bindings for SCALER driver

2013-09-12 Thread Shaik Ameer Basha
This patch adds the DT binding documentation for the
Exynos5420/5410 based SCALER device driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 .../devicetree/bindings/media/exynos5-scaler.txt   |   22 
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-scaler.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-scaler.txt 
b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
new file mode 100644
index 000..f620baf
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-scaler.txt
@@ -0,0 +1,22 @@
+* Samsung Exynos5 SCALER device
+
+SCALER is used for scaling, blending, color fill and color space
+conversion on EXYNOS[5420/5410] SoCs.
+
+Required properties:
+- compatible: should be samsung,exynos5420-scaler or
+   samsung,exynos5410-scaler
+- reg: should contain SCALER physical address location and length.
+- interrupts: should contain SCALER interrupt number
+- clocks: should contain the SCALER clock specifier, from the
+   common clock bindings
+- clock-names: should be scaler
+
+Example:
+   scaler_0: scaler@0x1280 {
+   compatible = samsung,exynos5420-scaler;
+   reg = 0x1280 0x1000;
+   interrupts = 0 220 0;
+   clocks = clock 381;
+   clock-names = scaler;
+   };
-- 
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 v3 3/4] [media] exynos-scaler: Add m2m functionality for the SCALER driver

2013-09-12 Thread Shaik Ameer Basha
This patch adds the Makefile and memory to memory (m2m) interface
functionality for the SCALER driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/Kconfig|8 +
 drivers/media/platform/Makefile   |1 +
 drivers/media/platform/exynos-scaler/Makefile |3 +
 drivers/media/platform/exynos-scaler/scaler-m2m.c |  781 +
 4 files changed, 793 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/Makefile
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-m2m.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 8068d7b..339d3ba 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -201,6 +201,14 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
  This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
+config VIDEO_SAMSUNG_EXYNOS_SCALER
+   tristate Samsung Exynos SCALER driver
+   depends on OF  VIDEO_DEV  VIDEO_V4L2  ARCH_EXYNOS5
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+ This is a v4l2 driver for Samsung EXYNOS5410/5420 SoC SCALER.
+
 config VIDEO_SH_VEU
tristate SuperH VEU mem2mem video processing driver
depends on VIDEO_DEV  VIDEO_V4L2  GENERIC_HARDIRQS  HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 4e4da48..14cdad5 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_EXYNOS_SCALER)  += exynos-scaler/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos-scaler/Makefile 
b/drivers/media/platform/exynos-scaler/Makefile
new file mode 100644
index 000..6c8a25b
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/Makefile
@@ -0,0 +1,3 @@
+exynos-scaler-objs := scaler.o scaler-m2m.o scaler-regs.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_SCALER)  += exynos-scaler.o
diff --git a/drivers/media/platform/exynos-scaler/scaler-m2m.c 
b/drivers/media/platform/exynos-scaler/scaler-m2m.c
new file mode 100644
index 000..eb32f2f
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler-m2m.c
@@ -0,0 +1,781 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/module.h
+#include linux/pm_runtime.h
+
+#include media/v4l2-ioctl.h
+
+#include scaler-regs.h
+
+#define SCALER_DEF_PIX_FMT V4L2_PIX_FMT_RGB32
+#define SCALER_DEF_WIDTH   1280
+#define SCALER_DEF_HEIGHT  720
+
+static int scaler_m2m_ctx_stop_req(struct scaler_ctx *ctx)
+{
+   struct scaler_ctx *curr_ctx;
+   struct scaler_dev *scaler = ctx-scaler_dev;
+   int ret;
+
+   curr_ctx = v4l2_m2m_get_curr_priv(scaler-m2m.m2m_dev);
+   if (!scaler_m2m_pending(scaler) || (curr_ctx != ctx))
+   return 0;
+
+   scaler_ctx_state_lock_set(SCALER_CTX_STOP_REQ, ctx);
+   ret = wait_event_timeout(scaler-irq_queue,
+   !scaler_ctx_state_is_set(SCALER_CTX_STOP_REQ, ctx),
+   SCALER_SHUTDOWN_TIMEOUT);
+
+   return ret == 0 ? -ETIMEDOUT : ret;
+}
+
+static int scaler_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
+{
+   struct scaler_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = pm_runtime_get_sync(ctx-scaler_dev-pdev-dev);
+
+   return ret  0 ? 0 : ret;
+}
+
+static int scaler_m2m_stop_streaming(struct vb2_queue *q)
+{
+   struct scaler_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = scaler_m2m_ctx_stop_req(ctx);
+   if (ret  0)
+   scaler_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+   pm_runtime_put(ctx-scaler_dev-pdev-dev);
+
+   return 0;
+}
+
+void scaler_m2m_job_finish(struct scaler_ctx *ctx, int vb_state)
+{
+   struct vb2_buffer *src_vb, *dst_vb;
+
+   if (!ctx || !ctx-m2m_ctx)
+   return;
+
+   src_vb = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
+   dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
+
+   if (src_vb  dst_vb) {
+   v4l2_m2m_buf_done(src_vb, vb_state);
+   v4l2_m2m_buf_done(dst_vb, vb_state);
+
+   v4l2_m2m_job_finish(ctx-scaler_dev-m2m.m2m_dev,
+   ctx-m2m_ctx);
+   }
+}
+
+static void scaler_m2m_job_abort(void *priv)
+{
+   struct scaler_ctx *ctx = priv;
+   int ret;
+
+   ret = scaler_m2m_ctx_stop_req(ctx);
+   if (ret  0

[PATCH v3 1/4] [media] exynos-scaler: Add new driver for Exynos5 SCALER

2013-09-12 Thread Shaik Ameer Basha
This patch adds support for SCALER device which is a new device
for scaling, blending, color fill  and color space conversion
on EXYNOS5410 and EXYNOS5420 SoCs.

This device supports the followings as key feature.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size - Exynos5420
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
Size - Exynos5410
- Input/Output: 4x4 to 4096x4096
alpha blending, color fill

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-scaler/scaler-regs.c |  334 
 drivers/media/platform/exynos-scaler/scaler-regs.h |  331 +++
 2 files changed, 665 insertions(+)
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.c
 create mode 100644 drivers/media/platform/exynos-scaler/scaler-regs.h

diff --git a/drivers/media/platform/exynos-scaler/scaler-regs.c 
b/drivers/media/platform/exynos-scaler/scaler-regs.c
new file mode 100644
index 000..6c488ce
--- /dev/null
+++ b/drivers/media/platform/exynos-scaler/scaler-regs.c
@@ -0,0 +1,334 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series SCALER driver
+ *
+ * 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/delay.h
+#include linux/platform_device.h
+
+#include scaler-regs.h
+
+/* Scaler reset timeout in milliseconds */
+#define SCALER_RESET_TIMEOUT   50
+
+void scaler_hw_set_sw_reset(struct scaler_dev *dev)
+{
+   u32 cfg;
+
+   cfg = scaler_read(dev, SCALER_CFG);
+   cfg |= SCALER_CFG_SOFT_RESET;
+
+   scaler_write(dev, SCALER_CFG, cfg);
+}
+
+int scaler_wait_reset(struct scaler_dev *dev)
+{
+   unsigned long end = jiffies + msecs_to_jiffies(SCALER_RESET_TIMEOUT);
+   u32 cfg, reset_done = 0;
+
+   while (time_before(jiffies, end)) {
+   cfg = scaler_read(dev, SCALER_CFG);
+   if (!(cfg  SCALER_CFG_SOFT_RESET)) {
+   reset_done = 1;
+   break;
+   }
+   usleep_range(10, 20);
+   }
+
+   /*
+* Write any value to read/write register and read it back.
+* If the written and read value matches, then the reset process is
+* succeeded.
+*/
+   while (reset_done) {
+
+   /*
+* [TODO] need to define number of tries before returning
+* -EBUSY to the caller
+*/
+
+   scaler_write(dev, SCALER_CFG_SOFT_RESET_CHECK_REG,
+   SCALER_CFG_SOFT_RESET_CHECK_VAL);
+   if (SCALER_CFG_SOFT_RESET_CHECK_VAL ==
+   scaler_read(dev, SCALER_CFG_SOFT_RESET_CHECK_REG))
+   return 0;
+   }
+
+   return -EBUSY;
+}
+
+void scaler_hw_set_irq(struct scaler_dev *dev, int irq_num, bool enable)
+{
+   u32 cfg;
+
+   if ((irq_num  SCALER_INT_FRAME_END) ||
+   (irq_num  SCALER_INT_TIMEOUT))
+   return;
+
+   cfg = scaler_read(dev, SCALER_INT_EN);
+   if (enable)
+   cfg |= (1  irq_num);
+   else
+   cfg = ~(1  irq_num);
+   scaler_write(dev, SCALER_INT_EN, cfg);
+}
+
+void scaler_hw_set_input_addr(struct scaler_dev *dev, struct scaler_addr *addr)
+{
+   scaler_dbg(dev, src_buf: 0x%x, cb: 0x%x, cr: 0x%x,
+   addr-y, addr-cb, addr-cr);
+   scaler_write(dev, SCALER_SRC_Y_BASE, addr-y);
+   scaler_write(dev, SCALER_SRC_CB_BASE, addr-cb);
+   scaler_write(dev, SCALER_SRC_CR_BASE, addr-cr);
+}
+
+void scaler_hw_set_output_addr(struct scaler_dev *dev,
+struct scaler_addr *addr)
+{
+   scaler_dbg(dev, dst_buf: 0x%x, cb: 0x%x, cr: 0x%x,
+   addr-y, addr-cb, addr-cr);
+   scaler_write(dev, SCALER_DST_Y_BASE, addr-y);
+   scaler_write(dev, SCALER_DST_CB_BASE, addr-cb);
+   scaler_write(dev, SCALER_DST_CR_BASE, addr-cr);
+}
+
+void scaler_hw_set_in_size(struct scaler_ctx *ctx)
+{
+   struct scaler_dev *dev = ctx-scaler_dev;
+   struct scaler_frame *frame = ctx-s_frame;
+   u32 cfg;
+
+   /* set input pixel offset

Re: [PATCH v2 3/5] [media] exynos-mscl: Add m2m functionality for the M-Scaler driver

2013-09-10 Thread Shaik Ameer Basha
Hi Sylwester,

Almost all of the comments are already addressed.
Will try to post the v3 by tomorrow.

I have one doubt?
Do I need to rebase this driver on m2m-helpers-v2 or once the driver
is merged we can take this up?

Regards,
Shaik Ameer Basha


On Thu, Aug 29, 2013 at 6:51 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 On 08/19/2013 12:58 PM, Shaik Ameer Basha wrote:
 This patch adds the memory to memory (m2m) interface functionality
 for the M-Scaler driver.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/exynos-mscl/mscl-m2m.c |  763 
 +
  1 file changed, 763 insertions(+)
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-m2m.c

 diff --git a/drivers/media/platform/exynos-mscl/mscl-m2m.c 
 b/drivers/media/platform/exynos-mscl/mscl-m2m.c
 new file mode 100644
 index 000..fecbb57
 --- /dev/null
 +++ b/drivers/media/platform/exynos-mscl/mscl-m2m.c
 @@ -0,0 +1,763 @@
 +/*
 + * Copyright (c) 2013 - 2014 Samsung Electronics Co., Ltd.

 2013 - 2014 ??

 + *   http://www.samsung.com
 + *
 + * Samsung EXYNOS5 SoC series M-Scaler driver
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published
 + * by the Free Software Foundation, either version 2 of the License,
 + * or (at your option) any later version.
 + */
 +
 +#include linux/module.h
 +#include linux/pm_runtime.h
 +#include linux/slab.h
 +
 +#include media/v4l2-ioctl.h
 +
 +#include mscl-core.h
 +
 +static int mscl_m2m_ctx_stop_req(struct mscl_ctx *ctx)
 +{
 + struct mscl_ctx *curr_ctx;
 + struct mscl_dev *mscl = ctx-mscl_dev;
 + int ret;
 +
 + curr_ctx = v4l2_m2m_get_curr_priv(mscl-m2m.m2m_dev);
 + if (!mscl_m2m_pending(mscl) || (curr_ctx != ctx))
 + return 0;
 +
 + mscl_ctx_state_lock_set(MSCL_CTX_STOP_REQ, ctx);
 + ret = wait_event_timeout(mscl-irq_queue,
 + !mscl_ctx_state_is_set(MSCL_CTX_STOP_REQ, ctx),
 + MSCL_SHUTDOWN_TIMEOUT);
 +
 + return ret == 0 ? -ETIMEDOUT : ret;
 +}
 +
 +static int mscl_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
 +{
 + struct mscl_ctx *ctx = q-drv_priv;
 + int ret;
 +
 + ret = pm_runtime_get_sync(ctx-mscl_dev-pdev-dev);
 +
 + return ret  0 ? 0 : ret;
 +}
 +
 +static int mscl_m2m_stop_streaming(struct vb2_queue *q)
 +{
 + struct mscl_ctx *ctx = q-drv_priv;
 + int ret;
 +
 + ret = mscl_m2m_ctx_stop_req(ctx);
 + if (ret == -ETIMEDOUT)
 + mscl_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
 +
 + pm_runtime_put(ctx-mscl_dev-pdev-dev);
 +
 + return 0;
 +}
 +
 +void mscl_m2m_job_finish(struct mscl_ctx *ctx, int vb_state)
 +{
 + struct vb2_buffer *src_vb, *dst_vb;
 +
 + if (!ctx || !ctx-m2m_ctx)
 + return;
 +
 + src_vb = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
 + dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
 +
 + if (src_vb  dst_vb) {
 + v4l2_m2m_buf_done(src_vb, vb_state);
 + v4l2_m2m_buf_done(dst_vb, vb_state);
 +
 + v4l2_m2m_job_finish(ctx-mscl_dev-m2m.m2m_dev,
 + ctx-m2m_ctx);
 + }
 +}
 +
 +

 Stray empty line.

 +static void mscl_m2m_job_abort(void *priv)
 +{
 + struct mscl_ctx *ctx = priv;
 + int ret;
 +
 + ret = mscl_m2m_ctx_stop_req(ctx);
 + if (ret == -ETIMEDOUT)
 + mscl_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
 +}
 +
 +static int mscl_get_bufs(struct mscl_ctx *ctx)
 +{
 + struct mscl_frame *s_frame, *d_frame;
 + struct vb2_buffer *src_vb, *dst_vb;
 + int ret;
 +
 + s_frame = ctx-s_frame;
 + d_frame = ctx-d_frame;
 +
 + src_vb = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
 + ret = mscl_prepare_addr(ctx, src_vb, s_frame, s_frame-addr);
 + if (ret)

 How about using if (ret  0) pattern consistently ?

 + return ret;
 +
 + dst_vb = v4l2_m2m_next_dst_buf(ctx-m2m_ctx);
 + ret = mscl_prepare_addr(ctx, dst_vb, d_frame, d_frame-addr);
 + if (ret)
 + return ret;
 +
 + dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
 +
 + return 0;
 +}
 +
 +static void mscl_m2m_device_run(void *priv)
 +{
 + struct mscl_ctx *ctx = priv;
 + struct mscl_dev *mscl;
 + unsigned long flags;
 + int ret;
 + bool is_set = false;

 Unneeded initialization. And I can see a room for improvement WRT
 the variable's name.

 +
 + if (WARN(!ctx, null hardware context\n))
 + return;
 +
 + mscl = ctx-mscl_dev;
 + spin_lock_irqsave(mscl-slock, flags);
 +
 + set_bit(ST_M2M_PEND, mscl-state);
 +
 + /* Reconfigure hardware if the context has changed. */
 + if (mscl-m2m.ctx != ctx) {
 + dev_dbg(mscl-pdev-dev,
 + mscl-m2m.ctx = 0x%p, current_ctx = 0x%p,
 + mscl-m2m.ctx, ctx);
 + ctx-state

Re: [PATCH v2 5/5] [media] exynos-mscl: Add Makefile for M-Scaler driver

2013-08-29 Thread Shaik Ameer Basha
Hi Sylwester,

On Thu, Aug 29, 2013 at 3:42 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 Hi Shaik,

 On 08/19/2013 12:58 PM, Shaik Ameer Basha wrote:
 This patch adds the Makefile for the M-Scaler (M2M scaler).

 Perhaps we could combine this with patch 3/5 ?

Ok. I will do that.

are you done with the review? can I start preparing for v3?

Regards,
Shaik



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


Re: [PATCH v2 4/5] [media] exynos-mscl: Add DT bindings for M-Scaler driver

2013-08-26 Thread Shaik Ameer Basha
Hi Sylwester,

Thanks for the comments.
Please find the response inline...

Actually, I am waiting for your comments only :)
are you also reviewing the driver code? If yes, I can delay the next
version until your post your comments.


On Sun, Aug 25, 2013 at 3:56 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 08/19/2013 02:57 PM, Inki Dae wrote:

 -Original Message-
 From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
 ow...@vger.kernel.org] On Behalf Of Shaik Ameer Basha
 Sent: Monday, August 19, 2013 7:59 PM
 To: linux-media@vger.kernel.org; linux-samsung-...@vger.kernel.org
 Cc: s.nawro...@samsung.com; posc...@google.com; arun...@samsung.com;
 shaik.am...@samsung.com
 Subject: [PATCH v2 4/5] [media] exynos-mscl: Add DT bindings for M-Scaler
 driver

 This patch adds the DT binding documentation for the exynos5


 You may want to say to which specific SoC it applies.

Ok. will update this.
Only 5410 and 5420 has this IP as of now.



 based M-Scaler device driver.

 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 ---
   .../devicetree/bindings/media/exynos5-mscl.txt |   34
 
   1 file changed, 34 insertions(+)
   create mode 100644 Documentation/devicetree/bindings/media/exynos5-
 mscl.txt

 diff --git a/Documentation/devicetree/bindings/media/exynos5-mscl.txt
 b/Documentation/devicetree/bindings/media/exynos5-mscl.txt
 new file mode 100644
 index 000..5c9d1b1
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/exynos5-mscl.txt
 @@ -0,0 +1,34 @@
 +* Samsung Exynos5 M-Scaler device
 +
 +M-Scaler is used for scaling, blending, color fill and color space
 +conversion on EXYNOS5 SoCs.
 +
 +Required properties:
 +- compatible: should be samsung,exynos5-mscl


 What is an exact name of this IP in the datasheet ?

It is named as SCALER. But when i got the Initial doc, it was also
known as memory to memory scaler.
so, i am using M-Scaler.

Can i change this name to SCALER instead ?



 If Exynos5410/5420 have same IP,
 samsung,exynos5410-mscl for M Scaler IP in Exynos5410/5420

 Else,
 Compatible: should be one of the following:
 (a) samsung,exynos5410-mscl for M Scaler IP in Exynos5410
 (b) samsung,exynos5420-mscl for M Scaler IP in Exynos5420


 Yes, except I suspect mscl is incorrect. It sounds like an unclear
 abbreviation of real name of the IP. It likely should be mscaler.


 +- reg: should contain M-Scaler physical address location and length.
 +- interrupts: should contain M-Scaler interrupt number
 +- clocks: should contain the clock number according to CCF


 Hmm, this sounds like a Linux specific term in the binding. Perhaps:

  - clocks: should contain the M-Scaler clock specifier, from the common
clock bindings


 ?

 +- clock-names: should be mscl
 +
 +Example:
 +
 +   mscl_0: mscl@0x1280 {


 s/0x//

Ok. Like this?
mscl_0: mscl@1280 {



 +   compatible = samsung,exynos5-mscl;


 samsung,exynos5410-mscl;

 +   reg =0x1280 0x1000;
 +   interrupts =0 220 0;
 +   clocks =clock 381;
 +   clock-names = mscl;
 +   };
 +
 +Aliases:
 +Each M-Scaler node should have a numbered alias in the aliases node,
 +in the form of msclN, N = 0...2. M-Scaler driver uses these aliases
 +to retrieve the device IDs using of_alias_get_id() call.


 So except in debug logs and for selecting variant data (which is same for
 all IP instances) are the aliases used for anything else ?
 I suspect you could do without these aliases. Device name includes start
 address of the IP register region, so that could be used to identify the
 M-Scaler instance in the logs.

Ok. I will check more.
If it is only used for logs, then i will remove the aliases.


Regards,
Shaik Ameer Basha


 --
 Regards,
 Sylwester

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


Re: [PATCH v2 2/5] [media] exynos-mscl: Add core functionality for the M-Scaler driver

2013-08-20 Thread Shaik Ameer Basha
On Tue, Aug 20, 2013 at 11:57 AM, Hans Verkuil hverk...@xs4all.nl wrote:
 On 08/20/2013 07:43 AM, Shaik Ameer Basha wrote:
 + linux-media, linux-samsung-soc

 Hi Hans,

 Thanks for the review.
 Will address all your comments in v3.

 I have only one doubt regarding try_ctrl... (addressed inline)


 On Mon, Aug 19, 2013 at 6:36 PM, Hans Verkuil hverk...@xs4all.nl wrote:

 On 08/19/2013 12:58 PM, Shaik Ameer Basha wrote:
 This patch adds the core functionality for the M-Scaler driver.

 Some more comments below...


 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/exynos-mscl/mscl-core.c | 1312 
 
  drivers/media/platform/exynos-mscl/mscl-core.h |  549 ++
  2 files changed, 1861 insertions(+)
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.c
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.h

 diff --git a/drivers/media/platform/exynos-mscl/mscl-core.c 
 b/drivers/media/platform/exynos-mscl/mscl-core.c
 new file mode 100644
 index 000..4a3a851
 --- /dev/null
 +++ b/drivers/media/platform/exynos-mscl/mscl-core.c
 @@ -0,0 +1,1312 @@
 +/*
 + * Copyright (c) 2013 - 2014 Samsung Electronics Co., Ltd.
 + *   http://www.samsung.com
 + *
 + * Samsung EXYNOS5 SoC series M-Scaler driver
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published
 + * by the Free Software Foundation, either version 2 of the License,
 + * or (at your option) any later version.
 + */
 +
 +#include linux/clk.h
 +#include linux/interrupt.h

 [snip]

 +
 +static int __mscl_s_ctrl(struct mscl_ctx *ctx, struct v4l2_ctrl *ctrl)
 +{
 + struct mscl_dev *mscl = ctx-mscl_dev;
 + struct mscl_variant *variant = mscl-variant;
 + unsigned int flags = MSCL_DST_FMT | MSCL_SRC_FMT;
 + int ret = 0;
 +
 + if (ctrl-flags  V4L2_CTRL_FLAG_INACTIVE)
 + return 0;

 Why would you want to do this check?

 Will remove this. seems no such check is required for this driver.


 +
 + switch (ctrl-id) {
 + case V4L2_CID_HFLIP:
 + ctx-hflip = ctrl-val;
 + break;
 +
 + case V4L2_CID_VFLIP:
 + ctx-vflip = ctrl-val;
 + break;
 +
 + case V4L2_CID_ROTATE:
 + if ((ctx-state  flags) == flags) {
 + ret = mscl_check_scaler_ratio(variant,
 + ctx-s_frame.crop.width,
 + ctx-s_frame.crop.height,
 + ctx-d_frame.crop.width,
 + ctx-d_frame.crop.height,
 + ctx-ctrls_mscl.rotate-val);
 +
 + if (ret)
 + return -EINVAL;
 + }

 I think it would be good if the try_ctrl op is implemented so you can call
 VIDIOC_EXT_TRY_CTRLS in the application to check if the ROTATE control can 
 be
 set.

 * @try_ctrl: Test whether the control's value is valid. Only relevant when
 * the usual min/max/step checks are not sufficient.

 As we support only 0,90,270 and the min, max and step can address these 
 values,
 does it really relevant to have try_ctrl op here ???

 Well, you seem to have an additional mscl_check_scaler_ratio check here that 
 can
 make it fail, in other words: the min/max/step checks aren't sufficient.

Ok. Thanks for the explanation. Will implement that.

Regards,
Shaik Ameer Basha


 Regards,

 Hans

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


Re: [PATCH v2 1/5] [media] exynos-mscl: Add new driver for M-Scaler

2013-08-20 Thread Shaik Ameer Basha
Hi Inki Dae,

Thanks for the review.


On Mon, Aug 19, 2013 at 6:18 PM, Inki Dae inki@samsung.com wrote:
 Just quick review.

 -Original Message-
 From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
 ow...@vger.kernel.org] On Behalf Of Shaik Ameer Basha
 Sent: Monday, August 19, 2013 7:59 PM
 To: linux-media@vger.kernel.org; linux-samsung-...@vger.kernel.org
 Cc: s.nawro...@samsung.com; posc...@google.com; arun...@samsung.com;
 shaik.am...@samsung.com
 Subject: [PATCH v2 1/5] [media] exynos-mscl: Add new driver for M-Scaler

 This patch adds support for M-Scaler (M2M Scaler) device which is a
 new device for scaling, blending, color fill  and color space
 conversion on EXYNOS5 SoCs.

 This device supports the followings as key feature.
 input image format
 - YCbCr420 2P(UV/VU), 3P
 - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
 - YCbCr444 2P(UV,VU), 3P
 - RGB565, ARGB1555, ARGB, ARGB, RGBA
 - Pre-multiplexed ARGB, L8A8 and L8
 output image format
 - YCbCr420 2P(UV/VU), 3P
 - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
 - YCbCr444 2P(UV,VU), 3P
 - RGB565, ARGB1555, ARGB, ARGB, RGBA
 - Pre-multiplexed ARGB
 input rotation
 - 0/90/180/270 degree, X/Y/XY Flip
 scale ratio
 - 1/4 scale down to 16 scale up
 color space conversion
 - RGB to YUV / YUV to RGB
 Size
 - Input : 16x16 to 8192x8192
 - Output:   4x4 to 8192x8192
 alpha blending, color fill

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/exynos-mscl/mscl-regs.c |  318
 
  drivers/media/platform/exynos-mscl/mscl-regs.h |  282
 +
  2 files changed, 600 insertions(+)
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.c
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.h

 diff --git a/drivers/media/platform/exynos-mscl/mscl-regs.c
 b/drivers/media/platform/exynos-mscl/mscl-regs.c
 new file mode 100644
 index 000..9354afc
 --- /dev/null
 +++ b/drivers/media/platform/exynos-mscl/mscl-regs.c
 @@ -0,0 +1,318 @@
 +/*
 + * Copyright (c) 2013 - 2014 Samsung Electronics Co., Ltd.
 + *   http://www.samsung.com
 + *
 + * Samsung EXYNOS5 SoC series M-Scaler driver
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published
 + * by the Free Software Foundation, either version 2 of the License,
 + * or (at your option) any later version.
 + */
 +
 +#include linux/delay.h
 +#include linux/platform_device.h
 +
 +#include mscl-core.h
 +
 +void mscl_hw_set_sw_reset(struct mscl_dev *dev)
 +{
 + u32 cfg;
 +
 + cfg = readl(dev-regs + MSCL_CFG);
 + cfg |= MSCL_CFG_SOFT_RESET;
 +
 + writel(cfg, dev-regs + MSCL_CFG);
 +}
 +
 +int mscl_wait_reset(struct mscl_dev *dev)
 +{
 + unsigned long end = jiffies + msecs_to_jiffies(50);

 What does 50 mean?

 + u32 cfg, reset_done = 0;
 +

 Please describe why the below codes are needed.


As per the Documentation,

 SOFT RESET: Writing 1 to this bit generates software reset. To
check the completion of the reset, wait until this
field becomes zero, then wrie an arbitrary value to any of RW
registers and read it. If the read data matches the written data,
 it means SW reset succeeded. Otherwise, repeat write  read until matched.


Thie below code tries to do the same (as per user manual). and in the
above msec_to_jiffies(50), 50 is the 50msec wait. before
checking the SOFT RESET is really done.

Is it good to ignore this checks?




 + while (time_before(jiffies, end)) {
 + cfg = readl(dev-regs + MSCL_CFG);
 + if (!(cfg  MSCL_CFG_SOFT_RESET)) {
 + reset_done = 1;
 + break;
 + }
 + usleep_range(10, 20);
 + }
 +
 + /* write any value to r/w reg and read it back */
 + while (reset_done) {
 +
 + /* [TBD] need to define number of tries before returning
 +  * -EBUSY to the caller
 +  */
 +
 + writel(MSCL_CFG_SOFT_RESET_CHECK_VAL,
 + dev-regs + MSCL_CFG_SOFT_RESET_CHECK_REG);
 + if (MSCL_CFG_SOFT_RESET_CHECK_VAL ==
 + readl(dev-regs + MSCL_CFG_SOFT_RESET_CHECK_REG))
 + return 0;
 + }
 +
 + return -EBUSY;
 +}
 +
 +void mscl_hw_set_irq_mask(struct mscl_dev *dev, int interrupt, bool mask)
 +{
 + u32 cfg;
 +
 + switch (interrupt) {
 + case MSCL_INT_TIMEOUT:
 + case MSCL_INT_ILLEGAL_BLEND:
 + case MSCL_INT_ILLEGAL_RATIO:
 + case MSCL_INT_ILLEGAL_DST_HEIGHT:
 + case MSCL_INT_ILLEGAL_DST_WIDTH:
 + case MSCL_INT_ILLEGAL_DST_V_POS:
 + case MSCL_INT_ILLEGAL_DST_H_POS:
 + case MSCL_INT_ILLEGAL_DST_C_SPAN:
 + case MSCL_INT_ILLEGAL_DST_Y_SPAN

Re: [PATCH v2 1/5] [media] exynos-mscl: Add new driver for M-Scaler

2013-08-20 Thread Shaik Ameer Basha
On Tue, Aug 20, 2013 at 2:13 PM, Inki Dae inki@samsung.com wrote:


 -Original Message-
 From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
 ow...@vger.kernel.org] On Behalf Of Shaik Ameer Basha
 Sent: Tuesday, August 20, 2013 5:07 PM
 To: Inki Dae
 Cc: Shaik Ameer Basha; LMML; linux-samsung-...@vger.kernel.org;
 c...@samsung.com; Sylwester Nawrocki; posc...@google.com; Arun Kumar K
 Subject: Re: [PATCH v2 1/5] [media] exynos-mscl: Add new driver for M-
 Scaler

 Hi Inki Dae,

 Thanks for the review.


 On Mon, Aug 19, 2013 at 6:18 PM, Inki Dae inki@samsung.com wrote:
  Just quick review.
 
  -Original Message-
  From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
  ow...@vger.kernel.org] On Behalf Of Shaik Ameer Basha
  Sent: Monday, August 19, 2013 7:59 PM
  To: linux-media@vger.kernel.org; linux-samsung-...@vger.kernel.org
  Cc: s.nawro...@samsung.com; posc...@google.com; arun...@samsung.com;
  shaik.am...@samsung.com
  Subject: [PATCH v2 1/5] [media] exynos-mscl: Add new driver for M-
 Scaler
 
  This patch adds support for M-Scaler (M2M Scaler) device which is a
  new device for scaling, blending, color fill  and color space
  conversion on EXYNOS5 SoCs.
 
  This device supports the followings as key feature.
  input image format
  - YCbCr420 2P(UV/VU), 3P
  - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
  - YCbCr444 2P(UV,VU), 3P
  - RGB565, ARGB1555, ARGB, ARGB, RGBA
  - Pre-multiplexed ARGB, L8A8 and L8
  output image format
  - YCbCr420 2P(UV/VU), 3P
  - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
  - YCbCr444 2P(UV,VU), 3P
  - RGB565, ARGB1555, ARGB, ARGB, RGBA
  - Pre-multiplexed ARGB
  input rotation
  - 0/90/180/270 degree, X/Y/XY Flip
  scale ratio
  - 1/4 scale down to 16 scale up
  color space conversion
  - RGB to YUV / YUV to RGB
  Size
  - Input : 16x16 to 8192x8192
  - Output:   4x4 to 8192x8192
  alpha blending, color fill
 
  Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
  ---
   drivers/media/platform/exynos-mscl/mscl-regs.c |  318
  
   drivers/media/platform/exynos-mscl/mscl-regs.h |  282
  +
   2 files changed, 600 insertions(+)
   create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.c
   create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.h
 
  diff --git a/drivers/media/platform/exynos-mscl/mscl-regs.c
  b/drivers/media/platform/exynos-mscl/mscl-regs.c
  new file mode 100644
  index 000..9354afc
  --- /dev/null
  +++ b/drivers/media/platform/exynos-mscl/mscl-regs.c
  @@ -0,0 +1,318 @@
  +/*
  + * Copyright (c) 2013 - 2014 Samsung Electronics Co., Ltd.
  + *   http://www.samsung.com
  + *
  + * Samsung EXYNOS5 SoC series M-Scaler driver
  + *
  + * This program is free software; you can redistribute it and/or
 modify
  + * it under the terms of the GNU General Public License as published
  + * by the Free Software Foundation, either version 2 of the License,
  + * or (at your option) any later version.
  + */
  +
  +#include linux/delay.h
  +#include linux/platform_device.h
  +
  +#include mscl-core.h
  +
  +void mscl_hw_set_sw_reset(struct mscl_dev *dev)
  +{
  + u32 cfg;
  +
  + cfg = readl(dev-regs + MSCL_CFG);
  + cfg |= MSCL_CFG_SOFT_RESET;
  +
  + writel(cfg, dev-regs + MSCL_CFG);
  +}
  +
  +int mscl_wait_reset(struct mscl_dev *dev)
  +{
  + unsigned long end = jiffies + msecs_to_jiffies(50);
 
  What does 50 mean?
 
  + u32 cfg, reset_done = 0;
  +
 
  Please describe why the below codes are needed.


 As per the Documentation,

  SOFT RESET: Writing 1 to this bit generates software reset. To
 check the completion of the reset, wait until this
 field becomes zero, then wrie an arbitrary value to any of RW
 registers and read it. If the read data matches the written data,
  it means SW reset succeeded. Otherwise, repeat write  read until
 matched.


 Thie below code tries to do the same (as per user manual). and in the
 above msec_to_jiffies(50), 50 is the 50msec wait. before
 checking the SOFT RESET is really done.

 Is it good to ignore this checks?


 No, I mean that someone may want to understand your codes so leave comments 
 enough for them.


Ok. thanks. I will add more comments. :)

Regards,
Shaik Ameer Basha


 Thanks,
 Inki Dae



 
  + while (time_before(jiffies, end)) {
  + cfg = readl(dev-regs + MSCL_CFG);
  + if (!(cfg  MSCL_CFG_SOFT_RESET)) {
  + reset_done = 1;
  + break;
  + }
  + usleep_range(10, 20);
  + }
  +
  + /* write any value to r/w reg and read it back */
  + while (reset_done) {
  +
  + /* [TBD] need to define number of tries before returning
  +  * -EBUSY to the caller

[PATCH v2 1/5] [media] exynos-mscl: Add new driver for M-Scaler

2013-08-19 Thread Shaik Ameer Basha
This patch adds support for M-Scaler (M2M Scaler) device which is a
new device for scaling, blending, color fill  and color space
conversion on EXYNOS5 SoCs.

This device supports the followings as key feature.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
alpha blending, color fill

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-mscl/mscl-regs.c |  318 
 drivers/media/platform/exynos-mscl/mscl-regs.h |  282 +
 2 files changed, 600 insertions(+)
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.c
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.h

diff --git a/drivers/media/platform/exynos-mscl/mscl-regs.c 
b/drivers/media/platform/exynos-mscl/mscl-regs.c
new file mode 100644
index 000..9354afc
--- /dev/null
+++ b/drivers/media/platform/exynos-mscl/mscl-regs.c
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2013 - 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series M-Scaler driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 2 of the License,
+ * or (at your option) any later version.
+ */
+
+#include linux/delay.h
+#include linux/platform_device.h
+
+#include mscl-core.h
+
+void mscl_hw_set_sw_reset(struct mscl_dev *dev)
+{
+   u32 cfg;
+
+   cfg = readl(dev-regs + MSCL_CFG);
+   cfg |= MSCL_CFG_SOFT_RESET;
+
+   writel(cfg, dev-regs + MSCL_CFG);
+}
+
+int mscl_wait_reset(struct mscl_dev *dev)
+{
+   unsigned long end = jiffies + msecs_to_jiffies(50);
+   u32 cfg, reset_done = 0;
+
+   while (time_before(jiffies, end)) {
+   cfg = readl(dev-regs + MSCL_CFG);
+   if (!(cfg  MSCL_CFG_SOFT_RESET)) {
+   reset_done = 1;
+   break;
+   }
+   usleep_range(10, 20);
+   }
+
+   /* write any value to r/w reg and read it back */
+   while (reset_done) {
+
+   /* [TBD] need to define number of tries before returning
+* -EBUSY to the caller
+*/
+
+   writel(MSCL_CFG_SOFT_RESET_CHECK_VAL,
+   dev-regs + MSCL_CFG_SOFT_RESET_CHECK_REG);
+   if (MSCL_CFG_SOFT_RESET_CHECK_VAL ==
+   readl(dev-regs + MSCL_CFG_SOFT_RESET_CHECK_REG))
+   return 0;
+   }
+
+   return -EBUSY;
+}
+
+void mscl_hw_set_irq_mask(struct mscl_dev *dev, int interrupt, bool mask)
+{
+   u32 cfg;
+
+   switch (interrupt) {
+   case MSCL_INT_TIMEOUT:
+   case MSCL_INT_ILLEGAL_BLEND:
+   case MSCL_INT_ILLEGAL_RATIO:
+   case MSCL_INT_ILLEGAL_DST_HEIGHT:
+   case MSCL_INT_ILLEGAL_DST_WIDTH:
+   case MSCL_INT_ILLEGAL_DST_V_POS:
+   case MSCL_INT_ILLEGAL_DST_H_POS:
+   case MSCL_INT_ILLEGAL_DST_C_SPAN:
+   case MSCL_INT_ILLEGAL_DST_Y_SPAN:
+   case MSCL_INT_ILLEGAL_DST_CR_BASE:
+   case MSCL_INT_ILLEGAL_DST_CB_BASE:
+   case MSCL_INT_ILLEGAL_DST_Y_BASE:
+   case MSCL_INT_ILLEGAL_DST_COLOR:
+   case MSCL_INT_ILLEGAL_SRC_HEIGHT:
+   case MSCL_INT_ILLEGAL_SRC_WIDTH:
+   case MSCL_INT_ILLEGAL_SRC_CV_POS:
+   case MSCL_INT_ILLEGAL_SRC_CH_POS:
+   case MSCL_INT_ILLEGAL_SRC_YV_POS:
+   case MSCL_INT_ILLEGAL_SRC_YH_POS:
+   case MSCL_INT_ILLEGAL_SRC_C_SPAN:
+   case MSCL_INT_ILLEGAL_SRC_Y_SPAN:
+   case MSCL_INT_ILLEGAL_SRC_CR_BASE:
+   case MSCL_INT_ILLEGAL_SRC_CB_BASE:
+   case MSCL_INT_ILLEGAL_SRC_Y_BASE:
+   case MSCL_INT_ILLEGAL_SRC_COLOR:
+   case MSCL_INT_FRAME_END:
+   break;
+   default:
+   return;
+   }
+   cfg = readl(dev-regs + MSCL_INT_EN);
+   if (mask)
+   cfg |= interrupt;
+   else
+   cfg = ~interrupt;
+   writel(cfg, dev-regs + MSCL_INT_EN);
+}
+
+void mscl_hw_set_input_addr(struct mscl_dev *dev, struct mscl_addr *addr)
+{
+   dev_dbg(dev-pdev-dev, src_buf: 0x%X, cb: 0x%X, cr: 0x%X,
+   addr-y, addr-cb, addr-cr);
+   writel(addr-y, dev-regs

[PATCH v2 2/5] [media] exynos-mscl: Add core functionality for the M-Scaler driver

2013-08-19 Thread Shaik Ameer Basha
This patch adds the core functionality for the M-Scaler driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-mscl/mscl-core.c | 1312 
 drivers/media/platform/exynos-mscl/mscl-core.h |  549 ++
 2 files changed, 1861 insertions(+)
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.c
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.h

diff --git a/drivers/media/platform/exynos-mscl/mscl-core.c 
b/drivers/media/platform/exynos-mscl/mscl-core.c
new file mode 100644
index 000..4a3a851
--- /dev/null
+++ b/drivers/media/platform/exynos-mscl/mscl-core.c
@@ -0,0 +1,1312 @@
+/*
+ * Copyright (c) 2013 - 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series M-Scaler driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 2 of the License,
+ * or (at your option) any later version.
+ */
+
+#include linux/clk.h
+#include linux/interrupt.h
+#include linux/module.h
+#include linux/of_platform.h
+#include linux/pm_runtime.h
+
+#ifdef CONFIG_EXYNOS_IOMMU
+#include asm/dma-iommu.h
+#endif
+
+#include mscl-core.h
+
+#define MSCL_CLOCK_GATE_NAME   mscl
+
+static const struct mscl_fmt mscl_formats[] = {
+   {
+   .name   = YUV 4:2:0 non-contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12M,
+   .depth  = { 8, 4 },
+   .color  = MSCL_YUV420,
+   .corder = MSCL_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .mscl_color = MSCL_YUV420_2P_Y_UV,
+   .mscl_color_fmt_type = (MSCL_FMT_SRC | MSCL_FMT_DST),
+
+   }, {
+   .name   = YUV 4:2:0 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV12,
+   .depth  = { 12 },
+   .color  = MSCL_YUV420,
+   .corder = MSCL_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .mscl_color = MSCL_YUV420_2P_Y_UV,
+   .mscl_color_fmt_type = (MSCL_FMT_SRC | MSCL_FMT_DST),
+   }, {
+   .name   = YUV 4:2:0 n.c. 2p, Y/CbCr tiled,
+   .pixelformat= V4L2_PIX_FMT_NV12MT_16X16,
+   .depth  = { 8, 4 },
+   .color  = MSCL_YUV420,
+   .corder = MSCL_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
+   .mscl_color = MSCL_YUV420_2P_Y_UV,
+   .mscl_color_fmt_type = (MSCL_FMT_SRC),
+   .is_tiled   = true,
+   }, {
+   .name   = YUV 4:2:2 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV16,
+   .depth  = { 16 },
+   .color  = MSCL_YUV422,
+   .corder = MSCL_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .mscl_color = MSCL_YUV422_2P_Y_UV,
+   .mscl_color_fmt_type = (MSCL_FMT_SRC | MSCL_FMT_DST),
+   }, {
+   .name   = YUV 4:4:4 contig. 2p, Y/CbCr,
+   .pixelformat= V4L2_PIX_FMT_NV24,
+   .depth  = { 24 },
+   .color  = MSCL_YUV444,
+   .corder = MSCL_CBCR,
+   .num_planes = 1,
+   .num_comp   = 2,
+   .mscl_color = MSCL_YUV444_2P_Y_UV,
+   .mscl_color_fmt_type = (MSCL_FMT_SRC | MSCL_FMT_DST),
+   }, {
+   .name   = RGB565,
+   .pixelformat= V4L2_PIX_FMT_RGB565X,
+   .depth  = { 16 },
+   .color  = MSCL_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .mscl_color = MSCL_RGB565,
+   .mscl_color_fmt_type = (MSCL_FMT_SRC | MSCL_FMT_DST),
+   }, {
+   .name   = XRGB-1555, 16 bpp,
+   .pixelformat= V4L2_PIX_FMT_RGB555,
+   .depth  = { 16 },
+   .color  = MSCL_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .mscl_color = MSCL_ARGB1555,
+   .mscl_color_fmt_type = (MSCL_FMT_SRC | MSCL_FMT_DST),
+   }, {
+   .name   = XRGB-, 32 bpp,
+   .pixelformat= V4L2_PIX_FMT_RGB32,
+   .depth  = { 32 },
+   .color  = MSCL_RGB,
+   .num_planes = 1,
+   .num_comp   = 1,
+   .mscl_color = MSCL_ARGB,
+   .mscl_color_fmt_type = (MSCL_FMT_SRC | MSCL_FMT_DST),
+   }, {
+   .name

[PATCH v2 4/5] [media] exynos-mscl: Add DT bindings for M-Scaler driver

2013-08-19 Thread Shaik Ameer Basha
This patch adds the DT binding documentation for the exynos5
based M-Scaler device driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 .../devicetree/bindings/media/exynos5-mscl.txt |   34 
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mscl.txt

diff --git a/Documentation/devicetree/bindings/media/exynos5-mscl.txt 
b/Documentation/devicetree/bindings/media/exynos5-mscl.txt
new file mode 100644
index 000..5c9d1b1
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos5-mscl.txt
@@ -0,0 +1,34 @@
+* Samsung Exynos5 M-Scaler device
+
+M-Scaler is used for scaling, blending, color fill and color space
+conversion on EXYNOS5 SoCs.
+
+Required properties:
+- compatible: should be samsung,exynos5-mscl
+- reg: should contain M-Scaler physical address location and length.
+- interrupts: should contain M-Scaler interrupt number
+- clocks: should contain the clock number according to CCF
+- clock-names: should be mscl
+
+Example:
+
+   mscl_0: mscl@0x1280 {
+   compatible = samsung,exynos5-mscl;
+   reg = 0x1280 0x1000;
+   interrupts = 0 220 0;
+   clocks = clock 381;
+   clock-names = mscl;
+   };
+
+Aliases:
+Each M-Scaler node should have a numbered alias in the aliases node,
+in the form of msclN, N = 0...2. M-Scaler driver uses these aliases
+to retrieve the device IDs using of_alias_get_id() call.
+
+Example:
+
+aliases {
+   mscl0 =mscl_0;
+   mscl1 =mscl_1;
+   mscl2 =mscl_2;
+};
-- 
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 v2 0/5] Exynos5 M-Scaler Driver

2013-08-19 Thread Shaik Ameer Basha
This patch adds support for M-Scaler (M2M Scaler) device which is a
new device for scaling, blending, color fill  and color space
conversion on EXYNOS5 SoCs.

This device supports the following as key features.
input image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB, L8A8 and L8
output image format
- YCbCr420 2P(UV/VU), 3P
- YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
- YCbCr444 2P(UV,VU), 3P
- RGB565, ARGB1555, ARGB, ARGB, RGBA
- Pre-multiplexed ARGB
input rotation
- 0/90/180/270 degree, X/Y/XY Flip
scale ratio
- 1/4 scale down to 16 scale up
color space conversion
- RGB to YUV / YUV to RGB
Size
- Input : 16x16 to 8192x8192
- Output:   4x4 to 8192x8192
alpha blending, color fill

Rebased on:
---
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git:master

Changes from v1:
---
1] Split the previous single patch into multiple patches.
2] Added DT binding documentation.
3] Removed the unnecessary header file inclusions.
4] Fix the condition check in mscl_prepare_address for swapping cb/cr addresses.

Shaik Ameer Basha (5):
  [media] exynos-mscl: Add new driver for M-Scaler
  [media] exynos-mscl: Add core functionality for the M-Scaler driver
  [media] exynos-mscl: Add m2m functionality for the M-Scaler driver
  [media] exynos-mscl: Add DT bindings for M-Scaler driver
  [media] exynos-mscl: Add Makefile for M-Scaler driver

 .../devicetree/bindings/media/exynos5-mscl.txt |   34 +
 drivers/media/platform/Kconfig |8 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos-mscl/Makefile|3 +
 drivers/media/platform/exynos-mscl/mscl-core.c | 1312 
 drivers/media/platform/exynos-mscl/mscl-core.h |  549 
 drivers/media/platform/exynos-mscl/mscl-m2m.c  |  763 
 drivers/media/platform/exynos-mscl/mscl-regs.c |  318 +
 drivers/media/platform/exynos-mscl/mscl-regs.h |  282 +
 9 files changed, 3270 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mscl.txt
 create mode 100644 drivers/media/platform/exynos-mscl/Makefile
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.c
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.h
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-m2m.c
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.c
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.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 v2 5/5] [media] exynos-mscl: Add Makefile for M-Scaler driver

2013-08-19 Thread Shaik Ameer Basha
This patch adds the Makefile for the M-Scaler (M2M scaler).

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/Kconfig  |8 
 drivers/media/platform/Makefile |1 +
 drivers/media/platform/exynos-mscl/Makefile |3 +++
 3 files changed, 12 insertions(+)
 create mode 100644 drivers/media/platform/exynos-mscl/Makefile

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 08de865..bff437a 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -201,6 +201,14 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
  This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
+config VIDEO_SAMSUNG_EXYNOS_MSCL
+   tristate Samsung Exynos M-Scaler driver
+   depends on OF  VIDEO_DEV  VIDEO_V4L2  ARCH_EXYNOS5
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+ This is a v4l2 driver for Samsung EXYNOS5 SoC M-Scaler.
+
 config VIDEO_SH_VEU
tristate SuperH VEU mem2mem video processing driver
depends on VIDEO_DEV  VIDEO_V4L2  GENERIC_HARDIRQS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index eee28dd..2452b09 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_EXYNOS_MSCL)+= exynos-mscl/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/exynos-mscl/Makefile 
b/drivers/media/platform/exynos-mscl/Makefile
new file mode 100644
index 000..c9ffcd8
--- /dev/null
+++ b/drivers/media/platform/exynos-mscl/Makefile
@@ -0,0 +1,3 @@
+exynos-mscl-objs := mscl-core.o mscl-m2m.o mscl-regs.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_MSCL)+= exynos-mscl.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 v2 3/5] [media] exynos-mscl: Add m2m functionality for the M-Scaler driver

2013-08-19 Thread Shaik Ameer Basha
This patch adds the memory to memory (m2m) interface functionality
for the M-Scaler driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-mscl/mscl-m2m.c |  763 +
 1 file changed, 763 insertions(+)
 create mode 100644 drivers/media/platform/exynos-mscl/mscl-m2m.c

diff --git a/drivers/media/platform/exynos-mscl/mscl-m2m.c 
b/drivers/media/platform/exynos-mscl/mscl-m2m.c
new file mode 100644
index 000..fecbb57
--- /dev/null
+++ b/drivers/media/platform/exynos-mscl/mscl-m2m.c
@@ -0,0 +1,763 @@
+/*
+ * Copyright (c) 2013 - 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS5 SoC series M-Scaler driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 2 of the License,
+ * or (at your option) any later version.
+ */
+
+#include linux/module.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+
+#include media/v4l2-ioctl.h
+
+#include mscl-core.h
+
+static int mscl_m2m_ctx_stop_req(struct mscl_ctx *ctx)
+{
+   struct mscl_ctx *curr_ctx;
+   struct mscl_dev *mscl = ctx-mscl_dev;
+   int ret;
+
+   curr_ctx = v4l2_m2m_get_curr_priv(mscl-m2m.m2m_dev);
+   if (!mscl_m2m_pending(mscl) || (curr_ctx != ctx))
+   return 0;
+
+   mscl_ctx_state_lock_set(MSCL_CTX_STOP_REQ, ctx);
+   ret = wait_event_timeout(mscl-irq_queue,
+   !mscl_ctx_state_is_set(MSCL_CTX_STOP_REQ, ctx),
+   MSCL_SHUTDOWN_TIMEOUT);
+
+   return ret == 0 ? -ETIMEDOUT : ret;
+}
+
+static int mscl_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
+{
+   struct mscl_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = pm_runtime_get_sync(ctx-mscl_dev-pdev-dev);
+
+   return ret  0 ? 0 : ret;
+}
+
+static int mscl_m2m_stop_streaming(struct vb2_queue *q)
+{
+   struct mscl_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = mscl_m2m_ctx_stop_req(ctx);
+   if (ret == -ETIMEDOUT)
+   mscl_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+   pm_runtime_put(ctx-mscl_dev-pdev-dev);
+
+   return 0;
+}
+
+void mscl_m2m_job_finish(struct mscl_ctx *ctx, int vb_state)
+{
+   struct vb2_buffer *src_vb, *dst_vb;
+
+   if (!ctx || !ctx-m2m_ctx)
+   return;
+
+   src_vb = v4l2_m2m_src_buf_remove(ctx-m2m_ctx);
+   dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
+
+   if (src_vb  dst_vb) {
+   v4l2_m2m_buf_done(src_vb, vb_state);
+   v4l2_m2m_buf_done(dst_vb, vb_state);
+
+   v4l2_m2m_job_finish(ctx-mscl_dev-m2m.m2m_dev,
+   ctx-m2m_ctx);
+   }
+}
+
+
+static void mscl_m2m_job_abort(void *priv)
+{
+   struct mscl_ctx *ctx = priv;
+   int ret;
+
+   ret = mscl_m2m_ctx_stop_req(ctx);
+   if (ret == -ETIMEDOUT)
+   mscl_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+}
+
+static int mscl_get_bufs(struct mscl_ctx *ctx)
+{
+   struct mscl_frame *s_frame, *d_frame;
+   struct vb2_buffer *src_vb, *dst_vb;
+   int ret;
+
+   s_frame = ctx-s_frame;
+   d_frame = ctx-d_frame;
+
+   src_vb = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
+   ret = mscl_prepare_addr(ctx, src_vb, s_frame, s_frame-addr);
+   if (ret)
+   return ret;
+
+   dst_vb = v4l2_m2m_next_dst_buf(ctx-m2m_ctx);
+   ret = mscl_prepare_addr(ctx, dst_vb, d_frame, d_frame-addr);
+   if (ret)
+   return ret;
+
+   dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+
+   return 0;
+}
+
+static void mscl_m2m_device_run(void *priv)
+{
+   struct mscl_ctx *ctx = priv;
+   struct mscl_dev *mscl;
+   unsigned long flags;
+   int ret;
+   bool is_set = false;
+
+   if (WARN(!ctx, null hardware context\n))
+   return;
+
+   mscl = ctx-mscl_dev;
+   spin_lock_irqsave(mscl-slock, flags);
+
+   set_bit(ST_M2M_PEND, mscl-state);
+
+   /* Reconfigure hardware if the context has changed. */
+   if (mscl-m2m.ctx != ctx) {
+   dev_dbg(mscl-pdev-dev,
+   mscl-m2m.ctx = 0x%p, current_ctx = 0x%p,
+   mscl-m2m.ctx, ctx);
+   ctx-state |= MSCL_PARAMS;
+   mscl-m2m.ctx = ctx;
+   }
+
+   is_set = (ctx-state  MSCL_CTX_STOP_REQ) ? 1 : 0;
+   ctx-state = ~MSCL_CTX_STOP_REQ;
+   if (is_set) {
+   wake_up(mscl-irq_queue);
+   goto put_device;
+   }
+
+   ret = mscl_get_bufs(ctx);
+   if (ret) {
+   dev_dbg(mscl-pdev-dev, Wrong address);
+   goto put_device;
+   }
+
+   mscl_hw_address_queue_reset(ctx);
+   mscl_set_prefbuf(mscl, ctx-s_frame);
+   mscl_hw_set_input_addr(mscl, ctx-s_frame.addr

Re: [PATCH v2 2/5] [media] exynos-mscl: Add core functionality for the M-Scaler driver

2013-08-19 Thread Shaik Ameer Basha
+ linux-media, linux-samsung-soc

Hi Hans,

Thanks for the review.
Will address all your comments in v3.

I have only one doubt regarding try_ctrl... (addressed inline)


On Mon, Aug 19, 2013 at 6:36 PM, Hans Verkuil hverk...@xs4all.nl wrote:

 On 08/19/2013 12:58 PM, Shaik Ameer Basha wrote:
  This patch adds the core functionality for the M-Scaler driver.

 Some more comments below...

 
  Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
  ---
   drivers/media/platform/exynos-mscl/mscl-core.c | 1312 
  
   drivers/media/platform/exynos-mscl/mscl-core.h |  549 ++
   2 files changed, 1861 insertions(+)
   create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.c
   create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.h
 
  diff --git a/drivers/media/platform/exynos-mscl/mscl-core.c 
  b/drivers/media/platform/exynos-mscl/mscl-core.c
  new file mode 100644
  index 000..4a3a851
  --- /dev/null
  +++ b/drivers/media/platform/exynos-mscl/mscl-core.c
  @@ -0,0 +1,1312 @@
  +/*
  + * Copyright (c) 2013 - 2014 Samsung Electronics Co., Ltd.
  + *   http://www.samsung.com
  + *
  + * Samsung EXYNOS5 SoC series M-Scaler driver
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License as published
  + * by the Free Software Foundation, either version 2 of the License,
  + * or (at your option) any later version.
  + */
  +
  +#include linux/clk.h
  +#include linux/interrupt.h

[snip]

  +
  +static int __mscl_s_ctrl(struct mscl_ctx *ctx, struct v4l2_ctrl *ctrl)
  +{
  + struct mscl_dev *mscl = ctx-mscl_dev;
  + struct mscl_variant *variant = mscl-variant;
  + unsigned int flags = MSCL_DST_FMT | MSCL_SRC_FMT;
  + int ret = 0;
  +
  + if (ctrl-flags  V4L2_CTRL_FLAG_INACTIVE)
  + return 0;

 Why would you want to do this check?

Will remove this. seems no such check is required for this driver.


  +
  + switch (ctrl-id) {
  + case V4L2_CID_HFLIP:
  + ctx-hflip = ctrl-val;
  + break;
  +
  + case V4L2_CID_VFLIP:
  + ctx-vflip = ctrl-val;
  + break;
  +
  + case V4L2_CID_ROTATE:
  + if ((ctx-state  flags) == flags) {
  + ret = mscl_check_scaler_ratio(variant,
  + ctx-s_frame.crop.width,
  + ctx-s_frame.crop.height,
  + ctx-d_frame.crop.width,
  + ctx-d_frame.crop.height,
  + ctx-ctrls_mscl.rotate-val);
  +
  + if (ret)
  + return -EINVAL;
  + }

 I think it would be good if the try_ctrl op is implemented so you can call
 VIDIOC_EXT_TRY_CTRLS in the application to check if the ROTATE control can be
 set.

* @try_ctrl: Test whether the control's value is valid. Only relevant when
* the usual min/max/step checks are not sufficient.

As we support only 0,90,270 and the min, max and step can address these values,
does it really relevant to have try_ctrl op here ???

Regards,
Shaik Ameer Basha


  +
  + ctx-rotation = ctrl-val;
  + break;
  +
  + case V4L2_CID_ALPHA_COMPONENT:
  + ctx-d_frame.alpha = ctrl-val;
  + break;
  + }
  +
  + ctx-state |= MSCL_PARAMS;
  + return 0;
  +}
  +
  +static int mscl_s_ctrl(struct v4l2_ctrl *ctrl)
  +{
  + struct mscl_ctx *ctx = ctrl_to_ctx(ctrl);
  + unsigned long flags;
  + int ret;
  +
  + spin_lock_irqsave(ctx-mscl_dev-slock, flags);
  + ret = __mscl_s_ctrl(ctx, ctrl);
  + spin_unlock_irqrestore(ctx-mscl_dev-slock, flags);
  +
  + return ret;
  +}
  +
  +static const struct v4l2_ctrl_ops mscl_ctrl_ops = {
  + .s_ctrl = mscl_s_ctrl,
  +};

 Thanks for the patches!

 Regards,

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


Re: [PATCH v2 0/5] Exynos5 M-Scaler Driver

2013-08-19 Thread Shaik Ameer Basha
Hi Inki Dae,

Thanks for the review.

On Mon, Aug 19, 2013 at 5:56 PM, Inki Dae inki@samsung.com wrote:


 -Original Message-
 From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
 ow...@vger.kernel.org] On Behalf Of Shaik Ameer Basha
 Sent: Monday, August 19, 2013 7:59 PM
 To: linux-media@vger.kernel.org; linux-samsung-...@vger.kernel.org
 Cc: s.nawro...@samsung.com; posc...@google.com; arun...@samsung.com;
 shaik.am...@samsung.com
 Subject: [PATCH v2 0/5] Exynos5 M-Scaler Driver

 This patch adds support for M-Scaler (M2M Scaler) device which is a
 new device for scaling, blending, color fill  and color space
 conversion on EXYNOS5 SoCs.

 All Exynos5 SoCs really have this IP? It seems that only Exynos5420 and
 maybe Exynos5410 have this IP, NOT Exynos5250. Please check it again and
 describe it surely over the all patch series.

 Thanks,
 Inki Dae

True, not all exynos5 series SoCs has this IP.
Will change the description and the binding accordingly.

Regards,
Shaik Ameer Basha


 This device supports the following as key features.
 input image format
 - YCbCr420 2P(UV/VU), 3P
 - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
 - YCbCr444 2P(UV,VU), 3P
 - RGB565, ARGB1555, ARGB, ARGB, RGBA
 - Pre-multiplexed ARGB, L8A8 and L8
 output image format
 - YCbCr420 2P(UV/VU), 3P
 - YCbCr422 1P(YUYV/UYVY/YVYU), 2P(UV,VU), 3P
 - YCbCr444 2P(UV,VU), 3P
 - RGB565, ARGB1555, ARGB, ARGB, RGBA
 - Pre-multiplexed ARGB
 input rotation
 - 0/90/180/270 degree, X/Y/XY Flip
 scale ratio
 - 1/4 scale down to 16 scale up
 color space conversion
 - RGB to YUV / YUV to RGB
 Size
 - Input : 16x16 to 8192x8192
 - Output:   4x4 to 8192x8192
 alpha blending, color fill

 Rebased on:
 ---
 git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git:master

 Changes from v1:
 ---
 1] Split the previous single patch into multiple patches.
 2] Added DT binding documentation.
 3] Removed the unnecessary header file inclusions.
 4] Fix the condition check in mscl_prepare_address for swapping cb/cr
 addresses.

 Shaik Ameer Basha (5):
   [media] exynos-mscl: Add new driver for M-Scaler
   [media] exynos-mscl: Add core functionality for the M-Scaler driver
   [media] exynos-mscl: Add m2m functionality for the M-Scaler driver
   [media] exynos-mscl: Add DT bindings for M-Scaler driver
   [media] exynos-mscl: Add Makefile for M-Scaler driver

  .../devicetree/bindings/media/exynos5-mscl.txt |   34 +
  drivers/media/platform/Kconfig |8 +
  drivers/media/platform/Makefile|1 +
  drivers/media/platform/exynos-mscl/Makefile|3 +
  drivers/media/platform/exynos-mscl/mscl-core.c | 1312
 
  drivers/media/platform/exynos-mscl/mscl-core.h |  549 
  drivers/media/platform/exynos-mscl/mscl-m2m.c  |  763 
  drivers/media/platform/exynos-mscl/mscl-regs.c |  318 +
  drivers/media/platform/exynos-mscl/mscl-regs.h |  282 +
  9 files changed, 3270 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/media/exynos5-
 mscl.txt
  create mode 100644 drivers/media/platform/exynos-mscl/Makefile
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.c
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-core.h
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-m2m.c
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.c
  create mode 100644 drivers/media/platform/exynos-mscl/mscl-regs.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

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


[PATCH] [media] v4l2-mem2mem: clear m2m context from job_queue before ctx streamoff

2013-08-13 Thread Shaik Ameer Basha
When streamoff is called on the context and the context
is added to the job_queue,
1] sometimes device_run receives the empty vb2 buffers (as
   v4l2_m2m_streamoff is dropping the ready queue).
2] sometimes v4l2_m2m_job_finish may not succeed as the m2m_dev-curr_ctx
   is made NULL in the v4l2_m2m_streamoff()

The above points may stop the execution of the other queued contexts.
This patch makes sure that before streamoff is executed on any context,
that context should not be running or not queued in the job_queue.
1] If the current context is running, then abort job will be called.
2] If the current context is queued, then the context will be removed from
   the job_queue.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/v4l2-core/v4l2-mem2mem.c |   59 
 1 file changed, 38 insertions(+), 21 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c 
b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 89b9067..7c43712 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -266,6 +266,39 @@ static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx 
*m2m_ctx)
 }
 
 /**
+ * v4l2_m2m_cancel_job() - cancel pending jobs for the context
+ *
+ * In case of streamoff or release called on any context,
+ * 1] If the context is currently running, then abort job will be called
+ * 2] If the context is queued, then the context will be removed from
+ *the job_queue
+ */
+static void v4l2_m2m_cancel_job(struct v4l2_m2m_ctx *m2m_ctx)
+{
+   struct v4l2_m2m_dev *m2m_dev;
+   unsigned long flags;
+
+   m2m_dev = m2m_ctx-m2m_dev;
+   spin_lock_irqsave(m2m_dev-job_spinlock, flags);
+   if (m2m_ctx-job_flags  TRANS_RUNNING) {
+   spin_unlock_irqrestore(m2m_dev-job_spinlock, flags);
+   m2m_dev-m2m_ops-job_abort(m2m_ctx-priv);
+   dprintk(m2m_ctx %p running, will wait to complete, m2m_ctx);
+   wait_event(m2m_ctx-finished,
+   !(m2m_ctx-job_flags  TRANS_RUNNING));
+   } else if (m2m_ctx-job_flags  TRANS_QUEUED) {
+   list_del(m2m_ctx-queue);
+   m2m_ctx-job_flags = ~(TRANS_QUEUED | TRANS_RUNNING);
+   spin_unlock_irqrestore(m2m_dev-job_spinlock, flags);
+   dprintk(m2m_ctx: %p had been on queue and was removed\n,
+   m2m_ctx);
+   } else {
+   /* Do nothing, was not on queue/running */
+   spin_unlock_irqrestore(m2m_dev-job_spinlock, flags);
+   }
+}
+
+/**
  * v4l2_m2m_job_finish() - inform the framework that a job has been finished
  * and have it clean up
  *
@@ -436,6 +469,9 @@ int v4l2_m2m_streamoff(struct file *file, struct 
v4l2_m2m_ctx *m2m_ctx,
unsigned long flags_job, flags;
int ret;
 
+   /* wait until the current context is dequeued from job_queue */
+   v4l2_m2m_cancel_job(m2m_ctx);
+
q_ctx = get_queue_ctx(m2m_ctx, type);
ret = vb2_streamoff(q_ctx-q, type);
if (ret)
@@ -658,27 +694,8 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ctx_init);
  */
 void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx)
 {
-   struct v4l2_m2m_dev *m2m_dev;
-   unsigned long flags;
-
-   m2m_dev = m2m_ctx-m2m_dev;
-
-   spin_lock_irqsave(m2m_dev-job_spinlock, flags);
-   if (m2m_ctx-job_flags  TRANS_RUNNING) {
-   spin_unlock_irqrestore(m2m_dev-job_spinlock, flags);
-   m2m_dev-m2m_ops-job_abort(m2m_ctx-priv);
-   dprintk(m2m_ctx %p running, will wait to complete, m2m_ctx);
-   wait_event(m2m_ctx-finished, !(m2m_ctx-job_flags  
TRANS_RUNNING));
-   } else if (m2m_ctx-job_flags  TRANS_QUEUED) {
-   list_del(m2m_ctx-queue);
-   m2m_ctx-job_flags = ~(TRANS_QUEUED | TRANS_RUNNING);
-   spin_unlock_irqrestore(m2m_dev-job_spinlock, flags);
-   dprintk(m2m_ctx: %p had been on queue and was removed\n,
-   m2m_ctx);
-   } else {
-   /* Do nothing, was not on queue/running */
-   spin_unlock_irqrestore(m2m_dev-job_spinlock, flags);
-   }
+   /* wait until the current context is dequeued from job_queue */
+   v4l2_m2m_cancel_job(m2m_ctx);
 
vb2_queue_release(m2m_ctx-cap_q_ctx.q);
vb2_queue_release(m2m_ctx-out_q_ctx.q);
-- 
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 v2 0/6] Adding media device driver for Exynos5 imaging subsystem

2013-04-24 Thread Shaik Ameer Basha
The following patchset features:

1] Creating a common pipeline framework which can be used by all
Exynos series SoCs for developing media device drivers.
2] Modified the existing fimc-mdevice for exynos4 to use the common
pipeline framework.
3] Adding of media device driver for Exynos5 Imaging subsystem.
4] Upgrading mipi-csis and fimc-lite drivers for Exynos5 SoCs.

Current changes are not tested on exynos4 series SoCs. Current media
device driver only support one pipeline (pipeline0) which consists of
Sensor -- MIPI-CSIS -- FIMC-LITE
Sensor -- FIMC-LITE
G-Scaler support to pipeline0 will be added later.

Once the fimc-is device driver is posted, one more pipeline (pipeline1)
will be added for exynos5 media device driver for fimc-is sub-devices.

This patchset is rebased on:
git://linuxtv.org/snawrocki/samsung.git:for_v3.10_2

Shaik Ameer Basha (6):
  media: exynos4-is: modify existing mdev to use common pipeline
  fimc-lite: Adding Exynos5 compatibility to fimc-lite driver
  media: fimc-lite: Adding support for Exynos5
  media: fimc-lite: Fix for DMA output corruption
  media: s5p-csis: Adding Exynos5250 compatibility
  media: exynos5-is: Adding media device driver for exynos5

 .../devicetree/bindings/media/exynos5-mdev.txt |  153 +++
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos4-is/fimc-capture.c   |   47 +-
 drivers/media/platform/exynos4-is/fimc-lite-reg.c  |   16 +-
 drivers/media/platform/exynos4-is/fimc-lite-reg.h  |   41 +-
 drivers/media/platform/exynos4-is/fimc-lite.c  |   45 +-
 drivers/media/platform/exynos4-is/fimc-lite.h  |4 +-
 drivers/media/platform/exynos4-is/media-dev.c  |  179 +++-
 drivers/media/platform/exynos4-is/media-dev.h  |   16 +
 drivers/media/platform/exynos4-is/mipi-csis.c  |3 +-
 drivers/media/platform/exynos5-is/Kconfig  |7 +
 drivers/media/platform/exynos5-is/Makefile |4 +
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1131 
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  120 +++
 include/media/s5p_fimc.h   |   46 +-
 16 files changed, 1757 insertions(+), 57 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 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

-- 
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 v2 1/6] media: exynos4-is: modify existing mdev to use common pipeline

2013-04-24 Thread Shaik Ameer Basha
Current fimc_pipeline is tightly coupled with exynos4-is media
device driver. And this will not allow to use the same pipeline
across different exynos series media device drivers.

This patch adds,
1] Changing of the existing pipeline as a common pipeline
   to be used across multiple exynos series media device drivers.
2] Modifies the existing exynos4-is media device driver to
   use the updated common pipeline implementation.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-capture.c |   47 --
 drivers/media/platform/exynos4-is/fimc-lite.c|4 +-
 drivers/media/platform/exynos4-is/media-dev.c|  179 +++---
 drivers/media/platform/exynos4-is/media-dev.h|   16 ++
 include/media/s5p_fimc.h |   46 --
 5 files changed, 248 insertions(+), 44 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
b/drivers/media/platform/exynos4-is/fimc-capture.c
index 72c516a..904d725 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -178,13 +178,16 @@ static int fimc_capture_config_update(struct fimc_ctx 
*ctx)
 
 void fimc_capture_irq_handler(struct fimc_dev *fimc, int deq_buf)
 {
-   struct v4l2_subdev *csis = fimc-pipeline.subdevs[IDX_CSIS];
+   struct v4l2_subdev *csis;
struct fimc_vid_cap *cap = fimc-vid_cap;
struct fimc_frame *f = cap-ctx-d_frame;
struct fimc_vid_buffer *v_buf;
struct timeval *tv;
struct timespec ts;
 
+   csis = fimc_pipeline_get_subdev(fimc-pipeline_ops,
+   fimc-pipeline, EXYNOS_SD_CSIS);
+
if (test_and_clear_bit(ST_CAPT_SHUT, fimc-state)) {
wake_up(fimc-irq_queue);
goto done;
@@ -480,9 +483,12 @@ static struct vb2_ops fimc_capture_qops = {
 int fimc_capture_ctrls_create(struct fimc_dev *fimc)
 {
struct fimc_vid_cap *vid_cap = fimc-vid_cap;
-   struct v4l2_subdev *sensor = fimc-pipeline.subdevs[IDX_SENSOR];
+   struct v4l2_subdev *sensor;
int ret;
 
+   sensor = fimc_pipeline_get_subdev(fimc-pipeline_ops,
+   fimc-pipeline, EXYNOS_SD_SENSOR);
+
if (WARN_ON(vid_cap-ctx == NULL))
return -ENXIO;
if (vid_cap-ctx-ctrls.ready)
@@ -800,7 +806,7 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx,
bool set)
 {
struct fimc_dev *fimc = ctx-fimc_dev;
-   struct v4l2_subdev *sd = fimc-pipeline.subdevs[IDX_SENSOR];
+   struct v4l2_subdev *sd;
struct v4l2_subdev_format sfmt;
struct v4l2_mbus_framefmt *mf = sfmt.format;
struct media_entity *me;
@@ -809,6 +815,8 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx,
int ret, i = 1;
u32 fcc;
 
+   sd = fimc_pipeline_get_subdev(fimc-pipeline_ops,
+   fimc-pipeline, EXYNOS_SD_SENSOR);
if (WARN_ON(!sd || !tfmt))
return -EINVAL;
 
@@ -974,8 +982,10 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void 
*fh,
fimc_adjust_mplane_format(ffmt, pix-width, pix-height, pix);
 
if (ffmt-flags  FMT_FLAGS_COMPRESSED)
-   fimc_get_sensor_frame_desc(fimc-pipeline.subdevs[IDX_SENSOR],
-   pix-plane_fmt, ffmt-memplanes, true);
+   fimc_get_sensor_frame_desc(
+   fimc_pipeline_get_subdev(fimc-pipeline_ops,
+   fimc-pipeline, EXYNOS_SD_SENSOR),
+   pix-plane_fmt, ffmt-memplanes, true);
 unlock:
mutex_unlock(fimc-lock);
fimc_md_graph_unlock(fimc);
@@ -1044,9 +1054,10 @@ static int __fimc_capture_set_format(struct fimc_dev 
*fimc,
fimc_adjust_mplane_format(ff-fmt, pix-width, pix-height, pix);
 
if (ff-fmt-flags  FMT_FLAGS_COMPRESSED) {
-   ret = 
fimc_get_sensor_frame_desc(fimc-pipeline.subdevs[IDX_SENSOR],
-   pix-plane_fmt, ff-fmt-memplanes,
-   true);
+   ret = fimc_get_sensor_frame_desc(
+   fimc_pipeline_get_subdev(fimc-pipeline_ops,
+   fimc-pipeline, EXYNOS_SD_SENSOR),
+   pix-plane_fmt, ff-fmt-memplanes, true);
if (ret  0)
return ret;
}
@@ -1100,7 +,10 @@ static int fimc_cap_enum_input(struct file *file, void 
*priv,
   struct v4l2_input *i)
 {
struct fimc_dev *fimc = video_drvdata(file);
-   struct v4l2_subdev *sd = fimc-pipeline.subdevs[IDX_SENSOR];
+   struct v4l2_subdev *sd;
+
+   sd = fimc_pipeline_get_subdev(fimc-pipeline_ops,
+   fimc-pipeline, EXYNOS_SD_SENSOR);
 
if (i-index != 0)
return -EINVAL;
@@ -1186,8 +1200,10

[RFC v2 2/6] fimc-lite: Adding Exynos5 compatibility to fimc-lite driver

2013-04-24 Thread Shaik Ameer Basha
This patch adds,
1] Exynos5 soc compatibility to the fimc-lite driver
2] Multiple dma output buffer support as from Exynos5 onwards,
   fimc-lite h/w ip supports multiple dma buffers.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite.c |   19 ++-
 drivers/media/platform/exynos4-is/fimc-lite.h |4 +++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index 4878089..cb173ec 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -1467,7 +1467,7 @@ static int fimc_lite_probe(struct platform_device *pdev)
fimc-index = pdev-id;
}
 
-   if (!drv_data || fimc-index  0 || fimc-index = FIMC_LITE_MAX_DEVS)
+   if (!drv_data || fimc-index  0 || fimc-index = drv_data-num_devs)
return -EINVAL;
 
fimc-dd = drv_data;
@@ -1625,6 +1625,19 @@ static struct flite_drvdata fimc_lite_drvdata_exynos4 = {
.out_width_align= 8,
.win_hor_offs_align = 2,
.out_hor_offs_align = 8,
+   .support_multi_dma_buf  = false,
+   .num_devs = 2,
+};
+
+/* EXYNOS5250 */
+static struct flite_drvdata fimc_lite_drvdata_exynos5 = {
+   .max_width  = 8192,
+   .max_height = 8192,
+   .out_width_align= 8,
+   .win_hor_offs_align = 2,
+   .out_hor_offs_align = 8,
+   .support_multi_dma_buf  = true,
+   .num_devs = 3,
 };
 
 static struct platform_device_id fimc_lite_driver_ids[] = {
@@ -1641,6 +1654,10 @@ static const struct of_device_id flite_of_match[] = {
.compatible = samsung,exynos4212-fimc-lite,
.data = fimc_lite_drvdata_exynos4,
},
+   {
+   .compatible = samsung,exynos5250-fimc-lite,
+   .data = fimc_lite_drvdata_exynos5,
+   },
{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, flite_of_match);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h 
b/drivers/media/platform/exynos4-is/fimc-lite.h
index 71fed51..a35f29e 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.h
+++ b/drivers/media/platform/exynos4-is/fimc-lite.h
@@ -27,7 +27,7 @@
 
 #define FIMC_LITE_DRV_NAME exynos-fimc-lite
 #define FLITE_CLK_NAME flite
-#define FIMC_LITE_MAX_DEVS 2
+#define FIMC_LITE_MAX_DEVS 3
 #define FLITE_REQ_BUFS_MIN 2
 
 /* Bit index definitions for struct fimc_lite::state */
@@ -54,6 +54,8 @@ struct flite_drvdata {
unsigned short out_width_align;
unsigned short win_hor_offs_align;
unsigned short out_hor_offs_align;
+   unsigned short support_multi_dma_buf;
+   unsigned short num_devs;
 };
 
 #define fimc_lite_get_drvdata(_pdev) \
-- 
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 v2 3/6] media: fimc-lite: Adding support for Exynos5

2013-04-24 Thread Shaik Ameer Basha
FIMC-LITE supports multiple DMA shadow registers from Exynos5 onwards.
This patch adds the functionality of using shadow registers by
checking the driver data.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite-reg.c |   13 +++
 drivers/media/platform/exynos4-is/fimc-lite-reg.h |   41 -
 drivers/media/platform/exynos4-is/fimc-lite.c |   12 --
 3 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
index 8cc0d39..a1d566a 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
@@ -215,6 +215,18 @@ void flite_hw_set_camera_bus(struct fimc_lite *dev,
flite_hw_set_camera_port(dev, si-mux_id);
 }
 
+static void flite_hw_set_pack12(struct fimc_lite *dev, int on)
+{
+   u32 cfg = readl(dev-regs + FLITE_REG_CIODMAFMT);
+
+   cfg = ~FLITE_REG_CIODMAFMT_PACK12;
+
+   if (on)
+   cfg |= FLITE_REG_CIODMAFMT_PACK12;
+
+   writel(cfg, dev-regs + FLITE_REG_CIODMAFMT);
+}
+
 static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame 
*f)
 {
static const u32 pixcode[4][2] = {
@@ -267,6 +279,7 @@ void flite_hw_set_output_dma(struct fimc_lite *dev, struct 
flite_frame *f,
 
flite_hw_set_out_order(dev, f);
flite_hw_set_dma_window(dev, f);
+   flite_hw_set_pack12(dev, 0);
 }
 
 void flite_hw_dump_regs(struct fimc_lite *dev, const char *label)
diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.h 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
index 3903839..8e57e7a 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
@@ -120,6 +120,10 @@
 /* b0: 1 - camera B, 0 - camera A */
 #define FLITE_REG_CIGENERAL_CAM_B  (1  0)
 
+
+#define FLITE_REG_CIFCNTSEQ0x100
+#define FLITE_REG_CIOSAN(x)(0x200 + (4 * (x)))
+
 /* 
  * Function declarations
  */
@@ -143,8 +147,41 @@ void flite_hw_set_dma_window(struct fimc_lite *dev, struct 
flite_frame *f);
 void flite_hw_set_test_pattern(struct fimc_lite *dev, bool on);
 void flite_hw_dump_regs(struct fimc_lite *dev, const char *label);
 
-static inline void flite_hw_set_output_addr(struct fimc_lite *dev, u32 paddr)
+static inline void flite_hw_set_output_addr(struct fimc_lite *dev,
+   u32 paddr, u32 index)
+{
+   u32 config;
+
+   /* FLITE in EXYNOS4 has only one DMA register */
+   if (!dev-dd-support_multi_dma_buf)
+   index = 0;
+
+   config = readl(dev-regs + FLITE_REG_CIFCNTSEQ);
+   config |= 1  index;
+   writel(config, dev-regs + FLITE_REG_CIFCNTSEQ);
+
+   if (index == 0)
+   writel(paddr, dev-regs + FLITE_REG_CIOSA);
+   else
+   writel(paddr, dev-regs + FLITE_REG_CIOSAN(index-1));
+}
+
+static inline void flite_hw_clear_output_addr(struct fimc_lite *dev, u32 index)
 {
-   writel(paddr, dev-regs + FLITE_REG_CIOSA);
+   u32 config;
+
+   /* FLITE in EXYNOS4 has only one DMA register */
+   if (!dev-dd-support_multi_dma_buf)
+   index = 0;
+
+   config = readl(dev-regs + FLITE_REG_CIFCNTSEQ);
+   config = ~(1  index);
+   writel(config, dev-regs + FLITE_REG_CIFCNTSEQ);
 }
+
+static inline void flite_hw_clear_output_index(struct fimc_lite *dev)
+{
+   writel(0, dev-regs + FLITE_REG_CIFCNTSEQ);
+}
+
 #endif /* FIMC_LITE_REG_H */
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index cb173ec..1b12ea8 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -166,6 +166,8 @@ static int fimc_lite_hw_init(struct fimc_lite *fimc, bool 
isp_output)
if (fimc-inp_frame.fmt == NULL || fimc-out_frame.fmt == NULL)
return -EINVAL;
 
+   flite_hw_clear_output_index(fimc);
+
/* Get sensor configuration data from the sensor subdev */
si = v4l2_get_subdev_hostdata(fimc-sensor);
if (!si)
@@ -307,11 +309,12 @@ static irqreturn_t flite_irq_handler(int irq, void *priv)
tv-tv_sec = ts.tv_sec;
tv-tv_usec = ts.tv_nsec / NSEC_PER_USEC;
vbuf-vb.v4l2_buf.sequence = fimc-frame_count++;
+   flite_hw_clear_output_addr(fimc, vbuf-vb.v4l2_buf.index);
vb2_buffer_done(vbuf-vb, VB2_BUF_STATE_DONE);
 
vbuf = fimc_lite_pending_queue_pop(fimc);
-   flite_hw_set_output_addr(fimc, vbuf-paddr);
-   fimc_lite_active_queue_add(fimc, vbuf);
+   flite_hw_set_output_addr(fimc, vbuf-paddr,
+   vbuf-vb.v4l2_buf.index);
}
 
if (test_bit

[RFC v2 4/6] media: fimc-lite: Fix for DMA output corruption

2013-04-24 Thread Shaik Ameer Basha
Fixes Buffer corruption on DMA output from fimc-lite

Signed-off-by: Arun Kumar K arun...@samsung.com
Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite-reg.c |3 ++-
 drivers/media/platform/exynos4-is/fimc-lite.c |   14 +-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
index a1d566a..46eda5b 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
@@ -68,7 +68,8 @@ void flite_hw_set_interrupt_mask(struct fimc_lite *dev)
if (atomic_read(dev-out_path) == FIMC_IO_DMA) {
intsrc = FLITE_REG_CIGCTRL_IRQ_OVFEN |
 FLITE_REG_CIGCTRL_IRQ_LASTEN |
-FLITE_REG_CIGCTRL_IRQ_STARTEN;
+FLITE_REG_CIGCTRL_IRQ_STARTEN |
+FLITE_REG_CIGCTRL_IRQ_ENDEN;
} else {
/* An output to the FIMC-IS */
intsrc = FLITE_REG_CIGCTRL_IRQ_OVFEN |
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index 1b12ea8..5de2dd4 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -301,8 +301,16 @@ static irqreturn_t flite_irq_handler(int irq, void *priv)
 
if ((intsrc  FLITE_REG_CISTATUS_IRQ_SRC_FRMSTART) 
test_bit(ST_FLITE_RUN, fimc-state) 
-   !list_empty(fimc-active_buf_q) 
!list_empty(fimc-pending_buf_q)) {
+   vbuf = fimc_lite_pending_queue_pop(fimc);
+   flite_hw_set_output_addr(fimc, vbuf-paddr,
+   vbuf-vb.v4l2_buf.index);
+   fimc_lite_active_queue_add(fimc, vbuf);
+   }
+
+   if ((intsrc  FLITE_REG_CISTATUS_IRQ_SRC_FRMEND) 
+   test_bit(ST_FLITE_RUN, fimc-state) 
+   !list_empty(fimc-active_buf_q)) {
vbuf = fimc_lite_active_queue_pop(fimc);
ktime_get_ts(ts);
tv = vbuf-vb.v4l2_buf.timestamp;
@@ -311,10 +319,6 @@ static irqreturn_t flite_irq_handler(int irq, void *priv)
vbuf-vb.v4l2_buf.sequence = fimc-frame_count++;
flite_hw_clear_output_addr(fimc, vbuf-vb.v4l2_buf.index);
vb2_buffer_done(vbuf-vb, VB2_BUF_STATE_DONE);
-
-   vbuf = fimc_lite_pending_queue_pop(fimc);
-   flite_hw_set_output_addr(fimc, vbuf-paddr,
-   vbuf-vb.v4l2_buf.index);
}
 
if (test_bit(ST_FLITE_CONFIG, fimc-state))
-- 
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 v2 5/6] media: s5p-csis: Adding Exynos5250 compatibility

2013-04-24 Thread Shaik Ameer Basha
FIMC-IS firmware needs all the MIPI-CSIS interrupts to be enabled.
This patch enables all those MIPI interrupts and adds the Exynos5
compatible string.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos4-is/mipi-csis.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c 
b/drivers/media/platform/exynos4-is/mipi-csis.c
index 8636bcd..51ad9b2 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -66,7 +66,7 @@ MODULE_PARM_DESC(debug, Debug level (0-2));
 
 /* Interrupt mask */
 #define S5PCSIS_INTMSK 0x10
-#define S5PCSIS_INTMSK_EN_ALL  0xf000103f
+#define S5PCSIS_INTMSK_EN_ALL  0xfc00103f
 #define S5PCSIS_INTMSK_EVEN_BEFORE (1  31)
 #define S5PCSIS_INTMSK_EVEN_AFTER  (1  30)
 #define S5PCSIS_INTMSK_ODD_BEFORE  (1  29)
@@ -1003,6 +1003,7 @@ static const struct dev_pm_ops s5pcsis_pm_ops = {
 static const struct of_device_id s5pcsis_of_match[] = {
{ .compatible = samsung,s5pv210-csis },
{ .compatible = samsung,exynos4210-csis },
+   { .compatible = samsung,exynos5250-csis },
{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, s5pcsis_of_match);
-- 
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 v2 6/6] media: exynos5-is: Adding media device driver for exynos5

2013-04-24 Thread Shaik Ameer Basha
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

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

* Gscaler: general scaler
  Support memory to memory interface
  Support output interface from memory to display device(LCD, TV)
  Support capture interface from device(FIMC-LITE, FIMD) to memory

-- media 0
  Camera Capture path consists of MIPI-CSIS, FIMC-LITE and G-Scaler
  ++ +---+ +-+
  | Sensor | -- | FIMC-LITE | -- | G-Scaler-capture |
  ++ +---+ +-+

  ++ +---+ +---+ +-+
  | Sensor | -- | MIPI-CSIS | -- | FIMC-LITE | -- | G-Scaler-capture |
  ++ +---+ +---+ +-+

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 .../devicetree/bindings/media/exynos5-mdev.txt |  153 +++
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/exynos5-is/Kconfig  |7 +
 drivers/media/platform/exynos5-is/Makefile |4 +
 drivers/media/platform/exynos5-is/exynos5-mdev.c   | 1131 
 drivers/media/platform/exynos5-is/exynos5-mdev.h   |  120 +++
 7 files changed, 1417 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos5-mdev.txt
 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

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

Re: [RFC 11/12] media: m5mols: Adding dt support to m5mols driver

2013-03-24 Thread Shaik Ameer Basha
Hi Sylwester,

Thanks for the review.
Actually I agree with all of your review comments.

This was just a temporary test patch, used to test exynos5-mdev.
I thought for some one to test exynos5-mdev series patches, i need to
provide one working m5mols dt driver.

Good to hear you already have one patch for this driver.
If you can able to post the dt patch for this driver, I will use that.

Regards,
Shaik Ameer Basha


On Sat, Mar 23, 2013 at 5:26 PM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Shaik,


 On 03/06/2013 12:53 PM, Shaik Ameer Basha wrote:

 This patch adds the dt support to m5mols driver.

 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 ---
   drivers/media/i2c/m5mols/m5mols_core.c |   54
 +++-
   1 file changed, 53 insertions(+), 1 deletion(-)

 diff --git a/drivers/media/i2c/m5mols/m5mols_core.c
 b/drivers/media/i2c/m5mols/m5mols_core.c
 index d4e7567..21c66ef 100644
 --- a/drivers/media/i2c/m5mols/m5mols_core.c
 +++ b/drivers/media/i2c/m5mols/m5mols_core.c
 @@ -19,6 +19,8 @@
   #includelinux/interrupt.h
   #includelinux/delay.h
   #includelinux/gpio.h
 +#includelinux/of_gpio.h
 +#includelinux/pinctrl/consumer.h


 What would you need pinctrl for ? In most cases this driver just needs one
 GPIO
 (sensor RESET), which is normally passed in gpios property.


   #includelinux/regulator/consumer.h
   #includelinux/videodev2.h
   #includelinux/module.h
 @@ -926,13 +928,38 @@ static irqreturn_t m5mols_irq_handler(int irq, void
 *data)
 return IRQ_HANDLED;
   }

 +static const struct of_device_id m5mols_match[];
 +
   static int m5mols_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
   {
 -   const struct m5mols_platform_data *pdata =
 client-dev.platform_data;
 +   struct m5mols_platform_data *pdata;
 struct m5mols_info *info;
 +   const struct of_device_id *of_id;
 struct v4l2_subdev *sd;
 int ret;
 +   struct pinctrl *pctrl;
 +   int eint_gpio = 0;
 +
 +   if (client-dev.of_node) {
 +   of_id = of_match_node(m5mols_match, client-dev.of_node);
 +   if (of_id)
 +   pdata = (struct m5mols_platform_data
 *)of_id-data;
 +   client-dev.platform_data = pdata;


 Oh, no. Probably best thing to do would be to get rid of struct
 m5mols_platform_data pointer from struct m5mols_info and just add gpio_reset
 field there. That's what we have currently in the driver's platform data
 structure.

 struct m5mols_platform_data {
 int gpio_reset;
 u8 reset_polarity;
 int (*set_power)(struct device *dev, int on);
 };

 gpio_reset and reset_polarity are already handled in the driver, and for
 this we just need a single entry in 'gpios' property.

 set_power callback can't be supported. Luckily there seems to be no board
 that needs it any more. So we just drop it. One solution for more complex
 power sequence could be the Runtime Interpreted Power Sequences. Once it
 is available we might be able to describe what was previously in a board
 file in set_power callback in the device tree.


 +   } else {
 +   pdata = client-dev.platform_data;
 +   }
 +
 +   if (!pdata)
 +   return -EINVAL;
 +
 +   pctrl = devm_pinctrl_get_select_default(client-dev);


 Two issues here:

 1. m5mols DT node doesn't include pinctrl property, does it ?
 2. default pinctrl state is now being handled in the driver core.

 Hence this pinctrl set up could well be removed.


 +   if (client-dev.of_node) {
 +   eint_gpio = of_get_named_gpio(client-dev.of_node,
 gpios, 0);
 +   client-irq = gpio_to_irq(eint_gpio);
 +   pdata-gpio_reset = of_get_named_gpio(client-dev.of_node,
 +   gpios,
 1);


 Err, now when pinctrl and generic GPIO DT bindings are supported on Exynos5
 this should not be needed at all. request_irq() should work when you add
 relevant properties in this device DT node. Please see exynos4210-trats.dts,
 mms114-touchscreen node for an example.

 mms114-touchscreen@48 {
 ...
 interrupt-parent = gpx0;
 interrupts = 4 2;
 ...
 };

 You specify GPIO bank in the 'interrupt-parent' property, and the GPIO
 index within the bank in first cell of 'interrupts' property. The second
 cell are interrupt flags as defined in /Documentation/devicetree/bindings/
 interrupt-controller/interrupts.txt. I'm not sure how this interacts with
 the interrupt flags passed to request_irq ATM.

 It's the pinctrl driver's task to configure the GPIO pinmux into EINT
 function, when the above properties are present in device DT node.


 +   }

 if (pdata == NULL) {
 dev_err(client-dev, No platform data\n);
 @@ -1040,9 +1067,34 @@ static const struct i2c_device_id m5mols_id

Re: [RFC 01/12] media: s5p-fimc: modify existing mdev to use common pipeline

2013-03-11 Thread Shaik Ameer Basha
Hi Sylwester,

Thanks for the review.
Actually I know this is the important patch in this series and I
wanted us to have
enough time to discuss on this patch. That's why I posted this patch
series in hurry.

I will remove this patch from the exynos5-mdev series and will send this as a
separate patch from next time.

please find my review comments inline..


On Mon, Mar 11, 2013 at 3:30 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 03/06/2013 12:53 PM, Shaik Ameer Basha wrote:

 This patch modifies the current fimc_pipeline to exynos_pipeline,


 I think we could leave it as fimc_pipeline, exynos_pipeline seems
 too generic to me.

no issues, if we are going to strict to this common pipeline implementation
definitely we can retain fimc_pipeline or we can use some other name which
is not too generic.


 which can be used across multiple media device drivers.
 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 ---
   drivers/media/platform/s5p-fimc/fimc-capture.c |   96 +++-
   drivers/media/platform/s5p-fimc/fimc-core.h|4 +-
   drivers/media/platform/s5p-fimc/fimc-lite.c|   73 --
   drivers/media/platform/s5p-fimc/fimc-lite.h|4 +-
   drivers/media/platform/s5p-fimc/fimc-mdevice.c |  186
 ++--
   drivers/media/platform/s5p-fimc/fimc-mdevice.h |   41 +++---
   include/media/s5p_fimc.h   |   66 ++---
   7 files changed, 326 insertions(+), 144 deletions(-)

 diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c
 b/drivers/media/platform/s5p-fimc/fimc-capture.c
 index 4cbaf46..106466e 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-capture.c
 +++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
 @@ -27,24 +27,26 @@
   #includemedia/videobuf2-core.h
   #includemedia/videobuf2-dma-contig.h

 -#include fimc-mdevice.h
   #include fimc-core.h
   #include fimc-reg.h

   static int fimc_capture_hw_init(struct fimc_dev *fimc)
   {
 struct fimc_ctx *ctx = fimc-vid_cap.ctx;
 -   struct fimc_pipeline *p =fimc-pipeline;
 +   struct exynos_pipeline *p =fimc-pipeline;

 struct fimc_sensor_info *sensor;
 unsigned long flags;
 +   struct v4l2_subdev *sd;
 int ret = 0;

 -   if (p-subdevs[IDX_SENSOR] == NULL || ctx == NULL)
 +   sd = exynos_pipeline_get_subdev(fimc-pipeline_ops,
 +   get_subdev_sensor, p);


 Hmm, it feels it is going wrong path this way. I would keep changes
 to the s5p-fimc driver as small as possible. And the modules that
 are shared across the exynos4 and exynos5 driver should use generic
 media graph walking routines where possible.

The only problem here is, the fimc_subdev_index enum is specific to
fimc-mdevice.
and why should we expose one particular media-device driver specific
enums to other drivers.
My Idea was to remove all media device specific structures, macros
from fimc, fimc-lite,
mipi-csis and fimc-is drivers.



 +   if (sd == NULL || ctx == NULL)
 return -ENXIO;
 if (ctx-s_frame.fmt == NULL)
 return -EINVAL;

 -   sensor = v4l2_get_subdev_hostdata(p-subdevs[IDX_SENSOR]);
 +   sensor = v4l2_get_subdev_hostdata(sd);

 spin_lock_irqsave(fimc-slock, flags);
 fimc_prepare_dma_offset(ctx,ctx-d_frame);

 ...

 @@ -486,9 +491,12 @@ static struct vb2_ops fimc_capture_qops = {
   int fimc_capture_ctrls_create(struct fimc_dev *fimc)
   {
 struct fimc_vid_cap *vid_cap =fimc-vid_cap;

 -   struct v4l2_subdev *sensor = fimc-pipeline.subdevs[IDX_SENSOR];
 +   struct v4l2_subdev *sensor;
 int ret;

 +   sensor = exynos_pipeline_get_subdev(fimc-pipeline_ops,
 +
 get_subdev_sensor,fimc-pipeline);

 +
 if (WARN_ON(vid_cap-ctx == NULL))
 return -ENXIO;
 if (vid_cap-ctx-ctrls.ready)
 @@ -513,7 +521,7 @@ static int fimc_capture_open(struct file *file)

 dbg(pid: %d, state: 0x%lx, task_pid_nr(current), fimc-state);

 -   fimc_md_graph_lock(fimc);
 +   exynos_pipeline_graph_lock(fimc-pipeline_ops,fimc-pipeline);


 Hmm, this look pretty scary to me. But I suspect this change is not
 needed at all. The graph lock is _not_ the pipeline lock. It protects
 all media entities registered to the media device, and links between
 them. Not only entities linked into specific video processing pipeline
 at a moment.

Sorry, here the function name doesn't suits its implementation.
Actually  exynos_pipeline_graph_lock() does what exactly
fimc_md_graph_lock() does.
I thought of having one common function across all the drivers to use
graph lock/unlock functionality.


 mutex_lock(fimc-lock);

 if (fimc_m2m_active(fimc))
 @@ -531,7 +539,7 @@ static int fimc_capture_open(struct file *file)
 }

 if (++fimc-vid_cap.refcnt == 1) {
 -   ret = fimc_pipeline_call(fimc, open,fimc-pipeline,
 +   ret = exynos_pipeline_call(fimc, open,fimc-pipeline

Re: [RFC 02/12] fimc-lite: Adding Exynos5 compatibility to fimc-lite driver

2013-03-11 Thread Shaik Ameer Basha
Hi Sylwester,

On Mon, Mar 11, 2013 at 2:06 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 03/06/2013 12:53 PM, Shaik Ameer Basha wrote:

 This patch adds the Exynos5 soc compatibility to the fimc-lite driver.
 It also adds a version checking to deal with the changes between
 different fimc-lite hardware versions.


 Is there really anything different between the Exynos4 and Exynos5
 FIMC-LITE IPs except the maximum number of buffer descriptors in
 the output DMA queue ?


 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 ---
   drivers/media/platform/s5p-fimc/fimc-lite.c |   23
 +++
   drivers/media/platform/s5p-fimc/fimc-lite.h |7 ++-
   2 files changed, 29 insertions(+), 1 deletion(-)

 diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c
 b/drivers/media/platform/s5p-fimc/fimc-lite.c
 index 122cf95..eb64f87 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-lite.c
 +++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
 @@ -1653,6 +1653,16 @@ static struct flite_variant
 fimc_lite0_variant_exynos4 = {
 .out_width_align= 8,
 .win_hor_offs_align = 2,
 .out_hor_offs_align = 8,
 +   .version= FLITE_VER_EXYNOS4,
 +};
 +
 +static struct flite_variant fimc_lite0_variant_exynos5 = {
 +   .max_width  = 8192,
 +   .max_height = 8192,
 +   .out_width_align= 8,
 +   .win_hor_offs_align = 2,
 +   .out_hor_offs_align = 8,


 Please see my comment to patch 03/12.


 +   .version= FLITE_VER_EXYNOS5,
   };

   /* EXYNOS4212, EXYNOS4412 */
 @@ -1663,6 +1673,15 @@ static struct flite_drvdata
 fimc_lite_drvdata_exynos4 = {
 },
   };

 +/* EXYNOS5250 */
 +static struct flite_drvdata fimc_lite_drvdata_exynos5 = {
 +   .variant = {
 +   [0] =fimc_lite0_variant_exynos5,
 +   [1] =fimc_lite0_variant_exynos5,
 +   [2] =fimc_lite0_variant_exynos5,
 +   },
 +};
 +
   static struct platform_device_id fimc_lite_driver_ids[] = {
 {
 .name   = exynos-fimc-lite,
 @@ -1677,6 +1696,10 @@ static const struct of_device_id flite_of_match[] =
 {
 .compatible = samsung,exynos4212-fimc-lite,
 .data =fimc_lite_drvdata_exynos4,
 },
 +   {
 +   .compatible = samsung,exynos5250-fimc-lite,
 +   .data =fimc_lite_drvdata_exynos5,
 +   },
 { /* sentinel */ },
   };
   MODULE_DEVICE_TABLE(of, flite_of_match);
 diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.h
 b/drivers/media/platform/s5p-fimc/fimc-lite.h
 index 66d6eeb..ef43fe0 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-lite.h
 +++ b/drivers/media/platform/s5p-fimc/fimc-lite.h
 @@ -28,7 +28,7 @@

   #define FIMC_LITE_DRV_NAMEexynos-fimc-lite
   #define FLITE_CLK_NAMEflite
 -#define FIMC_LITE_MAX_DEVS 2
 +#define FIMC_LITE_MAX_DEVS 3
   #define FLITE_REQ_BUFS_MIN2

   /* Bit index definitions for struct fimc_lite::state */
 @@ -49,12 +49,17 @@ enum {
   #define FLITE_SD_PAD_SOURCE_ISP   2
   #define FLITE_SD_PADS_NUM 3

 +#define FLITE_VER_EXYNOS4  0
 +#define FLITE_VER_EXYNOS5  1


 I would prefer not using explicit version and rather put each
 quirk in the driver data structure, so we can avoid those
 multiple if (version == ...) checks all over in the code, should
 more revision of this IP come in future SoCs.

Ok. no issues. we can remove this version checking and maintain the
differences in driver data structures.

Regards,
Shaik Ameer Basha
--
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 03/12] media: fimc-lite: Adding support for Exynos5

2013-03-11 Thread Shaik Ameer Basha
Hi Sylweter,

On Mon, Mar 11, 2013 at 2:09 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 03/06/2013 12:53 PM, Shaik Ameer Basha wrote:

 This patch adds the following functionalities to existing driver

 1] FIMC-LITE supports multiple DMA shadow registers from Exynos5 onwards.
 This patch adds the functionality of using shadow registers by
 checking the current FIMC-LITE hardware version.
 2] Fixes Buffer corruption on DMA output from fimc-lite
 3] Modified the driver to be used as pipeline endpoint


 There seems to be too many things done in this single patch. Can
 we have it split for example to the parts adding:
 - registers definitions and hardware interface helpers
   for exynos5
 - the DMA handling fix

 So it is easier to apply it and test incrementally ?

Definitely, I will split this patch in to multiple patches



 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 Signed-off-by: Arun Kumar Karun...@samsung.com
 ---
   drivers/media/platform/s5p-fimc/fimc-lite-reg.c |   16 +-
   drivers/media/platform/s5p-fimc/fimc-lite-reg.h |   41 -
   drivers/media/platform/s5p-fimc/fimc-lite.c |  196
 +--
   drivers/media/platform/s5p-fimc/fimc-lite.h |3 +-
   4 files changed, 236 insertions(+), 20 deletions(-)

 ...

   void flite_hw_dump_regs(struct fimc_lite *dev, const char *label)
 diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.h
 b/drivers/media/platform/s5p-fimc/fimc-lite-reg.h
 index 0e34584..716df6c 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.h
 +++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.h
 @@ -120,6 +120,10 @@
   /* b0: 1 - camera B, 0 - camera A */
   #define FLITE_REG_CIGENERAL_CAM_B (1  0)

 +
 +#define FLITE_REG_CIFCNTSEQ0x100
 +#define FLITE_REG_CIOSAN(x)(0x200 + (4 * (x)))
 +
   /*
 
* Function declarations
*/
 @@ -143,8 +147,41 @@ void flite_hw_set_dma_window(struct fimc_lite *dev,
 struct flite_frame *f);
   void flite_hw_set_test_pattern(struct fimc_lite *dev, bool on);
   void flite_hw_dump_regs(struct fimc_lite *dev, const char *label);

 -static inline void flite_hw_set_output_addr(struct fimc_lite *dev, u32
 paddr)
 +static inline void flite_hw_set_output_addr(struct fimc_lite *dev,
 +   u32 paddr, u32 index)
 +{
 +   u32 config;
 +
 +   /* FLITE in EXYNOS4 has only one DMA register */
 +   if (dev-variant-version == FLITE_VER_EXYNOS4)
 +   index = 0;
 +
 +   config = readl(dev-regs + FLITE_REG_CIFCNTSEQ);
 +   config |= 1  index;
 +   writel(config, dev-regs + FLITE_REG_CIFCNTSEQ);
 +
 +   if (index == 0)
 +   writel(paddr, dev-regs + FLITE_REG_CIOSA);
 +   else
 +   writel(paddr, dev-regs + FLITE_REG_CIOSAN(index-1));
 +}
 +
 +static inline void flite_hw_clear_output_addr(struct fimc_lite *dev, u32
 index)
   {
 -   writel(paddr, dev-regs + FLITE_REG_CIOSA);
 +   u32 config;
 +
 +   /* FLITE in EXYNOS4 has only one DMA register */
 +   if (dev-variant-version == FLITE_VER_EXYNOS4)
 +   index = 0;


 I'm planning to remove struct flite_variant and put everything what's
 needed in the driver data structure. Are there any differences between
 FIMC-LITE IP block instances or Exynos5250 ? Or are these all same ?

Except the out dma buffers change, I don't think any changes are there in
fimc-lite for Exynos5250.


 That said it seems better to me to add a field like out_dma_bufs to the
 driver data structure and embed a pointer to this structure in struct
 fimc_lite. The driver data matching would be done automatically, based
 on the compatible property and those unpleasant checks
 if (variant-version == FLITE_VER_EXYNOS4) ...

Ok. This seems a better option. I will follow your suggestions.


 +
 +   config = readl(dev-regs + FLITE_REG_CIFCNTSEQ);
 +   config= ~(1  index);

 +   writel(config, dev-regs + FLITE_REG_CIFCNTSEQ);
   }
 +
 +static inline void flite_hw_clear_output_index(struct fimc_lite *dev)
 +{
 +   writel(0, dev-regs + FLITE_REG_CIFCNTSEQ);
 +}
 +
   #endif /* FIMC_LITE_REG_H */
 diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c
 b/drivers/media/platform/s5p-fimc/fimc-lite.c
 index eb64f87..1edc5ce 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-lite.c
 +++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
 @@ -136,6 +136,8 @@ static int fimc_lite_hw_init(struct fimc_lite *fimc,
 bool isp_output)
 if (fimc-fmt == NULL)
 return -EINVAL;

 +   flite_hw_clear_output_index(fimc);
 +
 /* Get sensor configuration data from the sensor subdev */
 src_info = v4l2_get_subdev_hostdata(sensor);
 spin_lock_irqsave(fimc-slock, flags);
 @@ -266,19 +268,24 @@ static irqreturn_t flite_irq_handler(int irq, void
 *priv)

 if ((intsrc  FLITE_REG_CISTATUS_IRQ_SRC_FRMSTART

Re: [RFC 04/12] s5p-csis: Adding Exynos5250 compatibility

2013-03-11 Thread Shaik Ameer Basha
Hi Sylwester,

On Mon, Mar 11, 2013 at 2:10 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 03/06/2013 12:53 PM, Shaik Ameer Basha wrote:

 Please don't leave the change log empty. I'll apply this patch.
 I'm just wondering, if there aren't any further changes needed
 to make the driver really working on exynos5250 ?


There was nothing from driver side to change for making it work
for Exynos5250. May be I need to update the S5P_INTMASK_EN_ALL
to include all interrupts.

Regards,
Shaik Ameer Basha


 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 ---
   drivers/media/platform/s5p-fimc/mipi-csis.c |1 +
   1 file changed, 1 insertion(+)

 diff --git a/drivers/media/platform/s5p-fimc/mipi-csis.c
 b/drivers/media/platform/s5p-fimc/mipi-csis.c
 index df4411c..debda7c 100644
 --- a/drivers/media/platform/s5p-fimc/mipi-csis.c
 +++ b/drivers/media/platform/s5p-fimc/mipi-csis.c
 @@ -1002,6 +1002,7 @@ static const struct dev_pm_ops s5pcsis_pm_ops = {
   static const struct of_device_id s5pcsis_of_match[] __devinitconst = {
 { .compatible = samsung,exynos3110-csis },
 { .compatible = samsung,exynos4210-csis },
 +   { .compatible = samsung,exynos5250-csis },
 { /* sentinel */ },
   };
   MODULE_DEVICE_TABLE(of, s5pcsis_of_match);
--
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 05/12] ARM: EXYNOS: Add devicetree node for mipi-csis driver for exynos5

2013-03-11 Thread Shaik Ameer Basha
Hi Sylwester,

On Mon, Mar 11, 2013 at 2:24 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 03/06/2013 12:53 PM, Shaik Ameer Basha wrote:

 This patch adds necessary source definations needed for mipi-csis
 driver and adds devicetree node for exynos5250.

 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 ---
   arch/arm/boot/dts/exynos5250.dtsi   |   18 ++
   arch/arm/mach-exynos/clock-exynos5.c|   16 ++--
   arch/arm/mach-exynos/include/mach/map.h |3 +++
   arch/arm/mach-exynos/mach-exynos5-dt.c  |4 
   4 files changed, 39 insertions(+), 2 deletions(-)

 diff --git a/arch/arm/boot/dts/exynos5250.dtsi
 b/arch/arm/boot/dts/exynos5250.dtsi
 index 3a2cd9a..4fff98b 100644
 --- a/arch/arm/boot/dts/exynos5250.dtsi
 +++ b/arch/arm/boot/dts/exynos5250.dtsi
 @@ -47,6 +47,8 @@
 i2c6 =i2c_6;
 i2c7 =i2c_7;
 i2c8 =i2c_8;
 +   csis0 =csis_0;
 +   csis1 =csis_1;
 };

 gic:interrupt-controller@10481000 {
 @@ -357,4 +359,20 @@
 reg =0x1445 0x1;
 interrupts =0 94 0;
 };
 +
 +   csis_0: csis@13C2 {
 +   compatible = samsung,exynos5250-csis;
 +   reg =0x13C2 0x4000;
 +   interrupts =0 79 0;
 +   bus-width =4;
 +   status = disabled;
 +   };
 +
 +   csis_1: csis@13C3 {
 +   compatible = samsung,exynos5250-csis;
 +   reg =0x13C3 0x4000;
 +   interrupts =0 80 0;
 +   bus-width =4;


 Shouldn't this be 2 ? Anyway what's the point of adding this node here

Yes, It has to be 2. Seems some Ctrl+c/v issues. :)

 only to move it in a subsequent patch ? I guess you should first add
 'camera' node and then have further patches adding relevant device nodes

Ok.. I even got the same comments just before postings. As it was a RFC patch,
I just posted this as it is.
Definitely, i will modify this in the upcoming version of patches.


Regards,
Shaik Ameer Basha



 +   status = disabled;
 +   };
   };


 diff --git a/arch/arm/mach-exynos/clock-exynos5.c
 b/arch/arm/mach-exynos/clock-exynos5.c
 index e9d7b80..34a22ff 100644
 --- a/arch/arm/mach-exynos/clock-exynos5.c
 +++ b/arch/arm/mach-exynos/clock-exynos5.c


 This file is already removed in Kukjin's for-next tree.
 And for dts changes I would start the patch summary line with ARM: dts:.


 @@ -859,6 +859,16 @@ static struct clk exynos5_init_clocks_off[] = {
 .enable = exynos5_clk_ip_gscl_ctrl,
 .ctrlbit= (1  3),
 }, {
 +   .name   = csis,
 +   .devname= s5p-mipi-csis.0,
 +   .enable = exynos5_clk_ip_gscl_ctrl,
 +   .ctrlbit= (1  5),
 +   }, {
 +   .name   = csis,
 +   .devname= s5p-mipi-csis.1,
 +   .enable = exynos5_clk_ip_gscl_ctrl,
 +   .ctrlbit= (1  6),
 +   }, {
--
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 05/12] ARM: EXYNOS: Add devicetree node for mipi-csis driver for exynos5

2013-03-11 Thread Shaik Ameer Basha
On Mon, Mar 11, 2013 at 2:27 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 03/06/2013 12:53 PM, Shaik Ameer Basha wrote:

 --- a/arch/arm/boot/dts/exynos5250.dtsi
 +++ b/arch/arm/boot/dts/exynos5250.dtsi
 @@ -47,6 +47,8 @@
 i2c6 =i2c_6;
 i2c7 =i2c_7;
 i2c8 =i2c_8;
 +   csis0 =csis_0;
 +   csis1 =csis_1;


 You can drop these aliases if you use my latest patches as indicated
 in the comment to patch 00/12.


Ok.


 diff --git a/arch/arm/mach-exynos/clock-exynos5.c
 b/arch/arm/mach-exynos/clock-exynos5.c
 index e9d7b80..34a22ff 100644
 --- a/arch/arm/mach-exynos/clock-exynos5.c
 +++ b/arch/arm/mach-exynos/clock-exynos5.c
 @@ -859,6 +859,16 @@ static struct clk exynos5_init_clocks_off[] = {
 .enable = exynos5_clk_ip_gscl_ctrl,
 .ctrlbit= (1  3),
 }, {
 +   .name   = csis,
 +   .devname= s5p-mipi-csis.0,
 +   .enable = exynos5_clk_ip_gscl_ctrl,
 +   .ctrlbit= (1  5),
 +   }, {


 Instead you should add relevant clock definitions to the Samsung clocks
 driver,
 it's already merged in Kukjin's tree.


No Issues, the next version posting will be re-based on the Samsung
common clock driver.

Regards,
Shaik Ameer Basha





--
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 07/12] media: exynos5-is: Adding media device driver for exynos5

2013-03-11 Thread Shaik Ameer Basha
Hi Sylwester,

Thanks for the review.
I will address all you comments for this patch in the next version.

Thanks,
Shaik Ameer Basha

On Mon, Mar 11, 2013 at 3:58 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 03/06/2013 12:53 PM, Shaik Ameer Basha wrote:

 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

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

 * Gscaler: general scaler
Support memory to memory interface
Support output interface from memory to display device(LCD, TV)
Support capture interface from device(FIMC-LITE, FIMD) to memory

 --  media 0
Camera Capture path consists of MIPI-CSIS, FIMC-LITE and G-Scaler
++ +---+ +-+
| Sensor | --  | FIMC-LITE | --  | G-Scaler-capture |
++ +---+ +-+

++ +---+ +---+ +-+
| Sensor | --  | MIPI-CSIS | --  | FIMC-LITE | --  |
 G-Scaler-capture |
++ +---+ +---+ +-+

 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 ---
   drivers/media/platform/Kconfig   |1 +
   drivers/media/platform/Makefile  |1 +
   drivers/media/platform/exynos5-is/Kconfig|7 +
   drivers/media/platform/exynos5-is/Makefile   |4 +
   drivers/media/platform/exynos5-is/exynos5-mdev.c | 1309
 ++
   drivers/media/platform/exynos5-is/exynos5-mdev.h |  107 ++
   6 files changed, 1429 insertions(+)
   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

 ...

 diff --git a/drivers/media/platform/exynos5-is/exynos5-mdev.c
 b/drivers/media/platform/exynos5-is/exynos5-mdev.c
 new file mode 100644
 index 000..1158696
 --- /dev/null
 +++ b/drivers/media/platform/exynos5-is/exynos5-mdev.c
 @@ -0,0 +1,1309 @@
 +/*
 + * S5P/EXYNOS4 SoC series camera host interface media device driver


 EXYNOS5


 + * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd.
 + * Sylwester Nawrockis.nawro...@samsung.com


 This is incorrect too, you should add your authorship and a note it
 is based on other code, with a proper copyright notice.


 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published
 + * by the Free Software Foundation, either version 2 of the License,
 + * or (at your option) any later version.
 + */
 +
 +#includelinux/bug.h
 +#includelinux/device.h
 +#includelinux/errno.h
 +#includelinux/i2c.h
 +#includelinux/kernel.h
 +#includelinux/list.h
 +#includelinux/module.h
 +#includelinux/of.h
 +#includelinux/of_platform.h
 +#includelinux/of_device.h
 +#includelinux/of_i2c.h
 +#includelinux/pinctrl/consumer.h
 +#includelinux/platform_device.h
 +#includelinux/pm_runtime.h
 +#includelinux/types.h
 +#includelinux/slab.h
 +#includemedia/v4l2-ctrls.h
 +#includemedia/v4l2-of.h
 +#includemedia/media-device.h
 +
 +#include exynos5-mdev.h
 +
 +#define dbg(fmt, args...) \
 +   pr_debug(%s:%d:  fmt \n, __func__, __LINE__, ##args)
 +
 +static struct fimc_md *g_exynos_mdev;
 +
 +static int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
 +static int __fimc_md_set_camclk(struct fimc_md *fmd,
 +   struct fimc_sensor_info *s_info,
 +   bool on);
 +/**
 + * fimc_pipeline_prepare - update pipeline information with subdevice
 pointers
 + * @fimc: fimc device terminating the pipeline
 + *
 + * Caller holds the graph mutex.
 + */
 +static void fimc_pipeline_prepare(struct exynos5_pipeline0 *p,
 + struct media_entity *me)
 +{
 +   struct media_pad *pad =me-pads[0];


 This will need to be changed to support subdevs with more than 2 pads.
 I should post relevant patch this week.

 +   struct v4l2_subdev *sd;
 +   int i;
 +
 +   for (i = 0; i  IDX_MAX; i++)
 +   p-subdevs[i] = NULL;
 +
 +   while (1) {
 +
 +   if (!(pad-flags  MEDIA_PAD_FL_SINK))

 +   break;
 +
 +   /* source pad */
 +   pad = media_entity_remote_source(pad);
 +
 +   if (pad != NULL)
 +   pr_err(entity type: %d, entity name: %s\n,
 +   media_entity_type(pad-entity),
 pad-entity-name);
 +
 +   if (pad == NULL ||
 +   media_entity_type(pad

Re: [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash

2013-03-07 Thread Shaik Ameer Basha
On Thu, Mar 7, 2013 at 8:21 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 On 02/21/2013 12:54 PM, Shaik Ameer Basha wrote:
 Changing the variable type to 'int' from 'unsigned int'. Driver
 logic expects the variable type to be 'int'.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/s5p-fimc/fimc-lite-reg.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c 
 b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
 index f0af075..3c7dd65 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
 +++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
 @@ -128,7 +128,7 @@ static const u32 src_pixfmt_map[8][3] = {
  void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame 
 *f)
  {
   enum v4l2_mbus_pixelcode pixelcode = dev-fmt-mbus_code;
 - unsigned int i = ARRAY_SIZE(src_pixfmt_map);
 + int i = ARRAY_SIZE(src_pixfmt_map);
   u32 cfg;

   while (i-- = 0) {
 @@ -224,7 +224,7 @@ static void flite_hw_set_out_order(struct fimc_lite 
 *dev, struct flite_frame *f)
   { V4L2_MBUS_FMT_VYUY8_2X8, FLITE_REG_CIODMAFMT_CRYCBY },
   };
   u32 cfg = readl(dev-regs + FLITE_REG_CIODMAFMT);
 - unsigned int i = ARRAY_SIZE(pixcode);
 + int i = ARRAY_SIZE(pixcode);

   while (i-- = 0)
   if (pixcode[i][0] == dev-fmt-mbus_code)


 There was a build warning like:

 drivers/media/platform/s5p-fimc/fimc-lite-reg.c: In function 
 ‘flite_hw_set_output_dma’:
 drivers/media/platform/s5p-fimc/fimc-lite-reg.c:230: warning: array subscript 
 is below array bounds
 drivers/media/platform/s5p-fimc/fimc-lite-reg.c: In function 
 ‘flite_hw_set_source_format’:
 drivers/media/platform/s5p-fimc/fimc-lite-reg.c:135: warning: array subscript 
 is below array bounds

 thus I squashed following change before applying this patch:

Thanks for that :)

-Shaik


 diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c 
 b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
 index 3c7dd65..ac9663c 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
 +++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
 @@ -131,7 +131,7 @@ void flite_hw_set_source_format(struct fimc_lite *dev, 
 struct flite_frame *f)
 int i = ARRAY_SIZE(src_pixfmt_map);
 u32 cfg;

 -   while (i-- = 0) {
 +   while (--i = 0) {
 if (src_pixfmt_map[i][0] == pixelcode)
 break;
 }
 @@ -226,7 +226,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, 
 struct flite_frame *f)
 u32 cfg = readl(dev-regs + FLITE_REG_CIODMAFMT);
 int i = ARRAY_SIZE(pixcode);

 -   while (i-- = 0)
 +   while (--i = 0)
 if (pixcode[i][0] == dev-fmt-mbus_code)
 break;
 cfg = ~FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK;

 --

 Regards,
 Sylwester
 --
 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
--
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 00/12] Adding media device driver for Exynos imaging subsystem

2013-03-06 Thread Shaik Ameer Basha
The following patchset features:

1] Creating a common pipeline framework which can be used by all
Exynos series SoCs for developing media device drivers.
2] Modified the existing fimc-mdevice for exynos4 to use the common
pipeline framework.
3] Adding of media device driver for Exynos5 Imaging subsystem.
4] Upgrading mipi-csis and fimc-lite drivers for Exynos5 SoCs.
5] Adding DT support to m5mols driver and tested with Exynos5 media
device driver.

Current changes are not tested on exynos4 series SoCs. Current media
device driver only support one pipeline (pipeline0) which consists of 
Sensor -- MIPI-CSIS -- FIMC-LITE
Sensor -- FIMC-LITE
G-Scaler support to pipeline0 will be added later.

Once the fimc-is device driver is posted, one more pipeline (pipeline1)
will be added for exynos5 media device driver for fimc-is sub-devices.

This patchset is rebased on:
git://linuxtv.org/media_tree.git:staging/for_v3.9

This patchset depends on:
from Thomas Abraham:
[1] pinctrl: exynos: add support for Samsung's Exynos5250
[2] ARM: dts: add pinctrl nodes for Exynos5250 SoC

from Sylwester Nawrocki:
[1] Device tree support for Exynos SoC camera subsystem

Shaik Ameer Basha (12):
  media: s5p-fimc: modify existing mdev to use common pipeline
  fimc-lite: Adding Exynos5 compatibility to fimc-lite driver
  media: fimc-lite: Adding support for Exynos5
  s5p-csis: Adding Exynos5250 compatibility
  ARM: EXYNOS: Add devicetree node for mipi-csis driver for exynos5
  ARM: EXYNOS: Add devicetree node for FIMC-LITE driver for exynos5
  media: exynos5-is: Adding media device driver for exynos5
  ARM: dts: add camera specific pinctrl nodes for Exynos5250 SoC
  ARM: dts: Adding pinctrl support to Exynos5250 i2c nodes
  ARM: dts: Adding media device nodes to Exynos5 SoCs
  media: m5mols: Adding dt support to m5mols driver
  ARM: dts: Add camera node to exynos5250-smdk5250.dts

 arch/arm/boot/dts/exynos5250-pinctrl.dtsi|   41 +
 arch/arm/boot/dts/exynos5250-smdk5250.dts|   65 +-
 arch/arm/boot/dts/exynos5250.dtsi|   54 +
 arch/arm/mach-exynos/clock-exynos5.c |   20 +-
 arch/arm/mach-exynos/include/mach/map.h  |7 +
 arch/arm/mach-exynos/mach-exynos5-dt.c   |   10 +
 drivers/media/i2c/m5mols/m5mols_core.c   |   54 +-
 drivers/media/platform/Kconfig   |1 +
 drivers/media/platform/Makefile  |1 +
 drivers/media/platform/exynos5-is/Kconfig|7 +
 drivers/media/platform/exynos5-is/Makefile   |4 +
 drivers/media/platform/exynos5-is/exynos5-mdev.c | 1309 ++
 drivers/media/platform/exynos5-is/exynos5-mdev.h |  107 ++
 drivers/media/platform/s5p-fimc/fimc-capture.c   |   96 +-
 drivers/media/platform/s5p-fimc/fimc-core.h  |4 +-
 drivers/media/platform/s5p-fimc/fimc-lite-reg.c  |   16 +-
 drivers/media/platform/s5p-fimc/fimc-lite-reg.h  |   41 +-
 drivers/media/platform/s5p-fimc/fimc-lite.c  |  292 -
 drivers/media/platform/s5p-fimc/fimc-lite.h  |   12 +-
 drivers/media/platform/s5p-fimc/fimc-mdevice.c   |  186 ++-
 drivers/media/platform/s5p-fimc/fimc-mdevice.h   |   41 +-
 drivers/media/platform/s5p-fimc/mipi-csis.c  |1 +
 include/media/s5p_fimc.h |   66 +-
 23 files changed, 2261 insertions(+), 174 deletions(-)
 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

-- 
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 01/12] media: s5p-fimc: modify existing mdev to use common pipeline

2013-03-06 Thread Shaik Ameer Basha
This patch modifies the current fimc_pipeline to exynos_pipeline,
which can be used across multiple media device drivers.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |   96 +++-
 drivers/media/platform/s5p-fimc/fimc-core.h|4 +-
 drivers/media/platform/s5p-fimc/fimc-lite.c|   73 --
 drivers/media/platform/s5p-fimc/fimc-lite.h|4 +-
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |  186 ++--
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   41 +++---
 include/media/s5p_fimc.h   |   66 ++---
 7 files changed, 326 insertions(+), 144 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 4cbaf46..106466e 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -27,24 +27,26 @@
 #include media/videobuf2-core.h
 #include media/videobuf2-dma-contig.h
 
-#include fimc-mdevice.h
 #include fimc-core.h
 #include fimc-reg.h
 
 static int fimc_capture_hw_init(struct fimc_dev *fimc)
 {
struct fimc_ctx *ctx = fimc-vid_cap.ctx;
-   struct fimc_pipeline *p = fimc-pipeline;
+   struct exynos_pipeline *p = fimc-pipeline;
struct fimc_sensor_info *sensor;
unsigned long flags;
+   struct v4l2_subdev *sd;
int ret = 0;
 
-   if (p-subdevs[IDX_SENSOR] == NULL || ctx == NULL)
+   sd = exynos_pipeline_get_subdev(fimc-pipeline_ops,
+   get_subdev_sensor, p);
+   if (sd == NULL || ctx == NULL)
return -ENXIO;
if (ctx-s_frame.fmt == NULL)
return -EINVAL;
 
-   sensor = v4l2_get_subdev_hostdata(p-subdevs[IDX_SENSOR]);
+   sensor = v4l2_get_subdev_hostdata(sd);
 
spin_lock_irqsave(fimc-slock, flags);
fimc_prepare_dma_offset(ctx, ctx-d_frame);
@@ -118,7 +120,7 @@ static int fimc_capture_state_cleanup(struct fimc_dev 
*fimc, bool suspend)
spin_unlock_irqrestore(fimc-slock, flags);
 
if (streaming)
-   return fimc_pipeline_call(fimc, set_stream,
+   return exynos_pipeline_call(fimc, set_stream,
  fimc-pipeline, 0);
else
return 0;
@@ -177,13 +179,16 @@ static int fimc_capture_config_update(struct fimc_ctx 
*ctx)
 
 void fimc_capture_irq_handler(struct fimc_dev *fimc, int deq_buf)
 {
-   struct v4l2_subdev *csis = fimc-pipeline.subdevs[IDX_CSIS];
+   struct v4l2_subdev *csis;
struct fimc_vid_cap *cap = fimc-vid_cap;
struct fimc_frame *f = cap-ctx-d_frame;
struct fimc_vid_buffer *v_buf;
struct timeval *tv;
struct timespec ts;
 
+   csis = exynos_pipeline_get_subdev(fimc-pipeline_ops,
+   get_subdev_csis, fimc-pipeline);
+
if (test_and_clear_bit(ST_CAPT_SHUT, fimc-state)) {
wake_up(fimc-irq_queue);
goto done;
@@ -286,7 +291,7 @@ static int start_streaming(struct vb2_queue *q, unsigned 
int count)
fimc_activate_capture(ctx);
 
if (!test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
-   fimc_pipeline_call(fimc, set_stream,
+   exynos_pipeline_call(fimc, set_stream,
   fimc-pipeline, 1);
}
 
@@ -311,7 +316,7 @@ int fimc_capture_suspend(struct fimc_dev *fimc)
int ret = fimc_stop_capture(fimc, suspend);
if (ret)
return ret;
-   return fimc_pipeline_call(fimc, close, fimc-pipeline);
+   return exynos_pipeline_call(fimc, close, fimc-pipeline);
 }
 
 static void buffer_queue(struct vb2_buffer *vb);
@@ -327,7 +332,7 @@ int fimc_capture_resume(struct fimc_dev *fimc)
 
INIT_LIST_HEAD(fimc-vid_cap.active_buf_q);
vid_cap-buf_index = 0;
-   fimc_pipeline_call(fimc, open, fimc-pipeline,
+   exynos_pipeline_call(fimc, open, fimc-pipeline,
   vid_cap-vfd.entity, false);
fimc_capture_hw_init(fimc);
 
@@ -447,7 +452,7 @@ static void buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(fimc-slock, flags);
 
if (!test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
-   fimc_pipeline_call(fimc, set_stream,
+   exynos_pipeline_call(fimc, set_stream,
   fimc-pipeline, 1);
return;
}
@@ -486,9 +491,12 @@ static struct vb2_ops fimc_capture_qops = {
 int fimc_capture_ctrls_create(struct fimc_dev *fimc)
 {
struct fimc_vid_cap *vid_cap = fimc-vid_cap;
-   struct v4l2_subdev *sensor = fimc-pipeline.subdevs[IDX_SENSOR];
+   struct v4l2_subdev *sensor;
int ret;
 
+   sensor = exynos_pipeline_get_subdev(fimc-pipeline_ops

[RFC 02/12] fimc-lite: Adding Exynos5 compatibility to fimc-lite driver

2013-03-06 Thread Shaik Ameer Basha
This patch adds the Exynos5 soc compatibility to the fimc-lite driver.
It also adds a version checking to deal with the changes between
different fimc-lite hardware versions.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-lite.c |   23 +++
 drivers/media/platform/s5p-fimc/fimc-lite.h |7 ++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 122cf95..eb64f87 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -1653,6 +1653,16 @@ static struct flite_variant fimc_lite0_variant_exynos4 = 
{
.out_width_align= 8,
.win_hor_offs_align = 2,
.out_hor_offs_align = 8,
+   .version= FLITE_VER_EXYNOS4,
+};
+
+static struct flite_variant fimc_lite0_variant_exynos5 = {
+   .max_width  = 8192,
+   .max_height = 8192,
+   .out_width_align= 8,
+   .win_hor_offs_align = 2,
+   .out_hor_offs_align = 8,
+   .version= FLITE_VER_EXYNOS5,
 };
 
 /* EXYNOS4212, EXYNOS4412 */
@@ -1663,6 +1673,15 @@ static struct flite_drvdata fimc_lite_drvdata_exynos4 = {
},
 };
 
+/* EXYNOS5250 */
+static struct flite_drvdata fimc_lite_drvdata_exynos5 = {
+   .variant = {
+   [0] = fimc_lite0_variant_exynos5,
+   [1] = fimc_lite0_variant_exynos5,
+   [2] = fimc_lite0_variant_exynos5,
+   },
+};
+
 static struct platform_device_id fimc_lite_driver_ids[] = {
{
.name   = exynos-fimc-lite,
@@ -1677,6 +1696,10 @@ static const struct of_device_id flite_of_match[] = {
.compatible = samsung,exynos4212-fimc-lite,
.data = fimc_lite_drvdata_exynos4,
},
+   {
+   .compatible = samsung,exynos5250-fimc-lite,
+   .data = fimc_lite_drvdata_exynos5,
+   },
{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, flite_of_match);
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.h 
b/drivers/media/platform/s5p-fimc/fimc-lite.h
index 66d6eeb..ef43fe0 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.h
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.h
@@ -28,7 +28,7 @@
 
 #define FIMC_LITE_DRV_NAME exynos-fimc-lite
 #define FLITE_CLK_NAME flite
-#define FIMC_LITE_MAX_DEVS 2
+#define FIMC_LITE_MAX_DEVS 3
 #define FLITE_REQ_BUFS_MIN 2
 
 /* Bit index definitions for struct fimc_lite::state */
@@ -49,12 +49,17 @@ enum {
 #define FLITE_SD_PAD_SOURCE_ISP2
 #define FLITE_SD_PADS_NUM  3
 
+#define FLITE_VER_EXYNOS4  0
+#define FLITE_VER_EXYNOS5  1
+
+
 struct flite_variant {
unsigned short max_width;
unsigned short max_height;
unsigned short out_width_align;
unsigned short win_hor_offs_align;
unsigned short out_hor_offs_align;
+   unsigned short version;
 };
 
 struct flite_drvdata {
-- 
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 03/12] media: fimc-lite: Adding support for Exynos5

2013-03-06 Thread Shaik Ameer Basha
This patch adds the following functionalities to existing driver

1] FIMC-LITE supports multiple DMA shadow registers from Exynos5 onwards.
This patch adds the functionality of using shadow registers by
checking the current FIMC-LITE hardware version.
2] Fixes Buffer corruption on DMA output from fimc-lite
3] Modified the driver to be used as pipeline endpoint

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-lite-reg.c |   16 +-
 drivers/media/platform/s5p-fimc/fimc-lite-reg.h |   41 -
 drivers/media/platform/s5p-fimc/fimc-lite.c |  196 +--
 drivers/media/platform/s5p-fimc/fimc-lite.h |3 +-
 4 files changed, 236 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c 
b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
index 3c7dd65..3d63526 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
@@ -68,7 +68,8 @@ void flite_hw_set_interrupt_mask(struct fimc_lite *dev)
if (atomic_read(dev-out_path) == FIMC_IO_DMA) {
intsrc = FLITE_REG_CIGCTRL_IRQ_OVFEN |
 FLITE_REG_CIGCTRL_IRQ_LASTEN |
-FLITE_REG_CIGCTRL_IRQ_STARTEN;
+FLITE_REG_CIGCTRL_IRQ_STARTEN |
+FLITE_REG_CIGCTRL_IRQ_ENDEN;
} else {
/* An output to the FIMC-IS */
intsrc = FLITE_REG_CIGCTRL_IRQ_OVFEN |
@@ -215,6 +216,18 @@ void flite_hw_set_camera_bus(struct fimc_lite *dev,
flite_hw_set_camera_port(dev, si-mux_id);
 }
 
+static void flite_hw_set_pack12(struct fimc_lite *dev, int on)
+{
+   u32 cfg = readl(dev-regs + FLITE_REG_CIODMAFMT);
+
+   cfg = ~FLITE_REG_CIODMAFMT_PACK12;
+
+   if (on)
+   cfg |= FLITE_REG_CIODMAFMT_PACK12;
+
+   writel(cfg, dev-regs + FLITE_REG_CIODMAFMT);
+}
+
 static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame 
*f)
 {
static const u32 pixcode[4][2] = {
@@ -267,6 +280,7 @@ void flite_hw_set_output_dma(struct fimc_lite *dev, struct 
flite_frame *f,
 
flite_hw_set_out_order(dev, f);
flite_hw_set_dma_window(dev, f);
+   flite_hw_set_pack12(dev, 0);
 }
 
 void flite_hw_dump_regs(struct fimc_lite *dev, const char *label)
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.h 
b/drivers/media/platform/s5p-fimc/fimc-lite-reg.h
index 0e34584..716df6c 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.h
+++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.h
@@ -120,6 +120,10 @@
 /* b0: 1 - camera B, 0 - camera A */
 #define FLITE_REG_CIGENERAL_CAM_B  (1  0)
 
+
+#define FLITE_REG_CIFCNTSEQ0x100
+#define FLITE_REG_CIOSAN(x)(0x200 + (4 * (x)))
+
 /* 
  * Function declarations
  */
@@ -143,8 +147,41 @@ void flite_hw_set_dma_window(struct fimc_lite *dev, struct 
flite_frame *f);
 void flite_hw_set_test_pattern(struct fimc_lite *dev, bool on);
 void flite_hw_dump_regs(struct fimc_lite *dev, const char *label);
 
-static inline void flite_hw_set_output_addr(struct fimc_lite *dev, u32 paddr)
+static inline void flite_hw_set_output_addr(struct fimc_lite *dev,
+   u32 paddr, u32 index)
+{
+   u32 config;
+
+   /* FLITE in EXYNOS4 has only one DMA register */
+   if (dev-variant-version == FLITE_VER_EXYNOS4)
+   index = 0;
+
+   config = readl(dev-regs + FLITE_REG_CIFCNTSEQ);
+   config |= 1  index;
+   writel(config, dev-regs + FLITE_REG_CIFCNTSEQ);
+
+   if (index == 0)
+   writel(paddr, dev-regs + FLITE_REG_CIOSA);
+   else
+   writel(paddr, dev-regs + FLITE_REG_CIOSAN(index-1));
+}
+
+static inline void flite_hw_clear_output_addr(struct fimc_lite *dev, u32 index)
 {
-   writel(paddr, dev-regs + FLITE_REG_CIOSA);
+   u32 config;
+
+   /* FLITE in EXYNOS4 has only one DMA register */
+   if (dev-variant-version == FLITE_VER_EXYNOS4)
+   index = 0;
+
+   config = readl(dev-regs + FLITE_REG_CIFCNTSEQ);
+   config = ~(1  index);
+   writel(config, dev-regs + FLITE_REG_CIFCNTSEQ);
 }
+
+static inline void flite_hw_clear_output_index(struct fimc_lite *dev)
+{
+   writel(0, dev-regs + FLITE_REG_CIFCNTSEQ);
+}
+
 #endif /* FIMC_LITE_REG_H */
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index eb64f87..1edc5ce 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -136,6 +136,8 @@ static int fimc_lite_hw_init(struct fimc_lite *fimc, bool 
isp_output)
if (fimc-fmt == NULL)
return -EINVAL;
 
+   flite_hw_clear_output_index(fimc);
+
/* Get sensor configuration data from the sensor

[RFC 04/12] s5p-csis: Adding Exynos5250 compatibility

2013-03-06 Thread Shaik Ameer Basha
Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/s5p-fimc/mipi-csis.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/s5p-fimc/mipi-csis.c 
b/drivers/media/platform/s5p-fimc/mipi-csis.c
index df4411c..debda7c 100644
--- a/drivers/media/platform/s5p-fimc/mipi-csis.c
+++ b/drivers/media/platform/s5p-fimc/mipi-csis.c
@@ -1002,6 +1002,7 @@ static const struct dev_pm_ops s5pcsis_pm_ops = {
 static const struct of_device_id s5pcsis_of_match[] __devinitconst = {
{ .compatible = samsung,exynos3110-csis },
{ .compatible = samsung,exynos4210-csis },
+   { .compatible = samsung,exynos5250-csis },
{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, s5pcsis_of_match);
-- 
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 05/12] ARM: EXYNOS: Add devicetree node for mipi-csis driver for exynos5

2013-03-06 Thread Shaik Ameer Basha
This patch adds necessary source definations needed for mipi-csis
driver and adds devicetree node for exynos5250.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 arch/arm/boot/dts/exynos5250.dtsi   |   18 ++
 arch/arm/mach-exynos/clock-exynos5.c|   16 ++--
 arch/arm/mach-exynos/include/mach/map.h |3 +++
 arch/arm/mach-exynos/mach-exynos5-dt.c  |4 
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index 3a2cd9a..4fff98b 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -47,6 +47,8 @@
i2c6 = i2c_6;
i2c7 = i2c_7;
i2c8 = i2c_8;
+   csis0 = csis_0;
+   csis1 = csis_1;
};
 
gic:interrupt-controller@10481000 {
@@ -357,4 +359,20 @@
reg = 0x1445 0x1;
interrupts = 0 94 0;
};
+
+   csis_0: csis@13C2 {
+   compatible = samsung,exynos5250-csis;
+   reg = 0x13C2 0x4000;
+   interrupts = 0 79 0;
+   bus-width = 4;
+   status = disabled;
+   };
+
+   csis_1: csis@13C3 {
+   compatible = samsung,exynos5250-csis;
+   reg = 0x13C3 0x4000;
+   interrupts = 0 80 0;
+   bus-width = 4;
+   status = disabled;
+   };
 };
diff --git a/arch/arm/mach-exynos/clock-exynos5.c 
b/arch/arm/mach-exynos/clock-exynos5.c
index e9d7b80..34a22ff 100644
--- a/arch/arm/mach-exynos/clock-exynos5.c
+++ b/arch/arm/mach-exynos/clock-exynos5.c
@@ -859,6 +859,16 @@ static struct clk exynos5_init_clocks_off[] = {
.enable = exynos5_clk_ip_gscl_ctrl,
.ctrlbit= (1  3),
}, {
+   .name   = csis,
+   .devname= s5p-mipi-csis.0,
+   .enable = exynos5_clk_ip_gscl_ctrl,
+   .ctrlbit= (1  5),
+   }, {
+   .name   = csis,
+   .devname= s5p-mipi-csis.1,
+   .enable = exynos5_clk_ip_gscl_ctrl,
+   .ctrlbit= (1  6),
+   }, {
.name   = SYSMMU_CLOCK_NAME,
.devname= SYSMMU_CLOCK_DEVNAME(mfc_l, 0),
.enable = exynos5_clk_ip_mfc_ctrl,
@@ -1263,9 +1273,10 @@ static struct clksrc_clk exynos5_clksrcs[] = {
.reg_div = { .reg = EXYNOS5_CLKDIV_FSYS0, .shift = 20, .size = 
4 },
}, {
.clk= {
-   .name   = sclk_gscl_wrap,
+   .name   = sclk_csis,
.devname= s5p-mipi-csis.0,
.enable = exynos5_clksrc_mask_gscl_ctrl,
+   .parent = exynos5_clk_mout_mpll_user.clk,
.ctrlbit= (1  24),
},
.sources = exynos5_clkset_group,
@@ -1273,9 +1284,10 @@ static struct clksrc_clk exynos5_clksrcs[] = {
.reg_div = { .reg = EXYNOS5_CLKDIV_GSCL, .shift = 24, .size = 4 
},
}, {
.clk= {
-   .name   = sclk_gscl_wrap,
+   .name   = sclk_csis,
.devname= s5p-mipi-csis.1,
.enable = exynos5_clksrc_mask_gscl_ctrl,
+   .parent = exynos5_clk_mout_mpll_user.clk,
.ctrlbit= (1  28),
},
.sources = exynos5_clkset_group,
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index 1df6abb..c834321 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -177,6 +177,9 @@
 #define EXYNOS4_PA_MIPI_CSIS0  0x1188
 #define EXYNOS4_PA_MIPI_CSIS1  0x1189
 
+#define EXYNOS5_PA_MIPI_CSIS0  0x13C2
+#define EXYNOS5_PA_MIPI_CSIS1  0x13C3
+
 #define EXYNOS4_PA_FIMD0   0x11C0
 
 #define EXYNOS4_PA_HSMMC(x)(0x1251 + ((x) * 0x1))
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c 
b/arch/arm/mach-exynos/mach-exynos5-dt.c
index e99d3d8..c420349 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -104,6 +104,10 @@ static const struct of_dev_auxdata 
exynos5250_auxdata_lookup[] __initconst = {
OF_DEV_AUXDATA(samsung,mfc-v6, 0x1100, s5p-mfc-v6, NULL),
OF_DEV_AUXDATA(samsung,exynos5250-tmu, 0x1006,
exynos-tmu, NULL),
+   OF_DEV_AUXDATA(samsung,exynos5250-csis, EXYNOS5_PA_MIPI_CSIS0,
+   s5p-mipi-csis.0, NULL),
+   OF_DEV_AUXDATA(samsung,exynos5250-csis, EXYNOS5_PA_MIPI_CSIS1

[RFC 06/12] ARM: EXYNOS: Add devicetree node for FIMC-LITE driver for exynos5

2013-03-06 Thread Shaik Ameer Basha
This patch adds necessary source definitions needed for FIMC-LITE
driver and adds devicetree node for exynos5250.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 arch/arm/boot/dts/exynos5250.dtsi   |   21 +
 arch/arm/mach-exynos/clock-exynos5.c|4 
 arch/arm/mach-exynos/include/mach/map.h |4 
 arch/arm/mach-exynos/mach-exynos5-dt.c  |6 ++
 4 files changed, 35 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index 4fff98b..4754865 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -49,6 +49,9 @@
i2c8 = i2c_8;
csis0 = csis_0;
csis1 = csis_1;
+   fimc-lite0 = fimc_lite_0;
+   fimc-lite1 = fimc_lite_1;
+   fimc-lite2 = fimc_lite_2;
};
 
gic:interrupt-controller@10481000 {
@@ -375,4 +378,22 @@
bus-width = 4;
status = disabled;
};
+
+   fimc_lite_0: fimc-lite@13C0 {
+   compatible = samsung,exynos5250-fimc-lite;
+   reg = 0x13C0 0x1000;
+   interrupts = 0 125 0;
+   };
+
+   fimc_lite_1: fimc-lite@13C1 {
+   compatible = samsung,exynos5250-fimc-lite;
+   reg = 0x13C1 0x1000;
+   interrupts = 0 126 0;
+   };
+
+   fimc_lite_2: fimc-lite@13C9 {
+   compatible = samsung,exynos5250-fimc-lite;
+   reg = 0x13C9 0x1000;
+   interrupts = 0 110 0;
+   };
 };
diff --git a/arch/arm/mach-exynos/clock-exynos5.c 
b/arch/arm/mach-exynos/clock-exynos5.c
index 34a22ff..4536515 100644
--- a/arch/arm/mach-exynos/clock-exynos5.c
+++ b/arch/arm/mach-exynos/clock-exynos5.c
@@ -859,6 +859,10 @@ static struct clk exynos5_init_clocks_off[] = {
.enable = exynos5_clk_ip_gscl_ctrl,
.ctrlbit= (1  3),
}, {
+   .name   = flite,
+   .enable = exynos5_clk_ip_gscl_ctrl,
+   .ctrlbit= (1  4),
+   }, {
.name   = csis,
.devname= s5p-mipi-csis.0,
.enable = exynos5_clk_ip_gscl_ctrl,
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index c834321..5bfc744 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -125,6 +125,10 @@
 #define EXYNOS4_PA_SYSMMU_MFC_L0x1362
 #define EXYNOS4_PA_SYSMMU_MFC_R0x1363
 
+#define EXYNOS5_PA_FIMC_LITE0   0x13C0
+#define EXYNOS5_PA_FIMC_LITE1   0x13C1
+#define EXYNOS5_PA_FIMC_LITE2   0x13C9
+
 #define EXYNOS5_PA_GSC00x13E0
 #define EXYNOS5_PA_GSC10x13E1
 #define EXYNOS5_PA_GSC20x13E2
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c 
b/arch/arm/mach-exynos/mach-exynos5-dt.c
index c420349..f6c3223 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -108,6 +108,12 @@ static const struct of_dev_auxdata 
exynos5250_auxdata_lookup[] __initconst = {
s5p-mipi-csis.0, NULL),
OF_DEV_AUXDATA(samsung,exynos5250-csis, EXYNOS5_PA_MIPI_CSIS1,
s5p-mipi-csis.1, NULL),
+   OF_DEV_AUXDATA(samsung,exynos5250-fimc-lite, EXYNOS5_PA_FIMC_LITE0,
+   exynos5-fimc-lite.0, NULL),
+   OF_DEV_AUXDATA(samsung,exynos5250-fimc-lite, EXYNOS5_PA_FIMC_LITE1,
+   exynos5-fimc-lite.1, NULL),
+   OF_DEV_AUXDATA(samsung,exynos5250-fimc-lite, EXYNOS5_PA_FIMC_LITE2,
+   exynos5-fimc-lite.2, NULL),
{},
 };
 
-- 
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 07/12] media: exynos5-is: Adding media device driver for exynos5

2013-03-06 Thread Shaik Ameer Basha
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

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

* Gscaler: general scaler
  Support memory to memory interface
  Support output interface from memory to display device(LCD, TV)
  Support capture interface from device(FIMC-LITE, FIMD) to memory

-- media 0
  Camera Capture path consists of MIPI-CSIS, FIMC-LITE and G-Scaler
  ++ +---+ +-+
  | Sensor | -- | FIMC-LITE | -- | G-Scaler-capture |
  ++ +---+ +-+

  ++ +---+ +---+ +-+
  | Sensor | -- | MIPI-CSIS | -- | FIMC-LITE | -- | G-Scaler-capture |
  ++ +---+ +---+ +-+

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/Kconfig   |1 +
 drivers/media/platform/Makefile  |1 +
 drivers/media/platform/exynos5-is/Kconfig|7 +
 drivers/media/platform/exynos5-is/Makefile   |4 +
 drivers/media/platform/exynos5-is/exynos5-mdev.c | 1309 ++
 drivers/media/platform/exynos5-is/exynos5-mdev.h |  107 ++
 6 files changed, 1429 insertions(+)
 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

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 2433e2b..f74bd92 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/s5p-fimc/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 42089ba..43da7ab 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..7aacf3b
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Kconfig
@@ -0,0 +1,7 @@
+config VIDEO_SAMSUNG_EXYNOS5_MDEV
+   bool Samsung Exynos5 Media Device driver
+   depends on VIDEO_DEV  VIDEO_V4L2  ARCH_EXYNOS5
+   help
+ This is a v4l2 based media controller driver for
+ Exynos5 SoC.
+
diff --git a/drivers/media/platform/exynos5-is/Makefile 
b/drivers/media/platform/exynos5-is/Makefile
new file mode 100644
index 000..472d8e1
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/Makefile
@@ -0,0 +1,4 @@
+ccflags-y += -Idrivers/media/platform/s5p-fimc
+exynos-mdevice-objs := exynos5-mdev.o
+
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS5_MDEV) += exynos-mdevice.o
diff --git a/drivers/media/platform/exynos5-is/exynos5-mdev.c 
b/drivers/media/platform/exynos5-is/exynos5-mdev.c
new file mode 100644
index 000..1158696
--- /dev/null
+++ b/drivers/media/platform/exynos5-is/exynos5-mdev.c
@@ -0,0 +1,1309 @@
+/*
+ * S5P/EXYNOS4 SoC series camera host interface media device driver
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki s.nawro...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 2 of the License,
+ * or (at your option) any later version.
+ */
+
+#include linux/bug.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/i2c.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_device.h
+#include linux/of_i2c.h
+#include linux/pinctrl/consumer.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+#include linux/types.h
+#include linux/slab.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-of.h
+#include media/media-device.h
+
+#include exynos5-mdev.h
+
+#define dbg(fmt, args...) \
+   pr_debug(%s:%d:  fmt \n, __func__, __LINE__, ##args)
+
+static struct fimc_md *g_exynos_mdev;
+
+static int fimc_md_set_camclk(struct

[RFC 08/12] ARM: dts: add camera specific pinctrl nodes for Exynos5250 SoC

2013-03-06 Thread Shaik Ameer Basha
Add device nodes for pinctrl group-1 for Exynos5250 SoC.
This only adds cam1 specific pinctrl nodes to the file.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 arch/arm/boot/dts/exynos5250-pinctrl.dtsi |   41 +
 arch/arm/boot/dts/exynos5250.dtsi |7 +
 2 files changed, 48 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5250-pinctrl.dtsi 
b/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
index 24180fc..3caaa21 100644
--- a/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
+++ b/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
@@ -555,6 +555,47 @@
};
};
 
+   pinctrl@1340 {
+   gph0: gph0 {
+   gpio-controller;
+   #gpio-cells = 2;
+
+   interrupt-controller;
+   #interrupt-cells = 2;
+   };
+
+   gph1: gph1 {
+   gpio-controller;
+   #gpio-cells = 2;
+
+   interrupt-controller;
+   #interrupt-cells = 2;
+   };
+
+   cam_port_a_io: cam-port-a-io {
+   samsung,pins = gph0-0, gph0-1, gph0-2, gph0-3,
+   gph1-0, gph1-1, gph1-2, gph1-3,
+   gph1-4, gph1-5, gph1-6, gph1-7;
+   samsung,pin-function = 2;
+   samsung,pin-pud = 0;
+   samsung,pin-drv = 3;
+   };
+
+   cam_port_a_clk_active: cam-port-a-clk-active {
+   samsung,pins = gph0-3;
+   samsung,pin-function = 2;
+   samsung,pin-pud = 0;
+   samsung,pin-drv = 3;
+   };
+
+   cam_port_a_clk_idle: cam-port-a-clk-idle {
+   samsung,pins = gph0-3;
+   samsung,pin-function = 0;
+   samsung,pin-pud = 0;
+   samsung,pin-drv = 0;
+   };
+   };
+
pinctrl_3: pinctrl@0368 {
gpz: gpz {
gpio-controller;
diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index 4754865..e09cda0 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -37,6 +37,7 @@
mshc2 = dwmmc_2;
mshc3 = dwmmc_3;
pinctrl0 = pinctrl_0;
+   pinctrl1 = pinctrl_1;
pinctrl3 = pinctrl_3;
i2c0 = i2c_0;
i2c1 = i2c_1;
@@ -95,6 +96,12 @@
};
};
 
+   pinctrl_1: pinctrl@1340 {
+   compatible = samsung,pinctrl-exynos5250;
+   reg = 0x1340 0x1000;
+   interrupts = 0 47 0;
+   };
+
pinctrl_3: pinctrl@0368 {
compatible = samsung,pinctrl-exynos5250;
reg = 0x0368000 0x1000;
-- 
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 09/12] ARM: dts: Adding pinctrl support to Exynos5250 i2c nodes

2013-03-06 Thread Shaik Ameer Basha
This patch adds the default pinctrl functionality to the
i2c device nodes on exynos5250-smdk5250.dts file

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 arch/arm/boot/dts/exynos5250-smdk5250.dts |   22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts 
b/arch/arm/boot/dts/exynos5250-smdk5250.dts
index 942d576..4b10744 100644
--- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
+++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
@@ -30,8 +30,8 @@
i2c@12C6 {
samsung,i2c-sda-delay = 100;
samsung,i2c-max-bus-freq = 2;
-   gpios = gpb3 0 2 3 0,
-   gpb3 1 2 3 0;
+   pinctrl-0 = i2c0_bus;
+   pinctrl-names = default;
 
eeprom@50 {
compatible = samsung,s524ad0xd1;
@@ -42,8 +42,8 @@
i2c@12C7 {
samsung,i2c-sda-delay = 100;
samsung,i2c-max-bus-freq = 2;
-   gpios = gpb3 2 2 3 0,
-   gpb3 3 2 3 0;
+   pinctrl-0 = i2c1_bus;
+   pinctrl-names = default;
 
eeprom@51 {
compatible = samsung,s524ad0xd1;
@@ -69,8 +69,8 @@
i2c@12C8 {
samsung,i2c-sda-delay = 100;
samsung,i2c-max-bus-freq = 66000;
-   gpios = gpa0 6 3 3 0,
-   gpa0 7 3 3 0;
+   pinctrl-0 = i2c2_bus;
+   pinctrl-names = default;
 
hdmiddc@50 {
compatible = samsung,exynos5-hdmiddc;
@@ -80,22 +80,32 @@
 
i2c@12C9 {
status = disabled;
+   pinctrl-0 = i2c3_bus;
+   pinctrl-names = default;
};
 
i2c@12CA {
status = disabled;
+   pinctrl-0 = i2c4_bus;
+   pinctrl-names = default;
};
 
i2c@12CB {
status = disabled;
+   pinctrl-0 = i2c5_bus;
+   pinctrl-names = default;
};
 
i2c@12CC {
status = disabled;
+   pinctrl-0 = i2c6_bus;
+   pinctrl-names = default;
};
 
i2c@12CD {
status = disabled;
+   pinctrl-0 = i2c7_bus;
+   pinctrl-names = default;
};
 
i2c@12CE {
-- 
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 10/12] ARM: dts: Adding media device nodes to Exynos5 SoCs

2013-03-06 Thread Shaik Ameer Basha
This patch adds the media device driver specific dt bindings
to the Exynos5 specific SoCs.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 arch/arm/boot/dts/exynos5250.dtsi |   64 +
 1 file changed, 36 insertions(+), 28 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index e09cda0..564c05f 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -370,37 +370,45 @@
interrupts = 0 94 0;
};
 
-   csis_0: csis@13C2 {
-   compatible = samsung,exynos5250-csis;
-   reg = 0x13C2 0x4000;
-   interrupts = 0 79 0;
-   bus-width = 4;
-   status = disabled;
-   };
+   camera {
+   compatible = samsung,exynos5-fimc, simple-bus;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
 
-   csis_1: csis@13C3 {
-   compatible = samsung,exynos5250-csis;
-   reg = 0x13C3 0x4000;
-   interrupts = 0 80 0;
-   bus-width = 4;
-   status = disabled;
-   };
+   fimc_lite_0: fimc-lite@13C0 {
+   compatible = samsung,exynos5250-fimc-lite;
+   reg = 0x13C0 0x1000;
+   interrupts = 0 125 0;
+   };
 
-   fimc_lite_0: fimc-lite@13C0 {
-   compatible = samsung,exynos5250-fimc-lite;
-   reg = 0x13C0 0x1000;
-   interrupts = 0 125 0;
-   };
+   fimc_lite_1: fimc-lite@13C1 {
+   compatible = samsung,exynos5250-fimc-lite;
+   reg = 0x13C1 0x1000;
+   interrupts = 0 126 0;
+   };
 
-   fimc_lite_1: fimc-lite@13C1 {
-   compatible = samsung,exynos5250-fimc-lite;
-   reg = 0x13C1 0x1000;
-   interrupts = 0 126 0;
-   };
+   fimc_lite_2: fimc-lite@13C9 {
+   compatible = samsung,exynos5250-fimc-lite;
+   reg = 0x13C9 0x1000;
+   interrupts = 0 110 0;
+   };
 
-   fimc_lite_2: fimc-lite@13C9 {
-   compatible = samsung,exynos5250-fimc-lite;
-   reg = 0x13C9 0x1000;
-   interrupts = 0 110 0;
+   csis_0: csis@13C2 {
+   compatible = samsung,exynos5250-csis;
+   reg = 0x13C2 0x4000;
+   interrupts = 0 79 0;
+   bus-width = 4;
+   clock-names = csis, sclk_csis, mux, parent;
+   status = disabled;
+   };
+
+   csis_1: csis@13C3 {
+   compatible = samsung,exynos5250-csis;
+   reg = 0x13C3 0x4000;
+   interrupts = 0 80 0;
+   bus-width = 2;
+   status = disabled;
+   };
};
 };
-- 
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 11/12] media: m5mols: Adding dt support to m5mols driver

2013-03-06 Thread Shaik Ameer Basha
This patch adds the dt support to m5mols driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/i2c/m5mols/m5mols_core.c |   54 +++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/m5mols/m5mols_core.c 
b/drivers/media/i2c/m5mols/m5mols_core.c
index d4e7567..21c66ef 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -19,6 +19,8 @@
 #include linux/interrupt.h
 #include linux/delay.h
 #include linux/gpio.h
+#include linux/of_gpio.h
+#include linux/pinctrl/consumer.h
 #include linux/regulator/consumer.h
 #include linux/videodev2.h
 #include linux/module.h
@@ -926,13 +928,38 @@ static irqreturn_t m5mols_irq_handler(int irq, void *data)
return IRQ_HANDLED;
 }
 
+static const struct of_device_id m5mols_match[];
+
 static int m5mols_probe(struct i2c_client *client,
const struct i2c_device_id *id)
 {
-   const struct m5mols_platform_data *pdata = client-dev.platform_data;
+   struct m5mols_platform_data *pdata;
struct m5mols_info *info;
+   const struct of_device_id *of_id;
struct v4l2_subdev *sd;
int ret;
+   struct pinctrl *pctrl;
+   int eint_gpio = 0;
+
+   if (client-dev.of_node) {
+   of_id = of_match_node(m5mols_match, client-dev.of_node);
+   if (of_id)
+   pdata = (struct m5mols_platform_data *)of_id-data;
+   client-dev.platform_data = pdata;
+   } else {
+   pdata = client-dev.platform_data;
+   }
+
+   if (!pdata)
+   return -EINVAL;
+
+   pctrl = devm_pinctrl_get_select_default(client-dev);
+   if (client-dev.of_node) {
+   eint_gpio = of_get_named_gpio(client-dev.of_node, gpios, 0);
+   client-irq = gpio_to_irq(eint_gpio);
+   pdata-gpio_reset = of_get_named_gpio(client-dev.of_node,
+   gpios, 1);
+   }
 
if (pdata == NULL) {
dev_err(client-dev, No platform data\n);
@@ -1040,9 +1067,34 @@ static const struct i2c_device_id m5mols_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, m5mols_id);
 
+static int m5mols_set_power(struct device *dev, int on)
+{
+   struct m5mols_platform_data *pdata =
+   (struct m5mols_platform_data *)dev-platform_data;
+   gpio_set_value(pdata-gpio_reset, !on);
+   gpio_set_value(pdata-gpio_reset, !!on);
+   return 0;
+}
+
+static struct m5mols_platform_data m5mols_drvdata = {
+   .gpio_reset = 0,
+   .reset_polarity = 0,
+   .set_power  = m5mols_set_power,
+};
+
+static const struct of_device_id m5mols_match[] = {
+   {
+   .compatible = fujitsu,m-5mols,
+   .data = m5mols_drvdata,
+   },
+   {},
+};
+MODULE_DEVICE_TABLE(of, m5mols_match);
+
 static struct i2c_driver m5mols_i2c_driver = {
.driver = {
.name   = MODULE_NAME,
+   .of_match_table = m5mols_match,
},
.probe  = m5mols_probe,
.remove = m5mols_remove,
-- 
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 12/12] ARM: dts: Add camera node to exynos5250-smdk5250.dts

2013-03-06 Thread Shaik Ameer Basha
Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 arch/arm/boot/dts/exynos5250-smdk5250.dts |   43 -
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts 
b/arch/arm/boot/dts/exynos5250-smdk5250.dts
index 4b10744..7fbc236 100644
--- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
+++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
@@ -85,9 +85,26 @@
};
 
i2c@12CA {
-   status = disabled;
+   samsung,i2c-sda-delay = 100;
+   samsung,i2c-max-bus-freq = 10;
pinctrl-0 = i2c4_bus;
pinctrl-names = default;
+
+   m5mols@1f {
+   compatible = fujitsu,m-5mols;
+   reg = 0x1F;
+   gpios = gpx3 3 0xf, gpx1 2 1;
+   clock-frequency = 2400;
+   pinctrl-0 = cam_port_a_clk_active;
+   pinctrl-names = default;
+
+   port {
+   m5mols_ep: endpoint {
+   remote-endpoint = csis0_ep;
+   };
+   };
+
+   };
};
 
i2c@12CB {
@@ -214,4 +231,28 @@
samsung,mfc-r = 0x4300 0x80;
samsung,mfc-l = 0x5100 0x80;
};
+
+   camera {
+   compatible = samsung,exynos5-fimc, simple-bus;
+   status = okay;
+
+   csis_0: csis@13C2 {
+   status = okay;
+   clock-frequency = 16600;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   /* Camera C (3) MIPI CSI-2 (CSIS0) */
+   port@3 {
+   reg = 3;
+   csis0_ep: endpoint {
+   remote-endpoint = m5mols_ep;
+   data-lanes = 1 2 3 4;
+   samsung,csis-hs-settle = 12;
+   samsung,csis-wclk;
+   };
+   };
+   };
+
+   };
 };
-- 
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] s5p-mfc: Fix encoder control 15 issue

2013-03-06 Thread Shaik Ameer Basha
Hi Sylwester,

On Thu, Mar 7, 2013 at 3:40 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Arun,


 On 03/06/2013 02:15 PM, Arun Kumar K wrote:

 mfc-encoder is not working in the latest kernel giving the
 erorr Adding control (15) failed. Adding the missing step
 parameter in this control to fix the issue.


 Do you mean this problem was not observed in 3.8 kernel and something
 has changed in the v4l2 core so it fails in 3.9-rc now ? Or is it
 related to some change in the driver itself ?

v4l2_ctrl_new() uses check_range() for control range checking (which
is added newly).
This function expects 'step' value for V4L2_CTRL_TYPE_BOOLEAN type control.
If 'step' value doesn't match to '1', it returns -ERANGE error.

Its a change in v4l2 core.

Regards,
Shaik Ameer Basha



 Signed-off-by: Arun Kumar Karun...@samsung.com
 ---
   drivers/media/platform/s5p-mfc/s5p_mfc_enc.c |1 +
   1 file changed, 1 insertion(+)

 diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
 b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
 index 2356fd5..4f6b553 100644
 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
 +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
 @@ -232,6 +232,7 @@ static struct mfc_control controls[] = {
 .minimum = 0,
 .maximum = 1,
 .default_value = 0,
 +   .step = 1,
 .menu_skip_mask = 0,
 },
 {


 Regards,
 Sylwester

 --
 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
--
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] fimc-lite: Fix the variable type to avoid possible crash

2013-02-21 Thread Shaik Ameer Basha
Changing the variable type to 'int' from 'unsigned int'. Driver
logic expects the variable type to be 'int'.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-lite-reg.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c 
b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
index f0af075..3c7dd65 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
@@ -128,7 +128,7 @@ static const u32 src_pixfmt_map[8][3] = {
 void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
 {
enum v4l2_mbus_pixelcode pixelcode = dev-fmt-mbus_code;
-   unsigned int i = ARRAY_SIZE(src_pixfmt_map);
+   int i = ARRAY_SIZE(src_pixfmt_map);
u32 cfg;
 
while (i-- = 0) {
@@ -224,7 +224,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, 
struct flite_frame *f)
{ V4L2_MBUS_FMT_VYUY8_2X8, FLITE_REG_CIODMAFMT_CRYCBY },
};
u32 cfg = readl(dev-regs + FLITE_REG_CIODMAFMT);
-   unsigned int i = ARRAY_SIZE(pixcode);
+   int i = ARRAY_SIZE(pixcode);
 
while (i-- = 0)
if (pixcode[i][0] == dev-fmt-mbus_code)
-- 
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] [media] fimc-lite: Initialize 'step' field in fimc_lite_ctrl structure

2013-02-21 Thread Shaik Ameer Basha
v4l2_ctrl_new() uses check_range() for control range checking.
This function expects 'step' value for V4L2_CTRL_TYPE_BOOLEAN type control.
If 'step' value doesn't match to '1', it returns -ERANGE error.

This patch adds the default .step value to 1.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-lite.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index bfc4206..bbc35de 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -1408,6 +1408,7 @@ static const struct v4l2_ctrl_config fimc_lite_ctrl = {
.id = V4L2_CTRL_CLASS_USER | 0x1001,
.type   = V4L2_CTRL_TYPE_BOOLEAN,
.name   = Test Pattern 640x480,
+   .step   = 1,
 };
 
 static int fimc_lite_create_capture_subdev(struct fimc_lite *fimc)
-- 
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] [media] exynos-gsc: send valid m2m ctx to gsc_m2m_job_finish

2013-02-05 Thread Shaik Ameer Basha
gsc_m2m_job_finish() has to be called with the m2m context for the necessary
cleanup while resume. But currently gsc_m2m_job_finish() always passes m2m
context as NULL.

This patch preserves the context before making it null, for necessary cleanup.
Use gsc_m2m_opened() instead gsc_m2m_active() in gsc_resume().

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-core.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index 99b841d..4d10845 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -1054,16 +1054,18 @@ static int gsc_m2m_suspend(struct gsc_dev *gsc)
 
 static int gsc_m2m_resume(struct gsc_dev *gsc)
 {
+   struct gsc_ctx *ctx;
unsigned long flags;
 
spin_lock_irqsave(gsc-slock, flags);
/* Clear for full H/W setup in first run after resume */
+   ctx = gsc-m2m.ctx;
gsc-m2m.ctx = NULL;
spin_unlock_irqrestore(gsc-slock, flags);
 
if (test_and_clear_bit(ST_M2M_SUSPENDED, gsc-state))
-   gsc_m2m_job_finish(gsc-m2m.ctx,
-   VB2_BUF_STATE_ERROR);
+   gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
return 0;
 }
 
@@ -1206,7 +1208,7 @@ static int gsc_resume(struct device *dev)
/* Do not resume if the device was idle before system suspend */
spin_lock_irqsave(gsc-slock, flags);
if (!test_and_clear_bit(ST_SUSPEND, gsc-state) ||
-   !gsc_m2m_active(gsc)) {
+   !gsc_m2m_opened(gsc)) {
spin_unlock_irqrestore(gsc-slock, flags);
return 0;
}
-- 
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] s5p-fimc: send valid m2m ctx to fimc_m2m_job_finish

2013-02-05 Thread Shaik Ameer Basha
fimc_m2m_job_finish() has to be called with the m2m context for the necessary
cleanup while resume. But currently fimc_m2m_job_finish() always passes m2m
context as NULL.

This patch preserves the context before making it null, for necessary cleanup.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-core.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-core.c 
b/drivers/media/platform/s5p-fimc/fimc-core.c
index 29f7bb7..a5d7cea 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.c
+++ b/drivers/media/platform/s5p-fimc/fimc-core.c
@@ -850,16 +850,18 @@ static int fimc_m2m_suspend(struct fimc_dev *fimc)
 
 static int fimc_m2m_resume(struct fimc_dev *fimc)
 {
+   struct fimc_ctx *ctx;
unsigned long flags;
 
spin_lock_irqsave(fimc-slock, flags);
/* Clear for full H/W setup in first run after resume */
+   ctx = fimc-m2m.ctx;
fimc-m2m.ctx = NULL;
spin_unlock_irqrestore(fimc-slock, flags);
 
if (test_and_clear_bit(ST_M2M_SUSPENDED, fimc-state))
-   fimc_m2m_job_finish(fimc-m2m.ctx,
-   VB2_BUF_STATE_ERROR);
+   fimc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
return 0;
 }
 
-- 
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] s5p-fimc: set m2m context to null at the end of fimc_m2m_resume

2013-01-18 Thread Shaik Ameer Basha
fimc_m2m_job_finish() has to be called with the m2m context for the necessary
cleanup while resume. But currently fimc_m2m_job_finish() always passes
fimc-m2m.ctx as NULL.

This patch changes the order of the calls for proper cleanup while resume.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-core.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-core.c 
b/drivers/media/platform/s5p-fimc/fimc-core.c
index 2a1558a..5b11544 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.c
+++ b/drivers/media/platform/s5p-fimc/fimc-core.c
@@ -868,14 +868,15 @@ static int fimc_m2m_resume(struct fimc_dev *fimc)
 {
unsigned long flags;
 
+   if (test_and_clear_bit(ST_M2M_SUSPENDED, fimc-state))
+   fimc_m2m_job_finish(fimc-m2m.ctx,
+   VB2_BUF_STATE_ERROR);
+
spin_lock_irqsave(fimc-slock, flags);
/* Clear for full H/W setup in first run after resume */
fimc-m2m.ctx = NULL;
spin_unlock_irqrestore(fimc-slock, flags);
 
-   if (test_and_clear_bit(ST_M2M_SUSPENDED, fimc-state))
-   fimc_m2m_job_finish(fimc-m2m.ctx,
-   VB2_BUF_STATE_ERROR);
return 0;
 }
 
-- 
1.8.0

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


Re: [PATCH] s5p-fimc: set m2m context to null at the end of fimc_m2m_resume

2013-01-18 Thread Shaik Ameer Basha
Hi Sylwester,

On Fri, Jan 18, 2013 at 3:58 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 Hi Shaik,

 On 01/18/2013 11:01 AM, Shaik Ameer Basha wrote:
 fimc_m2m_job_finish() has to be called with the m2m context for the necessary
 cleanup while resume. But currently fimc_m2m_job_finish() always passes
 fimc-m2m.ctx as NULL.

 This patch changes the order of the calls for proper cleanup while resume.

 Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
 ---
  drivers/media/platform/s5p-fimc/fimc-core.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)

 diff --git a/drivers/media/platform/s5p-fimc/fimc-core.c 
 b/drivers/media/platform/s5p-fimc/fimc-core.c
 index 2a1558a..5b11544 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-core.c
 +++ b/drivers/media/platform/s5p-fimc/fimc-core.c
 @@ -868,14 +868,15 @@ static int fimc_m2m_resume(struct fimc_dev *fimc)
  {
   unsigned long flags;

 + if (test_and_clear_bit(ST_M2M_SUSPENDED, fimc-state))
 + fimc_m2m_job_finish(fimc-m2m.ctx,
 + VB2_BUF_STATE_ERROR);
 +
   spin_lock_irqsave(fimc-slock, flags);
   /* Clear for full H/W setup in first run after resume */
   fimc-m2m.ctx = NULL;
   spin_unlock_irqrestore(fimc-slock, flags);

 - if (test_and_clear_bit(ST_M2M_SUSPENDED, fimc-state))
 - fimc_m2m_job_finish(fimc-m2m.ctx,
 - VB2_BUF_STATE_ERROR);

 Thanks for the patch. Not sure how I managed to miss that...
 I'm not convince this is the right fix though. fimc-m2m.ctx should
 be reset so the device is properly configured in fimc_dma_run()
 callback. Since after suspend/resume cycle all previous registers'
 state is lost.

Yes, you are right. In case, more buffers are queued for the same
context, there can be issues.
I think you can apply this patch with your modified changes.

 So I think something more like below is needed. Can you check if it
 helps ? And what problem exactly are you observing ? Streaming is not
 resumed after system resume ?


I was reviewing my gsc-m2m code and found out this issue.
As you know gsc-m2m mostly follows fimc-m2m ;)

Regards,
Shaik Ameer Basha


 diff --git a/drivers/media/platform/s5p-fimc/fimc-core.c
 b/drivers/media/platform/s5p-fimc/fimc-core.c
 index bdb544f..feb8620 100644
 --- a/drivers/media/platform/s5p-fimc/fimc-core.c
 +++ b/drivers/media/platform/s5p-fimc/fimc-core.c
 @@ -869,16 +869,18 @@ static int fimc_m2m_suspend(struct fimc_dev *fimc)

  static int fimc_m2m_resume(struct fimc_dev *fimc)
  {
 +   struct fimc_ctx *ctx;
 unsigned long flags;

 spin_lock_irqsave(fimc-slock, flags);
 /* Clear for full H/W setup in first run after resume */
 +   ctx = fimc-m2m.ctx;
 fimc-m2m.ctx = NULL;
 spin_unlock_irqrestore(fimc-slock, flags);

 if (test_and_clear_bit(ST_M2M_SUSPENDED, fimc-state))
 -   fimc_m2m_job_finish(fimc-m2m.ctx,
 -   VB2_BUF_STATE_ERROR);
 +   fimc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
 +
 return 0;
  }

 Regards,
 Sylwester

 --
 Sylwester Nawrocki
 Samsung Poland RD Center
 --
 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
--
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: Support dmabuf export buffer

2012-12-07 Thread Shaik Ameer Basha
This patch adds the dmabuf export buffer feature to the
Exynos G-Scaler driver.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-m2m.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index c267c57..d0c3e42 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -367,6 +367,13 @@ static int gsc_m2m_reqbufs(struct file *file, void *fh,
return v4l2_m2m_reqbufs(file, ctx-m2m_ctx, reqbufs);
 }
 
+static int gsc_m2m_expbuf(struct file *file, void *fh,
+   struct v4l2_exportbuffer *eb)
+{
+   struct gsc_ctx *ctx = fh_to_ctx(fh);
+   return v4l2_m2m_expbuf(file, ctx-m2m_ctx, eb);
+}
+
 static int gsc_m2m_querybuf(struct file *file, void *fh,
struct v4l2_buffer *buf)
 {
@@ -548,6 +555,7 @@ static const struct v4l2_ioctl_ops gsc_m2m_ioctl_ops = {
.vidioc_s_fmt_vid_cap_mplane= gsc_m2m_s_fmt_mplane,
.vidioc_s_fmt_vid_out_mplane= gsc_m2m_s_fmt_mplane,
.vidioc_reqbufs = gsc_m2m_reqbufs,
+   .vidioc_expbuf  = gsc_m2m_expbuf,
.vidioc_querybuf= gsc_m2m_querybuf,
.vidioc_qbuf= gsc_m2m_qbuf,
.vidioc_dqbuf   = gsc_m2m_dqbuf,
@@ -565,7 +573,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 
memset(src_vq, 0, sizeof(*src_vq));
src_vq-type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
-   src_vq-io_modes = VB2_MMAP | VB2_USERPTR;
+   src_vq-io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
src_vq-drv_priv = ctx;
src_vq-ops = gsc_m2m_qops;
src_vq-mem_ops = vb2_dma_contig_memops;
@@ -577,7 +585,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 
memset(dst_vq, 0, sizeof(*dst_vq));
dst_vq-type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
-   dst_vq-io_modes = VB2_MMAP | VB2_USERPTR;
+   dst_vq-io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
dst_vq-drv_priv = ctx;
dst_vq-ops = gsc_m2m_qops;
dst_vq-mem_ops = vb2_dma_contig_memops;
-- 
1.7.0.4

--
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: modify number of output/capture buffers

2012-11-27 Thread Shaik Ameer Basha
G-Scaler src buffer count as well as destination buffer
count is increased to 32. This is required for G-Scaler to
interface with MFC, as MFC demands 32 capture buffers for
some H264 streams.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-core.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index cc7b218..4856dd7 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -935,8 +935,8 @@ static struct gsc_variant gsc_v_100_variant = {
.pix_max= gsc_v_100_max,
.pix_min= gsc_v_100_min,
.pix_align  = gsc_v_100_align,
-   .in_buf_cnt = 8,
-   .out_buf_cnt= 16,
+   .in_buf_cnt = 32,
+   .out_buf_cnt= 32,
.sc_up_max  = 8,
.sc_down_max= 16,
.poly_sc_down_max   = 4,
-- 
1.7.0.4

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


Re: [PATCH v2 0/4] [media] exynos-gsc: Some fixes

2012-11-24 Thread Shaik Ameer Basha
Hi Sylwester,

I tested this patch series. Looks good to me.

Thanks,
Shaik Ameer Basha

On Fri, Nov 23, 2012 at 4:34 PM, Sachin Kamat sachin.ka...@linaro.org wrote:
 Changes since v1:
 Removed the label 'err' from function gsc_clk_get as suggested
 by Sylwester Nawrocki s.nawro...@samsung.com in patch 3/4.
 Other patches remain the same.

 Patch series build tested and based on samsung/for_v3.8 branch of
 git://linuxtv.org/snawrocki/media.git.

 Sachin Kamat (4):
   [media] exynos-gsc: Rearrange error messages for valid prints
   [media] exynos-gsc: Remove gsc_clk_put call from gsc_clk_get
   [media] exynos-gsc: Use devm_clk_get()
   [media] exynos-gsc: Fix checkpatch warning in gsc-m2m.c

  drivers/media/platform/exynos-gsc/gsc-core.c |   21 -
  drivers/media/platform/exynos-gsc/gsc-m2m.c  |2 +-
  2 files changed, 9 insertions(+), 14 deletions(-)

 --
 1.7.4.1

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


[PATCH v2] [media] exynos-gsc: propagate timestamps from src to dst buffers

2012-11-22 Thread Shaik Ameer Basha
Make gsc-m2m propagate the timestamp field from source to destination
buffers

Signed-off-by: John Sheu s...@google.com
Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-m2m.c |   20 +---
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 047f0f0..39dff20 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -99,22 +99,28 @@ static void gsc_m2m_job_abort(void *priv)
gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
 }
 
-static int gsc_fill_addr(struct gsc_ctx *ctx)
+static int gsc_get_bufs(struct gsc_ctx *ctx)
 {
struct gsc_frame *s_frame, *d_frame;
-   struct vb2_buffer *vb = NULL;
+   struct vb2_buffer *src_vb, *dst_vb;
int ret;
 
s_frame = ctx-s_frame;
d_frame = ctx-d_frame;
 
-   vb = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
-   ret = gsc_prepare_addr(ctx, vb, s_frame, s_frame-addr);
+   src_vb = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
+   ret = gsc_prepare_addr(ctx, src_vb, s_frame, s_frame-addr);
+   if (ret)
+   return ret;
+
+   dst_vb = v4l2_m2m_next_dst_buf(ctx-m2m_ctx);
+   ret = gsc_prepare_addr(ctx, dst_vb, d_frame, d_frame-addr);
if (ret)
return ret;
 
-   vb = v4l2_m2m_next_dst_buf(ctx-m2m_ctx);
-   return gsc_prepare_addr(ctx, vb, d_frame, d_frame-addr);
+   dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+
+   return 0;
 }
 
 static void gsc_m2m_device_run(void *priv)
@@ -148,7 +154,7 @@ static void gsc_m2m_device_run(void *priv)
goto put_device;
}
 
-   ret = gsc_fill_addr(ctx);
+   ret = gsc_get_bufs(ctx);
if (ret) {
pr_err(Wrong address);
goto put_device;
-- 
1.7.0.4

--
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] Selections targets at V4L2 video mem-to-mem interface

2012-11-22 Thread Shaik Ameer Basha
Hi Sylwester,

On Wed, Nov 7, 2012 at 3:52 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi All,

 I'd like to clarify the meaning of selection targets on a mem-to-mem video
 device, in order to document it and to make sure new m2m drivers get it
 right, and also that the existing ones, using originally the crop ioctls,
 are converted to the selection ioctls properly.

 Until the selections API was introduced we used the CROP ioctls to configure
 cropping on OUTPUT buffer queue and composition onto CAPTURE buffer.
 Looking at Figure 1.2, [1] it seems obvious that there should be applied
 following mapping of the CROP to SELECTION ioctls:

 S_CROP(V4L2_BUF_TYPE_VIDEO_OUTPUT) -
 S_SELECTION(V4L2_BUF_TYPE_VIDEO_OUTPUT,
   V4L2_SEL_TGT_CROP)

 S_CROP(V4L2_BUF_TYPE_VIDEO_CAPTURE) -
 S_SELECTION(V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_SEL_TGT_COMPOSE)

 And that's how selections are currently documented at video output and
 capture interfaces:

 
 *Configuration of video output*

 For output devices targets and ioctls are used similarly to the video
 capture
 case. The composing rectangle refers to the insertion of an image into a
 video
 signal. The cropping rectangles refer to a memory buffer.


 *Configuration of video capture*
 ... The top left corner, width and height of the source rectangle, that is
 the
 area actually sampled, is given by the V4L2_SEL_TGT_CROP target.
 ...
 The composing targets refer to a memory buffer.
 

 If we apply this mapping, then current VIDIOC_S/G_CROP -
 VIDIOC_S/G_SELECTION
 ioctl fallback code wouldn't be valid, as we have there, e.g.

 static int v4l_s_crop(const struct v4l2_ioctl_ops *ops,
 struct file *file, void *fh, void *arg)
 {
 struct v4l2_crop *p = arg;
 struct v4l2_selection s = {
 .type = p-type,
 .r = p-c,
 };

 if (ops-vidioc_s_crop)
 return ops-vidioc_s_crop(file, fh, p);
 /* simulate capture crop using selection api */

 /* crop means compose for output devices */
 if (V4L2_TYPE_IS_OUTPUT(p-type))
 s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE;
 else
 s.target = V4L2_SEL_TGT_CROP_ACTIVE;

 return ops-vidioc_s_selection(file, fh, s);
 }

 i.e. it does exactly opposite to what we would expect for M2M.

You are right. Instead of handling this confusion in driver, as you
mentioned, we can use
vfl_dir field to select the target before sending it to the driver.

apart from using this vfl_dir field, I can't able to see any other
solution here.

Regards,
Shaik Ameer Basha


 One possible solution would be to get hold of struct video_device and
 do proper targets conversion after checking the vfl_dir field.

 Does anyone have suggestions on this ?


 BTW, we still have some V4L2_SEL_TGT*_ACTIVE symbols left, I'll write
 a patch to clean this up.

 [1] http://hverkuil.home.xs4all.nl/spec/media.html#idp9025504
 [2] http://hverkuil.home.xs4all.nl/spec/media.html#idp9031840

 --
 Thanks,
 Sylwester
 --
 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
--
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] exynos-gsc: Add missing video device vfl_dir flag initialization

2012-11-21 Thread Shaik Ameer Basha
Hi Sylwester,

I applied this patch and tested exynos-gsc driver basic features on exynos5250.
It's working fine for me.

Thanks,
Shaik Ameer Basha

On Tue, Nov 20, 2012 at 1:36 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Shaik,

 Could you let us know if the driver is working fine with this patch
 applied ? I have no exynos5 based board to test it. And this patch
 qualifies as an important fix that should be applied for v3.7, where
 the driver's first appeared.

 Thanks,
 Sylwester


 On 11/10/2012 11:57 PM, Sylwester Nawrocki wrote:

 vfl_dir should be set to VFL_DIR_M2M so valid ioctls for this
 mem-to-mem device can be properly determined in the v4l2 core.

 Cc: Shaik Ameer Bashashaik.am...@samsung.com
 Signed-off-by: Sylwester Nawrockisylvester.nawro...@gmail.com
 ---
 I didn't run-time test this patch.

   drivers/media/platform/exynos-gsc/gsc-m2m.c |1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

 diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c
 b/drivers/media/platform/exynos-gsc/gsc-m2m.c
 index 3c7f005..88642a8 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
 +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
 @@ -732,6 +732,7 @@ int gsc_register_m2m_device(struct gsc_dev *gsc)
 gsc-vdev.ioctl_ops =gsc_m2m_ioctl_ops;
 gsc-vdev.release   = video_device_release_empty;
 gsc-vdev.lock  =gsc-lock;

 +   gsc-vdev.vfl_dir   = VFL_DIR_M2M;
 snprintf(gsc-vdev.name, sizeof(gsc-vdev.name), %s.%d:m2m,
 GSC_MODULE_NAME, gsc-id);

 --
 1.7.4.1

 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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: Adding tiled multi-planar format to G-Scaler

2012-11-20 Thread Shaik Ameer Basha
Hi Sylwester,

On Tue, Nov 20, 2012 at 3:05 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 Hi Shaik,


 On 11/07/2012 07:37 AM, Shaik Ameer Basha wrote:

 Adding V4L2_PIX_FMT_NV12MT_16X16 to G-Scaler supported formats.
 If the output or input format is V4L2_PIX_FMT_NV12MT_16X16, configure
 G-Scaler to use GSC_IN_TILE_MODE.

 Signed-off-by: Shaik Ameer Bashashaik.am...@samsung.com
 ---
   drivers/media/platform/exynos-gsc/gsc-core.c |9 +
   drivers/media/platform/exynos-gsc/gsc-core.h |5 +
   drivers/media/platform/exynos-gsc/gsc-regs.c |6 ++
   3 files changed, 20 insertions(+), 0 deletions(-)

 diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c
 b/drivers/media/platform/exynos-gsc/gsc-core.c
 index cc7b218..00f1013 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-core.c
 +++ b/drivers/media/platform/exynos-gsc/gsc-core.c
 @@ -185,6 +185,15 @@ static const struct gsc_fmt gsc_formats[] = {
 .corder = GSC_CRCB,
 .num_planes = 3,
 .num_comp   = 3,
 +   }, {
 +   .name   = YUV 4:2:0 non-contig. 2p, Y/CbCr,
 tiled,


 I have applied this patch to my tree for v3.8, and I've shortened this
 description like this

 .name   = YUV 4:2:0 n.c. 2p, Y/CbCr tiled,

 so it fits in 32 char buffer.

Thanks and that should be fine.


 There are some too long format descriptions in the driver already.
 Please check output of VIDIOC_ENUM_FMT ioctl, for instance with
 'v4l2-ctl --list-fmt'.


 +   .pixelformat= V4L2_PIX_FMT_NV12MT_16X16,
 +   .depth  = { 8, 4 },
 +   .color  = GSC_YUV420,
 +   .yorder = GSC_LSB_Y,
 +   .corder = GSC_CBCR,
 +   .num_planes = 2,
 +   .num_comp   = 2,
 }
   };

 diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h
 b/drivers/media/platform/exynos-gsc/gsc-core.h
 index 5f157ef..cc19bba 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-core.h
 +++ b/drivers/media/platform/exynos-gsc/gsc-core.h
 @@ -427,6 +427,11 @@ static inline void gsc_ctx_state_lock_clear(u32
 state, struct gsc_ctx *ctx)
 spin_unlock_irqrestore(ctx-gsc_dev-slock, flags);
   }

 +static inline int is_tiled(const struct gsc_fmt *fmt)
 +{
 +   return fmt-pixelformat == V4L2_PIX_FMT_NV12MT_16X16;
 +}
 +
   static inline void gsc_hw_enable_control(struct gsc_dev *dev, bool on)
   {
 u32 cfg = readl(dev-regs + GSC_ENABLE);
 diff --git a/drivers/media/platform/exynos-gsc/gsc-regs.c
 b/drivers/media/platform/exynos-gsc/gsc-regs.c
 index 0146b35..6f5b5a4 100644
 --- a/drivers/media/platform/exynos-gsc/gsc-regs.c
 +++ b/drivers/media/platform/exynos-gsc/gsc-regs.c
 @@ -214,6 +214,9 @@ void gsc_hw_set_in_image_format(struct gsc_ctx *ctx)
 break;
 }

 +   if (is_tiled(frame-fmt))
 +   cfg |= GSC_IN_TILE_C_16x8 | GSC_IN_TILE_MODE;
 +
 writel(cfg, dev-regs + GSC_IN_CON);
   }

 @@ -334,6 +337,9 @@ void gsc_hw_set_out_image_format(struct gsc_ctx *ctx)
 break;
 }

 +   if (is_tiled(frame-fmt))
 +   cfg |= GSC_OUT_TILE_C_16x8 | GSC_OUT_TILE_MODE;
 +
   end_set:
 writel(cfg, dev-regs + GSC_OUT_CON);
   }


 Thanks,
 Sylwester
--
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: Adding tiled multi-planar format to G-Scaler

2012-11-06 Thread Shaik Ameer Basha
Adding V4L2_PIX_FMT_NV12MT_16X16 to G-Scaler supported formats.
If the output or input format is V4L2_PIX_FMT_NV12MT_16X16, configure
G-Scaler to use GSC_IN_TILE_MODE.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-core.c |9 +
 drivers/media/platform/exynos-gsc/gsc-core.h |5 +
 drivers/media/platform/exynos-gsc/gsc-regs.c |6 ++
 3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index cc7b218..00f1013 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -185,6 +185,15 @@ static const struct gsc_fmt gsc_formats[] = {
.corder = GSC_CRCB,
.num_planes = 3,
.num_comp   = 3,
+   }, {
+   .name   = YUV 4:2:0 non-contig. 2p, Y/CbCr, tiled,
+   .pixelformat= V4L2_PIX_FMT_NV12MT_16X16,
+   .depth  = { 8, 4 },
+   .color  = GSC_YUV420,
+   .yorder = GSC_LSB_Y,
+   .corder = GSC_CBCR,
+   .num_planes = 2,
+   .num_comp   = 2,
}
 };
 
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h 
b/drivers/media/platform/exynos-gsc/gsc-core.h
index 5f157ef..cc19bba 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/exynos-gsc/gsc-core.h
@@ -427,6 +427,11 @@ static inline void gsc_ctx_state_lock_clear(u32 state, 
struct gsc_ctx *ctx)
spin_unlock_irqrestore(ctx-gsc_dev-slock, flags);
 }
 
+static inline int is_tiled(const struct gsc_fmt *fmt)
+{
+   return fmt-pixelformat == V4L2_PIX_FMT_NV12MT_16X16;
+}
+
 static inline void gsc_hw_enable_control(struct gsc_dev *dev, bool on)
 {
u32 cfg = readl(dev-regs + GSC_ENABLE);
diff --git a/drivers/media/platform/exynos-gsc/gsc-regs.c 
b/drivers/media/platform/exynos-gsc/gsc-regs.c
index 0146b35..6f5b5a4 100644
--- a/drivers/media/platform/exynos-gsc/gsc-regs.c
+++ b/drivers/media/platform/exynos-gsc/gsc-regs.c
@@ -214,6 +214,9 @@ void gsc_hw_set_in_image_format(struct gsc_ctx *ctx)
break;
}
 
+   if (is_tiled(frame-fmt))
+   cfg |= GSC_IN_TILE_C_16x8 | GSC_IN_TILE_MODE;
+
writel(cfg, dev-regs + GSC_IN_CON);
 }
 
@@ -334,6 +337,9 @@ void gsc_hw_set_out_image_format(struct gsc_ctx *ctx)
break;
}
 
+   if (is_tiled(frame-fmt))
+   cfg |= GSC_OUT_TILE_C_16x8 | GSC_OUT_TILE_MODE;
+
 end_set:
writel(cfg, dev-regs + GSC_OUT_CON);
 }
-- 
1.7.0.4

--
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: Fix settings for input and output image RGB type

2012-11-06 Thread Shaik Ameer Basha
Macros used to set input and output RGB type aren't correct.
Updating the macros as per register manual.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-regs.h |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-regs.h 
b/drivers/media/platform/exynos-gsc/gsc-regs.h
index 533e994..4678f9a 100644
--- a/drivers/media/platform/exynos-gsc/gsc-regs.h
+++ b/drivers/media/platform/exynos-gsc/gsc-regs.h
@@ -40,10 +40,10 @@
 #define GSC_IN_ROT_YFLIP   (2  16)
 #define GSC_IN_ROT_XFLIP   (1  16)
 #define GSC_IN_RGB_TYPE_MASK   (3  14)
-#define GSC_IN_RGB_HD_WIDE (3  14)
-#define GSC_IN_RGB_HD_NARROW   (2  14)
-#define GSC_IN_RGB_SD_WIDE (1  14)
-#define GSC_IN_RGB_SD_NARROW   (0  14)
+#define GSC_IN_RGB_HD_NARROW   (3  14)
+#define GSC_IN_RGB_HD_WIDE (2  14)
+#define GSC_IN_RGB_SD_NARROW   (1  14)
+#define GSC_IN_RGB_SD_WIDE (0  14)
 #define GSC_IN_YUV422_1P_ORDER_MASK(1  13)
 #define GSC_IN_YUV422_1P_ORDER_LSB_Y   (0  13)
 #define GSC_IN_YUV422_1P_OEDER_LSB_C   (1  13)
@@ -85,10 +85,10 @@
 #define GSC_OUT_GLOBAL_ALPHA_MASK  (0xff  24)
 #define GSC_OUT_GLOBAL_ALPHA(x)((x)  24)
 #define GSC_OUT_RGB_TYPE_MASK  (3  10)
-#define GSC_OUT_RGB_HD_NARROW  (3  10)
-#define GSC_OUT_RGB_HD_WIDE(2  10)
-#define GSC_OUT_RGB_SD_NARROW  (1  10)
-#define GSC_OUT_RGB_SD_WIDE(0  10)
+#define GSC_OUT_RGB_HD_WIDE(3  10)
+#define GSC_OUT_RGB_HD_NARROW  (2  10)
+#define GSC_OUT_RGB_SD_WIDE(1  10)
+#define GSC_OUT_RGB_SD_NARROW  (0  10)
 #define GSC_OUT_YUV422_1P_ORDER_MASK   (1  9)
 #define GSC_OUT_YUV422_1P_ORDER_LSB_Y  (0  9)
 #define GSC_OUT_YUV422_1P_OEDER_LSB_C  (1  9)
-- 
1.7.0.4

--
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: propagate timestamps from src to dst buffers

2012-11-06 Thread Shaik Ameer Basha
Make gsc-m2m propagate the timestamp field from source to destination
buffers

Signed-off-by: John Sheu s...@google.com
Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-m2m.c |   19 ---
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 047f0f0..1139276 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -99,22 +99,27 @@ static void gsc_m2m_job_abort(void *priv)
gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
 }
 
-static int gsc_fill_addr(struct gsc_ctx *ctx)
+static int gsc_get_bufs(struct gsc_ctx *ctx)
 {
struct gsc_frame *s_frame, *d_frame;
-   struct vb2_buffer *vb = NULL;
+   struct vb2_buffer *src_vb, *dst_vb;
int ret;
 
s_frame = ctx-s_frame;
d_frame = ctx-d_frame;
 
-   vb = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
-   ret = gsc_prepare_addr(ctx, vb, s_frame, s_frame-addr);
+   src_vb = v4l2_m2m_next_src_buf(ctx-m2m_ctx);
+   ret = gsc_prepare_addr(ctx, src_vb, s_frame, s_frame-addr);
+
+   dst_vb = v4l2_m2m_next_dst_buf(ctx-m2m_ctx);
+   ret |= gsc_prepare_addr(ctx, dst_vb, d_frame, d_frame-addr);
if (ret)
return ret;
 
-   vb = v4l2_m2m_next_dst_buf(ctx-m2m_ctx);
-   return gsc_prepare_addr(ctx, vb, d_frame, d_frame-addr);
+   memcpy(dst_vb-v4l2_buf.timestamp, src_vb-v4l2_buf.timestamp,
+   sizeof(dst_vb-v4l2_buf.timestamp));
+
+   return 0;
 }
 
 static void gsc_m2m_device_run(void *priv)
@@ -148,7 +153,7 @@ static void gsc_m2m_device_run(void *priv)
goto put_device;
}
 
-   ret = gsc_fill_addr(ctx);
+   ret = gsc_get_bufs(ctx);
if (ret) {
pr_err(Wrong address);
goto put_device;
-- 
1.7.0.4

--
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: fix variable type in gsc_m2m_device_run()

2012-10-15 Thread Shaik Ameer Basha
In gsc_m2m_device_run(), variable ret is accepting signed integer
values. But currently it is defined as u32. This patch will modify
the type of ret variable to int.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-m2m.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 3c7f005..047f0f0 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -122,7 +122,7 @@ static void gsc_m2m_device_run(void *priv)
struct gsc_ctx *ctx = priv;
struct gsc_dev *gsc;
unsigned long flags;
-   u32 ret;
+   int ret;
bool is_set = false;
 
if (WARN(!ctx, null hardware context\n))
-- 
1.7.0.4

--
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] s5p-fimc: fix variable type in fimc_device_run()

2012-10-15 Thread Shaik Ameer Basha
In fimc_device_run(), variable ret is accepting signed integer
values. But currently it is defined as u32. This patch will modify
the type of ret variable to int.

Signed-off-by: Shaik Ameer Basha shaik.am...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-m2m.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-m2m.c 
b/drivers/media/platform/s5p-fimc/fimc-m2m.c
index 4500e44..4c4e901 100644
--- a/drivers/media/platform/s5p-fimc/fimc-m2m.c
+++ b/drivers/media/platform/s5p-fimc/fimc-m2m.c
@@ -105,7 +105,7 @@ static void fimc_device_run(void *priv)
struct fimc_frame *sf, *df;
struct fimc_dev *fimc;
unsigned long flags;
-   u32 ret;
+   int ret;
 
if (WARN(!ctx, Null context\n))
return;
-- 
1.7.0.4

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