Re: [PATCH] adp1653: included linux/module.h twice

2012-02-16 Thread Sakari Ailus
Hi Danny,

On Wed, Feb 15, 2012 at 08:20:44PM +0100, Danny Kukawka wrote:
 drivers/media/video/adp1653.c included 'linux/module.h' twice,
 remove the duplicate.
 
 Signed-off-by: Danny Kukawka danny.kuka...@bisect.de
 ---
  drivers/media/video/adp1653.c |1 -
  1 files changed, 0 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/media/video/adp1653.c b/drivers/media/video/adp1653.c
 index 12eedf4..6e7d094 100644
 --- a/drivers/media/video/adp1653.c
 +++ b/drivers/media/video/adp1653.c
 @@ -33,7 +33,6 @@
  #include linux/delay.h
  #include linux/module.h
  #include linux/i2c.h
 -#include linux/module.h
  #include linux/slab.h
  #include linux/version.h
  #include media/adp1653.h

Thanks for the patch. However, I've got a patch in my tree that already
contains this change.

Kind regards,

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi jabber/XMPP/Gmail: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] media: video: append $(srctree) to -I parameters

2012-02-16 Thread Andy Shevchenko
On Thu, 2012-02-16 at 07:22 +0100, Laurent Pinchart wrote: 
 Hi Andy,
 
 Thanks for the patch.
 
 On Wednesday 15 February 2012 17:08:01 Andy Shevchenko wrote:
  Without this we have got the warnings like following if build with make W=1
  O=/var/tmp:
 CHECK   drivers/media/video/videobuf-vmalloc.c
 CC [M]  drivers/media/video/videobuf-vmalloc.o
   +cc1: warning: drivers/media/dvb/dvb-core: No such file or directory
  [enabled by default] +cc1: warning: drivers/media/dvb/frontends: No such
  file or directory [enabled by default] +cc1: warning:
  drivers/media/dvb/dvb-core: No such file or directory [enabled by default]
  +cc1: warning: drivers/media/dvb/frontends: No such file or directory
  [enabled by default] LD  drivers/media/built-in.o
  
  Some details could be found in [1] as well.
  
  [1] http://comments.gmane.org/gmane.linux.kbuild.devel/7733
 
 There are several occurencies if the same issue throughout drivers/. Could 
 you 
 send a patch that fixes them all in one go ?
I guess it should be a patch series anyway to help with bisecting.
Okay, I will check it and make a patches if there any issue is found.

  Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
  ---
   drivers/media/video/Makefile |6 +++---
   1 files changed, 3 insertions(+), 3 deletions(-)
  
  diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
  index 3541388..3bf0aa8 100644
  --- a/drivers/media/video/Makefile
  +++ b/drivers/media/video/Makefile
  @@ -199,6 +199,6 @@ obj-y   += davinci/
  
   obj-$(CONFIG_ARCH_OMAP)+= omap/
  
  -ccflags-y += -Idrivers/media/dvb/dvb-core
  -ccflags-y += -Idrivers/media/dvb/frontends
  -ccflags-y += -Idrivers/media/common/tuners
  +ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
  +ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
  +ccflags-y += -I$(srctree)/drivers/media/common/tuners
 
 The above link mentions $(src). Is that different than $(srctree) ?
If I remember correctly $srctree points always to the root of the linux
kernel sources, but $src to the path of a certain Makefile.
In this case it seems $(src) == drivers/media/video. 

Moment...

Aha, the Documentation/kbuild/makefiles.txt clearly tells us:
$(src)
$(src) is a relative path which points to the directory
where the Makefile is located. Always use $(src) when
referring to files located in the src tree.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] s5p-csis: Add explicit dependency on REGULATOR

2012-02-16 Thread Sylwester Nawrocki
The driver used the regulator API so it should depend on REGULATOR.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/Kconfig |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9adada0..0eb7f3f 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -1116,7 +1116,8 @@ config VIDEO_ATMEL_ISI
 
 config VIDEO_S5P_MIPI_CSIS
tristate Samsung S5P and EXYNOS4 MIPI CSI receiver driver
-   depends on VIDEO_V4L2  PM_RUNTIME  PLAT_S5P  VIDEO_V4L2_SUBDEV_API
+   depends on VIDEO_V4L2  PM_RUNTIME  PLAT_S5P  \
+  VIDEO_V4L2_SUBDEV_API  REGULATOR
---help---
  This is a v4l2 driver for Samsung S5P/EXYNOS4 MIPI-CSI receiver.
 
-- 
1.7.9

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


[PATCH 0/6] s5p-fimc driver updates

2012-02-16 Thread Sylwester Nawrocki
This patch series includes a few updates for s5p-fimc/s5p-csis drivers,
like support for VIDIOC_PREPARE/CREATE_BUFS and VIDIOC_G/S_SELECTION ioctls,
addition of clk_prepare/unprepare (required for upcoming common struct clk)
and conversion to the device managed resources.

Sylwester Nawrocki (6):
  s5p-fimc: convert to clk_prepare()/clk_unprepare()
  s5p-csis: Add explicit dependency on REGULATOR
  s5p-fimc: Convert to the device managed resources
  s5p-fimc: Add support for VIDIOC_PREPARE_BUF/CREATE_BUFS ioctls
  s5p-fimc: Replace the crop ioctls with VIDIOC_S/G_SELECTION
  s5p-csis: Convert to the device managed resources

 drivers/media/video/Kconfig |3 +-
 drivers/media/video/s5p-fimc/fimc-capture.c |  121 +--
 drivers/media/video/s5p-fimc/fimc-core.c|   85 +++
 drivers/media/video/s5p-fimc/fimc-core.h|2 -
 drivers/media/video/s5p-fimc/fimc-mdevice.c |7 +-
 drivers/media/video/s5p-fimc/mipi-csis.c|  109 ++---
 6 files changed, 173 insertions(+), 154 deletions(-)

-- 
1.7.9

--
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 6/6] s5p-csis: Convert to the device managed resources

2012-02-16 Thread Sylwester Nawrocki
The devm_* functions are used in the platform device probe() for data
that is freed on driver removal. The managed device layer takes care
of undoing actions taken in the probe callback() and freeing resources
on driver detach. This eliminates the need for manually releasing
resources and simplifies error handling.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/mipi-csis.c |   81 +-
 1 files changed, 24 insertions(+), 57 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/mipi-csis.c 
