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

[PATCH] soc_camera: convert to devm_ioremap_resource()

2013-03-11 Thread Silviu-Mihai Popescu
Convert all uses of devm_request_and_ioremap() to the newly introduced
devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit
error messages can be removed from the failure code paths.

Signed-off-by: Silviu-Mihai Popescu silviupopescu1...@gmail.com
---
 drivers/media/platform/soc_camera/pxa_camera.c |6 +++---
 .../platform/soc_camera/sh_mobile_ceu_camera.c |8 +++-
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |8 +++-
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 395e2e0..e94ed6c 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1710,9 +1710,9 @@ static int pxa_camera_probe(struct platform_device *pdev)
/*
 * Request the regions.
 */
-   base = devm_request_and_ioremap(pdev-dev, res);
-   if (!base)
-   return -ENOMEM;
+   base = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(base))
+   return PTR_ERR(base);
pcdev-irq = irq;
pcdev-base = base;
 
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index bb08a46..8cdee71 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -2110,11 +2110,9 @@ static int sh_mobile_ceu_probe(struct platform_device 
*pdev)
pcdev-max_width = pcdev-pdata-max_width ? : 2560;
pcdev-max_height = pcdev-pdata-max_height ? : 1920;
 
-   base = devm_request_and_ioremap(pdev-dev, res);
-   if (!base) {
-   dev_err(pdev-dev, Unable to ioremap CEU registers.\n);
-   return -ENXIO;
-   }
+   base = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(base))
+   return PTR_ERR(base);
 
pcdev-irq = irq;
pcdev-base = base;
diff --git a/drivers/media/platform/soc_camera/sh_mobile_csi2.c 
b/drivers/media/platform/soc_camera/sh_mobile_csi2.c
index 42c559e..3ec7735 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_csi2.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_csi2.c
@@ -324,11 +324,9 @@ static int sh_csi2_probe(struct platform_device *pdev)
 
priv-irq = irq;
 
-   priv-base = devm_request_and_ioremap(pdev-dev, res);
-   if (!priv-base) {
-   dev_err(pdev-dev, Unable to ioremap CSI2 registers.\n);
-   return -ENXIO;
-   }
+   priv-base = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(priv-base))
+   return PTR_ERR(priv-base);
 
priv-pdev = pdev;
platform_set_drvdata(pdev, 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


Re: [PATCH] soc_camera: convert to devm_ioremap_resource()

2013-03-11 Thread Guennadi Liakhovetski
Hi Silviu-Mihai

On Mon, 11 Mar 2013, Silviu-Mihai Popescu wrote:

 Convert all uses of devm_request_and_ioremap() to the newly introduced
 devm_ioremap_resource() which provides more consistent error handling.
 
 devm_ioremap_resource() provides its own error messages so all explicit
 error messages can be removed from the failure code paths.
 
 Signed-off-by: Silviu-Mihai Popescu silviupopescu1...@gmail.com

Is there anything in this patch, that this patch series

http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/61337

is missing?

Thanks
Guennadi

 ---
  drivers/media/platform/soc_camera/pxa_camera.c |6 +++---
  .../platform/soc_camera/sh_mobile_ceu_camera.c |8 +++-
  drivers/media/platform/soc_camera/sh_mobile_csi2.c |8 +++-
  3 files changed, 9 insertions(+), 13 deletions(-)
 
 diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
 b/drivers/media/platform/soc_camera/pxa_camera.c
 index 395e2e0..e94ed6c 100644
 --- a/drivers/media/platform/soc_camera/pxa_camera.c
 +++ b/drivers/media/platform/soc_camera/pxa_camera.c
 @@ -1710,9 +1710,9 @@ static int pxa_camera_probe(struct platform_device 
 *pdev)
   /*
* Request the regions.
*/
 - base = devm_request_and_ioremap(pdev-dev, res);
 - if (!base)
 - return -ENOMEM;
 + base = devm_ioremap_resource(pdev-dev, res);
 + if (IS_ERR(base))
 + return PTR_ERR(base);
   pcdev-irq = irq;
   pcdev-base = base;
  
 diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
 b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
 index bb08a46..8cdee71 100644
 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
 +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
 @@ -2110,11 +2110,9 @@ static int sh_mobile_ceu_probe(struct platform_device 
 *pdev)
   pcdev-max_width = pcdev-pdata-max_width ? : 2560;
   pcdev-max_height = pcdev-pdata-max_height ? : 1920;
  
 - base = devm_request_and_ioremap(pdev-dev, res);
 - if (!base) {
 - dev_err(pdev-dev, Unable to ioremap CEU registers.\n);
 - return -ENXIO;
 - }
 + base = devm_ioremap_resource(pdev-dev, res);
 + if (IS_ERR(base))
 + return PTR_ERR(base);
  
   pcdev-irq = irq;
   pcdev-base = base;
 diff --git a/drivers/media/platform/soc_camera/sh_mobile_csi2.c 
 b/drivers/media/platform/soc_camera/sh_mobile_csi2.c
 index 42c559e..3ec7735 100644
 --- a/drivers/media/platform/soc_camera/sh_mobile_csi2.c
 +++ b/drivers/media/platform/soc_camera/sh_mobile_csi2.c
 @@ -324,11 +324,9 @@ static int sh_csi2_probe(struct platform_device *pdev)
  
   priv-irq = irq;
  
 - priv-base = devm_request_and_ioremap(pdev-dev, res);
 - if (!priv-base) {
 - dev_err(pdev-dev, Unable to ioremap CSI2 registers.\n);
 - return -ENXIO;
 - }
 + priv-base = devm_ioremap_resource(pdev-dev, res);
 + if (IS_ERR(priv-base))
 + return PTR_ERR(priv-base);
  
   priv-pdev = pdev;
   platform_set_drvdata(pdev, priv);
 -- 
 1.7.9.5
 

---
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: [PATCH] soc_camera: convert to devm_ioremap_resource()

2013-03-11 Thread Silviu Popescu
On Mon, Mar 11, 2013 at 9:50 AM, Guennadi Liakhovetski
g.liakhovet...@gmx.de wrote:

 Is there anything in this patch, that this patch series

 http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/61337

 is missing?

 Thanks
 Guennadi

Hello Guennadi,

I seem to have missed that patch series. And no, this does not cover
anything extra.
I'm sorry for the lack of attention on my behalf.

--
Silviu Popescu
--
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] soc_camera: convert to devm_ioremap_resource()

2013-03-11 Thread Guennadi Liakhovetski
On Mon, 11 Mar 2013, Silviu Popescu wrote:

 On Mon, Mar 11, 2013 at 9:50 AM, Guennadi Liakhovetski
 g.liakhovet...@gmx.de wrote:
 
  Is there anything in this patch, that this patch series
 
  http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/61337
 
  is missing?
 
  Thanks
  Guennadi
 
 Hello Guennadi,
 
 I seem to have missed that patch series. And no, this does not cover
 anything extra.

Good, thanks for checking!

 I'm sorry for the lack of attention on my behalf.

No problem, it's hard to follow all incoming changes.

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


[PATCH] crystalhd gst: Port to GStreamer 1.0 API

2013-03-11 Thread Guido Günther
---
Tested with totem as well as gst-launch. Any chance this can be applied
to http://git.linuxtv.org/jarod/crystalhd.git?
Cheers,
 -- Guido

 filters/gst/gst-plugin/configure.ac|8 +-
 filters/gst/gst-plugin/src/gstbcmdec.c |  431 
 filters/gst/gst-plugin/src/gstbcmdec.h |   68 ++---
 3 files changed, 248 insertions(+), 259 deletions(-)

diff --git a/filters/gst/gst-plugin/configure.ac 
b/filters/gst/gst-plugin/configure.ac
index 99b3713..a3c6467 100644
--- a/filters/gst/gst-plugin/configure.ac
+++ b/filters/gst/gst-plugin/configure.ac
@@ -1,9 +1,9 @@
 AC_INIT
 
 dnl versions of gstreamer and plugins-base
-GST_MAJORMINOR=0.10
-GST_REQUIRED=0.10.0
-GSTPB_REQUIRED=0.10.0
+GST_MAJORMINOR=1.0
+GST_REQUIRED=1.0
+GSTPB_REQUIRED=1.0
 
 dnl fill in your package name and version here
 dnl the fourth (nano) number should be 0 for a release, 1 for CVS,
@@ -56,7 +56,7 @@ dnl And we can also ask for the right version of gstreamer
 
 PKG_CHECK_MODULES(GST, \
   gstreamer-$GST_MAJORMINOR = $GST_REQUIRED
-  gstreamer-video-0.10,
+  gstreamer-video-1.0,
   HAVE_GST=yes,HAVE_GST=no)
 
 dnl Give error and exit if we don't have gstreamer
diff --git a/filters/gst/gst-plugin/src/gstbcmdec.c 
b/filters/gst/gst-plugin/src/gstbcmdec.c
index ed01c14..a51bd59 100644
--- a/filters/gst/gst-plugin/src/gstbcmdec.c
+++ b/filters/gst/gst-plugin/src/gstbcmdec.c
@@ -8,6 +8,7 @@
  *  AU
  *
  *  HISTORY:
+ * Updated for 1.0 by Guido Guenther a...@sigxcpu.org
  *
  ***
  *
@@ -40,6 +41,7 @@
 #include glib.h
 #include gst/base/gstadapter.h
 #include gst/video/video.h
+#include gst/video/gstvideopool.h
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -51,8 +53,8 @@
 #include parse.h
 #include gstbcmdec.h
 
-GST_DEBUG_CATEGORY_STATIC (gst_bcmdec_debug);
-#define GST_CAT_DEFAULT gst_bcmdec_debug
+GST_DEBUG_CATEGORY_STATIC (gst_bcm_dec_debug);
+#define GST_CAT_DEFAULT gst_bcm_dec_debug
 
 //#define YV12__
 
@@ -64,16 +66,18 @@ static GstFlowReturn 
bcmdec_send_buff_detect_error(GstBcmDec *bcmdec, GstBuffer
   guint8 flags)
 {
BC_STATUS sts = BC_STS_SUCCESS;
+   GstMapInfo info;
 
GST_DEBUG_OBJECT(bcmdec, Attempting to Send Buffer);
 
sts = decif_send_buffer(bcmdec-decif, pbuffer, size, tCurrent, flags);
 
if (sts != BC_STS_SUCCESS) {
+   gst_buffer_map(buf, info, GST_MAP_READ);
GST_ERROR_OBJECT(bcmdec, proc input failed sts = %d, sts);
GST_ERROR_OBJECT(bcmdec, Chain: timeStamp = %llu size = %d 
data = %p,
-GST_BUFFER_TIMESTAMP(buf), 
GST_BUFFER_SIZE(buf),
-GST_BUFFER_DATA (buf));
+GST_BUFFER_DTS(buf), info.size, info.data);
+   gst_buffer_unmap(buf, info);
return GST_FLOW_ERROR;
}
 
@@ -92,7 +96,7 @@ enum {
 };
 
 
-GLB_INST_STS *g_inst_sts = NULL;
+static GLB_INST_STS *g_inst_sts = NULL;
 
 /*
  * the capabilities of the inputs and outputs.
@@ -111,35 +115,29 @@ GstStaticPadTemplate sink_factory_bcm70012 = 
GST_STATIC_PAD_TEMPLATE(sink, GST
 
 #ifdef YV12__
 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE(src, 
GST_PAD_SRC, GST_PAD_ALWAYS,
-   GST_STATIC_CAPS(video/x-raw-yuv,  format = (fourcc) { YV12 
},  width = (int) [ 1, MAX ], 
+   GST_STATIC_CAPS(video/x-raw,  format = (string) { YV12 },  
width = (int) [ 1, MAX ], 
height = (int) [ 1, MAX ],  framerate = 
(fraction) [ 0/1, 2147483647/1 ]));
 #define BUF_MULT (12 / 8)
 #define BUF_MODE MODE420
 #else
 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE(src, 
GST_PAD_SRC, GST_PAD_ALWAYS,
-   GST_STATIC_CAPS(video/x-raw-yuv,  format = (fourcc) { YUY2 } 
,  framerate = (fraction) [0,MAX], 
-   width = (int) [1,MAX],  height = (int) 
[1,MAX];  video/x-raw-yuv, 
-   format = (fourcc) { UYVY } ,  framerate = 
(fraction) [0,MAX],  width = (int) [1,MAX], 
+   GST_STATIC_CAPS(video/x-raw,  format = (string) { YUY2 } ,  
framerate = (fraction) [0,MAX], 
+   width = (int) [1,MAX],  height = (int) 
[1,MAX];  video/x-raw, 
+   format = (string) { UYVY } ,  framerate = 
(fraction) [0,MAX],  width = (int) [1,MAX], 
height = (int) [1,MAX]; ));
 #define BUF_MULT (16 / 8)
 #define BUF_MODE MODE422_YUY2
 #endif
 
-GST_BOILERPLATE(GstBcmDec, gst_bcmdec, GstElement, GST_TYPE_ELEMENT);
+G_DEFINE_TYPE(GstBcmDec, gst_bcm_dec, GST_TYPE_ELEMENT);
 
 /* GObject vmethod implementations */
 
-static void gst_bcmdec_base_init(gpointer gclass)
+static void gst_bcm_dec_base_init(gpointer gclass)
 {
-   static GstElementDetails element_details;
BC_HW_CAPS hwCaps;
 
-   GST_DEBUG_OBJECT(gclass, 

omap3isp: iommu register problem.

2013-03-11 Thread javier Martin
Hi,
I'm trying to make omap3isp work with our DM3730 based board.

When I try to boot the kernel I get the following message:

[2.064239] omap3isp omap3isp: Revision 15.0 found
[2.070220] omap_iommu_attach: 1
[2.073669] omap_iommu_attach: 2
[2.077056] omap_iommu_attach: 3
[2.080627] omap_iommu_attach: 4
[2.084014] omap_iommu_attach: 5
[2.087432] iommu_enable: 1
[2.090362] iommu_enable: 2, arch_iommu =   (null)
[2.095428] omap_iommu_attach: 6
[2.098815] omap3isp omap3isp: can't get omap iommu: -19
[2.104431] omap3isp omap3isp: can't attach iommu device: -19
[2.110504] Unable to handle kernel NULL pointer dereference at
virtual address 0034
[2.119018] pgd = c0004000
[2.121856] [0034] *pgd=
[2.125671] Internal error: Oops: 5 [#1] ARM
[2.130157] Modules linked in:
[2.133361] CPU: 0Not tainted  (3.8.0-2-g07e6459-dirty #741)
[2.140045] PC is at omap_iommu_save_ctx+0x18/0x24
[2.145050] LR is at omap3isp_put+0x98/0xd8
[2.149444] pc : [c0432cdc]lr : [c03e3654]psr: 6113
[2.149444] sp : cf831e50  ip :   fp : c0670184
[2.161437] r10: 0010  r9 : bfff  r8 : ffed
[2.166931] r7 : 0001  r6 : c077b9a8  r5 : cf010530  r4 : cf01
[2.173736] r3 :   r2 : c077bc00  r1 :   r0 : 
[2.180572] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM
Segment kernel
[2.188232] Control: 10c5387d  Table: 80004019  DAC: 0015
[2.194244] Process swapper (pid: 1, stack limit = 0xcf830230)
[2.200347] Stack: (0xcf831e50 to 0xcf832000)
[2.204925] 1e40: cf01
c03e3654 cf01 c077b9b8
[2.213470] 1e60: c077b9a8 c03e3c70  0001 
cf010530 cf01 c0058e84
[2.222045] 1e80:  c07606c8 cf8e6a40  c077b9b8
c077b9b8 c0d16db4 c077b9ec
[2.230590] 1ea0: c07bba98 c0736360 00b0 c07606c8 
c02f822c c077b9b8 c02f6f2c
[2.239166] 1ec0: c077b9b8 c07bba98 c077b9ec  c0736360
c02f7154 c07bba98 cf831ee8
[2.247711] 1ee0: c02f70c0 c02f5888 cf81e4a8 cf8de510 
c07bba98 c07ac1d0 cfbed240
[2.256286] 1f00:  c02f6004 c066b5c0 c07bba98 
c07606c0 c07bba98 
[2.264831] 1f20: c07562d8 c02f7748 c07606c0 c07cddc0 
c07562d8 c0736360 c000864c
[2.273406] 1f40: c06bdb3c c070fd04 0006 0006 
c07606c0 c076dcd4 c07cddc0
[2.281951] 1f60: 0007 c0736360 00b0 c07606c8 
c073628c 0006 0006
[2.290527] 1f80: c0736360 cf83  c052ecb8 
  
[2.299072] 1fa0:  c052ecc0  c000e0b0 
  
[2.307647] 1fc0:     
  
[2.316223] 1fe0:     0013
 60402140 4b080520
[2.324798] [c0432cdc] (omap_iommu_save_ctx+0x18/0x24) from
[c03e3654] (omap3isp_put+0x98/0xd8)
[2.334259] [c03e3654] (omap3isp_put+0x98/0xd8) from [c03e3c70]
(isp_probe+0x1d0/0xaf0)
[2.343017] [c03e3c70] (isp_probe+0x1d0/0xaf0) from [c02f822c]
(platform_drv_probe+0x18/0x1c)
[2.352325] [c02f822c] (platform_drv_probe+0x18/0x1c) from
[c02f6f2c] (driver_probe_device+0x80/0x214)
[2.362426] [c02f6f2c] (driver_probe_device+0x80/0x214) from
[c02f7154] (__driver_attach+0x94/0x98)
[2.372283] [c02f7154] (__driver_attach+0x94/0x98) from
[c02f5888] (bus_for_each_dev+0x60/0x8c)
[2.381744] [c02f5888] (bus_for_each_dev+0x60/0x8c) from
[c02f6004] (bus_add_driver+0xa4/0x238)
[2.391235] [c02f6004] (bus_add_driver+0xa4/0x238) from
[c02f7748] (driver_register+0x78/0x140)
[2.400695] [c02f7748] (driver_register+0x78/0x140) from
[c000864c] (do_one_initcall+0x30/0x170)
[2.410278] [c000864c] (do_one_initcall+0x30/0x170) from
[c073628c] (kernel_init_freeable+0xdc/0x1b0)
[2.420318] [c073628c] (kernel_init_freeable+0xdc/0x1b0) from
[c052ecc0] (kernel_init+0x8/0xe4)
[2.429809] [c052ecc0] (kernel_init+0x8/0xe4) from [c000e0b0]
(ret_from_fork+0x14/0x24)
[2.438568] Code: e92d4010 e59021d4 e5933000 e5920004 (e5933034)
[2.445129] ---[ end trace ce0d24c569f5d702 ]---
[2.450012] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x000b

This is  due to the following function not being executed at startup:

static int __init omap2_iommu_init(void)
{
printk(%s\n, __func__);
return omap_install_iommu_arch(omap2_iommu_ops);
}
module_init(omap2_iommu_init);

Does anyone know what could be the reason?

Regards.
-- 
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
--
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: mt9m111/mt9m131: kernel 3.8 issues.

2013-03-11 Thread Guennadi Liakhovetski
On Fri, 8 Mar 2013, Guennadi Liakhovetski wrote:

 On Fri, 8 Mar 2013, Benoît Thébaudeau wrote:
 
  Hi Javier,
  
  On Friday, March 8, 2013 1:37:38 PM, Javier Martin wrote:
   Hi Benoît,
   
   On 8 March 2013 12:53, Benoît Thébaudeau 
   benoit.thebaud...@advansee.com
   wrote:
   
Regarding 3, you say it works nicely for you in kernel 3.4.5. I've
migrated my code to that version but I still get colours that lack
enough intensity.
This is a snapshot a taken with my mobile which is much more similar
to what I can really see with my eyes:
http://img96.imageshack.us/img96/1451/20130307171334.jpg
   
This is a similar snapshot b taken with mt9m131 in my board. It
shows that colours tend to be dull and darker, specially green:
http://img703.imageshack.us/img703/6025/testgo.jpg
   
Are the snapshots you take with your HW  more similar to a or to
b? Perhaps I am being too picky with the image quality and this is
all what mt9m131 can do?
   
I fear that my captures are closer to b. Your description of 3 was
giving
the impression of flashy colors. But the impression that this sensor 
gives
me is
rather a superimposed gray film. This effect is more or less visible
depending
on the lighting conditions, but it never seems to produce high quality
colors.
   
   Yes, yours is probably is the best description for the image quality
   this sensor provides with the current settings.
   Well, this is a bit disappointing. Let's see if some other user has a
   similar experience with it or comes up with a way to improve it.
   
   I've tested several things such as disabling auto white balance and
   auto exposure and try to manually change colour gains but it seems the
   sensor simply ignores the latter.
   
   There is an evaluation board  from Aptina
   (http://www.digikey.com/product-detail/es/MT9M131C12STCH%20ES/557-1251-ND/1643271)
   but, unfortunately, I don't have one of these available. It could be
   very useful to test the sensor with this board with the configuration
   Aptina recommends and see whether the grey layer effect still
   persists.
  
  It is perhaps also possible to find their recommended register settings
  somewhere without having this evaluation board.
 
 I just tested my mt9m131 camera on a i.MX31 board, if not this your email 
 I don't think I'd be alarmed by the image quality it's producing, maybe 
 I'm just less picky:-) And yes, in general I agree, I think, this level of 
 image quality tuning is difficult to achieve on modern cameras with 100s 
 of fine-tuning knobs. I'll try to re-test this camera in day light 
 conditions and post my best shot :)

http://download.open-technology.de/mt9m131/

.ppm is taken with mt9m131. Note, that I shot 10 frames and took the 3rd 
one - the first two are much darker, #3 is where autoexposure has kicked 
in, I suppose. Also note, that the comparison shot has been fired from a 
much smaller distance to cover a similar area due to obviously different 
lenses. I'll leave any colour-quality judgement to the reader(s) :-)

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: mt9m111/mt9m131: kernel 3.8 issues.

2013-03-11 Thread javier Martin
Hi Guennadi,

 I just tested my mt9m131 camera on a i.MX31 board, if not this your email
 I don't think I'd be alarmed by the image quality it's producing, maybe
 I'm just less picky:-) And yes, in general I agree, I think, this level of
 image quality tuning is difficult to achieve on modern cameras with 100s
 of fine-tuning knobs. I'll try to re-test this camera in day light
 conditions and post my best shot :)

 http://download.open-technology.de/mt9m131/

 .ppm is taken with mt9m131. Note, that I shot 10 frames and took the 3rd
 one - the first two are much darker, #3 is where autoexposure has kicked
 in, I suppose. Also note, that the comparison shot has been fired from a
 much smaller distance to cover a similar area due to obviously different
 lenses. I'll leave any colour-quality judgement to the reader(s) :-)

Thank you for your feedback. It seems that we all have a similar colour quality.
If Aptina comes up with better settings or I find them I'll post a
patch for you to test.

Regards.
-- 
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
--
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


[REVIEW PATCH 00/42] go7007: complete overhaul

2013-03-11 Thread Hans Verkuil
Hi all,

This patch series updates the staging go7007 driver to the latest
V4L2 frameworks and actually makes it work reliably.

Some highlights:

- moved the custom i2c drivers to media/i2c.
- replaced the s2250-loader by a common loader for all the supported
  devices.
- replaced all MPEG-related custom ioctls by standard ioctls and FMT
  support.
- added the saa7134-go7007 combination (similar to the saa7134-empress).

In addition I've made some V4L2 core and saa7115 changes (the first 6
patches):

- eliminate false lockdep warnings when dealing with nested control
  handlers. This patch is a slightly modified version from the one Andy
  posted a long time ago.
- add support to easily test if any subdevices support a particular operation.
- fix a few bugs in the code that tests if an ioctl is available: it didn't
  take 'disabling of ioctls' into account.
- added additional configuration flags to saa7115, needed by the go7007.
- improved querystd support in saa7115.

This driver now passes all v4l2-compliance tests.

Volokh, I've merged your tw2804 v4l2 framework cleanup patches into one
with my modifications on top. I hope you don't mind.

It has been tested with:

- Plextor PX-TV402U (PAL model)
- Sensoray S2250S (generously provided by Sensoray, all audio inputs
  now work!)
- Sensoray Model 614 (saa7134+go7007 PCI board, generously provided by
  Sensoray)
- WIS X-Men II sensor board (generously provided by Sensoray)
- Adlink PCI-MPG24 surveillance board

Everything seems to work OK, but for two things:

- the WIS X-Men and tthe S2250 do not honor requested frameperiod changes
  using S_PARM. The others work fine, and I have no idea why these work
  differently.
- the bttv part of the Adlink card doesn't work for me: I just get black
  with fuzzy lines. This doesn't work in 3.8 either, so I don't know
  what's going on here. It's not related to my patch series, that's for
  sure. Volokh, can you test it as well?

What needs to be done to get this driver out of staging? The main thing
is the motion detection support. Volokh has some addition code for that,
and I want to experiment with motion detection for this card and the
solo6x10 card and see if I can come up with a nice API for that.

It would also be nice to get the s2250-board.c code make use of the already
existing i2c devices, but it is hooked up somewhat strangely, so I need to
look at that some day.

I also need to look at the firmware licensing. I think it is all OK, but
I need to check. For now all the firmwares are available here:

http://hverkuil.home.xs4all.nl/go7007-fw.tar.bz2

Just unpack in /lib/firmware.

I've moved all firmwares into a single go7007 directory. And the old .hex
files have been converted into binary format that the cypress loader expects.

Pete, can you test this for your S2251 USB device?

This week I'll also receive a Plextor PX-M402U to test with and an ADS DVD
XPress DX2 is also on its way (I did some ebay shopping!).

I plan on posting the pull request this Friday, so let me know if there are
any issues.

BTW, my git tree is available here:

http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/go7007

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


[REVIEW PATCH 03/42] v4l2-ioctl: check if an ioctl is valid.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Just checking if the op exists isn't correct, you should check if the ioctl
is valid (which implies that the op exists as well).

One exception is g_std: if current_norm is non-zero, then the g_std op may be
absent. This sort of weird behavior is one of the reasons why I am trying to
get rid of current_norm.

This patch fixes the case where the g/s_std op is set, but these ioctls are
disabled. This can happen in drivers supporting multiple models, some that
have TV input (and support the STD API) and some that have a sensor (and do
not support the STD API). In the latter case qv4l2 would still show the
Standards combobox.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ioctl.c |   22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index aa6e7c7..b589c34 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -35,6 +35,8 @@
memset((u8 *)(p) + offsetof(typeof(*(p)), field) + sizeof((p)-field), \
0, sizeof(*(p)) - offsetof(typeof(*(p)), field) - sizeof((p)-field))
 
+#define is_valid_ioctl(vfd, cmd) test_bit(_IOC_NR(cmd), (vfd)-valid_ioctls)
+
 struct std_descr {
v4l2_std_id std;
const char *descr;
@@ -997,6 +999,7 @@ static int v4l_s_priority(const struct v4l2_ioctl_ops *ops,
 static int v4l_enuminput(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
 {
+   struct video_device *vfd = video_devdata(file);
struct v4l2_input *p = arg;
 
/*
@@ -1005,11 +1008,11 @@ static int v4l_enuminput(const struct v4l2_ioctl_ops 
*ops,
 * driver. If the driver doesn't support these
 * for a specific input, it must override these flags.
 */
-   if (ops-vidioc_s_std)
+   if (is_valid_ioctl(vfd, VIDIOC_S_STD))
p-capabilities |= V4L2_IN_CAP_STD;
-   if (ops-vidioc_s_dv_preset)
+   if (is_valid_ioctl(vfd, VIDIOC_S_DV_PRESET))
p-capabilities |= V4L2_IN_CAP_PRESETS;
-   if (ops-vidioc_s_dv_timings)
+   if (is_valid_ioctl(vfd, VIDIOC_S_DV_TIMINGS))
p-capabilities |= V4L2_IN_CAP_DV_TIMINGS;
 
return ops-vidioc_enum_input(file, fh, p);
@@ -1018,6 +1021,7 @@ static int v4l_enuminput(const struct v4l2_ioctl_ops *ops,
 static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
 {
+   struct video_device *vfd = video_devdata(file);
struct v4l2_output *p = arg;
 
/*
@@ -1026,11 +1030,11 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops 
*ops,
 * driver. If the driver doesn't support these
 * for a specific output, it must override these flags.
 */
-   if (ops-vidioc_s_std)
+   if (is_valid_ioctl(vfd, VIDIOC_S_STD))
p-capabilities |= V4L2_OUT_CAP_STD;
-   if (ops-vidioc_s_dv_preset)
+   if (is_valid_ioctl(vfd, VIDIOC_S_DV_PRESET))
p-capabilities |= V4L2_OUT_CAP_PRESETS;
-   if (ops-vidioc_s_dv_timings)
+   if (is_valid_ioctl(vfd, VIDIOC_S_DV_TIMINGS))
p-capabilities |= V4L2_OUT_CAP_DV_TIMINGS;
 
return ops-vidioc_enum_output(file, fh, p);
@@ -1513,7 +1517,7 @@ static int v4l_g_parm(const struct v4l2_ioctl_ops *ops,
p-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
return -EINVAL;
p-parm.capture.readbuffers = 2;
-   if (ops-vidioc_g_std)
+   if (is_valid_ioctl(vfd, VIDIOC_G_STD)  ops-vidioc_g_std)
ret = ops-vidioc_g_std(file, fh, std);
if (ret == 0)
v4l2_video_std_frame_period(std,
@@ -1873,7 +1877,7 @@ static int v4l_enum_freq_bands(const struct 
v4l2_ioctl_ops *ops,
return -EINVAL;
if (ops-vidioc_enum_freq_bands)
return ops-vidioc_enum_freq_bands(file, fh, p);
-   if (ops-vidioc_g_tuner) {
+   if (is_valid_ioctl(vfd, VIDIOC_G_TUNER)) {
struct v4l2_tuner t = {
.index = p-tuner,
.type = type,
@@ -1891,7 +1895,7 @@ static int v4l_enum_freq_bands(const struct 
v4l2_ioctl_ops *ops,
V4L2_BAND_MODULATION_FM : V4L2_BAND_MODULATION_VSB;
return 0;
}
-   if (ops-vidioc_g_modulator) {
+   if (is_valid_ioctl(vfd, VIDIOC_G_MODULATOR)) {
struct v4l2_modulator m = {
.index = p-tuner,
};
-- 
1.7.10.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


[REVIEW PATCH 04/42] saa7115: add config flag to change the IDQ polarity.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Needed by the go7007 driver: it assumes a different polarity of the IDQ
signal, so we need to be able to tell the saa7115 about this.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/saa7115.c |6 ++
 include/media/saa7115.h |   31 +--
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 6b6788c..f249b20 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -1259,6 +1259,12 @@ static int saa711x_s_routing(struct v4l2_subdev *sd,
(saa711x_read(sd, 
R_83_X_PORT_I_O_ENA_AND_OUT_CLK)  0xfe) |
(state-output  0x01));
}
+   if (state-ident  V4L2_IDENT_SAA7111A) {
+   if (config  SAA7115_IDQ_IS_DEFAULT)
+   saa711x_write(sd, R_85_I_PORT_SIGNAL_POLAR, 0x20);
+   else
+   saa711x_write(sd, R_85_I_PORT_SIGNAL_POLAR, 0x21);
+   }
return 0;
 }
 
diff --git a/include/media/saa7115.h b/include/media/saa7115.h
index bab2127..8b2ecc6 100644
--- a/include/media/saa7115.h
+++ b/include/media/saa7115.h
@@ -21,6 +21,8 @@
 #ifndef _SAA7115_H_
 #define _SAA7115_H_
 
+/* s_routing inputs, outputs, and config */
+
 /* SAA7111/3/4/5 HW inputs */
 #define SAA7115_COMPOSITE0 0
 #define SAA7115_COMPOSITE1 1
@@ -33,24 +35,33 @@
 #define SAA7115_SVIDEO28
 #define SAA7115_SVIDEO39
 
-/* SAA7115 v4l2_crystal_freq frequency values */
-#define SAA7115_FREQ_32_11_MHZ  3211   /* 32.11 MHz crystal, SAA7114/5 
only */
-#define SAA7115_FREQ_24_576_MHZ 24576000   /* 24.576 MHz crystal */
-
-/* SAA7115 v4l2_crystal_freq audio clock control flags */
-#define SAA7115_FREQ_FL_UCGC   (1  0)   /* SA 3A[7], UCGC, SAA7115 
only */
-#define SAA7115_FREQ_FL_CGCDIV (1  1)   /* SA 3A[6], CGCDIV, SAA7115 
only */
-#define SAA7115_FREQ_FL_APLL   (1  2)   /* SA 3A[3], APLL, SAA7114/5 
only */
-
+/* outputs */
 #define SAA7115_IPORT_ON   1
 #define SAA7115_IPORT_OFF  0
 
-/* SAA7111 specific output flags */
+/* SAA7111 specific outputs. */
 #define SAA7111_VBI_BYPASS 2
 #define SAA7111_FMT_YUV422  0x00
 #define SAA7111_FMT_RGB0x40
 #define SAA7111_FMT_CCIR   0x80
 #define SAA7111_FMT_YUV411 0xc0
 
+/* config flags */
+/* Register 0x85 should set bit 0 to 0 (it's 1 by default). This bit
+ * controls the IDQ signal polarity which is set to 'inverted' if the bit
+ * it 1 and to 'default' if it is 0. */
+#define SAA7115_IDQ_IS_DEFAULT  (1  0)
+
+/* s_crystal_freq values and flags */
+
+/* SAA7115 v4l2_crystal_freq frequency values */
+#define SAA7115_FREQ_32_11_MHZ  3211   /* 32.11 MHz crystal, SAA7114/5 
only */
+#define SAA7115_FREQ_24_576_MHZ 24576000   /* 24.576 MHz crystal */
+
+/* SAA7115 v4l2_crystal_freq audio clock control flags */
+#define SAA7115_FREQ_FL_UCGC   (1  0)   /* SA 3A[7], UCGC, SAA7115 
only */
+#define SAA7115_FREQ_FL_CGCDIV (1  1)   /* SA 3A[6], CGCDIV, SAA7115 
only */
+#define SAA7115_FREQ_FL_APLL   (1  2)   /* SA 3A[3], APLL, SAA7114/5 
only */
+
 #endif
 
-- 
1.7.10.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


[REVIEW PATCH 02/42] v4l2-core: add code to check for specific ops.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This patch adds a v4l2_subdev_has_op() macro and a v4l2_device_has_op macro to
quickly check if a specific subdev or any subdev supports a particular subdev
operation.

This makes it easy for drivers to disable certain ioctls if none of the subdevs
supports the necessary functionality.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 include/media/v4l2-device.h |   13 +
 include/media/v4l2-subdev.h |3 +++
 2 files changed, 16 insertions(+)

diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index d61febf..c9b1593 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -190,4 +190,17 @@ v4l2_device_register_subdev_nodes(struct v4l2_device 
*v4l2_dev);
##args);\
 })
 
+#define v4l2_device_has_op(v4l2_dev, o, f) \
+({ \
+   struct v4l2_subdev *__sd;   \
+   bool __result = false;  \
+   list_for_each_entry(__sd, (v4l2_dev)-subdevs, list) { \
+   if (v4l2_subdev_has_op(__sd, o, f)) {   \
+   __result = true;\
+   break;  \
+   }   \
+   }   \
+   __result;   \
+})
+
 #endif
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index b137a5e..0740c06 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -687,4 +687,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
((!(sd) || !(sd)-v4l2_dev || !(sd)-v4l2_dev-notify) ? -ENODEV : \
 (sd)-v4l2_dev-notify((sd), (notification), (arg)))
 
+#define v4l2_subdev_has_op(sd, o, f) \
+   ((sd)-ops-o  (sd)-ops-o-f)
+
 #endif
-- 
1.7.10.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


[REVIEW PATCH 01/42] v4l2-ctrls: eliminate lockdep false alarms for struct v4l2_ctrl_handler.lock

2013-03-11 Thread Hans Verkuil
From: Andy Walls awalls at

When calling v4l2_ctrl_add_handler(), lockdep would detect a potential
recursive locking problem on a situation that is by design intended and
not a recursive lock.  This happened because all struct
v4l2_ctrl_handler.lock mutexes were created as members of the same lock
class in v4l2_ctrl_handler_init(), and v4l2_ctrl_add_handler() takes the
hdl-lock on two different v4l2_ctrl_handler instances.

This change breaks the large lockdep lock class for struct
v4l2_ctrl_handler.lock and breaks it into v4l2_ctrl_handler
instantiation specific lock classes with meaningful class names.

This will validly eliminate lockdep alarms for v4l2_ctrl_handler locking
validation, as long as the relationships between drivers adding v4l2
controls to their own handler from other v4l2 drivers' control handlers
remains straightforward.

struct v4l2_ctrl_handler.lock lock classes are created with names such
that the output of cat /proc/lockdep indicates where in the v4l2 driver
code v4l2_ctrl_handle_init() is being called on instantiations:

a045f490 FD:   10 BD:8 +.+...: cx2341x:1534:(hdl)-lock
a0497d20 FD:   12 BD:2 +.+.+.: saa7115:1581:(hdl)-lock
a04ac660 FD:   14 BD:2 +.+.+.: msp3400_driver:756:(hdl)-lock
a0484b90 FD:   12 BD:1 +.+.+.: ivtv_gpio:366:(itv-hdl_gpio)-lock
a04eb530 FD:   11 BD:2 +.+.+.: cx25840_core:1982:(state-hdl)-lock
a04fbc80 FD:   11 BD:3 +.+.+.: wm8775:246:(state-hdl)-lock

Some lock chains, that were previously causing the recursion alarms, are
now visible in the output of cat /proc/lockdep_chains:

irq_context: 0
[a0497d20] saa7115:1581:(hdl)-lock
[a045f490] cx2341x:1534:(hdl)-lock

irq_context: 0
[a04ac660] msp3400_driver:756:(hdl)-lock
[a045f490] cx2341x:1534:(hdl)-lock

irq_context: 0
[a0484b90] ivtv_gpio:366:(itv-hdl_gpio)-lock
[a045f490] cx2341x:1534:(hdl)-lock

irq_context: 0
[a04eb530] cx25840_core:1982:(state-hdl)-lock
[a045f490] cx2341x:1534:(hdl)-lock

irq_context: 0
[a04fbc80] wm8775:246:(state-hdl)-lock
[a045f490] cx2341x:1534:(hdl)-lock

Signed-off-by: Andy Walls awalls at md.metrocast.net
[hans.verk...@cisco.com: keep mutex_init in v4l2_ctrl_handler_init_class]
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c |8 +---
 include/media/v4l2-ctrls.h   |   29 ++---
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 6b28b58..b36d1ec 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1362,11 +1362,13 @@ static inline int handler_set_err(struct 
v4l2_ctrl_handler *hdl, int err)
 }
 
 /* Initialize the handler */
-int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl,
-  unsigned nr_of_controls_hint)
+int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
+unsigned nr_of_controls_hint,
+struct lock_class_key *key, const char *name)
 {
hdl-lock = hdl-_lock;
mutex_init(hdl-lock);
+   lockdep_set_class_and_name(hdl-lock, key, name);
INIT_LIST_HEAD(hdl-ctrls);
INIT_LIST_HEAD(hdl-ctrl_refs);
hdl-nr_of_buckets = 1 + nr_of_controls_hint / 8;
@@ -1375,7 +1377,7 @@ int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl,
hdl-error = hdl-buckets ? 0 : -ENOMEM;
return hdl-error;
 }
-EXPORT_SYMBOL(v4l2_ctrl_handler_init);
+EXPORT_SYMBOL(v4l2_ctrl_handler_init_class);
 
 /* Free all controls and control refs */
 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index f00d42b..7343a27 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -259,7 +259,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags);
 
 
-/** v4l2_ctrl_handler_init() - Initialize the control handler.
+/** v4l2_ctrl_handler_init_class() - Initialize the control handler.
   * @hdl:  The control handler.
   * @nr_of_controls_hint: A hint of how many controls this handler is
   *expected to refer to. This is the total number, so including
@@ -268,12 +268,35 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
   *are allocated) or the control lookup becomes slower (not enough
   *buckets are allocated, so there are more slow list lookups).
   *It will always work, though.
+  * @key:  Used by the lock validator if CONFIG_LOCKDEP is set.
+  * @name: Used by the lock validator if CONFIG_LOCKDEP is set.
   *
   * Returns an error if the buckets could not be allocated. This error will
   * also be stored in @hdl-error.

[REVIEW PATCH 08/42] tuner: add Sony BTF tuners

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This adds support for three Sony BTF tuners:

TUNER_SONY_BTF_PG472Z: PAL+SECAM
TUNER_SONY_BTF_PK467Z: NTSC-M-JP
TUNER_SONY_BTF_PB463Z: NTSC-M

These come from the go7007 staging driver where they were implemented in
the wis-sony-tuner i2c driver.

Adding support for these tuners to tuner-types.c is the first step towards
removing the wis-sony-tuner driver.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/CARDLIST.tuner   |3 ++
 drivers/media/tuners/tuner-types.c |   69 
 drivers/staging/media/go7007/go7007-usb.c  |1 +
 drivers/staging/media/go7007/go7007-v4l2.c |1 +
 drivers/staging/media/go7007/wis-i2c.h |6 ---
 include/media/tuner.h  |4 ++
 6 files changed, 78 insertions(+), 6 deletions(-)

diff --git a/Documentation/video4linux/CARDLIST.tuner 
b/Documentation/video4linux/CARDLIST.tuner
index c83f6e4..5b83a3f 100644
--- a/Documentation/video4linux/CARDLIST.tuner
+++ b/Documentation/video4linux/CARDLIST.tuner
@@ -86,3 +86,6 @@ tuner=85 - Philips FQ1236 MK5
 tuner=86 - Tena TNF5337 MFD
 tuner=87 - Xceive 4000 tuner
 tuner=88 - Xceive 5000C tuner
+tuner=89 - Sony PAL+SECAM (BTF-PG472Z)
+tuner=90 - Sony NTSC-M-JP (BTF-PK467Z)
+tuner=91 - Sony NTSC-M (BTF-PB463Z)
diff --git a/drivers/media/tuners/tuner-types.c 
b/drivers/media/tuners/tuner-types.c
index 2da4440..98bc15a 100644
--- a/drivers/media/tuners/tuner-types.c
+++ b/drivers/media/tuners/tuner-types.c
@@ -1381,6 +1381,58 @@ static struct tuner_params 
tuner_philips_fq1236_mk5_params[] = {
},
 };
 
+/* - Sony BTF-PG472Z PAL/SECAM --- */
+
+static struct tuner_range tuner_sony_btf_pg472z_ranges[] = {
+   { 16 * 144.25 /*MHz*/, 0xc6, 0x01, },
+   { 16 * 427.25 /*MHz*/, 0xc6, 0x02, },
+   { 16 * 999.99, 0xc6, 0x04, },
+};
+
+static struct tuner_params tuner_sony_btf_pg472z_params[] = {
+   {
+   .type   = TUNER_PARAM_TYPE_PAL,
+   .ranges = tuner_sony_btf_pg472z_ranges,
+   .count  = ARRAY_SIZE(tuner_sony_btf_pg472z_ranges),
+   .has_tda9887 = 1,
+   .port1_active = 1,
+   .port2_invert_for_secam_lc = 1,
+   },
+};
+
+/* 90-99 */
+/* - Sony BTF-PG467Z NTSC-M-JP --- */
+
+static struct tuner_range tuner_sony_btf_pg467z_ranges[] = {
+   { 16 * 220.25 /*MHz*/, 0xc6, 0x01, },
+   { 16 * 467.25 /*MHz*/, 0xc6, 0x02, },
+   { 16 * 999.99, 0xc6, 0x04, },
+};
+
+static struct tuner_params tuner_sony_btf_pg467z_params[] = {
+   {
+   .type   = TUNER_PARAM_TYPE_NTSC,
+   .ranges = tuner_sony_btf_pg467z_ranges,
+   .count  = ARRAY_SIZE(tuner_sony_btf_pg467z_ranges),
+   },
+};
+
+/* - Sony BTF-PG463Z NTSC-M --- */
+
+static struct tuner_range tuner_sony_btf_pg463z_ranges[] = {
+   { 16 * 130.25 /*MHz*/, 0xc6, 0x01, },
+   { 16 * 364.25 /*MHz*/, 0xc6, 0x02, },
+   { 16 * 999.99, 0xc6, 0x04, },
+};
+
+static struct tuner_params tuner_sony_btf_pg463z_params[] = {
+   {
+   .type   = TUNER_PARAM_TYPE_NTSC,
+   .ranges = tuner_sony_btf_pg463z_ranges,
+   .count  = ARRAY_SIZE(tuner_sony_btf_pg463z_ranges),
+   },
+};
+
 /* - */
 
 struct tunertype tuners[] = {
@@ -1872,6 +1924,23 @@ struct tunertype tuners[] = {
.name   = Xceive 5000C tuner,
/* see xc5000.c for details */
},
+   [TUNER_SONY_BTF_PG472Z] = {
+   .name   = Sony BTF-PG472Z PAL/SECAM,
+   .params = tuner_sony_btf_pg472z_params,
+   .count  = ARRAY_SIZE(tuner_sony_btf_pg472z_params),
+   },
+
+   /* 90-99 */
+   [TUNER_SONY_BTF_PK467Z] = {
+   .name   = Sony BTF-PK467Z NTSC-M-JP,
+   .params = tuner_sony_btf_pg467z_params,
+   .count  = ARRAY_SIZE(tuner_sony_btf_pg467z_params),
+   },
+   [TUNER_SONY_BTF_PB463Z] = {
+   .name   = Sony BTF-PB463Z NTSC-M,
+   .params = tuner_sony_btf_pg463z_params,
+   .count  = ARRAY_SIZE(tuner_sony_btf_pg463z_params),
+   },
 };
 EXPORT_SYMBOL(tuners);
 
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 914b247..a8f 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -27,6 +27,7 @@
 #include linux/i2c.h
 #include asm/byteorder.h
 #include media/tvaudio.h
+#include media/tuner.h
 
 #include go7007-priv.h
 #include wis-i2c.h
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index cb9fe33..e115132 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -1238,6 +1238,7 @@ static int vidioc_g_tuner(struct file 

[REVIEW PATCH 05/42] saa7115: improve querystd handling for the saa7115.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The saa7115 has better PAL/NTSC detection, so it can detect PAL even
though the chip is currently set up for NTSC.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/saa7115.c |   56 +--
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index f249b20..d301442 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -1360,6 +1360,34 @@ static int saa711x_querystd(struct v4l2_subdev *sd, 
v4l2_std_id *std)
 */
 
reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC);
+
+   if (state-ident == V4L2_IDENT_SAA7115) {
+   reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC);
+
+   v4l2_dbg(1, debug, sd, Status byte 1 (0x1e)=0x%02x\n, reg1e);
+
+   switch (reg1e  0x03) {
+   case 1:
+   *std = V4L2_STD_NTSC;
+   break;
+   case 2:
+   /*
+* V4L2_STD_PAL just cover the european PAL standards.
+* This is wrong, as the device could also be using an
+* other PAL standard.
+*/
+   *std = V4L2_STD_PAL   | V4L2_STD_PAL_N  | 
V4L2_STD_PAL_Nc |
+   V4L2_STD_PAL_M | V4L2_STD_PAL_60;
+   break;
+   case 3:
+   *std = V4L2_STD_SECAM;
+   break;
+   default:
+   /* Can't detect anything */
+   break;
+   }
+   }
+
v4l2_dbg(1, debug, sd, Status byte 2 (0x1f)=0x%02x\n, reg1f);
 
/* horizontal/vertical not locked */
@@ -1371,34 +1399,6 @@ static int saa711x_querystd(struct v4l2_subdev *sd, 
v4l2_std_id *std)
else
*std = V4L2_STD_625_50;
 
-   if (state-ident != V4L2_IDENT_SAA7115)
-   goto ret;
-
-   reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC);
-
-   switch (reg1e  0x03) {
-   case 1:
-   *std = V4L2_STD_NTSC;
-   break;
-   case 2:
-   /*
-* V4L2_STD_PAL just cover the european PAL standards.
-* This is wrong, as the device could also be using an
-* other PAL standard.
-*/
-   *std = V4L2_STD_PAL   | V4L2_STD_PAL_N  | V4L2_STD_PAL_Nc |
-   V4L2_STD_PAL_M | V4L2_STD_PAL_60;
-   break;
-   case 3:
-   *std = V4L2_STD_SECAM;
-   break;
-   default:
-   /* Can't detect anything */
-   break;
-   }
-
-   v4l2_dbg(1, debug, sd, Status byte 1 (0x1e)=0x%02x\n, reg1e);
-
 ret:
v4l2_dbg(1, debug, sd, detected std mask = %08Lx\n, *std);
 
-- 
1.7.10.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


[REVIEW PATCH 06/42] saa7115: add support for double-rate ASCLK

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Some devices expect a double rate ASCLK. Add a flag to let the driver know
through the s_crystal_freq call.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/saa7115.c |   16 +++-
 include/media/saa7115.h |7 ---
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index d301442..9d3dbb3 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -83,9 +83,10 @@ struct saa711x_state {
u32 ident;
u32 audclk_freq;
u32 crystal_freq;
-   u8 ucgc;
+   bool ucgc;
u8 cgcdiv;
-   u8 apll;
+   bool apll;
+   bool double_asclk;
 };
 
 static inline struct saa711x_state *to_state(struct v4l2_subdev *sd)
@@ -732,8 +733,12 @@ static int saa711x_s_clock_freq(struct v4l2_subdev *sd, 
u32 freq)
if (state-apll)
acc |= 0x08;
 
+   if (state-double_asclk) {
+   acpf = 1;
+   acni = 1;
+   }
saa711x_write(sd, R_38_CLK_RATIO_AMXCLK_TO_ASCLK, 0x03);
-   saa711x_write(sd, R_39_CLK_RATIO_ASCLK_TO_ALRCLK, 0x10);
+   saa711x_write(sd, R_39_CLK_RATIO_ASCLK_TO_ALRCLK, 0x10  
state-double_asclk);
saa711x_write(sd, R_3A_AUD_CLK_GEN_BASIC_SETUP, acc);
 
saa711x_write(sd, R_30_AUD_MAST_CLK_CYCLES_PER_FIELD, acpf  0xff);
@@ -1302,9 +1307,10 @@ static int saa711x_s_crystal_freq(struct v4l2_subdev 
*sd, u32 freq, u32 flags)
if (freq != SAA7115_FREQ_32_11_MHZ  freq != SAA7115_FREQ_24_576_MHZ)
return -EINVAL;
state-crystal_freq = freq;
+   state-double_asclk = flags  SAA7115_FREQ_FL_DOUBLE_ASCLK;
state-cgcdiv = (flags  SAA7115_FREQ_FL_CGCDIV) ? 3 : 4;
-   state-ucgc = (flags  SAA7115_FREQ_FL_UCGC) ? 1 : 0;
-   state-apll = (flags  SAA7115_FREQ_FL_APLL) ? 1 : 0;
+   state-ucgc = flags  SAA7115_FREQ_FL_UCGC;
+   state-apll = flags  SAA7115_FREQ_FL_APLL;
saa711x_s_clock_freq(sd, state-audclk_freq);
return 0;
 }
diff --git a/include/media/saa7115.h b/include/media/saa7115.h
index 8b2ecc6..4079186 100644
--- a/include/media/saa7115.h
+++ b/include/media/saa7115.h
@@ -59,9 +59,10 @@
 #define SAA7115_FREQ_24_576_MHZ 24576000   /* 24.576 MHz crystal */
 
 /* SAA7115 v4l2_crystal_freq audio clock control flags */
-#define SAA7115_FREQ_FL_UCGC   (1  0)   /* SA 3A[7], UCGC, SAA7115 
only */
-#define SAA7115_FREQ_FL_CGCDIV (1  1)   /* SA 3A[6], CGCDIV, SAA7115 
only */
-#define SAA7115_FREQ_FL_APLL   (1  2)   /* SA 3A[3], APLL, SAA7114/5 
only */
+#define SAA7115_FREQ_FL_UCGC (1  0) /* SA 3A[7], UCGC, SAA7115 only 
*/
+#define SAA7115_FREQ_FL_CGCDIV   (1  1) /* SA 3A[6], CGCDIV, SAA7115 
only */
+#define SAA7115_FREQ_FL_APLL (1  2) /* SA 3A[3], APLL, SAA7114/5 
only */
+#define SAA7115_FREQ_FL_DOUBLE_ASCLK (1  3) /* SA 39, LRDIV, SAA7114/5 only 
*/
 
 #endif
 
-- 
1.7.10.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


[REVIEW PATCH 13/42] tw2804: add support for the Techwell tw2804.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This is based on the wis-tw2804.c driver that's part of the go7007 driver.
It has been converted to a v4l subdev driver by Volokh Konstantin, and I
made additional cleanups.

Based on work by: Volokh Konstantin volok...@gmail.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Cc: Volokh Konstantin volok...@gmail.com
---
 drivers/media/i2c/Kconfig  |   11 +-
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/tw2804.c |  467 
 3 files changed, 478 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/i2c/tw2804.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index eb9ef55..4c03684 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -301,11 +301,20 @@ config VIDEO_TVP7002
  To compile this driver as a module, choose M here: the
  module will be called tvp7002.
 
+config VIDEO_TW2804
+   tristate Techwell TW2804 multiple video decoder
+   depends on VIDEO_V4L2  I2C
+   ---help---
+ Support for the Techwell tw2804 multiple video decoder.
+
+ To compile this driver as a module, choose M here: the
+ module will be called tw2804.
+
 config VIDEO_TW9903
tristate Techwell TW9903 video decoder
depends on VIDEO_V4L2  I2C
---help---
- Support for the Techwell 9903 multi-standard video decoder
+ Support for the Techwell tw9903 multi-standard video decoder
  with high quality down scaler.
 
  To compile this driver as a module, choose M here: the
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index af8fb29..399050a 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_VIDEO_THS7303) += ths7303.o
 obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
 obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
 obj-$(CONFIG_VIDEO_TVP7002) += tvp7002.o
+obj-$(CONFIG_VIDEO_TW2804) += tw2804.o
 obj-$(CONFIG_VIDEO_TW9903) += tw9903.o
 obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
 obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
diff --git a/drivers/media/i2c/tw2804.c b/drivers/media/i2c/tw2804.c
new file mode 100644
index 000..4bb5ba6
--- /dev/null
+++ b/drivers/media/i2c/tw2804.c
@@ -0,0 +1,467 @@
+/*
+ * Copyright (C) 2005-2006 Micronas USA Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/i2c.h
+#include linux/videodev2.h
+#include linux/ioctl.h
+#include linux/slab.h
+#include media/v4l2-subdev.h
+#include media/v4l2-device.h
+#include media/v4l2-chip-ident.h
+#include media/v4l2-ctrls.h
+
+#define TW2804_REG_AUTOGAIN0x02
+#define TW2804_REG_HUE 0x0f
+#define TW2804_REG_SATURATION  0x10
+#define TW2804_REG_CONTRAST0x11
+#define TW2804_REG_BRIGHTNESS  0x12
+#define TW2804_REG_COLOR_KILLER0x14
+#define TW2804_REG_GAIN0x3c
+#define TW2804_REG_CHROMA_GAIN 0x3d
+#define TW2804_REG_BLUE_BALANCE0x3e
+#define TW2804_REG_RED_BALANCE 0x3f
+
+struct tw2804 {
+   struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+   u8 channel:2;
+   u8 input:1;
+   int norm;
+};
+
+static const u8 global_registers[] = {
+   0x39, 0x00,
+   0x3a, 0xff,
+   0x3b, 0x84,
+   0x3c, 0x80,
+   0x3d, 0x80,
+   0x3e, 0x82,
+   0x3f, 0x82,
+   0xff, 0xff, /* Terminator (reg 0xff does not exist) */
+};
+
+static const u8 channel_registers[] = {
+   0x01, 0xc4,
+   0x02, 0xa5,
+   0x03, 0x20,
+   0x04, 0xd0,
+   0x05, 0x20,
+   0x06, 0xd0,
+   0x07, 0x88,
+   0x08, 0x20,
+   0x09, 0x07,
+   0x0a, 0xf0,
+   0x0b, 0x07,
+   0x0c, 0xf0,
+   0x0d, 0x40,
+   0x0e, 0xd2,
+   0x0f, 0x80,
+   0x10, 0x80,
+   0x11, 0x80,
+   0x12, 0x80,
+   0x13, 0x1f,
+   0x14, 0x00,
+   0x15, 0x00,
+   0x16, 0x00,
+   0x17, 0x00,
+   0x18, 0xff,
+   0x19, 0xff,
+   0x1a, 0xff,
+   0x1b, 0xff,
+   0x1c, 0xff,
+   0x1d, 0xff,
+   0x1e, 0xff,
+   0x1f, 0xff,
+   0x20, 0x07,
+   0x21, 0x07,
+   0x22, 0x00,
+   0x23, 0x91,
+   0x24, 0x51,
+   0x25, 0x03,
+   0x26, 0x00,
+   0x27, 0x00,
+   

[REVIEW PATCH 09/42] sony-btf-mpx: the MPX driver for the sony BTF PAL/SECAM tuner

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The Sony BTF PG472Z has an internal MPX to deal with mono/stereo/bilingual
audio. This is split off from the wis-sony-tuner driver that is part of
the go7007 driver as it should be a separate i2c sub-device driver.

The wis-sony-tuner is really three i2c devices: a standard tuner, a tda9887
compatible demodulator and this mpx. After this patch the wis-sony-tuner
can be replaced by this driver and the standard tuner driver.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/Kconfig|   11 +-
 drivers/media/i2c/Makefile   |1 +
 drivers/media/i2c/sony-btf-mpx.c |  399 ++
 3 files changed, 410 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/i2c/sony-btf-mpx.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 7b771ba..70dbae2 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -133,7 +133,7 @@ config VIDEO_WM8739
  module will be called wm8739.
 
 config VIDEO_VP27SMPX
-   tristate Panasonic VP27s internal MPX
+   tristate Panasonic VP27's internal MPX
depends on VIDEO_V4L2  I2C
---help---
  Support for the internal MPX of the Panasonic VP27s tuner.
@@ -141,6 +141,15 @@ config VIDEO_VP27SMPX
  To compile this driver as a module, choose M here: the
  module will be called vp27smpx.
 
+config VIDEO_SONY_BTF_MPX
+   tristate Sony BTF's internal MPX
+   depends on VIDEO_V4L2  I2C
+   help
+ Support for the internal MPX of the Sony BTF-PG472Z tuner.
+
+ To compile this driver as a module, choose M here: the
+ module will be called sony-btf-mpx.
+
 comment RDS decoders
 
 config VIDEO_SAA6588
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index cfefd30..4c57075 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_VIDEO_TLV320AIC23B) += tlv320aic23b.o
 obj-$(CONFIG_VIDEO_WM8775) += wm8775.o
 obj-$(CONFIG_VIDEO_WM8739) += wm8739.o
 obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
+obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
diff --git a/drivers/media/i2c/sony-btf-mpx.c b/drivers/media/i2c/sony-btf-mpx.c
new file mode 100644
index 000..bc73e8f
--- /dev/null
+++ b/drivers/media/i2c/sony-btf-mpx.c
@@ -0,0 +1,399 @@
+/*
+ * Copyright (C) 2005-2006 Micronas USA Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/i2c.h
+#include linux/videodev2.h
+#include media/tuner.h
+#include media/v4l2-common.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-device.h
+#include linux/slab.h
+
+MODULE_DESCRIPTION(sony-btf-mpx driver);
+MODULE_LICENSE(GPL v2);
+
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, debug level 0=off(default) 1=on\n);
+
+/* #define MPX_DEBUG */
+
+/*
+ * Note:
+ *
+ * AS(IF/MPX) pin:  LOW  HIGH/OPEN
+ * IF/MPX address:   0x42/0x40   0x43/0x44
+ */
+
+
+static int force_mpx_mode = -1;
+module_param(force_mpx_mode, int, 0644);
+
+struct sony_btf_mpx {
+   struct v4l2_subdev sd;
+   int mpxmode;
+   u32 audmode;
+};
+
+static inline struct sony_btf_mpx *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct sony_btf_mpx, sd);
+}
+
+static int mpx_write(struct i2c_client *client, int dev, int addr, int val)
+{
+   u8 buffer[5];
+   struct i2c_msg msg;
+
+   buffer[0] = dev;
+   buffer[1] = addr  8;
+   buffer[2] = addr  0xff;
+   buffer[3] = val  8;
+   buffer[4] = val  0xff;
+   msg.addr = client-addr;
+   msg.flags = 0;
+   msg.len = 5;
+   msg.buf = buffer;
+   i2c_transfer(client-adapter, msg, 1);
+   return 0;
+}
+
+/*
+ * MPX register values for the BTF-PG472Z:
+ *
+ * FM_ NICAM_  SCART_
+ *  MODUS  SOURCEACB   PRESCAL PRESCAL PRESCAL SYSTEM  VOLUME
+ * 10/0030 12/0008 12/0013 12/000E 12/0010 12/ 10/0020 12/
+ * ---
+ * Auto 1003002001002603500000017500
+ *
+ * B/G
+ *  Mono 

[REVIEW PATCH 23/42] go7007: remember boot firmware.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Don't load it everytime you stop encoding. Instead remember it.
Another reason for not loading it every time is that this could
be called from within the release() file operation, which turns
out to be deadly.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c |   43 +-
 drivers/staging/media/go7007/go7007-priv.h   |2 ++
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index 09d0ef4..db9a4b3 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -95,34 +95,34 @@ static int go7007_load_encoder(struct go7007 *go)
int fw_len, rv = 0;
u16 intr_val, intr_data;
 
-   if (request_firmware(fw_entry, fw_name, go-dev)) {
-   v4l2_err(go, unable to load firmware from file 
-   \%s\\n, fw_name);
-   return -1;
-   }
-   if (fw_entry-size  16 || memcmp(fw_entry-data, WISGO7007FW, 11)) {
-   v4l2_err(go, file \%s\ does not appear to be 
-   go7007 firmware\n, fw_name);
-   release_firmware(fw_entry);
-   return -1;
-   }
-   fw_len = fw_entry-size - 16;
-   bounce = kmemdup(fw_entry-data + 16, fw_len, GFP_KERNEL);
-   if (bounce == NULL) {
-   v4l2_err(go, unable to allocate %d bytes for 
-   firmware transfer\n, fw_len);
+   if (go-boot_fw == NULL) {
+   if (request_firmware(fw_entry, fw_name, go-dev)) {
+   v4l2_err(go, unable to load firmware from file 
\%s\\n, fw_name);
+   return -1;
+   }
+   if (fw_entry-size  16 || memcmp(fw_entry-data, 
WISGO7007FW, 11)) {
+   v4l2_err(go, file \%s\ does not appear to be go7007 
firmware\n, fw_name);
+   release_firmware(fw_entry);
+   return -1;
+   }
+   fw_len = fw_entry-size - 16;
+   bounce = kmemdup(fw_entry-data + 16, fw_len, GFP_KERNEL);
+   if (bounce == NULL) {
+   v4l2_err(go, unable to allocate %d bytes for firmware 
transfer\n, fw_len);
+   release_firmware(fw_entry);
+   return -1;
+   }
release_firmware(fw_entry);
-   return -1;
+   go-boot_fw_len = fw_len;
+   go-boot_fw = bounce;
}
-   release_firmware(fw_entry);
if (go7007_interface_reset(go)  0 ||
-   go7007_send_firmware(go, bounce, fw_len)  0 ||
-   go7007_read_interrupt(go, intr_val, intr_data)  0 ||
+   go7007_send_firmware(go, go-boot_fw, go-boot_fw_len)  0 ||
+   go7007_read_interrupt(go, intr_val, intr_data)  0 ||
(intr_val  ~0x1) != 0x5a5a) {
v4l2_err(go, error transferring firmware\n);
rv = -1;
}
-   kfree(bounce);
return rv;
 }
 
@@ -675,6 +675,7 @@ void go7007_remove(struct go7007 *go)
 
if (go-audio_enabled)
go7007_snd_remove(go);
+   kfree(go-boot_fw);
go7007_v4l2_remove(go);
 }
 EXPORT_SYMBOL(go7007_remove);
diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index daae6dd..d390120 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -178,6 +178,8 @@ struct go7007 {
int channel_number; /* for multi-channel boards like Adlink PCI-MPG24 */
char name[64];
struct video_device *video_dev;
+   void *boot_fw;
+   unsigned boot_fw_len;
struct v4l2_device v4l2_dev;
int ref_count;
enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status;
-- 
1.7.10.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


[REVIEW PATCH 24/42] go7007: fix unregister/disconnect handling.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

- use the v4l2_device's release() callback
- remove the unnecessary ref_count
- don't free usb data structures on disconnect, only do that in the final
  release callback.

This is the correct way in order to safely handle disconnect and removal
of modules.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c  |   63 +---
 drivers/staging/media/go7007/go7007-priv.h|4 +-
 drivers/staging/media/go7007/go7007-usb.c |   64 +++--
 drivers/staging/media/go7007/go7007-v4l2.c|   22 +
 drivers/staging/media/go7007/saa7134-go7007.c |7 ++-
 drivers/staging/media/go7007/snd-go7007.c |5 +-
 6 files changed, 85 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index db9a4b3..dca85d8 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -221,6 +221,31 @@ static int init_i2c_module(struct i2c_adapter *adapter, 
const struct go_i2c *con
 }
 
 /*
+ * Detach and unregister the encoder.  The go7007 struct won't be freed
+ * until v4l2 finishes releasing its resources and all associated fds are
+ * closed by applications.
+ */
+static void go7007_remove(struct v4l2_device *v4l2_dev)
+{
+   struct go7007 *go = container_of(v4l2_dev, struct go7007, v4l2_dev);
+
+   v4l2_device_unregister(v4l2_dev);
+   if (go-hpi_ops-release)
+   go-hpi_ops-release(go);
+   if (go-i2c_adapter_online) {
+   if (i2c_del_adapter(go-i2c_adapter) == 0)
+   go-i2c_adapter_online = 0;
+   else
+   v4l2_err(go-v4l2_dev,
+   error removing I2C adapter!\n);
+   }
+
+   kfree(go-boot_fw);
+   go7007_v4l2_remove(go);
+   kfree(go);
+}
+
+/*
  * Finalize the GO7007 hardware setup, register the on-board I2C adapter
  * (if used on this board), load the I2C client driver for the sensor
  * (SAA7115 or whatever) and other devices, and register the ALSA and V4L2
@@ -234,17 +259,17 @@ int go7007_register_encoder(struct go7007 *go, unsigned 
num_i2c_devs)
 
dev_info(go-dev, go7007: registering new %s\n, go-name);
 
+   go-v4l2_dev.release = go7007_remove;
+   ret = v4l2_device_register(go-dev, go-v4l2_dev);
+   if (ret  0)
+   return ret;
+
mutex_lock(go-hw_lock);
ret = go7007_init_encoder(go);
mutex_unlock(go-hw_lock);
if (ret  0)
return -1;
 
-   /* v4l2 init must happen before i2c subdevs */
-   ret = go7007_v4l2_init(go);
-   if (ret  0)
-   return ret;
-
if (!go-i2c_adapter_online 
go-board_info-flags  GO7007_BOARD_USE_ONBOARD_I2C) {
if (go7007_i2c_init(go)  0)
@@ -269,6 +294,11 @@ int go7007_register_encoder(struct go7007 *go, unsigned 
num_i2c_devs)
v4l2_subdev_call(go-sd_video, video, s_routing,
0, 0, go-channel_number + 1);
}
+
+   ret = go7007_v4l2_init(go);
+   if (ret  0)
+   return ret;
+
if (go-board_info-flags  GO7007_BOARD_HAS_AUDIO) {
go-audio_enabled = 1;
go7007_snd_init(go);
@@ -608,7 +638,6 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
init_waitqueue_head(go-frame_waitq);
spin_lock_init(go-spinlock);
go-video_dev = NULL;
-   go-ref_count = 0;
go-status = STATUS_INIT;
memset(go-i2c_adapter, 0, sizeof(go-i2c_adapter));
go-i2c_adapter_online = 0;
@@ -658,26 +687,4 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
 }
 EXPORT_SYMBOL(go7007_alloc);
 
-/*
- * Detach and unregister the encoder.  The go7007 struct won't be freed
- * until v4l2 finishes releasing its resources and all associated fds are
- * closed by applications.
- */
-void go7007_remove(struct go7007 *go)
-{
-   if (go-i2c_adapter_online) {
-   if (i2c_del_adapter(go-i2c_adapter) == 0)
-   go-i2c_adapter_online = 0;
-   else
-   v4l2_err(go-v4l2_dev,
-   error removing I2C adapter!\n);
-   }
-
-   if (go-audio_enabled)
-   go7007_snd_remove(go);
-   kfree(go-boot_fw);
-   go7007_v4l2_remove(go);
-}
-EXPORT_SYMBOL(go7007_remove);
-
 MODULE_LICENSE(GPL v2);
diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index d390120..54cfc0a 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -117,6 +117,7 @@ struct go7007_hpi_ops {
int (*stream_stop)(struct go7007 *go);
int (*send_firmware)(struct go7007 *go, u8 

[REVIEW PATCH 26/42] s2250: convert to the control framework.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/s2250-board.c |  149 +---
 1 file changed, 46 insertions(+), 103 deletions(-)

diff --git a/drivers/staging/media/go7007/s2250-board.c 
b/drivers/staging/media/go7007/s2250-board.c
index 2266e1b..5899513 100644
--- a/drivers/staging/media/go7007/s2250-board.c
+++ b/drivers/staging/media/go7007/s2250-board.c
@@ -116,6 +116,7 @@ static u16 vid_regs_fp_pal[] = {
 
 struct s2250 {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
v4l2_std_id std;
int input;
int brightness;
@@ -370,110 +371,36 @@ static int s2250_s_std(struct v4l2_subdev *sd, 
v4l2_std_id norm)
return 0;
 }
 
-static int s2250_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl 
*query)
+static int s2250_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   switch (query-id) {
-   case V4L2_CID_BRIGHTNESS:
-   return v4l2_ctrl_query_fill(query, 0, 100, 1, 50);
-   case V4L2_CID_CONTRAST:
-   return v4l2_ctrl_query_fill(query, 0, 100, 1, 50);
-   case V4L2_CID_SATURATION:
-   return v4l2_ctrl_query_fill(query, 0, 100, 1, 50);
-   case V4L2_CID_HUE:
-   return v4l2_ctrl_query_fill(query, -50, 50, 1, 0);
-   default:
-   return -EINVAL;
-   }
-   return 0;
-}
-
-static int s2250_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct s2250 *state = to_state(sd);
-   struct i2c_client *client = v4l2_get_subdevdata(sd);
-   int value1;
+   struct s2250 *state = container_of(ctrl-handler, struct s2250, hdl);
+   struct i2c_client *client = v4l2_get_subdevdata(state-sd);
u16 oldvalue;
 
switch (ctrl-id) {
case V4L2_CID_BRIGHTNESS:
-   if (ctrl-value  100)
-   state-brightness = 100;
-   else if (ctrl-value  0)
-   state-brightness = 0;
-   else
-   state-brightness = ctrl-value;
-   value1 = (state-brightness - 50) * 255 / 100;
read_reg_fp(client, VPX322_ADDR_BRIGHTNESS0, oldvalue);
write_reg_fp(client, VPX322_ADDR_BRIGHTNESS0,
-value1 | (oldvalue  ~0xff));
+ctrl-val | (oldvalue  ~0xff));
read_reg_fp(client, VPX322_ADDR_BRIGHTNESS1, oldvalue);
write_reg_fp(client, VPX322_ADDR_BRIGHTNESS1,
-value1 | (oldvalue  ~0xff));
+ctrl-val | (oldvalue  ~0xff));
write_reg_fp(client, 0x140, 0x60);
break;
case V4L2_CID_CONTRAST:
-   if (ctrl-value  100)
-   state-contrast = 100;
-   else if (ctrl-value  0)
-   state-contrast = 0;
-   else
-   state-contrast = ctrl-value;
-   value1 = state-contrast * 0x40 / 100;
-   if (value1  0x3f)
-   value1 = 0x3f; /* max */
read_reg_fp(client, VPX322_ADDR_CONTRAST0, oldvalue);
write_reg_fp(client, VPX322_ADDR_CONTRAST0,
-value1 | (oldvalue  ~0x3f));
+ctrl-val | (oldvalue  ~0x3f));
read_reg_fp(client, VPX322_ADDR_CONTRAST1, oldvalue);
write_reg_fp(client, VPX322_ADDR_CONTRAST1,
-value1 | (oldvalue  ~0x3f));
+ctrl-val | (oldvalue  ~0x3f));
write_reg_fp(client, 0x140, 0x60);
break;
case V4L2_CID_SATURATION:
-   if (ctrl-value  100)
-   state-saturation = 100;
-   else if (ctrl-value  0)
-   state-saturation = 0;
-   else
-   state-saturation = ctrl-value;
-   value1 = state-saturation * 4140 / 100;
-   if (value1  4094)
-   value1 = 4094;
-   write_reg_fp(client, VPX322_ADDR_SAT, value1);
-   break;
-   case V4L2_CID_HUE:
-   if (ctrl-value  50)
-   state-hue = 50;
-   else if (ctrl-value  -50)
-   state-hue = -50;
-   else
-   state-hue = ctrl-value;
-   /* clamp the hue range */
-   value1 = state-hue * 280 / 50;
-   write_reg_fp(client, VPX322_ADDR_HUE, value1);
-   break;
-   default:
-   return -EINVAL;
-   }
-   return 0;
-}
-
-static int s2250_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct s2250 *state = to_state(sd);
-
-   switch (ctrl-id) {
-   case V4L2_CID_BRIGHTNESS:
-   ctrl-value = state-brightness;
-   break;
-   case 

[REVIEW PATCH 27/42] go7007: add prio and control event support.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-priv.h |2 ++
 drivers/staging/media/go7007/go7007-v4l2.c |   23 ++-
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index d127a8d..2321fd7 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -23,6 +23,7 @@
 
 #include media/v4l2-device.h
 #include media/v4l2-ctrls.h
+#include media/v4l2-fh.h
 
 struct go7007;
 
@@ -143,6 +144,7 @@ struct go7007_buffer {
 };
 
 struct go7007_file {
+   struct v4l2_fh fh;
struct go7007 *go;
struct mutex lock;
int buf_count;
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index cb89af3..186a56b 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -27,13 +27,14 @@
 #include linux/time.h
 #include linux/vmalloc.h
 #include linux/pagemap.h
+#include linux/i2c.h
+#include linux/mutex.h
+#include linux/uaccess.h
 #include linux/videodev2.h
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-subdev.h
-#include linux/i2c.h
-#include linux/mutex.h
-#include linux/uaccess.h
+#include media/v4l2-event.h
 
 #include go7007.h
 #include go7007-priv.h
@@ -101,6 +102,8 @@ static int go7007_open(struct file *file)
mutex_init(gofh-lock);
gofh-buf_count = 0;
file-private_data = gofh;
+   v4l2_fh_init(gofh-fh, video_devdata(file));
+   v4l2_fh_add(gofh-fh);
return 0;
 }
 
@@ -115,6 +118,8 @@ static int go7007_release(struct file *file)
kfree(gofh-bufs);
gofh-buf_count = 0;
}
+   v4l2_fh_del(gofh-fh);
+   v4l2_fh_exit(gofh-fh);
kfree(gofh);
file-private_data = NULL;
return 0;
@@ -1582,16 +1587,20 @@ static int go7007_mmap(struct file *file, struct 
vm_area_struct *vma)
 
 static unsigned int go7007_poll(struct file *file, poll_table *wait)
 {
+   unsigned long req_events = poll_requested_events(wait);
struct go7007_file *gofh = file-private_data;
struct go7007_buffer *gobuf;
+   unsigned int res = v4l2_ctrl_poll(file, wait);
 
+   if (!(req_events  (POLLIN | POLLRDNORM)))
+   return res;
if (list_empty(gofh-go-stream))
return POLLERR;
gobuf = list_entry(gofh-go-stream.next, struct go7007_buffer, stream);
poll_wait(file, gofh-go-frame_waitq, wait);
if (gobuf-state == BUF_STATE_DONE)
-   return POLLIN | POLLRDNORM;
-   return 0;
+   return res | POLLIN | POLLRDNORM;
+   return res;
 }
 
 static void go7007_vfl_release(struct video_device *vfd)
@@ -1645,6 +1654,9 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_cropcap   = vidioc_cropcap,
.vidioc_g_crop= vidioc_g_crop,
.vidioc_s_crop= vidioc_s_crop,
+   .vidioc_log_status= v4l2_ctrl_log_status,
+   .vidioc_subscribe_event   = v4l2_ctrl_subscribe_event,
+   .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
 
 static struct video_device go7007_template = {
@@ -1707,6 +1719,7 @@ int go7007_v4l2_init(struct go7007 *go)
if (go-video_dev == NULL)
return -ENOMEM;
*go-video_dev = go7007_template;
+   set_bit(V4L2_FL_USE_FH_PRIO, go-video_dev-flags);
video_set_drvdata(go-video_dev, go);
go-video_dev-v4l2_dev = go-v4l2_dev;
rv = video_register_device(go-video_dev, VFL_TYPE_GRABBER, -1);
-- 
1.7.10.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


[REVIEW PATCH 29/42] go7007: tuner/std related fixes.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

- The Adlink is initially detected as a sensor board, so the driver config
  is set up as if it was a sensor. Later the driver discovers that it really
  is a video capture card and that means that the driver configuration has
  to be updated for a PAL/NTSC capture card.

- Setup the correct initial std based on the TV tuner type.

- Remember the exact std the user selected, don't map it to STD_PAL or NTSC.

- Use v4l2_disable_ioctl to disable ioctls based on the board config and
  drop a lot of checking code in each of those ioctls since that is no longer
  needed.

- enum_input should use tvnorms to fill its std field.

- configure the input, std and initial tuner frequency at driver initialization.

- fix std handling in the s2250 driver.

- the code handling scaling for devices without a scaler was broken. This is
  now fixed.

- correctly set readbuffers and capability in g/s_parm.

- remove the bogus test for capturemode in s_parm.

- correctly implement enum_framesizes/intervals.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c |   35 ++--
 drivers/staging/media/go7007/go7007-priv.h   |3 +
 drivers/staging/media/go7007/go7007-usb.c|3 +
 drivers/staging/media/go7007/go7007-v4l2.c   |  255 --
 drivers/staging/media/go7007/s2250-board.c   |   13 +-
 5 files changed, 154 insertions(+), 155 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index d689989..eac91bc 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -650,19 +650,7 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
init_waitqueue_head(go-interrupt_waitq);
go-in_use = 0;
go-input = 0;
-   if (board-sensor_flags  GO7007_SENSOR_TV) {
-   go-standard = GO7007_STD_NTSC;
-   go-width = 720;
-   go-height = 480;
-   go-sensor_framerate = 3;
-   } else {
-   go-standard = GO7007_STD_OTHER;
-   go-width = board-sensor_width;
-   go-height = board-sensor_height;
-   go-sensor_framerate = board-sensor_framerate;
-   }
-   go-encoder_v_offset = board-sensor_v_offset;
-   go-encoder_h_offset = board-sensor_h_offset;
+   go7007_update_board(go);
go-encoder_h_halve = 0;
go-encoder_v_halve = 0;
go-encoder_subsample = 0;
@@ -692,4 +680,25 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
 }
 EXPORT_SYMBOL(go7007_alloc);
 
+void go7007_update_board(struct go7007 *go)
+{
+   struct go7007_board_info *board = go-board_info;
+
+   if (board-sensor_flags  GO7007_SENSOR_TV) {
+   go-standard = GO7007_STD_NTSC;
+   go-std = V4L2_STD_NTSC_M;
+   go-width = 720;
+   go-height = 480;
+   go-sensor_framerate = 3;
+   } else {
+   go-standard = GO7007_STD_OTHER;
+   go-width = board-sensor_width;
+   go-height = board-sensor_height;
+   go-sensor_framerate = board-sensor_framerate;
+   }
+   go-encoder_v_offset = board-sensor_v_offset;
+   go-encoder_h_offset = board-sensor_h_offset;
+}
+EXPORT_SYMBOL(go7007_update_board);
+
 MODULE_LICENSE(GPL v2);
diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index 2321fd7..bf874dd 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -200,6 +200,7 @@ struct go7007 {
int input;
int aud_input;
enum { GO7007_STD_NTSC, GO7007_STD_PAL, GO7007_STD_OTHER } standard;
+   v4l2_std_id std;
int sensor_framerate;
int width;
int height;
@@ -291,6 +292,8 @@ int go7007_start_encoder(struct go7007 *go);
 void go7007_parse_video_stream(struct go7007 *go, u8 *buf, int length);
 struct go7007 *go7007_alloc(struct go7007_board_info *board,
struct device *dev);
+void go7007_update_board(struct go7007 *go);
+
 /* go7007-fw.c */
 int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen);
 
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 2d349f4..14d1cda 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1193,6 +1193,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
Adlink PCI-MPG24, channel #%d,
channel);
}
+   go7007_update_board(go);
}
}
 
@@ -1209,12 +1210,14 @@ static int go7007_usb_probe(struct usb_interface *intf,
case 1:

[REVIEW PATCH 30/42] go7007: standardize MPEG handling support.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The go7007 produces elementary streams, so we shouldn't use the STREAM_TYPE
control, since that is for multiplexed streams.

Instead use V4L2_PIX_FMT_MPEG1/2/4.

Initially set up all the values for MPEG-2 dvd-mode, and select the dvd_mode
field if those values match that setup precisely.

Clean up lots of obsolete code relating to the custom ioctls for the MPEG
support.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c |   16 +-
 drivers/staging/media/go7007/go7007-fw.c |   78 ++--
 drivers/staging/media/go7007/go7007-priv.h   |   13 +-
 drivers/staging/media/go7007/go7007-v4l2.c   |  507 +++---
 drivers/staging/media/go7007/go7007.h|   74 
 5 files changed, 181 insertions(+), 507 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index eac91bc..732b452 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -433,12 +433,12 @@ void go7007_parse_video_stream(struct go7007 *go, u8 
*buf, int length)
spin_lock(go-spinlock);
 
switch (go-format) {
-   case GO7007_FORMAT_MPEG4:
+   case V4L2_PIX_FMT_MPEG4:
seq_start_code = 0xB0;
frame_start_code = 0xB6;
break;
-   case GO7007_FORMAT_MPEG1:
-   case GO7007_FORMAT_MPEG2:
+   case V4L2_PIX_FMT_MPEG1:
+   case V4L2_PIX_FMT_MPEG2:
seq_start_code = 0xB3;
frame_start_code = 0x00;
break;
@@ -518,9 +518,9 @@ void go7007_parse_video_stream(struct go7007 *go, u8 *buf, 
int length)
}
/* If this is the start of a new MPEG frame,
 * get a new buffer */
-   if ((go-format == GO7007_FORMAT_MPEG1 ||
-   go-format == GO7007_FORMAT_MPEG2 ||
-   go-format == GO7007_FORMAT_MPEG4) 
+   if ((go-format == V4L2_PIX_FMT_MPEG1 ||
+go-format == V4L2_PIX_FMT_MPEG2 ||
+go-format == V4L2_PIX_FMT_MPEG4) 
(buf[i] == seq_start_code ||
buf[i] == 0xB8 || /* GOP code */
buf[i] == frame_start_code)) {
@@ -577,7 +577,7 @@ void go7007_parse_video_stream(struct go7007 *go, u8 *buf, 
int length)
/* go-state remains STATE_FF */
break;
case 0xD8:
-   if (go-format == GO7007_FORMAT_MJPEG)
+   if (go-format == V4L2_PIX_FMT_MJPEG)
frame_boundary(go);
/* fall through */
default:
@@ -654,8 +654,8 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
go-encoder_h_halve = 0;
go-encoder_v_halve = 0;
go-encoder_subsample = 0;
+   go-format = V4L2_PIX_FMT_MJPEG;
go-streaming = 0;
-   go-format = GO7007_FORMAT_MJPEG;
go-bitrate = 150;
go-fps_scale = 1;
go-pali = 0;
diff --git a/drivers/staging/media/go7007/go7007-fw.c 
b/drivers/staging/media/go7007/go7007-fw.c
index a5ede1c..524ba48 100644
--- a/drivers/staging/media/go7007/go7007-fw.c
+++ b/drivers/staging/media/go7007/go7007-fw.c
@@ -455,9 +455,9 @@ static int mpeg1_frame_header(struct go7007 *go, unsigned 
char *buf,
 
CODE_ADD(c, frame == PFRAME ? 0x2 : 0x3, 13);
CODE_ADD(c, 0x, 16);
-   CODE_ADD(c, go-format == GO7007_FORMAT_MPEG2 ? 0x7 : 0x4, 4);
+   CODE_ADD(c, go-format == V4L2_PIX_FMT_MPEG2 ? 0x7 : 0x4, 4);
if (frame != PFRAME)
-   CODE_ADD(c, go-format == GO7007_FORMAT_MPEG2 ? 0x7 : 0x4, 4);
+   CODE_ADD(c, go-format == V4L2_PIX_FMT_MPEG2 ? 0x7 : 0x4, 4);
else
CODE_ADD(c, 0, 4); /* Is this supposed to be here?? */
CODE_ADD(c, 0, 3); /* What is this?? */
@@ -466,7 +466,7 @@ static int mpeg1_frame_header(struct go7007 *go, unsigned 
char *buf,
if (j != 8)
CODE_ADD(c, 0, j);
 
-   if (go-format == GO7007_FORMAT_MPEG2) {
+   if (go-format == V4L2_PIX_FMT_MPEG2) {
CODE_ADD(c, 0x1, 24);
CODE_ADD(c, 0xb5, 8);
CODE_ADD(c, 0x844, 12);
@@ -537,7 +537,7 @@ static int mpeg1_sequence_header(struct go7007 *go, 
unsigned char *buf, int ext)
int i, aspect_ratio, picture_rate;
CODE_GEN(c, buf + 6);
 
-   if (go-format == GO7007_FORMAT_MPEG1) {
+   if (go-format == V4L2_PIX_FMT_MPEG1) {
switch (go-aspect_ratio) {
case GO7007_RATIO_4_3:

[REVIEW PATCH 32/42] go7007: set up the saa7115 audio clock correctly.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The s_crystal_freq operation has to be called for the saa7115 to
set up the audio clock correctly.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-priv.h |1 +
 drivers/staging/media/go7007/go7007-usb.c  |5 -
 drivers/staging/media/go7007/go7007-v4l2.c |7 +++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index a6ef67b..7f79cc1 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -60,6 +60,7 @@ struct go7007;
 #define GO7007_SENSOR_TV   (17)
 #define GO7007_SENSOR_VBI  (18)
 #define GO7007_SENSOR_SCALING  (19)
+#define GO7007_SENSOR_SAA7115  (110)
 
 /* Characteristics of audio sensor devices */
 #define GO7007_AUDIO_I2S_MODE_1(1)
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 53c5b16..5c7a19e6 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -88,6 +88,7 @@ static struct go7007_usb_board board_matrix_ii = {
.sensor_flags= GO7007_SENSOR_656 |
GO7007_SENSOR_VALID_ENABLE |
GO7007_SENSOR_TV |
+   GO7007_SENSOR_SAA7115 |
GO7007_SENSOR_VBI |
GO7007_SENSOR_SCALING,
.num_i2c_devs= 1,
@@ -131,7 +132,7 @@ static struct go7007_usb_board board_matrix_reload = {
.num_i2c_devs= 1,
.i2c_devs= {
{
-   .type   = saa7115,
+   .type   = saa7113,
.addr   = 0x25,
.is_video = 1,
},
@@ -160,6 +161,7 @@ static struct go7007_usb_board board_star_trek = {
.sensor_flags= GO7007_SENSOR_656 |
GO7007_SENSOR_VALID_ENABLE |
GO7007_SENSOR_TV |
+   GO7007_SENSOR_SAA7115 |
GO7007_SENSOR_VBI |
GO7007_SENSOR_SCALING,
.audio_flags = GO7007_AUDIO_I2S_MODE_1 |
@@ -207,6 +209,7 @@ static struct go7007_usb_board board_px_tv402u = {
.sensor_flags= GO7007_SENSOR_656 |
GO7007_SENSOR_VALID_ENABLE |
GO7007_SENSOR_TV |
+   GO7007_SENSOR_SAA7115 |
GO7007_SENSOR_VBI |
GO7007_SENSOR_SCALING,
.audio_flags = GO7007_AUDIO_I2S_MODE_1 |
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index fd6cae0..972f8a5 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -35,6 +35,7 @@
 #include media/v4l2-ioctl.h
 #include media/v4l2-subdev.h
 #include media/v4l2-event.h
+#include media/saa7115.h
 
 #include go7007.h
 #include go7007-priv.h
@@ -1461,6 +1462,12 @@ int go7007_v4l2_init(struct go7007 *go)
v4l2_disable_ioctl(go-video_dev, VIDIOC_S_AUDIO);
v4l2_disable_ioctl(go-video_dev, VIDIOC_ENUMAUDIO);
}
+   /* Setup correct crystal frequency on this board */
+   if (go-board_info-sensor_flags  GO7007_SENSOR_SAA7115)
+   v4l2_subdev_call(go-sd_video, video, s_crystal_freq,
+   SAA7115_FREQ_24_576_MHZ,
+   SAA7115_FREQ_FL_APLL | SAA7115_FREQ_FL_UCGC |
+   SAA7115_FREQ_FL_DOUBLE_ASCLK);
go7007_s_input(go);
if (go-board_info-sensor_flags  GO7007_SENSOR_TV)
go7007_s_std(go);
-- 
1.7.10.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


[REVIEW PATCH 35/42] go7007: embed struct video_device

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Do not allocate it, but just embed in the go7007 struct.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c  |1 -
 drivers/staging/media/go7007/go7007-priv.h|2 +-
 drivers/staging/media/go7007/go7007-usb.c |2 +-
 drivers/staging/media/go7007/go7007-v4l2.c|   56 ++---
 drivers/staging/media/go7007/saa7134-go7007.c |2 +-
 5 files changed, 26 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index 075de4d..0fd3f10 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -639,7 +639,6 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
mutex_init(go-hw_lock);
init_waitqueue_head(go-frame_waitq);
spin_lock_init(go-spinlock);
-   go-video_dev = NULL;
go-status = STATUS_INIT;
memset(go-i2c_adapter, 0, sizeof(go-i2c_adapter));
go-i2c_adapter_online = 0;
diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index 30148eb..0914fa3 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -156,7 +156,7 @@ struct go7007 {
int tuner_type;
int channel_number; /* for multi-channel boards like Adlink PCI-MPG24 */
char name[64];
-   struct video_device *video_dev;
+   struct video_device vdev;
void *boot_fw;
unsigned boot_fw_len;
struct v4l2_device v4l2_dev;
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index c95538c..2a1cda2 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1324,7 +1324,7 @@ static void go7007_usb_disconnect(struct usb_interface 
*intf)
 
go-status = STATUS_SHUTDOWN;
v4l2_device_disconnect(go-v4l2_dev);
-   video_unregister_device(go-video_dev);
+   video_unregister_device(go-vdev);
mutex_unlock(go-serialize_lock);
mutex_unlock(go-queue_lock);
 
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 46db491..2e5bc02 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -967,11 +967,6 @@ static int vidioc_s_crop(struct file *file, void *priv, 
const struct v4l2_crop *
}
 #endif
 
-static void go7007_vfl_release(struct video_device *vfd)
-{
-   video_device_release(vfd);
-}
-
 static struct v4l2_file_operations go7007_fops = {
.owner  = THIS_MODULE,
.open   = v4l2_fh_open,
@@ -1022,7 +1017,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 static struct video_device go7007_template = {
.name   = go7007,
.fops   = go7007_fops,
-   .release= go7007_vfl_release,
+   .release= video_device_release_empty,
.ioctl_ops  = video_ioctl_ops,
.tvnorms= V4L2_STD_ALL,
 };
@@ -1062,6 +1057,7 @@ int go7007_v4l2_ctrl_init(struct go7007 *go)
 
 int go7007_v4l2_init(struct go7007 *go)
 {
+   struct video_device *vdev = go-vdev;
int rv;
 
mutex_init(go-serialize_lock);
@@ -1079,22 +1075,19 @@ int go7007_v4l2_init(struct go7007 *go)
rv = vb2_queue_init(go-vidq);
if (rv)
return rv;
-   go-video_dev = video_device_alloc();
-   if (go-video_dev == NULL)
-   return -ENOMEM;
-   *go-video_dev = go7007_template;
-   go-video_dev-lock = go-serialize_lock;
-   go-video_dev-queue = go-vidq;
-   set_bit(V4L2_FL_USE_FH_PRIO, go-video_dev-flags);
-   video_set_drvdata(go-video_dev, go);
-   go-video_dev-v4l2_dev = go-v4l2_dev;
+   *vdev = go7007_template;
+   vdev-lock = go-serialize_lock;
+   vdev-queue = go-vidq;
+   set_bit(V4L2_FL_USE_FH_PRIO, vdev-flags);
+   video_set_drvdata(vdev, go);
+   vdev-v4l2_dev = go-v4l2_dev;
if (!v4l2_device_has_op(go-v4l2_dev, video, querystd))
-   v4l2_disable_ioctl(go-video_dev, VIDIOC_QUERYSTD);
+   v4l2_disable_ioctl(vdev, VIDIOC_QUERYSTD);
if (!(go-board_info-flags  GO7007_BOARD_HAS_TUNER)) {
-   v4l2_disable_ioctl(go-video_dev, VIDIOC_S_FREQUENCY);
-   v4l2_disable_ioctl(go-video_dev, VIDIOC_G_FREQUENCY);
-   v4l2_disable_ioctl(go-video_dev, VIDIOC_S_TUNER);
-   v4l2_disable_ioctl(go-video_dev, VIDIOC_G_TUNER);
+   v4l2_disable_ioctl(vdev, VIDIOC_S_FREQUENCY);
+   v4l2_disable_ioctl(vdev, VIDIOC_G_FREQUENCY);
+   v4l2_disable_ioctl(vdev, VIDIOC_S_TUNER);
+   v4l2_disable_ioctl(vdev, VIDIOC_G_TUNER);
} else {
struct 

[REVIEW PATCH 36/42] go7007: remove cropping functions

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Remove these dummy cropping functions: cropping was never implemented.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-v4l2.c |   92 
 1 file changed, 92 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 2e5bc02..24d93b4 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -842,95 +842,6 @@ static int vidioc_log_status(struct file *file, void *priv)
return call_all(go-v4l2_dev, core, log_status);
 }
 
-static int vidioc_cropcap(struct file *file, void *priv,
-   struct v4l2_cropcap *cropcap)
-{
-   struct go7007 *go = video_drvdata(file);
-
-   if (cropcap-type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   return -EINVAL;
-
-   /* These specify the raw input of the sensor */
-   switch (go-standard) {
-   case GO7007_STD_NTSC:
-   cropcap-bounds.top = 0;
-   cropcap-bounds.left = 0;
-   cropcap-bounds.width = 720;
-   cropcap-bounds.height = 480;
-   cropcap-defrect.top = 0;
-   cropcap-defrect.left = 0;
-   cropcap-defrect.width = 720;
-   cropcap-defrect.height = 480;
-   break;
-   case GO7007_STD_PAL:
-   cropcap-bounds.top = 0;
-   cropcap-bounds.left = 0;
-   cropcap-bounds.width = 720;
-   cropcap-bounds.height = 576;
-   cropcap-defrect.top = 0;
-   cropcap-defrect.left = 0;
-   cropcap-defrect.width = 720;
-   cropcap-defrect.height = 576;
-   break;
-   case GO7007_STD_OTHER:
-   cropcap-bounds.top = 0;
-   cropcap-bounds.left = 0;
-   cropcap-bounds.width = go-board_info-sensor_width;
-   cropcap-bounds.height = go-board_info-sensor_height;
-   cropcap-defrect.top = 0;
-   cropcap-defrect.left = 0;
-   cropcap-defrect.width = go-board_info-sensor_width;
-   cropcap-defrect.height = go-board_info-sensor_height;
-   break;
-   }
-
-   return 0;
-}
-
-static int vidioc_g_crop(struct file *file, void *priv, struct v4l2_crop *crop)
-{
-   struct go7007 *go = video_drvdata(file);
-
-   if (crop-type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   return -EINVAL;
-
-   crop-type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
-   /* These specify the raw input of the sensor */
-   switch (go-standard) {
-   case GO7007_STD_NTSC:
-   crop-c.top = 0;
-   crop-c.left = 0;
-   crop-c.width = 720;
-   crop-c.height = 480;
-   break;
-   case GO7007_STD_PAL:
-   crop-c.top = 0;
-   crop-c.left = 0;
-   crop-c.width = 720;
-   crop-c.height = 576;
-   break;
-   case GO7007_STD_OTHER:
-   crop-c.top = 0;
-   crop-c.left = 0;
-   crop-c.width = go-board_info-sensor_width;
-   crop-c.height = go-board_info-sensor_height;
-   break;
-   }
-
-   return 0;
-}
-
-/* FIXME: vidioc_s_crop is not really implemented!!!
- */
-static int vidioc_s_crop(struct file *file, void *priv, const struct v4l2_crop 
*crop)
-{
-   if (crop-type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   return -EINVAL;
-
-   return 0;
-}
-
 /* FIXME:
Those ioctls are private, and not needed, since several standard
extended controls already provide streaming control.
@@ -1006,9 +917,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_s_parm= vidioc_s_parm,
.vidioc_enum_framesizes   = vidioc_enum_framesizes,
.vidioc_enum_frameintervals = vidioc_enum_frameintervals,
-   .vidioc_cropcap   = vidioc_cropcap,
-   .vidioc_g_crop= vidioc_g_crop,
-   .vidioc_s_crop= vidioc_s_crop,
.vidioc_log_status= vidioc_log_status,
.vidioc_subscribe_event   = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
-- 
1.7.10.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


[REVIEW PATCH 38/42] s2250: add comment describing the hardware.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/s2250-board.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/media/go7007/s2250-board.c 
b/drivers/staging/media/go7007/s2250-board.c
index cb36427..beaa98b 100644
--- a/drivers/staging/media/go7007/s2250-board.c
+++ b/drivers/staging/media/go7007/s2250-board.c
@@ -29,6 +29,13 @@
 MODULE_DESCRIPTION(Sensoray 2250/2251 i2c v4l2 subdev driver);
 MODULE_LICENSE(GPL v2);
 
+/*
+ * Note: this board has two i2c devices: a vpx3226f and a tlv320aic23b.
+ * Due to the unusual way these are accessed on this device we do not
+ * reuse the i2c drivers, but instead they are implemented in this
+ * driver. It would be nice to improve on this, though.
+ */
+
 #define TLV320_ADDRESS  0x34
 #define VPX322_ADDR_ANALOGCONTROL1 0x02
 #define VPX322_ADDR_BRIGHTNESS00x0127
-- 
1.7.10.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


[REVIEW PATCH 42/42] MAINTAINERS: add the go7007 driver.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 MAINTAINERS |5 +
 1 file changed, 5 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index ff2fcc9..5703edd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7550,6 +7550,11 @@ M:   David Täht d...@teklibre.com
 S: Odd Fixes
 F: drivers/staging/frontier/
 
+STAGING - GO7007 MPEG CODEC
+M: Hans Verkuil hans.verk...@cisco.com
+S: Maintained
+F: drivers/staging/media/go7007/
+
 STAGING - INDUSTRIAL IO
 M: Jonathan Cameron ji...@cam.ac.uk
 L: linux-...@vger.kernel.org
-- 
1.7.10.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


[REVIEW PATCH 41/42] go7007: update the README

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/README |   14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/go7007/README 
b/drivers/staging/media/go7007/README
index aeba132..779fe3f 100644
--- a/drivers/staging/media/go7007/README
+++ b/drivers/staging/media/go7007/README
@@ -1,11 +1,5 @@
 Todo:
-   - checkpatch.pl cleanups
-   - sparse cleanups
-   - lots of little modules, should be merged together
- and added to the build.
-   - testing?
-   - handle churn in v4l layer.
-
-Please send patches to Greg Kroah-Hartman g...@linuxfoundation.org and Cc: 
Ross
-Cohen rco...@snurgle.org as well.
-
+   - create an API for motion detection
+   - figure out how to distribute the firmware files
+   - let s2250-board use i2c subdevs as well instead of hardcoding
+ support for the i2c devices.
-- 
1.7.10.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


[REVIEW PATCH 37/42] saa7134-go7007: add support for this combination.

2013-03-11 Thread Hans Verkuil
From: Pete Eberlein p...@sensoray.com

Add support for the Sensoray model 614 board, which is a saa7134
with a go7007 MPEG encoder.

Signed-off-by: Pete Eberlein p...@sensoray.com
[hans.verk...@cisco.com: updated to make it merge correctly]
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/pci/saa7134/saa7134-cards.c |   29 ++
 drivers/media/pci/saa7134/saa7134-core.c  |   10 ++-
 drivers/media/pci/saa7134/saa7134.h   |5 ++
 drivers/staging/media/go7007/Makefile |4 +-
 drivers/staging/media/go7007/saa7134-go7007.c |  117 +++--
 5 files changed, 115 insertions(+), 50 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-cards.c 
b/drivers/media/pci/saa7134/saa7134-cards.c
index dc68cf1..9a53794 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -5790,6 +5790,29 @@ struct saa7134_board saa7134_boards[] = {
.gpio = 0x601,
} },
},
+   [SAA7134_BOARD_WIS_VOYAGER] = {
+   .name   = WIS Voyager or compatible,
+   .audio_clock= 0x0020,
+   .tuner_type = TUNER_PHILIPS_TDA8290,
+   .radio_type = UNSET,
+   .tuner_addr = ADDR_UNSET,
+   .radio_addr = ADDR_UNSET,
+   .mpeg   = SAA7134_MPEG_GO7007,
+   .inputs = { {
+   .name = name_comp1,
+   .vmux = 0,
+   .amux = LINE2,
+   }, {
+   .name = name_tv,
+   .vmux = 3,
+   .amux = TV,
+   .tv   = 1,
+   }, {
+   .name = name_svideo,
+   .vmux = 6,
+   .amux = LINE1,
+   } },
+   },
 
 };
 
@@ -7037,6 +7060,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subdevice= 0x0911,
.driver_data  = SAA7134_BOARD_SENSORAY811_911,
}, {
+   .vendor   = PCI_VENDOR_ID_PHILIPS,
+   .device   = PCI_DEVICE_ID_PHILIPS_SAA7133,
+   .subvendor= 0x1905, /* WIS */
+   .subdevice= 0x7007,
+   .driver_data  = SAA7134_BOARD_WIS_VOYAGER,
+   }, {
/* --- boards without eeprom + subsystem ID --- */
.vendor   = PCI_VENDOR_ID_PHILIPS,
.device   = PCI_DEVICE_ID_PHILIPS_SAA7134,
diff --git a/drivers/media/pci/saa7134/saa7134-core.c 
b/drivers/media/pci/saa7134/saa7134-core.c
index 8fd24e7..0a849ea 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -156,6 +156,8 @@ static void request_module_async(struct work_struct *work){
request_module(saa7134-empress);
if (card_is_dvb(dev))
request_module(saa7134-dvb);
+   if (card_is_go7007(dev))
+   request_module(saa7134-go7007);
if (alsa) {
if (dev-pci-device != PCI_DEVICE_ID_PHILIPS_SAA7130)
request_module(saa7134-alsa);
@@ -557,8 +559,12 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id)
saa7134_irq_vbi_done(dev,status);
 
if ((report  SAA7134_IRQ_REPORT_DONE_RA2) 
-   card_has_mpeg(dev))
-   saa7134_irq_ts_done(dev,status);
+   card_has_mpeg(dev)) {
+   if (dev-mops-irq_ts_done != NULL)
+   dev-mops-irq_ts_done(dev, status);
+   else
+   saa7134_irq_ts_done(dev, status);
+   }
 
if (report  SAA7134_IRQ_REPORT_GPIO16) {
switch (dev-has_remote) {
diff --git a/drivers/media/pci/saa7134/saa7134.h 
b/drivers/media/pci/saa7134/saa7134.h
index 71eefef..e337e6c 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -334,6 +334,7 @@ struct saa7134_card_ir {
 #define SAA7134_BOARD_KWORLD_PC150U 189
 #define SAA7134_BOARD_ASUSTeK_PS3_100  190
 #define SAA7134_BOARD_HAWELL_HW_9004V1  191
+#define SAA7134_BOARD_WIS_VOYAGER   192
 
 #define SAA7134_MAXBOARDS 32
 #define SAA7134_INPUT_MAX 8
@@ -364,6 +365,7 @@ enum saa7134_mpeg_type {
SAA7134_MPEG_UNUSED,
SAA7134_MPEG_EMPRESS,
SAA7134_MPEG_DVB,
+   SAA7134_MPEG_GO7007,
 };
 
 enum saa7134_mpeg_ts_type {
@@ -403,6 +405,7 @@ struct saa7134_board {
 #define card_has_radio(dev)   (NULL != saa7134_boards[dev-board].radio.name)
 #define card_is_empress(dev)  (SAA7134_MPEG_EMPRESS == 
saa7134_boards[dev-board].mpeg)
 #define card_is_dvb(dev)  (SAA7134_MPEG_DVB == 
saa7134_boards[dev-board].mpeg)
+#define card_is_go7007(dev)   (SAA7134_MPEG_GO7007  == 
saa7134_boards[dev-board].mpeg)
 #define 

[REVIEW PATCH 40/42] go7007-loader: add support for the other devices and move fw files

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add support for the other devices that need to load the boot firmware.
All firmware files are now placed in a single go7007 directory.

Also remove the device_extension_s stuff: this is clearly a left-over from
the olden days.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c  |4 +-
 drivers/staging/media/go7007/go7007-loader.c  |  131 ++---
 drivers/staging/media/go7007/go7007-usb.c |   22 ++---
 drivers/staging/media/go7007/saa7134-go7007.c |3 +-
 4 files changed, 68 insertions(+), 92 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index 0fd3f10..4378223 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -90,7 +90,7 @@ EXPORT_SYMBOL(go7007_read_addr);
 static int go7007_load_encoder(struct go7007 *go)
 {
const struct firmware *fw_entry;
-   char fw_name[] = go7007fw.bin;
+   char fw_name[] = go7007/go7007fw.bin;
void *bounce;
int fw_len, rv = 0;
u16 intr_val, intr_data;
@@ -126,7 +126,7 @@ static int go7007_load_encoder(struct go7007 *go)
return rv;
 }
 
-MODULE_FIRMWARE(go7007fw.bin);
+MODULE_FIRMWARE(go7007/go7007fw.bin);
 
 /*
  * Boot the encoder and register the I2C adapter if requested.  Do the
diff --git a/drivers/staging/media/go7007/go7007-loader.c 
b/drivers/staging/media/go7007/go7007-loader.c
index 730a4f8..4ce53d6 100644
--- a/drivers/staging/media/go7007/go7007-loader.c
+++ b/drivers/staging/media/go7007/go7007-loader.c
@@ -22,86 +22,67 @@
 #include linux/firmware.h
 #include cypress_firmware.h
 
-#define S2250_LOADER_FIRMWARE  s2250_loader.fw
-#define S2250_FIRMWARE 2250.fw
-
-typedef struct device_extension_s {
-struct kref kref;
-int minor;
-struct usb_device *usbdev;
-} device_extension_t, *pdevice_extension_t;
-
-#define USB_go7007_loader_MAJOR 240
-#define USB_go7007_loader_MINOR_BASE 0
-#define MAX_DEVICES 256
-
-static pdevice_extension_t go7007_dev_table[MAX_DEVICES];
-static DEFINE_MUTEX(go7007_dev_table_mutex);
+struct fw_config {
+   u16 vendor;
+   u16 product;
+   const char * const fw_name1;
+   const char * const fw_name2;
+};
 
-#define to_go7007_loader_dev_common(d) container_of(d, device_extension_t, 
kref)
-static void go7007_loader_delete(struct kref *kref)
-{
-   pdevice_extension_t s = to_go7007_loader_dev_common(kref);
-   go7007_dev_table[s-minor] = NULL;
-   kfree(s);
-}
+struct fw_config fw_configs[] = {
+   { 0x1943, 0xa250, go7007/s2250-1.fw, go7007/s2250-2.fw },
+   { 0x093b, 0xa002, go7007/px-m402u.fw, NULL },
+   { 0x093b, 0xa004, go7007/px-tv402u.fw, NULL },
+   { 0x0eb1, 0x, go7007/lr192.fw, NULL },
+   { 0x0eb1, 0x6668, go7007/wis-startrek.fw, NULL },
+   { 0, 0, NULL, NULL }
+};
+MODULE_FIRMWARE(go7007/s2250-1.fw);
+MODULE_FIRMWARE(go7007/s2250-2.fw);
+MODULE_FIRMWARE(go7007/px-m402u.fw);
+MODULE_FIRMWARE(go7007/px-tv402u.fw);
+MODULE_FIRMWARE(go7007/lr192.fw);
+MODULE_FIRMWARE(go7007/wis-startrek.fw);
 
 static int go7007_loader_probe(struct usb_interface *interface,
const struct usb_device_id *id)
 {
struct usb_device *usbdev;
-   int minor, ret;
-   pdevice_extension_t s = NULL;
const struct firmware *fw;
+   u16 vendor, product;
+   const char *fw1, *fw2;
+   int ret;
+   int i;
 
usbdev = usb_get_dev(interface_to_usbdev(interface));
-   if (!usbdev) {
-   dev_err(interface-dev, Enter go7007_loader_probe failed\n);
-   return -1;
-   }
-   dev_info(interface-dev, vendor id 0x%x, device id 0x%x devnum:%d\n,
-usbdev-descriptor.idVendor, usbdev-descriptor.idProduct,
-usbdev-devnum);
+   if (!usbdev)
+   goto failed2;
 
if (usbdev-descriptor.bNumConfigurations != 1) {
dev_err(interface-dev, can't handle multiple config\n);
-   return -1;
-   }
-   mutex_lock(go7007_dev_table_mutex);
-
-   for (minor = 0; minor  MAX_DEVICES; minor++) {
-   if (go7007_dev_table[minor] == NULL)
-   break;
+   return -ENODEV;
}
 
-   if (minor  0 || minor = MAX_DEVICES) {
-   dev_err(interface-dev, Invalid minor: %d\n, minor);
-   goto failed;
-   }
-
-   /* Allocate dev data structure */
-   s = kmalloc(sizeof(device_extension_t), GFP_KERNEL);
-   if (s == NULL)
-   goto failed;
-
-   go7007_dev_table[minor] = s;
+   vendor = le16_to_cpu(usbdev-descriptor.idVendor);
+   product = le16_to_cpu(usbdev-descriptor.idProduct);
 
-   dev_info(interface-dev,
-Device %d on Bus %d Minor %d\n,
-usbdev-devnum, usbdev-bus-busnum, minor);
+   

[REVIEW PATCH 34/42] go7007: convert to core locking and vb2.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Convert this driver to videobuf2 and core locking.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/Kconfig  |2 +-
 drivers/staging/media/go7007/go7007-driver.c  |  156 ---
 drivers/staging/media/go7007/go7007-priv.h|   27 +-
 drivers/staging/media/go7007/go7007-usb.c |9 +-
 drivers/staging/media/go7007/go7007-v4l2.c|  535 ++---
 drivers/staging/media/go7007/saa7134-go7007.c |2 +-
 6 files changed, 205 insertions(+), 526 deletions(-)

diff --git a/drivers/staging/media/go7007/Kconfig 
b/drivers/staging/media/go7007/Kconfig
index da32031..46cb7bf 100644
--- a/drivers/staging/media/go7007/Kconfig
+++ b/drivers/staging/media/go7007/Kconfig
@@ -2,7 +2,7 @@ config VIDEO_GO7007
tristate WIS GO7007 MPEG encoder support
depends on VIDEO_DEV  PCI  I2C
depends on SND
-   select VIDEOBUF_DMA_SG
+   select VIDEOBUF2_VMALLOC
depends on RC_CORE
select VIDEO_TUNER
select VIDEO_TVEEPROM
diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index 732b452..075de4d 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -363,48 +363,54 @@ start_error:
 /*
  * Store a byte in the current video buffer, if there is one.
  */
-static inline void store_byte(struct go7007_buffer *gobuf, u8 byte)
+static inline void store_byte(struct go7007_buffer *vb, u8 byte)
 {
-   if (gobuf != NULL  gobuf-bytesused  GO7007_BUF_SIZE) {
-   unsigned int pgidx = gobuf-offset  PAGE_SHIFT;
-   unsigned int pgoff = gobuf-offset  ~PAGE_MASK;
+   if (vb  vb-vb.v4l2_planes[0].bytesused  GO7007_BUF_SIZE) {
+   u8 *ptr = vb2_plane_vaddr(vb-vb, 0);
 
-   *((u8 *)page_address(gobuf-pages[pgidx]) + pgoff) = byte;
-   ++gobuf-offset;
-   ++gobuf-bytesused;
+   ptr[vb-vb.v4l2_planes[0].bytesused++] = byte;
}
 }
 
 /*
  * Deliver the last video buffer and get a new one to start writing to.
  */
-static void frame_boundary(struct go7007 *go)
+static struct go7007_buffer *frame_boundary(struct go7007 *go, struct 
go7007_buffer *vb)
 {
-   struct go7007_buffer *gobuf;
+   struct go7007_buffer *vb_tmp = NULL;
+   u32 *bytesused = vb-vb.v4l2_planes[0].bytesused;
int i;
 
-   if (go-active_buf) {
-   if (go-active_buf-modet_active) {
-   if (go-active_buf-bytesused + 216  GO7007_BUF_SIZE) {
+   if (vb) {
+   if (vb-modet_active) {
+   if (*bytesused + 216  GO7007_BUF_SIZE) {
for (i = 0; i  216; ++i)
-   store_byte(go-active_buf,
-   go-active_map[i]);
-   go-active_buf-bytesused -= 216;
+   store_byte(vb, go-active_map[i]);
+   *bytesused -= 216;
} else
-   go-active_buf-modet_active = 0;
+   vb-modet_active = 0;
}
-   go-active_buf-state = BUF_STATE_DONE;
-   wake_up_interruptible(go-frame_waitq);
-   go-active_buf = NULL;
+   vb-vb.v4l2_buf.sequence = go-next_seq++;
+   v4l2_get_timestamp(vb-vb.v4l2_buf.timestamp);
+   vb_tmp = vb;
+   spin_lock(go-spinlock);
+   list_del(vb-list);
+   if (list_empty(go-vidq_active))
+   vb = NULL;
+   else
+   vb = list_first_entry(go-vidq_active, struct 
go7007_buffer, list);
+   go-active_buf = vb;
+   spin_unlock(go-spinlock);
+   vb2_buffer_done(vb_tmp-vb, VB2_BUF_STATE_DONE);
+   return vb;
}
-   list_for_each_entry(gobuf, go-stream, stream)
-   if (gobuf-state == BUF_STATE_QUEUED) {
-   gobuf-seq = go-next_seq;
-   do_gettimeofday(gobuf-timestamp);
-   go-active_buf = gobuf;
-   break;
-   }
-   ++go-next_seq;
+   spin_lock(go-spinlock);
+   if (!list_empty(go-vidq_active))
+   vb = go-active_buf =
+   list_first_entry(go-vidq_active, struct 
go7007_buffer, list);
+   spin_unlock(go-spinlock);
+   go-next_seq++;
+   return vb;
 }
 
 static void write_bitmap_word(struct go7007 *go)
@@ -428,10 +434,9 @@ static void write_bitmap_word(struct go7007 *go)
  */
 void go7007_parse_video_stream(struct go7007 *go, u8 *buf, int length)
 {
+   struct go7007_buffer *vb = go-active_buf;
int i, seq_start_code = -1, frame_start_code = -1;
 
-   

[REVIEW PATCH 39/42] go7007-loader: renamed from s2250-loader

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

All s2250 names are renamed to go7007. This will be the generic go7007
firmware loader for any go7007 device, not just for the s2250/1.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/Kconfig |   24 ++--
 drivers/staging/media/go7007/Makefile|7 +-
 drivers/staging/media/go7007/go7007-loader.c |  169 +
 drivers/staging/media/go7007/s2250-loader.c  |  170 --
 drivers/staging/media/go7007/s2250-loader.h  |   24 
 5 files changed, 189 insertions(+), 205 deletions(-)
 create mode 100644 drivers/staging/media/go7007/go7007-loader.c
 delete mode 100644 drivers/staging/media/go7007/s2250-loader.c
 delete mode 100644 drivers/staging/media/go7007/s2250-loader.h

diff --git a/drivers/staging/media/go7007/Kconfig 
b/drivers/staging/media/go7007/Kconfig
index 46cb7bf..957277c 100644
--- a/drivers/staging/media/go7007/Kconfig
+++ b/drivers/staging/media/go7007/Kconfig
@@ -1,13 +1,10 @@
 config VIDEO_GO7007
tristate WIS GO7007 MPEG encoder support
-   depends on VIDEO_DEV  PCI  I2C
+   depends on VIDEO_DEV  I2C
depends on SND
select VIDEOBUF2_VMALLOC
-   depends on RC_CORE
select VIDEO_TUNER
-   select VIDEO_TVEEPROM
select SND_PCM
-   select CRC32
select VIDEO_SONY_BTF_MPX if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_TW2804 if MEDIA_SUBDRV_AUTOSELECT
@@ -20,7 +17,7 @@ config VIDEO_GO7007
  encoder chip.
 
  To compile this driver as a module, choose M here: the
- module will be called go7007
+ module will be called go7007.
 
 config VIDEO_GO7007_USB
tristate WIS GO7007 USB support
@@ -31,14 +28,25 @@ config VIDEO_GO7007_USB
  encoder chip over USB.
 
  To compile this driver as a module, choose M here: the
- module will be called go7007-usb
+ module will be called go7007-usb.
+
+config VIDEO_GO7007_LOADER
+   tristate WIS GO7007 Loader support
+   depends on VIDEO_GO7007  DVB_USB
+   default y
+   ---help---
+ This is a go7007 firmware loader driver for the WIS GO7007
+ MPEG encoder chip over USB.
+
+ To compile this driver as a module, choose M here: the
+ module will be called go7007-loader.
 
 config VIDEO_GO7007_USB_S2250_BOARD
tristate Sensoray 2250/2251 support
-   depends on VIDEO_GO7007_USB  DVB_USB
+   depends on VIDEO_GO7007_USB  USB
default N
---help---
  This is a video4linux driver for the Sensoray 2250/2251 device.
 
  To compile this driver as a module, choose M here: the
- module will be called s2250
+ module will be called s2250.
diff --git a/drivers/staging/media/go7007/Makefile 
b/drivers/staging/media/go7007/Makefile
index 7885c21..e94ab0d 100644
--- a/drivers/staging/media/go7007/Makefile
+++ b/drivers/staging/media/go7007/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_VIDEO_GO7007) += go7007.o
 obj-$(CONFIG_VIDEO_GO7007_USB) += go7007-usb.o
-obj-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD) += s2250.o s2250-loader.o
+obj-$(CONFIG_VIDEO_GO7007_LOADER) += go7007-loader.o
+obj-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD) += s2250.o
 
 go7007-y := go7007-v4l2.o go7007-driver.o go7007-i2c.o go7007-fw.o \
snd-go7007.o
@@ -11,8 +12,8 @@ s2250-y := s2250-board.o
 obj-$(CONFIG_VIDEO_SAA7134) += saa7134-go7007.o
 ccflags-$(CONFIG_VIDEO_SAA7134:m=y) += -Idrivers/media/pci/saa7134
 
-# S2250 needs cypress ezusb loader from dvb-usb-v2
-ccflags-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD:m=y) += 
-Idrivers/media/usb/dvb-usb-v2
+# go7007-loader needs cypress ezusb loader from dvb-usb-v2
+ccflags-$(CONFIG_VIDEO_GO7007_LOADER:m=y) += -Idrivers/media/usb/dvb-usb-v2
 
 ccflags-y += -Idrivers/media/dvb-frontends
 ccflags-y += -Idrivers/media/dvb-core
diff --git a/drivers/staging/media/go7007/go7007-loader.c 
b/drivers/staging/media/go7007/go7007-loader.c
new file mode 100644
index 000..730a4f8
--- /dev/null
+++ b/drivers/staging/media/go7007/go7007-loader.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2008 Sensoray Company Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/slab.h
+#include 

[REVIEW PATCH 14/42] tw2804: modify ADC power control

2013-03-11 Thread Hans Verkuil
From: Volokh Konstantin volok...@gmail.com

Switch off all ADC (max 4) with first init, we control it
when starting/stopping streaming.

Signed-off-by: Volokh Konstantin volok...@gmail.com
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/tw2804.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/tw2804.c b/drivers/media/i2c/tw2804.c
index 4bb5ba6..441b766 100644
--- a/drivers/media/i2c/tw2804.c
+++ b/drivers/media/i2c/tw2804.c
@@ -53,6 +53,7 @@ static const u8 global_registers[] = {
0x3d, 0x80,
0x3e, 0x82,
0x3f, 0x82,
+   0x78, 0x0f,
0xff, 0xff, /* Terminator (reg 0xff does not exist) */
 };
 
-- 
1.7.10.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


[REVIEW PATCH 21/42] go7007: remove current_norm.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

It's deprecated and replaced by g_std. Since this driver already implements
g_std the use of current_norm can just be removed.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-v4l2.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 6f14ac5..b470306 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -1834,7 +1834,6 @@ static struct video_device go7007_template = {
.release= go7007_vfl_release,
.ioctl_ops  = video_ioctl_ops,
.tvnorms= V4L2_STD_ALL,
-   .current_norm   = V4L2_STD_NTSC,
 };
 
 int go7007_v4l2_init(struct go7007 *go)
-- 
1.7.10.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


[REVIEW PATCH 33/42] go7007: drop struct go7007_file

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Remove struct go7007_file: all fields contained in that struct are moved to
the go7007 struct since they are really global values. The lock has just
been deleted (what's the point of a per-fh lock??).

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-priv.h |   11 +-
 drivers/staging/media/go7007/go7007-v4l2.c |  177 ++--
 2 files changed, 67 insertions(+), 121 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index 7f79cc1..2c0afb1 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -141,14 +141,6 @@ struct go7007_buffer {
int mapped;
 };
 
-struct go7007_file {
-   struct v4l2_fh fh;
-   struct go7007 *go;
-   struct mutex lock;
-   int buf_count;
-   struct go7007_buffer *bufs;
-};
-
 #define GO7007_RATIO_1_1   0
 #define GO7007_RATIO_4_3   1
 #define GO7007_RATIO_16_9  2
@@ -242,6 +234,9 @@ struct go7007 {
u32 next_seq;
struct list_head stream;
wait_queue_head_t frame_waitq;
+   int buf_count;
+   struct go7007_buffer *bufs;
+   struct v4l2_fh *bufs_owner;
 
/* Audio streaming */
void (*audio_deliver)(struct go7007 *go, u8 *buf, int length);
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 972f8a5..191af80 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -88,41 +88,19 @@ static int go7007_streamoff(struct go7007 *go)
return 0;
 }
 
-static int go7007_open(struct file *file)
-{
-   struct go7007 *go = video_get_drvdata(video_devdata(file));
-   struct go7007_file *gofh;
-
-   if (go-status != STATUS_ONLINE)
-   return -EBUSY;
-   gofh = kzalloc(sizeof(struct go7007_file), GFP_KERNEL);
-   if (gofh == NULL)
-   return -ENOMEM;
-   gofh-go = go;
-   mutex_init(gofh-lock);
-   gofh-buf_count = 0;
-   file-private_data = gofh;
-   v4l2_fh_init(gofh-fh, video_devdata(file));
-   v4l2_fh_add(gofh-fh);
-   return 0;
-}
-
 static int go7007_release(struct file *file)
 {
-   struct go7007_file *gofh = file-private_data;
-   struct go7007 *go = gofh-go;
+   struct go7007 *go = video_drvdata(file);
 
-   if (gofh-buf_count  0) {
+   if (file-private_data == go-bufs_owner  go-buf_count  0) {
go7007_streamoff(go);
go-in_use = 0;
-   kfree(gofh-bufs);
-   gofh-buf_count = 0;
+   kfree(go-bufs);
+   go-bufs = NULL;
+   go-buf_count = 0;
+   go-bufs_owner = NULL;
}
-   v4l2_fh_del(gofh-fh);
-   v4l2_fh_exit(gofh-fh);
-   kfree(gofh);
-   file-private_data = NULL;
-   return 0;
+   return v4l2_fh_release(file);
 }
 
 static bool valid_pixelformat(u32 pixelformat)
@@ -428,7 +406,7 @@ static int clip_to_modet_map(struct go7007 *go, int region,
 static int vidioc_querycap(struct file *file, void  *priv,
struct v4l2_capability *cap)
 {
-   struct go7007 *go = ((struct go7007_file *) priv)-go;
+   struct go7007 *go = video_drvdata(file);
 
strlcpy(cap-driver, go7007, sizeof(cap-driver));
strlcpy(cap-card, go-name, sizeof(cap-card));
@@ -480,7 +458,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  
*priv,
 static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *fmt)
 {
-   struct go7007 *go = ((struct go7007_file *) priv)-go;
+   struct go7007 *go = video_drvdata(file);
 
fmt-type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt-fmt.pix.width = go-width;
@@ -497,7 +475,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void 
*priv,
 static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *fmt)
 {
-   struct go7007 *go = ((struct go7007_file *) priv)-go;
+   struct go7007 *go = video_drvdata(file);
 
return set_capture_size(go, fmt, 1);
 }
@@ -505,7 +483,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void 
*priv,
 static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *fmt)
 {
-   struct go7007 *go = ((struct go7007_file *) priv)-go;
+   struct go7007 *go = video_drvdata(file);
 
if (go-streaming)
return -EBUSY;
@@ -516,8 +494,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
 static int vidioc_reqbufs(struct file *file, void *priv,
  struct v4l2_requestbuffers *req)
 {
-   struct go7007_file *gofh = priv;
-   struct go7007 *go = gofh-go;
+   struct go7007 *go = video_drvdata(file);

[REVIEW PATCH 31/42] go7007: simplify the PX-TV402U board ID handling.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

There really is no need to split out the board IDs for each tuner.
That's what the tuner_type is for, after all.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-priv.h |   15 ++-
 drivers/staging/media/go7007/go7007-usb.c  |9 +++--
 drivers/staging/media/go7007/go7007-v4l2.c |9 -
 3 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index c2fafb2..a6ef67b 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -36,15 +36,12 @@ struct go7007;
 #define GO7007_BOARDID_XMEN_II 5
 #define GO7007_BOARDID_XMEN_III6
 #define GO7007_BOARDID_MATRIX_REV  7
-#define GO7007_BOARDID_PX_M402U16
-#define GO7007_BOARDID_PX_TV402U_ANY   17 /* need to check tuner model */
-#define GO7007_BOARDID_PX_TV402U_NA18 /* detected NTSC tuner */
-#define GO7007_BOARDID_PX_TV402U_EU19 /* detected PAL tuner */
-#define GO7007_BOARDID_PX_TV402U_JP20 /* detected NTSC-J tuner */
-#define GO7007_BOARDID_LIFEVIEW_LR192  21 /* TV Walker Ultra */
-#define GO7007_BOARDID_ENDURA  22
-#define GO7007_BOARDID_ADLINK_MPG2423
-#define GO7007_BOARDID_SENSORAY_2250   24 /* Sensoray 2250/2251 */
+#define GO7007_BOARDID_PX_M402U8
+#define GO7007_BOARDID_PX_TV402U   9
+#define GO7007_BOARDID_LIFEVIEW_LR192  10 /* TV Walker Ultra */
+#define GO7007_BOARDID_ENDURA  11
+#define GO7007_BOARDID_ADLINK_MPG2412
+#define GO7007_BOARDID_SENSORAY_2250   13 /* Sensoray 2250/2251 */
 
 /* Various characteristics of each board */
 #define GO7007_BOARD_HAS_AUDIO (10)
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 14d1cda..53c5b16 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -568,7 +568,7 @@ static const struct usb_device_id go7007_usb_id_table[] = {
.idProduct  = 0xa104,  /* Product ID of TV402U */
.bcdDevice_lo   = 0x1,
.bcdDevice_hi   = 0x1,
-   .driver_info= (kernel_ulong_t)GO7007_BOARDID_PX_TV402U_ANY,
+   .driver_info= (kernel_ulong_t)GO7007_BOARDID_PX_TV402U,
},
{
.match_flags= USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION,
@@ -1079,7 +1079,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
name = Plextor PX-M402U;
board = board_matrix_ii;
break;
-   case GO7007_BOARDID_PX_TV402U_ANY:
+   case GO7007_BOARDID_PX_TV402U:
name = Plextor PX-TV402U (unknown tuner);
board = board_px_tv402u;
break;
@@ -1200,7 +1200,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
num_i2c_devs = go-board_info-num_i2c_devs;
 
/* Probe the tuner model on the TV402U */
-   if (go-board_id == GO7007_BOARDID_PX_TV402U_ANY) {
+   if (go-board_id == GO7007_BOARDID_PX_TV402U) {
/* Board strapping indicates tuner model */
if (go7007_usb_vendor_request(go, 0x41, 0, 0, go-usb_buf, 3, 
1)  0) {
printk(KERN_ERR go7007-usb: GPIO read failed!\n);
@@ -1208,14 +1208,12 @@ static int go7007_usb_probe(struct usb_interface *intf,
}
switch (go-usb_buf[0]  6) {
case 1:
-   go-board_id = GO7007_BOARDID_PX_TV402U_EU;
go-tuner_type = TUNER_SONY_BTF_PG472Z;
go-std = V4L2_STD_PAL;
strncpy(go-name, Plextor PX-TV402U-EU,
sizeof(go-name));
break;
case 2:
-   go-board_id = GO7007_BOARDID_PX_TV402U_JP;
go-tuner_type = TUNER_SONY_BTF_PK467Z;
go-std = V4L2_STD_NTSC_M_JP;
num_i2c_devs -= 2;
@@ -1223,7 +1221,6 @@ static int go7007_usb_probe(struct usb_interface *intf,
sizeof(go-name));
break;
case 3:
-   go-board_id = GO7007_BOARDID_PX_TV402U_NA;
go-tuner_type = TUNER_SONY_BTF_PB463Z;
num_i2c_devs -= 2;
strncpy(go-name, Plextor PX-TV402U-NA,
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index df5296f..fd6cae0 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -1075,15 +1075,6 @@ static int vidioc_s_tuner(struct file *file, void *priv,
if (t-index != 0)
return -EINVAL;
 
-   switch (go-board_id) {
-   

[REVIEW PATCH 28/42] go7007: add log_status support.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-v4l2.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 186a56b..d3eef8d 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -1188,6 +1188,14 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
return call_all(go-v4l2_dev, tuner, s_frequency, f);
 }
 
+static int vidioc_log_status(struct file *file, void *priv)
+{
+   struct go7007 *go = ((struct go7007_file *) priv)-go;
+
+   v4l2_ctrl_log_status(file, priv);
+   return call_all(go-v4l2_dev, core, log_status);
+}
+
 static int vidioc_cropcap(struct file *file, void *priv,
struct v4l2_cropcap *cropcap)
 {
@@ -1654,7 +1662,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_cropcap   = vidioc_cropcap,
.vidioc_g_crop= vidioc_g_crop,
.vidioc_s_crop= vidioc_s_crop,
-   .vidioc_log_status= v4l2_ctrl_log_status,
+   .vidioc_log_status= vidioc_log_status,
.vidioc_subscribe_event   = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
-- 
1.7.10.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


[REVIEW PATCH 25/42] go7007: convert to the control framework and remove obsolete JPEGCOMP support.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Just add a read-only V4L2_CID_JPEG_ACTIVE_MARKER control to replace
the JPEGCOMP support.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c |   11 +-
 drivers/staging/media/go7007/go7007-priv.h   |3 +
 drivers/staging/media/go7007/go7007-v4l2.c   |  249 +++---
 3 files changed, 71 insertions(+), 192 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index dca85d8..d689989 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -268,12 +268,17 @@ int go7007_register_encoder(struct go7007 *go, unsigned 
num_i2c_devs)
ret = go7007_init_encoder(go);
mutex_unlock(go-hw_lock);
if (ret  0)
-   return -1;
+   return ret;
+
+   ret = go7007_v4l2_ctrl_init(go);
+   if (ret  0)
+   return ret;
 
if (!go-i2c_adapter_online 
go-board_info-flags  GO7007_BOARD_USE_ONBOARD_I2C) {
-   if (go7007_i2c_init(go)  0)
-   return -1;
+   ret = go7007_i2c_init(go);
+   if (ret  0)
+   return ret;
go-i2c_adapter_online = 1;
}
if (go-i2c_adapter_online) {
diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index 54cfc0a..d127a8d 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -22,6 +22,7 @@
  */
 
 #include media/v4l2-device.h
+#include media/v4l2-ctrls.h
 
 struct go7007;
 
@@ -182,6 +183,7 @@ struct go7007 {
void *boot_fw;
unsigned boot_fw_len;
struct v4l2_device v4l2_dev;
+   struct v4l2_ctrl_handler hdl;
enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status;
spinlock_t spinlock;
struct mutex hw_lock;
@@ -296,6 +298,7 @@ int go7007_i2c_remove(struct go7007 *go);
 
 /* go7007-v4l2.c */
 int go7007_v4l2_init(struct go7007 *go);
+int go7007_v4l2_ctrl_init(struct go7007 *go);
 void go7007_v4l2_remove(struct go7007 *go);
 
 /* snd-go7007.c */
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 53d2cbc..cb89af3 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -42,9 +42,6 @@
 #ifndef V4L2_MPEG_STREAM_TYPE_MPEG_ELEM
 #defineV4L2_MPEG_STREAM_TYPE_MPEG_ELEM   6 /* MPEG elementary stream */
 #endif
-#ifndef V4L2_MPEG_VIDEO_ENCODING_MPEG_4
-#defineV4L2_MPEG_VIDEO_ENCODING_MPEG_4   3
-#endif
 
 #define call_all(dev, o, f, args...) \
v4l2_device_call_until_err(dev, 0, o, f, ##args)
@@ -387,67 +384,18 @@ static int clip_to_modet_map(struct go7007 *go, int 
region,
 }
 #endif
 
-static int mpeg_query_ctrl(struct v4l2_queryctrl *ctrl)
+static int go7007_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   static const u32 mpeg_ctrls[] = {
-   V4L2_CID_MPEG_CLASS,
-   V4L2_CID_MPEG_STREAM_TYPE,
-   V4L2_CID_MPEG_VIDEO_ENCODING,
-   V4L2_CID_MPEG_VIDEO_ASPECT,
-   V4L2_CID_MPEG_VIDEO_GOP_SIZE,
-   V4L2_CID_MPEG_VIDEO_GOP_CLOSURE,
-   V4L2_CID_MPEG_VIDEO_BITRATE,
-   0
-   };
-   static const u32 *ctrl_classes[] = {
-   mpeg_ctrls,
-   NULL
-   };
-
-   ctrl-id = v4l2_ctrl_next(ctrl_classes, ctrl-id);
-
-   switch (ctrl-id) {
-   case V4L2_CID_MPEG_CLASS:
-   return v4l2_ctrl_query_fill(ctrl, 0, 0, 0, 0);
-   case V4L2_CID_MPEG_STREAM_TYPE:
-   return v4l2_ctrl_query_fill(ctrl,
-   V4L2_MPEG_STREAM_TYPE_MPEG2_DVD,
-   V4L2_MPEG_STREAM_TYPE_MPEG_ELEM, 1,
-   V4L2_MPEG_STREAM_TYPE_MPEG_ELEM);
-   case V4L2_CID_MPEG_VIDEO_ENCODING:
-   return v4l2_ctrl_query_fill(ctrl,
-   V4L2_MPEG_VIDEO_ENCODING_MPEG_1,
-   V4L2_MPEG_VIDEO_ENCODING_MPEG_4, 1,
-   V4L2_MPEG_VIDEO_ENCODING_MPEG_2);
-   case V4L2_CID_MPEG_VIDEO_ASPECT:
-   return v4l2_ctrl_query_fill(ctrl,
-   V4L2_MPEG_VIDEO_ASPECT_1x1,
-   V4L2_MPEG_VIDEO_ASPECT_16x9, 1,
-   V4L2_MPEG_VIDEO_ASPECT_1x1);
-   case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
-   return v4l2_ctrl_query_fill(ctrl, 0, 34, 1, 15);
-   case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE:
-   return v4l2_ctrl_query_fill(ctrl, 0, 1, 1, 0);
-   case V4L2_CID_MPEG_VIDEO_BITRATE:
-   return v4l2_ctrl_query_fill(ctrl,
-   64000,
-   1000, 1,
-   

[REVIEW PATCH 12/42] tw9903: add new tw9903 video decoder.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This based on the wis-tw9903.c driver that's part of the go7007 driver.
It has been converted to a v4l subdev driver by Pete Eberlein, and I made
additional cleanups.

Based on work by: Pete Eberlein p...@sensoray.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Cc: Pete Eberlein p...@sensoray.com
---
 drivers/media/i2c/Kconfig  |   10 ++
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/tw9903.c |  274 
 3 files changed, 285 insertions(+)
 create mode 100644 drivers/media/i2c/tw9903.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 8000642..eb9ef55 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -301,6 +301,16 @@ config VIDEO_TVP7002
  To compile this driver as a module, choose M here: the
  module will be called tvp7002.
 
+config VIDEO_TW9903
+   tristate Techwell TW9903 video decoder
+   depends on VIDEO_V4L2  I2C
+   ---help---
+ Support for the Techwell 9903 multi-standard video decoder
+ with high quality down scaler.
+
+ To compile this driver as a module, choose M here: the
+ module will be called tw9903.
+
 config VIDEO_VPX3220
tristate vpx3220a, vpx3216b  vpx3214c video decoders
depends on VIDEO_V4L2  I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index b1775b3..af8fb29 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_VIDEO_THS7303) += ths7303.o
 obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
 obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
 obj-$(CONFIG_VIDEO_TVP7002) += tvp7002.o
+obj-$(CONFIG_VIDEO_TW9903) += tw9903.o
 obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
 obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
 obj-$(CONFIG_VIDEO_M52790) += m52790.o
diff --git a/drivers/media/i2c/tw9903.c b/drivers/media/i2c/tw9903.c
new file mode 100644
index 000..82626ea
--- /dev/null
+++ b/drivers/media/i2c/tw9903.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright (C) 2005-2006 Micronas USA Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/i2c.h
+#include linux/videodev2.h
+#include linux/ioctl.h
+#include media/v4l2-device.h
+#include media/v4l2-ctrls.h
+#include linux/slab.h
+
+MODULE_DESCRIPTION(TW9903 I2C subdev driver);
+MODULE_LICENSE(GPL v2);
+
+/*
+ * This driver is based on the wis-tw9903.c source that was in
+ * drivers/staging/media/go7007. That source had commented out code for
+ * saturation and scaling (neither seemed to work). If anyone ever gets
+ * hardware to test this driver, then that code might be useful to look at.
+ * You need to get the kernel sources of, say, kernel 3.8 where that
+ * wis-tw9903 driver is still present.
+ */
+
+struct tw9903 {
+   struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+   v4l2_std_id norm;
+};
+
+static inline struct tw9903 *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct tw9903, sd);
+}
+
+static const u8 initial_registers[] = {
+   0x02, 0x44, /* input 1, composite */
+   0x03, 0x92, /* correct digital format */
+   0x04, 0x00,
+   0x05, 0x80, /* or 0x00 for PAL */
+   0x06, 0x40, /* second internal current reference */
+   0x07, 0x02, /* window */
+   0x08, 0x14, /* window */
+   0x09, 0xf0, /* window */
+   0x0a, 0x81, /* window */
+   0x0b, 0xd0, /* window */
+   0x0c, 0x8c,
+   0x0d, 0x00, /* scaling */
+   0x0e, 0x11, /* scaling */
+   0x0f, 0x00, /* scaling */
+   0x10, 0x00, /* brightness */
+   0x11, 0x60, /* contrast */
+   0x12, 0x01, /* sharpness */
+   0x13, 0x7f, /* U gain */
+   0x14, 0x5a, /* V gain */
+   0x15, 0x00, /* hue */
+   0x16, 0xc3, /* sharpness */
+   0x18, 0x00,
+   0x19, 0x58, /* vbi */
+   0x1a, 0x80,
+   0x1c, 0x0f, /* video norm */
+   0x1d, 0x7f, /* video norm */
+   0x20, 0xa0, /* clamping gain (working 0x50) */
+   0x21, 0x22,
+   0x22, 0xf0,
+   0x23, 0xfe,
+   0x24, 0x3c,
+   0x25, 0x38,
+   0x26, 0x44,
+   0x27, 0x20,
+   0x28, 0x00,
+   0x29, 0x15,
+   0x2a, 0xa0,
+   0x2b, 0x44,
+   0x2c, 0x37,
+   0x2d, 0x00,
+   0x2e, 0xa5, /* burst PLL control 

[REVIEW PATCH 07/42] go7007: fix i2c_xfer return codes.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The i2c_xfer functions didn't return the proper error codes and (especially
important) on success they returned 0 instead of the number of transferred
messages.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-i2c.c |   20 ++--
 drivers/staging/media/go7007/go7007-usb.c |6 +++---
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-i2c.c 
b/drivers/staging/media/go7007/go7007-i2c.c
index 39456a3..1d0a400 100644
--- a/drivers/staging/media/go7007/go7007-i2c.c
+++ b/drivers/staging/media/go7007/go7007-i2c.c
@@ -52,11 +52,11 @@ static DEFINE_MUTEX(adlink_mpg24_i2c_lock);
 static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read,
u16 command, int flags, u8 *data)
 {
-   int i, ret = -1;
+   int i, ret = -EIO;
u16 val;
 
if (go-status == STATUS_SHUTDOWN)
-   return -1;
+   return -ENODEV;
 
 #ifdef GO7007_I2C_DEBUG
if (read)
@@ -146,7 +146,7 @@ static int go7007_smbus_xfer(struct i2c_adapter *adapter, 
u16 addr,
struct go7007 *go = i2c_get_adapdata(adapter);
 
if (size != I2C_SMBUS_BYTE_DATA)
-   return -1;
+   return -EIO;
return go7007_i2c_xfer(go, addr, read_write == I2C_SMBUS_READ, command,
flags  I2C_CLIENT_SCCB ? 0x10 : 0x00, data-byte);
 }
@@ -170,26 +170,26 @@ static int go7007_i2c_master_xfer(struct i2c_adapter 
*adapter,
(msgs[i].flags  I2C_M_RD) ||
!(msgs[i + 1].flags  I2C_M_RD) ||
msgs[i + 1].len != 1)
-   return -1;
+   return -EIO;
if (go7007_i2c_xfer(go, msgs[i].addr, 1,
(msgs[i].buf[0]  8) | msgs[i].buf[1],
0x01, msgs[i + 1].buf[0])  0)
-   return -1;
+   return -EIO;
++i;
} else if (msgs[i].len == 3) {
if (msgs[i].flags  I2C_M_RD)
-   return -1;
+   return -EIO;
if (msgs[i].len != 3)
-   return -1;
+   return -EIO;
if (go7007_i2c_xfer(go, msgs[i].addr, 0,
(msgs[i].buf[0]  8) | msgs[i].buf[1],
0x01, msgs[i].buf[2])  0)
-   return -1;
+   return -EIO;
} else
-   return -1;
+   return -EIO;
}
 
-   return 0;
+   return num;
 }
 
 static u32 go7007_functionality(struct i2c_adapter *adapter)
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 9dbf5ec..914b247 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -876,10 +876,10 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter 
*adapter,
struct go7007_usb *usb = go-hpi_context;
u8 buf[16];
int buf_len, i;
-   int ret = -1;
+   int ret = -EIO;
 
if (go-status == STATUS_SHUTDOWN)
-   return -1;
+   return -ENODEV;
 
mutex_lock(usb-i2c_lock);
 
@@ -936,7 +936,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter 
*adapter,
memcpy(msgs[i].buf, buf + 1, msgs[i].len);
}
}
-   ret = 0;
+   ret = num;
 
 i2c_done:
mutex_unlock(usb-i2c_lock);
-- 
1.7.10.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


[REVIEW PATCH 16/42] go7007: switch to standard tuner/i2c subdevs.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Instead of using the wis-* drivers we now use the standard 'proper' subdev
drivers.

The board configuration tables now also list the possible audio inputs,
this will be used later to implement audio inputs.

Special mention deserves a little change in set_capture_size() where the
height passed to s_mbus_fmt is doubled: that is because the saa7115 driver
expects to see the frame height, not the field height as the wis_saa7115
driver did.

Another change is that the tuner input is moved from last to the first
input, which is consistent with the common practice in other video drivers.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/Kconfig  |   77 ++---
 drivers/staging/media/go7007/Makefile |   12 ---
 drivers/staging/media/go7007/go7007-driver.c  |   29 +--
 drivers/staging/media/go7007/go7007-i2c.c |1 -
 drivers/staging/media/go7007/go7007-priv.h|   18 +++-
 drivers/staging/media/go7007/go7007-usb.c |  112 +
 drivers/staging/media/go7007/go7007-v4l2.c|   18 +++-
 drivers/staging/media/go7007/saa7134-go7007.c |2 +-
 8 files changed, 135 insertions(+), 134 deletions(-)

diff --git a/drivers/staging/media/go7007/Kconfig 
b/drivers/staging/media/go7007/Kconfig
index 7dfb281..da32031 100644
--- a/drivers/staging/media/go7007/Kconfig
+++ b/drivers/staging/media/go7007/Kconfig
@@ -8,6 +8,12 @@ config VIDEO_GO7007
select VIDEO_TVEEPROM
select SND_PCM
select CRC32
+   select VIDEO_SONY_BTF_MPX if MEDIA_SUBDRV_AUTOSELECT
+   select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
+   select VIDEO_TW2804 if MEDIA_SUBDRV_AUTOSELECT
+   select VIDEO_TW9903 if MEDIA_SUBDRV_AUTOSELECT
+   select VIDEO_OV7640 if MEDIA_SUBDRV_AUTOSELECT
+   select VIDEO_UDA1342 if MEDIA_SUBDRV_AUTOSELECT
default N
---help---
  This is a video4linux driver for the WIS GO7007 MPEG
@@ -36,74 +42,3 @@ config VIDEO_GO7007_USB_S2250_BOARD
 
  To compile this driver as a module, choose M here: the
  module will be called s2250
-
-config VIDEO_GO7007_OV7640
-   tristate OV7640 subdev support
-   depends on VIDEO_GO7007
-   default N
-   ---help---
- This is a video4linux driver for the OV7640 sub-device.
-
- To compile this driver as a module, choose M here: the
- module will be called wis-ov7640
-
-config VIDEO_GO7007_SAA7113
-   tristate SAA7113 subdev support
-   depends on VIDEO_GO7007
-   default N
-   ---help---
- This is a video4linux driver for the SAA7113 sub-device.
-
- To compile this driver as a module, choose M here: the
- module will be called wis-saa7113
-
-config VIDEO_GO7007_SAA7115
-   tristate SAA7115 subdev support
-   depends on VIDEO_GO7007
-   default N
-   ---help---
- This is a video4linux driver for the SAA7115 sub-device.
-
- To compile this driver as a module, choose M here: the
- module will be called wis-saa7115
-
-config VIDEO_GO7007_TW9903
-   tristate TW9903 subdev support
-   depends on VIDEO_GO7007
-   default N
-   ---help---
- This is a video4linux driver for the TW9903 sub-device.
-
- To compile this driver as a module, choose M here: the
- module will be called wis-tw9903
-
-config VIDEO_GO7007_UDA1342
-   tristate UDA1342 subdev support
-   depends on VIDEO_GO7007
-   default N
-   ---help---
- This is a video4linux driver for the UDA1342 sub-device.
-
- To compile this driver as a module, choose M here: the
- module will be called wis-uda1342
-
-config VIDEO_GO7007_SONY_TUNER
-   tristate Sony tuner subdev support
-   depends on VIDEO_GO7007
-   default N
-   ---help---
- This is a video4linux driver for the Sony Tuner sub-device.
-
- To compile this driver as a module, choose M here: the
- module will be called wis-sony-tuner
-
-config VIDEO_GO7007_TW2804
-   tristate TW2804 subdev support
-   depends on VIDEO_GO7007
-   default N
-   ---help---
- This is a video4linux driver for the TW2804 sub-device.
-
- To compile this driver as a module, choose M here: the
- module will be called wis-tw2804
-
diff --git a/drivers/staging/media/go7007/Makefile 
b/drivers/staging/media/go7007/Makefile
index 3fdbef5..5bed78b 100644
--- a/drivers/staging/media/go7007/Makefile
+++ b/drivers/staging/media/go7007/Makefile
@@ -1,18 +1,6 @@
-#obj-m += go7007.o go7007-usb.o snd-go7007.o wis-saa7115.o wis-tw9903.o \
-   wis-uda1342.o wis-sony-tuner.o wis-saa7113.o wis-ov7640.o \
-   wis-tw2804.o
-
-
 obj-$(CONFIG_VIDEO_GO7007) += go7007.o
 obj-$(CONFIG_VIDEO_GO7007_USB) += go7007-usb.o
 obj-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD) += s2250.o s2250-loader.o
-obj-$(CONFIG_VIDEO_GO7007_SAA7113) += 

[REVIEW PATCH 20/42] go7007: go7007: add device_caps and bus_info support to querycap.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

And don't set the version field, the core does that for you.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-priv.h|1 +
 drivers/staging/media/go7007/go7007-usb.c |1 +
 drivers/staging/media/go7007/go7007-v4l2.c|   10 +++---
 drivers/staging/media/go7007/saa7134-go7007.c |1 +
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index 898eb5b..1c4b049 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -171,6 +171,7 @@ enum go7007_parser_state {
 
 struct go7007 {
struct device *dev;
+   u8 bus_info[32];
struct go7007_board_info *board_info;
unsigned int board_id;
int tuner_type;
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 5e3e5a0..0b1af50 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1087,6 +1087,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
goto allocfail;
usb-board = board;
usb-usbdev = usbdev;
+   usb_make_path(usbdev, go-bus_info, sizeof(go-bus_info));
go-board_id = id-driver_info;
strncpy(go-name, name, sizeof(go-name));
if (board-flags  GO7007_USB_EZUSB)
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index b79cda8..6f14ac5 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -602,19 +602,15 @@ static int vidioc_querycap(struct file *file, void  *priv,
 
strlcpy(cap-driver, go7007, sizeof(cap-driver));
strlcpy(cap-card, go-name, sizeof(cap-card));
-#if 0
-   strlcpy(cap-bus_info, dev_name(dev-udev-dev), 
sizeof(cap-bus_info));
-#endif
-
-   cap-version = KERNEL_VERSION(0, 9, 8);
+   strlcpy(cap-bus_info, go-bus_info, sizeof(cap-bus_info));
 
cap-capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
 
if (go-board_info-num_aud_inputs)
cap-device_caps |= V4L2_CAP_AUDIO;
if (go-board_info-flags  GO7007_BOARD_HAS_TUNER)
-   cap-capabilities |= V4L2_CAP_TUNER;
-
+   cap-device_caps |= V4L2_CAP_TUNER;
+   cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
 }
 
diff --git a/drivers/staging/media/go7007/saa7134-go7007.c 
b/drivers/staging/media/go7007/saa7134-go7007.c
index e037a39..d65e17a 100644
--- a/drivers/staging/media/go7007/saa7134-go7007.c
+++ b/drivers/staging/media/go7007/saa7134-go7007.c
@@ -456,6 +456,7 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
if (go == NULL)
goto allocfail;
go-board_id = GO7007_BOARDID_PCI_VOYAGER;
+   snprintf(go-bus_info, sizeof(go-bus_info), PCI:%s, 
pci_name(dev-pci));
strncpy(go-name, saa7134_boards[dev-board].name, sizeof(go-name));
go-hpi_ops = saa7134_go7007_hpi_ops;
go-hpi_context = saa;
-- 
1.7.10.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


[REVIEW PATCH 18/42] go7007: add audio input ioctls.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Since we now know what audio inputs there are, we can also get/set and
enumerate them.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-v4l2.c |   51 ++--
 1 file changed, 48 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index bab4a31..b79cda8 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -608,9 +608,10 @@ static int vidioc_querycap(struct file *file, void  *priv,
 
cap-version = KERNEL_VERSION(0, 9, 8);
 
-   cap-capabilities = V4L2_CAP_VIDEO_CAPTURE |
-   V4L2_CAP_STREAMING; /* | V4L2_CAP_AUDIO; */
+   cap-capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
 
+   if (go-board_info-num_aud_inputs)
+   cap-device_caps |= V4L2_CAP_AUDIO;
if (go-board_info-flags  GO7007_BOARD_HAS_TUNER)
cap-capabilities |= V4L2_CAP_TUNER;
 
@@ -1191,7 +1192,10 @@ static int vidioc_enum_input(struct file *file, void 
*priv,
else
inp-type = V4L2_INPUT_TYPE_CAMERA;
 
-   inp-audioset = 0;
+   if (go-board_info-num_aud_inputs)
+   inp-audioset = (1  go-board_info-num_aud_inputs) - 1;
+   else
+   inp-audioset = 0;
inp-tuner = 0;
if (go-board_info-sensor_flags  GO7007_SENSOR_TV)
inp-std = V4L2_STD_NTSC | V4L2_STD_PAL |
@@ -1212,6 +1216,39 @@ static int vidioc_g_input(struct file *file, void *priv, 
unsigned int *input)
return 0;
 }
 
+static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a)
+{
+   struct go7007 *go = video_drvdata(file);
+
+   if (a-index = go-board_info-num_aud_inputs)
+   return -EINVAL;
+   strlcpy(a-name, go-board_info-aud_inputs[a-index].name, 
sizeof(a-name));
+   a-capability = V4L2_AUDCAP_STEREO;
+   return 0;
+}
+
+static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a)
+{
+   struct go7007 *go = video_drvdata(file);
+
+   a-index = go-aud_input;
+   strlcpy(a-name, go-board_info-aud_inputs[go-aud_input].name, 
sizeof(a-name));
+   a-capability = V4L2_AUDCAP_STEREO;
+   return 0;
+}
+
+static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio 
*a)
+{
+   struct go7007 *go = video_drvdata(file);
+
+   if (a-index = go-board_info-num_aud_inputs)
+   return -EINVAL;
+   go-aud_input = a-index;
+   v4l2_subdev_call(go-sd_audio, audio, s_routing,
+   go-board_info-aud_inputs[go-aud_input].audio_input, 
0, 0);
+   return 0;
+}
+
 static int vidioc_s_input(struct file *file, void *priv, unsigned int input)
 {
struct go7007 *go = ((struct go7007_file *) priv)-go;
@@ -1772,6 +1809,9 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_enum_input= vidioc_enum_input,
.vidioc_g_input   = vidioc_g_input,
.vidioc_s_input   = vidioc_s_input,
+   .vidioc_enumaudio = vidioc_enumaudio,
+   .vidioc_g_audio   = vidioc_g_audio,
+   .vidioc_s_audio   = vidioc_s_audio,
.vidioc_queryctrl = vidioc_queryctrl,
.vidioc_g_ctrl= vidioc_g_ctrl,
.vidioc_s_ctrl= vidioc_s_ctrl,
@@ -1816,6 +1856,11 @@ int go7007_v4l2_init(struct go7007 *go)
go-video_dev = NULL;
return rv;
}
+   if (go-board_info-num_aud_inputs == 0) {
+   v4l2_disable_ioctl(go-video_dev, VIDIOC_G_AUDIO);
+   v4l2_disable_ioctl(go-video_dev, VIDIOC_S_AUDIO);
+   v4l2_disable_ioctl(go-video_dev, VIDIOC_ENUMAUDIO);
+   }
rv = v4l2_device_register(go-dev, go-v4l2_dev);
if (rv  0) {
video_device_release(go-video_dev);
-- 
1.7.10.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


[REVIEW PATCH 11/42] uda1342: add new uda1342 audio codec driver

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This based on the wis-uda1342.c driver that's part of the go7007 driver.
It has been converted to a v4l subdev driver by Pete Eberlein, and I made
additional cleanups.

Based on work by: Pete Eberlein p...@sensoray.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Cc: Pete Eberlein p...@sensoray.com
---
 drivers/media/i2c/Kconfig   |9 
 drivers/media/i2c/Makefile  |1 +
 drivers/media/i2c/uda1342.c |  113 +++
 include/media/uda1342.h |   29 +++
 4 files changed, 152 insertions(+)
 create mode 100644 drivers/media/i2c/uda1342.c
 create mode 100644 include/media/uda1342.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index fe5f9d0..8000642 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -112,6 +112,15 @@ config VIDEO_TLV320AIC23B
  To compile this driver as a module, choose M here: the
  module will be called tlv320aic23b.
 
+config VIDEO_UDA1342
+   tristate Philips UDA1342 audio codec
+   depends on VIDEO_V4L2  I2C
+   ---help---
+ Support for the Philips UDA1342 audio codec.
+
+ To compile this driver as a module, choose M here: the
+ module will be called uda1342.
+
 config VIDEO_WM8775
tristate Wolfson Microelectronics WM8775 audio ADC with input mixer
depends on VIDEO_V4L2  I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index adf9504..b1775b3 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
 obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
 obj-$(CONFIG_VIDEO_M52790) += m52790.o
 obj-$(CONFIG_VIDEO_TLV320AIC23B) += tlv320aic23b.o
+obj-$(CONFIG_VIDEO_UDA1342) += uda1342.o
 obj-$(CONFIG_VIDEO_WM8775) += wm8775.o
 obj-$(CONFIG_VIDEO_WM8739) += wm8739.o
 obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
diff --git a/drivers/media/i2c/uda1342.c b/drivers/media/i2c/uda1342.c
new file mode 100644
index 000..3af4085
--- /dev/null
+++ b/drivers/media/i2c/uda1342.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2005-2006 Micronas USA Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/i2c.h
+#include linux/videodev2.h
+#include media/v4l2-device.h
+#include media/uda1342.h
+#include linux/slab.h
+
+static int write_reg(struct i2c_client *client, int reg, int value)
+{
+   /* UDA1342 wants MSB first, but SMBus sends LSB first */
+   i2c_smbus_write_word_data(client, reg, swab16(value));
+   return 0;
+}
+
+static int uda1342_s_routing(struct v4l2_subdev *sd,
+   u32 input, u32 output, u32 config)
+{
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+   switch (input) {
+   case UDA1342_IN1:
+   write_reg(client, 0x00, 0x1241); /* select input 1 */
+   break;
+   case UDA1342_IN2:
+   write_reg(client, 0x00, 0x1441); /* select input 2 */
+   break;
+   default:
+   v4l2_err(sd, input %d not supported\n, input);
+   break;
+   }
+   return 0;
+}
+
+static const struct v4l2_subdev_audio_ops uda1342_audio_ops = {
+   .s_routing = uda1342_s_routing,
+};
+
+static const struct v4l2_subdev_ops uda1342_ops = {
+   .audio = uda1342_audio_ops,
+};
+
+static int uda1342_probe(struct i2c_client *client,
+const struct i2c_device_id *id)
+{
+   struct i2c_adapter *adapter = client-adapter;
+   struct v4l2_subdev *sd;
+
+   if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
+   return -ENODEV;
+
+   dev_dbg(client-dev, initializing UDA1342 at address %d on %s\n,
+   client-addr, adapter-name);
+
+   sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+   if (sd == NULL)
+   return -ENOMEM;
+
+   v4l2_i2c_subdev_init(sd, client, uda1342_ops);
+
+   write_reg(client, 0x00, 0x8000); /* reset registers */
+   write_reg(client, 0x00, 0x1241); /* select input 1 */
+
+   v4l_info(client, chip found @ 0x%02x (%s)\n,
+   client-addr  1, client-adapter-name);
+
+   return 0;
+}
+
+static int uda1342_remove(struct i2c_client *client)
+{
+   struct v4l2_subdev *sd = 

[REVIEW PATCH 10/42] ov7640: add new ov7640 driver

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This based on the wis-ov7640.c driver that's part of the go7007 driver.
It has been converted to a v4l subdev driver by Pete Eberlein, and I made
additional cleanups.

Based on work by: Pete Eberlein p...@sensoray.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Cc: Pete Eberlein p...@sensoray.com
---
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |3 +-
 drivers/media/i2c/ov7640.c |  106 
 3 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/i2c/ov7640.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 70dbae2..fe5f9d0 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -395,6 +395,17 @@ config VIDEO_APTINA_PLL
 config VIDEO_SMIAPP_PLL
tristate
 
+config VIDEO_OV7640
+   tristate OmniVision OV7640 sensor support
+   depends on I2C  VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV7640 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov7640.
+
 config VIDEO_OV7670
tristate OmniVision OV7670 sensor support
depends on I2C  VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 4c57075..adf9504 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -47,7 +47,8 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
 obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
-obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
+obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
+obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
 obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
 obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o
 obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
diff --git a/drivers/media/i2c/ov7640.c b/drivers/media/i2c/ov7640.c
new file mode 100644
index 000..b0cc927
--- /dev/null
+++ b/drivers/media/i2c/ov7640.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2005-2006 Micronas USA Inc.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/i2c.h
+#include linux/videodev2.h
+#include media/v4l2-device.h
+#include media/v4l2-chip-ident.h
+#include linux/slab.h
+
+MODULE_DESCRIPTION(OmniVision ov7640 sensor driver);
+MODULE_LICENSE(GPL v2);
+
+static const u8 initial_registers[] = {
+   0x12, 0x80,
+   0x12, 0x54,
+   0x14, 0x24,
+   0x15, 0x01,
+   0x28, 0x20,
+   0x75, 0x82,
+   0xFF, 0xFF, /* Terminator (reg 0xFF is unused) */
+};
+
+static int write_regs(struct i2c_client *client, const u8 *regs)
+{
+   int i;
+
+   for (i = 0; regs[i] != 0xFF; i += 2)
+   if (i2c_smbus_write_byte_data(client, regs[i], regs[i + 1])  0)
+   return -1;
+   return 0;
+}
+
+/* --- */
+
+static const struct v4l2_subdev_ops ov7640_ops;
+
+static int ov7640_probe(struct i2c_client *client,
+   const struct i2c_device_id *id)
+{
+   struct i2c_adapter *adapter = client-adapter;
+   struct v4l2_subdev *sd;
+
+   if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+   return -ENODEV;
+
+   sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+   if (sd == NULL)
+   return -ENOMEM;
+   v4l2_i2c_subdev_init(sd, client, ov7640_ops);
+
+   client-flags = I2C_CLIENT_SCCB;
+
+   v4l_info(client, chip found @ 0x%02x (%s)\n,
+   client-addr  1, client-adapter-name);
+
+   if (write_regs(client, initial_registers)  0) {
+   v4l_err(client, error initializing OV7640\n);
+   kfree(sd);
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
+
+static int ov7640_remove(struct i2c_client *client)
+{
+   struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+   v4l2_device_unregister_subdev(sd);
+   kfree(sd);
+   return 0;
+}
+
+static const struct i2c_device_id ov7640_id[] = {
+   { ov7640, 0 },
+   { }
+};
+MODULE_DEVICE_TABLE(i2c, ov7640_id);
+
+static struct i2c_driver ov7640_driver = {
+   .driver = 

[REVIEW PATCH 15/42] go7007: i2c initialization changes for tw2804

2013-03-11 Thread Hans Verkuil
From: Volokh Konstantin volok...@gmail.com

Do i2c initialization via struct item as tw2804 has a 0x00 i2c address,
so we need to use the I2C_CLIENT_TEN flag for validity.

Signed-off-by: Volokh Konstantin volok...@gmail.com
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c |   20 +++-
 drivers/staging/media/go7007/go7007-priv.h   |3 ++-
 drivers/staging/media/go7007/go7007-usb.c|1 +
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index 6695091..2e5be70 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -196,18 +196,22 @@ int go7007_reset_encoder(struct go7007 *go)
 /*
  * Attempt to instantiate an I2C client by ID, probably loading a module.
  */
-static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
-  int addr)
+static int init_i2c_module(struct i2c_adapter *adapter, const struct go_i2c 
*const i2c)
 {
struct go7007 *go = i2c_get_adapdata(adapter);
struct v4l2_device *v4l2_dev = go-v4l2_dev;
+   struct i2c_board_info info;
 
-   if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, addr, NULL))
+   memset(info, 0, sizeof(info));
+   strlcpy(info.type, i2c-type, sizeof(info.type));
+   info.addr = i2c-addr;
+   info.flags = i2c-flags;
+
+   if (v4l2_i2c_new_subdev_board(v4l2_dev, adapter, info, NULL))
return 0;
 
-   dev_info(adapter-dev,
-go7007: probing for module i2c:%s failed\n, type);
-   return -1;
+   printk(KERN_INFO go7007: probing for module i2c:%s failed\n, 
i2c-type);
+   return -EINVAL;
 }
 
 /*
@@ -243,9 +247,7 @@ int go7007_register_encoder(struct go7007 *go)
}
if (go-i2c_adapter_online) {
for (i = 0; i  go-board_info-num_i2c_devs; ++i)
-   init_i2c_module(go-i2c_adapter,
-   go-board_info-i2c_devs[i].type,
-   go-board_info-i2c_devs[i].addr);
+   init_i2c_module(go-i2c_adapter, 
go-board_info-i2c_devs[i]);
if (go-board_id == GO7007_BOARDID_ADLINK_MPG24)
i2c_clients_command(go-i2c_adapter,
DECODER_SET_CHANNEL, go-channel_number);
diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index b58c394..b9ebdfb 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -88,10 +88,11 @@ struct go7007_board_info {
int audio_bclk_div;
int audio_main_div;
int num_i2c_devs;
-   struct {
+   struct go_i2c {
const char *type;
int id;
int addr;
+   u32 flags;
} i2c_devs[4];
int num_inputs;
struct {
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index a8f..b44f9b1 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -398,6 +398,7 @@ static struct go7007_usb_board board_adlink_mpg24 = {
.type   = wis_tw2804,
.id = I2C_DRIVERID_WIS_TW2804,
.addr   = 0x00, /* yes, really */
+   .flags  = I2C_CLIENT_TEN,
},
},
.num_inputs  = 1,
-- 
1.7.10.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: [REVIEW PATCH 01/42] v4l2-ctrls: eliminate lockdep false alarms for struct v4l2_ctrl_handler.lock

2013-03-11 Thread Hans Verkuil
On Mon March 11 2013 12:45:39 Hans Verkuil wrote:
 From: Andy Walls awalls at

Oops, somehow I messed up Andy's email. I've corrected it in my git tree.

Regards,

Hans

 
 When calling v4l2_ctrl_add_handler(), lockdep would detect a potential
 recursive locking problem on a situation that is by design intended and
 not a recursive lock.  This happened because all struct
 v4l2_ctrl_handler.lock mutexes were created as members of the same lock
 class in v4l2_ctrl_handler_init(), and v4l2_ctrl_add_handler() takes the
 hdl-lock on two different v4l2_ctrl_handler instances.
 
 This change breaks the large lockdep lock class for struct
 v4l2_ctrl_handler.lock and breaks it into v4l2_ctrl_handler
 instantiation specific lock classes with meaningful class names.
 
 This will validly eliminate lockdep alarms for v4l2_ctrl_handler locking
 validation, as long as the relationships between drivers adding v4l2
 controls to their own handler from other v4l2 drivers' control handlers
 remains straightforward.
 
 struct v4l2_ctrl_handler.lock lock classes are created with names such
 that the output of cat /proc/lockdep indicates where in the v4l2 driver
 code v4l2_ctrl_handle_init() is being called on instantiations:
 
 a045f490 FD:   10 BD:8 +.+...: cx2341x:1534:(hdl)-lock
 a0497d20 FD:   12 BD:2 +.+.+.: saa7115:1581:(hdl)-lock
 a04ac660 FD:   14 BD:2 +.+.+.: msp3400_driver:756:(hdl)-lock
 a0484b90 FD:   12 BD:1 +.+.+.: 
 ivtv_gpio:366:(itv-hdl_gpio)-lock
 a04eb530 FD:   11 BD:2 +.+.+.: 
 cx25840_core:1982:(state-hdl)-lock
 a04fbc80 FD:   11 BD:3 +.+.+.: wm8775:246:(state-hdl)-lock
 
 Some lock chains, that were previously causing the recursion alarms, are
 now visible in the output of cat /proc/lockdep_chains:
 
 irq_context: 0
 [a0497d20] saa7115:1581:(hdl)-lock
 [a045f490] cx2341x:1534:(hdl)-lock
 
 irq_context: 0
 [a04ac660] msp3400_driver:756:(hdl)-lock
 [a045f490] cx2341x:1534:(hdl)-lock
 
 irq_context: 0
 [a0484b90] ivtv_gpio:366:(itv-hdl_gpio)-lock
 [a045f490] cx2341x:1534:(hdl)-lock
 
 irq_context: 0
 [a04eb530] cx25840_core:1982:(state-hdl)-lock
 [a045f490] cx2341x:1534:(hdl)-lock
 
 irq_context: 0
 [a04fbc80] wm8775:246:(state-hdl)-lock
 [a045f490] cx2341x:1534:(hdl)-lock
 
 Signed-off-by: Andy Walls awalls at md.metrocast.net
 [hans.verk...@cisco.com: keep mutex_init in v4l2_ctrl_handler_init_class]
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
  drivers/media/v4l2-core/v4l2-ctrls.c |8 +---
  include/media/v4l2-ctrls.h   |   29 ++---
  2 files changed, 31 insertions(+), 6 deletions(-)
 
 diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
 b/drivers/media/v4l2-core/v4l2-ctrls.c
 index 6b28b58..b36d1ec 100644
 --- a/drivers/media/v4l2-core/v4l2-ctrls.c
 +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
 @@ -1362,11 +1362,13 @@ static inline int handler_set_err(struct 
 v4l2_ctrl_handler *hdl, int err)
  }
  
  /* Initialize the handler */
 -int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl,
 -unsigned nr_of_controls_hint)
 +int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
 +  unsigned nr_of_controls_hint,
 +  struct lock_class_key *key, const char *name)
  {
   hdl-lock = hdl-_lock;
   mutex_init(hdl-lock);
 + lockdep_set_class_and_name(hdl-lock, key, name);
   INIT_LIST_HEAD(hdl-ctrls);
   INIT_LIST_HEAD(hdl-ctrl_refs);
   hdl-nr_of_buckets = 1 + nr_of_controls_hint / 8;
 @@ -1375,7 +1377,7 @@ int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler 
 *hdl,
   hdl-error = hdl-buckets ? 0 : -ENOMEM;
   return hdl-error;
  }
 -EXPORT_SYMBOL(v4l2_ctrl_handler_init);
 +EXPORT_SYMBOL(v4l2_ctrl_handler_init_class);
  
  /* Free all controls and control refs */
  void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)
 diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
 index f00d42b..7343a27 100644
 --- a/include/media/v4l2-ctrls.h
 +++ b/include/media/v4l2-ctrls.h
 @@ -259,7 +259,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
 v4l2_ctrl_type *type,
   s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags);
  
  
 -/** v4l2_ctrl_handler_init() - Initialize the control handler.
 +/** v4l2_ctrl_handler_init_class() - Initialize the control handler.
* @hdl:The control handler.
* @nr_of_controls_hint: A hint of how many controls this handler is
*  expected to refer to. This is the total number, so including
 @@ -268,12 +268,35 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
 v4l2_ctrl_type *type,
*  are allocated) or the control lookup becomes slower (not enough
*  buckets are allocated, so there are more slow list lookups).
*  It will always work, though.
 +  * @key:Used by 

Re: [PATCH] block i2c tuner reads for Avermedia Twinstar in the af9035 driver

2013-03-11 Thread Jose Alberto Reguero
On Lunes, 11 de febrero de 2013 14:48:18 Jose Alberto Reguero escribió:
 On Domingo, 10 de febrero de 2013 22:11:53 Antti Palosaari escribió:
  On 02/10/2013 09:43 PM, Jose Alberto Reguero wrote:
   This patch block the i2c tuner reads for Avermedia Twinstar. If it's
   needed other pids can be added.
   
   Signed-off-by: Jose Alberto Reguero jaregu...@telefonica.net
   
   diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.c
   linux.new/drivers/media/usb/dvb-usb-v2/af9035.c ---
   linux/drivers/media/usb/dvb-usb-v2/af9035.c   2013-01-07
   05:45:57.0 +0100 +++
   linux.new/drivers/media/usb/dvb-usb-v2/af9035.c   2013-02-08
   22:55:08.304089054 +0100 @@ -232,7 +232,11 @@ static int
   af9035_i2c_master_xfer(struct
   
 buf[3] = 0x00; /* reg addr MSB */
 buf[4] = 0x00; /* reg addr LSB */
 memcpy(buf[5], msg[0].buf, msg[0].len);
   
   - ret = af9035_ctrl_msg(d, req);
   + if (state-block_read) {
   + msg[1].buf[0] = 0x3f;
   + ret = 0;
   + } else
   + ret = af9035_ctrl_msg(d, req);
   
 }
 
 } else if (num == 1  !(msg[0].flags  I2C_M_RD)) {
 
 if (msg[0].len  40) {
   
   @@ -638,6 +642,17 @@ static int af9035_read_config(struct dvb
   
 for (i = 0; i  ARRAY_SIZE(state-af9033_config); i++)
 
 state-af9033_config[i].clock = clock_lut[tmp];
   
   + state-block_read = false;
   +
   + if (le16_to_cpu(d-udev-descriptor.idVendor) == USB_VID_AVERMEDIA 
   + le16_to_cpu(d-udev-descriptor.idProduct) ==
   + USB_PID_AVERMEDIA_TWINSTAR) {
   + dev_dbg(d-udev-dev,
   + %s: AverMedia Twinstar: block i2c read from 
   tuner\n,
   + __func__);
   + state-block_read = true;
   + }
   +
   
 return 0;
 
 err:
   diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.h
   linux.new/drivers/media/usb/dvb-usb-v2/af9035.h ---
   linux/drivers/media/usb/dvb-usb-v2/af9035.h   2013-01-07
   05:45:57.0 +0100 +++
   linux.new/drivers/media/usb/dvb-usb-v2/af9035.h   2013-02-08
   22:52:42.293842710 +0100 @@ -54,6 +54,7 @@ struct usb_req {
   
 struct state {
 
 u8 seq; /* packet sequence number */
 bool dual_mode;
   
   + bool block_read;
   
 struct af9033_config af9033_config[2];
 
 };
  
  Could you test if faking tuner ID during attach() is enough?
  
  Also, I would like to know what is returned error code from firmware
  when it fails. Enable debugs to see it. It should print something like
  that: af9035_ctrl_msg: command=03 failed fw error=2
  
  
  diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c
  b/drivers/media/usb/dvb-usb-v2/af9035.c
  index a1e953a..5a4f28d 100644
  --- a/drivers/media/usb/dvb-usb-v2/af9035.c
  +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
  @@ -1082,9 +1082,22 @@ static int af9035_tuner_attach(struct
  dvb_usb_adapter *adap)
  
   tuner_addr = 0x60 | 0x80; /* I2C bus hack */
   
   }
  
  +   // fake used tuner for demod firmware / i2c adapter
  +   if (adap-id == 0)
  +   ret = af9035_wr_reg(d, 0x00f641,
  AF9033_TUNER_FC0011);
  +   else
  +   ret = af9035_wr_reg(d, 0x10f641,
  AF9033_TUNER_FC0011);
  +
  
   /* attach tuner */
   fe = dvb_attach(mxl5007t_attach, adap-fe[0],
   d-i2c_adap,
   
   tuner_addr,
  
  af9035_mxl5007t_config[adap-id]);
  +
  +   // return correct tuner
  +   if (adap-id == 0)
  +   ret = af9035_wr_reg(d, 0x00f641,
  AF9033_TUNER_MXL5007T);
  +   else
  +   ret = af9035_wr_reg(d, 0x10f641,
  AF9033_TUNER_MXL5007T);
  +
  
   break;
   
   case AF9033_TUNER_TDA18218:
   /* attach tuner */
  
  regards
  Antti
 
 I will try with fake tuner, but I can't test unil next weekend.
 If I remember, the read operation is performed, and return good value,
 but after that, all the i2c transfers fail. Seee:
 
 http://www.mail-archive.com/linux-media@vger.kernel.org/msg56346.html
 
 Jose Alberto
 


I tried with fake tuner without success:

[ 1346.707405] DVB: registering new adapter (AVerMedia Twinstar (A825))
[ 1346.959043] i2c i2c-1: af9033: firmware version: LINK=11.5.9.0 
OFDM=5.17.9.1
[ 1346.962920] usb 1-2: DVB: registering adapter 0 frontend 0 (Afatech AF9033 
(DVB-T))...
[ 1347.439354] mxl5007t 1-0060: creating new instance
[ 1347.440644] mxl5007t_get_chip_id: unknown rev (3f)
[ 1347.440652] mxl5007t_get_chip_id: MxL5007T 

[REVIEW PATCH 22/42] go7007: fix DMA related errors.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

- Don't pass data allocated on the stack to usb_control_msg.
- Use dma_mapping_error after calling dma_map_page().

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-priv.h|1 +
 drivers/staging/media/go7007/go7007-usb.c |   36 +++--
 drivers/staging/media/go7007/s2250-board.c|2 +-
 drivers/staging/media/go7007/saa7134-go7007.c |4 +--
 4 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index 1c4b049..daae6dd 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -188,6 +188,7 @@ struct go7007 {
int audio_enabled;
struct v4l2_subdev *sd_video;
struct v4l2_subdev *sd_audio;
+   u8 usb_buf[16];
 
/* Video input */
int input;
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 0b1af50..f496720 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -652,7 +652,7 @@ static int go7007_usb_ezusb_write_interrupt(struct go7007 
*go,
 {
struct go7007_usb *usb = go-hpi_context;
int i, r;
-   u16 status_reg;
+   u16 status_reg = 0;
int timeout = 500;
 
 #ifdef GO7007_USB_DEBUG
@@ -664,15 +664,17 @@ static int go7007_usb_ezusb_write_interrupt(struct go7007 
*go,
r = usb_control_msg(usb-usbdev,
usb_rcvctrlpipe(usb-usbdev, 0), 0x14,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
-   0, HPI_STATUS_ADDR, status_reg,
+   0, HPI_STATUS_ADDR, go-usb_buf,
sizeof(status_reg), timeout);
if (r  0)
-   goto write_int_error;
-   __le16_to_cpus(status_reg);
+   break;
+   status_reg = le16_to_cpu(*((u16 *)go-usb_buf));
if (!(status_reg  0x0010))
break;
msleep(10);
}
+   if (r  0)
+   goto write_int_error;
if (i == 100) {
printk(KERN_ERR
go7007-usb: device is hung, status reg = 0x%04x\n,
@@ -700,7 +702,6 @@ static int go7007_usb_onboard_write_interrupt(struct go7007 
*go,
int addr, int data)
 {
struct go7007_usb *usb = go-hpi_context;
-   u8 *tbuf;
int r;
int timeout = 500;
 
@@ -709,17 +710,14 @@ static int go7007_usb_onboard_write_interrupt(struct 
go7007 *go,
go7007-usb: WriteInterrupt: %04x %04x\n, addr, data);
 #endif
 
-   tbuf = kzalloc(8, GFP_KERNEL);
-   if (tbuf == NULL)
-   return -ENOMEM;
-   tbuf[0] = data  0xff;
-   tbuf[1] = data  8;
-   tbuf[2] = addr  0xff;
-   tbuf[3] = addr  8;
+   go-usb_buf[0] = data  0xff;
+   go-usb_buf[1] = data  8;
+   go-usb_buf[2] = addr  0xff;
+   go-usb_buf[3] = addr  8;
+   go-usb_buf[4] = go-usb_buf[5] = go-usb_buf[6] = go-usb_buf[7] = 0;
r = usb_control_msg(usb-usbdev, usb_sndctrlpipe(usb-usbdev, 2), 0x00,
USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, 0x55aa,
-   0xf0f0, tbuf, 8, timeout);
-   kfree(tbuf);
+   0xf0f0, go-usb_buf, 8, timeout);
if (r  0) {
printk(KERN_ERR go7007-usb: error in WriteInterrupt: %d\n, r);
return r;
@@ -913,7 +911,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter 
*adapter,
 {
struct go7007 *go = i2c_get_adapdata(adapter);
struct go7007_usb *usb = go-hpi_context;
-   u8 buf[16];
+   u8 *buf = go-usb_buf;
int buf_len, i;
int ret = -EIO;
 
@@ -1169,14 +1167,12 @@ static int go7007_usb_probe(struct usb_interface *intf,
 
/* Probe the tuner model on the TV402U */
if (go-board_id == GO7007_BOARDID_PX_TV402U_ANY) {
-   u8 data[3];
-
/* Board strapping indicates tuner model */
-   if (go7007_usb_vendor_request(go, 0x41, 0, 0, data, 3, 1)  0) {
+   if (go7007_usb_vendor_request(go, 0x41, 0, 0, go-usb_buf, 3, 
1)  0) {
printk(KERN_ERR go7007-usb: GPIO read failed!\n);
goto initfail;
}
-   switch (data[0]  6) {
+   switch (go-usb_buf[0]  6) {
case 1:
go-board_id = GO7007_BOARDID_PX_TV402U_EU;
go-tuner_type = TUNER_SONY_BTF_PG472Z;
@@ -1309,8 +1305,8 @@ static void go7007_usb_disconnect(struct usb_interface 
*intf)
 
kfree(go-hpi_context);
 
-   go7007_remove(go);
go-status = STATUS_SHUTDOWN;
+   

[REVIEW PATCH 19/42] s2250-loader: use usbv2_cypress_load_firmware

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The v2 of this function doesn't do DMA to objects on the stack like
its predecessor does.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/Makefile   |4 ++--
 drivers/staging/media/go7007/s2250-loader.c |7 ---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/go7007/Makefile 
b/drivers/staging/media/go7007/Makefile
index 5bed78b..f9c8e0f 100644
--- a/drivers/staging/media/go7007/Makefile
+++ b/drivers/staging/media/go7007/Makefile
@@ -11,8 +11,8 @@ s2250-y := s2250-board.o
 #obj-$(CONFIG_VIDEO_SAA7134) += saa7134-go7007.o
 #ccflags-$(CONFIG_VIDEO_SAA7134:m=y) += -Idrivers/media/video/saa7134 
-DSAA7134_MPEG_GO7007=3
 
-# S2250 needs cypress ezusb loader from dvb-usb
-ccflags-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD:m=y) += 
-Idrivers/media/usb/dvb-usb
+# S2250 needs cypress ezusb loader from dvb-usb-v2
+ccflags-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD:m=y) += 
-Idrivers/media/usb/dvb-usb-v2
 
 ccflags-y += -Idrivers/media/dvb-frontends
 ccflags-y += -Idrivers/media/dvb-core
diff --git a/drivers/staging/media/go7007/s2250-loader.c 
b/drivers/staging/media/go7007/s2250-loader.c
index 72e5175..6453ec0 100644
--- a/drivers/staging/media/go7007/s2250-loader.c
+++ b/drivers/staging/media/go7007/s2250-loader.c
@@ -19,7 +19,8 @@
 #include linux/init.h
 #include linux/slab.h
 #include linux/usb.h
-#include dvb-usb.h
+#include linux/firmware.h
+#include cypress_firmware.h
 
 #define S2250_LOADER_FIRMWARE  s2250_loader.fw
 #define S2250_FIRMWARE s2250.fw
@@ -104,7 +105,7 @@ static int s2250loader_probe(struct usb_interface 
*interface,
S2250_LOADER_FIRMWARE);
goto failed2;
}
-   ret = usb_cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
+   ret = usbv2_cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
release_firmware(fw);
if (0 != ret) {
dev_err(interface-dev, loader download failed\n);
@@ -117,7 +118,7 @@ static int s2250loader_probe(struct usb_interface 
*interface,
S2250_FIRMWARE);
goto failed2;
}
-   ret = usb_cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
+   ret = usbv2_cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
release_firmware(fw);
if (0 != ret) {
dev_err(interface-dev, firmware_s2250 download failed\n);
-- 
1.7.10.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: dvb-apps: Additional channels for Netherlands

2013-03-11 Thread Oliver Schinagl

On 09-03-13 15:45, Dmitry Katsubo wrote:

Dear LinuxTV developers,

Hoi Dimitry,


When I was playing with scan utility, I paid attention to comments in
file /usr/share/dvb/dvb-t/nl-All


# The Netherlands, whole country
# Created from http://radio-tv-nederland.nl/TV%20zenderlijst%20Nederland.xls
# and http://radio-tv-nederland.nl/dvbt/dvbt-lokaal.html

and what is interesting the comments refer to radio-stations only.
TV zenderlijst is pure DVB-T frequencies. I have not found a single FM 
frequency there. Note that if you open it via their website, there are 
two lists, FM zenderlijst and TV zenderlijst.


After I have completed the scan (I leave in the Netherlands in Delft
area) I have not found few TV stations. I think that the list is missing
522MHz and 698MHz. After I have added them (see patch file), I was able
to complete the scan. However I think that I have made an error, because
I can't watch TV channels fount on the newly added frequencies.

Can somebody help me to improve nl-All file?
You are probably using an old scan file. I pushed an updated version a 
week or two ago. I'm still working on an automated way to have daily 
frequency releases, but even then it can take a while before packagers 
pick it up.


Until then, you are free to use:
http://git.linuxtv.org/dtv-scan-tables.git/blob_plain/HEAD:/dvb-t/nl-All


As for your patch, I think it's wrong. On 522 Mhz (through the country, 
Delft as well) we have NTS4 (Bouquet 5) which is on a 2/3 coding rate, 
in your patch it's at 1/2.


On 698 MHz we have NTS1 (Bouquet 2) which is on a code rate of 1/2.

Feel free to correct me if I'm wrong.


Thanks.

Additional links:

http://dvbt4all.nl/digitenne/zenders/zuid-holland-noord/delft/
http://nl.wikipedia.org/wiki/DVB-T-frequenties



--
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: omap3isp: iommu register problem.

2013-03-11 Thread javier Martin
I've just found the following thread where te problem is explained:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-February/086364.html

The problem is related with the order iommu and omap3isp are probed
when both are built-in. If I load omap3isp as a module the problem is
gone.

However, according to the previous thread, omap3isp register should
return error but an oops should not be generated. So I think there is
a bug here anyway.



-- 
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
--
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] block i2c tuner reads for Avermedia Twinstar in the af9035 driver

2013-03-11 Thread Antti Palosaari

On 03/11/2013 01:51 PM, Jose Alberto Reguero wrote:

On Lunes, 11 de febrero de 2013 14:48:18 Jose Alberto Reguero escribió:

On Domingo, 10 de febrero de 2013 22:11:53 Antti Palosaari escribió:

On 02/10/2013 09:43 PM, Jose Alberto Reguero wrote:

This patch block the i2c tuner reads for Avermedia Twinstar. If it's
needed other pids can be added.

Signed-off-by: Jose Alberto Reguero jaregu...@telefonica.net

diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.c
linux.new/drivers/media/usb/dvb-usb-v2/af9035.c ---
linux/drivers/media/usb/dvb-usb-v2/af9035.c 2013-01-07
05:45:57.0 +0100 +++
linux.new/drivers/media/usb/dvb-usb-v2/af9035.c 2013-02-08
22:55:08.304089054 +0100 @@ -232,7 +232,11 @@ static int
af9035_i2c_master_xfer(struct

buf[3] = 0x00; /* reg addr MSB */
buf[4] = 0x00; /* reg addr LSB */
memcpy(buf[5], msg[0].buf, msg[0].len);

-   ret = af9035_ctrl_msg(d, req);
+   if (state-block_read) {
+   msg[1].buf[0] = 0x3f;
+   ret = 0;
+   } else
+   ret = af9035_ctrl_msg(d, req);

}

} else if (num == 1  !(msg[0].flags  I2C_M_RD)) {

if (msg[0].len  40) {

@@ -638,6 +642,17 @@ static int af9035_read_config(struct dvb

for (i = 0; i  ARRAY_SIZE(state-af9033_config); i++)

state-af9033_config[i].clock = clock_lut[tmp];

+   state-block_read = false;
+
+   if (le16_to_cpu(d-udev-descriptor.idVendor) == USB_VID_AVERMEDIA 
+   le16_to_cpu(d-udev-descriptor.idProduct) ==
+   USB_PID_AVERMEDIA_TWINSTAR) {
+   dev_dbg(d-udev-dev,
+   %s: AverMedia Twinstar: block i2c read from 
tuner\n,
+   __func__);
+   state-block_read = true;
+   }
+

return 0;

   err:
diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.h
linux.new/drivers/media/usb/dvb-usb-v2/af9035.h ---
linux/drivers/media/usb/dvb-usb-v2/af9035.h 2013-01-07
05:45:57.0 +0100 +++
linux.new/drivers/media/usb/dvb-usb-v2/af9035.h 2013-02-08
22:52:42.293842710 +0100 @@ -54,6 +54,7 @@ struct usb_req {

   struct state {

u8 seq; /* packet sequence number */
bool dual_mode;

+   bool block_read;

struct af9033_config af9033_config[2];

   };


Could you test if faking tuner ID during attach() is enough?

Also, I would like to know what is returned error code from firmware
when it fails. Enable debugs to see it. It should print something like
that: af9035_ctrl_msg: command=03 failed fw error=2


diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c
b/drivers/media/usb/dvb-usb-v2/af9035.c
index a1e953a..5a4f28d 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1082,9 +1082,22 @@ static int af9035_tuner_attach(struct
dvb_usb_adapter *adap)

  tuner_addr = 0x60 | 0x80; /* I2C bus hack */

  }

+   // fake used tuner for demod firmware / i2c adapter
+   if (adap-id == 0)
+   ret = af9035_wr_reg(d, 0x00f641,
AF9033_TUNER_FC0011);
+   else
+   ret = af9035_wr_reg(d, 0x10f641,
AF9033_TUNER_FC0011);
+

  /* attach tuner */
  fe = dvb_attach(mxl5007t_attach, adap-fe[0],
  d-i2c_adap,

  tuner_addr,

af9035_mxl5007t_config[adap-id]);
+
+   // return correct tuner
+   if (adap-id == 0)
+   ret = af9035_wr_reg(d, 0x00f641,
AF9033_TUNER_MXL5007T);
+   else
+   ret = af9035_wr_reg(d, 0x10f641,
AF9033_TUNER_MXL5007T);
+

  break;

  case AF9033_TUNER_TDA18218:
  /* attach tuner */

regards
Antti


I will try with fake tuner, but I can't test unil next weekend.
If I remember, the read operation is performed, and return good value,
but after that, all the i2c transfers fail. Seee:

http://www.mail-archive.com/linux-media@vger.kernel.org/msg56346.html

Jose Alberto




I tried with fake tuner without success:

[ 1346.707405] DVB: registering new adapter (AVerMedia Twinstar (A825))
[ 1346.959043] i2c i2c-1: af9033: firmware version: LINK=11.5.9.0
OFDM=5.17.9.1
[ 1346.962920] usb 1-2: DVB: registering adapter 0 frontend 0 (Afatech AF9033
(DVB-T))...
[ 1347.439354] mxl5007t 1-0060: creating new instance
[ 1347.440644] mxl5007t_get_chip_id: unknown rev (3f)
[ 1347.440652] mxl5007t_get_chip_id: MxL5007T detected @ 1-0060
[ 1347.443023] mxl5007t_write_reg: 472: failed!
[ 1347.443031] mxl5007t_attach: error -121 on line 903
[ 1347.443790] usb 1-2: dvb_usb_v2: 'AVerMedia Twinstar (A825)' error while
loading driver (-19)
[ 1347.446624] usb 1-2: dvb_usb_v2: 

Re: omap3isp: iommu register problem.

2013-03-11 Thread Laurent Pinchart
Hi Javier,

On Monday 11 March 2013 13:18:12 javier Martin wrote:
 I've just found the following thread where te problem is explained:
 http://lists.infradead.org/pipermail/linux-arm-kernel/2012-February/086364.h
 tml
 
 The problem is related with the order iommu and omap3isp are probed
 when both are built-in. If I load omap3isp as a module the problem is
 gone.
 
 However, according to the previous thread, omap3isp register should
 return error but an oops should not be generated. So I think there is
 a bug here anyway.

Does the following patch (compile-tested only) fix the issue ?

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 6e5ad8e..4d889be 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2123,6 +2123,7 @@ static int isp_probe(struct platform_device *pdev)
ret = iommu_attach_device(isp-domain, pdev-dev);
if (ret) {
dev_err(pdev-dev, can't attach iommu device: %d\n, ret);
+   ret = -EPROBE_DEFER;
goto free_domain;
}
 
@@ -2161,6 +2162,7 @@ detach_dev:
iommu_detach_device(isp-domain, pdev-dev);
 free_domain:
iommu_domain_free(isp-domain);
+   isp-domain = NULL;
 error_isp:
omap3isp_put(isp);
 error:

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


Re: [PATCH v7] [media] Add a V4L2 OF parser

2013-03-11 Thread Guennadi Liakhovetski
Hi Sylwester

Thanks for continuing this work! You have made a great progress compared 
to my initial version, and I should really have looked at each your 
submitted new revision, unfortunately, I haven't managed that. So, sorry 
for chiming back in so late in the game, but maybe we still manage to get 
it in on time for 3.10. Let me know if you'd like me to do the next couple 
of rounds :) Or if you disagree with my comments and prefer your present 
state.

On Fri, 8 Mar 2013, Sylwester Nawrocki wrote:

 From: Guennadi Liakhovetski g.liakhovet...@gmx.de
 
 Add a V4L2 OF parser, implementing bindings documented in
 Documentation/devicetree/bindings/media/video-interfaces.txt.
 
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 [s.nawro...@samsung.com: various corrections and improvements
 since the initial version]
 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 ---
 The last version of the bindings documentation patch can be found
 at: https://patchwork.kernel.org/patch/2074951
 
 Changes since v6:
  - minor v4l2_of_get_remote_port_parent() function cleanup.
 
 Changes since v5:
  - renamed v4l2_of_parse_mipi_csi2 - v4l2_of_parse_csi_bus,
  - corrected v4l2_of_get_remote_port_parent() function declaration
for !CONFIG_OF,
  - reworked v4l2_of_get_next_endpoint() function to consider the
'port' nodes can be grouped under optional 'ports' node,
  - added kerneldoc description for v4l2_of_get_next_endpoint()
function.
 
 Changes since v4:
  - reworked v4l2_of_get_remote_port() function to consider cases
where 'port' nodes are grouped in a parent 'ports' node,
  - rearranged struct v4l2_of_endpoint and related changes added
in the parser code,
  - added kerneldoc description for struct v4l2_of_endpoint,
  - s/link/endpoint in the comments,
 ---
  drivers/media/v4l2-core/Makefile  |3 +
  drivers/media/v4l2-core/v4l2-of.c |  261 
 +
  include/media/v4l2-of.h   |   98 ++
  3 files changed, 362 insertions(+)
  create mode 100644 drivers/media/v4l2-core/v4l2-of.c
  create mode 100644 include/media/v4l2-of.h
 
 diff --git a/drivers/media/v4l2-core/Makefile 
 b/drivers/media/v4l2-core/Makefile
 index c2d61d4..00f64d6 100644
 --- a/drivers/media/v4l2-core/Makefile
 +++ b/drivers/media/v4l2-core/Makefile
 @@ -9,6 +9,9 @@ videodev-objs :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o 
 v4l2-fh.o \
  ifeq ($(CONFIG_COMPAT),y)
videodev-objs += v4l2-compat-ioctl32.o
  endif
 +ifeq ($(CONFIG_OF),y)
 +  videodev-objs += v4l2-of.o
 +endif
  
  obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o
  obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
 diff --git a/drivers/media/v4l2-core/v4l2-of.c 
 b/drivers/media/v4l2-core/v4l2-of.c
 new file mode 100644
 index 000..cbd18f6
 --- /dev/null
 +++ b/drivers/media/v4l2-core/v4l2-of.c
 @@ -0,0 +1,261 @@
 +/*
 + * V4L2 OF binding parsing library
 + *
 + * Copyright (C) 2012 Renesas Electronics Corp.
 + * Author: Guennadi Liakhovetski g.liakhovet...@gmx.de
 + *
 + * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
 + * Sylwester Nawrocki s.nawro...@samsung.com

You probably want to put your copyright at the top as the newer one, isn't 
it the usual order - newest first?

 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of version 2 of the GNU General Public License as
 + * published by the Free Software Foundation.
 + */
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/string.h
 +#include linux/types.h
 +
 +#include media/v4l2-of.h
 +
 +/**
 + * v4l2_of_parse_csi_bus() - parse MIPI CSI-2 bus properties
 + * @node: pointer to endpoint device_node
 + * @endpoint: pointer to v4l2_of_endpoint data structure
 + *
 + * Return: 0 on success or negative error value otherwise.
 + */
 +int v4l2_of_parse_csi_bus(const struct device_node *node,
 +   struct v4l2_of_endpoint *endpoint)
 +{
 + struct v4l2_mbus_mipi_csi2 *mipi_csi2 = endpoint-mbus.mipi_csi2;
 + u32 data_lanes[ARRAY_SIZE(mipi_csi2-data_lanes)];
 + struct property *prop;
 + const __be32 *lane = NULL;
 + u32 v;
 + int i = 0;
 +
 + prop = of_find_property(node, data-lanes, NULL);
 + if (!prop)
 + return -EINVAL;

Oh... Well, first - this isn't an error to not specify data-lanes. Below 
you also try to continue configuring the CSI-2 properties in this error 
case, but since you return here, you skip parsing all clock-related 
properties...

 + do {
 + lane = of_prop_next_u32(prop, lane, data_lanes[i]);
 + } while (lane  i++  ARRAY_SIZE(data_lanes));

you could do this as a for loop, but then you'd have an additional 
if-break check inside, so, maybe your do-while is a prettier solution 
here.

 +
 + mipi_csi2-num_data_lanes = i;
 + while (i--)
 + mipi_csi2-data_lanes[i] = data_lanes[i];
 +
 + if (!of_property_read_u32(node, 

Re: omap3isp: iommu register problem.

2013-03-11 Thread javier Martin
Hi Laurent,
thank you for your answer.

On 11 March 2013 16:01, Laurent Pinchart
laurent.pinch...@ideasonboard.com wrote:
 Hi Javier,

 On Monday 11 March 2013 13:18:12 javier Martin wrote:
 I've just found the following thread where te problem is explained:
 http://lists.infradead.org/pipermail/linux-arm-kernel/2012-February/086364.h
 tml

 The problem is related with the order iommu and omap3isp are probed
 when both are built-in. If I load omap3isp as a module the problem is
 gone.

 However, according to the previous thread, omap3isp register should
 return error but an oops should not be generated. So I think there is
 a bug here anyway.

 Does the following patch (compile-tested only) fix the issue ?

 diff --git a/drivers/media/platform/omap3isp/isp.c 
 b/drivers/media/platform/omap3isp/isp.c
 index 6e5ad8e..4d889be 100644
 --- a/drivers/media/platform/omap3isp/isp.c
 +++ b/drivers/media/platform/omap3isp/isp.c
 @@ -2123,6 +2123,7 @@ static int isp_probe(struct platform_device *pdev)
 ret = iommu_attach_device(isp-domain, pdev-dev);
 if (ret) {
 dev_err(pdev-dev, can't attach iommu device: %d\n, ret);
 +   ret = -EPROBE_DEFER;
 goto free_domain;
 }

 @@ -2161,6 +2162,7 @@ detach_dev:
 iommu_detach_device(isp-domain, pdev-dev);
  free_domain:
 iommu_domain_free(isp-domain);
 +   isp-domain = NULL;
  error_isp:
 omap3isp_put(isp);
  error:


Yes,
that solves the problems.

[2.706939] omap3isp omap3isp: Revision 15.0 found
[2.712402] omap_iommu_attach: 1
[2.715942] omap_iommu_attach: 2
[2.719329] omap_iommu_attach: 3
[2.722778] omap_iommu_attach: 4
[2.726135] omap_iommu_attach: 5
[2.729553] iommu_enable: 1
[2.732482] iommu_enable: 2, arch_iommu = c0599adc
[2.737548] iommu_enable: 3
[2.740478] iommu_enable: 5
[2.743652] omap-iommu omap-iommu.0: mmu_isp: version 1.1
[2.749389] omap_iommu_attach: 6
[2.752807] omap_iommu_attach: 7
[2.756195] omap_iommu_attach: 8
[2.759613] omap_iommu_attach: 9
[2.763977] omap3isp omap3isp: hist: DMA channel = 2
[2.770904] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[2.778839] ALSA device list:
[2.781982]   No soundcards found.
[2.799285] mt9m111 2-0048: mt9m111: driver needs platform data
[2.805603] mt9m111: probe of 2-0048 failed with error -22
[2.814849] omap3isp omap3isp: isp_register_subdev_group: Unable to
register subdev mt9m111

The error I get now seems more related to the fact that I am trying to
use a soc-camera sensor (mt9m111) with a non-soc-camera host
(omap3isp) and I probably need some extra platform code.

Do you know any board in mainline in a similar situation?

Regards.

-- 
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
--
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] ts2020: use customise option correctly

2013-03-11 Thread Paul Bolle
The Kconfig entry for TS2020 based tuners defaults to modular if
DVB_FE_CUSTOMISE is set. But that Kconfig symbol was replaced with
MEDIA_SUBDRV_AUTOSELECT as of v3.7. So use the new symbol. And negate
the logic, so we are in line with all the similar entries in this file.

Signed-off-by: Paul Bolle pebo...@tiscali.nl
---
Entirely untested.

 drivers/media/dvb-frontends/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 6f809a7..0e2ec6f 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -210,7 +210,7 @@ config DVB_SI21XX
 config DVB_TS2020
tristate Montage Tehnology TS2020 based tuners
depends on DVB_CORE  I2C
-   default m if DVB_FE_CUSTOMISE
+   default m if !MEDIA_SUBDRV_AUTOSELECT
help
  A DVB-S/S2 silicon tuner. Say Y when you want to support this tuner.
 
-- 
1.7.11.7

--
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] m920x: silence compiler warning

2013-03-11 Thread Antti Palosaari
drivers/media/usb/dvb-usb/m920x.c: In function ‘m920x_probe’:
drivers/media/usb/dvb-usb/m920x.c:91:6: warning: ‘ret’ may be used 
uninitialized in this function [-Wuninitialized]
drivers/media/usb/dvb-usb/m920x.c:70:6: note: ‘ret’ was declared here

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/dvb-usb/m920x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb/m920x.c 
b/drivers/media/usb/dvb-usb/m920x.c
index 92afeb2..f5e4654 100644
--- a/drivers/media/usb/dvb-usb/m920x.c
+++ b/drivers/media/usb/dvb-usb/m920x.c
@@ -67,7 +67,7 @@ static inline int m920x_write(struct usb_device *udev, u8 
request,
 static inline int m920x_write_seq(struct usb_device *udev, u8 request,
  struct m920x_inits *seq)
 {
-   int ret;
+   int ret = 0;
while (seq-address) {
ret = m920x_write(udev, request, seq-data, seq-address);
if (ret != 0)
-- 
1.7.11.7

--
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: Custom device names for v4l2 devices

2013-03-11 Thread vkalia
Please suggest.

Thanks
Vinay

 Hi

 Names of V4L2 device nodes keep on varying depending on target, on some
 targets, the device node assigned to my device is /dev/video21 and on some
 it is /dev/video15. In order to determine my device, i am opening it,
 reading the capabilities, enumerating its formats and then chose the one
 matching my requirements. This is impacting start-up latency. One way to
 resolve this without impacting start-up latency is to give custom name to
 my V4L2 device node (/dev/custom_name instead of /dev/video21). This needs
 following change in V4L2 framework. Please review this patch. If you have
 faced similar problem please let me know.

 --- a/drivers/media/video/v4l2-dev.c
 +++ b/drivers/media/video/v4l2-dev.c
 @@ -676,7 +676,8 @@ int __video_register_device(struct video_device *vdev,
 int type, int nr,
   vdev-dev.devt = MKDEV(VIDEO_MAJOR, vdev-minor);
   if (vdev-parent)
   vdev-dev.parent = vdev-parent;
 - dev_set_name(vdev-dev, %s%d, name_base, vdev-num);
 + if (!dev_name(vdev-dev))
 + dev_set_name(vdev-dev, %s%d, name_base, vdev-num);
   ret = device_register(vdev-dev);
   if (ret  0) {
   printk(KERN_ERR %s: device_register failed\n, __func__);


 Thanks
 Vinay



--
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 RFC 00/11] s5p-fimc: Exynos4x12 FIMC-IS support prerequisite

2013-03-11 Thread Sylwester Nawrocki
This patch series contains couple fixes to the s5p-fimc driver
and changes necessary for the Exynos4x12 FIMC-IS support.

Andrzej Hajda (1):
  s5p-fimc: Added error checks for pipeline stream on callbacks

Sylwester Nawrocki (10):
  s5p-fimc: Add parent clock setup
  s5p-csis: Add parent clock setup
  s5p-fimc: Update graph traversal for entities with multiple source
pads
  s5p-fimc: Add support for PIXELASYNCMx clocks
  s5p-fimc: Add the FIMC ISP writeback input support
  s5p-fimc: Ensure CAMCLK clock can be enabled by FIMC-LITE devices
  s5p-fimc: Ensure proper s_stream() call order in the ISP datapaths
  s5p-fimc: Ensure proper s_power() call order in the ISP datapaths
  s5p-fimc: Remove dependency on fimc-core.h in fimc-lite driver
  V4L: Add MATRIX option to V4L2_CID_EXPOSURE_METERING control

 Documentation/DocBook/media/v4l/controls.xml   |9 +-
 drivers/media/platform/s5p-fimc/fimc-capture.c |   46 +---
 drivers/media/platform/s5p-fimc/fimc-core.c|   67 
 drivers/media/platform/s5p-fimc/fimc-core.h|   42 ++--
 drivers/media/platform/s5p-fimc/fimc-lite.c|1 -
 drivers/media/platform/s5p-fimc/fimc-lite.h|3 +-
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |  134 ++--
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   10 ++
 drivers/media/platform/s5p-fimc/fimc-reg.c |   65 +++-
 drivers/media/platform/s5p-fimc/fimc-reg.h |   10 ++
 drivers/media/platform/s5p-fimc/mipi-csis.c|   66 
 drivers/media/v4l2-core/v4l2-ctrls.c   |1 +
 include/media/s5p_fimc.h   |   34 ++
 include/uapi/linux/v4l2-controls.h |1 +
 14 files changed, 360 insertions(+), 129 deletions(-)

--
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 RFC 01/11] s5p-fimc: Added error checks for pipeline stream on callbacks

2013-03-11 Thread Sylwester Nawrocki
From: Andrzej Hajda a.ha...@samsung.com

set_stream error for pipelines is logged or reported to user
space if possible.

Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |   15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 2a1da4c..52abc9f 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -286,8 +286,8 @@ 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,
-  fimc-pipeline, 1);
+   return fimc_pipeline_call(fimc, set_stream,
+ fimc-pipeline, 1);
}
 
return 0;
@@ -443,12 +443,17 @@ static void buffer_queue(struct vb2_buffer *vb)
if (vb2_is_streaming(vid_cap-vbq) 
vid_cap-active_buf_cnt = min_bufs 
!test_and_set_bit(ST_CAPT_STREAM, fimc-state)) {
+   int ret;
+
fimc_activate_capture(ctx);
spin_unlock_irqrestore(fimc-slock, flags);
 
-   if (!test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
-   fimc_pipeline_call(fimc, set_stream,
-  fimc-pipeline, 1);
+   if (test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
+   return;
+
+   ret = fimc_pipeline_call(fimc, set_stream, fimc-pipeline, 1);
+   if (ret  0)
+   v4l2_err(vid_cap-vfd, stream on failed: %d\n, ret);
return;
}
spin_unlock_irqrestore(fimc-slock, flags);
-- 
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 RFC 03/11] s5p-csis: Add parent clock setup

2013-03-11 Thread Sylwester Nawrocki
With this patch the driver will set parent clock as a parent
clock of mux clock. When the samsung clocks driver is reworked
to use new composite clock type, the mux clock can be removed.

parent clock should be set in relevant dtsi file and can be
overwritten in a board dts file. This way it is ensured the
SCLK_CSIS has correct parent clock set, and the parent clock
can be selected per each board if required.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/mipi-csis.c |   66 ++-
 1 file changed, 45 insertions(+), 21 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/mipi-csis.c 
b/drivers/media/platform/s5p-fimc/mipi-csis.c
index 4673625..6854c9e 100644
--- a/drivers/media/platform/s5p-fimc/mipi-csis.c
+++ b/drivers/media/platform/s5p-fimc/mipi-csis.c
@@ -108,13 +108,17 @@ MODULE_PARM_DESC(debug, Debug level (0-2));
 #define S5PCSIS_PKTDATA_SIZE   SZ_4K
 
 enum {
-   CSIS_CLK_MUX,
+   CSIS_CLK_BUS,
CSIS_CLK_GATE,
+   CSIS_CLK_MUX,
+   CSIS_CLK_PARENT,
 };
 
 static char *csi_clock_name[] = {
-   [CSIS_CLK_MUX]  = sclk_csis,
+   [CSIS_CLK_BUS]  = sclk_csis,
[CSIS_CLK_GATE] = csis,
+   [CSIS_CLK_MUX] = mux,
+   [CSIS_CLK_PARENT] = parent,
 };
 #define NUM_CSIS_CLOCKSARRAY_SIZE(csi_clock_name)
 #define DEFAULT_SCLK_CSIS_FREQ 16600UL
@@ -362,7 +366,7 @@ static void s5pcsis_set_params(struct csis_state *state)
s5pcsis_write(state, S5PCSIS_CTRL, val | S5PCSIS_CTRL_UPDATE_SHADOW);
 }
 
-static void s5pcsis_clk_put(struct csis_state *state)
+static void s5pcsis_put_clocks(struct csis_state *state)
 {
int i;
 
@@ -375,11 +379,16 @@ static void s5pcsis_clk_put(struct csis_state *state)
}
 }
 
-static int s5pcsis_clk_get(struct csis_state *state)
+static int s5pcsis_get_clocks(struct csis_state *state)
 {
struct device *dev = state-pdev-dev;
+   unsigned int num_clocks = NUM_CSIS_CLOCKS;
int i, ret;
 
+   /* Skip parent and mux clocks for non-dt platforms */
+   if (!dev-of_node)
+   num_clocks -= 2;
+
for (i = 0; i  NUM_CSIS_CLOCKS; i++)
state-clock[i] = ERR_PTR(-EINVAL);
 
@@ -398,11 +407,32 @@ static int s5pcsis_clk_get(struct csis_state *state)
}
return 0;
 err:
-   s5pcsis_clk_put(state);
+   s5pcsis_put_clocks(state);
dev_err(dev, failed to get clock: %s\n, csi_clock_name[i]);
return ret;
 }
 
+static int s5pcsis_setup_clocks(struct csis_state *state)
+{
+   int ret;
+
+   if (!IS_ERR(state-clock[CSIS_CLK_PARENT])) {
+   ret = clk_set_parent(state-clock[CSIS_CLK_MUX],
+state-clock[CSIS_CLK_PARENT]);
+   if (ret  0) {
+   dev_err(state-pdev-dev,
+   %s(): failed to set parent: %d\n,
+   __func__, ret);
+   return ret;
+   }
+   }
+   ret = clk_set_rate(state-clock[CSIS_CLK_BUS],
+   state-clk_frequency);
+   if (ret  0)
+   return ret;
+   return clk_enable(state-clock[CSIS_CLK_BUS]);
+}
+
 static void dump_regs(struct csis_state *state, const char *label)
 {
struct {
@@ -725,8 +755,10 @@ static int s5pcsis_get_platform_data(struct 
platform_device *pdev,
dev_err(pdev-dev, Platform data not specified\n);
return -EINVAL;
}
-
-   state-clk_frequency = pdata-clk_rate;
+   if (pdata-clk_rate)
+   state-clk_frequency = pdata-clk_rate;
+   else
+   state-clk_frequency = DEFAULT_SCLK_CSIS_FREQ;
state-num_lanes = pdata-lanes;
state-hs_settle = pdata-hs_settle;
state-index = max(0, pdev-id);
@@ -830,19 +862,11 @@ static int s5pcsis_probe(struct platform_device *pdev)
if (ret)
return ret;
 
-   ret = s5pcsis_clk_get(state);
+   ret = s5pcsis_get_clocks(state);
if (ret  0)
return ret;
 
-   if (state-clk_frequency)
-   ret = clk_set_rate(state-clock[CSIS_CLK_MUX],
-  state-clk_frequency);
-   else
-   dev_WARN(dev, No clock frequency specified!\n);
-   if (ret  0)
-   goto e_clkput;
-
-   ret = clk_enable(state-clock[CSIS_CLK_MUX]);
+   ret = s5pcsis_setup_clocks(state);
if (ret  0)
goto e_clkput;
 
@@ -885,9 +909,9 @@ static int s5pcsis_probe(struct platform_device *pdev)
return 0;
 
 e_clkdis:
-   clk_disable(state-clock[CSIS_CLK_MUX]);
+   clk_disable(state-clock[CSIS_CLK_BUS]);
 e_clkput:
-   s5pcsis_clk_put(state);
+   s5pcsis_put_clocks(state);
return ret;
 }
 
@@ -990,9 +1014,9 @@ static int s5pcsis_remove(struct platform_device *pdev)
 

[PATCH RFC 02/11] s5p-fimc: Add parent clock setup

2013-03-11 Thread Sylwester Nawrocki
With this patch the driver will set parent clock as a parent
clock of mux clock. When the samsung clocks driver is reworked
to use new composite clock type, the mux clock can be removed.

parent clock should be set in related dtsi file and can be
overwritten in a board dts file. This way it is ensured the
SCLK_FIMC clock has correct parent clock set, and the parent
clock can be selected per each board if required.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-core.c |   63 ++-
 drivers/media/platform/s5p-fimc/fimc-core.h |6 ++-
 2 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-core.c 
b/drivers/media/platform/s5p-fimc/fimc-core.c
index d7fe332..c968e80 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.c
+++ b/drivers/media/platform/s5p-fimc/fimc-core.c
@@ -33,8 +33,8 @@
 #include fimc-reg.h
 #include fimc-mdevice.h
 
-static char *fimc_clocks[MAX_FIMC_CLOCKS] = {
-   sclk_fimc, fimc
+static char *fimc_clocks[CLK_FIMC_MAX] = {
+   sclk_fimc, fimc, mux, parent
 };
 
 static struct fimc_fmt fimc_formats[] = {
@@ -787,10 +787,10 @@ struct fimc_fmt *fimc_find_format(const u32 *pixelformat, 
const u32 *mbus_code,
return def_fmt;
 }
 
-static void fimc_clk_put(struct fimc_dev *fimc)
+static void fimc_put_clocks(struct fimc_dev *fimc)
 {
int i;
-   for (i = 0; i  MAX_FIMC_CLOCKS; i++) {
+   for (i = 0; i  CLK_FIMC_MAX; i++) {
if (IS_ERR(fimc-clock[i]))
continue;
clk_unprepare(fimc-clock[i]);
@@ -799,15 +799,21 @@ static void fimc_clk_put(struct fimc_dev *fimc)
}
 }
 
-static int fimc_clk_get(struct fimc_dev *fimc)
+static int fimc_get_clocks(struct fimc_dev *fimc)
 {
+   struct device *dev = fimc-pdev-dev;
+   unsigned int num_clocks = CLK_FIMC_MAX;
int i, ret;
 
-   for (i = 0; i  MAX_FIMC_CLOCKS; i++)
+   /* Skip parent and mux clocks for non-dt platforms */
+   if (!dev-of_node)
+   num_clocks -= 2;
+
+   for (i = 0; i  CLK_FIMC_MAX; i++)
fimc-clock[i] = ERR_PTR(-EINVAL);
 
-   for (i = 0; i  MAX_FIMC_CLOCKS; i++) {
-   fimc-clock[i] = clk_get(fimc-pdev-dev, fimc_clocks[i]);
+   for (i = 0; i  num_clocks; i++) {
+   fimc-clock[i] = clk_get(dev, fimc_clocks[i]);
if (IS_ERR(fimc-clock[i])) {
ret = PTR_ERR(fimc-clock[i]);
goto err;
@@ -821,12 +827,32 @@ static int fimc_clk_get(struct fimc_dev *fimc)
}
return 0;
 err:
-   fimc_clk_put(fimc);
-   dev_err(fimc-pdev-dev, failed to get clock: %s\n,
-   fimc_clocks[i]);
+   fimc_put_clocks(fimc);
+   dev_err(dev, failed to get clock: %s\n, fimc_clocks[i]);
return -ENXIO;
 }
 
+static int fimc_setup_clocks(struct fimc_dev *fimc, unsigned long freq)
+{
+   int ret;
+
+   if (!IS_ERR(fimc-clock[CLK_PARENT])) {
+   ret = clk_set_parent(fimc-clock[CLK_MUX],
+fimc-clock[CLK_PARENT]);
+   if (ret  0) {
+   dev_err(fimc-pdev-dev,
+   %s(): failed to set parent: %d\n,
+   __func__, ret);
+   return ret;
+   }
+   }
+   ret = clk_set_rate(fimc-clock[CLK_BUS], freq);
+   if (ret  0)
+   return ret;
+
+   return clk_enable(fimc-clock[CLK_BUS]);
+}
+
 static int fimc_m2m_suspend(struct fimc_dev *fimc)
 {
unsigned long flags;
@@ -968,18 +994,13 @@ static int fimc_probe(struct platform_device *pdev)
return -ENXIO;
}
 
-   ret = fimc_clk_get(fimc);
-   if (ret)
+   ret = fimc_get_clocks(fimc);
+   if (ret  0)
return ret;
-
if (lclk_freq == 0)
lclk_freq = fimc-drv_data-lclk_frequency;
 
-   ret = clk_set_rate(fimc-clock[CLK_BUS], lclk_freq);
-   if (ret  0)
-   return ret;
-
-   ret = clk_enable(fimc-clock[CLK_BUS]);
+   ret = fimc_setup_clocks(fimc, lclk_freq);
if (ret  0)
return ret;
 
@@ -1016,7 +1037,7 @@ err_sd:
fimc_unregister_capture_subdev(fimc);
 err_clk:
clk_disable(fimc-clock[CLK_BUS]);
-   fimc_clk_put(fimc);
+   fimc_put_clocks(fimc);
return ret;
 }
 
@@ -1103,7 +1124,7 @@ static int fimc_remove(struct platform_device *pdev)
vb2_dma_contig_cleanup_ctx(fimc-alloc_ctx);
 
clk_disable(fimc-clock[CLK_BUS]);
-   fimc_clk_put(fimc);
+   fimc_put_clocks(fimc);
 
dev_info(pdev-dev, driver unloaded\n);
return 0;
diff --git a/drivers/media/platform/s5p-fimc/fimc-core.h 
b/drivers/media/platform/s5p-fimc/fimc-core.h
index 58b674e..67e3201 100644
--- 

[PATCH RFC 04/11] s5p-fimc: Update graph traversal for entities with multiple source pads

2013-03-11 Thread Sylwester Nawrocki
We cannot assume that the passed entity the fimc_pipeline_prepare()
function is supposed to start the media graph traversal from will
always have its sink pad at pad index 0. Find the starting media
entity's sink pad by iterating over its all pads and checking the
pad flags. This ensures proper handling of FIMC, FIMC-LITE and
FIMC-IS-ISP subdevs that have more than one sink and one source pad.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 19cd628..0a7c95b 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -47,7 +47,6 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
 static void fimc_pipeline_prepare(struct fimc_pipeline *p,
  struct media_entity *me)
 {
-   struct media_pad *pad = me-pads[0];
struct v4l2_subdev *sd;
int i;
 
@@ -55,15 +54,21 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
p-subdevs[i] = NULL;
 
while (1) {
-   if (!(pad-flags  MEDIA_PAD_FL_SINK))
-   break;
+   struct media_pad *pad = NULL;
+
+   /* Find remote source pad */
+   for (i = 0; i  me-num_pads; i++) {
+   struct media_pad *spad = me-pads[i];
+   if (!(spad-flags  MEDIA_PAD_FL_SINK))
+   continue;
+   pad = media_entity_remote_source(spad);
+   if (pad)
+   break;
+   }
 
-   /* source pad */
-   pad = media_entity_remote_source(pad);
if (pad == NULL ||
media_entity_type(pad-entity) != MEDIA_ENT_T_V4L2_SUBDEV)
break;
-
sd = media_entity_to_v4l2_subdev(pad-entity);
 
switch (sd-grp_id) {
@@ -84,8 +89,9 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
pr_warn(%s: Unknown subdev grp_id: %#x\n,
__func__, sd-grp_id);
}
-   /* sink pad */
-   pad = sd-entity.pads[0];
+   me = sd-entity;
+   if (me-num_pads == 1)
+   break;
}
 }
 
-- 
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 RFC 05/11] s5p-fimc: Add support for PIXELASYNCMx clocks

2013-03-11 Thread Sylwester Nawrocki
This patch ads handling of clocks for the CAMBLK subsystem which
is a glue logic for FIMC-IS or LCD controller and FIMC IP.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   41 +++-
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |8 +
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 0a7c95b..b9f9976 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -944,7 +944,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)
 }
 
 /*
- * The peripheral sensor clock management.
+ * The peripheral sensor and CAM_BLK (PIXELASYNCMx) clocks management.
  */
 static void fimc_md_put_clocks(struct fimc_md *fmd)
 {
@@ -957,6 +957,17 @@ static void fimc_md_put_clocks(struct fimc_md *fmd)
clk_put(fmd-camclk[i].clock);
fmd-camclk[i].clock = ERR_PTR(-EINVAL);
}
+
+   /* Writeback (PIXELASYNCMx) clocks */
+   for (i = 0; i  FIMC_MAX_WBCLKS; i++) {
+   if (IS_ERR(fmd-wbclk[i]))
+   continue;
+   /* FIXME: find better place to disable this clock! */
+   clk_disable(fmd-wbclk[i]);
+   clk_unprepare(fmd-wbclk[i]);
+   clk_put(fmd-wbclk[i]);
+   fmd-wbclk[i] = ERR_PTR(-EINVAL);
+   }
 }
 
 static int fimc_md_get_clocks(struct fimc_md *fmd)
@@ -993,6 +1004,34 @@ static int fimc_md_get_clocks(struct fimc_md *fmd)
if (ret)
fimc_md_put_clocks(fmd);
 
+   if (!fmd-use_isp)
+   return 0;
+   /*
+* For now get only PIXELASYNCM1 clock (Writeback B/ISP),
+* leave PIXELASYNCM0 out for the display driver.
+*/
+   for (i = CLK_IDX_WB_B; i  FIMC_MAX_WBCLKS; i++) {
+   snprintf(clk_name, sizeof(clk_name), pxl_async%u, i);
+   clock = clk_get(dev, clk_name);
+   if (IS_ERR(clock)) {
+   v4l2_err(fmd-v4l2_dev, Failed to get clock: %s\n,
+ clk_name);
+   ret = PTR_ERR(clock);
+   break;
+   }
+   ret = clk_prepare(clock);
+   if (ret  0) {
+   clk_put(clock);
+   fmd-wbclk[i] = ERR_PTR(-EINVAL);
+   break;
+   }
+   fmd-wbclk[i] = clock;
+   /* FIXME: find better place to enable this clock! */
+   clk_enable(clock);
+   }
+   if (ret)
+   fimc_md_put_clocks(fmd);
+
return ret;
 }
 
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.h 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
index 5d6146e..91be5db 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
@@ -41,6 +41,13 @@
 #define FIMC_MAX_SENSORS   8
 #define FIMC_MAX_CAMCLKS   2
 
+/* LCD/ISP Writeback clocks (PIXELASYNCMx) */
+enum {
+   CLK_IDX_WB_A,
+   CLK_IDX_WB_B,
+   FIMC_MAX_WBCLKS
+};
+
 struct fimc_csis_info {
struct v4l2_subdev *sd;
int id;
@@ -87,6 +94,7 @@ struct fimc_md {
struct fimc_sensor_info sensor[FIMC_MAX_SENSORS];
int num_sensors;
struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS];
+   struct clk *wbclk[FIMC_MAX_WBCLKS];
struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS];
struct fimc_dev *fimc[FIMC_MAX_DEVS];
struct media_device media_dev;
-- 
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 RFC 06/11] s5p-fimc: Add the FIMC ISP writeback input support

2013-03-11 Thread Sylwester Nawrocki
A second sink pad is added to each FIMC.N subdev that will be used
to link it to the ISP subdev. Only V4L2_MBUS_FMT_YUV10_1X30 format
is supported at the pad FIMC_SD_PAD_SINK_FIFO.

TODO:
 - Implement the FIMC input bus type selection based on
   state of media link from FIMC-IS-ISP to FIMC.N subdev.
 - Implement an interface for CAMBLK registers, the CAMBLK glue
   logic registers are shared by multiple drivers so this
   probably belongs to the platform at arch/arm/mach-exynos/.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |   31 +++
 drivers/media/platform/s5p-fimc/fimc-core.c|4 ++
 drivers/media/platform/s5p-fimc/fimc-core.h|6 ++-
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |5 ++
 drivers/media/platform/s5p-fimc/fimc-reg.c |   65 +++-
 drivers/media/platform/s5p-fimc/fimc-reg.h |   10 
 6 files changed, 108 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 52abc9f..a3a58c4 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -46,6 +46,9 @@ static int fimc_capture_hw_init(struct fimc_dev *fimc)
 
sensor = v4l2_get_subdev_hostdata(p-subdevs[IDX_SENSOR]);
 
+   if (sensor-pdata.fimc_bus_type == FIMC_BUS_TYPE_ISP_WRITEBACK)
+   fimc_hw_camblk_set_isp_wb(fimc, 1  fimc-id, 1);
+
spin_lock_irqsave(fimc-slock, flags);
fimc_prepare_dma_offset(ctx, ctx-d_frame);
fimc_set_yuv_order(ctx);
@@ -647,18 +650,22 @@ static struct fimc_fmt *fimc_capture_try_format(struct 
fimc_ctx *ctx,
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)
+   if (fourcc  *fourcc != V4L2_PIX_FMT_JPEG  pad == FIMC_SD_PAD_SOURCE)
mask |= FMT_FLAGS_M2M;
 
+   if (pad == FIMC_SD_PAD_SINK_FIFO)
+   mask = FMT_FLAGS_WRITEBACK;
+
ffmt = fimc_find_format(fourcc, code, mask, 0);
if (WARN_ON(!ffmt))
return NULL;
+
if (code)
*code = ffmt-mbus_code;
if (fourcc)
*fourcc = ffmt-fourcc;
 
-   if (pad == FIMC_SD_PAD_SINK) {
+   if (pad != FIMC_SD_PAD_SOURCE) {
max_w = fimc_fmt_is_user_defined(ffmt-color) ?
pl-scaler_dis_w : pl-scaler_en_w;
/* Apply the camera input interface pixel constraints */
@@ -1552,12 +1559,16 @@ static int fimc_subdev_get_fmt(struct v4l2_subdev *sd,
}
mf = fmt-format;
mf-colorspace = V4L2_COLORSPACE_JPEG;
-   ff = fmt-pad == FIMC_SD_PAD_SINK ? ctx-s_frame : ctx-d_frame;
+   if (fmt-pad == FIMC_SD_PAD_SOURCE)
+   ff = ctx-d_frame;
+   else
+   ff = ctx-s_frame;
 
mutex_lock(fimc-lock);
/* The pixel code is same on both input and output pad */
if (!WARN_ON(ctx-s_frame.fmt == NULL))
mf-code = ctx-s_frame.fmt-mbus_code;
+
mf-width  = ff-f_width;
mf-height = ff-f_height;
mutex_unlock(fimc-lock);
@@ -1601,9 +1612,10 @@ static int fimc_subdev_set_fmt(struct v4l2_subdev *sd,
fimc_alpha_ctrl_update(ctx);
 
fimc_capture_mark_jpeg_xfer(ctx, ffmt-color);
-
-   ff = fmt-pad == FIMC_SD_PAD_SINK ?
-   ctx-s_frame : ctx-d_frame;
+   if (fmt-pad == FIMC_SD_PAD_SOURCE)
+   ff = ctx-d_frame;
+   else
+   ff = ctx-s_frame;
 
mutex_lock(fimc-lock);
set_frame_bounds(ff, mf-width, mf-height);
@@ -1614,7 +1626,7 @@ static int fimc_subdev_set_fmt(struct v4l2_subdev *sd,
if (!(fmt-pad == FIMC_SD_PAD_SOURCE  (ctx-state  FIMC_COMPOSE)))
set_frame_crop(ff, 0, 0, mf-width, mf-height);
 
-   if (fmt-pad == FIMC_SD_PAD_SINK)
+   if (fmt-pad != FIMC_SD_PAD_SOURCE)
ctx-state = ~FIMC_COMPOSE;
mutex_unlock(fimc-lock);
return 0;
@@ -1630,7 +1642,7 @@ static int fimc_subdev_get_selection(struct v4l2_subdev 
*sd,
struct v4l2_rect *r = sel-r;
struct v4l2_rect *try_sel;
 
-   if (sel-pad != FIMC_SD_PAD_SINK)
+   if (sel-pad == FIMC_SD_PAD_SOURCE)
return -EINVAL;
 
mutex_lock(fimc-lock);
@@ -1686,7 +1698,7 @@ static int fimc_subdev_set_selection(struct v4l2_subdev 
*sd,
struct v4l2_rect *try_sel;
unsigned long flags;
 
-   if (sel-pad != FIMC_SD_PAD_SINK)
+   if (sel-pad == FIMC_SD_PAD_SOURCE)
return -EINVAL;
 
mutex_lock(fimc-lock);
@@ -1892,6 +1904,7 @@ int fimc_initialize_capture_subdev(struct fimc_dev *fimc)
snprintf(sd-name, sizeof(sd-name), FIMC.%d, fimc-id);
 

[PATCH RFC 07/11] s5p-fimc: Ensure CAMCLK clock can be enabled by FIMC-LITE devices

2013-03-11 Thread Sylwester Nawrocki
In configurations where FIMC-LITE is used to capture image signal
from an external sensor only we need to ensure one of FIMC devices
is in active power state and the fimc gate clock is enabled.
Otherwise the CAMCLK clock output signal will be masked off
preventing an external sensor's operation.
This affect processing pipelines like:

 - sensor - FIMC-LITE - memory
 - sensor - MIPI-CSIS - FIMC-LITE - memory

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   18 ++
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |2 ++
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index d26b7bf..c336ed1 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -464,7 +464,6 @@ static int fimc_md_register_sensor_entities(struct fimc_md 
*fmd)
 {
struct s5p_platform_fimc *pdata = fmd-pdev-dev.platform_data;
struct device_node *of_node = fmd-pdev-dev.of_node;
-   struct fimc_dev *fd = NULL;
int num_clients = 0;
int ret, i;
 
@@ -472,13 +471,10 @@ static int fimc_md_register_sensor_entities(struct 
fimc_md *fmd)
 * Runtime resume one of the FIMC entities to make sure
 * the sclk_cam clocks are not globally disabled.
 */
-   for (i = 0; !fd  i  ARRAY_SIZE(fmd-fimc); i++)
-   if (fmd-fimc[i])
-   fd = fmd-fimc[i];
-   if (!fd)
+   if (!fmd-pmf)
return -ENXIO;
 
-   ret = pm_runtime_get_sync(fd-pdev-dev);
+   ret = pm_runtime_get_sync(fmd-pmf);
if (ret  0)
return ret;
 
@@ -512,7 +508,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md 
*fmd)
}
}
 
-   pm_runtime_put(fd-pdev-dev);
+   pm_runtime_put(fmd-pmf);
return ret;
 }
 
@@ -557,6 +553,8 @@ static int register_fimc_entity(struct fimc_md *fmd, struct 
fimc_dev *fimc)
 
ret = v4l2_device_register_subdev(fmd-v4l2_dev, sd);
if (!ret) {
+   if (!fmd-pmf  fimc-pdev)
+   fmd-pmf = fimc-pdev-dev;
fmd-fimc[fimc-id] = fimc;
fimc-vid_cap.user_subdev_api = fmd-user_subdev_api;
} else {
@@ -1048,7 +1046,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
struct fimc_camclk_info *camclk;
int ret = 0;
 
-   if (WARN_ON(pdata-clk_id = FIMC_MAX_CAMCLKS) || fmd == NULL)
+   if (WARN_ON(pdata-clk_id = FIMC_MAX_CAMCLKS) || !fmd || !fmd-pmf)
return -EINVAL;
 
camclk = fmd-camclk[pdata-clk_id];
@@ -1064,6 +1062,9 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
if (camclk-use_count++ == 0) {
clk_set_rate(camclk-clock, pdata-clk_frequency);
camclk-frequency = pdata-clk_frequency;
+   ret = pm_runtime_get_sync(fmd-pmf);
+   if (ret  0)
+   return ret;
ret = clk_enable(camclk-clock);
dbg(Enabled camclk %d: f: %lu, pdata-clk_id,
clk_get_rate(camclk-clock));
@@ -1076,6 +1077,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
 
if (--camclk-use_count == 0) {
clk_disable(camclk-clock);
+   pm_runtime_put(fmd-pmf);
dbg(Disabled camclk %d, pdata-clk_id);
}
return ret;
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.h 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
index 91be5db..a827bf9 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
@@ -80,6 +80,7 @@ struct fimc_sensor_info {
  * @num_sensors: actual number of registered sensors
  * @camclk: external sensor clock information
  * @fimc: array of registered fimc devices
+ * @pmf: handle to the CAMCLK clock control FIMC helper device
  * @media_dev: top level media device
  * @v4l2_dev: top level v4l2_device holding up the subdevs
  * @pdev: platform device this media device is hooked up into
@@ -97,6 +98,7 @@ struct fimc_md {
struct clk *wbclk[FIMC_MAX_WBCLKS];
struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS];
struct fimc_dev *fimc[FIMC_MAX_DEVS];
+   struct device *pmf;
struct media_device media_dev;
struct v4l2_device v4l2_dev;
struct platform_device *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


[PATCH RFC 08/11] s5p-fimc: Ensure proper s_stream() call order in the ISP datapaths

2013-03-11 Thread Sylwester Nawrocki
Since the FIMC-IS firmware communicates with an image sensor directly
through the ISP I2C bus controllers data streaming cannot be simply
enabled from left to right or disabled from right to left along the
processing pipeline. Thus a subdev index to call s_stream() on is
looked up from a table, rather than doing the op call based on
increasing/decreasing indexes.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index c336ed1..c99802d 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -194,28 +194,36 @@ static int __fimc_pipeline_close(struct fimc_pipeline *p)
 }
 
 /**
- * __fimc_pipeline_s_stream - invoke s_stream on pipeline subdevs
+ * __fimc_pipeline_s_stream - call s_stream() on pipeline subdevs
  * @pipeline: video pipeline structure
- * @on: passed as the s_stream call argument
+ * @on: passed as the s_stream() callback argument
  */
 static int __fimc_pipeline_s_stream(struct fimc_pipeline *p, bool on)
 {
-   int i, ret;
+   static const u8 seq[2][IDX_MAX] = {
+   { IDX_FIMC, IDX_SENSOR, IDX_IS_ISP, IDX_CSIS, IDX_FLITE },
+   { IDX_CSIS, IDX_FLITE, IDX_FIMC, IDX_SENSOR, IDX_IS_ISP },
+   };
+   int i, ret = 0;
 
if (p-subdevs[IDX_SENSOR] == NULL)
return -ENODEV;
 
for (i = 0; i  IDX_MAX; i++) {
-   unsigned int idx = on ? (IDX_MAX - 1) - i : i;
+   unsigned int idx = seq[on][i];
 
ret = v4l2_subdev_call(p-subdevs[idx], video, s_stream, on);
 
if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV)
-   return ret;
+   goto error;
}
-
return 0;
-
+error:
+   for (; i = 0; i--) {
+   unsigned int idx = seq[on][i];
+   v4l2_subdev_call(p-subdevs[idx], video, s_stream, !on);
+   }
+   return ret;
 }
 
 /* Media pipeline operations for the FIMC/FIMC-LITE video device driver */
-- 
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 RFC 09/11] s5p-fimc: Ensure proper s_power() call order in the ISP datapaths

2013-03-11 Thread Sylwester Nawrocki
Since the FIMC-IS firmware communicates with an image sensor directly
through the ISP I2C bus controllers the sub-devices power supplies
cannot be simply enabled from left to right or disabled from right
to left along the processing pipeline. Thus a subdev index to call
s_power() on is looked up from a table, rather than doing the op call
based on increasing/decreasing indexes.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   26 
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index c99802d..e9e5337 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -128,23 +128,33 @@ static int __subdev_set_power(struct v4l2_subdev *sd, int 
on)
  *
  * Needs to be called with the graph mutex held.
  */
-static int fimc_pipeline_s_power(struct fimc_pipeline *p, bool state)
+static int fimc_pipeline_s_power(struct fimc_pipeline *p, bool on)
 {
-   unsigned int i;
-   int ret;
+   static const u8 seq[2][IDX_MAX - 1] = {
+   { IDX_IS_ISP, IDX_SENSOR, IDX_CSIS, IDX_FLITE },
+   { IDX_CSIS, IDX_FLITE, IDX_SENSOR, IDX_IS_ISP },
+   };
+   int i, ret = 0;
 
if (p-subdevs[IDX_SENSOR] == NULL)
return -ENXIO;
 
-   for (i = 0; i  IDX_MAX; i++) {
-   unsigned int idx = state ? (IDX_MAX - 1) - i : i;
+   for (i = 0; i  IDX_MAX - 1; i++) {
+   unsigned int idx = seq[on][i];
+
+   ret = __subdev_set_power(p-subdevs[idx], on);
+
 
-   ret = __subdev_set_power(p-subdevs[idx], state);
if (ret  0  ret != -ENXIO)
-   return ret;
+   goto error;
}
-
return 0;
+error:
+   for (; i = 0; i--) {
+   unsigned int idx = seq[on][i];
+   __subdev_set_power(p-subdevs[idx], !on);
+   }
+   return ret;
 }
 
 /**
-- 
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 RFC 10/11] s5p-fimc: Remove dependency on fimc-core.h in fimc-lite driver

2013-03-11 Thread Sylwester Nawrocki
Drop fimc-lite.h header inclusion to make the exynos-fimc-lite
module independent on other modules. Move struct fimc_fmt
declaration to the driver's private headers as it is used in
multiple modules.

Reported-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-core.h |   32 -
 drivers/media/platform/s5p-fimc/fimc-lite.c |1 -
 drivers/media/platform/s5p-fimc/fimc-lite.h |3 +--
 include/media/s5p_fimc.h|   34 +++
 4 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-core.h 
b/drivers/media/platform/s5p-fimc/fimc-core.h
index d95aa66..6e2fa1a 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.h
+++ b/drivers/media/platform/s5p-fimc/fimc-core.h
@@ -40,7 +40,6 @@
 #define DMA_MIN_SIZE   8
 #define FIMC_CAMIF_MAX_HEIGHT  0x2000
 #define FIMC_MAX_JPEG_BUF_SIZE (10 * SZ_1M)
-#define FIMC_MAX_PLANES3
 #define FIMC_PIX_LIMITS_MAX6
 #define FIMC_DEF_MIN_SIZE  16
 #define FIMC_DEF_HEIGHT_ALIGN  2
@@ -138,37 +137,6 @@ enum fimc_color_fmt {
 #defineFIMC_COLOR_RANGE_NARROW (1  3)
 
 /**
- * struct fimc_fmt - the driver's internal color format data
- * @mbus_code: Media Bus pixel code, -1 if not applicable
- * @name: format description
- * @fourcc: the fourcc code for this format, 0 if not applicable
- * @color: the corresponding fimc_color_fmt
- * @memplanes: number of physically non-contiguous data planes
- * @colplanes: number of physically contiguous data planes
- * @depth: per plane driver's private 'number of bits per pixel'
- * @mdataplanes: bitmask indicating meta data plane(s), (1  plane_no)
- * @flags: flags indicating which operation mode format applies to
- */
-struct fimc_fmt {
-   enum v4l2_mbus_pixelcode mbus_code;
-   char*name;
-   u32 fourcc;
-   u32 color;
-   u16 memplanes;
-   u16 colplanes;
-   u8  depth[VIDEO_MAX_PLANES];
-   u16 mdataplanes;
-   u16 flags;
-#define FMT_FLAGS_CAM  (1  0)
-#define FMT_FLAGS_M2M_IN   (1  1)
-#define FMT_FLAGS_M2M_OUT  (1  2)
-#define FMT_FLAGS_M2M  (1  1 | 1  2)
-#define FMT_HAS_ALPHA  (1  3)
-#define FMT_FLAGS_COMPRESSED   (1  4)
-#define FMT_FLAGS_WRITEBACK(1  5)
-};
-
-/**
  * struct fimc_dma_offset - pixel offset information for DMA
  * @y_h:   y value horizontal offset
  * @y_v:   y value vertical offset
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 97050ee..412fcb8 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -32,7 +32,6 @@
 #include media/s5p_fimc.h
 
 #include fimc-mdevice.h
-#include fimc-core.h
 #include fimc-lite.h
 #include fimc-lite-reg.h
 
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.h 
b/drivers/media/platform/s5p-fimc/fimc-lite.h
index 7085761..4c234508 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.h
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.h
@@ -20,12 +20,11 @@
 
 #include media/media-entity.h
 #include media/videobuf2-core.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/s5p_fimc.h
 
-#include fimc-core.h
-
 #define FIMC_LITE_DRV_NAME exynos-fimc-lite
 #define FLITE_CLK_NAME flite
 #define FIMC_LITE_MAX_DEVS 2
diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h
index e2434bb..2363aff 100644
--- a/include/media/s5p_fimc.h
+++ b/include/media/s5p_fimc.h
@@ -13,6 +13,7 @@
 #define S5P_FIMC_H_
 
 #include media/media-entity.h
+#include media/v4l2-mediabus.h
 
 /*
  * Enumeration of data inputs to the camera subsystem.
@@ -93,6 +94,39 @@ struct s5p_platform_fimc {
  */
 #define S5P_FIMC_TX_END_NOTIFY _IO('e', 0)
 
+#define FIMC_MAX_PLANES3
+
+/**
+ * struct fimc_fmt - color format data structure
+ * @mbus_code: media bus pixel code, -1 if not applicable
+ * @name: format description
+ * @fourcc: fourcc code for this format, 0 if not applicable
+ * @color: the driver's private color format id
+ * @memplanes: number of physically non-contiguous data planes
+ * @colplanes: number of physically contiguous data planes
+ * @depth: per plane driver's private 'number of bits per pixel'
+ * @mdataplanes: bitmask indicating meta data plane(s), (1  plane_no)
+ * @flags: flags indicating which operation mode format applies to
+ */
+struct fimc_fmt {
+   enum v4l2_mbus_pixelcode mbus_code;
+   char*name;
+   u32 fourcc;
+   u32 color;
+   u16 memplanes;
+   u16 colplanes;
+   u8  depth[FIMC_MAX_PLANES];
+   u16 mdataplanes;
+   u16 flags;
+#define FMT_FLAGS_CAM  (1  0)
+#define FMT_FLAGS_M2M_IN   (1  1)
+#define 

[PATCH RFC 11/11] V4L: Add MATRIX option to V4L2_CID_EXPOSURE_METERING control

2013-03-11 Thread Sylwester Nawrocki
This patch adds a menu option to the V4L2_CID_EXPOSURE_METERING
control for multi-zone metering.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/DocBook/media/v4l/controls.xml |9 -
 drivers/media/v4l2-core/v4l2-ctrls.c |1 +
 include/uapi/linux/v4l2-controls.h   |1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 7fe5be1..0484a7d 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3159,6 +3159,13 @@ giving priority to the center of the metered 
area./entry
  
entryconstantV4L2_EXPOSURE_METERING_SPOT/constantnbsp;/entry
  entryMeasure only very small area at the center of the 
frame./entry
/row
+   row
+ 
entryconstantV4L2_EXPOSURE_METERING_MATRIX/constantnbsp;/entry
+ entryA multi-zone metering. The light intensity is measured
+in several points of the frame and the the results are combined. The
+algorithm of the zones selection and their significance in calculating the
+final value is device dependant./entry
+   /row
  /tbody
/entrytbl
  /row
@@ -3986,7 +3993,7 @@ interface and may change in the future./para
 
   table pgwide=1 frame=none id=flash-control-id
   titleFlash Control IDs/title
-
+
   tgroup cols=4
colspec colname=c1 colwidth=1* /
colspec colname=c2 colwidth=6* /
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 4b45d49..6b56d7b 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -234,6 +234,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
Average,
Center Weighted,
Spot,
+   Matrix,
NULL
};
static const char * const camera_auto_focus_range[] = {
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index f56c945..22556a2 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -642,6 +642,7 @@ enum v4l2_exposure_metering {
V4L2_EXPOSURE_METERING_AVERAGE  = 0,
V4L2_EXPOSURE_METERING_CENTER_WEIGHTED  = 1,
V4L2_EXPOSURE_METERING_SPOT = 2,
+   V4L2_EXPOSURE_METERING_MATRIX   = 3,
 };
 
 #define V4L2_CID_SCENE_MODE(V4L2_CID_CAMERA_CLASS_BASE+26)
-- 
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 PATCH 0/8] A V4L2 driver for Exynos4x12 Imaging Subsystem

2013-03-11 Thread Sylwester Nawrocki
This patch series is an initial version of a driver for the camera ISP
subsystem (FIMC-IS) embedded in Samsung Exynos4x12 SoCs.

The FIMC-IS subsystem is build around a ARM Cortex-A5 CPU that controls
its dedicated peripherals, like I2C, SPI, UART, PWM, ADC,...  and the
ISP chain. There are 3 hardware image processing blocks: ISP, DRC
(dynamic range compression) and FD (face detection) that are normally
controlled by the Cortex-A5 firmware.

The driver currently exposes two additional sub-device to user space:
the image sensor and FIMC-IS-ISP sub-device. Another one might be
added in future for the FD features.

The FIMC-IS has various data inputs, it can capture data from memory
or from other SoC IP blocks (FIMC-LITE). It is currently plugged
between FIMC-LITE and FIMC IP blocks, so there is a media pipeline
like:

sensor - MIPI-CSIS - FIMC-LITE - FIMC-IS-ISP - FIMC - memory

A raw Bayer image data can be captured from the ISP block which has
it's own DMA engines. Support for this is not really included in
this series though, only a video capture node driver stubs are added.

This is a bit complicated code, nevertheless I would really appreciate
any review comments you might have.

And this is just a basic set of futures this patch series addresses.
Others include input/output DMA support for the DRC and FD blocks,
support for more ISP controls, etc.

But it all is not immediately needed to make use of this really
great ISP!

A full git tree with all dependencies can be found at:
git://linuxtv.org/snawrocki/samsung.git
http://git.linuxtv.org/snawrocki/samsung.git/exynos4-fimc-is

Sylwester Nawrocki (8):
  s5p-fimc: Add Exynos4x12 FIMC-IS driver
  s5p-fimc: Add FIMC-IS ISP I2C bus driver
  s5p-fimc: Add FIMC-IS parameter region definitions
  s5p-fimc: Add common FIMC-IS image sensor driver
  s5p-fimc: Add ISP video capture driver stubs
  fimc-is: Add Exynos4x12 FIMC-IS device tree bindings documentation
  s5p-fimc: Add fimc-is subdevs registration
  s5p-fimc: Create media links for the FIMC-IS entities

 .../devicetree/bindings/media/exynos4-fimc-is.txt  |   41 +
 drivers/media/platform/s5p-fimc/Kconfig|   13 +
 drivers/media/platform/s5p-fimc/Makefile   |4 +
 drivers/media/platform/s5p-fimc/fimc-is-command.h  |  147 +++
 drivers/media/platform/s5p-fimc/fimc-is-errno.c|  272 ++
 drivers/media/platform/s5p-fimc/fimc-is-errno.h|  248 +
 drivers/media/platform/s5p-fimc/fimc-is-i2c.c  |   81 ++
 drivers/media/platform/s5p-fimc/fimc-is-i2c.h  |   15 +
 drivers/media/platform/s5p-fimc/fimc-is-param.c|  971 +++
 drivers/media/platform/s5p-fimc/fimc-is-param.h| 1018 
 drivers/media/platform/s5p-fimc/fimc-is-regs.c |  242 +
 drivers/media/platform/s5p-fimc/fimc-is-regs.h |  164 
 drivers/media/platform/s5p-fimc/fimc-is-sensor.c   |  308 ++
 drivers/media/platform/s5p-fimc/fimc-is-sensor.h   |   80 ++
 drivers/media/platform/s5p-fimc/fimc-is.c  |  970 +++
 drivers/media/platform/s5p-fimc/fimc-is.h  |  344 +++
 drivers/media/platform/s5p-fimc/fimc-isp-video.c   |  414 
 drivers/media/platform/s5p-fimc/fimc-isp-video.h   |   50 +
 drivers/media/platform/s5p-fimc/fimc-isp.c |  791 +++
 drivers/media/platform/s5p-fimc/fimc-isp.h |  205 
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |  129 ++-
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   15 +
 22 files changed, 6502 insertions(+), 20 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-command.h
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-errno.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-errno.h
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-i2c.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-i2c.h
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-param.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-param.h
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-regs.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-regs.h
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-sensor.h
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is.h
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-isp-video.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-isp-video.h
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-isp.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-isp.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 PATCH 2/8] s5p-fimc: Add FIMC-IS ISP I2C bus driver

2013-03-11 Thread Sylwester Nawrocki
This patch adds the ISP I2C bus controller driver files.

Creating a standard I2C bus adapter, even if the driver doesn't
actually communicates with the hardware and it is instead used
by the ISP firmware running on the Cortex-A5, allows to use
standard hardware description in the device tree. As the sensor
would have actually had a standard V4L2 sub-device driver run
on the host CPU.

This approach allows to adapt the driver with a relatively small
effort should the Imaging Subsystem architecture change so that
the I2C bus is controlled by the host CPU, rather than the
internal FIMC-IS ARM CPU. The image sensor drivers can be
standard I2C client driver, as in case of most existing image
sensor driver.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-is-i2c.c |   81 +
 drivers/media/platform/s5p-fimc/fimc-is-i2c.h |   15 +
 2 files changed, 96 insertions(+)
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-i2c.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-i2c.h

diff --git a/drivers/media/platform/s5p-fimc/fimc-is-i2c.c 
b/drivers/media/platform/s5p-fimc/fimc-is-i2c.c
new file mode 100644
index 000..d4c75dc
--- /dev/null
+++ b/drivers/media/platform/s5p-fimc/fimc-is-i2c.c
@@ -0,0 +1,81 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 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
+ * published by the Free Software Foundation.
+ */
+#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
+
+#include linux/module.h
+#include linux/of_i2c.h
+#include linux/platform_device.h
+#include fimc-is-i2c.h
+
+/*
+ * An empty algorithm is used as the actual I2C bus controller driver
+ * is implemented in the FIMC-IS subsystem firmware and the host CPU
+ * doesn't touch the hardware.
+ */
+static const struct i2c_algorithm fimc_is_i2c_algorithm;
+
+static int fimc_is_i2c_probe(struct platform_device *pdev)
+{
+   struct device_node *node = pdev-dev.of_node;
+   struct i2c_adapter *i2c_adap;
+   int ret;
+
+   i2c_adap = devm_kzalloc(pdev-dev, sizeof(*i2c_adap), GFP_KERNEL);
+
+   i2c_adap-dev.of_node = node;
+   i2c_adap-dev.parent = pdev-dev;
+   strlcpy(i2c_adap-name, exynos4x12-is-i2c, sizeof(i2c_adap-name));
+   i2c_adap-owner = THIS_MODULE;
+   i2c_adap-algo = fimc_is_i2c_algorithm;
+   i2c_adap-class = I2C_CLASS_SPD;
+
+   ret = i2c_add_adapter(i2c_adap);
+   if (ret  0) {
+   dev_err(pdev-dev, failed to add I2C bus %s\n,
+   node-full_name);
+   return ret;
+   }
+   of_i2c_register_devices(i2c_adap);
+
+   return 0;
+}
+
+static int fimc_is_i2c_remove(struct platform_device *pdev)
+{
+   return 0;
+}
+
+static const struct of_device_id fimc_is_i2c_of_match[] = {
+   { .compatible = FIMC_IS_I2C_COMPATIBLE },
+   { },
+};
+MODULE_DEVICE_TABLE(of, fimc_is_i2c_of_match);
+
+static struct platform_driver fimc_is_i2c_driver = {
+   .probe  = fimc_is_i2c_probe,
+   .remove = fimc_is_i2c_remove,
+   .driver = {
+   .of_match_table = fimc_is_i2c_of_match,
+   .name   = fimc-is-i2c,
+   .owner  = THIS_MODULE,
+   }
+};
+
+int fimc_is_register_i2c_driver(void)
+{
+   return platform_driver_register(fimc_is_i2c_driver);
+}
+
+void fimc_is_unregister_i2c_driver(void)
+{
+   platform_driver_unregister(fimc_is_i2c_driver);
+}
+
diff --git a/drivers/media/platform/s5p-fimc/fimc-is-i2c.h 
b/drivers/media/platform/s5p-fimc/fimc-is-i2c.h
new file mode 100644
index 000..0d38d6b
--- /dev/null
+++ b/drivers/media/platform/s5p-fimc/fimc-is-i2c.h
@@ -0,0 +1,15 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 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
+ * published by the Free Software Foundation.
+ */
+
+#define FIMC_IS_I2C_COMPATIBLE samsung,exynos4212-i2c-isp
+
+int fimc_is_register_i2c_driver(void);
+void fimc_is_unregister_i2c_driver(void);
-- 
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 PATCH 3/8] s5p-fimc: Add FIMC-IS parameter region definitions

2013-03-11 Thread Sylwester Nawrocki
This patch adds ISP processing parameters interface files.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-is-param.c |  971 +
 drivers/media/platform/s5p-fimc/fimc-is-param.h | 1018 +++
 2 files changed, 1989 insertions(+)
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-param.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-param.h

diff --git a/drivers/media/platform/s5p-fimc/fimc-is-param.c 
b/drivers/media/platform/s5p-fimc/fimc-is-param.c
new file mode 100644
index 000..5674c3b
--- /dev/null
+++ b/drivers/media/platform/s5p-fimc/fimc-is-param.c
@@ -0,0 +1,971 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Authors: Younghwan Joo yhwan@samsung.com
+ *  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
+ * published by the Free Software Foundation.
+ */
+#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
+
+#include linux/bug.h
+#include linux/device.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/firmware.h
+#include linux/gpio.h
+#include plat/gpio-cfg.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/module.h
+#include linux/types.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/videodev2.h
+
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-mem2mem.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+#include fimc-is-command.h
+#include fimc-is-errno.h
+#include fimc-is-param.h
+#include fimc-is-regs.h
+#include fimc-is-sensor.h
+
+static void __hw_param_copy(void *dst, void *src)
+{
+   memcpy(dst, src, FIMC_IS_PARAM_MAX_SIZE);
+}
+
+void __fimc_is_hw_update_param_global_shotmode(struct fimc_is *is)
+{
+   struct param_global_shotmode *dst, *src;
+
+   dst = is-is_p_region-parameter.global.shotmode;
+   src = is-cfg_param[is-scenario_id].global.shotmode;
+   __hw_param_copy(dst, src);
+}
+
+void __fimc_is_hw_update_param_sensor_framerate(struct fimc_is *is)
+{
+   struct param_sensor_framerate *dst, *src;
+
+   dst = is-is_p_region-parameter.sensor.frame_rate;
+   src = is-cfg_param[is-scenario_id].sensor.frame_rate;
+   __hw_param_copy(dst, src);
+}
+
+int __fimc_is_hw_update_param(struct fimc_is *is, u32 offset)
+{
+   struct is_param_region *par = is-is_p_region-parameter;
+   struct is_config_param *cfg = is-cfg_param[is-scenario_id];
+
+   switch (offset) {
+   case PARAM_ISP_CONTROL:
+   __hw_param_copy(par-isp.control, cfg-isp.control);
+   break;
+
+   case PARAM_ISP_OTF_INPUT:
+   __hw_param_copy(par-isp.otf_input, cfg-isp.otf_input);
+   break;
+
+   case PARAM_ISP_DMA1_INPUT:
+   __hw_param_copy(par-isp.dma1_input, cfg-isp.dma1_input);
+   break;
+
+   case PARAM_ISP_DMA2_INPUT:
+   __hw_param_copy(par-isp.dma2_input, cfg-isp.dma2_input);
+   break;
+
+   case PARAM_ISP_AA:
+   __hw_param_copy(par-isp.aa, cfg-isp.aa);
+   break;
+
+   case PARAM_ISP_FLASH:
+   __hw_param_copy(par-isp.flash, cfg-isp.flash);
+   break;
+
+   case PARAM_ISP_AWB:
+   __hw_param_copy(par-isp.awb, cfg-isp.awb);
+   break;
+
+   case PARAM_ISP_IMAGE_EFFECT:
+   __hw_param_copy(par-isp.effect, cfg-isp.effect);
+   break;
+
+   case PARAM_ISP_ISO:
+   __hw_param_copy(par-isp.iso, cfg-isp.iso);
+   break;
+
+   case PARAM_ISP_ADJUST:
+   __hw_param_copy(par-isp.adjust, cfg-isp.adjust);
+   break;
+
+   case PARAM_ISP_METERING:
+   __hw_param_copy(par-isp.metering, cfg-isp.metering);
+   break;
+
+   case PARAM_ISP_AFC:
+   __hw_param_copy(par-isp.afc, cfg-isp.afc);
+   break;
+
+   case PARAM_ISP_OTF_OUTPUT:
+   __hw_param_copy(par-isp.otf_output, cfg-isp.otf_output);
+   break;
+
+   case PARAM_ISP_DMA1_OUTPUT:
+   __hw_param_copy(par-isp.dma1_output, cfg-isp.dma1_output);
+   break;
+
+   case PARAM_ISP_DMA2_OUTPUT:
+   __hw_param_copy(par-isp.dma2_output, cfg-isp.dma2_output);
+   break;
+
+   case PARAM_DRC_CONTROL:
+   __hw_param_copy(par-drc.control, cfg-drc.control);
+   break;
+
+   case PARAM_DRC_OTF_INPUT:
+   __hw_param_copy(par-drc.otf_input, cfg-drc.otf_input);
+   break;
+
+   case 

[RFC PATCH 4/8] s5p-fimc: Add common FIMC-IS image sensor driver

2013-03-11 Thread Sylwester Nawrocki
This subdev driver currently only handles an image sensor's
power supplies and reset signal. There is no any I2C communication
here as it is handled by the ISP's firmware.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-is-sensor.c |  308 ++
 drivers/media/platform/s5p-fimc/fimc-is-sensor.h |   80 ++
 2 files changed, 388 insertions(+)
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-is-sensor.h

diff --git a/drivers/media/platform/s5p-fimc/fimc-is-sensor.c 
b/drivers/media/platform/s5p-fimc/fimc-is-sensor.c
new file mode 100644
index 000..151915c
--- /dev/null
+++ b/drivers/media/platform/s5p-fimc/fimc-is-sensor.c
@@ -0,0 +1,308 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 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
+ * published by the Free Software Foundation.
+ */
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/gpio.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/kernel.h
+#include linux/memory.h
+#include linux/module.h
+#include linux/of_gpio.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+#include media/v4l2-subdev.h
+
+#include fimc-is.h
+#include fimc-is-sensor.h
+
+#define DRIVER_NAME FIMC-IS-SENSOR
+
+static const char * const sensor_supply_names[] = {
+   svdda,
+   svddio,
+};
+
+static const struct v4l2_mbus_framefmt fimc_is_sensor_formats[] = {
+   {
+   .code = V4L2_MBUS_FMT_SGRBG10_1X10,
+   .colorspace = V4L2_COLORSPACE_SRGB,
+   .field = V4L2_FIELD_NONE,
+   }
+};
+
+static struct fimc_is_sensor *sd_to_fimc_is_sensor(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct fimc_is_sensor, subdev);
+}
+
+static const struct v4l2_mbus_framefmt *find_sensor_format(
+   struct v4l2_mbus_framefmt *mf)
+{
+   int i;
+
+   for (i = 0; i  ARRAY_SIZE(fimc_is_sensor_formats); i++)
+   if (mf-code == fimc_is_sensor_formats[i].code)
+   return fimc_is_sensor_formats[i];
+
+   return fimc_is_sensor_formats[0];
+}
+
+static int fimc_is_sensor_enum_mbus_code(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_mbus_code_enum *code)
+{
+   if (code-index = ARRAY_SIZE(fimc_is_sensor_formats))
+   return -EINVAL;
+
+   code-code = fimc_is_sensor_formats[code-index].code;
+   return 0;
+}
+
+static void fimc_is_sensor_try_format(struct fimc_is_sensor *sensor,
+ struct v4l2_mbus_framefmt *mf)
+{
+   const struct sensor_drv_data *dd = sensor-drvdata;
+   const struct v4l2_mbus_framefmt *fmt;
+
+   fmt = find_sensor_format(mf);
+   mf-code = fmt-code;
+   v4l_bound_align_image(mf-width, 16 + 8, dd-width, 0,
+ mf-height, 12 + 8, dd-height, 0, 0);
+}
+
+static struct v4l2_mbus_framefmt *__fimc_is_sensor_get_format(
+   struct fimc_is_sensor *sensor, struct v4l2_subdev_fh *fh,
+   u32 pad, enum v4l2_subdev_format_whence which)
+{
+   if (which == V4L2_SUBDEV_FORMAT_TRY)
+   return fh ? v4l2_subdev_get_try_format(fh, pad) : NULL;
+
+   return sensor-format;
+}
+
+static int fimc_is_sensor_set_fmt(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_format *fmt)
+{
+   struct fimc_is_sensor *sensor = sd_to_fimc_is_sensor(sd);
+   struct v4l2_mbus_framefmt *mf;
+
+   fimc_is_sensor_try_format(sensor, fmt-format);
+
+   mf = __fimc_is_sensor_get_format(sensor, fh, fmt-pad, fmt-which);
+   if (mf) {
+   mutex_lock(sensor-lock);
+   if (fmt-which == V4L2_SUBDEV_FORMAT_ACTIVE)
+   sensor-format = *mf;
+   mutex_unlock(sensor-lock);
+   }
+   return 0;
+}
+
+static int fimc_is_sensor_get_fmt(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_format *fmt)
+{
+   struct fimc_is_sensor *sensor = sd_to_fimc_is_sensor(sd);
+   struct v4l2_mbus_framefmt *mf;
+
+   mf = __fimc_is_sensor_get_format(sensor, fh, fmt-pad, fmt-which);
+
+   mutex_lock(sensor-lock);
+   fmt-format = *mf;
+   mutex_unlock(sensor-lock);
+   return 0;
+}
+
+static struct v4l2_subdev_pad_ops fimc_is_sensor_pad_ops = {
+   .enum_mbus_code = fimc_is_sensor_enum_mbus_code,
+   .get_fmt= 

[RFC PATCH 5/8] s5p-fimc: Add ISP video capture driver stubs

2013-03-11 Thread Sylwester Nawrocki
This patch adds a video capture node for the FIMC-IS ISP IP block
and Makefile/Kconfig to actually enable the driver's compilation.

The ISP video capture driver is still a work in progress.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/Kconfig  |   13 +
 drivers/media/platform/s5p-fimc/Makefile |4 +
 drivers/media/platform/s5p-fimc/fimc-isp-video.c |  414 ++
 drivers/media/platform/s5p-fimc/fimc-isp-video.h |   50 +++
 4 files changed, 481 insertions(+)
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-isp-video.c
 create mode 100644 drivers/media/platform/s5p-fimc/fimc-isp-video.h

diff --git a/drivers/media/platform/s5p-fimc/Kconfig 
b/drivers/media/platform/s5p-fimc/Kconfig
index c16b20d..1253e25 100644
--- a/drivers/media/platform/s5p-fimc/Kconfig
+++ b/drivers/media/platform/s5p-fimc/Kconfig
@@ -46,4 +46,17 @@ config VIDEO_EXYNOS_FIMC_LITE
  module will be called exynos-fimc-lite.
 endif
 
+if (SOC_EXYNOS4212 || SOC_EXYNOS4412)  OF  !ARCH_MULTIPLATFORM
+
+config VIDEO_EXYNOS4_FIMC_IS
+   tristate EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ This is a V4L2 driver for Samsung EXYNOS4x12 SoC FIMC-IS
+ (Imaging Subsystem).
+
+ To compile this driver as a module, choose M here: the
+ module will be called exynos-fimc-is.
+endif
+
 endif # VIDEO_SAMSUNG_S5P_FIMC
diff --git a/drivers/media/platform/s5p-fimc/Makefile 
b/drivers/media/platform/s5p-fimc/Makefile
index 4648514..55b171a 100644
--- a/drivers/media/platform/s5p-fimc/Makefile
+++ b/drivers/media/platform/s5p-fimc/Makefile
@@ -1,7 +1,11 @@
 s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-m2m.o fimc-capture.o 
fimc-mdevice.o
 exynos-fimc-lite-objs += fimc-lite-reg.o fimc-lite.o
+exynos-fimc-is-objs := fimc-is.o fimc-isp.o fimc-is-sensor.o fimc-is-regs.o
+exynos-fimc-is-objs += fimc-is-param.o fimc-is-errno.o fimc-is-i2c.o
+exynos-fimc-is-objs += fimc-isp-video.o
 s5p-csis-objs := mipi-csis.o
 
 obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS)  += s5p-csis.o
 obj-$(CONFIG_VIDEO_EXYNOS_FIMC_LITE)   += exynos-fimc-lite.o
+obj-$(CONFIG_VIDEO_EXYNOS4_FIMC_IS)+= exynos-fimc-is.o
 obj-$(CONFIG_VIDEO_S5P_FIMC)   += s5p-fimc.o
diff --git a/drivers/media/platform/s5p-fimc/fimc-isp-video.c 
b/drivers/media/platform/s5p-fimc/fimc-isp-video.c
new file mode 100644
index 000..bdeacaa
--- /dev/null
+++ b/drivers/media/platform/s5p-fimc/fimc-isp-video.c
@@ -0,0 +1,414 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: 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
+ * published by the Free Software Foundation.
+ */
+
+#include linux/device.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/types.h
+#include linux/printk.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/videodev2.h
+
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-mdevice.h
+#include fimc-core.h
+#include fimc-is.h
+
+static int isp_video_capture_start_streaming(struct vb2_queue *q,
+   unsigned int count)
+{
+   /* TODO: start ISP output DMA */
+   return 0;
+}
+
+static int isp_video_capture_stop_streaming(struct vb2_queue *q)
+{
+   /* TODO: stop ISP output DMA */
+   return 0;
+}
+
+static int isp_video_capture_queue_setup(struct vb2_queue *vq,
+   const struct v4l2_format *pfmt,
+   unsigned int *num_buffers, unsigned int *num_planes,
+   unsigned int sizes[], void *allocators[])
+{
+   const struct v4l2_pix_format_mplane *pixm = NULL;
+   struct fimc_isp *isp = vq-drv_priv;
+   struct fimc_isp_frame *frame = isp-out_frame;
+   const struct fimc_fmt *fmt = isp-video_capture_format;
+   unsigned long wh;
+   int i;
+
+   if (pfmt) {
+   pixm = pfmt-fmt.pix_mp;
+   fmt = fimc_isp_find_format(pixm-pixelformat, NULL, -1);
+   wh = pixm-width * pixm-height;
+   } else {
+   wh = frame-f_width * frame-f_height;
+   }
+
+   if (fmt == NULL)
+   return -EINVAL;
+
+   *num_planes = fmt-memplanes;
+
+   for (i = 0; i  fmt-memplanes; i++) {
+   unsigned int size = (wh * fmt-depth[i]) / 8;
+   if (pixm)
+   sizes[i] = max(size, pixm-plane_fmt[i].sizeimage);
+   else
+   sizes[i] = size;
+   allocators[i] = isp-alloc_ctx;
+   }
+
+   return 0;
+}
+

[RFC PATCH 7/8] s5p-fimc: Add fimc-is subdevs registration

2013-03-11 Thread Sylwester Nawrocki
This patch allows to register FIMC-IS device represented by FIMC-IS-ISP
subdev to the top level media device driver. The use_isp platform data
structure field allows to select whether the fimc-is ISP subdev should
be tried to be registered or not.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   51 ++--
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   15 +++
 2 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index e9e5337..1521dec 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -31,6 +31,7 @@
 #include media/s5p_fimc.h
 
 #include fimc-core.h
+#include fimc-is.h
 #include fimc-lite.h
 #include fimc-mdevice.h
 #include mipi-csis.h
@@ -85,9 +86,11 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
case GRP_ID_FIMC:
/* No need to control FIMC subdev through subdev ops */
break;
+   case GRP_ID_FIMC_IS:
+   p-subdevs[IDX_IS_ISP] = sd;
+   break;
default:
-   pr_warn(%s: Unknown subdev grp_id: %#x\n,
-   __func__, sd-grp_id);
+   break;
}
me = sd-entity;
if (me-num_pads == 1)
@@ -291,6 +294,7 @@ static void fimc_md_unregister_sensor(struct v4l2_subdev 
*sd)
 
if (!client)
return;
+
v4l2_device_unregister_subdev(sd);
 
if (!client-dev.of_node) {
@@ -341,7 +345,11 @@ static int fimc_md_of_add_sensor(struct fimc_md *fmd,
goto mod_put;
 
v4l2_set_subdev_hostdata(sd, si);
-   sd-grp_id = GRP_ID_SENSOR;
+   if (si-pdata.fimc_bus_type == FIMC_BUS_TYPE_ISP_WRITEBACK)
+   sd-grp_id = GRP_ID_FIMC_IS_SENSOR;
+   else
+   sd-grp_id = GRP_ID_SENSOR;
+
si-subdev = sd;
v4l2_info(fmd-v4l2_dev, Registered sensor subdevice: %s (%d)\n,
  sd-name, fmd-num_sensors);
@@ -360,7 +368,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
   struct device_node *port,
   unsigned int index)
 {
-   struct device_node *rem, *endpoint;
+   struct device_node *rem, *endpoint, *np;
struct fimc_source_info *pd;
struct v4l2_of_endpoint bus_cfg;
u32 tmp, reg = 0;
@@ -415,6 +423,18 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
v4l2_err(fmd-v4l2_dev, Wrong port id (%u) at node %s\n,
 reg, rem-full_name);
}
+   /*
+* For FIMC-IS handled sensors, that are placed under fimc-is-i2c
+* device node, FIMC is connected to the FIMC-IS through its ISP
+* Writeback input. Sensors are attached to the FIMC-LITE hostdata
+* interface directly or through MIPI-CSIS, depending on the external
+* media bus used. This needs to be handled in a more reliable way,
+* not by just checking parent's node name.
+*/
+   if ((np = of_get_parent(rem))  !of_node_cmp(np-name, i2c-isp))
+   pd-fimc_bus_type = FIMC_BUS_TYPE_ISP_WRITEBACK;
+   else
+   pd-fimc_bus_type = pd-sensor_bus_type;
 
ret = fimc_md_of_add_sensor(fmd, rem, index);
of_node_put(rem);
@@ -607,6 +627,22 @@ static int register_csis_entity(struct fimc_md *fmd,
return ret;
 }
 
+static int register_fimc_is_entity(struct fimc_md *fmd, struct fimc_is *is)
+{
+   struct v4l2_subdev *sd = is-isp.subdev;
+   int ret;
+
+   ret = v4l2_device_register_subdev(fmd-v4l2_dev, sd);
+   if (ret) {
+   v4l2_err(fmd-v4l2_dev,
+Failed to register FIMC-ISP (%d)\n, ret);
+   return ret;
+   }
+
+   fmd-fimc_is = is;
+   return 0;
+}
+
 static int fimc_md_register_platform_entity(struct fimc_md *fmd,
struct platform_device *pdev,
int plat_entity)
@@ -634,6 +670,9 @@ static int fimc_md_register_platform_entity(struct fimc_md 
*fmd,
case IDX_CSIS:
ret = register_csis_entity(fmd, pdev, drvdata);
break;
+   case IDX_IS_ISP:
+   ret = register_fimc_is_entity(fmd, drvdata);
+   break;
default:
ret = -ENODEV;
}
@@ -697,6 +736,8 @@ static int fimc_md_register_of_platform_entities(struct 
fimc_md *fmd,
/* If driver of any entity isn't ready try all again later. */
  

[RFC PATCH 6/8] fimc-is: Add Exynos4x12 FIMC-IS device tree bindings documentation

2013-03-11 Thread Sylwester Nawrocki
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/media/exynos4-fimc-is.txt  |   41 
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos4-fimc-is.txt

diff --git a/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt 
b/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
new file mode 100644
index 000..ef994d1
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
@@ -0,0 +1,41 @@
+Exynos4x12 SoC series Imaging Subsystem (FIMC-IS)
+
+The FIMC-IS is an subsystem for processing image signal from an image sensor.
+The Exynos4x12 SoC series FIMC-IS V1.5 comprises of a dedicated ARM Cortex-A5
+processor, ISP, DRC and FD IP blocks and peripheral IPs such as I2C, SPI, UART
+bus controllers, Multi-PWM and ADC.
+
+fimc-is node
+
+
+Required properties:
+
+- compatible : should be samsung,exynos4212-fimc-is for Exynos4212 and
+  Exynos4412 SoCs;
+- reg   : physical base address and size of the device memory mapped
+  registers;
+- interrupts : should contain FIMC-IS interrupts;
+
+The following are the FIMC-IS peripheral device nodes and can be specified
+either standalone or as fimc-is child nodes.
+
+pmu subnode
+---
+
+Required properties:
+ - reg : should contain PMU physical base address of the memory mapped
+  registers and size, the value of size should be 0x3000.
+
+
+i2c-isp (ISP I2C bus controller) nodes
+--
+
+Required properties:
+
+- compatible : should be samsung,exynos4212-i2c-isp for Exynos4212 and
+  Exynos4412 SoCs;
+- reg   : physical base address and size of the device memory mapped
+  registers;
+
+For the above nodes it is required to specify a pinctrl state named default,
+according to the pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt.
-- 
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 PATCH 8/8] s5p-fimc: Create media links for the FIMC-IS entities

2013-03-11 Thread Sylwester Nawrocki
Create disabled links from the FIMC-LITE subdevs to the FIMC-IS-ISP
subdev and from FIMC-IS-ISP to all FIMC subdevs.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   78 +++-
 1 file changed, 62 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 1521dec..5304da5 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -807,9 +807,17 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md 
*fmd,
struct fimc_sensor_info *s_info = NULL;
struct media_entity *sink;
unsigned int flags = 0;
-   int ret, i;
+   int i, ret = 0;
 
-   for (i = 0; i  FIMC_MAX_DEVS; i++) {
+   if (sensor) {
+   s_info = v4l2_get_subdev_hostdata(sensor);
+   /* Skip direct FIMC links in the logical FIMC-IS sensor path */
+   if (s_info  s_info-pdata.fimc_bus_type ==
+   FIMC_BUS_TYPE_ISP_WRITEBACK)
+   ret = 1;
+   }
+
+   for (i = 0; !ret  i  FIMC_MAX_DEVS; i++) {
if (!fmd-fimc[i])
continue;
/*
@@ -838,7 +846,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md 
*fmd,
 
if (flags == 0 || sensor == NULL)
continue;
-   s_info = v4l2_get_subdev_hostdata(sensor);
+
if (!WARN_ON(s_info == NULL)) {
unsigned long irq_flags;
spin_lock_irqsave(fmd-slock, irq_flags);
@@ -851,25 +859,20 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
if (!fmd-fimc_lite[i])
continue;
 
-   if (link_mask  (1  (i + FIMC_MAX_DEVS)))
-   flags = MEDIA_LNK_FL_ENABLED;
-   else
-   flags = 0;
-
sink = fmd-fimc_lite[i]-subdev.entity;
ret = media_entity_create_link(source, pad, sink,
-  FLITE_SD_PAD_SINK, flags);
+  FLITE_SD_PAD_SINK, 0);
if (ret)
return ret;
 
/* Notify FIMC-LITE subdev entity */
ret = media_entity_call(sink, link_setup, sink-pads[0],
-   source-pads[pad], flags);
+   source-pads[pad], 0);
if (ret)
break;
 
-   v4l2_info(fmd-v4l2_dev, created link [%s] %c [%s]\n,
- source-name, flags ? '=' : '-', sink-name);
+   v4l2_info(fmd-v4l2_dev, created link [%s] - [%s]\n,
+ source-name, sink-name);
}
return 0;
 }
@@ -878,26 +881,59 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
 static int __fimc_md_create_flite_source_links(struct fimc_md *fmd)
 {
struct media_entity *source, *sink;
-   unsigned int flags = MEDIA_LNK_FL_ENABLED;
int i, ret = 0;
 
for (i = 0; i  FIMC_LITE_MAX_DEVS; i++) {
struct fimc_lite *fimc = fmd-fimc_lite[i];
+
if (fimc == NULL)
continue;
+
source = fimc-subdev.entity;
sink = fimc-vfd.entity;
/* FIMC-LITE's subdev and video node */
ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_DMA,
-  sink, 0, flags);
+  sink, 0, 0);
+   if (ret)
+   break;
+   /* Link from FIMC-LITE to IS-ISP subdev */
+   sink = fmd-fimc_is-isp.subdev.entity;
+   ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_ISP,
+  sink, 0, 0);
if (ret)
break;
-   /* TODO: create links to other entities */
}
 
return ret;
 }
 
+/* Create FIMC-IS links */
+static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd)
+{
+   struct media_entity *source, *sink;
+   int i, ret;
+
+   source = fmd-fimc_is-isp.subdev.entity;
+
+   for (i = 0; i  FIMC_MAX_DEVS; i++) {
+   if (fmd-fimc[i] == NULL)
+   continue;
+
+   /* Link from IS-ISP subdev to FIMC */
+   sink = fmd-fimc[i]-vid_cap.subdev.entity;
+   ret = media_entity_create_link(source, FIMC_IS_SD_PAD_SRC_FIFO,
+  sink, FIMC_SD_PAD_SINK_FIFO, 0);
+   if (ret)
+   return ret;
+   }
+
+   /* Link from IS-ISP subdev to 

Re: [PATCH] block i2c tuner reads for Avermedia Twinstar in the af9035 driver

2013-03-11 Thread Jose Alberto Reguero
On Lunes, 11 de marzo de 2013 14:57:37 Antti Palosaari escribió:
 On 03/11/2013 01:51 PM, Jose Alberto Reguero wrote:
  On Lunes, 11 de febrero de 2013 14:48:18 Jose Alberto Reguero escribió:
  On Domingo, 10 de febrero de 2013 22:11:53 Antti Palosaari escribió:
  On 02/10/2013 09:43 PM, Jose Alberto Reguero wrote:
  This patch block the i2c tuner reads for Avermedia Twinstar. If it's
  needed other pids can be added.
  
  Signed-off-by: Jose Alberto Reguero jaregu...@telefonica.net
  
  diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.c
  linux.new/drivers/media/usb/dvb-usb-v2/af9035.c ---
  linux/drivers/media/usb/dvb-usb-v2/af9035.c  2013-01-07
  05:45:57.0 +0100 +++
  linux.new/drivers/media/usb/dvb-usb-v2/af9035.c  2013-02-08
  22:55:08.304089054 +0100 @@ -232,7 +232,11 @@ static int
  af9035_i2c_master_xfer(struct
  
   buf[3] = 0x00; /* reg addr MSB */
   buf[4] = 0x00; /* reg addr LSB */
   memcpy(buf[5], msg[0].buf, msg[0].len);
  
  -ret = af9035_ctrl_msg(d, req);
  +if (state-block_read) {
  +msg[1].buf[0] = 0x3f;
  +ret = 0;
  +} else
  +ret = af9035_ctrl_msg(d, req);
  
   }
   
   } else if (num == 1  !(msg[0].flags  I2C_M_RD)) {
   
   if (msg[0].len  40) {
  
  @@ -638,6 +642,17 @@ static int af9035_read_config(struct dvb
  
   for (i = 0; i  ARRAY_SIZE(state-af9033_config); i++)
   
   state-af9033_config[i].clock = clock_lut[tmp];
  
  +state-block_read = false;
  +
  +if (le16_to_cpu(d-udev-descriptor.idVendor) == 
  USB_VID_AVERMEDIA 
  +le16_to_cpu(d-udev-descriptor.idProduct) ==
  +USB_PID_AVERMEDIA_TWINSTAR) {
  +dev_dbg(d-udev-dev,
  +%s: AverMedia Twinstar: block i2c read 
  from tuner\n,
  +__func__);
  +state-block_read = true;
  +}
  +
  
   return 0;
 
 err:
  diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.h
  linux.new/drivers/media/usb/dvb-usb-v2/af9035.h ---
  linux/drivers/media/usb/dvb-usb-v2/af9035.h  2013-01-07
  05:45:57.0 +0100 +++
  linux.new/drivers/media/usb/dvb-usb-v2/af9035.h  2013-02-08
  22:52:42.293842710 +0100 @@ -54,6 +54,7 @@ struct usb_req {
  
 struct state {
 
   u8 seq; /* packet sequence number */
   bool dual_mode;
  
  +bool block_read;
  
   struct af9033_config af9033_config[2];
 
 };
  
  Could you test if faking tuner ID during attach() is enough?
  
  Also, I would like to know what is returned error code from firmware
  when it fails. Enable debugs to see it. It should print something like
  that: af9035_ctrl_msg: command=03 failed fw error=2
  
  
  diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c
  b/drivers/media/usb/dvb-usb-v2/af9035.c
  index a1e953a..5a4f28d 100644
  --- a/drivers/media/usb/dvb-usb-v2/af9035.c
  +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
  @@ -1082,9 +1082,22 @@ static int af9035_tuner_attach(struct
  dvb_usb_adapter *adap)
  
tuner_addr = 0x60 | 0x80; /* I2C bus hack */

}
  
  +   // fake used tuner for demod firmware / i2c adapter
  +   if (adap-id == 0)
  +   ret = af9035_wr_reg(d, 0x00f641,
  AF9033_TUNER_FC0011);
  +   else
  +   ret = af9035_wr_reg(d, 0x10f641,
  AF9033_TUNER_FC0011);
  +
  
/* attach tuner */
fe = dvb_attach(mxl5007t_attach, adap-fe[0],
d-i2c_adap,

tuner_addr,
  
  af9035_mxl5007t_config[adap-id]);
  +
  +   // return correct tuner
  +   if (adap-id == 0)
  +   ret = af9035_wr_reg(d, 0x00f641,
  AF9033_TUNER_MXL5007T);
  +   else
  +   ret = af9035_wr_reg(d, 0x10f641,
  AF9033_TUNER_MXL5007T);
  +
  
break;

case AF9033_TUNER_TDA18218:
/* attach tuner */
  
  regards
  Antti
  
  I will try with fake tuner, but I can't test unil next weekend.
  If I remember, the read operation is performed, and return good value,
  but after that, all the i2c transfers fail. Seee:
  
  http://www.mail-archive.com/linux-media@vger.kernel.org/msg56346.html
  
  Jose Alberto
  
  I tried with fake tuner without success:
  
  [ 1346.707405] DVB: registering new adapter (AVerMedia Twinstar (A825))
  [ 1346.959043] i2c i2c-1: af9033: firmware version: LINK=11.5.9.0
  OFDM=5.17.9.1
  [ 1346.962920] usb 1-2: DVB: registering adapter 0 frontend 0 

Re: omap3isp: iommu register problem.

2013-03-11 Thread Laurent Pinchart
Hi Javier,

On Monday 11 March 2013 16:28:58 javier Martin wrote:
 On 11 March 2013 16:01, Laurent Pinchart wrote:
  On Monday 11 March 2013 13:18:12 javier Martin wrote:
  I've just found the following thread where te problem is explained:
  http://lists.infradead.org/pipermail/linux-arm-kernel/2012-February/08636
  4.h tml
  
  The problem is related with the order iommu and omap3isp are probed
  when both are built-in. If I load omap3isp as a module the problem is
  gone.
  
  However, according to the previous thread, omap3isp register should
  return error but an oops should not be generated. So I think there is
  a bug here anyway.
  
  Does the following patch (compile-tested only) fix the issue ?
  
  diff --git a/drivers/media/platform/omap3isp/isp.c
  b/drivers/media/platform/omap3isp/isp.c index 6e5ad8e..4d889be 100644
  --- a/drivers/media/platform/omap3isp/isp.c
  +++ b/drivers/media/platform/omap3isp/isp.c
  @@ -2123,6 +2123,7 @@ static int isp_probe(struct platform_device *pdev)
  ret = iommu_attach_device(isp-domain, pdev-dev);
  if (ret) {
  dev_err(pdev-dev, can't attach iommu device: %d\n,
  ret);
  +   ret = -EPROBE_DEFER;
  goto free_domain;
  }
  
  @@ -2161,6 +2162,7 @@ detach_dev:
  iommu_detach_device(isp-domain, pdev-dev);
   free_domain:
  iommu_domain_free(isp-domain);
  +   isp-domain = NULL;
   error_isp:
  omap3isp_put(isp);
   error:

 Yes, that solves the problems.

Great. I'll push the patch to v3.10 then.

 [2.706939] omap3isp omap3isp: Revision 15.0 found
 [2.712402] omap_iommu_attach: 1
 [2.715942] omap_iommu_attach: 2
 [2.719329] omap_iommu_attach: 3
 [2.722778] omap_iommu_attach: 4
 [2.726135] omap_iommu_attach: 5
 [2.729553] iommu_enable: 1
 [2.732482] iommu_enable: 2, arch_iommu = c0599adc
 [2.737548] iommu_enable: 3
 [2.740478] iommu_enable: 5
 [2.743652] omap-iommu omap-iommu.0: mmu_isp: version 1.1
 [2.749389] omap_iommu_attach: 6
 [2.752807] omap_iommu_attach: 7
 [2.756195] omap_iommu_attach: 8
 [2.759613] omap_iommu_attach: 9
 [2.763977] omap3isp omap3isp: hist: DMA channel = 2
 [2.770904] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
 [2.778839] ALSA device list:
 [2.781982]   No soundcards found.
 [2.799285] mt9m111 2-0048: mt9m111: driver needs platform data
 [2.805603] mt9m111: probe of 2-0048 failed with error -22
 [2.814849] omap3isp omap3isp: isp_register_subdev_group: Unable to
 register subdev mt9m111
 
 The error I get now seems more related to the fact that I am trying to
 use a soc-camera sensor (mt9m111) with a non-soc-camera host
 (omap3isp) and I probably need some extra platform code.
 
 Do you know any board in mainline in a similar situation?

There's none yet I'm afraid.

We don't have the necessary infrastructure in place yet to allow this. 
Guennadi might be able to give you a bit more information about the current 
status.

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


[REVIEW PATCH 00/15] au0828: v4l2-compliance cleanups

2013-03-11 Thread Hans Verkuil
Hi all,

This patch series converts the au0828/au8522 drivers to the latest frameworks,
except for vb2 as usual.

Tested with a WinTV aero generously donated by Hauppauge some time ago.

I also did a lot of fixes in the disconnect handling and setting up the
right routing/std information at the right time.

It is now working correctly as far as I can tell: if I stick it in my PC
and run qv4l2 it actually picks up the tuner signal right away (if I set
it to the correct frequency of course).

If someone has additional hardware, then that would be nice if that can be
tested as well.

My git branch is here:

http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/au0828

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


[REVIEW PATCH 01/15] au8522_decoder: convert to the control framework.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/dvb-frontends/au8522_decoder.c |  130 +-
 drivers/media/dvb-frontends/au8522_priv.h|6 +-
 2 files changed, 46 insertions(+), 90 deletions(-)

diff --git a/drivers/media/dvb-frontends/au8522_decoder.c 
b/drivers/media/dvb-frontends/au8522_decoder.c
index 5243ba6..be2c802 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -229,15 +229,11 @@ static void setup_decoder_defaults(struct au8522_state 
*state, u8 input_mode)
/* Provide reasonable defaults for picture tuning values */
au8522_writereg(state, AU8522_TVDEC_SHARPNESSREG009H, 0x07);
au8522_writereg(state, AU8522_TVDEC_BRIGHTNESS_REG00AH, 0xed);
-   state-brightness = 0xed - 128;
au8522_writereg(state, AU8522_TVDEC_CONTRAST_REG00BH, 0x79);
-   state-contrast = 0x79;
au8522_writereg(state, AU8522_TVDEC_SATURATION_CB_REG00CH, 0x80);
au8522_writereg(state, AU8522_TVDEC_SATURATION_CR_REG00DH, 0x80);
-   state-saturation = 0x80;
au8522_writereg(state, AU8522_TVDEC_HUE_H_REG00EH, 0x00);
au8522_writereg(state, AU8522_TVDEC_HUE_L_REG00FH, 0x00);
-   state-hue = 0x00;
 
/* Other decoder registers */
au8522_writereg(state, AU8522_TVDEC_INT_MASK_REG010H, 0x00);
@@ -489,75 +485,32 @@ static void set_audio_input(struct au8522_state *state, 
int aud_input)
 
 /* --- */
 
-static int au8522_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int au8522_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   struct au8522_state *state = to_state(sd);
+   struct au8522_state *state =
+   container_of(ctrl-handler, struct au8522_state, hdl);
 
switch (ctrl-id) {
case V4L2_CID_BRIGHTNESS:
-   state-brightness = ctrl-value;
au8522_writereg(state, AU8522_TVDEC_BRIGHTNESS_REG00AH,
-   ctrl-value - 128);
+   ctrl-val - 128);
break;
case V4L2_CID_CONTRAST:
-   state-contrast = ctrl-value;
au8522_writereg(state, AU8522_TVDEC_CONTRAST_REG00BH,
-   ctrl-value);
+   ctrl-val);
break;
case V4L2_CID_SATURATION:
-   state-saturation = ctrl-value;
au8522_writereg(state, AU8522_TVDEC_SATURATION_CB_REG00CH,
-   ctrl-value);
+   ctrl-val);
au8522_writereg(state, AU8522_TVDEC_SATURATION_CR_REG00DH,
-   ctrl-value);
+   ctrl-val);
break;
case V4L2_CID_HUE:
-   state-hue = ctrl-value;
au8522_writereg(state, AU8522_TVDEC_HUE_H_REG00EH,
-   ctrl-value  8);
+   ctrl-val  8);
au8522_writereg(state, AU8522_TVDEC_HUE_L_REG00FH,
-   ctrl-value  0xFF);
-   break;
-   case V4L2_CID_AUDIO_VOLUME:
-   case V4L2_CID_AUDIO_BASS:
-   case V4L2_CID_AUDIO_TREBLE:
-   case V4L2_CID_AUDIO_BALANCE:
-   case V4L2_CID_AUDIO_MUTE:
-   /* Not yet implemented */
-   default:
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
-static int au8522_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct au8522_state *state = to_state(sd);
-
-   /* Note that we are using values cached in the state structure instead
-  of reading the registers due to issues with i2c reads not working
-  properly/consistently yet on the HVR-950q */
-
-   switch (ctrl-id) {
-   case V4L2_CID_BRIGHTNESS:
-   ctrl-value = state-brightness;
-   break;
-   case V4L2_CID_CONTRAST:
-   ctrl-value = state-contrast;
-   break;
-   case V4L2_CID_SATURATION:
-   ctrl-value = state-saturation;
-   break;
-   case V4L2_CID_HUE:
-   ctrl-value = state-hue;
+   ctrl-val  0xFF);
break;
-   case V4L2_CID_AUDIO_VOLUME:
-   case V4L2_CID_AUDIO_BASS:
-   case V4L2_CID_AUDIO_TREBLE:
-   case V4L2_CID_AUDIO_BALANCE:
-   case V4L2_CID_AUDIO_MUTE:
-   /* Not yet supported */
default:
return -EINVAL;
}
@@ -616,26 +569,6 @@ static int au8522_s_stream(struct v4l2_subdev *sd, int 
enable)
return 0;
 }
 
-static int au8522_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
-{
-   switch (qc-id) {
-   case V4L2_CID_CONTRAST:
-   return v4l2_ctrl_query_fill(qc, 0, 255, 1,
-   

[REVIEW PATCH 07/15] au0828: add prio, control event and log_status support

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/au0828/au0828-video.c |   42 ---
 drivers/media/usb/au0828/au0828.h   |4 +++
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 7d762c0..07287ef 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -35,6 +35,7 @@
 #include linux/suspend.h
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
+#include media/v4l2-event.h
 #include media/v4l2-chip-ident.h
 #include media/tuner.h
 #include au0828.h
@@ -988,6 +989,7 @@ static int au0828_v4l2_open(struct file *filp)
 
fh-type = type;
fh-dev = dev;
+   v4l2_fh_init(fh-fh, vdev);
filp-private_data = fh;
 
if (fh-type == V4L2_BUF_TYPE_VIDEO_CAPTURE  dev-users == 0) {
@@ -1031,6 +1033,7 @@ static int au0828_v4l2_open(struct file *filp)
V4L2_FIELD_SEQ_TB,
sizeof(struct au0828_buffer), fh,
dev-lock);
+   v4l2_fh_add(fh-fh);
return ret;
 }
 
@@ -1040,6 +1043,8 @@ static int au0828_v4l2_close(struct file *filp)
struct au0828_fh *fh = filp-private_data;
struct au0828_dev *dev = fh-dev;
 
+   v4l2_fh_del(fh-fh);
+   v4l2_fh_exit(fh-fh);
if (res_check(fh, AU0828_RESOURCE_VIDEO)) {
/* Cancel timeout thread in case they didn't call streamoff */
dev-vid_timeout_running = 0;
@@ -1061,6 +1066,7 @@ static int au0828_v4l2_close(struct file *filp)
if (dev-users == 1) {
if (dev-dev_state  DEV_DISCONNECTED) {
au0828_analog_unregister(dev);
+   kfree(fh);
kfree(dev);
return 0;
}
@@ -1128,23 +1134,27 @@ static unsigned int au0828_v4l2_poll(struct file *filp, 
poll_table *wait)
 {
struct au0828_fh *fh = filp-private_data;
struct au0828_dev *dev = fh-dev;
-   int rc;
+   unsigned long req_events = poll_requested_events(wait);
+   unsigned int res;
 
-   rc = check_dev(dev);
-   if (rc  0)
-   return rc;
+   if (check_dev(dev)  0)
+   return POLLERR;
+
+   res = v4l2_ctrl_poll(filp, wait);
+   if (!(req_events  (POLLIN | POLLRDNORM)))
+   return res;
 
if (fh-type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
if (!res_get(fh, AU0828_RESOURCE_VIDEO))
return POLLERR;
-   return videobuf_poll_stream(filp, fh-vb_vidq, wait);
-   } else if (fh-type == V4L2_BUF_TYPE_VBI_CAPTURE) {
+   return res | videobuf_poll_stream(filp, fh-vb_vidq, wait);
+   }
+   if (fh-type == V4L2_BUF_TYPE_VBI_CAPTURE) {
if (!res_get(fh, AU0828_RESOURCE_VBI))
return POLLERR;
-   return videobuf_poll_stream(filp, fh-vb_vbiq, wait);
-   } else {
-   return POLLERR;
+   return res | videobuf_poll_stream(filp, fh-vb_vbiq, wait);
}
+   return POLLERR;
 }
 
 static int au0828_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
@@ -1760,6 +1770,15 @@ static int vidioc_s_register(struct file *file, void 
*priv,
 }
 #endif
 
+static int vidioc_log_status(struct file *file, void *fh)
+{
+   struct video_device *vdev = video_devdata(file);
+
+   v4l2_ctrl_log_status(file, fh);
+   v4l2_device_call_all(vdev-v4l2_dev, 0, core, log_status);
+   return 0;
+}
+
 static int vidioc_reqbufs(struct file *file, void *priv,
  struct v4l2_requestbuffers *rb)
 {
@@ -1883,6 +1902,9 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_s_register  = vidioc_s_register,
 #endif
.vidioc_g_chip_ident= vidioc_g_chip_ident,
+   .vidioc_log_status  = vidioc_log_status,
+   .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+   .vidioc_unsubscribe_event   = v4l2_event_unsubscribe,
 };
 
 static const struct video_device au0828_video_template = {
@@ -1979,12 +2001,14 @@ int au0828_analog_register(struct au0828_dev *dev,
*dev-vdev = au0828_video_template;
dev-vdev-v4l2_dev = dev-v4l2_dev;
dev-vdev-lock = dev-lock;
+   set_bit(V4L2_FL_USE_FH_PRIO, dev-vdev-flags);
strcpy(dev-vdev-name, au0828a video);
 
/* Setup the VBI device */
*dev-vbi_dev = au0828_video_template;
dev-vbi_dev-v4l2_dev = dev-v4l2_dev;
dev-vbi_dev-lock = dev-lock;
+   set_bit(V4L2_FL_USE_FH_PRIO, dev-vbi_dev-flags);
strcpy(dev-vbi_dev-name, au0828a vbi);
 
/* Register the v4l2 device */
diff --git a/drivers/media/usb/au0828/au0828.h 
b/drivers/media/usb/au0828/au0828.h
index 803af10..ad40048 

[REVIEW PATCH 10/15] au8522_decoder: remove obsolete control ops.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Now that au0828 has been converted to the control framework these
compatilibity ops are no longer needed.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/dvb-frontends/au8522_decoder.c |7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/media/dvb-frontends/au8522_decoder.c 
b/drivers/media/dvb-frontends/au8522_decoder.c
index be2c802..aa7be74 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -649,13 +649,6 @@ static int au8522_g_chip_ident(struct v4l2_subdev *sd,
 
 static const struct v4l2_subdev_core_ops au8522_core_ops = {
.log_status = v4l2_ctrl_subdev_log_status,
-   .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
-   .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
-   .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
-   .g_ctrl = v4l2_subdev_g_ctrl,
-   .s_ctrl = v4l2_subdev_s_ctrl,
-   .queryctrl = v4l2_subdev_queryctrl,
-   .querymenu = v4l2_subdev_querymenu,
.g_chip_ident = au8522_g_chip_ident,
.reset = au8522_reset,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
-- 
1.7.10.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


[REVIEW PATCH 02/15] au0828: fix querycap.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/au0828/au0828-video.c |   17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 8b9e826..4254b2c 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1241,20 +1241,25 @@ static int vidioc_queryctrl(struct file *file, void 
*priv,
 static int vidioc_querycap(struct file *file, void  *priv,
   struct v4l2_capability *cap)
 {
-   struct au0828_fh *fh  = priv;
+   struct video_device *vdev = video_devdata(file);
+   struct au0828_fh *fh = priv;
struct au0828_dev *dev = fh-dev;
 
strlcpy(cap-driver, au0828, sizeof(cap-driver));
strlcpy(cap-card, dev-board.name, sizeof(cap-card));
-   strlcpy(cap-bus_info, dev-v4l2_dev.name, sizeof(cap-bus_info));
+   usb_make_path(dev-usbdev, cap-bus_info, sizeof(cap-bus_info));
 
-   /*set the device capabilities */
-   cap-capabilities = V4L2_CAP_VIDEO_CAPTURE |
-   V4L2_CAP_VBI_CAPTURE |
-   V4L2_CAP_AUDIO |
+   /* set the device capabilities */
+   cap-device_caps = V4L2_CAP_AUDIO |
V4L2_CAP_READWRITE |
V4L2_CAP_STREAMING |
V4L2_CAP_TUNER;
+   if (vdev-vfl_type == VFL_TYPE_GRABBER)
+   cap-device_caps |= V4L2_CAP_VIDEO_CAPTURE;
+   else
+   cap-device_caps |= V4L2_CAP_VBI_CAPTURE;
+   cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS |
+   V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE;
return 0;
 }
 
-- 
1.7.10.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


[REVIEW PATCH 06/15] au0828: convert to the control framework.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/au0828/au0828-core.c  |   15 ++--
 drivers/media/usb/au0828/au0828-video.c |   39 ++-
 drivers/media/usb/au0828/au0828.h   |2 ++
 3 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 1e6f40e..ffd3bcb 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -143,6 +143,7 @@ static void au0828_usb_disconnect(struct usb_interface 
*interface)
au0828_i2c_unregister(dev);
 
 #ifdef CONFIG_VIDEO_AU0828_V4L2
+   v4l2_ctrl_handler_free(dev-v4l2_ctrl_hdl);
v4l2_device_unregister(dev-v4l2_dev);
 #endif
 
@@ -205,12 +206,22 @@ static int au0828_usb_probe(struct usb_interface 
*interface,
/* Create the v4l2_device */
retval = v4l2_device_register(interface-dev, dev-v4l2_dev);
if (retval) {
-   printk(KERN_ERR %s() v4l2_device_register failed\n,
+   pr_err(%s() v4l2_device_register failed\n,
   __func__);
mutex_unlock(dev-lock);
kfree(dev);
-   return -EIO;
+   return retval;
}
+   /* This control handler will inherit the controls from au8522 */
+   retval = v4l2_ctrl_handler_init(dev-v4l2_ctrl_hdl, 4);
+   if (retval) {
+   pr_err(%s() v4l2_ctrl_handler_init failed\n,
+  __func__);
+   mutex_unlock(dev-lock);
+   kfree(dev);
+   return retval;
+   }
+   dev-v4l2_dev.ctrl_handler = dev-v4l2_ctrl_hdl;
 #endif
 
/* Power Up the bridge */
diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index e4a24fa..7d762c0 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1226,18 +1226,6 @@ static int au0828_set_format(struct au0828_dev *dev, 
unsigned int cmd,
 }
 
 
-static int vidioc_queryctrl(struct file *file, void *priv,
-   struct v4l2_queryctrl *qc)
-{
-   struct au0828_fh *fh = priv;
-   struct au0828_dev *dev = fh-dev;
-   v4l2_device_call_all(dev-v4l2_dev, 0, core, queryctrl, qc);
-   if (qc-type)
-   return 0;
-   else
-   return -EINVAL;
-}
-
 static int vidioc_querycap(struct file *file, void  *priv,
   struct v4l2_capability *cap)
 {
@@ -1495,26 +1483,6 @@ static int vidioc_s_audio(struct file *file, void *priv, 
const struct v4l2_audio
return 0;
 }
 
-static int vidioc_g_ctrl(struct file *file, void *priv,
-struct v4l2_control *ctrl)
-{
-   struct au0828_fh *fh = priv;
-   struct au0828_dev *dev = fh-dev;
-
-   v4l2_device_call_all(dev-v4l2_dev, 0, core, g_ctrl, ctrl);
-   return 0;
-
-}
-
-static int vidioc_s_ctrl(struct file *file, void *priv,
-   struct v4l2_control *ctrl)
-{
-   struct au0828_fh *fh = priv;
-   struct au0828_dev *dev = fh-dev;
-   v4l2_device_call_all(dev-v4l2_dev, 0, core, s_ctrl, ctrl);
-   return 0;
-}
-
 static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
 {
struct au0828_fh *fh = priv;
@@ -1904,9 +1872,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_enum_input  = vidioc_enum_input,
.vidioc_g_input = vidioc_g_input,
.vidioc_s_input = vidioc_s_input,
-   .vidioc_queryctrl   = vidioc_queryctrl,
-   .vidioc_g_ctrl  = vidioc_g_ctrl,
-   .vidioc_s_ctrl  = vidioc_s_ctrl,
.vidioc_streamon= vidioc_streamon,
.vidioc_streamoff   = vidioc_streamoff,
.vidioc_g_tuner = vidioc_g_tuner,
@@ -2012,13 +1977,13 @@ int au0828_analog_register(struct au0828_dev *dev,
 
/* Fill the video capture device struct */
*dev-vdev = au0828_video_template;
-   dev-vdev-parent = dev-usbdev-dev;
+   dev-vdev-v4l2_dev = dev-v4l2_dev;
dev-vdev-lock = dev-lock;
strcpy(dev-vdev-name, au0828a video);
 
/* Setup the VBI device */
*dev-vbi_dev = au0828_video_template;
-   dev-vbi_dev-parent = dev-usbdev-dev;
+   dev-vbi_dev-v4l2_dev = dev-v4l2_dev;
dev-vbi_dev-lock = dev-lock;
strcpy(dev-vbi_dev-name, au0828a vbi);
 
diff --git a/drivers/media/usb/au0828/au0828.h 
b/drivers/media/usb/au0828/au0828.h
index e579ff6..803af10 100644
--- a/drivers/media/usb/au0828/au0828.h
+++ b/drivers/media/usb/au0828/au0828.h
@@ -28,6 +28,7 @@
 #include linux/videodev2.h
 #include media/videobuf-vmalloc.h
 #include media/v4l2-device.h
+#include media/v4l2-ctrls.h
 
 /* DVB */
 #include demux.h
@@ -202,6 +203,7 @@ struct au0828_dev {
 #ifdef 

[REVIEW PATCH 13/15] au0828: don't change global state information on open().

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Just opening a device shouldn't have any side-effects.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/au0828/au0828-video.c |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index ac89b2c5..1f06d97 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1005,11 +1005,6 @@ static int au0828_v4l2_open(struct file *filp)
printk(KERN_INFO Au0828 can't set alternate to 5!\n);
return -EBUSY;
}
-   dev-width = NTSC_STD_W;
-   dev-height = NTSC_STD_H;
-   dev-frame_size = dev-width * dev-height * 2;
-   dev-field_size = dev-width * dev-height;
-   dev-bytesperline = dev-width * 2;
 
au0828_analog_stream_enable(dev);
au0828_analog_stream_reset(dev);
@@ -1031,8 +1026,6 @@ static int au0828_v4l2_open(struct file *filp)
dev-lock);
 
/* VBI Setup */
-   dev-vbi_width = 720;
-   dev-vbi_height = 1;
videobuf_queue_vmalloc_init(fh-vb_vbiq, au0828_vbi_qops,
NULL, dev-slock,
V4L2_BUF_TYPE_VBI_CAPTURE,
@@ -1983,6 +1976,8 @@ int au0828_analog_register(struct au0828_dev *dev,
dev-field_size = dev-width * dev-height;
dev-frame_size = dev-field_size  1;
dev-bytesperline = dev-width  1;
+   dev-vbi_width = 720;
+   dev-vbi_height = 1;
dev-ctrl_ainput = 0;
dev-ctrl_freq = 960;
dev-std = V4L2_STD_NTSC_M;
-- 
1.7.10.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


[REVIEW PATCH 14/15] au0828: fix initial video routing.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

After loading the module the initial video routing is not setup.
Explicitly call s_input to get this right.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/au0828/au0828-video.c |   30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 1f06d97..cc1e861 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1391,20 +1391,10 @@ static int vidioc_g_input(struct file *file, void 
*priv, unsigned int *i)
return 0;
 }
 
-static int vidioc_s_input(struct file *file, void *priv, unsigned int index)
+static void au0828_s_input(struct au0828_dev *dev, int index)
 {
-   struct au0828_fh *fh = priv;
-   struct au0828_dev *dev = fh-dev;
int i;
 
-   dprintk(1, VIDIOC_S_INPUT in function %s, input=%d\n, __func__,
-   index);
-   if (index = AU0828_MAX_INPUT)
-   return -EINVAL;
-   if (AUVI_INPUT(index).type == 0)
-   return -EINVAL;
-   dev-ctrl_input = index;
-
switch (AUVI_INPUT(index).type) {
case AU0828_VMUX_SVIDEO:
dev-input_type = AU0828_VMUX_SVIDEO;
@@ -1419,7 +1409,7 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int index)
dev-ctrl_ainput = 0;
break;
default:
-   dprintk(1, VIDIOC_S_INPUT unknown input type set [%d]\n,
+   dprintk(1, unknown input type set [%d]\n,
AUVI_INPUT(index).type);
break;
}
@@ -1450,6 +1440,21 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int index)
 
v4l2_device_call_all(dev-v4l2_dev, 0, audio, s_routing,
AUVI_INPUT(index).amux, 0, 0);
+}
+
+static int vidioc_s_input(struct file *file, void *priv, unsigned int index)
+{
+   struct au0828_fh *fh = priv;
+   struct au0828_dev *dev = fh-dev;
+
+   dprintk(1, VIDIOC_S_INPUT in function %s, input=%d\n, __func__,
+   index);
+   if (index = AU0828_MAX_INPUT)
+   return -EINVAL;
+   if (AUVI_INPUT(index).type == 0)
+   return -EINVAL;
+   dev-ctrl_input = index;
+   au0828_s_input(dev, index);
return 0;
 }
 
@@ -1981,6 +1986,7 @@ int au0828_analog_register(struct au0828_dev *dev,
dev-ctrl_ainput = 0;
dev-ctrl_freq = 960;
dev-std = V4L2_STD_NTSC_M;
+   au0828_s_input(dev, 0);
 
/* allocate and fill v4l2 video struct */
dev-vdev = video_device_alloc();
-- 
1.7.10.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


[REVIEW PATCH 11/15] au0828: fix disconnect sequence.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The driver crashed when the device was disconnected while an application
still had a device node open. Fixed by using the release() callback of struct
v4l2_device.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/au0828/au0828-core.c  |   48 ---
 drivers/media/usb/au0828/au0828-video.c |9 +-
 2 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index ffd3bcb..bd9d19a 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -125,36 +125,48 @@ static int recv_control_msg(struct au0828_dev *dev, u16 
request, u32 value,
return status;
 }
 
-static void au0828_usb_disconnect(struct usb_interface *interface)
+static void au0828_usb_release(struct au0828_dev *dev)
 {
-   struct au0828_dev *dev = usb_get_intfdata(interface);
-
-   dprintk(1, %s()\n, __func__);
-
-   /* Digital TV */
-   au0828_dvb_unregister(dev);
-
-#ifdef CONFIG_VIDEO_AU0828_V4L2
-   if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED)
-   au0828_analog_unregister(dev);
-#endif
-
/* I2C */
au0828_i2c_unregister(dev);
 
+   kfree(dev);
+}
+
 #ifdef CONFIG_VIDEO_AU0828_V4L2
+static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
+{
+   struct au0828_dev *dev =
+   container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
+
v4l2_ctrl_handler_free(dev-v4l2_ctrl_hdl);
v4l2_device_unregister(dev-v4l2_dev);
+   au0828_usb_release(dev);
+}
 #endif
 
-   usb_set_intfdata(interface, NULL);
+static void au0828_usb_disconnect(struct usb_interface *interface)
+{
+   struct au0828_dev *dev = usb_get_intfdata(interface);
+
+   dprintk(1, %s()\n, __func__);
+
+   /* Digital TV */
+   au0828_dvb_unregister(dev);
 
+   usb_set_intfdata(interface, NULL);
mutex_lock(dev-mutex);
dev-usbdev = NULL;
mutex_unlock(dev-mutex);
-
-   kfree(dev);
-
+#ifdef CONFIG_VIDEO_AU0828_V4L2
+   if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {
+   au0828_analog_unregister(dev);
+   v4l2_device_disconnect(dev-v4l2_dev);
+   v4l2_device_put(dev-v4l2_dev);
+   return;
+   }
+#endif
+   au0828_usb_release(dev);
 }
 
 static int au0828_usb_probe(struct usb_interface *interface,
@@ -203,6 +215,8 @@ static int au0828_usb_probe(struct usb_interface *interface,
dev-boardnr = id-driver_info;
 
 #ifdef CONFIG_VIDEO_AU0828_V4L2
+   dev-v4l2_dev.release = au0828_usb_v4l2_release;
+
/* Create the v4l2_device */
retval = v4l2_device_register(interface-dev, dev-v4l2_dev);
if (retval) {
diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 62308fe..a41e5ae 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1063,14 +1063,7 @@ static int au0828_v4l2_close(struct file *filp)
res_free(fh, AU0828_RESOURCE_VBI);
}
 
-   if (dev-users == 1) {
-   if (dev-dev_state  DEV_DISCONNECTED) {
-   au0828_analog_unregister(dev);
-   kfree(fh);
-   kfree(dev);
-   return 0;
-   }
-
+   if (dev-users == 1  video_is_registered(video_devdata(filp))) {
au0828_analog_stream_disable(dev);
 
au0828_uninit_isoc(dev);
-- 
1.7.10.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


[REVIEW PATCH 15/15] au0828: improve firmware loading locking.

2013-03-11 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

- open/close/read and poll need to take the core lock as well.
- when the tuner goes to sleep we should set std_set_in_tuner_core
  to 0 since the tuner loses the firmware at that time.
- initialize the tuner if std_set_in_tuner_core == 0 whenever:
  1) g/s_tuner, s_std or s_frequency is called
  2) read or poll is called
  3) streamon is called

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/au0828/au0828-video.c |   66 ---
 1 file changed, 52 insertions(+), 14 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index cc1e861..1aee330 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -998,11 +998,17 @@ static int au0828_v4l2_open(struct file *filp)
v4l2_fh_init(fh-fh, vdev);
filp-private_data = fh;
 
-   if (fh-type == V4L2_BUF_TYPE_VIDEO_CAPTURE  dev-users == 0) {
+   if (mutex_lock_interruptible(dev-lock)) {
+   kfree(fh);
+   return -ERESTARTSYS;
+   }
+   if (dev-users == 0) {
/* set au0828 interface0 to AS5 here again */
ret = usb_set_interface(dev-usbdev, 0, 5);
if (ret  0) {
+   mutex_unlock(dev-lock);
printk(KERN_INFO Au0828 can't set alternate to 5!\n);
+   kfree(fh);
return -EBUSY;
}
 
@@ -1017,6 +1023,7 @@ static int au0828_v4l2_open(struct file *filp)
}
 
dev-users++;
+   mutex_unlock(dev-lock);
 
videobuf_queue_vmalloc_init(fh-vb_vidq, au0828_video_qops,
NULL, dev-slock,
@@ -1044,6 +1051,7 @@ static int au0828_v4l2_close(struct file *filp)
 
v4l2_fh_del(fh-fh);
v4l2_fh_exit(fh-fh);
+   mutex_lock(dev-lock);
if (res_check(fh, AU0828_RESOURCE_VIDEO)) {
/* Cancel timeout thread in case they didn't call streamoff */
dev-vid_timeout_running = 0;
@@ -1069,6 +1077,7 @@ static int au0828_v4l2_close(struct file *filp)
 
/* Save some power by putting tuner to sleep */
v4l2_device_call_all(dev-v4l2_dev, 0, core, s_power, 0);
+   dev-std_set_in_tuner_core = 0;
 
/* When close the device, set the usb intf0 into alt0 to free
   USB bandwidth */
@@ -1076,6 +1085,7 @@ static int au0828_v4l2_close(struct file *filp)
if (ret  0)
printk(KERN_INFO Au0828 can't set alternate to 0!\n);
}
+   mutex_unlock(dev-lock);
 
videobuf_mmap_free(fh-vb_vidq);
videobuf_mmap_free(fh-vb_vbiq);
@@ -1085,6 +1095,26 @@ static int au0828_v4l2_close(struct file *filp)
return 0;
 }
 
+/* Must be called with dev-lock held */
+static void au0828_init_tuner(struct au0828_dev *dev)
+{
+   struct v4l2_frequency f = {
+   .frequency = dev-ctrl_freq,
+   .type = V4L2_TUNER_ANALOG_TV,
+   };
+
+   if (dev-std_set_in_tuner_core)
+   return;
+   dev-std_set_in_tuner_core = 1;
+   i2c_gate_ctrl(dev, 1);
+   /* If we've never sent the standard in tuner core, do so now.
+  We don't do this at device probe because we don't want to
+  incur the cost of a firmware load */
+   v4l2_device_call_all(dev-v4l2_dev, 0, core, s_std, dev-std);
+   v4l2_device_call_all(dev-v4l2_dev, 0, tuner, s_frequency, f);
+   i2c_gate_ctrl(dev, 0);
+}
+
 static ssize_t au0828_v4l2_read(struct file *filp, char __user *buf,
size_t count, loff_t *pos)
 {
@@ -1096,6 +1126,11 @@ static ssize_t au0828_v4l2_read(struct file *filp, char 
__user *buf,
if (rc  0)
return rc;
 
+   if (mutex_lock_interruptible(dev-lock))
+   return -ERESTARTSYS;
+   au0828_init_tuner(dev);
+   mutex_unlock(dev-lock);
+
if (fh-type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
if (res_locked(dev, AU0828_RESOURCE_VIDEO))
return -EBUSY;
@@ -1136,6 +1171,11 @@ static unsigned int au0828_v4l2_poll(struct file *filp, 
poll_table *wait)
if (!(req_events  (POLLIN | POLLRDNORM)))
return res;
 
+   if (mutex_lock_interruptible(dev-lock))
+   return -ERESTARTSYS;
+   au0828_init_tuner(dev);
+   mutex_unlock(dev-lock);
+
if (fh-type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
if (!res_get(fh, AU0828_RESOURCE_VIDEO))
return POLLERR;
@@ -1319,6 +1359,10 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id *norm)
struct au0828_fh *fh = priv;
struct au0828_dev *dev = fh-dev;
 
+   dev-std = *norm;
+
+   au0828_init_tuner(dev);
+
i2c_gate_ctrl(dev, 1);
 
/* FIXME: when we support something other 

  1   2   >