b/drivers/media/video/s5p-fimc/mipi-csis.c
index 58c4075..a903138 100644
--- a/drivers/media/video/s5p-fimc/mipi-csis.c
+++ b/drivers/media/video/s5p-fimc/mipi-csis.c
@@ -1,8 +1,8 @@
 /*
  * Samsung S5P/EXYNOS4 SoC series MIPI-CSI receiver driver
  *
- * Copyright (C) 2011 Samsung Electronics Co., Ltd.
- * Contact: Sylwester Nawrocki, s.nawro...@samsung.com
+ * 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 version 2 as
@@ -100,7 +100,6 @@ enum {
  * @pads: CSIS pads array
  * @sd: v4l2_subdev associated with CSIS device instance
  * @pdev: CSIS platform device
- * @regs_res: requested I/O register memory resource
  * @regs: mmaped I/O registers memory
  * @clock: CSIS clocks
  * @irq: requested s5p-mipi-csis irq number
@@ -113,7 +112,6 @@ struct csis_state {
struct media_pad pads[CSIS_PADS_NUM];
struct v4l2_subdev sd;
struct platform_device *pdev;
-   struct resource *regs_res;
void __iomem *regs;
struct regulator_bulk_data supplies[CSIS_NUM_SUPPLIES];
struct clk *clock[NUM_CSIS_CLOCKS];
@@ -490,12 +488,11 @@ static int __devinit s5pcsis_probe(struct platform_device 
*pdev)
 {
struct s5p_platform_mipi_csis *pdata;
struct resource *mem_res;
-   struct resource *regs_res;
struct csis_state *state;
int ret = -ENOMEM;
int i;
 
-   state = kzalloc(sizeof(*state), GFP_KERNEL);
+   state = devm_kzalloc(pdev-dev, sizeof(*state), GFP_KERNEL);
if (!state)
return -ENOMEM;
 
@@ -505,52 +502,27 @@ static int __devinit s5pcsis_probe(struct platform_device 
*pdev)
pdata = pdev-dev.platform_data;
if (pdata == NULL || pdata-phy_enable == NULL) {
dev_err(pdev-dev, Platform data not fully specified\n);
-   goto e_free;
+   return -EINVAL;
}
 
if ((pdev-id == 1  pdata-lanes  CSIS1_MAX_LANES) ||
pdata-lanes  CSIS0_MAX_LANES) {
-   ret = -EINVAL;
dev_err(pdev-dev, Unsupported number of data lanes: %d\n,
pdata-lanes);
-   goto e_free;
+   return -EINVAL;
}
 
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!mem_res) {
-   dev_err(pdev-dev, Failed to get IO memory region\n);
-   goto e_free;
-   }
-
-   regs_res = request_mem_region(mem_res-start, resource_size(mem_res),
- pdev-name);
-   if (!regs_res) {
-   dev_err(pdev-dev, Failed to request IO memory region\n);
-   goto e_free;
+   state-regs = devm_request_and_ioremap(pdev-dev, mem_res);
+   if (state-regs == NULL) {
+   dev_err(pdev-dev, Failed to request and remap io memory\n);
+   return -ENXIO;
}
-   state-regs_res = regs_res;
-
-   state-regs = ioremap(mem_res-start, resource_size(mem_res));
-   if (!state-regs) {
-   dev_err(pdev-dev, Failed to remap IO region\n);
-   goto e_reqmem;
-   }
-
-   ret = s5pcsis_clk_get(state);
-   if (ret)
-   goto e_unmap;
-
-   clk_enable(state-clock[CSIS_CLK_MUX]);
-   if (pdata-clk_rate)
-   clk_set_rate(state-clock[CSIS_CLK_MUX], pdata-clk_rate);
-   else
-   dev_WARN(pdev-dev, No clock frequency specified!\n);
 
state-irq = platform_get_irq(pdev, 0);
if (state-irq  0) {
-   ret = state-irq;
dev_err(pdev-dev, Failed to get irq\n);
-   goto e_clkput;
+   return state-irq;
}
 
for (i = 0; i  CSIS_NUM_SUPPLIES; i++)
@@ -559,12 +531,22 @@ static int __devinit s5pcsis_probe(struct platform_device 
*pdev)
ret = regulator_bulk_get(pdev-dev, CSIS_NUM_SUPPLIES,
 state-supplies);
if (ret)
+   return ret;
+
+   ret = s5pcsis_clk_get(state);
+   if (ret)
goto e_clkput;
 
-   ret = request_irq(state-irq, s5pcsis_irq_handler, 0,
- dev_name(pdev-dev), state);
+   clk_enable(state-clock[CSIS_CLK_MUX]);
+  

[PATCH 1/6] s5p-fimc: convert to clk_prepare()/clk_unprepare()

2012-02-16 Thread Sylwester Nawrocki
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-core.c |   29 -
 drivers/media/video/s5p-fimc/mipi-csis.c |   28 +++-
 2 files changed, 39 insertions(+), 18 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index 81bcbb9..a6b4580 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -1602,24 +1602,35 @@ static void fimc_clk_put(struct fimc_dev *fimc)
 {
int i;
for (i = 0; i  fimc-num_clocks; i++) {
-   if (fimc-clock[i])
-   clk_put(fimc-clock[i]);
+   if (IS_ERR_OR_NULL(fimc-clock[i]))
+   continue;
+   clk_unprepare(fimc-clock[i]);
+   clk_put(fimc-clock[i]);
+   fimc-clock[i] = NULL;
}
 }
 
 static int fimc_clk_get(struct fimc_dev *fimc)
 {
-   int i;
+   int i, ret;
+
for (i = 0; i  fimc-num_clocks; i++) {
fimc-clock[i] = clk_get(fimc-pdev-dev, fimc_clocks[i]);
-   if (!IS_ERR_OR_NULL(fimc-clock[i]))
-   continue;
-   dev_err(fimc-pdev-dev, failed to get fimc clock: %s\n,
-   fimc_clocks[i]);
-   return -ENXIO;
+   if (IS_ERR(fimc-clock[i]))
+   goto err;
+   ret = clk_prepare(fimc-clock[i]);
+   if (ret  0) {
+   clk_put(fimc-clock[i]);
+   fimc-clock[i] = NULL;
+   goto err;
+   }
}
-
return 0;
+err:
+   fimc_clk_put(fimc);
+   dev_err(fimc-pdev-dev, failed to get clock: %s\n,
+   fimc_clocks[i]);
+   return -ENXIO;
 }
 
 static int fimc_m2m_suspend(struct fimc_dev *fimc)
diff --git a/drivers/media/video/s5p-fimc/mipi-csis.c 
b/drivers/media/video/s5p-fimc/mipi-csis.c
index 130335c..58c4075 100644
--- a/drivers/media/video/s5p-fimc/mipi-csis.c
+++ b/drivers/media/video/s5p-fimc/mipi-csis.c
@@ -258,26 +258,36 @@ static void s5pcsis_clk_put(struct csis_state *state)
 {
int i;
 
-   for (i = 0; i  NUM_CSIS_CLOCKS; i++)
-   if (!IS_ERR_OR_NULL(state-clock[i]))
-   clk_put(state-clock[i]);
+   for (i = 0; i  NUM_CSIS_CLOCKS; i++) {
+   if (IS_ERR_OR_NULL(state-clock[i]))
+   continue;
+   clk_unprepare(state-clock[i]);
+   clk_put(state-clock[i]);
+   state-clock[i] = NULL;
+   }
 }
 
 static int s5pcsis_clk_get(struct csis_state *state)
 {
struct device *dev = state-pdev-dev;
-   int i;
+   int i, ret;
 
for (i = 0; i  NUM_CSIS_CLOCKS; i++) {
state-clock[i] = clk_get(dev, csi_clock_name[i]);
-   if (IS_ERR(state-clock[i])) {
-   s5pcsis_clk_put(state);
-   dev_err(dev, failed to get clock: %s\n,
-   csi_clock_name[i]);
-   return -ENXIO;
+   if (IS_ERR(state-clock[i]))
+   goto err;
+   ret = clk_prepare(state-clock[i]);
+   if (ret  0) {
+   clk_put(state-clock[i]);
+   state-clock[i] = NULL;
+   goto err;
}
}
return 0;
+err:
+   s5pcsis_clk_put(state);
+   dev_err(dev, failed to get clock: %s\n, csi_clock_name[i]);
+   return -ENXIO;
 }
 
 static int s5pcsis_s_power(struct v4l2_subdev *sd, int on)
-- 
1.7.9

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


[PATCH 3/6] s5p-fimc: Convert to the device managed resources

2012-02-16 Thread Sylwester Nawrocki
The devm_* functions are used in the platform device probe() for data
that is freed on driver removal. The managed device layer takes care
of undoing actions taken in the probe callback() and freeing resources
on driver detach. This eliminates the need for manually releasing
resources and simplifies error handling.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-core.c|   56 ++-
 drivers/media/video/s5p-fimc/fimc-core.h|2 -
 drivers/media/video/s5p-fimc/fimc-mdevice.c |7 +--
 3 files changed, 14 insertions(+), 51 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index a6b4580..e184e65 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -1678,8 +1678,6 @@ static int fimc_probe(struct platform_device *pdev)
struct s5p_platform_fimc *pdata;
int ret = 0;
 
-   dev_dbg(pdev-dev, %s():\n, __func__);
-
drv_data = (struct samsung_fimc_driverdata *)
platform_get_device_id(pdev)-driver_data;
 
@@ -1689,7 +1687,7 @@ static int fimc_probe(struct platform_device *pdev)
return -EINVAL;
}
 
-   fimc = kzalloc(sizeof(struct fimc_dev), GFP_KERNEL);
+   fimc = devm_kzalloc(pdev-dev, sizeof(*fimc), GFP_KERNEL);
if (!fimc)
return -ENOMEM;
 
@@ -1700,51 +1698,35 @@ static int fimc_probe(struct platform_device *pdev)
pdata = pdev-dev.platform_data;
fimc-pdata = pdata;
 
-
init_waitqueue_head(fimc-irq_queue);
spin_lock_init(fimc-slock);
mutex_init(fimc-lock);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(pdev-dev, failed to find the registers\n);
-   ret = -ENOENT;
-   goto err_info;
-   }
-
-   fimc-regs_res = request_mem_region(res-start, resource_size(res),
-   dev_name(pdev-dev));
-   if (!fimc-regs_res) {
-   dev_err(pdev-dev, failed to obtain register region\n);
-   ret = -ENOENT;
-   goto err_info;
-   }
-
-   fimc-regs = ioremap(res-start, resource_size(res));
-   if (!fimc-regs) {
-   dev_err(pdev-dev, failed to map registers\n);
-   ret = -ENXIO;
-   goto err_req_region;
+   fimc-regs = devm_request_and_ioremap(pdev-dev, res);
+   if (fimc-regs == NULL) {
+   dev_err(pdev-dev, Failed to obtain io memory\n);
+   return -ENOENT;
}
 
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-   if (!res) {
-   dev_err(pdev-dev, failed to get IRQ resource\n);
-   ret = -ENXIO;
-   goto err_regs_unmap;
+   if (res == NULL) {
+   dev_err(pdev-dev, Failed to get IRQ resource\n);
+   return -ENXIO;
}
fimc-irq = res-start;
 
fimc-num_clocks = MAX_FIMC_CLOCKS;
ret = fimc_clk_get(fimc);
if (ret)
-   goto err_regs_unmap;
+   return ret;
clk_set_rate(fimc-clock[CLK_BUS], drv_data-lclk_frequency);
clk_enable(fimc-clock[CLK_BUS]);
 
platform_set_drvdata(pdev, fimc);
 
-   ret = request_irq(fimc-irq, fimc_irq_handler, 0, pdev-name, fimc);
+   ret = devm_request_irq(pdev-dev, fimc-irq, fimc_irq_handler,
+  0, pdev-name, fimc);
if (ret) {
dev_err(pdev-dev, failed to install irq (%d)\n, ret);
goto err_clk;
@@ -1753,7 +1735,7 @@ static int fimc_probe(struct platform_device *pdev)
pm_runtime_enable(pdev-dev);
ret = pm_runtime_get_sync(pdev-dev);
if (ret  0)
-   goto err_irq;
+   goto err_clk;
/* Initialize contiguous memory allocator */
fimc-alloc_ctx = vb2_dma_contig_init_ctx(pdev-dev);
if (IS_ERR(fimc-alloc_ctx)) {
@@ -1768,17 +1750,8 @@ static int fimc_probe(struct platform_device *pdev)
 
 err_pm:
pm_runtime_put(pdev-dev);
-err_irq:
-   free_irq(fimc-irq, fimc);
 err_clk:
fimc_clk_put(fimc);
-err_regs_unmap:
-   iounmap(fimc-regs);
-err_req_region:
-   release_resource(fimc-regs_res);
-   kfree(fimc-regs_res);
-err_info:
-   kfree(fimc);
return ret;
 }
 
@@ -1865,11 +1838,6 @@ static int __devexit fimc_remove(struct platform_device 
*pdev)
 
clk_disable(fimc-clock[CLK_BUS]);
fimc_clk_put(fimc);
-   free_irq(fimc-irq, fimc);
-   iounmap(fimc-regs);
-   release_resource(fimc-regs_res);
-   kfree(fimc-regs_res);
-   kfree(fimc);
 
dev_info(pdev-dev, driver unloaded\n);
return 0;
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h 
b/drivers/media/video/s5p-fimc/fimc-core.h
index 4e20560..a18291e 100644
--- 

[PATCH 5/6] s5p-fimc: Replace the crop ioctls with VIDIOC_S/G_SELECTION

2012-02-16 Thread Sylwester Nawrocki
Add support for cropping and composition setup on the video capture
node through VIDIOC_S/G_SELECTION ioctls. S/G_CROP, CROPCAP ioctls
are still  supported for applications since the core will translate
them to *_selection handler calls.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |  104 +++---
 1 files changed, 76 insertions(+), 28 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index b2fc0b5..b06efd2 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -1035,52 +1035,101 @@ static int fimc_cap_prepare_buf(struct file *file, 
void *priv,
return vb2_prepare_buf(fimc-vid_cap.vbq, b);
 }
 
-static int fimc_cap_cropcap(struct file *file, void *fh,
-   struct v4l2_cropcap *cr)
+static int fimc_cap_g_selection(struct file *file, void *fh,
+   struct v4l2_selection *s)
 {
struct fimc_dev *fimc = video_drvdata(file);
-   struct fimc_frame *f = fimc-vid_cap.ctx-s_frame;
+   struct fimc_ctx *ctx = fimc-vid_cap.ctx;
+   struct fimc_frame *f = ctx-s_frame;
 
-   if (cr-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+   if (s-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
return -EINVAL;
 
-   cr-bounds.left = 0;
-   cr-bounds.top  = 0;
-   cr-bounds.width= f-o_width;
-   cr-bounds.height   = f-o_height;
-   cr-defrect = cr-bounds;
+   switch (s-target) {
+   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+   f = ctx-d_frame;
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   s-r.left = 0;
+   s-r.top = 0;
+   s-r.width = f-o_width;
+   s-r.height = f-o_height;
+   return 0;
 
-   return 0;
+   case V4L2_SEL_TGT_COMPOSE_ACTIVE:
+   f = ctx-d_frame;
+   case V4L2_SEL_TGT_CROP_ACTIVE:
+   s-r.left = f-offs_h;
+   s-r.top = f-offs_v;
+   s-r.width = f-width;
+   s-r.height = f-height;
+   return 0;
+   }
+
+   return -EINVAL;
 }
 
-static int fimc_cap_g_crop(struct file *file, void *fh, struct v4l2_crop *cr)
+/* Return 1 if rectangle a is enclosed in rectangle b, or 0 otherwise. */
+int enclosed_rectangle(struct v4l2_rect *a, struct v4l2_rect *b)
 {
-   struct fimc_dev *fimc = video_drvdata(file);
-   struct fimc_frame *f = fimc-vid_cap.ctx-s_frame;
-
-   cr-c.left  = f-offs_h;
-   cr-c.top   = f-offs_v;
-   cr-c.width = f-width;
-   cr-c.height= f-height;
+   if (a-left  b-left || a-top  b-top)
+   return 0;
+   if (a-left + a-width  b-left + b-width)
+   return 0;
+   if (a-top + a-height  b-top + b-height)
+   return 0;
 
-   return 0;
+   return 1;
 }
 
-static int fimc_cap_s_crop(struct file *file, void *fh, struct v4l2_crop *cr)
+static int fimc_cap_s_selection(struct file *file, void *fh,
+   struct v4l2_selection *s)
 {
struct fimc_dev *fimc = video_drvdata(file);
struct fimc_ctx *ctx = fimc-vid_cap.ctx;
-   struct fimc_frame *ff;
+   struct v4l2_rect rect = s-r;
+   struct fimc_frame *f;
unsigned long flags;
+   unsigned int pad;
+
+   if (s-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+   return -EINVAL;
 
-   fimc_capture_try_crop(ctx, cr-c, FIMC_SD_PAD_SINK);
-   ff = ctx-s_frame;
+   switch (s-target) {
+   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+   case V4L2_SEL_TGT_COMPOSE_ACTIVE:
+   f = ctx-d_frame;
+   pad = FIMC_SD_PAD_SOURCE;
+   break;
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_ACTIVE:
+   f = ctx-s_frame;
+   pad = FIMC_SD_PAD_SINK;
+   break;
+   default:
+   return -EINVAL;
+   }
 
+   fimc_capture_try_crop(ctx, rect, pad);
+
+   if (s-flags  V4L2_SEL_FLAG_LE 
+   !enclosed_rectangle(rect, s-r))
+   return -ERANGE;
+
+   if (s-flags  V4L2_SEL_FLAG_GE 
+   !enclosed_rectangle(s-r, rect))
+   return -ERANGE;
+
+   s-r = rect;
spin_lock_irqsave(fimc-slock, flags);
-   set_frame_crop(ff, cr-c.left, cr-c.top, cr-c.width, cr-c.height);
-   set_bit(ST_CAPT_APPLY_CFG, fimc-state);
+   set_frame_crop(f, s-r.left, s-r.top, s-r.width,
+  s-r.height);
spin_unlock_irqrestore(fimc-slock, flags);
 
+   set_bit(ST_CAPT_APPLY_CFG, fimc-state);
return 0;
 }
 
@@ 

[PATCH 4/6] s5p-fimc: Add support for VIDIOC_PREPARE_BUF/CREATE_BUFS ioctls

2012-02-16 Thread Sylwester Nawrocki
Add VIDIOC_PREPARE_BUF and VIDIOC_CREATE_BUFS ioctl handlers to enable
support for multi-size buffer queue.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index a9e9653..b2fc0b5 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -1019,6 +1019,22 @@ static int fimc_cap_dqbuf(struct file *file, void *priv,
return vb2_dqbuf(fimc-vid_cap.vbq, buf, file-f_flags  O_NONBLOCK);
 }
 
+static int fimc_cap_create_bufs(struct file *file, void *priv,
+   struct v4l2_create_buffers *create)
+{
+   struct fimc_dev *fimc = video_drvdata(file);
+
+   return vb2_create_bufs(fimc-vid_cap.vbq, create);
+}
+
+static int fimc_cap_prepare_buf(struct file *file, void *priv,
+   struct v4l2_buffer *b)
+{
+   struct fimc_dev *fimc = video_drvdata(file);
+
+   return vb2_prepare_buf(fimc-vid_cap.vbq, b);
+}
+
 static int fimc_cap_cropcap(struct file *file, void *fh,
struct v4l2_cropcap *cr)
 {
@@ -1082,6 +1098,9 @@ static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops 
= {
.vidioc_qbuf= fimc_cap_qbuf,
.vidioc_dqbuf   = fimc_cap_dqbuf,
 
+   .vidioc_prepare_buf = fimc_cap_prepare_buf,
+   .vidioc_create_bufs = fimc_cap_create_bufs,
+
.vidioc_streamon= fimc_cap_streamon,
.vidioc_streamoff   = fimc_cap_streamoff,
 
-- 
1.7.9

--
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/PATCH 0/6] Interleaved image data on media bus

2012-02-16 Thread Sylwester Nawrocki
Hello,

This patch series presents a method of capturing interleaved YUYV/JPEG image
frames with the S5P/EXYNOS FIMC and MIPI-CSIS devices I went for to support 
a camera (sensor) that outputs interleaved image data at single User Defined 
MIPI-CSI2 data format. Such data is a combined two frames where each frame's 
resolution is separately configurable, i.e. both frames can have different
resolution. Additionally the sensor generates relatively small amount of 
meta data which is necessary for interpreting the interleaved format.  

I decided to use two-planar buffers for this, rather than using separate
buffer queues for the image and the meta data. Since both data are captured
at different devices and matching those data in user space might be hard to
achieve, and would add to complexity in the applications significantly.

So here is the initial patch series, I'm sending it early to possibly get
some better ideas...or just to have some background for discussion. :)

I suppose the get/set_frame_config callbacks are most open issues. I intended
these callbacks and the associated data structure as helpers for performing
additional configuration for transmission of more complex data than just
single raw image frame on media bus. I'm open to changing it, that's mainly
to indicate we really need such sort of an API.


Thoughts ?

--

Regards,
Sylwester

Sylwester Nawrocki (6):
  V4L: Add V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 media bus format
  V4L: Add V4L2_PIX_FMT_JPG_YUV_S5C fourcc definition
  V4L: Add g_embedded_data subdev callback
  V4L: Add get/set_frame_config subdev callbacks
  s5p-fimc: Add support for V4L2_PIX_FMT_JPG_YUYV_S5C fourcc
  s5p-csis: Add support for non-image data packets capture

 Documentation/DocBook/media/v4l/pixfmt.xml  |8 +
 drivers/media/video/s5p-fimc/fimc-capture.c |  123 ---
 drivers/media/video/s5p-fimc/fimc-core.c|   37 +++-
 drivers/media/video/s5p-fimc/fimc-core.h|   22 ++-
 drivers/media/video/s5p-fimc/fimc-reg.c |5 +-
 drivers/media/video/s5p-fimc/mipi-csis.c|  312 +--
 include/linux/v4l2-mediabus.h   |3 +
 include/linux/videodev2.h   |1 +
 include/media/v4l2-subdev.h |   28 +++
 9 files changed, 483 insertions(+), 56 deletions(-)

-- 
1.7.9

--
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/PATCH 2/6] V4L: Add V4L2_PIX_FMT_JPG_YUV_S5C fourcc definition

2012-02-16 Thread Sylwester Nawrocki
The V4L2_PIX_FMT_JPG_YUV_S5C is a two-plane image format generated
by S5C73M3 camera. The first plane contains interleaved JPEG and
YUYV data and the second one the meta data containing offsets
(pointers) to the YUYV data blocks. First 4 bytes of the meta
data plane indicate total size of the image data plane, subsequent
4 bytes indicate actual size of the meta data and the remainder
is a list of offsets to YUYV blocks within the first plane.
All numbers are 4 byte unsigned integers.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/DocBook/media/v4l/pixfmt.xml |8 
 include/linux/videodev2.h  |1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml 
b/Documentation/DocBook/media/v4l/pixfmt.xml
index 31eaae2..0512f2b 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -999,6 +999,14 @@ the other bits are set to 0./entry
entryOld 6-bit greyscale format. Only the least significant 6 
bits of each byte are used,
 the other bits are set to 0./entry
  /row
+ row id=V4L2-PIX-FMT-JPG-YUYV-S5C
+   entryconstantV4L2_PIX_FMT_JPG_YUYV_S5C/constant/entry
+   entry'S5CJ'/entry
+   entryTwo-planar format used by Samsung S5C73MX cameras.The first 
plane contains
+interleaved JPEG and YUYV data and the second one the meta data containing a 
list of offsets
+to the YUYV data blocks within first plane. All numbers in the second plane 
are 4-byte unsigned
+integers./entry
+ /row
/tbody
   /tgroup
 /table
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 740b35b..4fdba17 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -415,6 +415,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_KONICA420  v4l2_fourcc('K', 'O', 'N', 'I') /* YUV420 
planar in blocks of 256 pixels */
 #define V4L2_PIX_FMT_JPGL  v4l2_fourcc('J', 'P', 'G', 'L') /* JPEG-Lite */
 #define V4L2_PIX_FMT_SE401  v4l2_fourcc('S', '4', '0', '1') /* se401 
janggu compressed rgb */
+#define V4L2_PIX_FMT_JPG_YUYV_S5C v4l2_fourcc('S', '5', 'C', 'J') /* S5C73M3 
interleaved JPEG/YUYV */
 
 /*
  * F O R M A T   E N U M E R A T I O N
-- 
1.7.9

--
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/PATCH 1/6] V4L: Add V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 media bus format

2012-02-16 Thread Sylwester Nawrocki
This patch adds media bus pixel code for the interleaved JPEG/YUYV image
format used by S5C73MX Samsung cameras. The interleaved image data is
transferred on MIPI-CSI2 bus as User Defined Byte-based Data.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/linux/v4l2-mediabus.h |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
index 5ea7f75..c2f0e4e 100644
--- a/include/linux/v4l2-mediabus.h
+++ b/include/linux/v4l2-mediabus.h
@@ -92,6 +92,9 @@ enum v4l2_mbus_pixelcode {
 
/* JPEG compressed formats - next is 0x4002 */
V4L2_MBUS_FMT_JPEG_1X8 = 0x4001,
+
+   /* Interleaved JPEG and YUV formats - next is 0x4102 */
+   V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 = 0x4101,
 };
 
 /**
-- 
1.7.9

--
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/PATCH 6/6] s5p-csis: Add support for non-image data packets capture

2012-02-16 Thread Sylwester Nawrocki
MIPI-CSI has internal memory mapped buffers for the frame embedded
(non-image) data. There are two buffers, for even and odd frames which
need to be saved after an interrupt is raised. The packet data buffers
size is 4 KiB and there is no status register in the hardware where the
actual non-image data size can be read from. Hence the driver uses
pre-allocated buffers of 4 KiB in size to save the whole PKTDATA memory.
The packet data is copied to the bridge allocated buffers within
g_embedded_data callback. This will form a separate plane in the user
buffer.

When FIMC DMA engine is stopped by the driver due the to user space
not keeping up with buffer de-queuing the MIPI-CSIS will still run,
however it must discard data which is not captured by FIMC. For this
purpose FIMC driver sends VSYNC interrupt notification through
interrupt_service_routine callback which provides MIPI-CSIS with
information the header/footer of which frame is to be captured.

This patch also adds the hardware event/error counters which can be
dumped through VIDIOC_LOG_STATUS ioctl. The counters are reset in each
s_stream(1) call. Any errors are logged after streaming is turned off.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/mipi-csis.c |  305 --
 1 files changed, 286 insertions(+), 19 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/mipi-csis.c 
b/drivers/media/video/s5p-fimc/mipi-csis.c
index 04f1a0d..15a0eb5 100644
--- a/drivers/media/video/s5p-fimc/mipi-csis.c
+++ b/drivers/media/video/s5p-fimc/mipi-csis.c
@@ -9,6 +9,8 @@
  * published by the Free Software Foundation.
  */
 
+#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
+
 #include linux/clk.h
 #include linux/delay.h
 #include linux/device.h
@@ -25,13 +27,14 @@
 #include linux/slab.h
 #include linux/spinlock.h
 #include linux/videodev2.h
+#include linux/vmalloc.h
 #include media/v4l2-subdev.h
 #include plat/mipi_csis.h
 #include mipi-csis.h
 
 static int debug;
 module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, Debug level (0-1));
+MODULE_PARM_DESC(debug, Debug level (0-2));
 
 /* Register map definition */
 
@@ -60,16 +63,51 @@ MODULE_PARM_DESC(debug, Debug level (0-1));
 #define S5PCSIS_CFG_FMT_MASK   (0x3f  2)
 #define S5PCSIS_CFG_NR_LANE_MASK   3
 
-/* Interrupt mask. */
+/* Interrupt mask */
 #define S5PCSIS_INTMSK 0x10
-#define S5PCSIS_INTMSK_EN_ALL  0xf03f
+#define S5PCSIS_INTMSK_EN_ALL  0xf000103f
+#define S5PCSIS_INTMSK_EVEN_BEFORE (1  31)
+#define S5PCSIS_INTMSK_EVEN_AFTER  (1  30)
+#define S5PCSIS_INTMSK_ODD_BEFORE  (1  29)
+#define S5PCSIS_INTMSK_ODD_AFTER   (1  28)
+#define S5PCSIS_INTMSK_ERR_SOT_HS  (1  12)
+#define S5PCSIS_INTMSK_ERR_LOST_FS (1  5)
+#define S5PCSIS_INTMSK_ERR_LOST_FE (1  4)
+#define S5PCSIS_INTMSK_ERR_OVER(1  3)
+#define S5PCSIS_INTMSK_ERR_ECC (1  2)
+#define S5PCSIS_INTMSK_ERR_CRC (1  1)
+#define S5PCSIS_INTMSK_ERR_UNKNOWN (1  0)
+
+/* Interrupt source */
 #define S5PCSIS_INTSRC 0x14
+#define S5PCSIS_INTSRC_EVEN_BEFORE (1  31)
+#define S5PCSIS_INTSRC_EVEN_AFTER  (1  30)
+#define S5PCSIS_INTSRC_EVEN(0x3  30)
+#define S5PCSIS_INTSRC_ODD_BEFORE  (1  29)
+#define S5PCSIS_INTSRC_ODD_AFTER   (1  28)
+#define S5PCSIS_INTSRC_ODD (0x3  28)
+#define S5PCSIS_INTSRC_NON_IMAGE_DATA  (0xff  28)
+#define S5PCSIS_INTSRC_ERR_SOT_HS  (0xf  12)
+#define S5PCSIS_INTSRC_ERR_LOST_FS (1  5)
+#define S5PCSIS_INTSRC_ERR_LOST_FE (1  4)
+#define S5PCSIS_INTSRC_ERR_OVER(1  3)
+#define S5PCSIS_INTSRC_ERR_ECC (1  2)
+#define S5PCSIS_INTSRC_ERR_CRC (1  1)
+#define S5PCSIS_INTSRC_ERR_UNKNOWN (1  0)
+#define S5PCSIS_INTSRC_ERRORS  0xf03f
 
 /* Pixel resolution */
 #define S5PCSIS_RESOL  0x2c
 #define CSIS_MAX_PIX_WIDTH 0x
 #define CSIS_MAX_PIX_HEIGHT0x
 
+/* Non-image packet data buffers */
+#define S5PCSIS_PKTDATA_ODD0x2000
+#define S5PCSIS_PKTDATA_EVEN   0x3000
+#define S5PCSIS_PKTDATA_SIZE   SZ_4K
+/* Number of non-image data buffers */
+#define S5PCSIS_NUM_BUFFERS4
+
 enum {
CSIS_CLK_MUX,
CSIS_CLK_GATE,
@@ -93,6 +131,35 @@ enum {
ST_SUSPENDED= 4,
 };
 
+struct s5pcsis_event {
+   u32 mask;
+   const char * const name;
+   unsigned int counter;
+};
+
+static const struct s5pcsis_event s5pcsis_events[] = {
+   /* Errors */
+   { S5PCSIS_INTSRC_ERR_SOT_HS,SOT Error },
+   { S5PCSIS_INTSRC_ERR_LOST_FS,   Lost FS Error },
+   { S5PCSIS_INTSRC_ERR_LOST_FE,   Lost FE Error },
+   { S5PCSIS_INTSRC_ERR_OVER,  OVER Error },
+   { S5PCSIS_INTSRC_ERR_ECC,   ECC Error },
+   { S5PCSIS_INTSRC_ERR_CRC,   CRC Error },
+   { 

[RFC/PATCH 5/6] s5p-fimc: Add support for V4L2_PIX_FMT_JPG_YUYV_S5C fourcc

2012-02-16 Thread Sylwester Nawrocki
The V4L2_PIX_FMT_JPG_YUYV_S5C image formats consists of
2 planes, the first containing interleaved JPEG/YUYV data
and the second containing meta data describing the
interleaving method.

The image data is transferred with MIPI-CSI User Defined
Byte-Based Data 1 type and is captured to memory by FIMC
DMA engine.

The meta data is transferred using MIPI-CSI2 Embedded 8-bit
non Image Data and it is captured in the MIPI-CSI slave device
and retrieved by the bridge through a subdev callback.

Copying data from MIPI-CSIS doesn't influence performance a lot
(copying 4KiB buffer takes about 5 us) and simplifies the subdev
- bridge interactions. In opposite to having the bridge driver
allocating memory for meta data and passing it to the subdev.

The interrupt_service_routine subdev callback is used to provide
the MIPI-CSI receiver subdev with frame sequence numbers. This
is needed to discard non-image packets when FIMC DMA engine is
stopped, e.g. because user space is not de-queueing buffers.

To make sure the size of allocated buffers is correct for a
subdev configuration during VIDIOC_STREAMON ioctl the video
pipeline validation has been extended with an additional
check.

Flag FMT_FLAGS_COMPRESSED indicates the buffer size should
be retrieved from a sensor subdev.

For the discussion purposes this patch relies on new vendor
specific media bus pixel code - V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |  123 --
 drivers/media/video/s5p-fimc/fimc-core.c|   37 -
 drivers/media/video/s5p-fimc/fimc-core.h|   22 +-
 drivers/media/video/s5p-fimc/fimc-reg.c |5 +-
 drivers/media/video/s5p-fimc/mipi-csis.c|7 +-
 5 files changed, 157 insertions(+), 37 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index b06efd2..fb4eea8 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -246,29 +246,27 @@ int fimc_capture_resume(struct fimc_dev *fimc)
 
 }
 
-static unsigned int get_plane_size(struct fimc_frame *fr, unsigned int plane)
-{
-   if (!fr || plane = fr-fmt-memplanes)
-   return 0;
-   return fr-f_width * fr-f_height * fr-fmt-depth[plane] / 8;
-}
-
 static int queue_setup(struct vb2_queue *vq,  const struct v4l2_format *pfmt,
   unsigned int *num_buffers, unsigned int *num_planes,
   unsigned int sizes[], void *allocators[])
 {
struct fimc_ctx *ctx = vq-drv_priv;
-   struct fimc_fmt *fmt = ctx-d_frame.fmt;
-   int i;
+   struct fimc_frame *f = ctx-d_frame;
+   int plane;
 
-   if (!fmt)
+   if (!f-fmt)
return -EINVAL;
 
-   *num_planes = fmt-memplanes;
+   *num_planes = f-fmt-memplanes;
+
+   for (plane = 0; plane  f-fmt-memplanes; plane++) {
+   allocators[plane] = ctx-fimc_dev-alloc_ctx;
 
-   for (i = 0; i  fmt-memplanes; i++) {
-   sizes[i] = get_plane_size(ctx-d_frame, i);
-   allocators[i] = ctx-fimc_dev-alloc_ctx;
+   if (fimc_fmt_is_user_defined(f-fmt-color))
+   sizes[plane] = f-payload[plane];
+   else
+   sizes[plane] = f-f_width * f-f_height *
+   f-fmt-depth[plane] / 8;
}
 
return 0;
@@ -493,10 +491,10 @@ static struct fimc_fmt *fimc_capture_try_format(struct 
fimc_ctx *ctx,
u32 mask = FMT_FLAGS_CAM;
struct fimc_fmt *ffmt;
 
-   /* Color conversion from/to JPEG is not supported */
+   /* Conversion from/to JPEG or User Defined format is not supported */
if (code  ctx-s_frame.fmt  pad == FIMC_SD_PAD_SOURCE 
-   fimc_fmt_is_jpeg(ctx-s_frame.fmt-color))
-   *code = V4L2_MBUS_FMT_JPEG_1X8;
+   fimc_fmt_is_user_defined(ctx-s_frame.fmt-color))
+   *code = ctx-s_frame.fmt-mbus_code;
 
if (fourcc  *fourcc != V4L2_PIX_FMT_JPEG  pad != FIMC_SD_PAD_SINK)
mask |= FMT_FLAGS_M2M;
@@ -510,18 +508,19 @@ static struct fimc_fmt *fimc_capture_try_format(struct 
fimc_ctx *ctx,
*fourcc = ffmt-fourcc;
 
if (pad == FIMC_SD_PAD_SINK) {
-   max_w = fimc_fmt_is_jpeg(ffmt-color) ?
+   max_w = fimc_fmt_is_user_defined(ffmt-color) ?
pl-scaler_dis_w : pl-scaler_en_w;
/* Apply the camera input interface pixel constraints */
v4l_bound_align_image(width, max_t(u32, *width, 32), max_w, 4,
  height, max_t(u32, *height, 32),
  FIMC_CAMIF_MAX_HEIGHT,
- fimc_fmt_is_jpeg(ffmt-color) ? 3 : 1,
+ 

[RFC/PATCH 4/6] V4L: Add get/set_frame_config subdev callbacks

2012-02-16 Thread Sylwester Nawrocki
Add subdev callbacks for setting up parameters of frame on media bus that
are not exposed to user space directly. This is more a stub containing
only parameters needed to setup V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 data
transmision and the associated frame embedded data.

The @length field of struct v4l2_frame_config determines maximum number
of frame samples per frame, excluding embedded non-image data.

@header_length and @footer length determine the size in bytes of data
embedded at frame beginning and end respectively.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/media/v4l2-subdev.h |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index be74061..bd95f00 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -21,6 +21,7 @@
 #ifndef _V4L2_SUBDEV_H
 #define _V4L2_SUBDEV_H
 
+#include linux/types.h
 #include linux/v4l2-subdev.h
 #include media/media-entity.h
 #include media/v4l2-common.h
@@ -45,6 +46,7 @@ struct v4l2_fh;
 struct v4l2_subdev;
 struct v4l2_subdev_fh;
 struct tuner_setup;
+struct v4l2_frame_config;
 
 /* decode_vbi_line */
 struct v4l2_decode_vbi_line {
@@ -476,6 +478,10 @@ struct v4l2_subdev_pad_ops {
   struct v4l2_subdev_crop *crop);
int (*get_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
   struct v4l2_subdev_crop *crop);
+   int (*set_frame_config)(struct v4l2_subdev *sd, unsigned int pad,
+   struct v4l2_frame_config *fc);
+   int (*get_frame_config)(struct v4l2_subdev *sd, unsigned int pad,
+   struct v4l2_frame_config *fc);
 };
 
 struct v4l2_subdev_ops {
@@ -567,6 +573,18 @@ struct v4l2_subdev_fh {
 #define to_v4l2_subdev_fh(fh)  \
container_of(fh, struct v4l2_subdev_fh, vfh)
 
+/**
+ * struct v4l2_frame_config - media bus data frame configuration
+ * @length: maximum number of media bus samples per frame
+ * @header_length: size of embedded data at frame start (header)
+ * @footer_length: size of embedded data at frame end (footer)
+ */
+struct v4l2_frame_config {
+   size_t length;
+   size_t header_length;
+   size_t footer_length;
+};
+
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
 static inline struct v4l2_mbus_framefmt *
 v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad)
-- 
1.7.9

--
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/PATCH 3/6] V4L: Add g_embedded_data subdev callback

2012-02-16 Thread Sylwester Nawrocki
The g_embedded_data callback allows the host to retrieve frame embedded
(meta) data from a certain subdev. This callback can be implemented by
an image sensor or a MIPI-CSI receiver, allowing to read embedded frame
data from a subdev or just query it for the data size.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 include/media/v4l2-subdev.h |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index f0f3358..be74061 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -274,6 +274,14 @@ struct v4l2_subdev_audio_ops {
s_mbus_config: set a certain mediabus configuration. This operation is added
for compatibility with soc-camera drivers and should not be used by new
software.
+
+   g_embedded_data: retrieve the frame embedded data (frame header or footer).
+   After a full frame has been transmitted the host can query a subdev
+   for frame meta data using this operation. Metadata size is returned
+   in @size, and the actual metadata in memory pointed by @data. When
+   @buf is NULL the subdev will return only the metadata size. The
+   subdevs can adjust @size to a lower value but must not write more
+   data than the @size's original value.
  */
 struct v4l2_subdev_video_ops {
int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 
config);
@@ -321,6 +329,8 @@ struct v4l2_subdev_video_ops {
 struct v4l2_mbus_config *cfg);
int (*s_mbus_config)(struct v4l2_subdev *sd,
 const struct v4l2_mbus_config *cfg);
+   int (*g_embedded_data)(struct v4l2_subdev *sd, unsigned int *size,
+  void **buf);
 };
 
 /*
-- 
1.7.9

--
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: video: mx2_camera: Remove ifdef's

2012-02-16 Thread Fabio Estevam
As we are able to build a same kernel that supports both mx27 and mx25, we 
should remove
the ifdef's for CONFIG_MACH_MX27 in the mx2_camera driver.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/media/video/mx2_camera.c |   22 +++---
 1 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 04aab0c..afb4619 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -38,9 +38,7 @@
 #include linux/videodev2.h
 
 #include mach/mx2_cam.h
-#ifdef CONFIG_MACH_MX27
 #include mach/dma-mx1-mx2.h
-#endif
 #include mach/hardware.h
 
 #include asm/dma.h
@@ -402,7 +400,6 @@ static void mx2_camera_remove_device(struct 
soc_camera_device *icd)
pcdev-icd = NULL;
 }
 
-#ifdef CONFIG_MACH_MX27
 static void mx27_camera_dma_enable(struct mx2_camera_dev *pcdev)
 {
u32 tmp;
@@ -419,6 +416,9 @@ static irqreturn_t mx27_camera_irq(int irq_csi, void *data)
struct mx2_camera_dev *pcdev = data;
u32 status = readl(pcdev-base_csi + CSISR);
 
+   if(!cpu_is_mx27())
+   return IRQ_NONE;
+
if (status  CSISR_SOF_INT  pcdev-active) {
u32 tmp;
 
@@ -431,12 +431,6 @@ static irqreturn_t mx27_camera_irq(int irq_csi, void *data)
 
return IRQ_HANDLED;
 }
-#else
-static irqreturn_t mx27_camera_irq(int irq_csi, void *data)
-{
-   return IRQ_NONE;
-}
-#endif /* CONFIG_MACH_MX27 */
 
 static void mx25_camera_frame_done(struct mx2_camera_dev *pcdev, int fb,
int state)
@@ -619,7 +613,6 @@ static void mx2_videobuf_queue(struct videobuf_queue *vq,
 
if (mx27_camera_emma(pcdev)) {
goto out;
-#ifdef CONFIG_MACH_MX27
} else if (cpu_is_mx27()) {
int ret;
 
@@ -637,7 +630,6 @@ static void mx2_videobuf_queue(struct videobuf_queue *vq,
vb-state = VIDEOBUF_ACTIVE;
pcdev-active = buf;
}
-#endif
} else { /* cpu_is_mx25() */
u32 csicr3, dma_inten = 0;
 
@@ -1201,7 +1193,6 @@ static int mx2_camera_reqbufs(struct soc_camera_device 
*icd,
return 0;
 }
 
-#ifdef CONFIG_MACH_MX27
 static void mx27_camera_frame_done(struct mx2_camera_dev *pcdev, int state)
 {
struct videobuf_buffer *vb;
@@ -1310,7 +1301,6 @@ err_out:
 
return err;
 }
-#endif /* CONFIG_MACH_MX27 */
 
 static unsigned int mx2_camera_poll(struct file *file, poll_table *pt)
 {
@@ -1558,13 +1548,11 @@ static int __devinit mx2_camera_probe(struct 
platform_device *pdev)
clk_get_rate(pcdev-clk_csi));
 
/* Initialize DMA */
-#ifdef CONFIG_MACH_MX27
if (cpu_is_mx27()) {
err = mx27_camera_dma_init(pdev, pcdev);
if (err)
goto exit_clk_put;
}
-#endif /* CONFIG_MACH_MX27 */
 
pcdev-res_csi = res_csi;
pcdev-pdata = pdev-dev.platform_data;
@@ -1657,12 +1645,10 @@ exit_iounmap:
 exit_release:
release_mem_region(res_csi-start, resource_size(res_csi));
 exit_dma_free:
-#ifdef CONFIG_MACH_MX27
if (cpu_is_mx27())
imx_dma_free(pcdev-dma);
 exit_clk_put:
clk_put(pcdev-clk_csi);
-#endif /* CONFIG_MACH_MX27 */
 exit_kfree:
kfree(pcdev);
 exit:
@@ -1677,10 +1663,8 @@ static int __devexit mx2_camera_remove(struct 
platform_device *pdev)
struct resource *res;
 
clk_put(pcdev-clk_csi);
-#ifdef CONFIG_MACH_MX27
if (cpu_is_mx27())
imx_dma_free(pcdev-dma);
-#endif /* CONFIG_MACH_MX27 */
free_irq(pcdev-irq_csi, pcdev);
if (mx27_camera_emma(pcdev))
free_irq(pcdev-irq_emma, pcdev);
-- 
1.7.1


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


Re: [PATCH 00/35] Add a driver for Terratec H7

2012-02-16 Thread Roger Mårtensson

Mauro Carvalho Chehab skrev 2012-01-21 17:04:

Terratec H7 is a Cypress FX2 device with a mt2063 tuner and a drx-k
demod. This series add support for it. It started with a public
tree found at:
 
http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz

The driver were almost completely re-written, and it is now working,
at least with DVB-C. I don't have a DVB-T signal here for testing,
but I suspect it should also work fine.

The FX2 firmware has a NEC IR decoder. The driver has support for
it. The default keytable has support for the black Terratec IR
and for the grey IR with orange keys.

The CI support inside the driver is similar to the one found at the
az6027 driver. I don't have a CI module here, so it is not tested.

Tests and feedback are welcome.


A small feedback report.

I've tested with the latest media_build and can watch unencrypted 
channels on the DVB-C network I'm connected to.


It seems that the CI-module doesn't work. Nothing happens when I insert 
a CAM-module with our without a programme card.

I haven't tried to use the IR yet.

 * Okänt - identifierat
 * Engelska
 * Svenska
 * Franska
 * Tyska

 * Engelska
 * Svenska
 * Franska
 * Tyska

javascript:void(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


cron job: media_tree daily build: ERRORS

2012-02-16 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:Thu Feb 16 19:00:18 CET 2012
git hash:a3db60bcf7671cc011ab4f848cbc40ff7ab52c1e
gcc version:  i686-linux-gcc (GCC) 4.6.2
host hardware:x86_64
host os:  3.1-2.slh.1-amd64

linux-git-arm-eabi-enoxys: WARNINGS
linux-git-arm-eabi-omap: ERRORS
linux-git-armv5-ixp: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: WARNINGS
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
linux-git-x86_64: WARNINGS
linux-2.6.31.12-i686: WARNINGS
linux-2.6.32.6-i686: WARNINGS
linux-2.6.33-i686: WARNINGS
linux-2.6.34-i686: WARNINGS
linux-2.6.35.3-i686: WARNINGS
linux-2.6.36-i686: WARNINGS
linux-2.6.37-i686: WARNINGS
linux-2.6.38.2-i686: WARNINGS
linux-2.6.39.1-i686: WARNINGS
linux-3.0-i686: WARNINGS
linux-3.1-i686: WARNINGS
linux-3.2.1-i686: WARNINGS
linux-3.3-rc1-i686: WARNINGS
linux-2.6.31.12-x86_64: WARNINGS
linux-2.6.32.6-x86_64: WARNINGS
linux-2.6.33-x86_64: WARNINGS
linux-2.6.34-x86_64: WARNINGS
linux-2.6.35.3-x86_64: WARNINGS
linux-2.6.36-x86_64: WARNINGS
linux-2.6.37-x86_64: WARNINGS
linux-2.6.38.2-x86_64: WARNINGS
linux-2.6.39.1-x86_64: WARNINGS
linux-3.0-x86_64: WARNINGS
linux-3.1-x86_64: WARNINGS
linux-3.2.1-x86_64: WARNINGS
linux-3.3-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: WARNINGS
sparse: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Thursday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Thursday.tar.bz2

The V4L-DVB specification from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.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: video: mx2_camera: Remove ifdef's

2012-02-16 Thread Guennadi Liakhovetski
Hi

On Thu, 16 Feb 2012, Baruch Siach wrote:

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

I'm still hoping to merge this

http://patchwork.linuxtv.org/patch/298/

patch, after it is suitably updated... Sascha, any progress?

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
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: Division by zero in UVC driver

2012-02-16 Thread Hans Petter Selasky
On Thursday 16 February 2012 07:30:17 Laurent Pinchart wrote:
 Hi Hans,
 
 On Wednesday 15 February 2012 18:27:29 Hans Petter Selasky wrote:
  Hi,
  
  After getting through the compilation issues regarding the uvc_debugfs, I
  am now facing another problem, which I think is more generic.
  
  The FreeBSD port of the Linux UVC driver, webcamd, gives a division by
  zero inside the UVC driver, because it does not properly check if the
  returned SOF counter is the same like the previous one. This can also
  happen on Linux if the UVC capable device is plugged exactly when the
  EHCI/OHCI/UHCI SOF counter is equal to zero!
 
 It's a know bug (at least to me :-)). Does
 http://git.linuxtv.org/pinchartl/uvcvideo.git/commit/5c97eb2eb9c45dad8825de
 7754ceb33699451978 fix your problem ? I've queued that patch in my tree for
 v3.4.

Your patch works! Thanks!

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


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

2012-02-16 Thread Baruch Siach
Hi Fabio,

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

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

baruch 

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


Re: [RFC/PATCH 1/6] V4L: Add V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 media bus format

2012-02-16 Thread Sakari Ailus
Hi Sylwester,

On Thu, Feb 16, 2012 at 07:23:54PM +0100, Sylwester Nawrocki wrote:
 This patch adds media bus pixel code for the interleaved JPEG/YUYV image
 format used by S5C73MX Samsung cameras. The interleaved image data is
 transferred on MIPI-CSI2 bus as User Defined Byte-based Data.
 
 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  include/linux/v4l2-mediabus.h |3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
 
 diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
 index 5ea7f75..c2f0e4e 100644
 --- a/include/linux/v4l2-mediabus.h
 +++ b/include/linux/v4l2-mediabus.h
 @@ -92,6 +92,9 @@ enum v4l2_mbus_pixelcode {
  
   /* JPEG compressed formats - next is 0x4002 */
   V4L2_MBUS_FMT_JPEG_1X8 = 0x4001,
 +
 + /* Interleaved JPEG and YUV formats - next is 0x4102 */
 + V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 = 0x4101,
  };

Thanks for the patch. Just a tiny comment:

I'd go with a new hardware-specific buffer range, e.g. 0x5000.

Guennadi also proposed an interesting idea: a pass-through format. Does
your format have dimensions that the driver would use for something or is
that just a blob?

Kind regards,

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi jabber/XMPP/Gmail: sai...@retiisi.org.uk
--
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/PATCH 4/6] V4L: Add get/set_frame_config subdev callbacks

2012-02-16 Thread Sakari Ailus
Hi Sylwester,

Thanks for the patch.

Sylwester Nawrocki wrote:
 Add subdev callbacks for setting up parameters of frame on media bus that
 are not exposed to user space directly. This is more a stub containing
 only parameters needed to setup V4L2_MBUS_FMT_VYUY_JPEG_I1_1X8 data
 transmision and the associated frame embedded data.
 
 The @length field of struct v4l2_frame_config determines maximum number
 of frame samples per frame, excluding embedded non-image data.
 
 @header_length and @footer length determine the size in bytes of data
 embedded at frame beginning and end respectively.
 
 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  include/media/v4l2-subdev.h |   18 ++
  1 files changed, 18 insertions(+), 0 deletions(-)
 
 diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
 index be74061..bd95f00 100644
 --- a/include/media/v4l2-subdev.h
 +++ b/include/media/v4l2-subdev.h
 @@ -21,6 +21,7 @@
  #ifndef _V4L2_SUBDEV_H
  #define _V4L2_SUBDEV_H
  
 +#include linux/types.h
  #include linux/v4l2-subdev.h
  #include media/media-entity.h
  #include media/v4l2-common.h
 @@ -45,6 +46,7 @@ struct v4l2_fh;
  struct v4l2_subdev;
  struct v4l2_subdev_fh;
  struct tuner_setup;
 +struct v4l2_frame_config;
  
  /* decode_vbi_line */
  struct v4l2_decode_vbi_line {
 @@ -476,6 +478,10 @@ struct v4l2_subdev_pad_ops {
  struct v4l2_subdev_crop *crop);
   int (*get_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
  struct v4l2_subdev_crop *crop);
 + int (*set_frame_config)(struct v4l2_subdev *sd, unsigned int pad,
 + struct v4l2_frame_config *fc);
 + int (*get_frame_config)(struct v4l2_subdev *sd, unsigned int pad,
 + struct v4l2_frame_config *fc);
  };
  
  struct v4l2_subdev_ops {
 @@ -567,6 +573,18 @@ struct v4l2_subdev_fh {
  #define to_v4l2_subdev_fh(fh)\
   container_of(fh, struct v4l2_subdev_fh, vfh)
  
 +/**
 + * struct v4l2_frame_config - media bus data frame configuration
 + * @length: maximum number of media bus samples per frame
 + * @header_length: size of embedded data at frame start (header)
 + * @footer_length: size of embedded data at frame end (footer)
 + */
 +struct v4l2_frame_config {
 + size_t length;
 + size_t header_length;
 + size_t footer_length;
 +};
 +
  #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
  static inline struct v4l2_mbus_framefmt *
  v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad)

I think we need something a little more expressive to describe the
metadata. Preferrably the structure of the whole frame.

Is the size of your metadata measured in just bytes? If we have a frame
that has width and height the metadata is just spread to a number of
lines. That's the case on the SMIA(++) driver, for example.

Is the length field intended to be what once was planned in
v4l2_mbus_framefmt and later on as a control?

Also, only some receivers will be able to separate the metadata from the
rest of the frame. The above struct doesn't have information on the
format of the metadata either.

I admit that I should have written an RFC on this but it's my general
lack of time that has prevented me from doing that. :-I

Cheers,

-- 
Sakari Ailus
sakari.ai...@iki.fi
--
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: Business proposal

2012-02-16 Thread Laurent Pinchart
Hi Koen,

On Thursday 16 February 2012 23:46:51 Beel, Koen wrote:
 Hi Laurent,
 
 Would it be possible to give us your number on which you can be reached next
 Monday? I prefer to init the call from our side as we will join the call
 with two people and we will be in a meeting room... (so not available on
 our desk phone)

Sure. You can call me at +32477410753.

-- 
Regards,

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


Kernel Display and Video API Consolidation mini-summit at ELC 2012 - Notes

2012-02-16 Thread Laurent Pinchart
Hello everybody,

First of all, I would like to thank all the attendees for their participation 
in the mini-summit that helped make the meeting a success.

Here are my consolidated notes that cover both the Linaro Connect meeting and 
the ELC meeting. They're also available at 
http://www.ideasonboard.org/media/meetings/.


Kernel Display and Video API Consolidation mini-summit at ELC 2012
--

***  Video Transmitter Drivers ***

  Goal: Sharing video transmitter drivers (i2c or 'IP block') between V4L and
  DRM.

  This is mostly useful for embedded systems. Transmitters can be used by both
  GPUs and direct video outputs. Having a single driver for external (or even
  internal) HDMI transmitters is desired to avoid code duplication between
  subsystems.

  - DRM/KMS implements support for transmitters as DRM encoders. Code is
embedded in the main DRM/KMS driver.
  - V4L2 implements transmitter drivers as generic kernel objects called
v4l2_subdev that implement a set of abstract operations.

  v4l2_subdev already solves (most of ?) the problem, but is specific to V4L2.
  The proposed approach is to create a media_video_entity (exact name to be
  defined) object similar to v4l2_subdev.

  Using that API should not be mandatory, especially on hardware where the
  transmitter and the display controller are deeply cross-dependent.

  How to instantiate the transmitter device and how to handle probe order
  needs to be solved, especially when DT binding come into play. The problem
  already exists to some extend in V4L2.

  The subdev API takes mbus formats as arguments, which is not handled by
  DRM/KMS. V4L2 media bus codes will then need to be shared.

  Action points:
  - Initially, mostly FBDEV (HDMI-on-DSI, Renesas) and V4L2 (TI hardware,
Cisco). Hans + Laurent to work on a proposal.

***  Display Panel Drivers ***

  Goal: Sharing display panel drivers between display controllers from
  different vendors.

  Panels are connected to the display controller through a standard bus with a
  control channel (DSI and eDP are two major such buses). Various vendors have
  created proprietary interfaces for panel drivers:

  - TI on OMAP (drivers/video/omap2/displays).
  - Samsung on Exynos (drivers/video/exynos).
  - ST-Ericsson on MCDE (http://www.igloocommunity.org/gitweb/?p=kernel/igloo-
kernel.git;a=tree;f=drivers/video/mcde)
  - Renesas is working on a similar interface for SH Mobile.

  HDMI-on-DSI transmitters, while not panels per-se, can be supported through
  the same API.

  A Low level Linux Display Framework (https://lkml.org/lkml/2011/9/15/107)
  has been proposed and overlaps with this topic.

  For DSI, a possible abstraction level would be a DCS (Display Command Set)
  bus. Panels and/or HDMI-on-DSI transmitter drivers would be implemented as
  DCS drivers.

  Action points:
  - Marcus to work on a proposal for DCS-based panels (with Tomi Valkeinen and
Morimoto-san).

***  Common video mode data structure and EDID parser ***

  Goal: Sharing an EDID parser between DRM/KMS, FBDEV and V4L2.

  The DRM EDID parser is currently the most advanced implementation and will
  be taken as a starting point.

  Different subsystems use different data structures to describe video
  mode/timing information:

  - struct drm_mode_modeinfo in DRM/KMS
  - struct fb_videomode in FBDEV
  - struct v4l2_bt_timings in V4L2

  A new common video mode/timing data structure (struct media_video_mode_info,
  exact name is to be defined), not tied to any specific subsystem, is
  required to share the EDID parser. That structure won't be exported to
  userspace.

  Helper functions will be implemented in the subsystems to convert between
  that generic structure and the various subsystem-specific structures.

  The mode list is stored in the DRM connector in the EDID parser. A new mode
  list data structure can be added, or a callback function can be used by the
  parser to give modes one at a time to the caller.

  3D needs to be taken into account (this is similar to interlacing).

  Action points:
  - Laurent to work on a proposal. The DRM/KMS EDID parser will be reused.
  
***  Shared in-kernel image/framebuffer object type ***

  Goal: Describe dma-buf content in a generic cross-subsystem way.

  Most formats can be described by 4CC, width, height and pitch. Strange
  hardware-specific formats might not be possible to describes completely
  generically.

  However, format negotiation goes through userspace anyway, so there should
  be no need for passing format information directly between drivers.

  Action points:
  - None, this task will not be worked on.

***  Central 4CC Documentation ***

  Goal: Define and document 4CCs in a central location to make sure 4CCs won't
  overlap or have different meanings for different subsystems.

  DRM and V4L2 define their own 4CCs:

  - include/drm/drm-fourccs.h
  - include/linux/videodev2.h

  A new 

[patch 1/2] [media] s2255drv: cleanup vidioc_enum_fmt_cap()

2012-02-16 Thread Dan Carpenter
f wasn't checked consistently, so static checkers complain.  This
function is always called with a valid f pointer, so I have removed
the check.

Also the indenting was messed up.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index c1bef61..3505242 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -852,15 +852,13 @@ static int vidioc_querycap(struct file *file, void *priv,
 static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
   struct v4l2_fmtdesc *f)
 {
-   int index = 0;
-   if (f)
-   index = f-index;
+   int index = f-index;
 
if (index = ARRAY_SIZE(formats))
return -EINVAL;
-if (!jpeg_enable  ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
-(formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
-   return -EINVAL;
+   if (!jpeg_enable  ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
+   (formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
+   return -EINVAL;
dprintk(4, name %s\n, formats[index].name);
strlcpy(f-description, formats[index].name, sizeof(f-description));
f-pixelformat = formats[index].fourcc;
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 2/2] [media] s2255drv: fix some endian bugs

2012-02-16 Thread Dan Carpenter
I don't have this hardware and I don't know the subsystem very well.  So
please review this patch carefully.  The original code definitely looks
buggy though.

Sparse complains about some endian bugs where little endian bugs are
treated as cpu endian.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
---

diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 3505242..4894cbb 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -134,7 +134,7 @@
 
 /* usb config commands */
 #define IN_DATA_TOKEN  cpu_to_le32(0x2255c0de)
-#define CMD_2255   cpu_to_le32(0xc2255000)
+#define CMD_2255   0xc2255000
 #define CMD_SET_MODE   cpu_to_le32((CMD_2255 | 0x10))
 #define CMD_START  cpu_to_le32((CMD_2255 | 0x20))
 #define CMD_STOP   cpu_to_le32((CMD_2255 | 0x30))
@@ -2025,7 +2025,7 @@ static int save_frame(struct s2255_dev *dev, struct 
s2255_pipeinfo *pipe_info)
pdata[1]);
offset = jj + PREFIX_SIZE;
bframe = 1;
-   cc = pdword[1];
+   cc = le32_to_cpu(pdword[1]);
if (cc = MAX_CHANNELS) {
printk(KERN_ERR
   bad channel\n);
@@ -2034,22 +2034,22 @@ static int save_frame(struct s2255_dev *dev, struct 
s2255_pipeinfo *pipe_info)
/* reverse it */
dev-cc = G_chnmap[cc];
channel = dev-channel[dev-cc];
-   payload =  pdword[3];
+   payload =  le32_to_cpu(pdword[3]);
if (payload  channel-req_image_size) {
channel-bad_payload++;
/* discard the bad frame */
return -EINVAL;
}
channel-pkt_size = payload;
-   channel-jpg_size = pdword[4];
+   channel-jpg_size = le32_to_cpu(pdword[4]);
break;
case S2255_MARKER_RESPONSE:
 
pdata += DEF_USB_BLOCK;
jj += DEF_USB_BLOCK;
-   if (pdword[1] = MAX_CHANNELS)
+   if (le32_to_cpu(pdword[1]) = MAX_CHANNELS)
break;
-   cc = G_chnmap[pdword[1]];
+   cc = G_chnmap[le32_to_cpu(pdword[1])];
if (cc = MAX_CHANNELS)
break;
channel = dev-channel[cc];
@@ -2072,11 +2072,11 @@ static int save_frame(struct s2255_dev *dev, struct 
s2255_pipeinfo *pipe_info)
wake_up(dev-fw_data-wait_fw);
break;
case S2255_RESPONSE_STATUS:
-   channel-vidstatus = pdword[3];
+   channel-vidstatus = 
le32_to_cpu(pdword[3]);
channel-vidstatus_ready = 1;
wake_up(channel-wait_vidstatus);
dprintk(5, got vidstatus %x chan %d\n,
-   pdword[3], cc);
+   le32_to_cpu(pdword[3]), cc);
break;
default:
printk(KERN_INFO s2255 unknown 
resp\n);
@@ -2603,10 +2603,11 @@ static int s2255_probe(struct usb_interface *interface,
__le32 *pRel;
pRel = (__le32 *) dev-fw_data-fw-data[fw_size - 4];
printk(KERN_INFO s2255 dsp fw version %x\n, *pRel);
-   dev-dsp_fw_ver = *pRel;
-   if (*pRel  S2255_CUR_DSP_FWVER)
+   dev-dsp_fw_ver = le32_to_cpu(*pRel);
+   if (dev-dsp_fw_ver  S2255_CUR_DSP_FWVER)
printk(KERN_INFO s2255: f2255usb.bin out of date.\n);
-   if (dev-pid == 0x2257  *pRel  S2255_MIN_DSP_COLORFILTER)
+   if (dev-pid == 0x2257 
+   dev-dsp_fw_ver  S2255_MIN_DSP_COLORFILTER)
printk(KERN_WARNING s2255: 2257 requires firmware %d
or above.\n, S2255_MIN_DSP_COLORFILTER);
}
--
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