cron job: media_tree daily build: WARNINGS

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

Results of the daily build of media_tree:

date:   Tue Mar 11 04:00:26 CET 2014
git branch: test
git hash:   f2d7313534072a5fe192e7cf46204b413acef479
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: 0.4.5-rc1
host hardware:  x86_64
host os:3.13-5.slh.4-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: WARNINGS
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.14-i686: WARNINGS
linux-2.6.32.27-i686: WARNINGS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12-i686: OK
linux-3.13-i686: OK
linux-3.14-rc1-i686: OK
linux-2.6.31.14-x86_64: WARNINGS
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12-x86_64: OK
linux-3.13-x86_64: OK
linux-3.14-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse version: 0.4.5-rc1
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: dvb-apps build failure

2014-03-10 Thread Jonathan McCrohan
Hi Oliver,

On Thu, 06 Feb 2014 09:25:14 +0100, Quentin Glidic wrote:
> Hello,
>
> When building dvb-apps from the Mercurial repository, you hit the 
> following error:
> install: cannot stat 'atsc/*': No such file or directory
>
> In the latest changeset 
> (http://linuxtv.org/hg/dvb-apps/rev/d40083fff895) scan files were 
> deleted from the repository but not their install rule.
>
> Could someone please remove the bottom part of util/scan/Makefile (from 
> line 31, 
> http://linuxtv.org/hg/dvb-apps/file/d40083fff895/util/scan/Makefile#l31) 
> to fix this issue?

Ping on Quentin's behalf. I'd like to upload a new version of dvb-apps
to Debian, but the build is currently broken after your recent patch.

Would you be able to take a look?

Thanks,
Jon


pgpL2AIeH5kLF.pgp
Description: PGP signature


Re: [REVIEW PATCH 1/3] v4l2-subdev.h: add g_tvnorms video op

2014-03-10 Thread Hans Verkuil
On 03/11/2014 12:23 AM, Guennadi Liakhovetski wrote:
> Hi Hans,
> 
> Thanks for taking care about this problem. I'm not sure it would be ok for 
> me to pull this specific patch via my tree, because it's for the V4L2 
> core, and the other 2 patches in this series depend on this one.

It's OK by me to pull this through your tree.

> But 
> anyway I've got a question to this patch:
> 
> On Mon, 17 Feb 2014, Hans Verkuil wrote:
> 
>> From: Hans Verkuil 
>>
>> While there was already a g_tvnorms_output video op, it's counterpart for
>> video capture was missing. Add it.
>>
>> This is necessary for generic bridge drivers like soc-camera to set the
>> video_device tvnorms field correctly. Otherwise ENUMSTD cannot work.
>>
>> Signed-off-by: Hans Verkuil 
>> ---
>>  include/media/v4l2-subdev.h | 8 ++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>> index d67210a..787d078 100644
>> --- a/include/media/v4l2-subdev.h
>> +++ b/include/media/v4l2-subdev.h
>> @@ -264,8 +264,11 @@ struct v4l2_mbus_frame_desc {
>> g_std_output: get current standard for video OUTPUT devices. This is 
>> ignored
>>  by video input devices.
>>  
>> -   g_tvnorms_output: get v4l2_std_id with all standards supported by video
>> -OUTPUT device. This is ignored by video input devices.
>> +   g_tvnorms: get v4l2_std_id with all standards supported by the video
>> +CAPTURE device. This is ignored by video output devices.
>> +
>> +   g_tvnorms_output: get v4l2_std_id with all standards supported by the 
>> video
>> +OUTPUT device. This is ignored by video capture devices.
> 
> Why do we need two separate operations with the same functionality - one 
> for capture and one for output? Can we have subdevices, that need to 
> implement both? Besides, what about these two core ops:
> 
>   int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm);
>   int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
> 
> ? Seems like a slightly different approach is needed? Or am I missing 
> anything?

There are drivers (ivtv) that have both capture and output subdevices. Each can
have its own standard. Such drivers use v4l2_device_call_all() to call the
same op for all subdevs so any subdev that can handle that op gets called.
So they use it to call the s_std op to change the capture standard and they
call s_std_output to change the output standard.

If you can't tell the difference between capture tvnorms and output tvnorms this
becomes tricky to handle. Just keep the two separate and there is no confusion.

Note that the video ops have the g/s_std_output ops. It's due to historical
reasons that g/s_std ended up in the core ops. They probably should be moved to
the video ops, but it's just not worth the effort.

Regards,

Hans

> 
> Thanks
> Guennadi
> 
>> s_crystal_freq: sets the frequency of the crystal used to generate the
>>  clocks in Hz. An extra flags field allows device specific configuration
>> @@ -308,6 +311,7 @@ struct v4l2_subdev_video_ops {
>>  int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
>>  int (*g_std_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
>>  int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
>> +int (*g_tvnorms)(struct v4l2_subdev *sd, v4l2_std_id *std);
>>  int (*g_tvnorms_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
>>  int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
>>  int (*s_stream)(struct v4l2_subdev *sd, int enable);
>> -- 
>> 1.8.5.2
>>
> 
> ---
> 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
> 

--
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 1/3] v4l2-subdev.h: add g_tvnorms video op

2014-03-10 Thread Guennadi Liakhovetski
Hi Hans,

Thanks for taking care about this problem. I'm not sure it would be ok for 
me to pull this specific patch via my tree, because it's for the V4L2 
core, and the other 2 patches in this series depend on this one. But 
anyway I've got a question to this patch:

On Mon, 17 Feb 2014, Hans Verkuil wrote:

> From: Hans Verkuil 
> 
> While there was already a g_tvnorms_output video op, it's counterpart for
> video capture was missing. Add it.
> 
> This is necessary for generic bridge drivers like soc-camera to set the
> video_device tvnorms field correctly. Otherwise ENUMSTD cannot work.
> 
> Signed-off-by: Hans Verkuil 
> ---
>  include/media/v4l2-subdev.h | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index d67210a..787d078 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -264,8 +264,11 @@ struct v4l2_mbus_frame_desc {
> g_std_output: get current standard for video OUTPUT devices. This is 
> ignored
>   by video input devices.
>  
> -   g_tvnorms_output: get v4l2_std_id with all standards supported by video
> - OUTPUT device. This is ignored by video input devices.
> +   g_tvnorms: get v4l2_std_id with all standards supported by the video
> + CAPTURE device. This is ignored by video output devices.
> +
> +   g_tvnorms_output: get v4l2_std_id with all standards supported by the 
> video
> + OUTPUT device. This is ignored by video capture devices.

Why do we need two separate operations with the same functionality - one 
for capture and one for output? Can we have subdevices, that need to 
implement both? Besides, what about these two core ops:

int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm);
int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);

? Seems like a slightly different approach is needed? Or am I missing 
anything?

Thanks
Guennadi

> s_crystal_freq: sets the frequency of the crystal used to generate the
>   clocks in Hz. An extra flags field allows device specific configuration
> @@ -308,6 +311,7 @@ struct v4l2_subdev_video_ops {
>   int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
>   int (*g_std_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
>   int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
> + int (*g_tvnorms)(struct v4l2_subdev *sd, v4l2_std_id *std);
>   int (*g_tvnorms_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
>   int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
>   int (*s_stream)(struct v4l2_subdev *sd, int enable);
> -- 
> 1.8.5.2
> 

---
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 v2 14/48] media: bfin_capture: Switch to pad-level DV operations

2014-03-10 Thread Laurent Pinchart
The video-level enum_dv_timings and dv_timings_cap operations are
deprecated in favor of the pad-level versions. All subdev drivers
implement the pad-level versions, switch to them.

Cc: Scott Jiang 
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/platform/blackfin/bfin_capture.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/blackfin/bfin_capture.c 
b/drivers/media/platform/blackfin/bfin_capture.c
index 200bec9..22fb701 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -648,7 +648,9 @@ static int bcap_enum_dv_timings(struct file *file, void 
*priv,
 {
struct bcap_device *bcap_dev = video_drvdata(file);
 
-   return v4l2_subdev_call(bcap_dev->sd, video,
+   timings->pad = 0;
+
+   return v4l2_subdev_call(bcap_dev->sd, pad,
enum_dv_timings, timings);
 }
 
-- 
1.8.3.2

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


[PATCH v2 18/48] ad9389b: Remove deprecated video-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated
and unused. Remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/ad9389b.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 44c037d..4cdff9e 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -670,8 +670,6 @@ static const struct v4l2_subdev_video_ops ad9389b_video_ops 
= {
.s_stream = ad9389b_s_stream,
.s_dv_timings = ad9389b_s_dv_timings,
.g_dv_timings = ad9389b_g_dv_timings,
-   .enum_dv_timings = ad9389b_enum_dv_timings,
-   .dv_timings_cap = ad9389b_dv_timings_cap,
 };
 
 /* -- PAD OPS -- */
-- 
1.8.3.2

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


[PATCH v2 02/48] v4l: Add UYVY10_2X10 and VYUY10_2X10 media bus pixel codes

2014-03-10 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 128 +
 include/uapi/linux/v4l2-mediabus.h |   4 +-
 2 files changed, 131 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index 7331ce1..6fb58de 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -1898,6 +1898,134 @@
  y1
  y0

+   
+ V4L2_MBUS_FMT_UYVY10_2X10
+ 0x2018
+ 
+ &dash-ent-22;
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+   
+   
+ 
+ 
+ 
+ &dash-ent-22;
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-22;
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+   
+   
+ 
+ 
+ 
+ &dash-ent-22;
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ V4L2_MBUS_FMT_VYUY10_2X10
+ 0x2019
+ 
+ &dash-ent-22;
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+   
+   
+ 
+ 
+ 
+ &dash-ent-22;
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-22;
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+   
+   
+ 
+ 
+ 
+ &dash-ent-22;
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   

  V4L2_MBUS_FMT_YUYV10_2X10
  0x200b
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index b5c3aab..20a99b1 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -52,7 +52,7 @@ enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_RGB888_2X12_LE = 0x100c,
V4L2_MBUS_FMT_ARGB_1X32 = 0x100d,
 
-   /* YUV (including grey) - next is 0x2018 */
+   /* YUV (including grey) - next is 0x201a */
V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
V4L2_MBUS_FMT_UV8_1X8 = 0x2015,
V4L2_MBUS_FMT_UYVY8_1_5X8 = 0x2002,
@@ -64,6 +64,8 @@ enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_YUYV8_2X8 = 0x2008,
V4L2_MBUS_FMT_YVYU8_2X8 = 0x2009,
V4L2_MBUS_FMT_Y10_1X10 = 0x200a,
+   V4L2_MBUS_FMT_UYVY10_2X10 = 0x2018,
+   V4L2_MBUS_FMT_VYUY10_2X10 = 0x2019,
V4L2_MBUS_FMT_YUYV10_2X10 = 0x200b,
V4L2_MBUS_FMT_YVYU10_2X10 = 0x200c,
V4L2_MBUS_FMT_Y12_1X12 = 0x2013,
-- 
1.8.3.2

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


[PATCH v2 19/48] adv7511: Remove deprecated video-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated
and unused. Remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/adv7511.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index f8c75c6..de7ddf5 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -692,8 +692,6 @@ static const struct v4l2_subdev_video_ops adv7511_video_ops 
= {
.s_stream = adv7511_s_stream,
.s_dv_timings = adv7511_s_dv_timings,
.g_dv_timings = adv7511_g_dv_timings,
-   .enum_dv_timings = adv7511_enum_dv_timings,
-   .dv_timings_cap = adv7511_dv_timings_cap,
 };
 
 /* -- AUDIO OPS -- */
-- 
1.8.3.2

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


[PATCH v2 08/48] adv7511: Add pad-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated.
Implement the pad-level version of those operations to prepare for the
removal of the video version.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/adv7511.c | 67 ++---
 1 file changed, 39 insertions(+), 28 deletions(-)

diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index ee61894..f8c75c6 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -597,34 +597,6 @@ static int adv7511_isr(struct v4l2_subdev *sd, u32 status, 
bool *handled)
return 0;
 }
 
-static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid 
*edid)
-{
-   struct adv7511_state *state = get_adv7511_state(sd);
-
-   if (edid->pad != 0)
-   return -EINVAL;
-   if ((edid->blocks == 0) || (edid->blocks > 256))
-   return -EINVAL;
-   if (!edid->edid)
-   return -EINVAL;
-   if (!state->edid.segments) {
-   v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
-   return -ENODATA;
-   }
-   if (edid->start_block >= state->edid.segments * 2)
-   return -E2BIG;
-   if ((edid->blocks + edid->start_block) >= state->edid.segments * 2)
-   edid->blocks = state->edid.segments * 2 - edid->start_block;
-
-   memcpy(edid->edid, &state->edid.data[edid->start_block * 128],
-   128 * edid->blocks);
-   return 0;
-}
-
-static const struct v4l2_subdev_pad_ops adv7511_pad_ops = {
-   .get_edid = adv7511_get_edid,
-};
-
 static const struct v4l2_subdev_core_ops adv7511_core_ops = {
.log_status = adv7511_log_status,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -700,12 +672,18 @@ static int adv7511_g_dv_timings(struct v4l2_subdev *sd,
 static int adv7511_enum_dv_timings(struct v4l2_subdev *sd,
   struct v4l2_enum_dv_timings *timings)
 {
+   if (timings->pad != 0)
+   return -EINVAL;
+
return v4l2_enum_dv_timings_cap(timings, &adv7511_timings_cap, NULL, 
NULL);
 }
 
 static int adv7511_dv_timings_cap(struct v4l2_subdev *sd,
  struct v4l2_dv_timings_cap *cap)
 {
+   if (cap->pad != 0)
+   return -EINVAL;
+
*cap = adv7511_timings_cap;
return 0;
 }
@@ -797,6 +775,39 @@ static const struct v4l2_subdev_audio_ops 
adv7511_audio_ops = {
.s_routing = adv7511_s_routing,
 };
 
+/*  PAD OPS - 
*/
+
+static int adv7511_get_edid(struct v4l2_subdev *sd,
+   struct v4l2_subdev_edid *edid)
+{
+   struct adv7511_state *state = get_adv7511_state(sd);
+
+   if (edid->pad != 0)
+   return -EINVAL;
+   if ((edid->blocks == 0) || (edid->blocks > 256))
+   return -EINVAL;
+   if (!edid->edid)
+   return -EINVAL;
+   if (!state->edid.segments) {
+   v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
+   return -ENODATA;
+   }
+   if (edid->start_block >= state->edid.segments * 2)
+   return -E2BIG;
+   if ((edid->blocks + edid->start_block) >= state->edid.segments * 2)
+   edid->blocks = state->edid.segments * 2 - edid->start_block;
+
+   memcpy(edid->edid, &state->edid.data[edid->start_block * 128],
+   128 * edid->blocks);
+   return 0;
+}
+
+static const struct v4l2_subdev_pad_ops adv7511_pad_ops = {
+   .get_edid = adv7511_get_edid,
+   .enum_dv_timings = adv7511_enum_dv_timings,
+   .dv_timings_cap = adv7511_dv_timings_cap,
+};
+
 /* - SUBDEV OPS --- */
 
 static const struct v4l2_subdev_ops adv7511_ops = {
-- 
1.8.3.2

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


[PATCH v2 15/48] media: davinci: vpif: Switch to pad-level DV operations

2014-03-10 Thread Laurent Pinchart
The video-level enum_dv_timings and dv_timings_cap operations are
deprecated in favor of the pad-level versions. All subdev drivers
implement the pad-level versions, switch to them.

Cc: Prabhakar Lad 
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/platform/davinci/vpif_capture.c | 4 +++-
 drivers/media/platform/davinci/vpif_display.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index cd6da8b..16a1958 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1723,7 +1723,9 @@ vpif_enum_dv_timings(struct file *file, void *priv,
struct channel_obj *ch = fh->channel;
int ret;
 
-   ret = v4l2_subdev_call(ch->sd, video, enum_dv_timings, timings);
+   timings->pad = 0;
+
+   ret = v4l2_subdev_call(ch->sd, pad, enum_dv_timings, timings);
if (ret == -ENOIOCTLCMD || ret == -ENODEV)
return -EINVAL;
return ret;
diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index fd68236..e1edefe 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1380,7 +1380,9 @@ vpif_enum_dv_timings(struct file *file, void *priv,
struct channel_obj *ch = fh->channel;
int ret;
 
-   ret = v4l2_subdev_call(ch->sd, video, enum_dv_timings, timings);
+   timings->pad = 0;
+
+   ret = v4l2_subdev_call(ch->sd, pad, enum_dv_timings, timings);
if (ret == -ENOIOCTLCMD || ret == -ENODEV)
return -EINVAL;
return ret;
-- 
1.8.3.2

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


[PATCH v2 07/48] ad9389b: Add pad-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated.
Implement the pad-level version of those operations to prepare for the
removal of the video version.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/ad9389b.c | 69 ++---
 1 file changed, 40 insertions(+), 29 deletions(-)

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 83225d6..44c037d 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -571,35 +571,6 @@ static const struct v4l2_subdev_core_ops ad9389b_core_ops 
= {
.interrupt_service_routine = ad9389b_isr,
 };
 
-/* -- PAD OPS -- */
-
-static int ad9389b_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid 
*edid)
-{
-   struct ad9389b_state *state = get_ad9389b_state(sd);
-
-   if (edid->pad != 0)
-   return -EINVAL;
-   if (edid->blocks == 0 || edid->blocks > 256)
-   return -EINVAL;
-   if (!edid->edid)
-   return -EINVAL;
-   if (!state->edid.segments) {
-   v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
-   return -ENODATA;
-   }
-   if (edid->start_block >= state->edid.segments * 2)
-   return -E2BIG;
-   if (edid->blocks + edid->start_block >= state->edid.segments * 2)
-   edid->blocks = state->edid.segments * 2 - edid->start_block;
-   memcpy(edid->edid, &state->edid.data[edid->start_block * 128],
-  128 * edid->blocks);
-   return 0;
-}
-
-static const struct v4l2_subdev_pad_ops ad9389b_pad_ops = {
-   .get_edid = ad9389b_get_edid,
-};
-
 /* -- VIDEO OPS -- */
 
 /* Enable/disable ad9389b output */
@@ -678,6 +649,9 @@ static int ad9389b_g_dv_timings(struct v4l2_subdev *sd,
 static int ad9389b_enum_dv_timings(struct v4l2_subdev *sd,
   struct v4l2_enum_dv_timings *timings)
 {
+   if (timings->pad != 0)
+   return -EINVAL;
+
return v4l2_enum_dv_timings_cap(timings, &ad9389b_timings_cap,
NULL, NULL);
 }
@@ -685,6 +659,9 @@ static int ad9389b_enum_dv_timings(struct v4l2_subdev *sd,
 static int ad9389b_dv_timings_cap(struct v4l2_subdev *sd,
  struct v4l2_dv_timings_cap *cap)
 {
+   if (cap->pad != 0)
+   return -EINVAL;
+
*cap = ad9389b_timings_cap;
return 0;
 }
@@ -697,6 +674,40 @@ static const struct v4l2_subdev_video_ops 
ad9389b_video_ops = {
.dv_timings_cap = ad9389b_dv_timings_cap,
 };
 
+/* -- PAD OPS -- */
+
+static int ad9389b_get_edid(struct v4l2_subdev *sd,
+   struct v4l2_subdev_edid *edid)
+{
+   struct ad9389b_state *state = get_ad9389b_state(sd);
+
+   if (edid->pad != 0)
+   return -EINVAL;
+   if (edid->blocks == 0 || edid->blocks > 256)
+   return -EINVAL;
+   if (!edid->edid)
+   return -EINVAL;
+   if (!state->edid.segments) {
+   v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
+   return -ENODATA;
+   }
+   if (edid->start_block >= state->edid.segments * 2)
+   return -E2BIG;
+   if (edid->blocks + edid->start_block >= state->edid.segments * 2)
+   edid->blocks = state->edid.segments * 2 - edid->start_block;
+   memcpy(edid->edid, &state->edid.data[edid->start_block * 128],
+  128 * edid->blocks);
+   return 0;
+}
+
+static const struct v4l2_subdev_pad_ops ad9389b_pad_ops = {
+   .get_edid = ad9389b_get_edid,
+   .enum_dv_timings = ad9389b_enum_dv_timings,
+   .dv_timings_cap = ad9389b_dv_timings_cap,
+};
+
+/* -- AUDIO OPS -- */
+
 static int ad9389b_s_audio_stream(struct v4l2_subdev *sd, int enable)
 {
v4l2_dbg(1, debug, sd, "%s: %sable\n", __func__, (enable ? "en" : 
"dis"));
-- 
1.8.3.2

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


[PATCH v2 17/48] s5p-tv: mixer: Switch to pad-level DV operations

2014-03-10 Thread Laurent Pinchart
The video-level enum_dv_timings and dv_timings_cap operations are
deprecated in favor of the pad-level versions. All subdev drivers
implement the pad-level versions, switch to them.

Cc: Kyungmin Park 
Cc: Tomasz Stanislawski 
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/platform/s5p-tv/mixer_video.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/mixer_video.c 
b/drivers/media/platform/s5p-tv/mixer_video.c
index c5059ba..0d6b928 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -509,9 +509,11 @@ static int mxr_enum_dv_timings(struct file *file, void *fh,
struct mxr_device *mdev = layer->mdev;
int ret;
 
+   timings->pad = 0;
+
/* lock protects from changing sd_out */
mutex_lock(&mdev->mutex);
-   ret = v4l2_subdev_call(to_outsd(mdev), video, enum_dv_timings, timings);
+   ret = v4l2_subdev_call(to_outsd(mdev), pad, enum_dv_timings, timings);
mutex_unlock(&mdev->mutex);
 
return ret ? -EINVAL : 0;
@@ -567,9 +569,11 @@ static int mxr_dv_timings_cap(struct file *file, void *fh,
struct mxr_device *mdev = layer->mdev;
int ret;
 
+   cap->pad = 0;
+
/* lock protects from changing sd_out */
mutex_lock(&mdev->mutex);
-   ret = v4l2_subdev_call(to_outsd(mdev), video, dv_timings_cap, cap);
+   ret = v4l2_subdev_call(to_outsd(mdev), pad, dv_timings_cap, cap);
mutex_unlock(&mdev->mutex);
 
return ret ? -EINVAL : 0;
-- 
1.8.3.2

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


[PATCH v2 20/48] adv7842: Remove deprecated video-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated
and unused. Remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/adv7842.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 78d21fd..7fd9325 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2892,8 +2892,6 @@ static const struct v4l2_subdev_video_ops 
adv7842_video_ops = {
.s_dv_timings = adv7842_s_dv_timings,
.g_dv_timings = adv7842_g_dv_timings,
.query_dv_timings = adv7842_query_dv_timings,
-   .enum_dv_timings = adv7842_enum_dv_timings,
-   .dv_timings_cap = adv7842_dv_timings_cap,
.enum_mbus_fmt = adv7842_enum_mbus_fmt,
.g_mbus_fmt = adv7842_g_mbus_fmt,
.try_mbus_fmt = adv7842_g_mbus_fmt,
-- 
1.8.3.2

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


[PATCH v2 09/48] adv7842: Add pad-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated.
Implement the pad-level version of those operations to prepare for the
removal of the video version.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/adv7842.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index e04fe3f..78d21fd 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -1399,6 +1399,9 @@ static int read_stdi(struct v4l2_subdev *sd, struct 
stdi_readback *stdi)
 static int adv7842_enum_dv_timings(struct v4l2_subdev *sd,
   struct v4l2_enum_dv_timings *timings)
 {
+   if (timings->pad != 0)
+   return -EINVAL;
+
return v4l2_enum_dv_timings_cap(timings,
adv7842_get_dv_timings_cap(sd), adv7842_check_dv_timings, NULL);
 }
@@ -1406,6 +1409,9 @@ static int adv7842_enum_dv_timings(struct v4l2_subdev *sd,
 static int adv7842_dv_timings_cap(struct v4l2_subdev *sd,
  struct v4l2_dv_timings_cap *cap)
 {
+   if (cap->pad != 0)
+   return -EINVAL;
+
*cap = *adv7842_get_dv_timings_cap(sd);
return 0;
 }
@@ -2897,6 +2903,8 @@ static const struct v4l2_subdev_video_ops 
adv7842_video_ops = {
 static const struct v4l2_subdev_pad_ops adv7842_pad_ops = {
.get_edid = adv7842_get_edid,
.set_edid = adv7842_set_edid,
+   .enum_dv_timings = adv7842_enum_dv_timings,
+   .dv_timings_cap = adv7842_dv_timings_cap,
 };
 
 static const struct v4l2_subdev_ops adv7842_ops = {
-- 
1.8.3.2

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


[PATCH v2 11/48] s5p-tv: hdmiphy: Add pad-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings operation is deprecated. Implement the
pad-level version of the operation to prepare for the removal of the
video version.

Cc: Kyungmin Park 
Cc: Tomasz Stanislawski 
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/platform/s5p-tv/hdmiphy_drv.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/platform/s5p-tv/hdmiphy_drv.c 
b/drivers/media/platform/s5p-tv/hdmiphy_drv.c
index e19a0af..ff22320 100644
--- a/drivers/media/platform/s5p-tv/hdmiphy_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmiphy_drv.c
@@ -225,6 +225,9 @@ static int hdmiphy_s_dv_timings(struct v4l2_subdev *sd,
 static int hdmiphy_dv_timings_cap(struct v4l2_subdev *sd,
struct v4l2_dv_timings_cap *cap)
 {
+   if (cap->pad != 0)
+   return -EINVAL;
+
cap->type = V4L2_DV_BT_656_1120;
/* The phy only determines the pixelclock, leave the other values
 * at 0 to signify that we have no information for them. */
@@ -263,9 +266,14 @@ static const struct v4l2_subdev_video_ops 
hdmiphy_video_ops = {
.s_stream =  hdmiphy_s_stream,
 };
 
+static const struct v4l2_subdev_pad_ops hdmiphy_pad_ops = {
+   .dv_timings_cap = hdmiphy_dv_timings_cap,
+};
+
 static const struct v4l2_subdev_ops hdmiphy_ops = {
.core = &hdmiphy_core_ops,
.video = &hdmiphy_video_ops,
+   .pad = &hdmiphy_pad_ops,
 };
 
 static int hdmiphy_probe(struct i2c_client *client,
-- 
1.8.3.2

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


[PATCH v2 24/48] tvp7002: Remove deprecated video-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated
and unused. Remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/tvp7002.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 9f56fd5..fa901a9 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -926,7 +926,6 @@ static const struct v4l2_subdev_core_ops tvp7002_core_ops = 
{
 static const struct v4l2_subdev_video_ops tvp7002_video_ops = {
.g_dv_timings = tvp7002_g_dv_timings,
.s_dv_timings = tvp7002_s_dv_timings,
-   .enum_dv_timings = tvp7002_enum_dv_timings,
.query_dv_timings = tvp7002_query_dv_timings,
.s_stream = tvp7002_s_stream,
.g_mbus_fmt = tvp7002_mbus_fmt,
-- 
1.8.3.2

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


[PATCH v2 28/48] adv7604: Add missing include to linux/types.h

2014-03-10 Thread Laurent Pinchart
From: Lars-Peter Clausen 

The file is using u8 which is defined in linux/types.h.

Signed-off-by: Lars-Peter Clausen 
Signed-off-by: Laurent Pinchart 
---
 include/media/adv7604.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/media/adv7604.h b/include/media/adv7604.h
index d262a3a..c6b3937 100644
--- a/include/media/adv7604.h
+++ b/include/media/adv7604.h
@@ -21,6 +21,8 @@
 #ifndef _ADV7604_
 #define _ADV7604_
 
+#include 
+
 /* Analog input muxing modes (AFE register 0x02, [2:0]) */
 enum adv7604_ain_sel {
ADV7604_AIN1_2_3_NC_SYNC_1_2 = 0,
-- 
1.8.3.2

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


[PATCH v2 12/48] ths8200: Add pad-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated.
Implement the pad-level version of those operations to prepare for the
removal of the video version.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/ths8200.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c
index f72561e..c4ec8b2 100644
--- a/drivers/media/i2c/ths8200.c
+++ b/drivers/media/i2c/ths8200.c
@@ -410,6 +410,9 @@ static int ths8200_g_dv_timings(struct v4l2_subdev *sd,
 static int ths8200_enum_dv_timings(struct v4l2_subdev *sd,
   struct v4l2_enum_dv_timings *timings)
 {
+   if (timings->pad != 0)
+   return -EINVAL;
+
return v4l2_enum_dv_timings_cap(timings, &ths8200_timings_cap,
NULL, NULL);
 }
@@ -417,6 +420,9 @@ static int ths8200_enum_dv_timings(struct v4l2_subdev *sd,
 static int ths8200_dv_timings_cap(struct v4l2_subdev *sd,
  struct v4l2_dv_timings_cap *cap)
 {
+   if (cap->pad != 0)
+   return -EINVAL;
+
*cap = ths8200_timings_cap;
return 0;
 }
@@ -430,10 +436,16 @@ static const struct v4l2_subdev_video_ops 
ths8200_video_ops = {
.dv_timings_cap = ths8200_dv_timings_cap,
 };
 
+static const struct v4l2_subdev_pad_ops ths8200_pad_ops = {
+   .enum_dv_timings = ths8200_enum_dv_timings,
+   .dv_timings_cap = ths8200_dv_timings_cap,
+};
+
 /* V4L2 top level operation handlers */
 static const struct v4l2_subdev_ops ths8200_ops = {
.core  = &ths8200_core_ops,
.video = &ths8200_video_ops,
+   .pad = &ths8200_pad_ops,
 };
 
 static int ths8200_probe(struct i2c_client *client,
-- 
1.8.3.2

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


[PATCH v2 06/48] v4l: Add pad-level DV timings subdev operations

2014-03-10 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 
---
 include/media/v4l2-subdev.h|  4 
 include/uapi/linux/videodev2.h | 10 --
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 1752530..2b5ec32 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -509,6 +509,10 @@ struct v4l2_subdev_pad_ops {
 struct v4l2_subdev_selection *sel);
int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid);
int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid);
+   int (*dv_timings_cap)(struct v4l2_subdev *sd,
+ struct v4l2_dv_timings_cap *cap);
+   int (*enum_dv_timings)(struct v4l2_subdev *sd,
+  struct v4l2_enum_dv_timings *timings);
 #ifdef CONFIG_MEDIA_CONTROLLER
int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link,
 struct v4l2_subdev_format *source_fmt,
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 17acba8..72fbbd4 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1103,12 +1103,15 @@ struct v4l2_dv_timings {
 
 /** struct v4l2_enum_dv_timings - DV timings enumeration
  * @index: enumeration index
+ * @pad:   the pad number for which to enumerate timings (used with
+ * v4l-subdev nodes only)
  * @reserved:  must be zeroed
  * @timings:   the timings for the given index
  */
 struct v4l2_enum_dv_timings {
__u32 index;
-   __u32 reserved[3];
+   __u32 pad;
+   __u32 reserved[2];
struct v4l2_dv_timings timings;
 };
 
@@ -1146,11 +1149,14 @@ struct v4l2_bt_timings_cap {
 
 /** struct v4l2_dv_timings_cap - DV timings capabilities
  * @type:  the type of the timings (same as in struct v4l2_dv_timings)
+ * @pad:   the pad number for which to query capabilities (used with
+ * v4l-subdev nodes only)
  * @bt:the BT656/1120 timings capabilities
  */
 struct v4l2_dv_timings_cap {
__u32 type;
-   __u32 reserved[3];
+   __u32 pad;
+   __u32 reserved[2];
union {
struct v4l2_bt_timings_cap bt;
__u32 raw_data[32];
-- 
1.8.3.2

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


[PATCH v2 04/48] v4l: Add 12-bit YUV 4:2:0 media bus pixel codes

2014-03-10 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 288 +
 include/uapi/linux/v4l2-mediabus.h |   6 +-
 2 files changed, 293 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index e3cbbb4..a0fa7e0 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -2718,6 +2718,294 @@
  v1
  v0

+   
+ V4L2_MBUS_FMT_UYVY12_2X12
+ 0x201c
+ 
+ &dash-ent-20;
+ u11
+ u10
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ v11
+ v10
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ V4L2_MBUS_FMT_VYUY12_2X12
+ 0x201d
+ 
+ &dash-ent-20;
+ v11
+ v10
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ u11
+ u10
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ V4L2_MBUS_FMT_YUYV12_2X12
+ 0x201e
+ 
+ &dash-ent-20;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ u11
+ u10
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ v11
+ v10
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+   
+   
+ V4L2_MBUS_FMT_YVYU12_2X12
+ 0x201f
+ 
+ &dash-ent-20;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-20;
+ v11
+ v10
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+   
+   
+ 

[PATCH v2 21/48] s5p-tv: hdmi: Remove deprecated video-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated
and unused. Remove them.

Cc: Kyungmin Park 
Cc: Tomasz Stanislawski 
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/platform/s5p-tv/hdmi_drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c 
b/drivers/media/platform/s5p-tv/hdmi_drv.c
index 3db496c..754740f 100644
--- a/drivers/media/platform/s5p-tv/hdmi_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmi_drv.c
@@ -693,7 +693,7 @@ static int hdmi_dv_timings_cap(struct v4l2_subdev *sd,
return -EINVAL;
 
/* Let the phy fill in the pixelclock range */
-   v4l2_subdev_call(hdev->phy_sd, video, dv_timings_cap, cap);
+   v4l2_subdev_call(hdev->phy_sd, pad, dv_timings_cap, cap);
cap->type = V4L2_DV_BT_656_1120;
cap->bt.min_width = 720;
cap->bt.max_width = 1920;
@@ -712,8 +712,6 @@ static const struct v4l2_subdev_core_ops hdmi_sd_core_ops = 
{
 static const struct v4l2_subdev_video_ops hdmi_sd_video_ops = {
.s_dv_timings = hdmi_s_dv_timings,
.g_dv_timings = hdmi_g_dv_timings,
-   .enum_dv_timings = hdmi_enum_dv_timings,
-   .dv_timings_cap = hdmi_dv_timings_cap,
.g_mbus_fmt = hdmi_g_mbus_fmt,
.s_stream = hdmi_s_stream,
 };
-- 
1.8.3.2

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


[PATCH v2 22/48] s5p-tv: hdmiphy: Remove deprecated video-level DV timings operation

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings operation is deprecated and unused. Remove it.

Cc: Kyungmin Park 
Cc: Tomasz Stanislawski 
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/platform/s5p-tv/hdmiphy_drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/s5p-tv/hdmiphy_drv.c 
b/drivers/media/platform/s5p-tv/hdmiphy_drv.c
index ff22320..c2f2e35 100644
--- a/drivers/media/platform/s5p-tv/hdmiphy_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmiphy_drv.c
@@ -262,7 +262,6 @@ static const struct v4l2_subdev_core_ops hdmiphy_core_ops = 
{
 
 static const struct v4l2_subdev_video_ops hdmiphy_video_ops = {
.s_dv_timings = hdmiphy_s_dv_timings,
-   .dv_timings_cap = hdmiphy_dv_timings_cap,
.s_stream =  hdmiphy_s_stream,
 };
 
-- 
1.8.3.2

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


[PATCH v2 16/48] media: staging: davinci: vpfe: Switch to pad-level DV operations

2014-03-10 Thread Laurent Pinchart
The video-level enum_dv_timings and dv_timings_cap operations are
deprecated in favor of the pad-level versions. All subdev drivers
implement the pad-level versions, switch to them.

Cc: Prabhakar Lad 
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/staging/media/davinci_vpfe/vpfe_video.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c 
b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 1f3b0f9..a1655a8 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -987,8 +987,10 @@ vpfe_enum_dv_timings(struct file *file, void *fh,
struct vpfe_device *vpfe_dev = video->vpfe_dev;
struct v4l2_subdev *subdev = video->current_ext_subdev->subdev;
 
+   timings->pad = 0;
+
v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_dv_timings\n");
-   return v4l2_subdev_call(subdev, video, enum_dv_timings, timings);
+   return v4l2_subdev_call(subdev, pad, enum_dv_timings, timings);
 }
 
 /*
-- 
1.8.3.2

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


[PATCH v2 34/48] adv7604: Remove subdev control handlers

2014-03-10 Thread Laurent Pinchart
Control operations are handled by the control framework and the subdev
control handlers are never called directly. Remove them.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 3866970..dc7f6e0 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2172,13 +2172,6 @@ static const struct v4l2_ctrl_ops adv7604_ctrl_ops = {
 
 static const struct v4l2_subdev_core_ops adv7604_core_ops = {
.log_status = adv7604_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,
.interrupt_service_routine = adv7604_isr,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.g_register = adv7604_g_register,
-- 
1.8.3.2

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


[PATCH v2 31/48] adv7604: Add 16-bit read functions for CP and HDMI

2014-03-10 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 48 ++---
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 81d737c..75b3dae 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -542,6 +542,11 @@ static inline int hdmi_read(struct v4l2_subdev *sd, u8 reg)
return adv_smbus_read_byte_data(state->i2c_hdmi, reg);
 }
 
+static u16 hdmi_read16(struct v4l2_subdev *sd, u8 reg, u16 mask)
+{
+   return ((hdmi_read(sd, reg) << 8) | hdmi_read(sd, reg + 1)) & mask;
+}
+
 static inline int hdmi_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
struct adv7604_state *state = to_state(sd);
@@ -575,6 +580,11 @@ static inline int cp_read(struct v4l2_subdev *sd, u8 reg)
return adv_smbus_read_byte_data(state->i2c_cp, reg);
 }
 
+static u16 cp_read16(struct v4l2_subdev *sd, u8 reg, u16 mask)
+{
+   return ((cp_read(sd, reg) << 8) | cp_read(sd, reg + 1)) & mask;
+}
+
 static inline int cp_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
struct adv7604_state *state = to_state(sd);
@@ -1203,8 +1213,8 @@ static int read_stdi(struct v4l2_subdev *sd, struct 
stdi_readback *stdi)
}
 
/* read STDI */
-   stdi->bl = ((cp_read(sd, 0xb1) & 0x3f) << 8) | cp_read(sd, 0xb2);
-   stdi->lcf = ((cp_read(sd, 0xb3) & 0x7) << 8) | cp_read(sd, 0xb4);
+   stdi->bl = cp_read16(sd, 0xb1, 0x3fff);
+   stdi->lcf = cp_read16(sd, 0xb3, 0x7ff);
stdi->lcvs = cp_read(sd, 0xb3) >> 3;
stdi->interlaced = io_read(sd, 0x12) & 0x10;
 
@@ -1315,8 +1325,8 @@ static int adv7604_query_dv_timings(struct v4l2_subdev 
*sd,
 
timings->type = V4L2_DV_BT_656_1120;
 
-   bt->width = (hdmi_read(sd, 0x07) & 0x0f) * 256 + hdmi_read(sd, 
0x08);
-   bt->height = (hdmi_read(sd, 0x09) & 0x0f) * 256 + hdmi_read(sd, 
0x0a);
+   bt->width = hdmi_read16(sd, 0x07, 0xfff);
+   bt->height = hdmi_read16(sd, 0x09, 0xfff);
freq = (hdmi_read(sd, 0x06) * 100) +
((hdmi_read(sd, 0x3b) & 0x30) >> 4) * 25;
if (is_hdmi(sd)) {
@@ -1326,29 +1336,19 @@ static int adv7604_query_dv_timings(struct v4l2_subdev 
*sd,
freq = freq * 8 / bits_per_channel;
}
bt->pixelclock = freq;
-   bt->hfrontporch = (hdmi_read(sd, 0x20) & 0x03) * 256 +
-   hdmi_read(sd, 0x21);
-   bt->hsync = (hdmi_read(sd, 0x22) & 0x03) * 256 +
-   hdmi_read(sd, 0x23);
-   bt->hbackporch = (hdmi_read(sd, 0x24) & 0x03) * 256 +
-   hdmi_read(sd, 0x25);
-   bt->vfrontporch = ((hdmi_read(sd, 0x2a) & 0x1f) * 256 +
-   hdmi_read(sd, 0x2b)) / 2;
-   bt->vsync = ((hdmi_read(sd, 0x2e) & 0x1f) * 256 +
-   hdmi_read(sd, 0x2f)) / 2;
-   bt->vbackporch = ((hdmi_read(sd, 0x32) & 0x1f) * 256 +
-   hdmi_read(sd, 0x33)) / 2;
+   bt->hfrontporch = hdmi_read16(sd, 0x20, 0x3ff);
+   bt->hsync = hdmi_read16(sd, 0x22, 0x3ff);
+   bt->hbackporch = hdmi_read16(sd, 0x24, 0x3ff);
+   bt->vfrontporch = hdmi_read16(sd, 0x2a, 0x1fff) / 2;
+   bt->vsync = hdmi_read16(sd, 0x2e, 0x1fff) / 2;
+   bt->vbackporch = hdmi_read16(sd, 0x32, 0x1fff) / 2;
bt->polarities = ((hdmi_read(sd, 0x05) & 0x10) ? 
V4L2_DV_VSYNC_POS_POL : 0) |
((hdmi_read(sd, 0x05) & 0x20) ? V4L2_DV_HSYNC_POS_POL : 
0);
if (bt->interlaced == V4L2_DV_INTERLACED) {
-   bt->height += (hdmi_read(sd, 0x0b) & 0x0f) * 256 +
-   hdmi_read(sd, 0x0c);
-   bt->il_vfrontporch = ((hdmi_read(sd, 0x2c) & 0x1f) * 
256 +
-   hdmi_read(sd, 0x2d)) / 2;
-   bt->il_vsync = ((hdmi_read(sd, 0x30) & 0x1f) * 256 +
-   hdmi_read(sd, 0x31)) / 2;
-   bt->vbackporch = ((hdmi_read(sd, 0x34) & 0x1f) * 256 +
-   hdmi_read(sd, 0x35)) / 2;
+   bt->height += hdmi_read16(sd, 0x0b, 0xfff);
+   bt->il_vfrontporch = hdmi_read16(sd, 0x2c, 0x1fff) / 2;
+   bt->il_vsync = hdmi_read16(sd, 0x30, 0x1fff) / 2;
+   bt->vbackporch = hdmi_read16(sd, 0x34, 0x1fff) / 2;
}
adv7604_fill_optional_dv_timings_fields(sd, timings);
} else {
-- 
1.8.3.2

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


[PATCH v2 40/48] adv7604: Inline the to_sd function

2014-03-10 Thread Laurent Pinchart
This one line function is called in a single location. Inline it.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index d4d085c..2a3ced2 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -340,11 +340,6 @@ static inline struct adv7604_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct adv7604_state, sd);
 }
 
-static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
-{
-   return &container_of(ctrl->handler, struct adv7604_state, hdl)->sd;
-}
-
 static inline unsigned hblanking(const struct v4l2_bt_timings *t)
 {
return V4L2_DV_BT_BLANKING_WIDTH(t);
@@ -1270,7 +1265,9 @@ static void set_rgb_quantization_range(struct v4l2_subdev 
*sd)
 
 static int adv7604_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   struct v4l2_subdev *sd = to_sd(ctrl);
+   struct v4l2_subdev *sd =
+   &container_of(ctrl->handler, struct adv7604_state, hdl)->sd;
+
struct adv7604_state *state = to_state(sd);
 
switch (ctrl->id) {
-- 
1.8.3.2

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


[PATCH v2 44/48] adv7604: Support hot-plug detect control through a GPIO

2014-03-10 Thread Laurent Pinchart
Add support for optional GPIO-controlled HPD pins in addition to the
ADV7604-specific hotplug notifier.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 37 +
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 0c81c72..7f70c6f 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -28,6 +28,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -135,6 +136,8 @@ struct adv7604_state {
const struct adv7604_chip_info *info;
struct adv7604_platform_data pdata;
 
+   struct gpio_desc *hpd_gpio[4];
+
struct v4l2_subdev sd;
struct media_pad pads[ADV7604_PAD_MAX];
unsigned int source_pad;
@@ -598,6 +601,20 @@ static inline int edid_write_block(struct v4l2_subdev *sd,
return err;
 }
 
+static void adv7604_set_hpd(struct adv7604_state *state, unsigned int hpd)
+{
+   unsigned int i;
+
+   for (i = 0; i < state->info->num_dv_ports; ++i) {
+   if (IS_ERR(state->hpd_gpio[i]))
+   continue;
+
+   gpiod_set_value_cansleep(state->hpd_gpio[i], hpd & BIT(i));
+   }
+
+   v4l2_subdev_notify(&state->sd, ADV7604_HOTPLUG, &hpd);
+}
+
 static void adv7604_delayed_work_enable_hotplug(struct work_struct *work)
 {
struct delayed_work *dwork = to_delayed_work(work);
@@ -607,7 +624,7 @@ static void adv7604_delayed_work_enable_hotplug(struct 
work_struct *work)
 
v4l2_dbg(2, debug, sd, "%s: enable hotplug\n", __func__);
 
-   v4l2_subdev_notify(sd, ADV7604_HOTPLUG, (void *)&state->edid.present);
+   adv7604_set_hpd(state, state->edid.present);
 }
 
 static inline int hdmi_read(struct v4l2_subdev *sd, u8 reg)
@@ -2010,7 +2027,6 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *edi
struct adv7604_state *state = to_state(sd);
const struct adv7604_chip_info *info = state->info;
int spa_loc;
-   int tmp = 0;
int err;
int i;
 
@@ -2021,7 +2037,7 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *edi
if (edid->blocks == 0) {
/* Disable hotplug and I2C access to EDID RAM from DDC port */
state->edid.present &= ~(1 << edid->pad);
-   v4l2_subdev_notify(sd, ADV7604_HOTPLUG, (void 
*)&state->edid.present);
+   adv7604_set_hpd(state, state->edid.present);
rep_write_clr_set(sd, info->edid_enable_reg, 0x0f, 
state->edid.present);
 
/* Fall back to a 16:9 aspect ratio */
@@ -2045,7 +2061,7 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *edi
 
/* Disable hotplug and I2C access to EDID RAM from DDC port */
cancel_delayed_work_sync(&state->delayed_work_enable_hotplug);
-   v4l2_subdev_notify(sd, ADV7604_HOTPLUG, (void *)&tmp);
+   adv7604_set_hpd(state, 0);
rep_write_clr_set(sd, info->edid_enable_reg, 0x0f, 0x00);
 
spa_loc = get_edid_spa_location(edid->edid);
@@ -2641,6 +2657,19 @@ static int adv7604_probe(struct i2c_client *client,
return -ENODEV;
}
state->pdata = *pdata;
+
+   /* Request GPIOs. */
+   for (i = 0; i < state->info->num_dv_ports; ++i) {
+   state->hpd_gpio[i] =
+   devm_gpiod_get_index(&client->dev, "hpd", i);
+   if (IS_ERR(state->hpd_gpio[i]))
+   continue;
+
+   gpiod_set_value_cansleep(state->hpd_gpio[i], 0);
+
+   v4l_info(client, "Handling HPD %u GPIO\n", i);
+   }
+
state->timings = cea640x480;
state->format = adv7604_format_info(state, V4L2_MBUS_FMT_YUYV8_2X8);
 
-- 
1.8.3.2

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


[PATCH v2 32/48] adv7604: Cache register contents when reading multiple bits

2014-03-10 Thread Laurent Pinchart
When extracting multiple bits from a single register read the register
once and extract the bits on the read value.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 75b3dae..80534f9 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1207,6 +1207,8 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,
 
 static int read_stdi(struct v4l2_subdev *sd, struct stdi_readback *stdi)
 {
+   u8 polarity;
+
if (no_lock_stdi(sd) || no_lock_sspd(sd)) {
v4l2_dbg(2, debug, sd, "%s: STDI and/or SSPD not locked\n", 
__func__);
return -1;
@@ -1219,11 +1221,12 @@ static int read_stdi(struct v4l2_subdev *sd, struct 
stdi_readback *stdi)
stdi->interlaced = io_read(sd, 0x12) & 0x10;
 
/* read SSPD */
-   if ((cp_read(sd, 0xb5) & 0x03) == 0x01) {
-   stdi->hs_pol = ((cp_read(sd, 0xb5) & 0x10) ?
-   ((cp_read(sd, 0xb5) & 0x08) ? '+' : '-') : 'x');
-   stdi->vs_pol = ((cp_read(sd, 0xb5) & 0x40) ?
-   ((cp_read(sd, 0xb5) & 0x20) ? '+' : '-') : 'x');
+   polarity = cp_read(sd, 0xb5);
+   if ((polarity & 0x03) == 0x01) {
+   stdi->hs_pol = polarity & 0x10
+? (polarity & 0x08 ? '+' : '-') : 'x';
+   stdi->vs_pol = polarity & 0x40
+? (polarity & 0x20 ? '+' : '-') : 'x';
} else {
stdi->hs_pol = 'x';
stdi->vs_pol = 'x';
@@ -1881,6 +1884,8 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
struct v4l2_dv_timings timings;
struct stdi_readback stdi;
u8 reg_io_0x02 = io_read(sd, 0x02);
+   u8 edid_enabled;
+   u8 cable_det;
 
static const char * const csc_coeff_sel_rb[16] = {
"bypassed", "YPbPr601 -> RGB", "reserved", "YPbPr709 -> RGB",
@@ -1910,20 +1915,22 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
 
v4l2_info(sd, "-Chip status-\n");
v4l2_info(sd, "Chip power: %s\n", no_power(sd) ? "off" : "on");
+   edid_enabled = rep_read(sd, 0x7d);
v4l2_info(sd, "EDID enabled port A: %s, B: %s, C: %s, D: %s\n",
-   ((rep_read(sd, 0x7d) & 0x01) ? "Yes" : "No"),
-   ((rep_read(sd, 0x7d) & 0x02) ? "Yes" : "No"),
-   ((rep_read(sd, 0x7d) & 0x04) ? "Yes" : "No"),
-   ((rep_read(sd, 0x7d) & 0x08) ? "Yes" : "No"));
+   ((edid_enabled & 0x01) ? "Yes" : "No"),
+   ((edid_enabled & 0x02) ? "Yes" : "No"),
+   ((edid_enabled & 0x04) ? "Yes" : "No"),
+   ((edid_enabled & 0x08) ? "Yes" : "No"));
v4l2_info(sd, "CEC: %s\n", !!(cec_read(sd, 0x2a) & 0x01) ?
"enabled" : "disabled");
 
v4l2_info(sd, "-Signal status-\n");
+   cable_det = io_read(sd, 0x6f);
v4l2_info(sd, "Cable detected (+5V power) port A: %s, B: %s, C: %s, D: 
%s\n",
-   ((io_read(sd, 0x6f) & 0x10) ? "Yes" : "No"),
-   ((io_read(sd, 0x6f) & 0x08) ? "Yes" : "No"),
-   ((io_read(sd, 0x6f) & 0x04) ? "Yes" : "No"),
-   ((io_read(sd, 0x6f) & 0x02) ? "Yes" : "No"));
+   ((cable_det & 0x10) ? "Yes" : "No"),
+   ((cable_det & 0x08) ? "Yes" : "No"),
+   ((cable_det & 0x04) ? "Yes" : "No"),
+   ((cable_det & 0x02) ? "Yes" : "No"));
v4l2_info(sd, "TMDS signal detected: %s\n",
no_signal_tmds(sd) ? "false" : "true");
v4l2_info(sd, "TMDS signal locked: %s\n",
-- 
1.8.3.2

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


[PATCH v2 33/48] adv7604: Add adv7611 support

2014-03-10 Thread Laurent Pinchart
From: Lars-Peter Clausen 

This patch adds support for the Analog Devices ADV7611 HDMI receiver.
The adv7611 is quite similar to the adv7604. It has only one instead of four
HDMI inputs and no analog frontend though. Also some register bits have been
shuffled around, but large parts of their register maps are compatible.

Signed-off-by: Lars-Peter Clausen 
---
 drivers/media/i2c/adv7604.c | 719 +++-
 include/media/adv7604.h |  10 +
 2 files changed, 528 insertions(+), 201 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 80534f9..3866970 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -53,6 +53,43 @@ MODULE_LICENSE("GPL");
 /* ADV7604 system clock frequency */
 #define ADV7604_fsc (28636360)
 
+enum adv7604_type {
+   ADV7604,
+   ADV7611,
+};
+
+struct adv7604_reg_seq {
+   unsigned int reg;
+   u8 val;
+};
+
+struct adv7604_chip_info {
+   enum adv7604_type type;
+
+   bool has_afe;
+   unsigned int max_port;
+   unsigned int num_dv_ports;
+
+   unsigned int edid_enable_reg;
+   unsigned int edid_status_reg;
+   unsigned int lcf_reg;
+
+   unsigned int cable_det_mask;
+   unsigned int tdms_lock_mask;
+   unsigned int fmt_change_digital_mask;
+
+   void (*set_termination)(struct v4l2_subdev *sd, bool enable);
+   void (*setup_irqs)(struct v4l2_subdev *sd);
+   unsigned int (*read_hdmi_pixelclock)(struct v4l2_subdev *sd);
+   unsigned int (*read_cable_det)(struct v4l2_subdev *sd);
+
+   /* 0 = AFE, 1 = HDMI */
+   const struct adv7604_reg_seq *recommended_settings[2];
+   unsigned int num_recommended_settings[2];
+
+   unsigned long page_mask;
+};
+
 /*
  **
  *
@@ -61,6 +98,7 @@ MODULE_LICENSE("GPL");
  **
  */
 struct adv7604_state {
+   const struct adv7604_chip_info *info;
struct adv7604_platform_data pdata;
struct v4l2_subdev sd;
struct media_pad pad;
@@ -101,6 +139,11 @@ struct adv7604_state {
struct v4l2_ctrl *rgb_quantization_range_ctrl;
 };
 
+static bool adv7604_has_afe(struct adv7604_state *state)
+{
+   return state->info->has_afe;
+}
+
 /* Supported CEA and DMT timings */
 static const struct v4l2_dv_timings adv7604_timings[] = {
V4L2_DV_BT_CEA_720X480P59_94,
@@ -611,6 +654,121 @@ static inline int vdp_write(struct v4l2_subdev *sd, u8 
reg, u8 val)
return adv_smbus_write_byte_data(state->i2c_vdp, reg, val);
 }
 
+enum {
+   ADV7604_PAGE_IO,
+   ADV7604_PAGE_AVLINK,
+   ADV7604_PAGE_CEC,
+   ADV7604_PAGE_INFOFRAME,
+   ADV7604_PAGE_ESDP,
+   ADV7604_PAGE_DPP,
+   ADV7604_PAGE_AFE,
+   ADV7604_PAGE_REP,
+   ADV7604_PAGE_EDID,
+   ADV7604_PAGE_HDMI,
+   ADV7604_PAGE_TEST,
+   ADV7604_PAGE_CP,
+   ADV7604_PAGE_VDP,
+   ADV7604_PAGE_TERM,
+};
+
+#define ADV7604_REG(page, offset)  (((page) << 8) | (offset))
+#define ADV7604_REG_SEQ_TERM   0x
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int adv7604_read_reg(struct v4l2_subdev *sd, unsigned int reg)
+{
+   struct adv7604_state *state = to_state(sd);
+   unsigned int page = reg >> 8;
+
+   if (!(BIT(page) & state->info->page_mask))
+   return -EINVAL;
+
+   reg &= 0xff;
+
+   switch (page) {
+   case ADV7604_PAGE_IO:
+   return io_read(sd, reg);
+   case ADV7604_PAGE_AVLINK:
+   return avlink_read(sd, reg);
+   case ADV7604_PAGE_CEC:
+   return cec_read(sd, reg);
+   case ADV7604_PAGE_INFOFRAME:
+   return infoframe_read(sd, reg);
+   case ADV7604_PAGE_ESDP:
+   return esdp_read(sd, reg);
+   case ADV7604_PAGE_DPP:
+   return dpp_read(sd, reg);
+   case ADV7604_PAGE_AFE:
+   return afe_read(sd, reg);
+   case ADV7604_PAGE_REP:
+   return rep_read(sd, reg);
+   case ADV7604_PAGE_EDID:
+   return edid_read(sd, reg);
+   case ADV7604_PAGE_HDMI:
+   return hdmi_read(sd, reg);
+   case ADV7604_PAGE_TEST:
+   return test_read(sd, reg);
+   case ADV7604_PAGE_CP:
+   return cp_read(sd, reg);
+   case ADV7604_PAGE_VDP:
+   return vdp_read(sd, reg);
+   }
+
+   return -EINVAL;
+}
+#endif
+
+static int adv7604_write_reg(struct v4l2_subdev *sd, unsigned int reg, u8 val)
+{
+   struct adv7604_state *state = to_state(sd);
+   unsigned int page = reg >> 8;
+
+   if (!(BIT(page) & state->info->page_mask))
+   return -EINVAL;
+
+   reg &= 0xff;
+
+   switch (page) {
+   case ADV7604_PAGE_IO:
+   return io_write(sd, reg, val);
+   case ADV7604_PAGE_AVLINK:
+   return avlink_write(sd, reg, val);
+   case AD

[PATCH v2 36/48] adv7604: Make output format configurable through pad format operations

2014-03-10 Thread Laurent Pinchart
Replace the dummy video format operations by pad format operations that
configure the output format.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 243 +++-
 include/media/adv7604.h |  47 ++---
 2 files changed, 225 insertions(+), 65 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 851b350..66b3481 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -53,6 +53,28 @@ MODULE_LICENSE("GPL");
 /* ADV7604 system clock frequency */
 #define ADV7604_fsc (28636360)
 
+#define ADV7604_RGB_OUT(1 << 1)
+
+#define ADV7604_OP_FORMAT_SEL_8BIT (0 << 0)
+#define ADV7604_OP_FORMAT_SEL_10BIT(1 << 0)
+#define ADV7604_OP_FORMAT_SEL_12BIT(2 << 0)
+
+#define ADV7604_OP_MODE_SEL_SDR_422(0 << 5)
+#define ADV7604_OP_MODE_SEL_DDR_422(1 << 5)
+#define ADV7604_OP_MODE_SEL_SDR_444(2 << 5)
+#define ADV7604_OP_MODE_SEL_DDR_444(3 << 5)
+#define ADV7604_OP_MODE_SEL_SDR_422_2X (4 << 5)
+#define ADV7604_OP_MODE_SEL_ADI_CM (5 << 5)
+
+#define ADV7604_OP_CH_SEL_GBR  (0 << 5)
+#define ADV7604_OP_CH_SEL_GRB  (1 << 5)
+#define ADV7604_OP_CH_SEL_BGR  (2 << 5)
+#define ADV7604_OP_CH_SEL_RGB  (3 << 5)
+#define ADV7604_OP_CH_SEL_BRG  (4 << 5)
+#define ADV7604_OP_CH_SEL_RBG  (5 << 5)
+
+#define ADV7604_OP_SWAP_CB_CR  (1 << 0)
+
 enum adv7604_type {
ADV7604,
ADV7611,
@@ -63,6 +85,14 @@ struct adv7604_reg_seq {
u8 val;
 };
 
+struct adv7604_format_info {
+   enum v4l2_mbus_pixelcode code;
+   u8 op_ch_sel;
+   bool rgb_out;
+   bool swap_cb_cr;
+   u8 op_format_sel;
+};
+
 struct adv7604_chip_info {
enum adv7604_type type;
 
@@ -78,6 +108,9 @@ struct adv7604_chip_info {
unsigned int tdms_lock_mask;
unsigned int fmt_change_digital_mask;
 
+   const struct adv7604_format_info *formats;
+   unsigned int nformats;
+
void (*set_termination)(struct v4l2_subdev *sd, bool enable);
void (*setup_irqs)(struct v4l2_subdev *sd);
unsigned int (*read_hdmi_pixelclock)(struct v4l2_subdev *sd);
@@ -101,12 +134,18 @@ struct adv7604_chip_info {
 struct adv7604_state {
const struct adv7604_chip_info *info;
struct adv7604_platform_data pdata;
+
struct v4l2_subdev sd;
struct media_pad pads[ADV7604_PAD_MAX];
unsigned int source_pad;
+
struct v4l2_ctrl_handler hdl;
+
enum adv7604_pad selected_input;
+
struct v4l2_dv_timings timings;
+   const struct adv7604_format_info *format;
+
struct {
u8 edid[256];
u32 present;
@@ -771,6 +810,93 @@ static void adv7604_write_reg_seq(struct v4l2_subdev *sd,
adv7604_write_reg(sd, reg_seq[i].reg, reg_seq[i].val);
 }
 
+/* 
-
+ * Format helpers
+ */
+
+static const struct adv7604_format_info adv7604_formats[] = {
+   { V4L2_MBUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false,
+ ADV7604_OP_MODE_SEL_SDR_444 | ADV7604_OP_FORMAT_SEL_8BIT },
+   { V4L2_MBUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false,
+ ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT },
+   { V4L2_MBUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true,
+ ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT },
+   { V4L2_MBUS_FMT_YUYV10_2X10, ADV7604_OP_CH_SEL_RGB, false, false,
+ ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_10BIT },
+   { V4L2_MBUS_FMT_YVYU10_2X10, ADV7604_OP_CH_SEL_RGB, false, true,
+ ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_10BIT },
+   { V4L2_MBUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false,
+ ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT },
+   { V4L2_MBUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true,
+ ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT },
+   { V4L2_MBUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false,
+ ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
+   { V4L2_MBUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true,
+ ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
+   { V4L2_MBUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false,
+ ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
+   { V4L2_MBUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true,
+ ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
+   { V4L2_MBUS_FMT_UYVY10_1X20, ADV7604_OP_CH_SEL_RBG, false, false

[PATCH v2 26/48] v4l: Add support for DV timings ioctls on subdev nodes

2014-03-10 Thread Laurent Pinchart
Validate the pad field in the core code whenever specified.

Signed-off-by: Laurent Pinchart 
---
 .../DocBook/media/v4l/vidioc-dv-timings-cap.xml| 27 +++
 .../DocBook/media/v4l/vidioc-enum-dv-timings.xml   | 30 +-
 drivers/media/v4l2-core/v4l2-subdev.c  | 27 +++
 include/uapi/linux/v4l2-subdev.h   |  5 
 4 files changed, 77 insertions(+), 12 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml 
b/Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml
index cd7720d..28a8c1e 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml
@@ -1,11 +1,12 @@
 
   
-ioctl VIDIOC_DV_TIMINGS_CAP
+ioctl VIDIOC_DV_TIMINGS_CAP, 
VIDIOC_SUBDEV_DV_TIMINGS_CAP
 &manvol;
   
 
   
 VIDIOC_DV_TIMINGS_CAP
+VIDIOC_SUBDEV_DV_TIMINGS_CAP
 The capabilities of the Digital Video 
receiver/transmitter
   
 
@@ -33,7 +34,7 @@
   
request

- VIDIOC_DV_TIMINGS_CAP
+ VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP

   
   
@@ -54,10 +55,19 @@
   interface and may change in the future.
 
 
-To query the capabilities of the DV receiver/transmitter 
applications can call
-this ioctl and the driver will fill in the structure. Note that drivers may 
return
+To query the capabilities of the DV receiver/transmitter applications
+can call the VIDIOC_DV_TIMINGS_CAP ioctl on a video node
+and the driver will fill in the structure. Note that drivers may return
 different values after switching the video input or output.
 
+When implemented by the driver DV capabilities of subdevices can be
+queried by calling the VIDIOC_SUBDEV_DV_TIMINGS_CAP ioctl
+directly on a subdevice node. The capabilities are specific to inputs (for DV
+receivers) or outputs (for DV transmitters), applications must specify the
+desired pad number in the &v4l2-dv-timings-cap; pad
+field. Attempts to query capabilities on a pad that doesn't support them will
+return an &EINVAL;.
+
 
   struct v4l2_bt_timings_cap
   
@@ -127,7 +137,14 @@ different values after switching the video input or 
output.
  
  
__u32
-   reserved[3]
+   pad
+   Pad number as reported by the media controller API. This 
field
+   is only used when operating on a subdevice node. When operating on a
+   video node applications must set this field to zero.
+ 
+ 
+   __u32
+   reserved[2]
Reserved for future extensions. Drivers must set the array 
to zero.
  
  
diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml 
b/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
index b3e17c1..b9fdfea 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
@@ -1,11 +1,12 @@
 
   
-ioctl VIDIOC_ENUM_DV_TIMINGS
+ioctl VIDIOC_ENUM_DV_TIMINGS, 
VIDIOC_SUBDEV_ENUM_DV_TIMINGS
 &manvol;
   
 
   
 VIDIOC_ENUM_DV_TIMINGS
+VIDIOC_SUBDEV_ENUM_DV_TIMINGS
 Enumerate supported Digital Video timings
   
 
@@ -33,7 +34,7 @@
   
request

- VIDIOC_ENUM_DV_TIMINGS
+ VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS

   
   
@@ -61,14 +62,21 @@ standards or even custom timings that are not in this 
list.
 
 To query the available timings, applications initialize the
 index field and zero the reserved array of 
&v4l2-enum-dv-timings;
-and call the VIDIOC_ENUM_DV_TIMINGS ioctl with a pointer 
to this
-structure. Drivers fill the rest of the structure or return an
+and call the VIDIOC_ENUM_DV_TIMINGS ioctl on a video node 
with a
+pointer to this structure. Drivers fill the rest of the structure or return an
 &EINVAL; when the index is out of bounds. To enumerate all supported DV 
timings,
 applications shall begin at index zero, incrementing by one until the
 driver returns EINVAL. Note that drivers may enumerate a
 different set of DV timings after switching the video input or
 output.
 
+When implemented by the driver DV timings of subdevices can be 
queried
+by calling the VIDIOC_SUBDEV_ENUM_DV_TIMINGS ioctl 
directly
+on a subdevice node. The DV timings are specific to inputs (for DV receivers) 
or
+outputs (for DV transmitters), applications must specify the desired pad number
+in the &v4l2-enum-dv-timings; pad field. Attempts to
+enumerate timings on a pad that doesn't support them will return an 
&EINVAL;.
+
 
   struct v4l2_enum_dv_timings
   
@@ -82,8 +90,16 @@ application.
  
  
__u32
-   reserved[3]
-   Reserved for future extensions. Drivers must set the array 
to zero.
+   pad
+   Pad number as reported by the media controller API. Thi

[PATCH v2 39/48] v4l: subdev: Remove deprecated video-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated
and unused. Remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
Acked-by: Sakari Ailus 
---
 include/media/v4l2-subdev.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 2b5ec32..ab2b59d 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -330,12 +330,8 @@ struct v4l2_subdev_video_ops {
struct v4l2_dv_timings *timings);
int (*g_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
-   int (*enum_dv_timings)(struct v4l2_subdev *sd,
-   struct v4l2_enum_dv_timings *timings);
int (*query_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
-   int (*dv_timings_cap)(struct v4l2_subdev *sd,
-   struct v4l2_dv_timings_cap *cap);
int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
 enum v4l2_mbus_pixelcode *code);
int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
-- 
1.8.3.2

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


[PATCH v2 25/48] v4l: Improve readability by not wrapping ioctl number #define's

2014-03-10 Thread Laurent Pinchart
Wrapping the #define's at a 80 columns boundary just obfuscates the
code. Don't do that.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
Acked-by: Sakari Ailus 
---
 include/uapi/linux/v4l2-subdev.h | 33 +
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index a33c4da..9fe3493 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -156,25 +156,18 @@ struct v4l2_subdev_edid {
__u8 __user *edid;
 };
 
-#define VIDIOC_SUBDEV_G_FMT_IOWR('V',  4, struct v4l2_subdev_format)
-#define VIDIOC_SUBDEV_S_FMT_IOWR('V',  5, struct v4l2_subdev_format)
-#define VIDIOC_SUBDEV_G_FRAME_INTERVAL \
-   _IOWR('V', 21, struct v4l2_subdev_frame_interval)
-#define VIDIOC_SUBDEV_S_FRAME_INTERVAL \
-   _IOWR('V', 22, struct v4l2_subdev_frame_interval)
-#define VIDIOC_SUBDEV_ENUM_MBUS_CODE \
-   _IOWR('V',  2, struct v4l2_subdev_mbus_code_enum)
-#define VIDIOC_SUBDEV_ENUM_FRAME_SIZE \
-   _IOWR('V', 74, struct v4l2_subdev_frame_size_enum)
-#define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
-   _IOWR('V', 75, struct v4l2_subdev_frame_interval_enum)
-#define VIDIOC_SUBDEV_G_CROP   _IOWR('V', 59, struct v4l2_subdev_crop)
-#define VIDIOC_SUBDEV_S_CROP   _IOWR('V', 60, struct v4l2_subdev_crop)
-#define VIDIOC_SUBDEV_G_SELECTION \
-   _IOWR('V', 61, struct v4l2_subdev_selection)
-#define VIDIOC_SUBDEV_S_SELECTION \
-   _IOWR('V', 62, struct v4l2_subdev_selection)
-#define VIDIOC_SUBDEV_G_EDID   _IOWR('V', 40, struct v4l2_subdev_edid)
-#define VIDIOC_SUBDEV_S_EDID   _IOWR('V', 41, struct v4l2_subdev_edid)
+#define VIDIOC_SUBDEV_G_FMT_IOWR('V',  4, struct 
v4l2_subdev_format)
+#define VIDIOC_SUBDEV_S_FMT_IOWR('V',  5, struct 
v4l2_subdev_format)
+#define VIDIOC_SUBDEV_G_FRAME_INTERVAL _IOWR('V', 21, struct 
v4l2_subdev_frame_interval)
+#define VIDIOC_SUBDEV_S_FRAME_INTERVAL _IOWR('V', 22, struct 
v4l2_subdev_frame_interval)
+#define VIDIOC_SUBDEV_ENUM_MBUS_CODE   _IOWR('V',  2, struct 
v4l2_subdev_mbus_code_enum)
+#define VIDIOC_SUBDEV_ENUM_FRAME_SIZE  _IOWR('V', 74, struct 
v4l2_subdev_frame_size_enum)
+#define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL  _IOWR('V', 75, struct 
v4l2_subdev_frame_interval_enum)
+#define VIDIOC_SUBDEV_G_CROP   _IOWR('V', 59, struct 
v4l2_subdev_crop)
+#define VIDIOC_SUBDEV_S_CROP   _IOWR('V', 60, struct 
v4l2_subdev_crop)
+#define VIDIOC_SUBDEV_G_SELECTION  _IOWR('V', 61, struct 
v4l2_subdev_selection)
+#define VIDIOC_SUBDEV_S_SELECTION  _IOWR('V', 62, struct 
v4l2_subdev_selection)
+#define VIDIOC_SUBDEV_G_EDID   _IOWR('V', 40, struct 
v4l2_subdev_edid)
+#define VIDIOC_SUBDEV_S_EDID   _IOWR('V', 41, struct 
v4l2_subdev_edid)
 
 #endif
-- 
1.8.3.2

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


[PATCH v2 41/48] adv7604: Store I2C addresses and clients in arrays

2014-03-10 Thread Laurent Pinchart
This allows replacing duplicate code blocks by loops over the arrays.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 248 +---
 include/media/adv7604.h |  30 +++---
 2 files changed, 88 insertions(+), 190 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 2a3ced2..f79761e 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -159,18 +159,7 @@ struct adv7604_state {
bool restart_stdi_once;
 
/* i2c clients */
-   struct i2c_client *i2c_avlink;
-   struct i2c_client *i2c_cec;
-   struct i2c_client *i2c_infoframe;
-   struct i2c_client *i2c_esdp;
-   struct i2c_client *i2c_dpp;
-   struct i2c_client *i2c_afe;
-   struct i2c_client *i2c_repeater;
-   struct i2c_client *i2c_edid;
-   struct i2c_client *i2c_hdmi;
-   struct i2c_client *i2c_test;
-   struct i2c_client *i2c_cp;
-   struct i2c_client *i2c_vdp;
+   struct i2c_client *i2c_clients[ADV7604_PAGE_MAX];
 
/* controls */
struct v4l2_ctrl *detect_tx_5v_ctrl;
@@ -377,14 +366,18 @@ static s32 adv_smbus_read_byte_data_check(struct 
i2c_client *client,
return -EIO;
 }
 
-static s32 adv_smbus_read_byte_data(struct i2c_client *client, u8 command)
+static s32 adv_smbus_read_byte_data(struct adv7604_state *state,
+   enum adv7604_page page, u8 command)
 {
-   return adv_smbus_read_byte_data_check(client, command, true);
+   return adv_smbus_read_byte_data_check(state->i2c_clients[page],
+ command, true);
 }
 
-static s32 adv_smbus_write_byte_data(struct i2c_client *client,
-   u8 command, u8 value)
+static s32 adv_smbus_write_byte_data(struct adv7604_state *state,
+enum adv7604_page page, u8 command,
+u8 value)
 {
+   struct i2c_client *client = state->i2c_clients[page];
union i2c_smbus_data data;
int err;
int i;
@@ -404,9 +397,11 @@ static s32 adv_smbus_write_byte_data(struct i2c_client 
*client,
return err;
 }
 
-static s32 adv_smbus_write_i2c_block_data(struct i2c_client *client,
-  u8 command, unsigned length, const u8 *values)
+static s32 adv_smbus_write_i2c_block_data(struct adv7604_state *state,
+ enum adv7604_page page, u8 command,
+ unsigned length, const u8 *values)
 {
+   struct i2c_client *client = state->i2c_clients[page];
union i2c_smbus_data data;
 
if (length > I2C_SMBUS_BLOCK_MAX)
@@ -422,16 +417,16 @@ static s32 adv_smbus_write_i2c_block_data(struct 
i2c_client *client,
 
 static inline int io_read(struct v4l2_subdev *sd, u8 reg)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   struct adv7604_state *state = to_state(sd);
 
-   return adv_smbus_read_byte_data(client, reg);
+   return adv_smbus_read_byte_data(state, ADV7604_PAGE_IO, reg);
 }
 
 static inline int io_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   struct adv7604_state *state = to_state(sd);
 
-   return adv_smbus_write_byte_data(client, reg, val);
+   return adv_smbus_write_byte_data(state, ADV7604_PAGE_IO, reg, val);
 }
 
 static inline int io_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
@@ -443,28 +438,28 @@ static inline int avlink_read(struct v4l2_subdev *sd, u8 
reg)
 {
struct adv7604_state *state = to_state(sd);
 
-   return adv_smbus_read_byte_data(state->i2c_avlink, reg);
+   return adv_smbus_read_byte_data(state, ADV7604_PAGE_AVLINK, reg);
 }
 
 static inline int avlink_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
struct adv7604_state *state = to_state(sd);
 
-   return adv_smbus_write_byte_data(state->i2c_avlink, reg, val);
+   return adv_smbus_write_byte_data(state, ADV7604_PAGE_AVLINK, reg, val);
 }
 
 static inline int cec_read(struct v4l2_subdev *sd, u8 reg)
 {
struct adv7604_state *state = to_state(sd);
 
-   return adv_smbus_read_byte_data(state->i2c_cec, reg);
+   return adv_smbus_read_byte_data(state, ADV7604_PAGE_CEC, reg);
 }
 
 static inline int cec_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
struct adv7604_state *state = to_state(sd);
 
-   return adv_smbus_write_byte_data(state->i2c_cec, reg, val);
+   return adv_smbus_write_byte_data(state, ADV7604_PAGE_CEC, reg, val);
 }
 
 static inline int cec_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
@@ -476,70 +471,71 @@ static inline int infoframe_read(struct v4l2_subdev *sd, 
u8 reg)
 {
struct adv7604_state *state = to_state(sd);
 
-   return adv_smbus_read_byte_data(state->i2c_infoframe, reg);
+   return adv_smbus_read_byte_data(state, A

[PATCH v2 42/48] adv7604: Replace *_and_or() functions with *_clr_set()

2014-03-10 Thread Laurent Pinchart
The *_and_or() functions take an 'and' bitmask to be ANDed with the
register value before ORing it with th 'or' bitmask. As the functions
are used to mask and set bits selectively, this requires the caller to
invert the 'and' bitmask and is thus error prone. Replace those
functions with a *_clr_set() variant that takes a mask of bits to be
cleared instead of a mask of bits to be kept.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 86 ++---
 1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index f79761e..83ad97e 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -429,9 +429,9 @@ static inline int io_write(struct v4l2_subdev *sd, u8 reg, 
u8 val)
return adv_smbus_write_byte_data(state, ADV7604_PAGE_IO, reg, val);
 }
 
-static inline int io_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
+static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
 {
-   return io_write(sd, reg, (io_read(sd, reg) & mask) | val);
+   return io_write(sd, reg, (io_read(sd, reg) & ~mask) | val);
 }
 
 static inline int avlink_read(struct v4l2_subdev *sd, u8 reg)
@@ -462,9 +462,9 @@ static inline int cec_write(struct v4l2_subdev *sd, u8 reg, 
u8 val)
return adv_smbus_write_byte_data(state, ADV7604_PAGE_CEC, reg, val);
 }
 
-static inline int cec_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
+static inline int cec_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, 
u8 val)
 {
-   return cec_write(sd, reg, (cec_read(sd, reg) & mask) | val);
+   return cec_write(sd, reg, (cec_read(sd, reg) & ~mask) | val);
 }
 
 static inline int infoframe_read(struct v4l2_subdev *sd, u8 reg)
@@ -538,9 +538,9 @@ static inline int rep_write(struct v4l2_subdev *sd, u8 reg, 
u8 val)
return adv_smbus_write_byte_data(state, ADV7604_PAGE_REP, reg, val);
 }
 
-static inline int rep_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
+static inline int rep_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, 
u8 val)
 {
-   return rep_write(sd, reg, (rep_read(sd, reg) & mask) | val);
+   return rep_write(sd, reg, (rep_read(sd, reg) & ~mask) | val);
 }
 
 static inline int edid_read(struct v4l2_subdev *sd, u8 reg)
@@ -629,9 +629,9 @@ static inline int hdmi_write(struct v4l2_subdev *sd, u8 
reg, u8 val)
return adv_smbus_write_byte_data(state, ADV7604_PAGE_HDMI, reg, val);
 }
 
-static inline int hdmi_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, 
u8 val)
+static inline int hdmi_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, 
u8 val)
 {
-   return hdmi_write(sd, reg, (hdmi_read(sd, reg) & mask) | val);
+   return hdmi_write(sd, reg, (hdmi_read(sd, reg) & ~mask) | val);
 }
 
 static inline int test_read(struct v4l2_subdev *sd, u8 reg)
@@ -667,9 +667,9 @@ static inline int cp_write(struct v4l2_subdev *sd, u8 reg, 
u8 val)
return adv_smbus_write_byte_data(state, ADV7604_PAGE_CP, reg, val);
 }
 
-static inline int cp_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
+static inline int cp_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
 {
-   return cp_write(sd, reg, (cp_read(sd, reg) & mask) | val);
+   return cp_write(sd, reg, (cp_read(sd, reg) & ~mask) | val);
 }
 
 static inline int vdp_read(struct v4l2_subdev *sd, u8 reg)
@@ -947,7 +947,7 @@ static int configure_predefined_video_timings(struct 
v4l2_subdev *sd,
io_write(sd, 0x17, 0x5a);
}
/* disable embedded syncs for auto graphics mode */
-   cp_write_and_or(sd, 0x81, 0xef, 0x00);
+   cp_write_clr_set(sd, 0x81, 0x10, 0x00);
cp_write(sd, 0x8f, 0x00);
cp_write(sd, 0x90, 0x00);
cp_write(sd, 0xa2, 0x00);
@@ -1005,7 +1005,7 @@ static void configure_custom_video_timings(struct 
v4l2_subdev *sd,
io_write(sd, 0x00, 0x07); /* video std */
io_write(sd, 0x01, 0x02); /* prim mode */
/* enable embedded syncs for auto graphics mode */
-   cp_write_and_or(sd, 0x81, 0xef, 0x10);
+   cp_write_clr_set(sd, 0x81, 0x10, 0x10);
 
/* Should only be set in auto-graphics mode [REF_02, p. 91-92] 
*/
/* setup PLL_DIV_MAN_EN and PLL_DIV_RATIO */
@@ -1115,21 +1115,21 @@ static void set_rgb_quantization_range(struct 
v4l2_subdev *sd)
if (state->selected_input == ADV7604_PAD_VGA_RGB) {
/* Receiving analog RGB signal
 * Set RGB full range (0-255) */
-   io_write_and_or(sd, 0x02, 0x0f, 0x10);
+   io_write_clr_set(sd, 0x02, 0xf0, 0x10);
break;
}
 
if (state->selected_input == ADV7604_PAD_VGA_COMP) {
/* Receiving analog YPbPr signal

[PATCH v2 45/48] adv7604: Specify the default input through platform data

2014-03-10 Thread Laurent Pinchart
And set input routing when initializing the device.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 7 +++
 include/media/adv7604.h | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 7f70c6f..cce140c 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2404,6 +2404,13 @@ static int adv7604_core_init(struct v4l2_subdev *sd)
 
disable_input(sd);
 
+   if (pdata->default_input >= 0 &&
+   pdata->default_input < state->source_pad) {
+   state->selected_input = pdata->default_input;
+   select_input(sd);
+   enable_input(sd);
+   }
+
/* power */
io_write(sd, 0x0c, 0x42);   /* Power up part and power down VDP */
io_write(sd, 0x0b, 0x44);   /* Power down ESDP block */
diff --git a/include/media/adv7604.h b/include/media/adv7604.h
index a1798d6..6d69207 100644
--- a/include/media/adv7604.h
+++ b/include/media/adv7604.h
@@ -90,6 +90,8 @@ struct adv7604_platform_data {
/* DIS_CABLE_DET_RST: 1 if the 5V pins are unused and unconnected */
unsigned disable_cable_det_rst:1;
 
+   int default_input;
+
/* Analog input muxing mode */
enum adv7604_ain_sel ain_sel;
 
-- 
1.8.3.2

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


[PATCH v2 37/48] adv7604: Add pad-level DV timings support

2014-03-10 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 47 +
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 66b3481..a96c339 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1514,24 +1514,42 @@ static int read_stdi(struct v4l2_subdev *sd, struct 
stdi_readback *stdi)
 static int adv7604_enum_dv_timings(struct v4l2_subdev *sd,
struct v4l2_enum_dv_timings *timings)
 {
+   struct adv7604_state *state = to_state(sd);
+
if (timings->index >= ARRAY_SIZE(adv7604_timings) - 1)
return -EINVAL;
+
+   if (timings->pad >= state->source_pad)
+   return -EINVAL;
+
memset(timings->reserved, 0, sizeof(timings->reserved));
timings->timings = adv7604_timings[timings->index];
return 0;
 }
 
-static int adv7604_dv_timings_cap(struct v4l2_subdev *sd,
-   struct v4l2_dv_timings_cap *cap)
+static int __adv7604_dv_timings_cap(struct v4l2_subdev *sd,
+   struct v4l2_dv_timings_cap *cap,
+   unsigned int pad)
 {
cap->type = V4L2_DV_BT_656_1120;
cap->bt.max_width = 1920;
cap->bt.max_height = 1200;
cap->bt.min_pixelclock = 2500;
-   if (is_digital_input(sd))
+
+   switch (pad) {
+   case ADV7604_PAD_HDMI_PORT_A:
+   case ADV7604_PAD_HDMI_PORT_B:
+   case ADV7604_PAD_HDMI_PORT_C:
+   case ADV7604_PAD_HDMI_PORT_D:
cap->bt.max_pixelclock = 22500;
-   else
+   break;
+   case ADV7604_PAD_VGA_RGB:
+   case ADV7604_PAD_VGA_COMP:
+   default:
cap->bt.max_pixelclock = 17000;
+   break;
+   }
+
cap->bt.standards = V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT;
cap->bt.capabilities = V4L2_DV_BT_CAP_PROGRESSIVE |
@@ -1539,6 +1557,25 @@ static int adv7604_dv_timings_cap(struct v4l2_subdev *sd,
return 0;
 }
 
+static int adv7604_dv_timings_cap(struct v4l2_subdev *sd,
+   struct v4l2_dv_timings_cap *cap)
+{
+   struct adv7604_state *state = to_state(sd);
+
+   return __adv7604_dv_timings_cap(sd, cap, state->selected_input);
+}
+
+static int adv7604_pad_dv_timings_cap(struct v4l2_subdev *sd,
+   struct v4l2_dv_timings_cap *cap)
+{
+   struct adv7604_state *state = to_state(sd);
+
+   if (cap->pad >= state->source_pad)
+   return -EINVAL;
+
+   return __adv7604_dv_timings_cap(sd, cap, cap->pad);
+}
+
 /* Fill the optional fields .standards and .flags in struct v4l2_dv_timings
if the format is listed in adv7604_timings[] */
 static void adv7604_fill_optional_dv_timings_fields(struct v4l2_subdev *sd,
@@ -2389,6 +2426,8 @@ static const struct v4l2_subdev_pad_ops adv7604_pad_ops = 
{
.set_fmt = adv7604_set_format,
.get_edid = adv7604_get_edid,
.set_edid = adv7604_set_edid,
+   .dv_timings_cap = adv7604_pad_dv_timings_cap,
+   .enum_dv_timings = adv7604_enum_dv_timings,
 };
 
 static const struct v4l2_subdev_ops adv7604_ops = {
-- 
1.8.3.2

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


[PATCH v2 38/48] adv7604: Remove deprecated video-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated
and unused. Remove them.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 35 +--
 1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index a96c339..d4d085c 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1527,16 +1527,20 @@ static int adv7604_enum_dv_timings(struct v4l2_subdev 
*sd,
return 0;
 }
 
-static int __adv7604_dv_timings_cap(struct v4l2_subdev *sd,
-   struct v4l2_dv_timings_cap *cap,
-   unsigned int pad)
+static int adv7604_dv_timings_cap(struct v4l2_subdev *sd,
+   struct v4l2_dv_timings_cap *cap)
 {
+   struct adv7604_state *state = to_state(sd);
+
+   if (cap->pad >= state->source_pad)
+   return -EINVAL;
+
cap->type = V4L2_DV_BT_656_1120;
cap->bt.max_width = 1920;
cap->bt.max_height = 1200;
cap->bt.min_pixelclock = 2500;
 
-   switch (pad) {
+   switch (cap->pad) {
case ADV7604_PAD_HDMI_PORT_A:
case ADV7604_PAD_HDMI_PORT_B:
case ADV7604_PAD_HDMI_PORT_C:
@@ -1557,25 +1561,6 @@ static int __adv7604_dv_timings_cap(struct v4l2_subdev 
*sd,
return 0;
 }
 
-static int adv7604_dv_timings_cap(struct v4l2_subdev *sd,
-   struct v4l2_dv_timings_cap *cap)
-{
-   struct adv7604_state *state = to_state(sd);
-
-   return __adv7604_dv_timings_cap(sd, cap, state->selected_input);
-}
-
-static int adv7604_pad_dv_timings_cap(struct v4l2_subdev *sd,
-   struct v4l2_dv_timings_cap *cap)
-{
-   struct adv7604_state *state = to_state(sd);
-
-   if (cap->pad >= state->source_pad)
-   return -EINVAL;
-
-   return __adv7604_dv_timings_cap(sd, cap, cap->pad);
-}
-
 /* Fill the optional fields .standards and .flags in struct v4l2_dv_timings
if the format is listed in adv7604_timings[] */
 static void adv7604_fill_optional_dv_timings_fields(struct v4l2_subdev *sd,
@@ -2416,8 +2401,6 @@ static const struct v4l2_subdev_video_ops 
adv7604_video_ops = {
.s_dv_timings = adv7604_s_dv_timings,
.g_dv_timings = adv7604_g_dv_timings,
.query_dv_timings = adv7604_query_dv_timings,
-   .enum_dv_timings = adv7604_enum_dv_timings,
-   .dv_timings_cap = adv7604_dv_timings_cap,
 };
 
 static const struct v4l2_subdev_pad_ops adv7604_pad_ops = {
@@ -2426,7 +2409,7 @@ static const struct v4l2_subdev_pad_ops adv7604_pad_ops = 
{
.set_fmt = adv7604_set_format,
.get_edid = adv7604_get_edid,
.set_edid = adv7604_set_edid,
-   .dv_timings_cap = adv7604_pad_dv_timings_cap,
+   .dv_timings_cap = adv7604_dv_timings_cap,
.enum_dv_timings = adv7604_enum_dv_timings,
 };
 
-- 
1.8.3.2

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


[PATCH v2 47/48] adv7604: Add LLC polarity configuration

2014-03-10 Thread Laurent Pinchart
Add an inv_llc_pol field to platform data to control the clock polarity.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 3 ++-
 include/media/adv7604.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index de44213..95cc911 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2429,7 +2429,8 @@ static int adv7604_core_init(struct v4l2_subdev *sd)
cp_write(sd, 0x69, 0x30);   /* Enable CP CSC */
 
/* VS, HS polarities */
-   io_write(sd, 0x06, 0xa0 | pdata->inv_vs_pol << 2 | pdata->inv_hs_pol << 
1);
+   io_write(sd, 0x06, 0xa0 | pdata->inv_vs_pol << 2 |
+pdata->inv_hs_pol << 1 | pdata->inv_llc_pol);
 
/* Adjust drive strength */
io_write(sd, 0x14, 0x40 | pdata->dr_str_data << 4 |
diff --git a/include/media/adv7604.h b/include/media/adv7604.h
index 6d69207..7a8462f 100644
--- a/include/media/adv7604.h
+++ b/include/media/adv7604.h
@@ -114,6 +114,7 @@ struct adv7604_platform_data {
/* IO register 0x06 */
unsigned inv_vs_pol:1;
unsigned inv_hs_pol:1;
+   unsigned inv_llc_pol:1;
 
/* IO register 0x14 */
enum adv7604_drive_strength dr_str_data;
-- 
1.8.3.2

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


[PATCH v2 48/48] adv7604: Add endpoint properties to DT bindings

2014-03-10 Thread Laurent Pinchart
Add support for the hsync-active, vsync-active and pclk-sample
properties to the DT bindings and control BT.656 mode implicitly.

Signed-off-by: Laurent Pinchart 
---
 .../devicetree/bindings/media/i2c/adv7604.txt  | 13 +
 drivers/media/i2c/adv7604.c| 31 --
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
index 0845c50..2b62c06 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -30,6 +30,19 @@ Optional Properties:
   - adi,disable-cable-reset: Boolean property. When set disables the HDMI
 receiver automatic reset when the HDMI cable is unplugged.
 
+Optional Endpoint Properties:
+
+  The following three properties are defined in video-interfaces.txt and are
+  valid for source endpoints only.
+
+  - hsync-active: Horizontal synchronization polarity. Defaults to active low.
+  - vsync-active: Vertical synchronization polarity. Defaults to active low.
+  - pclk-sample: Pixel clock polarity. Defaults to output on the falling edge.
+
+  If none of hsync-active, vsync-active and pclk-sample is specified the
+  endpoint will use embedded BT.656 synchronization.
+
+
 Example:
 
hdmi_receiver@4c {
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 95cc911..2a92099 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int debug;
 module_param(debug, int, 0644);
@@ -2643,11 +2644,39 @@ MODULE_DEVICE_TABLE(of, adv7604_of_id);
 
 static int adv7604_parse_dt(struct adv7604_state *state)
 {
+   struct v4l2_of_endpoint bus_cfg;
+   struct device_node *endpoint;
struct device_node *np;
+   unsigned int flags;
int ret;
 
np = state->i2c_clients[ADV7604_PAGE_IO]->dev.of_node;
 
+   /* Parse the endpoint. */
+   endpoint = v4l2_of_get_next_endpoint(np, NULL);
+   if (!endpoint)
+   return -EINVAL;
+
+   v4l2_of_parse_endpoint(endpoint, &bus_cfg);
+   of_node_put(endpoint);
+
+   flags = bus_cfg.bus.parallel.flags;
+
+   if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
+   state->pdata.inv_hs_pol = 1;
+
+   if (flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
+   state->pdata.inv_vs_pol = 1;
+
+   if (flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
+   state->pdata.inv_llc_pol = 1;
+
+   if (bus_cfg.bus_type == V4L2_MBUS_BT656) {
+   state->pdata.insert_av_codes = 1;
+   state->pdata.op_656_range = 1;
+   }
+
+   /* Parse device-specific properties. */
state->pdata.disable_pwrdnb =
of_property_read_bool(np, "adi,disable-power-down");
state->pdata.disable_cable_det_rst =
@@ -2677,9 +2706,7 @@ static int adv7604_parse_dt(struct adv7604_state *state)
 
/* HACK: Hardcode the remaining platform data fields. */
state->pdata.blank_data = 1;
-   state->pdata.op_656_range = 1;
state->pdata.alt_data_sat = 1;
-   state->pdata.insert_av_codes = 1;
state->pdata.op_format_mode_sel = ADV7604_OP_FORMAT_MODE0;
 
return 0;
-- 
1.8.3.2

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


[PATCH v2 46/48] adv7604: Add DT support

2014-03-10 Thread Laurent Pinchart
Parse the device tree node to populate platform data.

Cc: devicet...@vger.kernel.org
Signed-off-by: Laurent Pinchart 
---
 .../devicetree/bindings/media/i2c/adv7604.txt  | 56 +
 drivers/media/i2c/adv7604.c| 92 ++
 2 files changed, 134 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/adv7604.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt 
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
new file mode 100644
index 000..0845c50
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt
@@ -0,0 +1,56 @@
+* Analog Devices ADV7604/11 video decoder with HDMI receiver
+
+The ADV7604 and ADV7611 are multiformat video decoders with an integrated HDMI
+receiver. The ADV7604 has four multiplexed HDMI inputs and one analog input,
+and the ADV7611 has one HDMI input and no analog input.
+
+Required Properties:
+
+  - compatible: Must contain one of the following
+- "adi,adv7604" for the ADV7604
+- "adi,adv7611" for the ADV7611
+
+  - reg: I2C slave address
+
+  - hpd-gpios: References to the GPIOs that control the HDMI hot-plug
+detection pins, one per HDMI input. The active flag indicates the GPIO
+level that enables hot-plug detection.
+
+Optional Properties:
+
+  - reset-gpios: Reference to the GPIO connected to the device's reset pin.
+
+  - adi,default-input: Index of the input to be configured as default. Valid
+values are 0..5 for the ADV7604 and 0 for the ADV7611.
+
+  - adi,disable-power-down: Boolean property. When set forces the device to
+ignore the power-down pin. The property is valid for the ADV7604 only as
+the ADV7611 has no power-down pin.
+
+  - adi,disable-cable-reset: Boolean property. When set disables the HDMI
+receiver automatic reset when the HDMI cable is unplugged.
+
+Example:
+
+   hdmi_receiver@4c {
+   compatible = "adi,adv7611";
+   reg = <0x4c>;
+
+   reset-gpios = <&ioexp 0 GPIO_ACTIVE_LOW>;
+   hpd-gpios = <&ioexp 2 GPIO_ACTIVE_HIGH>;
+
+   adi,default-input = <0>;
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   };
+   port@1 {
+   reg = <1>;
+   hdmi_in: endpoint {
+   remote-endpoint = <&ccdc_in>;
+   };
+   };
+   };
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index cce140c..de44213 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2626,13 +2626,70 @@ static const struct adv7604_chip_info 
adv7604_chip_info[] = {
},
 };
 
+static struct i2c_device_id adv7604_i2c_id[] = {
+   { "adv7604", (kernel_ulong_t)&adv7604_chip_info[ADV7604] },
+   { "adv7611", (kernel_ulong_t)&adv7604_chip_info[ADV7611] },
+   { }
+};
+MODULE_DEVICE_TABLE(i2c, adv7604_i2c_id);
+
+static struct of_device_id adv7604_of_id[] = {
+   { .compatible = "adi,adv7604", .data = &adv7604_chip_info[ADV7604] },
+   { .compatible = "adi,adv7611", .data = &adv7604_chip_info[ADV7611] },
+   { }
+};
+MODULE_DEVICE_TABLE(of, adv7604_of_id);
+
+static int adv7604_parse_dt(struct adv7604_state *state)
+{
+   struct device_node *np;
+   int ret;
+
+   np = state->i2c_clients[ADV7604_PAGE_IO]->dev.of_node;
+
+   state->pdata.disable_pwrdnb =
+   of_property_read_bool(np, "adi,disable-power-down");
+   state->pdata.disable_cable_det_rst =
+   of_property_read_bool(np, "adi,disable-cable-reset");
+
+   ret = of_property_read_u32(np, "adi,default-input",
+  &state->pdata.default_input);
+   if (ret < 0)
+   state->pdata.default_input = -1;
+
+   /* Disable the interrupt for now as no DT-based board uses it. */
+   state->pdata.int1_config = ADV7604_INT1_CONFIG_DISABLED;
+
+   /* Use the default I2C addresses. */
+   state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] = 0x42;
+   state->pdata.i2c_addresses[ADV7604_PAGE_CEC] = 0x40;
+   state->pdata.i2c_addresses[ADV7604_PAGE_INFOFRAME] = 0x3e;
+   state->pdata.i2c_addresses[ADV7604_PAGE_ESDP] = 0x38;
+   state->pdata.i2c_addresses[ADV7604_PAGE_DPP] = 0x3c;
+   state->pdata.i2c_addresses[ADV7604_PAGE_AFE] = 0x26;
+   state->pdata.i2c_addresses[ADV7604_PAGE_REP] = 0x32;
+   state->pdata.i2c_addresses[ADV7604_PAGE_EDID] = 0x36;
+   state->pdata.i2c_addresses[ADV7604_PAGE_HDMI] = 0x34;
+   state->pdata.i2c_addresses[ADV7604_PAGE_TEST] = 0x30;
+   state->pdata.i2c_addresses[ADV7604_PAGE_CP] = 0x22;
+   state->pdata.i2c_addresses[ADV7604_PAGE_VDP] = 0x24;
+
+   /* HACK: Hardcode the remaining platform data fields. */
+   state->pdata.blank_data = 1;
+   state->pdata.op_656

[PATCH v2 23/48] ths8200: Remove deprecated video-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated
and unused. Remove them.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/ths8200.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c
index c4ec8b2..656d889 100644
--- a/drivers/media/i2c/ths8200.c
+++ b/drivers/media/i2c/ths8200.c
@@ -432,8 +432,6 @@ static const struct v4l2_subdev_video_ops ths8200_video_ops 
= {
.s_stream = ths8200_s_stream,
.s_dv_timings = ths8200_s_dv_timings,
.g_dv_timings = ths8200_g_dv_timings,
-   .enum_dv_timings = ths8200_enum_dv_timings,
-   .dv_timings_cap = ths8200_dv_timings_cap,
 };
 
 static const struct v4l2_subdev_pad_ops ths8200_pad_ops = {
-- 
1.8.3.2

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


[PATCH v2 03/48] v4l: Add UYVY10_1X20 and VYUY10_1X20 media bus pixel codes

2014-03-10 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 104 +
 include/uapi/linux/v4l2-mediabus.h |   4 +-
 2 files changed, 107 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index 6fb58de..e3cbbb4 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -2436,6 +2436,110 @@
  v1
  v0

+   
+ V4L2_MBUS_FMT_UYVY10_1X20
+ 0x201a
+ 
+ &dash-ent-12;
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-12;
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ V4L2_MBUS_FMT_VYUY10_1X20
+ 0x201b
+ 
+ &dash-ent-12;
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-12;
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   

  V4L2_MBUS_FMT_YUYV10_1X20
  0x200d
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 20a99b1..43707b2 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -52,7 +52,7 @@ enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_RGB888_2X12_LE = 0x100c,
V4L2_MBUS_FMT_ARGB_1X32 = 0x100d,
 
-   /* YUV (including grey) - next is 0x201a */
+   /* YUV (including grey) - next is 0x201c */
V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
V4L2_MBUS_FMT_UV8_1X8 = 0x2015,
V4L2_MBUS_FMT_UYVY8_1_5X8 = 0x2002,
@@ -74,6 +74,8 @@ enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_YUYV8_1X16 = 0x2011,
V4L2_MBUS_FMT_YVYU8_1X16 = 0x2012,
V4L2_MBUS_FMT_YDYUYDYV8_1X16 = 0x2014,
+   V4L2_MBUS_FMT_UYVY10_1X20 = 0x201a,
+   V4L2_MBUS_FMT_VYUY10_1X20 = 0x201b,
V4L2_MBUS_FMT_YUYV10_1X20 = 0x200d,
V4L2_MBUS_FMT_YVYU10_1X20 = 0x200e,
V4L2_MBUS_FMT_YUV10_1X30 = 0x2016,
-- 
1.8.3.2

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


[PATCH v2 05/48] v4l: Add 12-bit YUV 4:2:2 media bus pixel codes

2014-03-10 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 240 +
 include/uapi/linux/v4l2-mediabus.h |   6 +-
 2 files changed, 245 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index a0fa7e0..b2d5a03 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -3006,6 +3006,246 @@
  u1
  u0

+   
+ V4L2_MBUS_FMT_UYVY12_1X24
+ 0x2020
+ 
+ &dash-ent-8;
+ u11
+ u10
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-8;
+ v11
+ v10
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ V4L2_MBUS_FMT_VYUY12_1X24
+ 0x2021
+ 
+ &dash-ent-8;
+ v11
+ v10
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ 
+ 
+ 
+ &dash-ent-8;
+ u11
+ u10
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+   
+   
+ V4L2_MBUS_FMT_YUYV12_1X24
+ 0x2022
+ 
+ &dash-ent-8;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+ u11
+ u10
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+   
+   
+ 
+ 
+ 
+ &dash-ent-8;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+ v11
+ v10
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+   
+   
+ V4L2_MBUS_FMT_YVYU12_1X24
+ 0x2023
+ 
+ &dash-ent-8;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+ v11
+ v10
+ v9
+ v8
+ v7
+ v6
+ v5
+ v4
+ v3
+ v2
+ v1
+ v0
+   
+   
+ 
+ 
+ 
+ &dash-ent-8;
+ y11
+ y10
+ y9
+ y8
+ y7
+ y6
+ y5
+ y4
+ y3
+ y2
+ y1
+ y0
+ u11
+ u10
+ u9
+ u8
+ u7
+ u6
+ u5
+ u4
+ u3
+ u2
+ u1
+ u0
+   
  

   
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 70a732b..1445e85 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/l

[PATCH v2 13/48] tvp7002: Add pad-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings operation is deprecated. Implement the
pad-level version of the operation to prepare for the removal of the
video version.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/i2c/tvp7002.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 912e1cc..9f56fd5 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -832,6 +832,9 @@ static int tvp7002_log_status(struct v4l2_subdev *sd)
 static int tvp7002_enum_dv_timings(struct v4l2_subdev *sd,
struct v4l2_enum_dv_timings *timings)
 {
+   if (timings->pad != 0)
+   return -EINVAL;
+
/* Check requested format index is within range */
if (timings->index >= NUM_TIMINGS)
return -EINVAL;
@@ -937,6 +940,7 @@ static const struct v4l2_subdev_pad_ops tvp7002_pad_ops = {
.enum_mbus_code = tvp7002_enum_mbus_code,
.get_fmt = tvp7002_get_pad_format,
.set_fmt = tvp7002_set_pad_format,
+   .enum_dv_timings = tvp7002_enum_dv_timings,
 };
 
 /* V4L2 top level operation handlers */
-- 
1.8.3.2

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


[PATCH v2 27/48] v4l: Validate fields in the core code for subdev EDID ioctls

2014-03-10 Thread Laurent Pinchart
The subdev EDID ioctls receive a pad field that must reference an
existing pad and an EDID field that must point to a buffer. Validate
both fields in the core code instead of duplicating validation in all
drivers.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/ad9389b.c   |  2 --
 drivers/media/i2c/adv7511.c   |  2 --
 drivers/media/i2c/adv7604.c   |  4 
 drivers/media/i2c/adv7842.c   |  4 
 drivers/media/v4l2-core/v4l2-subdev.c | 24 
 5 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 4cdff9e..5b78828 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -683,8 +683,6 @@ static int ad9389b_get_edid(struct v4l2_subdev *sd,
return -EINVAL;
if (edid->blocks == 0 || edid->blocks > 256)
return -EINVAL;
-   if (!edid->edid)
-   return -EINVAL;
if (!state->edid.segments) {
v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
return -ENODATA;
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index de7ddf5..ff1c2cd 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -784,8 +784,6 @@ static int adv7511_get_edid(struct v4l2_subdev *sd,
return -EINVAL;
if ((edid->blocks == 0) || (edid->blocks > 256))
return -EINVAL;
-   if (!edid->edid)
-   return -EINVAL;
if (!state->edid.segments) {
v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
return -ENODATA;
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 71c8570..de3db42 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1673,8 +1673,6 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *edi
return -EINVAL;
if (edid->start_block == 1)
edid->blocks = 1;
-   if (!edid->edid)
-   return -EINVAL;
 
if (edid->blocks > state->edid.blocks)
edid->blocks = state->edid.blocks;
@@ -1761,8 +1759,6 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *edi
edid->blocks = 2;
return -E2BIG;
}
-   if (!edid->edid)
-   return -EINVAL;
 
v4l2_dbg(2, debug, sd, "%s: write EDID pad %d, edid.present = 0x%x\n",
__func__, edid->pad, state->edid.present);
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 7fd9325..33558c8 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2035,8 +2035,6 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *edi
return -EINVAL;
if (edid->start_block == 1)
edid->blocks = 1;
-   if (!edid->edid)
-   return -EINVAL;
 
switch (edid->pad) {
case ADV7842_EDID_PORT_A:
@@ -2071,8 +2069,6 @@ static int adv7842_set_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *e)
return -EINVAL;
if (e->blocks > 2)
return -E2BIG;
-   if (!e->edid)
-   return -EINVAL;
 
/* todo, per edid */
state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15],
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 853fb84..9fff1eb 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -349,11 +349,27 @@ static long subdev_do_ioctl(struct file *file, unsigned 
int cmd, void *arg)
sd, pad, set_selection, subdev_fh, sel);
}
 
-   case VIDIOC_SUBDEV_G_EDID:
-   return v4l2_subdev_call(sd, pad, get_edid, arg);
+   case VIDIOC_SUBDEV_G_EDID: {
+   struct v4l2_subdev_edid *edid = arg;
 
-   case VIDIOC_SUBDEV_S_EDID:
-   return v4l2_subdev_call(sd, pad, set_edid, arg);
+   if (edid->pad >= sd->entity.num_pads)
+   return -EINVAL;
+   if (edid->edid == NULL)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, get_edid, edid);
+   }
+
+   case VIDIOC_SUBDEV_S_EDID: {
+   struct v4l2_subdev_edid *edid = arg;
+
+   if (edid->pad >= sd->entity.num_pads)
+   return -EINVAL;
+   if (edid->edid == NULL)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, set_edid, edid);
+   }
 
case VIDIOC_SUBDEV_DV_TIMINGS_CAP: {
struct v4l2_dv_timings_cap *cap = arg;
-- 
1.8.3.2

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

[PATCH v2 30/48] adv7604: Don't put info string arrays on the stack

2014-03-10 Thread Laurent Pinchart
From: Lars-Peter Clausen 

We do not want to modify the info string arrays ever, so no need to
waste stack space for them. While we are at it also make them const.

Signed-off-by: Lars-Peter Clausen 
Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index c3a76ac..81d737c 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1882,13 +1882,13 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
struct stdi_readback stdi;
u8 reg_io_0x02 = io_read(sd, 0x02);
 
-   char *csc_coeff_sel_rb[16] = {
+   static const char * const csc_coeff_sel_rb[16] = {
"bypassed", "YPbPr601 -> RGB", "reserved", "YPbPr709 -> RGB",
"reserved", "RGB -> YPbPr601", "reserved", "RGB -> YPbPr709",
"reserved", "YPbPr709 -> YPbPr601", "YPbPr601 -> YPbPr709",
"reserved", "reserved", "reserved", "reserved", "manual"
};
-   char *input_color_space_txt[16] = {
+   static const char * const input_color_space_txt[16] = {
"RGB limited range (16-235)", "RGB full range (0-255)",
"YCbCr Bt.601 (16-235)", "YCbCr Bt.709 (16-235)",
"xvYCC Bt.601", "xvYCC Bt.709",
@@ -1896,12 +1896,12 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
"invalid", "invalid", "invalid", "invalid", "invalid",
"invalid", "invalid", "automatic"
};
-   char *rgb_quantization_range_txt[] = {
+   static const char * const rgb_quantization_range_txt[] = {
"Automatic",
"RGB limited range (16-235)",
"RGB full range (0-255)",
};
-   char *deep_color_mode_txt[4] = {
+   static const char * const deep_color_mode_txt[4] = {
"8-bits per channel",
"10-bits per channel",
"12-bits per channel",
-- 
1.8.3.2

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


[PATCH v2 29/48] adv7604: Add support for asynchronous probing

2014-03-10 Thread Laurent Pinchart
From: Lars-Peter Clausen 

Signed-off-by: Lars-Peter Clausen 
Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index de3db42..c3a76ac 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2333,6 +2333,11 @@ static int adv7604_probe(struct i2c_client *client,
goto err_entity;
v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
client->addr << 1, client->adapter->name);
+
+   err = v4l2_async_register_subdev(sd);
+   if (err)
+   goto err_entity;
+
return 0;
 
 err_entity:
@@ -2356,6 +2361,7 @@ static int adv7604_remove(struct i2c_client *client)
 
cancel_delayed_work(&state->delayed_work_enable_hotplug);
destroy_workqueue(state->work_queues);
+   v4l2_async_unregister_subdev(sd);
v4l2_device_unregister_subdev(sd);
media_entity_cleanup(&sd->entity);
adv7604_unregister_clients(to_state(sd));
-- 
1.8.3.2

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


[PATCH v2 01/48] v4l: of: Support empty port nodes

2014-03-10 Thread Laurent Pinchart
Empty port nodes are allowed but currently unsupported as the
v4l2_of_get_next_endpoint() function assumes that all port nodes have at
least an endpoint. Fix this.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/v4l2-core/v4l2-of.c | 52 +--
 1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-of.c 
b/drivers/media/v4l2-core/v4l2-of.c
index 42e3e8a..4c07343 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -166,43 +166,51 @@ struct device_node *v4l2_of_get_next_endpoint(const 
struct device_node *parent,
struct device_node *prev)
 {
struct device_node *endpoint;
-   struct device_node *port = NULL;
+   struct device_node *port;
 
if (!parent)
return NULL;
 
+   /*
+* Start by locating the port node. If no previous endpoint is specified
+* search for the first port node, otherwise get the previous endpoint
+* parent port node.
+*/
if (!prev) {
struct device_node *node;
-   /*
-* It's the first call, we have to find a port subnode
-* within this node or within an optional 'ports' node.
-*/
+
node = of_get_child_by_name(parent, "ports");
if (node)
parent = node;
 
port = of_get_child_by_name(parent, "port");
+   of_node_put(node);
 
-   if (port) {
-   /* Found a port, get an endpoint. */
-   endpoint = of_get_next_child(port, NULL);
-   of_node_put(port);
-   } else {
-   endpoint = NULL;
-   }
-
-   if (!endpoint)
-   pr_err("%s(): no endpoint nodes specified for %s\n",
+   if (!port) {
+   pr_err("%s(): no port node found in %s\n",
   __func__, parent->full_name);
-   of_node_put(node);
+   return NULL;
+   }
} else {
port = of_get_parent(prev);
-   if (!port)
+   if (!port) {
/* Hm, has someone given us the root node ?... */
return NULL;
+   }
 
-   /* Avoid dropping prev node refcount to 0. */
+   /*
+* Avoid dropping prev node refcount to 0 when getting the next
+* child below.
+*/
of_node_get(prev);
+   }
+
+   while (1) {
+   /*
+* Now that we have a port node, get the next endpoint by
+* getting the next child. If the previous endpoint is NULL this
+* will return the first child.
+*/
endpoint = of_get_next_child(port, prev);
if (endpoint) {
of_node_put(port);
@@ -210,18 +218,14 @@ struct device_node *v4l2_of_get_next_endpoint(const 
struct device_node *parent,
}
 
/* No more endpoints under this port, try the next one. */
+   prev = NULL;
+
do {
port = of_get_next_child(parent, port);
if (!port)
return NULL;
} while (of_node_cmp(port->name, "port"));
-
-   /* Pick up the first endpoint in this port. */
-   endpoint = of_get_next_child(port, NULL);
-   of_node_put(port);
}
-
-   return endpoint;
 }
 EXPORT_SYMBOL(v4l2_of_get_next_endpoint);
 
-- 
1.8.3.2

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


[PATCH v2 43/48] adv7604: Sort headers alphabetically

2014-03-10 Thread Laurent Pinchart
This helps locating duplicates and inserting new headers.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 83ad97e..0c81c72 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -27,19 +27,19 @@
  * REF_03 - Analog devices, ADV7604, Hardware Manual, Rev. F, August 2010
  */
 
-
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
 #include 
 #include 
-#include 
-#include 
+
+#include 
 #include 
+#include 
 #include 
-#include 
 
 static int debug;
 module_param(debug, int, 0644);
-- 
1.8.3.2

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


[PATCH v2 10/48] s5p-tv: hdmi: Add pad-level DV timings operations

2014-03-10 Thread Laurent Pinchart
The video enum_dv_timings and dv_timings_cap operations are deprecated.
Implement the pad-level version of those operations to prepare for the
removal of the video version.

Cc: Kyungmin Park 
Cc: Tomasz Stanislawski 
Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
---
 drivers/media/platform/s5p-tv/hdmi_drv.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c 
b/drivers/media/platform/s5p-tv/hdmi_drv.c
index 534722c..3db496c 100644
--- a/drivers/media/platform/s5p-tv/hdmi_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmi_drv.c
@@ -674,6 +674,8 @@ static int hdmi_g_mbus_fmt(struct v4l2_subdev *sd,
 static int hdmi_enum_dv_timings(struct v4l2_subdev *sd,
struct v4l2_enum_dv_timings *timings)
 {
+   if (timings->pad != 0)
+   return -EINVAL;
if (timings->index >= ARRAY_SIZE(hdmi_timings))
return -EINVAL;
timings->timings = hdmi_timings[timings->index].dv_timings;
@@ -687,6 +689,9 @@ static int hdmi_dv_timings_cap(struct v4l2_subdev *sd,
 {
struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
 
+   if (cap->pad != 0)
+   return -EINVAL;
+
/* Let the phy fill in the pixelclock range */
v4l2_subdev_call(hdev->phy_sd, video, dv_timings_cap, cap);
cap->type = V4L2_DV_BT_656_1120;
@@ -713,6 +718,11 @@ static const struct v4l2_subdev_video_ops 
hdmi_sd_video_ops = {
.s_stream = hdmi_s_stream,
 };
 
+static const struct v4l2_subdev_pad_ops hdmi_sd_pad_ops = {
+   .enum_dv_timings = hdmi_enum_dv_timings,
+   .dv_timings_cap = hdmi_dv_timings_cap,
+};
+
 static const struct v4l2_subdev_ops hdmi_sd_ops = {
.core = &hdmi_sd_core_ops,
.video = &hdmi_sd_video_ops,
-- 
1.8.3.2

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


[PATCH v2 35/48] adv7604: Add sink pads

2014-03-10 Thread Laurent Pinchart
The ADV7604 has sink pads for its HDMI and analog inputs. Report them.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/i2c/adv7604.c | 61 ++---
 include/media/adv7604.h | 23 -
 2 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index dc7f6e0..851b350 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -97,13 +97,15 @@ struct adv7604_chip_info {
  *
  **
  */
+
 struct adv7604_state {
const struct adv7604_chip_info *info;
struct adv7604_platform_data pdata;
struct v4l2_subdev sd;
-   struct media_pad pad;
+   struct media_pad pads[ADV7604_PAD_MAX];
+   unsigned int source_pad;
struct v4l2_ctrl_handler hdl;
-   enum adv7604_input_port selected_input;
+   enum adv7604_pad selected_input;
struct v4l2_dv_timings timings;
struct {
u8 edid[256];
@@ -775,18 +777,18 @@ static inline bool is_analog_input(struct v4l2_subdev *sd)
 {
struct adv7604_state *state = to_state(sd);
 
-   return state->selected_input == ADV7604_INPUT_VGA_RGB ||
-  state->selected_input == ADV7604_INPUT_VGA_COMP;
+   return state->selected_input == ADV7604_PAD_VGA_RGB ||
+  state->selected_input == ADV7604_PAD_VGA_COMP;
 }
 
 static inline bool is_digital_input(struct v4l2_subdev *sd)
 {
struct adv7604_state *state = to_state(sd);
 
-   return state->selected_input == ADV7604_INPUT_HDMI_PORT_A ||
-  state->selected_input == ADV7604_INPUT_HDMI_PORT_B ||
-  state->selected_input == ADV7604_INPUT_HDMI_PORT_C ||
-  state->selected_input == ADV7604_INPUT_HDMI_PORT_D;
+   return state->selected_input == ADV7604_PAD_HDMI_PORT_A ||
+  state->selected_input == ADV7604_PAD_HDMI_PORT_B ||
+  state->selected_input == ADV7604_PAD_HDMI_PORT_C ||
+  state->selected_input == ADV7604_PAD_HDMI_PORT_D;
 }
 
 /* --- */
@@ -1066,14 +1068,14 @@ static void set_rgb_quantization_range(struct 
v4l2_subdev *sd)
 
switch (state->rgb_quantization_range) {
case V4L2_DV_RGB_RANGE_AUTO:
-   if (state->selected_input == ADV7604_INPUT_VGA_RGB) {
+   if (state->selected_input == ADV7604_PAD_VGA_RGB) {
/* Receiving analog RGB signal
 * Set RGB full range (0-255) */
io_write_and_or(sd, 0x02, 0x0f, 0x10);
break;
}
 
-   if (state->selected_input == ADV7604_INPUT_VGA_COMP) {
+   if (state->selected_input == ADV7604_PAD_VGA_COMP) {
/* Receiving analog YPbPr signal
 * Set automode */
io_write_and_or(sd, 0x02, 0x0f, 0xf0);
@@ -1106,7 +1108,7 @@ static void set_rgb_quantization_range(struct v4l2_subdev 
*sd)
}
break;
case V4L2_DV_RGB_RANGE_LIMITED:
-   if (state->selected_input == ADV7604_INPUT_VGA_COMP) {
+   if (state->selected_input == ADV7604_PAD_VGA_COMP) {
/* YCrCb limited range (16-235) */
io_write_and_or(sd, 0x02, 0x0f, 0x20);
break;
@@ -1117,7 +1119,7 @@ static void set_rgb_quantization_range(struct v4l2_subdev 
*sd)
 
break;
case V4L2_DV_RGB_RANGE_FULL:
-   if (state->selected_input == ADV7604_INPUT_VGA_COMP) {
+   if (state->selected_input == ADV7604_PAD_VGA_COMP) {
/* YCrCb full range (0-255) */
io_write_and_or(sd, 0x02, 0x0f, 0x60);
break;
@@ -1806,7 +1808,7 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *edi
struct adv7604_state *state = to_state(sd);
u8 *data = NULL;
 
-   if (edid->pad > ADV7604_EDID_PORT_D)
+   if (edid->pad > ADV7604_PAD_HDMI_PORT_D)
return -EINVAL;
if (edid->blocks == 0)
return -EINVAL;
@@ -1821,10 +1823,10 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, 
struct v4l2_subdev_edid *edi
edid->blocks = state->edid.blocks;
 
switch (edid->pad) {
-   case ADV7604_EDID_PORT_A:
-   case ADV7604_EDID_PORT_B:
-   case ADV7604_EDID_PORT_C:
-   case ADV7604_EDID_PORT_D:
+   case ADV7604_PAD_HDMI_PORT_A:
+   case ADV7604_PAD_HDMI_PORT_B:
+   case ADV7604_PAD_HDMI_PORT_C:
+   case ADV7604_PAD_HDMI_PORT_D:
if (state->edid.present & (1 << edid->pad))
data = state->edid.edid;
break;
@@ -1878,7 +1880,7 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, 
s

[PATCH v2 00/48] ADV7611 support

2014-03-10 Thread Laurent Pinchart
Hello,

This patch set implements support for the ADV7611 in the adv7604 driver. It
also comes up with new features such as output format configuration through
pad format operations, hot-plug detect control through GPIO and DT support.

Patches 06/48 to 24/48 and 39/48 replace the subdev video DV timings query cap
and enum operations with pad-level equivalents. I've split driver changes in
one patch per driver to make review easier, but I can squash them together if
desired.

I believe I've addressed all comments received on v1, except the one related
to op_ch_sel in patch "adv7604: Make output format configurable through pad
format operations" which is still open for discussion.

Patches 02/48 to 05/48 have been acked in v1 already, I will send a pull
request for them separately if a v3 of this series ends up being needed. I'd
like to get patch 01/48 upstream soon as well.

Changes compared to v1:

- Check the edid and pad fields for various ioctls in the subdev core
- Switch to the descriptor-based GPIO API
- Leave enum adv7604_pad in header file
- Keep the hotplug notifier
- Fix compilation breakage when !CONFIG_OF due to directly dereferencing the
  return value of of_match_node()
- Move patch "v4l: subdev: Remove deprecated video-level DV timings
  operations" later in the series to avoid bisection breakages
- Document struct v4l2_enum_dv_timings reserved field as being set to 0 by
  both drivers and application
- Document pad field of struct v4l2_enum_dv_timings and struct
  v4l2_dv_timings_cap as being used for subdev nodes only
- Typo fixes in documentation

Cc: Kyungmin Park 
Cc: Tomasz Stanislawski 
Cc: Scott Jiang 
Cc: Prabhakar Lad 

Lars-Peter Clausen (4):
  adv7604: Add missing include to linux/types.h
  adv7604: Add support for asynchronous probing
  adv7604: Don't put info string arrays on the stack
  adv7604: Add adv7611 support

Laurent Pinchart (44):
  v4l: of: Support empty port nodes
  v4l: Add UYVY10_2X10 and VYUY10_2X10 media bus pixel codes
  v4l: Add UYVY10_1X20 and VYUY10_1X20 media bus pixel codes
  v4l: Add 12-bit YUV 4:2:0 media bus pixel codes
  v4l: Add 12-bit YUV 4:2:2 media bus pixel codes
  v4l: Add pad-level DV timings subdev operations
  ad9389b: Add pad-level DV timings operations
  adv7511: Add pad-level DV timings operations
  adv7842: Add pad-level DV timings operations
  s5p-tv: hdmi: Add pad-level DV timings operations
  s5p-tv: hdmiphy: Add pad-level DV timings operations
  ths8200: Add pad-level DV timings operations
  tvp7002: Add pad-level DV timings operations
  media: bfin_capture: Switch to pad-level DV operations
  media: davinci: vpif: Switch to pad-level DV operations
  media: staging: davinci: vpfe: Switch to pad-level DV operations
  s5p-tv: mixer: Switch to pad-level DV operations
  ad9389b: Remove deprecated video-level DV timings operations
  adv7511: Remove deprecated video-level DV timings operations
  adv7842: Remove deprecated video-level DV timings operations
  s5p-tv: hdmi: Remove deprecated video-level DV timings operations
  s5p-tv: hdmiphy: Remove deprecated video-level DV timings operation
  ths8200: Remove deprecated video-level DV timings operations
  tvp7002: Remove deprecated video-level DV timings operations
  v4l: Improve readability by not wrapping ioctl number #define's
  v4l: Add support for DV timings ioctls on subdev nodes
  v4l: Validate fields in the core code for subdev EDID ioctls
  adv7604: Add 16-bit read functions for CP and HDMI
  adv7604: Cache register contents when reading multiple bits
  adv7604: Remove subdev control handlers
  adv7604: Add sink pads
  adv7604: Make output format configurable through pad format operations
  adv7604: Add pad-level DV timings support
  adv7604: Remove deprecated video-level DV timings operations
  v4l: subdev: Remove deprecated video-level DV timings operations
  adv7604: Inline the to_sd function
  adv7604: Store I2C addresses and clients in arrays
  adv7604: Replace *_and_or() functions with *_clr_set()
  adv7604: Sort headers alphabetically
  adv7604: Support hot-plug detect control through a GPIO
  adv7604: Specify the default input through platform data
  adv7604: Add DT support
  adv7604: Add LLC polarity configuration
  adv7604: Add endpoint properties to DT bindings

 Documentation/DocBook/media/v4l/subdev-formats.xml |  760 +++
 .../DocBook/media/v4l/vidioc-dv-timings-cap.xml|   27 +-
 .../DocBook/media/v4l/vidioc-enum-dv-timings.xml   |   30 +-
 .../devicetree/bindings/media/i2c/adv7604.txt  |   69 +
 drivers/media/i2c/ad9389b.c|   65 +-
 drivers/media/i2c/adv7511.c|   67 +-
 drivers/media/i2c/adv7604.c| 1440 ++--
 drivers/media/i2c/adv7842.c|   14 +-
 drivers/media/i2c/ths8200.c|   10 +
 drivers/media/i2c/tvp7002.c|5 +-
 drivers/media/platform/blackfin/bfin_capture.c |4 +-
 drivers/media/pl

[PATCH v2 00/48] ADV7611 support

2014-03-10 Thread Laurent Pinchart
Hello,

This patch set implements support for the ADV7611 in the adv7604 driver. It
also comes up with new features such as output format configuration through
pad format operations, hot-plug detect control through GPIO and DT support.

Patches 06/48 to 24/48 and 39/48 replace the subdev video DV timings query cap
and enum operations with pad-level equivalents. I've split driver changes in
one patch per driver to make review easier, but I can squash them together if
desired.

I believe I've addressed all comments received on v1, except the one related
to op_ch_sel in patch "adv7604: Make output format configurable through pad
format operations" which is still open for discussion.

Patches 02/48 to 05/48 have been acked in v1 already, I will send a pull
request for them separately if a v3 of this series ends up being needed. I'd
like to get patch 01/48 upstream soon as well.

Changes compared to v1:

- Check the edid and pad fields for various ioctls in the subdev core
- Switch to the descriptor-based GPIO API
- Leave enum adv7604_pad in header file
- Keep the hotplug notifier
- Fix compilation breakage when !CONFIG_OF due to directly dereferencing the
  return value of of_match_node()
- Move patch "v4l: subdev: Remove deprecated video-level DV timings
  operations" later in the series to avoid bisection breakages
- Document struct v4l2_enum_dv_timings reserved field as being set to 0 by
  both drivers and application
- Document pad field of struct v4l2_enum_dv_timings and struct
  v4l2_dv_timings_cap as being used for subdev nodes only
- Typo fixes in documentation

Cc: Kyungmin Park 
Cc: Tomasz Stanislawski 
Cc: Scott Jiang 
Cc: Prabhakar Lad 

Lars-Peter Clausen (4):
  adv7604: Add missing include to linux/types.h
  adv7604: Add support for asynchronous probing
  adv7604: Don't put info string arrays on the stack
  adv7604: Add adv7611 support

Laurent Pinchart (44):
  v4l: of: Support empty port nodes
  v4l: Add UYVY10_2X10 and VYUY10_2X10 media bus pixel codes
  v4l: Add UYVY10_1X20 and VYUY10_1X20 media bus pixel codes
  v4l: Add 12-bit YUV 4:2:0 media bus pixel codes
  v4l: Add 12-bit YUV 4:2:2 media bus pixel codes
  v4l: Add pad-level DV timings subdev operations
  ad9389b: Add pad-level DV timings operations
  adv7511: Add pad-level DV timings operations
  adv7842: Add pad-level DV timings operations
  s5p-tv: hdmi: Add pad-level DV timings operations
  s5p-tv: hdmiphy: Add pad-level DV timings operations
  ths8200: Add pad-level DV timings operations
  tvp7002: Add pad-level DV timings operations
  media: bfin_capture: Switch to pad-level DV operations
  media: davinci: vpif: Switch to pad-level DV operations
  media: staging: davinci: vpfe: Switch to pad-level DV operations
  s5p-tv: mixer: Switch to pad-level DV operations
  ad9389b: Remove deprecated video-level DV timings operations
  adv7511: Remove deprecated video-level DV timings operations
  adv7842: Remove deprecated video-level DV timings operations
  s5p-tv: hdmi: Remove deprecated video-level DV timings operations
  s5p-tv: hdmiphy: Remove deprecated video-level DV timings operation
  ths8200: Remove deprecated video-level DV timings operations
  tvp7002: Remove deprecated video-level DV timings operations
  v4l: Improve readability by not wrapping ioctl number #define's
  v4l: Add support for DV timings ioctls on subdev nodes
  v4l: Validate fields in the core code for subdev EDID ioctls
  adv7604: Add 16-bit read functions for CP and HDMI
  adv7604: Cache register contents when reading multiple bits
  adv7604: Remove subdev control handlers
  adv7604: Add sink pads
  adv7604: Make output format configurable through pad format operations
  adv7604: Add pad-level DV timings support
  adv7604: Remove deprecated video-level DV timings operations
  v4l: subdev: Remove deprecated video-level DV timings operations
  adv7604: Inline the to_sd function
  adv7604: Store I2C addresses and clients in arrays
  adv7604: Replace *_and_or() functions with *_clr_set()
  adv7604: Sort headers alphabetically
  adv7604: Support hot-plug detect control through a GPIO
  adv7604: Specify the default input through platform data
  adv7604: Add DT support
  adv7604: Add LLC polarity configuration
  adv7604: Add endpoint properties to DT bindings

 Documentation/DocBook/media/v4l/subdev-formats.xml |  760 +++
 .../DocBook/media/v4l/vidioc-dv-timings-cap.xml|   27 +-
 .../DocBook/media/v4l/vidioc-enum-dv-timings.xml   |   30 +-
 .../devicetree/bindings/media/i2c/adv7604.txt  |   69 +
 drivers/media/i2c/ad9389b.c|   65 +-
 drivers/media/i2c/adv7511.c|   67 +-
 drivers/media/i2c/adv7604.c| 1440 ++--
 drivers/media/i2c/adv7842.c|   14 +-
 drivers/media/i2c/ths8200.c|   10 +
 drivers/media/i2c/tvp7002.c|5 +-
 drivers/media/platform/blackfin/bfin_capture.c |4 +-
 drivers/media/pl

Re: [PATCH 36/47] adv7604: Make output format configurable through pad format operations

2014-03-10 Thread Laurent Pinchart
Hi Hans,

On Wednesday 12 February 2014 16:01:17 Hans Verkuil wrote:
> On 02/05/14 17:42, Laurent Pinchart wrote:
> > Replace the dummy video format operations by pad format operations that
> > configure the output format.
> > 
> > Signed-off-by: Laurent Pinchart 
> > ---
> > 
> >  drivers/media/i2c/adv7604.c | 243 ++-
> >  include/media/adv7604.h |  47 ++---
> >  2 files changed, 225 insertions(+), 65 deletions(-)
> 
> 
> 
> > diff --git a/include/media/adv7604.h b/include/media/adv7604.h
> > index 22811d3..2cc8e16 100644
> > --- a/include/media/adv7604.h
> > +++ b/include/media/adv7604.h
> > @@ -32,16 +32,6 @@ enum adv7604_ain_sel {
> > 
> > ADV7604_AIN9_4_5_6_SYNC_2_1 = 4,
> >  
> >  };
> > 
> > -/* Bus rotation and reordering (IO register 0x04, [7:5]) */
> > -enum adv7604_op_ch_sel {
> > -   ADV7604_OP_CH_SEL_GBR = 0,
> > -   ADV7604_OP_CH_SEL_GRB = 1,
> > -   ADV7604_OP_CH_SEL_BGR = 2,
> > -   ADV7604_OP_CH_SEL_RGB = 3,
> > -   ADV7604_OP_CH_SEL_BRG = 4,
> > -   ADV7604_OP_CH_SEL_RBG = 5,
> > -};
> > -
> >  /* Input Color Space (IO register 0x02, [7:4]) */
> >  enum adv7604_inp_color_space {
> > ADV7604_INP_COLOR_SPACE_LIM_RGB = 0,
> > @@ -55,29 +45,11 @@ enum adv7604_inp_color_space {
> > ADV7604_INP_COLOR_SPACE_AUTO = 0xf,
> >  };
> > 
> > -/* Select output format (IO register 0x03, [7:0]) */
> > -enum adv7604_op_format_sel {
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_8 = 0x00,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_10 = 0x01,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_12_MODE0 = 0x02,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_12_MODE1 = 0x06,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_12_MODE2 = 0x0a,
> > -   ADV7604_OP_FORMAT_SEL_DDR_422_8 = 0x20,
> > -   ADV7604_OP_FORMAT_SEL_DDR_422_10 = 0x21,
> > -   ADV7604_OP_FORMAT_SEL_DDR_422_12_MODE0 = 0x22,
> > -   ADV7604_OP_FORMAT_SEL_DDR_422_12_MODE1 = 0x23,
> > -   ADV7604_OP_FORMAT_SEL_DDR_422_12_MODE2 = 0x24,
> > -   ADV7604_OP_FORMAT_SEL_SDR_444_24 = 0x40,
> > -   ADV7604_OP_FORMAT_SEL_SDR_444_30 = 0x41,
> > -   ADV7604_OP_FORMAT_SEL_SDR_444_36_MODE0 = 0x42,
> > -   ADV7604_OP_FORMAT_SEL_DDR_444_24 = 0x60,
> > -   ADV7604_OP_FORMAT_SEL_DDR_444_30 = 0x61,
> > -   ADV7604_OP_FORMAT_SEL_DDR_444_36 = 0x62,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_16 = 0x80,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_20 = 0x81,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_24_MODE0 = 0x82,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_24_MODE1 = 0x86,
> > -   ADV7604_OP_FORMAT_SEL_SDR_ITU656_24_MODE2 = 0x8a,
> > +/* Select output format (IO register 0x03, [4:2]) */
> > +enum adv7604_op_format_mode_sel {
> > +   ADV7604_OP_FORMAT_MODE0 = 0x00,
> > +   ADV7604_OP_FORMAT_MODE1 = 0x04,
> > +   ADV7604_OP_FORMAT_MODE2 = 0x08,
> >  };
> >  
> >  enum adv7604_drive_strength {
> > @@ -104,11 +76,8 @@ struct adv7604_platform_data {
> > /* Analog input muxing mode */
> > enum adv7604_ain_sel ain_sel;
> > 
> > -   /* Bus rotation and reordering */
> > -   enum adv7604_op_ch_sel op_ch_sel;
> 
> I would keep this as part of the platform_data. This is typically used if
> things are wired up in a non-standard way and so is specific to the
> hardware. It is not something that will change from format to format.

Right, some level of configuration is needed to account for non-standard 
wiring. However I'm not sure where that should be handled.

With exotic wiring the format at the receiver will be different than the 
format output by the ADV7604. From a pure ADV7604 point of view, the output 
format doesn't depend on the wiring. I wonder whether this shouldn't be a link 
property instead of being a subdev property. There's of course the question of 
where to store that link property if it's not part of either subdev.

Even if we decide that the wiring is a property of the source subdev, I don't 
think we should duplicate bus reordering code in all subdev drivers. This 
should thus be handled by the v4l2 core (either directly or as helper 
functions).

> Other than this it all looks quite nice! Much more flexible than before.
>
> > -
> > -   /* Select output format */
> > -   enum adv7604_op_format_sel op_format_sel;
> > +   /* Select output format mode */
> > +   enum adv7604_op_format_mode_sel op_format_mode_sel;
> > 
> > /* Configuration of the INT1 pin */
> > enum adv7604_int1_config int1_config;
> > @@ -116,14 +85,12 @@ struct adv7604_platform_data {
> > /* IO register 0x02 */
> > unsigned alt_gamma:1;
> > unsigned op_656_range:1;
> > -   unsigned rgb_out:1;
> > unsigned alt_data_sat:1;
> > 
> > /* IO register 0x05 */
> > unsigned blank_data:1;
> > unsigned insert_av_codes:1;
> > unsigned replicate_av_codes:1;
> > -   unsigned invert_cbcr:1;
> > 
> > /* IO register 0x06 */
> > unsigned inv_vs_pol:1;

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

[REVIEW PATCH 09/11] vb2: add vb2_fileio_is_active and check it more often

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

Added a vb2_fileio_is_active inline function that returns true if fileio
is in progress. Check for this too in mmap() (you don't want apps mmap()ing
buffers used by fileio) and expbuf() (same reason).

In addition drivers should be able to check for this in queue_setup() to
return an error if an attempt is made to read() or write() with
V4L2_FIELD_ALTERNATE being configured. This is illegal (there is no way
to pass the TOP/BOTTOM information around using file I/O).

However, in order to be able to check for this the init_fileio function
needs to set q->fileio early on, before the buffers are allocated. So switch
to using internal functions (__reqbufs, vb2_internal_qbuf and
vb2_internal_streamon) to skip the fileio check. Well, that's why the internal
functions were created...

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 39 
 include/media/videobuf2-core.h   | 17 ++
 2 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 2ae316b..f68a60f 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -759,7 +759,7 @@ static int __verify_memory_type(struct vb2_queue *q,
 * create_bufs is called with count == 0, but count == 0 should still
 * do the memory and type validation.
 */
-   if (q->fileio) {
+   if (vb2_fileio_is_active(q)) {
dprintk(1, "%s: file io in progress\n", __func__);
return -EBUSY;
}
@@ -1628,7 +1628,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct 
v4l2_buffer *b)
struct vb2_buffer *vb;
int ret;
 
-   if (q->fileio) {
+   if (vb2_fileio_is_active(q)) {
dprintk(1, "%s(): file io in progress\n", __func__);
return -EBUSY;
}
@@ -1798,7 +1798,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct 
v4l2_buffer *b)
  */
 int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
-   if (q->fileio) {
+   if (vb2_fileio_is_active(q)) {
dprintk(1, "%s(): file io in progress\n", __func__);
return -EBUSY;
}
@@ -2018,7 +2018,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct 
v4l2_buffer *b, bool n
  */
 int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
 {
-   if (q->fileio) {
+   if (vb2_fileio_is_active(q)) {
dprintk(1, "%s: file io in progress\n", __func__);
return -EBUSY;
}
@@ -2148,7 +2148,7 @@ static int vb2_internal_streamon(struct vb2_queue *q, 
enum v4l2_buf_type type)
  */
 int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
 {
-   if (q->fileio) {
+   if (vb2_fileio_is_active(q)) {
dprintk(1, "%s: file io in progress\n", __func__);
return -EBUSY;
}
@@ -2195,7 +2195,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, 
enum v4l2_buf_type type)
  */
 int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
 {
-   if (q->fileio) {
+   if (vb2_fileio_is_active(q)) {
dprintk(1, "%s: file io in progress\n", __func__);
return -EBUSY;
}
@@ -2280,6 +2280,11 @@ int vb2_expbuf(struct vb2_queue *q, struct 
v4l2_exportbuffer *eb)
return -EINVAL;
}
 
+   if (vb2_fileio_is_active(q)) {
+   dprintk(1, "expbuf: file io in progress\n");
+   return -EBUSY;
+   }
+
vb_plane = &vb->planes[eb->plane];
 
dbuf = call_memop(vb, get_dmabuf, vb_plane->mem_priv, eb->flags & 
O_ACCMODE);
@@ -2356,6 +2361,10 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct 
*vma)
return -EINVAL;
}
}
+   if (vb2_fileio_is_active(q)) {
+   dprintk(1, "mmap: file io in progress\n");
+   return -EBUSY;
+   }
 
/*
 * Find the plane corresponding to the offset passed by userspace.
@@ -2467,7 +2476,7 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
*file, poll_table *wait)
/*
 * Start file I/O emulator only if streaming API has not been used yet.
 */
-   if (q->num_buffers == 0 && q->fileio == NULL) {
+   if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) {
if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) &&
(req_events & (POLLIN | POLLRDNORM))) {
if (__vb2_init_fileio(q, 1))
@@ -2672,7 +2681,8 @@ static int __vb2_init_fileio(struct vb2_queue *q, int 
read)
fileio->req.count = count;
fileio->req.memory = V4L2_MEMORY_MMAP;
fileio->req.type = q->type;
-   ret = vb2_reqbufs(q, &fileio->req);
+   q->fileio = fileio;
+   ret = __reqbufs(q, &fileio->req);
if (ret)

[REVIEW PATCH 02/11] vb2: fix handling of data_offset and v4l2_plane.reserved[]

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

The videobuf2-core did not zero the reserved array of v4l2_plane as it
should.

More serious is the fact that data_offset was not handled correctly:

- for capture devices it was never zeroed, which meant that it was
  uninitialized. Unless the driver sets it it was a completely random
  number.

- __qbuf_dmabuf had a completely incorrect length check that included
  data_offset.

- in the single-planar case data_offset was never correctly set to 0.
  The single-planar API doesn't support data_offset, so setting it
  to 0 is the right thing to do.

All these issues were found with v4l2-compliance.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index f9059bb..1a09442 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1141,6 +1141,12 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
unsigned int plane;
 
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
+   for (plane = 0; plane < vb->num_planes; ++plane) {
+   memset(v4l2_planes[plane].reserved, 0,
+  sizeof(v4l2_planes[plane].reserved));
+   v4l2_planes[plane].data_offset = 0;
+   }
+
/* Fill in driver-provided information for OUTPUT types */
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
/*
@@ -1169,8 +1175,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
b->m.planes[plane].m.fd;
v4l2_planes[plane].length =
b->m.planes[plane].length;
-   v4l2_planes[plane].data_offset =
-   b->m.planes[plane].data_offset;
}
}
} else {
@@ -1180,10 +1184,10 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
 * In videobuf we use our internal V4l2_planes struct for
 * single-planar buffers as well, for simplicity.
 */
-   if (V4L2_TYPE_IS_OUTPUT(b->type)) {
+   if (V4L2_TYPE_IS_OUTPUT(b->type))
v4l2_planes[0].bytesused = b->bytesused;
-   v4l2_planes[0].data_offset = 0;
-   }
+   /* Single-planar buffers never use data_offset */
+   v4l2_planes[0].data_offset = 0;
 
if (b->memory == V4L2_MEMORY_USERPTR) {
v4l2_planes[0].m.userptr = b->m.userptr;
@@ -1193,9 +1197,7 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
if (b->memory == V4L2_MEMORY_DMABUF) {
v4l2_planes[0].m.fd = b->m.fd;
v4l2_planes[0].length = b->length;
-   v4l2_planes[0].data_offset = 0;
}
-
}
 
/* Zero flags that the vb2 core handles */
@@ -1374,8 +1376,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
if (planes[plane].length == 0)
planes[plane].length = dbuf->size;
 
-   if (planes[plane].length < planes[plane].data_offset +
-   q->plane_sizes[plane]) {
+   if (planes[plane].length < q->plane_sizes[plane]) {
dprintk(1, "qbuf: invalid dmabuf length for plane %d\n",
plane);
ret = -EINVAL;
-- 
1.9.0

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


[REVIEW PATCH 07/11] vb2: reject output buffers with V4L2_FIELD_ALTERNATE

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

This is not allowed by the spec and does in fact not make any sense.
Return -EINVAL if this is the case.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index afd1268..8984187 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1526,6 +1526,15 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
__func__, ret);
return ret;
}
+   if (V4L2_TYPE_IS_OUTPUT(q->type) && b->field == V4L2_FIELD_ALTERNATE) {
+   /*
+* If field is ALTERNATE, then we return an error.
+* If the format's field is ALTERNATE, then the buffer's field
+* should be either TOP or BOTTOM, but using ALTERNATE here as
+* well makes no sense.
+*/
+   return -EINVAL;
+   }
 
vb->state = VB2_BUF_STATE_PREPARING;
vb->v4l2_buf.timestamp.tv_sec = 0;
-- 
1.9.0

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


[REVIEW PATCH 08/11] vb2: simplify a confusing condition.

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

q->start_streaming_called is always true, so the WARN_ON check against
it being false can be dropped.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 8984187..2ae316b 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1099,9 +1099,8 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum 
vb2_buffer_state state)
if (!q->start_streaming_called) {
if (WARN_ON(state != VB2_BUF_STATE_QUEUED))
state = VB2_BUF_STATE_QUEUED;
-   } else if (!WARN_ON(!q->start_streaming_called)) {
-   if (WARN_ON(state != VB2_BUF_STATE_DONE &&
-   state != VB2_BUF_STATE_ERROR))
+   } else if (WARN_ON(state != VB2_BUF_STATE_DONE &&
+  state != VB2_BUF_STATE_ERROR)) {
state = VB2_BUF_STATE_ERROR;
}
 
-- 
1.9.0

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


[REVIEW PATCH 03/11] vb2: if bytesused is 0, then fill with output buffer length

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

The application should really always fill in bytesused for output
buffers, unfortunately the vb2 framework never checked for that.

So for single planar formats replace a bytesused of 0 by the length
of the buffer, and for multiplanar format do the same if bytesused is
0 for ALL planes.

This seems to be what the user really intended if v4l2_buffer was
just memset to 0.

I'm afraid that just checking for this and returning an error would
break too many applications. Quite a few drivers never check for bytesused
at all and just use the buffer length instead.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 32 +++-
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 1a09442..83e78e9 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1145,19 +1145,35 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
memset(v4l2_planes[plane].reserved, 0,
   sizeof(v4l2_planes[plane].reserved));
v4l2_planes[plane].data_offset = 0;
+   v4l2_planes[plane].bytesused = 0;
}
 
/* Fill in driver-provided information for OUTPUT types */
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
+   bool bytesused_is_used;
+
+   /* Check if bytesused == 0 for all planes */
+   for (plane = 0; plane < vb->num_planes; ++plane)
+   if (b->m.planes[plane].bytesused)
+   break;
+   bytesused_is_used = plane < vb->num_planes;
+
/*
 * Will have to go up to b->length when API starts
 * accepting variable number of planes.
+*
+* If bytesused_is_used is false, then fall back to the
+* full buffer size. In that case userspace clearly
+* never bothered to set it and it's a safe assumption
+* that they really meant to use the full plane sizes.
 */
for (plane = 0; plane < vb->num_planes; ++plane) {
-   v4l2_planes[plane].bytesused =
-   b->m.planes[plane].bytesused;
-   v4l2_planes[plane].data_offset =
-   b->m.planes[plane].data_offset;
+   struct v4l2_plane *pdst = &v4l2_planes[plane];
+   struct v4l2_plane *psrc = &b->m.planes[plane];
+
+   pdst->bytesused = bytesused_is_used ?
+   psrc->bytesused : psrc->length;
+   pdst->data_offset = psrc->data_offset;
}
}
 
@@ -1183,9 +1199,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
 * so fill in relevant v4l2_buffer struct fields instead.
 * In videobuf we use our internal V4l2_planes struct for
 * single-planar buffers as well, for simplicity.
+*
+* If bytesused == 0, then fall back to the full buffer size
+* as that's a sensible default.
 */
if (V4L2_TYPE_IS_OUTPUT(b->type))
-   v4l2_planes[0].bytesused = b->bytesused;
+   v4l2_planes[0].bytesused =
+   b->bytesused ? b->bytesused : b->length;
+   else
+   v4l2_planes[0].bytesused = 0;
/* Single-planar buffers never use data_offset */
v4l2_planes[0].data_offset = 0;
 
-- 
1.9.0

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


[REVIEW PATCH 10/11] vb2: set v4l2_buffer.bytesused to 0 for mp buffers

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

The bytesused field of struct v4l2_buffer is not used for multiplanar
formats, so just zero it to prevent it from having some random value.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index f68a60f..54a4150 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -583,6 +583,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
struct v4l2_buffer *b)
 * for it. The caller has already verified memory and size.
 */
b->length = vb->num_planes;
+   b->bytesused = 0;
memcpy(b->m.planes, vb->v4l2_planes,
b->length * sizeof(struct v4l2_plane));
} else {
-- 
1.9.0

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


[REVIEW PATCH 11/11] vb2: allow read/write as long as the format is single planar

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

It was impossible to read() or write() a frame if the queue type was 
multiplanar.
Even if the current format is single planar. Change this to just check whether
the number of planes is 1 or more.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 54a4150..8faf1ef 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2622,6 +2622,7 @@ struct vb2_fileio_buf {
  */
 struct vb2_fileio_data {
struct v4l2_requestbuffers req;
+   struct v4l2_plane p;
struct v4l2_buffer b;
struct vb2_fileio_buf bufs[VIDEO_MAX_FRAME];
unsigned int cur_index;
@@ -2712,13 +2713,21 @@ static int __vb2_init_fileio(struct vb2_queue *q, int 
read)
 * Read mode requires pre queuing of all buffers.
 */
if (read) {
+   bool is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type);
+
/*
 * Queue all buffers.
 */
for (i = 0; i < q->num_buffers; i++) {
struct v4l2_buffer *b = &fileio->b;
+
memset(b, 0, sizeof(*b));
b->type = q->type;
+   if (is_multiplanar) {
+   memset(&fileio->p, 0, sizeof(fileio->p));
+   b->m.planes = &fileio->p;
+   b->length = 1;
+   }
b->memory = q->memory;
b->index = i;
ret = vb2_internal_qbuf(q, b);
@@ -2786,6 +2795,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
 {
struct vb2_fileio_data *fileio;
struct vb2_fileio_buf *buf;
+   bool is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type);
bool set_timestamp = !read &&
(q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
V4L2_BUF_FLAG_TIMESTAMP_COPY;
@@ -2820,6 +2830,11 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
memset(&fileio->b, 0, sizeof(fileio->b));
fileio->b.type = q->type;
fileio->b.memory = q->memory;
+   if (is_multiplanar) {
+   memset(&fileio->p, 0, sizeof(fileio->p));
+   fileio->b.m.planes = &fileio->p;
+   fileio->b.length = 1;
+   }
ret = vb2_internal_dqbuf(q, &fileio->b, nonblock);
dprintk(5, "file io: vb2_dqbuf result: %d\n", ret);
if (ret)
@@ -2890,6 +2905,12 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
fileio->b.memory = q->memory;
fileio->b.index = index;
fileio->b.bytesused = buf->pos;
+   if (is_multiplanar) {
+   memset(&fileio->p, 0, sizeof(fileio->p));
+   fileio->p.bytesused = buf->pos;
+   fileio->b.m.planes = &fileio->p;
+   fileio->b.length = 1;
+   }
if (set_timestamp)
v4l2_get_timestamp(&fileio->b.timestamp);
ret = vb2_internal_qbuf(q, &fileio->b);
-- 
1.9.0

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


[REVIEW PATCH 04/11] vb2: use correct prefix

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

Many dprintk's in vb2 use a hardcoded prefix with the function name. In
many cases that is now outdated. Replace prefixes by the function name using
__func__. At least now I know if I see a 'qbuf:' prefix whether that refers
to the mmap, userptr or dmabuf variant.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 102 ---
 1 file changed, 54 insertions(+), 48 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 83e78e9..71be247 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -371,7 +371,8 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned 
int buffers)
if (q->bufs[buffer] == NULL)
continue;
if (q->bufs[buffer]->state == VB2_BUF_STATE_PREPARING) {
-   dprintk(1, "reqbufs: preparing buffers, cannot free\n");
+   dprintk(1, "%s: preparing buffers, cannot free\n",
+   __func__);
return -EAGAIN;
}
}
@@ -656,12 +657,12 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer 
*b)
int ret;
 
if (b->type != q->type) {
-   dprintk(1, "querybuf: wrong buffer type\n");
+   dprintk(1, "%s: wrong buffer type\n", __func__);
return -EINVAL;
}
 
if (b->index >= q->num_buffers) {
-   dprintk(1, "querybuf: buffer index out of range\n");
+   dprintk(1, "%s: buffer index out of range\n", __func__);
return -EINVAL;
}
vb = q->bufs[b->index];
@@ -721,12 +722,12 @@ static int __verify_memory_type(struct vb2_queue *q,
 {
if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR &&
memory != V4L2_MEMORY_DMABUF) {
-   dprintk(1, "reqbufs: unsupported memory type\n");
+   dprintk(1, "%s: unsupported memory type\n", __func__);
return -EINVAL;
}
 
if (type != q->type) {
-   dprintk(1, "reqbufs: requested type is incorrect\n");
+   dprintk(1, "%s: requested type is incorrect\n", __func__);
return -EINVAL;
}
 
@@ -735,17 +736,20 @@ static int __verify_memory_type(struct vb2_queue *q,
 * are available.
 */
if (memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) {
-   dprintk(1, "reqbufs: MMAP for current setup unsupported\n");
+   dprintk(1, "%s: MMAP for current setup unsupported\n",
+   __func__);
return -EINVAL;
}
 
if (memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) {
-   dprintk(1, "reqbufs: USERPTR for current setup unsupported\n");
+   dprintk(1, "%s: USERPTR for current setup unsupported\n",
+   __func__);
return -EINVAL;
}
 
if (memory == V4L2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) {
-   dprintk(1, "reqbufs: DMABUF for current setup unsupported\n");
+   dprintk(1, "%s: DMABUF for current setup unsupported\n",
+   __func__);
return -EINVAL;
}
 
@@ -755,7 +759,7 @@ static int __verify_memory_type(struct vb2_queue *q,
 * do the memory and type validation.
 */
if (q->fileio) {
-   dprintk(1, "reqbufs: file io in progress\n");
+   dprintk(1, "%s: file io in progress\n", __func__);
return -EBUSY;
}
return 0;
@@ -790,7 +794,7 @@ static int __reqbufs(struct vb2_queue *q, struct 
v4l2_requestbuffers *req)
int ret;
 
if (q->streaming) {
-   dprintk(1, "reqbufs: streaming active\n");
+   dprintk(1, "%s: streaming active\n", __func__);
return -EBUSY;
}
 
@@ -800,7 +804,7 @@ static int __reqbufs(struct vb2_queue *q, struct 
v4l2_requestbuffers *req)
 * are not in use and can be freed.
 */
if (q->memory == V4L2_MEMORY_MMAP && __buffers_in_use(q)) {
-   dprintk(1, "reqbufs: memory in use, cannot free\n");
+   dprintk(1, "%s: memory in use, cannot free\n", 
__func__);
return -EBUSY;
}
 
@@ -1272,15 +1276,14 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
&& vb->v4l2_planes[plane].length == planes[plane].length)
continue;
 
-   dprintk(3, "qbuf: userspace address for plane %d changed, "
-   "reacquiring memory\n", plane);
+   dprintk(3, "%s: userspace address for plane %d changed, 
reacquiring memory\n",
+   __func__, plan

[REVIEW PATCH 06/11] vb2: set timestamp when using write()

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

When using write() to write data to an output video node the vb2 core
should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody
else is able to provide this information with the write() operation.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index e38b45e..afd1268 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static int debug;
@@ -2767,6 +2768,9 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
 {
struct vb2_fileio_data *fileio;
struct vb2_fileio_buf *buf;
+   bool set_timestamp = !read &&
+   (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
+   V4L2_BUF_FLAG_TIMESTAMP_COPY;
int ret, index;
 
dprintk(3, "file io: mode %s, offset %ld, count %zd, %sblocking\n",
@@ -2868,6 +2872,8 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
fileio->b.memory = q->memory;
fileio->b.index = index;
fileio->b.bytesused = buf->pos;
+   if (set_timestamp)
+   v4l2_get_timestamp(&fileio->b.timestamp);
ret = vb2_internal_qbuf(q, &fileio->b);
dprintk(5, "file io: vb2_internal_qbuf result: %d\n", ret);
if (ret)
-- 
1.9.0

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


[REVIEW PATCH 05/11] vb2: move __qbuf_mmap before __qbuf_userptr

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

__qbuf_mmap was sort of hidden in between the much larger __qbuf_userptr
and __qbuf_dmabuf functions. Move it before __qbuf_userptr which is
also conform the usual order these memory models are implemented: first
mmap, then userptr, then dmabuf.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 71be247..e38b45e 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1254,6 +1254,20 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
 }
 
 /**
+ * __qbuf_mmap() - handle qbuf of an MMAP buffer
+ */
+static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b)
+{
+   int ret;
+
+   __fill_vb2_buffer(vb, b, vb->v4l2_planes);
+   ret = call_vb_qop(vb, buf_prepare, vb);
+   if (ret)
+   fail_vb_qop(vb, buf_prepare);
+   return ret;
+}
+
+/**
  * __qbuf_userptr() - handle qbuf of a USERPTR buffer
  */
 static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b)
@@ -1359,20 +1373,6 @@ err:
 }
 
 /**
- * __qbuf_mmap() - handle qbuf of an MMAP buffer
- */
-static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b)
-{
-   int ret;
-
-   __fill_vb2_buffer(vb, b, vb->v4l2_planes);
-   ret = call_vb_qop(vb, buf_prepare, vb);
-   if (ret)
-   fail_vb_qop(vb, buf_prepare);
-   return ret;
-}
-
-/**
  * __qbuf_dmabuf() - handle qbuf of a DMABUF buffer
  */
 static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b)
-- 
1.9.0

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


[REVIEW PATCH 01/11] vb2: stop_streaming should return void

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

The vb2 core ignores any return code from the stop_streaming op.
And there really isn't anything it can do anyway in case of an error.
So change the return type to void and update any drivers that implement it.

The int return gave drivers the idea that this operation could actually
fail, but that's really not the case.

The pwc amd sdr-msi3101 drivers both had this construction:

if (mutex_lock_interruptible(&s->v4l2_lock))
return -ERESTARTSYS;

This has been updated to just call mutex_lock(). The stop_streaming op
expects this to really stop streaming and I very much doubt this will
work reliably if stop_streaming just returns without really stopping the
DMA.

Signed-off-by: Hans Verkuil 
---
 drivers/media/pci/sta2x11/sta2x11_vip.c  | 3 +--
 drivers/media/platform/blackfin/bfin_capture.c   | 6 +-
 drivers/media/platform/coda.c| 4 +---
 drivers/media/platform/exynos-gsc/gsc-m2m.c  | 4 +---
 drivers/media/platform/exynos4-is/fimc-capture.c | 6 +++---
 drivers/media/platform/exynos4-is/fimc-lite.c| 6 +++---
 drivers/media/platform/exynos4-is/fimc-m2m.c | 3 +--
 drivers/media/platform/marvell-ccic/mcam-core.c  | 7 +++
 drivers/media/platform/s3c-camif/camif-capture.c | 4 ++--
 drivers/media/platform/s5p-jpeg/jpeg-core.c  | 4 +---
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 3 +--
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 3 +--
 drivers/media/platform/s5p-tv/mixer_video.c  | 3 +--
 drivers/media/platform/soc_camera/atmel-isi.c| 6 ++
 drivers/media/platform/soc_camera/mx2_camera.c   | 4 +---
 drivers/media/platform/soc_camera/mx3_camera.c   | 4 +---
 drivers/media/platform/soc_camera/rcar_vin.c | 4 +---
 drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | 4 ++--
 drivers/media/platform/vivi.c| 3 +--
 drivers/media/platform/vsp1/vsp1_video.c | 4 +---
 drivers/media/usb/em28xx/em28xx-v4l.h| 2 +-
 drivers/media/usb/em28xx/em28xx-video.c  | 8 ++--
 drivers/media/usb/pwc/pwc-if.c   | 7 ++-
 drivers/media/usb/s2255/s2255drv.c   | 5 ++---
 drivers/media/usb/stk1160/stk1160-v4l.c  | 4 ++--
 drivers/media/usb/usbtv/usbtv-video.c| 9 +++--
 drivers/staging/media/davinci_vpfe/vpfe_video.c  | 3 +--
 drivers/staging/media/dt3155v4l/dt3155v4l.c  | 3 +--
 drivers/staging/media/go7007/go7007-v4l2.c   | 3 +--
 drivers/staging/media/msi3101/sdr-msi3101.c  | 7 ++-
 drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c   | 3 +--
 drivers/staging/media/solo6x10/solo6x10-v4l2.c   | 3 +--
 include/media/videobuf2-core.h   | 2 +-
 33 files changed, 49 insertions(+), 95 deletions(-)

diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
b/drivers/media/pci/sta2x11/sta2x11_vip.c
index bb11443..7559951 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -357,7 +357,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned 
int count)
 }
 
 /* abort streaming and wait for last buffer */
-static int stop_streaming(struct vb2_queue *vq)
+static void stop_streaming(struct vb2_queue *vq)
 {
struct sta2x11_vip *vip = vb2_get_drv_priv(vq);
struct vip_buffer *vip_buf, *node;
@@ -374,7 +374,6 @@ static int stop_streaming(struct vb2_queue *vq)
list_del(&vip_buf->list);
}
spin_unlock(&vip->lock);
-   return 0;
 }
 
 static struct vb2_ops vip_video_qops = {
diff --git a/drivers/media/platform/blackfin/bfin_capture.c 
b/drivers/media/platform/blackfin/bfin_capture.c
index 200bec9..16f643c 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -427,15 +427,12 @@ static int bcap_start_streaming(struct vb2_queue *vq, 
unsigned int count)
return 0;
 }
 
-static int bcap_stop_streaming(struct vb2_queue *vq)
+static void bcap_stop_streaming(struct vb2_queue *vq)
 {
struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
struct ppi_if *ppi = bcap_dev->ppi;
int ret;
 
-   if (!vb2_is_streaming(vq))
-   return 0;
-
bcap_dev->stop = true;
wait_for_completion(&bcap_dev->comp);
ppi->ops->stop(ppi);
@@ -452,7 +449,6 @@ static int bcap_stop_streaming(struct vb2_queue *vq)
list_del(&bcap_dev->cur_frm->list);
vb2_buffer_done(&bcap_dev->cur_frm->vb, VB2_BUF_STATE_ERROR);
}
-   return 0;
 }
 
 static struct vb2_ops bcap_video_qops = {
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 3e5199e..d9b1a04 100644
--- a/drivers/media/platform/coda.c
++

vb2: various small fixes/improvements

2014-03-10 Thread Hans Verkuil
This patch series contains a list of various vb2 fixes and improvements.

These patches were originally part of this RFC patch series:

http://www.spinics.net/lists/linux-media/msg73391.html

They are now rebased and reordered a bit. It's little stuff for the
most part, although the first patch touches on more drivers since it
changes the return type of stop_streaming to void. The return value was
always ignored by vb2 and you really cannot do anything sensible with it.
In general resource allocations can return an error, but freeing up resources
should not. That should always succeed.

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


[GIT PULL] SDR API

2014-03-10 Thread Antti Palosaari
That is just same set I sent earlier too, but rebased to latest 
media/master and 6 small compliance fix.



The following changes since commit f2d7313534072a5fe192e7cf46204b413acef479:

  [media] drx-d: add missing braces in drxd_hard.c:DRXD_init 
(2014-03-09 09:20:50 -0300)


are available in the git repository at:

  git://linuxtv.org/anttip/media_tree.git sdr_review_v3

for you to fetch changes up to 2a02f2e9cf67c2e083950ea4b1d03a2756c1ee94:

  msi3101: fix v4l2-compliance issues (2014-03-10 21:30:44 +0200)


Antti Palosaari (37):
  v4l: add RF tuner channel bandwidth control
  v4l: reorganize RF tuner control ID numbers
  v4l: uapi: add SDR formats CU8 and CU16LE
  v4l: add enum_freq_bands support to tuner sub-device
  v4l: add control for RF tuner PLL lock flag
  DocBook: V4L: add V4L2_SDR_FMT_CU8 - 'CU08'
  DocBook: V4L: add V4L2_SDR_FMT_CU16LE - 'CU16'
  DocBook: document RF tuner bandwidth controls
  DocBook: media: document PLL lock control
  DocBook: media: add some general info about RF tuners
  msi3101: convert to SDR API
  msi001: Mirics MSi001 silicon tuner driver
  msi3101: use msi001 tuner driver
  MAINTAINERS: add msi001 driver
  MAINTAINERS: add msi3101 driver
  msi3101: clamp mmap buffers to reasonable level
  e4000: convert DVB tuner to I2C driver model
  e4000: implement controls via v4l2 control framework
  e4000: fix PLL calc to allow higher frequencies
  e4000: implement PLL lock v4l control
  e4000: get rid of DVB i2c_gate_ctrl()
  e4000: convert to Regmap API
  e4000: rename some variables
  rtl2832_sdr: Realtek RTL2832 SDR driver module
  rtl28xxu: constify demod config structs
  rtl28xxu: attach SDR extension module
  rtl28xxu: fix switch-case style issue
  rtl28xxu: use muxed RTL2832 I2C adapters for E4000 and RTL2832_SDR
  rtl2832_sdr: expose e4000 controls to user
  r820t: add manual gain controls
  rtl2832_sdr: expose R820T controls to user
  MAINTAINERS: add rtl2832_sdr driver
  v4l: rename v4l2_format_sdr to v4l2_sdr_format
  rtl2832_sdr: clamp bandwidth to nearest legal value in automode
  rtl28xxu: depends on I2C_MUX
  msi001: fix v4l2-compliance issues
  msi3101: fix v4l2-compliance issues

Hans Verkuil (1):
  rtl2832u_sdr: fixing v4l2-compliance issues

 Documentation/DocBook/media/v4l/controls.xml  |   51 +++-
 Documentation/DocBook/media/v4l/dev-sdr.xml   |2 +-
 Documentation/DocBook/media/v4l/pixfmt-sdr-cu08.xml   |   44 
 Documentation/DocBook/media/v4l/pixfmt-sdr-cu16le.xml |   46 
 Documentation/DocBook/media/v4l/pixfmt.xml|3 +
 MAINTAINERS   |   30 +++
 drivers/media/tuners/Kconfig  |1 +
 drivers/media/tuners/e4000.c  |  598 
+--

 drivers/media/tuners/e4000.h  |   21 +-
 drivers/media/tuners/e4000_priv.h |   86 ++-
 drivers/media/tuners/r820t.c  |  137 ++-
 drivers/media/tuners/r820t.h  |   10 +
 drivers/media/usb/dvb-usb-v2/Kconfig  |2 +-
 drivers/media/usb/dvb-usb-v2/Makefile |1 +
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c   |   90 +--
 drivers/media/usb/dvb-usb-v2/rtl28xxu.h   |2 +
 drivers/media/v4l2-core/v4l2-ctrls.c  |9 +
 drivers/media/v4l2-core/v4l2-ioctl.c  |2 +-
 drivers/staging/media/Kconfig |2 +
 drivers/staging/media/Makefile|2 +
 drivers/staging/media/msi3101/Kconfig |7 +-
 drivers/staging/media/msi3101/Makefile|1 +
 drivers/staging/media/msi3101/msi001.c|  500 
+++
 drivers/staging/media/msi3101/sdr-msi3101.c   | 1564 
+-

 drivers/staging/media/rtl2832u_sdr/Kconfig|7 +
 drivers/staging/media/rtl2832u_sdr/Makefile   |6 +
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c  | 1501 
+

 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h  |   51 
 include/media/v4l2-subdev.h   |1 +
 include/uapi/linux/v4l2-controls.h|   15 +-
 include/uapi/linux/videodev2.h|   10 +-
 31 files changed, 3531 insertions(+), 1271 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-sdr-cu08.xml
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-sdr-cu16l

[FINAL PATCH 1/6] v4l: rename v4l2_format_sdr to v4l2_sdr_format

2014-03-10 Thread Antti Palosaari
Rename v4l2_format_sdr to v4l2_sdr_format in order to keep it in
line with other formats.

Reported-by: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 Documentation/DocBook/media/v4l/dev-sdr.xml | 2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c| 2 +-
 include/uapi/linux/videodev2.h  | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml 
b/Documentation/DocBook/media/v4l/dev-sdr.xml
index ac9f1af..524b9c4 100644
--- a/Documentation/DocBook/media/v4l/dev-sdr.xml
+++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
@@ -78,7 +78,7 @@ of the data format.
 
 
 
-  struct v4l2_format_sdr
+  struct v4l2_sdr_format
   
 &cs-str;
 
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 95dd4f1..e6e86a2 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -246,7 +246,7 @@ static void v4l_print_format(const void *arg, bool 
write_only)
const struct v4l2_vbi_format *vbi;
const struct v4l2_sliced_vbi_format *sliced;
const struct v4l2_window *win;
-   const struct v4l2_format_sdr *sdr;
+   const struct v4l2_sdr_format *sdr;
unsigned i;
 
pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index d3187d8..5f10ed9 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1714,10 +1714,10 @@ struct v4l2_pix_format_mplane {
 } __attribute__ ((packed));
 
 /**
- * struct v4l2_format_sdr - SDR format definition
+ * struct v4l2_sdr_format - SDR format definition
  * @pixelformat:   little endian four character code (fourcc)
  */
-struct v4l2_format_sdr {
+struct v4l2_sdr_format {
__u32   pixelformat;
__u8reserved[28];
 } __attribute__ ((packed));
@@ -1740,7 +1740,7 @@ struct v4l2_format {
struct v4l2_window  win; /* 
V4L2_BUF_TYPE_VIDEO_OVERLAY */
struct v4l2_vbi_format  vbi; /* 
V4L2_BUF_TYPE_VBI_CAPTURE */
struct v4l2_sliced_vbi_format   sliced;  /* 
V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
-   struct v4l2_format_sdr  sdr; /* 
V4L2_BUF_TYPE_SDR_CAPTURE */
+   struct v4l2_sdr_format  sdr; /* 
V4L2_BUF_TYPE_SDR_CAPTURE */
__u8raw_data[200];   /* user-defined */
} fmt;
 };
-- 
1.8.5.3

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


[FINAL PATCH 5/6] msi001: fix v4l2-compliance issues

2014-03-10 Thread Antti Palosaari
Fix msi001 driver v4l2-compliance issues.

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 drivers/staging/media/msi3101/msi001.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/msi3101/msi001.c 
b/drivers/staging/media/msi3101/msi001.c
index 25feece..ac43bae 100644
--- a/drivers/staging/media/msi3101/msi001.c
+++ b/drivers/staging/media/msi3101/msi001.c
@@ -429,6 +429,7 @@ static int msi001_probe(struct spi_device *spi)
}
 
s->spi = spi;
+   s->f_tuner = bands[0].rangelow;
v4l2_spi_subdev_init(&s->sd, spi, &msi001_ops);
 
/* Register controls */
-- 
1.8.5.3

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


[FINAL PATCH 2/6] rtl2832u_sdr: fixing v4l2-compliance issues

2014-03-10 Thread Antti Palosaari
From: Hans Verkuil 

Fix rtl2832u_sdr driver v4l2-compliance issues.

Signed-off-by: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 29 +++-
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index 932716f..bcc632a 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -120,6 +120,7 @@ struct rtl2832_sdr_state {
struct vb2_queue vb_queue;
struct list_head queued_bufs;
spinlock_t queued_bufs_lock; /* Protects queued_bufs */
+   unsigned sequence;   /* buffer sequence counter */
 
/* Note if taking both locks v4l2_lock must always be locked first! */
struct mutex v4l2_lock;  /* Protects everything else */
@@ -415,6 +416,8 @@ static void rtl2832_sdr_urb_complete(struct urb *urb)
len = rtl2832_sdr_convert_stream(s, ptr, urb->transfer_buffer,
urb->actual_length);
vb2_set_plane_payload(&fbuf->vb, 0, len);
+   v4l2_get_timestamp(&fbuf->vb.v4l2_buf.timestamp);
+   fbuf->vb.v4l2_buf.sequence = s->sequence++;
vb2_buffer_done(&fbuf->vb, VB2_BUF_STATE_DONE);
}
 skip:
@@ -611,8 +614,9 @@ static int rtl2832_sdr_queue_setup(struct vb2_queue *vq,
struct rtl2832_sdr_state *s = vb2_get_drv_priv(vq);
dev_dbg(&s->udev->dev, "%s: *nbuffers=%d\n", __func__, *nbuffers);
 
-   /* Absolute min and max number of buffers available for mmap() */
-   *nbuffers = clamp_t(unsigned int, *nbuffers, 8, 32);
+   /* Need at least 8 buffers */
+   if (vq->num_buffers + *nbuffers < 8)
+   *nbuffers = 8 - vq->num_buffers;
*nplanes = 1;
/* 2 = max 16-bit sample returned */
sizes[0] = PAGE_ALIGN(BULK_BUFFER_SIZE * 2);
@@ -1013,6 +1017,8 @@ static int rtl2832_sdr_start_streaming(struct vb2_queue 
*vq, unsigned int count)
if (ret)
goto err;
 
+   s->sequence = 0;
+
ret = rtl2832_sdr_submit_urbs(s);
if (ret)
goto err;
@@ -1090,6 +1096,8 @@ static int rtl2832_sdr_s_tuner(struct file *file, void 
*priv,
struct rtl2832_sdr_state *s = video_drvdata(file);
dev_dbg(&s->udev->dev, "%s:\n", __func__);
 
+   if (v->index > 1)
+   return -EINVAL;
return 0;
 }
 
@@ -1125,12 +1133,15 @@ static int rtl2832_sdr_g_frequency(struct file *file, 
void *priv,
dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d\n",
__func__, f->tuner, f->type);
 
-   if (f->tuner == 0)
+   if (f->tuner == 0) {
f->frequency = s->f_adc;
-   else if (f->tuner == 1)
+   f->type = V4L2_TUNER_ADC;
+   } else if (f->tuner == 1) {
f->frequency = s->f_tuner;
-   else
+   f->type = V4L2_TUNER_RF;
+   } else {
return -EINVAL;
+   }
 
return ret;
 }
@@ -1164,7 +1175,9 @@ static int rtl2832_sdr_s_frequency(struct file *file, 
void *priv,
__func__, s->f_adc);
ret = rtl2832_sdr_set_adc(s);
} else if (f->tuner == 1) {
-   s->f_tuner = f->frequency;
+   s->f_tuner = clamp_t(unsigned int, f->frequency,
+   bands_fm[0].rangelow,
+   bands_fm[0].rangehigh);
dev_dbg(&s->udev->dev, "%s: RF frequency=%u Hz\n",
__func__, f->frequency);
 
@@ -1198,6 +1211,7 @@ static int rtl2832_sdr_g_fmt_sdr_cap(struct file *file, 
void *priv,
dev_dbg(&s->udev->dev, "%s:\n", __func__);
 
f->fmt.sdr.pixelformat = s->pixelformat;
+   memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
 
return 0;
 }
@@ -1214,6 +1228,7 @@ static int rtl2832_sdr_s_fmt_sdr_cap(struct file *file, 
void *priv,
if (vb2_is_busy(q))
return -EBUSY;
 
+   memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
for (i = 0; i < NUM_FORMATS; i++) {
if (formats[i].pixelformat == f->fmt.sdr.pixelformat) {
s->pixelformat = f->fmt.sdr.pixelformat;
@@ -1235,6 +1250,7 @@ static int rtl2832_sdr_try_fmt_sdr_cap(struct file *file, 
void *priv,
dev_dbg(&s->udev->dev, "%s: pixelformat fourcc %4.4s\n", __func__,
(char *)&f->fmt.sdr.pixelformat);
 
+   memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
for (i = 0; i < NUM_FORMATS; i++) {
if (formats[i].pixelformat == f->fmt.sdr.pixelformat)
return 0;
@@ -1365,6 +1381,7 @@ struct dvb_frontend *rtl2832_sdr_attach(struct 
dvb_frontend *fe,
s->i2c = i2c;
s->cfg = cfg;
s->f_adc = bands_adc[0].rangelow;
+ 

[FINAL PATCH 4/6] rtl28xxu: depends on I2C_MUX

2014-03-10 Thread Antti Palosaari
We need depend on I2C_MUX as rtl2832 demod used requires it.

All error/warnings:
warning: (DVB_USB_RTL28XXU) selects DVB_RTL2832 which has unmet direct 
dependencies (MEDIA_SUPPORT && DVB_CORE && I2C && I2C_MUX)
ERROR: "i2c_add_mux_adapter" [drivers/media/dvb-frontends/rtl2832.ko] undefined!
ERROR: "i2c_del_mux_adapter" [drivers/media/dvb-frontends/rtl2832.ko] undefined!

Reported-by: kbuild test robot 
Signed-off-by: Antti Palosaari 
---
 drivers/media/usb/dvb-usb-v2/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig 
b/drivers/media/usb/dvb-usb-v2/Kconfig
index bfb7378..037e519 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -126,7 +126,7 @@ config DVB_USB_MXL111SF
 
 config DVB_USB_RTL28XXU
tristate "Realtek RTL28xxU DVB USB support"
-   depends on DVB_USB_V2
+   depends on DVB_USB_V2 && I2C_MUX
select DVB_RTL2830
select DVB_RTL2832
select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT
-- 
1.8.5.3

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


[FINAL PATCH 6/6] msi3101: fix v4l2-compliance issues

2014-03-10 Thread Antti Palosaari
Fix msi3101 driver v4l2-compliance issues.

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 drivers/staging/media/msi3101/sdr-msi3101.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c 
b/drivers/staging/media/msi3101/sdr-msi3101.c
index 93e6eba..011db2c 100644
--- a/drivers/staging/media/msi3101/sdr-msi3101.c
+++ b/drivers/staging/media/msi3101/sdr-msi3101.c
@@ -1134,6 +1134,7 @@ static int msi3101_g_fmt_sdr_cap(struct file *file, void 
*priv,
dev_dbg(&s->udev->dev, "%s: pixelformat fourcc %4.4s\n", __func__,
(char *)&s->pixelformat);
 
+   memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
f->fmt.sdr.pixelformat = s->pixelformat;
 
return 0;
@@ -1151,6 +1152,7 @@ static int msi3101_s_fmt_sdr_cap(struct file *file, void 
*priv,
if (vb2_is_busy(q))
return -EBUSY;
 
+   memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
for (i = 0; i < NUM_FORMATS; i++) {
if (formats[i].pixelformat == f->fmt.sdr.pixelformat) {
s->pixelformat = f->fmt.sdr.pixelformat;
@@ -1172,6 +1174,7 @@ static int msi3101_try_fmt_sdr_cap(struct file *file, 
void *priv,
dev_dbg(&s->udev->dev, "%s: pixelformat fourcc %4.4s\n", __func__,
(char *)&f->fmt.sdr.pixelformat);
 
+   memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
for (i = 0; i < NUM_FORMATS; i++) {
if (formats[i].pixelformat == f->fmt.sdr.pixelformat)
return 0;
@@ -1233,6 +1236,7 @@ static int msi3101_g_frequency(struct file *file, void 
*priv,
f->frequency = s->f_adc;
ret = 0;
} else if (f->tuner == 1) {
+   f->type = V4L2_TUNER_RF;
ret = v4l2_subdev_call(s->v4l2_subdev, tuner, g_frequency, f);
} else {
ret = -EINVAL;
-- 
1.8.5.3

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


[FINAL PATCH 3/6] rtl2832_sdr: clamp bandwidth to nearest legal value in automode

2014-03-10 Thread Antti Palosaari
Clamp bandwidth to nearest legal value in automode in order to pass
v4l2-compliance test.

Reported-by: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index bcc632a..c2c3c3d 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -1324,8 +1324,16 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
switch (ctrl->id) {
case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
case V4L2_CID_RF_TUNER_BANDWIDTH:
-   if (s->bandwidth_auto->val)
-   s->bandwidth->val = s->f_adc;
+   /* TODO: these controls should be moved to tuner drivers */
+   if (s->bandwidth_auto->val) {
+   /* Round towards the closest legal value */
+   s32 val = s->f_adc + s->bandwidth->step / 2;
+   u32 offset;
+   val = clamp(val, s->bandwidth->minimum, 
s->bandwidth->maximum);
+   offset = val - s->bandwidth->minimum;
+   offset = s->bandwidth->step * (offset / 
s->bandwidth->step);
+   s->bandwidth->val = s->bandwidth->minimum + offset;
+   }
 
c->bandwidth_hz = s->bandwidth->val;
 
-- 
1.8.5.3

--
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 v6 4/8] of: Reduce indentation in of_graph_get_next_endpoint

2014-03-10 Thread Laurent Pinchart
Hi Philipp,

On Friday 07 March 2014 18:40:54 Philipp Zabel wrote:
> Am Freitag, den 07.03.2014, 01:12 +0100 schrieb Laurent Pinchart:
> > Hi Philipp,
> > 
> > Thank you for the patch.
> > 
> > I've submitted a fix for the of_graph_get_next_endpoint() function, but it
> > hasn't been applied yet due to the patch series that contained it needing
> > more work.
> > 
> > The patch is available at https://patchwork.linuxtv.org/patch/21946/. I
> > can rebase it on top of this series, but I still wanted to let you know
> > about it in case you would like to integrate it.
> 
> Thank you for the pointer. A pity about the timing, this will mostly
> revert my indentation patch. I'd be glad if you could rebase on top of
> the merged series.
> 
> While we look at of_graph_get_next_endpoint(), could you explain the
> reason behind the extra reference count increase on the prev node:
>
>   /*
>* Avoid dropping prev node refcount to 0 when getting the next
>* child below.
>*/
>   of_node_get(prev);
>
> This unfortunately makes using the function in for_each style macros a
> hassle. If that part wasn't there and all users that want to keep using
> prev after the call were expected to increase refcount themselves,
> we could have a
>
> #define of_graph_for_each_endpoint(parent, endpoint) \
>   for (endpoint = of_graph_get_next_endpoint(parent, NULL); \
>endpoint != NULL; \
>endpoint = of_graph_get_next_endpoint(parent, endpoint))

I don't know what the exact design decision was (Sylwester might know), but I 
suspect it's mostly about historical reasons. I see no reason that would 
prevent modifying the current behaviour to make a for-each loop easier to 
implement.

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


[GIT PULL FOR v3.15] adv7180 fixes

2014-03-10 Thread Hans Verkuil
The following changes since commit f2d7313534072a5fe192e7cf46204b413acef479:

  [media] drx-d: add missing braces in drxd_hard.c:DRXD_init (2014-03-09 
09:20:50 -0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v3.15e

for you to fetch changes up to 72f965c6bbff5f0b3290e5019c90496dcb9462fe:

  adv7180: Add support for power down (2014-03-10 18:12:26 +0100)


Lars-Peter Clausen (7):
  adv7180: Fix remove order
  adv7180: Free control handler on remove()
  adv7180: Remove unnecessary v4l2_device_unregister_subdev() from probe 
error path
  adv7180: Remove duplicated probe error message
  adv7180: Use threaded IRQ instead of IRQ + workqueue
  adv7180: Add support for async device registration
  adv7180: Add support for power down

 drivers/media/i2c/adv7180.c | 100 
+---
 1 file changed, 59 insertions(+), 41 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] [media] adv7180: Add support for power down

2014-03-10 Thread Lars-Peter Clausen
The adv7180 has a low power mode in which the analog and the digital processing
section are shut down. Implement the s_power callback to let bridge drivers put
the part into low power mode when not needed.

Signed-off-by: Lars-Peter Clausen 
---
Changes since v1:
* Set powered to true in probe() since the part is powered on when it comes
  out of reset
* Avoid use ofgoto in adv7180_s_power
---
 drivers/media/i2c/adv7180.c | 52 -
 1 file changed, 42 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 623cec5..9cfc9a3 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -127,6 +127,7 @@ struct adv7180_state {
int irq;
v4l2_std_id curr_norm;
boolautodetect;
+   boolpowered;
u8  input;
 };
 #define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler,\
@@ -311,6 +312,37 @@ out:
return ret;
 }
 
+static int adv7180_set_power(struct adv7180_state *state,
+   struct i2c_client *client, bool on)
+{
+   u8 val;
+
+   if (on)
+   val = ADV7180_PWR_MAN_ON;
+   else
+   val = ADV7180_PWR_MAN_OFF;
+
+   return i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG, val);
+}
+
+static int adv7180_s_power(struct v4l2_subdev *sd, int on)
+{
+   struct adv7180_state *state = to_state(sd);
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   int ret;
+
+   ret = mutex_lock_interruptible(&state->mutex);
+   if (ret)
+   return ret;
+
+   ret = adv7180_set_power(state, client, on);
+   if (ret == 0)
+   state->powered = on;
+
+   mutex_unlock(&state->mutex);
+   return ret;
+}
+
 static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl)
 {
struct v4l2_subdev *sd = to_adv7180_sd(ctrl);
@@ -441,6 +473,7 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops 
= {
 
 static const struct v4l2_subdev_core_ops adv7180_core_ops = {
.s_std = adv7180_s_std,
+   .s_power = adv7180_s_power,
 };
 
 static const struct v4l2_subdev_ops adv7180_ops = {
@@ -587,6 +620,7 @@ static int adv7180_probe(struct i2c_client *client,
state->irq = client->irq;
mutex_init(&state->mutex);
state->autodetect = true;
+   state->powered = true;
state->input = 0;
sd = &state->sd;
v4l2_i2c_subdev_init(sd, client, &adv7180_ops);
@@ -640,13 +674,10 @@ static const struct i2c_device_id adv7180_id[] = {
 static int adv7180_suspend(struct device *dev)
 {
struct i2c_client *client = to_i2c_client(dev);
-   int ret;
+   struct v4l2_subdev *sd = i2c_get_clientdata(client);
+   struct adv7180_state *state = to_state(sd);
 
-   ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG,
-   ADV7180_PWR_MAN_OFF);
-   if (ret < 0)
-   return ret;
-   return 0;
+   return adv7180_set_power(state, client, false);
 }
 
 static int adv7180_resume(struct device *dev)
@@ -656,10 +687,11 @@ static int adv7180_resume(struct device *dev)
struct adv7180_state *state = to_state(sd);
int ret;
 
-   ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG,
-   ADV7180_PWR_MAN_ON);
-   if (ret < 0)
-   return ret;
+   if (state->powered) {
+   ret = adv7180_set_power(state, client, true);
+   if (ret)
+   return ret;
+   }
ret = init_device(client, state);
if (ret < 0)
return ret;
-- 
1.8.0

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


Re: Question about set format call check for vb2_is_busy

2014-03-10 Thread m silverstri
On Mon, Mar 10, 2014 at 12:21 AM, Hans Verkuil  wrote:
> On 03/10/2014 08:02 AM, m silverstri wrote:
>> Hi,
>>
>> I am studying v4l2 m2m driver example. I want to know why the set
>> format function in the example fails when it is called again after
>> user application req_buf? In set format function checks for
>> vb2_is_busy(vq) and that function returns true after user space app
>> calls req_buf.
>>
>> For example in here:
>> http://stuff.mit.edu/afs/sipb/contrib/linux/drivers/media/platform/mem2mem_testdev.c
>>
>> static int vidioc_s_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f)
>> {
>> //...
>> // Check for vb2_is_busy() here:
>> if (vb2_is_busy(vq)) {
>> v4l2_err(&ctx->dev->v4l2_dev, "%s queue busy\n", __func__);
>> return -EBUSY;
>> }
>> //...
>> }
>>
>> Why the driver prevents user space application change format after it
>> request buffers?
>
> When you request the buffers they will be allocated based on the current 
> format.
> Changing the format later will mean a change in buffer size, but once the 
> buffers
> are allocated that is locked in place. It's generally a bad idea to, say, 
> increase
> the image size and then watch how DMA overwrites your memory :-)
>
> This is not strictly speaking a v4l limitation, but a limitation of almost all
> hardware. It is possible to allow format changes after reqbufs is called, but
> that generally requires that the buffers all have the maximum possible size
> which wastes a lot of memory. And in addition you would have to have some sort
> of metadata as part of the captured frame so you know the actual size of the
> image stored in the buffer.
>
> None of the drivers in the kernel support this, BTW.
>
> Regards,
>
> Hans

Hans,

Thank you.

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


Re: [REVIEW PATCH 0/3] Add g_tvnorms video op

2014-03-10 Thread Laurent Pinchart
Hi Hans,

Thank you for the patches.

On Monday 17 February 2014 12:44:11 Hans Verkuil wrote:
> This patch series addresses a problem that was exposed by commit a5338190e.
> The issue is that soc_camera implements s/g_std ioctls and just forwards
> those to the subdev, whether or not the subdev actually implements them.
> 
> In addition, tvnorms is never set, so even if the subdev implements the
> s/g_std the ENUMSTD ioctl will not report anything.
> 
> The solution is to add a g_tvnorms video op to v4l2_subdev (there was
> already a g_tvnorms_output, so that fits nicely) and to let soc_camera call
> that so the video_device tvnorms field is set correctly.
> 
> Before registering the video node it will check if tvnorms == 0 and disable
> the STD ioctls if that's the case.
> 
> While this problem cropped up in soc_camera it is really a problem for any
> generic bridge driver, so this is useful to have.
> 
> Note that it is untested. The plan is that Laurent tests and Guennadi pulls
> it into his tree.

I've tested the series on v3.10 with the atmel-isi driver. Without the patches 
applied ENUMSTD returns -ENODATA, and with the patches applied it returns -
ENOTTY.

Tested-by: Laurent Pinchart 
Acked-by: Laurent Pinchart 

-- 
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: [RFC PATCH] [media]: of: move graph helpers from drivers/media/v4l2-core to drivers/of

2014-03-10 Thread Philipp Zabel
Am Montag, den 10.03.2014, 16:15 +0100 schrieb Laurent Pinchart:
> Hi Grant,
> 
> On Monday 10 March 2014 14:58:15 Grant Likely wrote:
> > On Mon, 10 Mar 2014 14:52:53 +0100, Laurent Pinchart wrote:
> > > On Monday 10 March 2014 12:18:20 Tomi Valkeinen wrote:
> > > > On 08/03/14 13:41, Grant Likely wrote:
> > > > >> Ok. If we go for single directional link, the question is then: which
> > > > >> way? And is the direction different for display and camera, which are
> > > > >> kind of reflections of each other?
> > > > > 
> > > > > In general I would recommend choosing whichever device you would
> > > > > sensibly think of as a master. In the camera case I would choose the
> > > > > camera controller node instead of the camera itself, and in the
> > > > > display case I would choose the display controller instead of the
> > > > > panel. The binding author needs to choose what she things makes the
> > > > > most sense, but drivers can still use if it it turns out to be
> > > > > 'backwards'
> > > > 
> > > > I would perhaps choose the same approach, but at the same time I think
> > > > it's all but clear. The display controller doesn't control the panel any
> > > > more than a DMA controller controls, say, the display controller.
> > > > 
> > > > In fact, in earlier versions of OMAP DSS DT support I had a simpler port
> > > > description, and in that I had the panel as the master (i.e. link from
> > > > panel to dispc) because the panel driver uses the display controller's
> > > > features to provide the panel device a data stream.
> > > > 
> > > > And even with the current OMAP DSS DT version, which uses the v4l2 style
> > > > ports/endpoints, the driver model is still the same, and only links
> > > > towards upstream are used.
> > > > 
> > > > So one reason I'm happy with the dual-linking is that I can easily
> > > > follow the links from the downstream entities to upstream entities, and
> > > > other people, who have different driver model, can easily do the
> > > > opposite.
> > > > 
> > > > But I agree that single-linking is enough and this can be handled at
> > > > runtime, even if it makes the code more complex. And perhaps requires
> > > > extra data in the dts, to give the start points for the graph.
> > > 
> > > In theory unidirectional links in DT are indeed enough. However, let's not
> > > forget the following.
> > > 
> > > - There's no such thing as single start points for graphs. Sure, in some
> > > simple cases the graph will have a single start point, but that's not a
> > > generic rule. For instance the camera graphs
> > > http://ideasonboard.org/media/omap3isp.ps and
> > > http://ideasonboard.org/media/eyecam.ps have two camera sensors, and thus
> > > two starting points from a data flow point of view. And if you want a
> > > better understanding of how complex media graphs can become, have a look
> > > at http://ideasonboard.org/media/vsp1.0.pdf (that's a real world example,
> > > albeit all connections are internal to the SoC in that particular case,
> > > and don't need to be described in DT).
> > > 
> > > - There's also no such thing as a master device that can just point to
> > > slave devices. Once again simple cases exist where that model could work,
> > > but real world examples exist of complex pipelines with dozens of
> > > elements all implemented by a separate IP core and handled by separate
> > > drivers, forming a graph with long chains and branches. We thus need real
> > > graph bindings.
> > > 
> > > - Finally, having no backlinks in DT would make the software
> > > implementation very complex. We need to be able to walk the graph in a
> > > generic way without having any of the IP core drivers loaded, and without
> > > any specific starting point. We would thus need to parse the complete DT
> > > tree, looking at all nodes and trying to find out whether they're part of
> > > the graph we're trying to walk. The complexity of the operation would be
> > > at best quadratic to the number of nodes in the whole DT and to the number
> > > of nodes in the graph.
> > 
> > Not really. To being with, you cannot determine any meaning of a node
> > across the tree (aside from it being an endpoint)
> 
> That's the important part. I can assume the target node of the 
> remote-endpoint 
> phandle to be an endpoint, and can thus assume that it implements the 
> of-graph 
> bindings. That's all I need to be able to walk the graph in a generic way.
> 
> > without also understanding the binding that the node is a part of. That
> > means you need to have something matching against the compatible string on
> > both ends of the linkage. For instance:
> > 
> > panel {
> > compatible = "acme,lvds-panel";
> > lvds-port: port {
> > };
> > };
> > 
> > display-controller {
> > compatible = "encom,video";
> > port {
> > remote-endpoint = <&lvds-port>;
> > };
> > };
> > 
> > In the above example, the encom,video driver has absolutely zero
> > information about what the a

Re: [PATCH] rtl2832u_sdr: fixing v4l2-compliance issues

2014-03-10 Thread Antti Palosaari

On 10.03.2014 17:36, Hans Verkuil wrote:

On 03/10/2014 04:29 PM, Antti Palosaari wrote:

Moikka Hans!

On 06.03.2014 01:21, Hans Verkuil wrote:

Antti,

Attached is a patch that fixed all but one v4l2-compliance error:

  fail: v4l2-test-controls.cpp(295): returned control value out 
of range
  fail: v4l2-test-controls.cpp(357): invalid control 00a2090c
  test VIDIOC_G/S_CTRL: FAIL
  fail: v4l2-test-controls.cpp(465): returned control value out 
of range
  fail: v4l2-test-controls.cpp(573): invalid control 00a2090c
  test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL

That's the BANDWIDTH control and it returned value 320 when the minimum was 
600.
I couldn't trace where that came from in the limited time I spent on it, I 
expect you
can find it much quicker.


That is because I added native V4L2_CID_RF_TUNER_BANDWIDTH support only
for E4000 tuner driver. The others, FC0012, FC0013 and R820T are set via
DVB API by rtl2832_sdr driver, which is quite hackish solution. Devices
having E4000 works correctly.

Dunno if it wise to hack rtl2832_sdr and clamp values to valid per tuner
or leave it as it is. Adding V4L2_CID_RF_TUNER_BANDWIDTH to those 3
tuner drivers is also quite trivial...


I recommend whatever is the best long-term solution :-)

It's good practice to fix such compliance errors. One reason is that 
v4l2-compliance
generally stops testing whatever ioctl it is testing once it finds a problem, 
so there
may be other failures lurking behind this one that v4l2-compliance won't find.

The other reason is that, well, it's a bug! So it should be fixed anyway.


Yeah it is bug. But I decided to convert only e4000 and wait some 
feedback until add v4l2 controls to those other supported drivers... OK, 
lets see if I can convert at least those FC0012 and FC0013 drivers now. 
That sdr driver is still on staging ;)


regards
Antti


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


Re: [PATCH] rtl2832u_sdr: fixing v4l2-compliance issues

2014-03-10 Thread Hans Verkuil
On 03/10/2014 04:29 PM, Antti Palosaari wrote:
> Moikka Hans!
> 
> On 06.03.2014 01:21, Hans Verkuil wrote:
>> Antti,
>>
>> Attached is a patch that fixed all but one v4l2-compliance error:
>>
>>  fail: v4l2-test-controls.cpp(295): returned control value 
>> out of range
>>  fail: v4l2-test-controls.cpp(357): invalid control 00a2090c
>>  test VIDIOC_G/S_CTRL: FAIL
>>  fail: v4l2-test-controls.cpp(465): returned control value 
>> out of range
>>  fail: v4l2-test-controls.cpp(573): invalid control 00a2090c
>>  test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
>>
>> That's the BANDWIDTH control and it returned value 320 when the minimum 
>> was 600.
>> I couldn't trace where that came from in the limited time I spent on it, I 
>> expect you
>> can find it much quicker.
> 
> That is because I added native V4L2_CID_RF_TUNER_BANDWIDTH support only 
> for E4000 tuner driver. The others, FC0012, FC0013 and R820T are set via 
> DVB API by rtl2832_sdr driver, which is quite hackish solution. Devices 
> having E4000 works correctly.
> 
> Dunno if it wise to hack rtl2832_sdr and clamp values to valid per tuner 
> or leave it as it is. Adding V4L2_CID_RF_TUNER_BANDWIDTH to those 3 
> tuner drivers is also quite trivial...

I recommend whatever is the best long-term solution :-)

It's good practice to fix such compliance errors. One reason is that 
v4l2-compliance
generally stops testing whatever ioctl it is testing once it finds a problem, 
so there
may be other failures lurking behind this one that v4l2-compliance won't find.

The other reason is that, well, it's a bug! So it should be fixed anyway.

Regards,

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


Re: [PATCH 7/7] [media] adv7180: Add support for power down

2014-03-10 Thread Lars-Peter Clausen

On 03/10/2014 04:28 PM, Hans Verkuil wrote:

On 03/10/2014 04:24 PM, Lars-Peter Clausen wrote:

On 03/10/2014 03:37 PM, Hans Verkuil wrote:
[...]

+
+static int adv7180_s_power(struct v4l2_subdev *sd, int on)
+{
+   struct adv7180_state *state = to_state(sd);
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   int ret;
+
+   ret = mutex_lock_interruptible(&state->mutex);
+   if (ret)
+   return ret;
+
+   ret = adv7180_set_power(state, client, on);
+   if (ret)
+   goto out;
+
+   state->powered = on;
+out:


I would change this to:

if (!ret)
state->powered = on;

and drop the 'goto'.



ok.

[...]

   static int adv7180_resume(struct device *dev)
@@ -656,10 +687,11 @@ static int adv7180_resume(struct device *dev)
struct adv7180_state *state = to_state(sd);
int ret;

-   ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG,
-   ADV7180_PWR_MAN_ON);
-   if (ret < 0)
-   return ret;
+   if (state->powered) {
+   ret = adv7180_set_power(state, client, true);
+   if (ret)
+   return ret;
+   }
ret = init_device(client, state);
if (ret < 0)
return ret;



What is the initial state of the driver when loaded? Shouldn't probe() set the
'powered' variable to true initially?


Yep, st->powered should be set to true by default.

What's your process in general, want me to resend the whole series, or are
you going to apply the patches that are ok?


When do you think you can have a fixed version of this patch ready? If it is
today/tomorrow, then I'll wait for that, otherwise I'll make a pull request
for the other 6 patches (which look fine).


I already have the updated version of the patch, will send it out soon.

- Lars


--
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] rtl2832u_sdr: fixing v4l2-compliance issues

2014-03-10 Thread Antti Palosaari

Moikka Hans!

On 06.03.2014 01:21, Hans Verkuil wrote:

Antti,

Attached is a patch that fixed all but one v4l2-compliance error:

 fail: v4l2-test-controls.cpp(295): returned control value out 
of range
 fail: v4l2-test-controls.cpp(357): invalid control 00a2090c
 test VIDIOC_G/S_CTRL: FAIL
 fail: v4l2-test-controls.cpp(465): returned control value out 
of range
 fail: v4l2-test-controls.cpp(573): invalid control 00a2090c
 test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL

That's the BANDWIDTH control and it returned value 320 when the minimum was 
600.
I couldn't trace where that came from in the limited time I spent on it, I 
expect you
can find it much quicker.


That is because I added native V4L2_CID_RF_TUNER_BANDWIDTH support only 
for E4000 tuner driver. The others, FC0012, FC0013 and R820T are set via 
DVB API by rtl2832_sdr driver, which is quite hackish solution. Devices 
having E4000 works correctly.


Dunno if it wise to hack rtl2832_sdr and clamp values to valid per tuner 
or leave it as it is. Adding V4L2_CID_RF_TUNER_BANDWIDTH to those 3 
tuner drivers is also quite trivial...


regards
Antti

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


Re: [PATCH 7/7] [media] adv7180: Add support for power down

2014-03-10 Thread Hans Verkuil
On 03/10/2014 04:24 PM, Lars-Peter Clausen wrote:
> On 03/10/2014 03:37 PM, Hans Verkuil wrote:
> [...]
>>> +
>>> +static int adv7180_s_power(struct v4l2_subdev *sd, int on)
>>> +{
>>> +   struct adv7180_state *state = to_state(sd);
>>> +   struct i2c_client *client = v4l2_get_subdevdata(sd);
>>> +   int ret;
>>> +
>>> +   ret = mutex_lock_interruptible(&state->mutex);
>>> +   if (ret)
>>> +   return ret;
>>> +
>>> +   ret = adv7180_set_power(state, client, on);
>>> +   if (ret)
>>> +   goto out;
>>> +
>>> +   state->powered = on;
>>> +out:
>>
>> I would change this to:
>>
>>  if (!ret)
>>  state->powered = on;
>>
>> and drop the 'goto'.
>>
> 
> ok.
> 
> [...]
>>>   static int adv7180_resume(struct device *dev)
>>> @@ -656,10 +687,11 @@ static int adv7180_resume(struct device *dev)
>>> struct adv7180_state *state = to_state(sd);
>>> int ret;
>>>
>>> -   ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG,
>>> -   ADV7180_PWR_MAN_ON);
>>> -   if (ret < 0)
>>> -   return ret;
>>> +   if (state->powered) {
>>> +   ret = adv7180_set_power(state, client, true);
>>> +   if (ret)
>>> +   return ret;
>>> +   }
>>> ret = init_device(client, state);
>>> if (ret < 0)
>>> return ret;
>>>
>>
>> What is the initial state of the driver when loaded? Shouldn't probe() set 
>> the
>> 'powered' variable to true initially?
> 
> Yep, st->powered should be set to true by default.
> 
> What's your process in general, want me to resend the whole series, or are 
> you going to apply the patches that are ok?

When do you think you can have a fixed version of this patch ready? If it is
today/tomorrow, then I'll wait for that, otherwise I'll make a pull request
for the other 6 patches (which look fine).

In any case there is no need to resend the whole series.

Regards,

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


Re: [PATCH 7/7] [media] adv7180: Add support for power down

2014-03-10 Thread Lars-Peter Clausen

On 03/10/2014 03:37 PM, Hans Verkuil wrote:
[...]

+
+static int adv7180_s_power(struct v4l2_subdev *sd, int on)
+{
+   struct adv7180_state *state = to_state(sd);
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   int ret;
+
+   ret = mutex_lock_interruptible(&state->mutex);
+   if (ret)
+   return ret;
+
+   ret = adv7180_set_power(state, client, on);
+   if (ret)
+   goto out;
+
+   state->powered = on;
+out:


I would change this to:

if (!ret)
state->powered = on;

and drop the 'goto'.



ok.

[...]

  static int adv7180_resume(struct device *dev)
@@ -656,10 +687,11 @@ static int adv7180_resume(struct device *dev)
struct adv7180_state *state = to_state(sd);
int ret;

-   ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG,
-   ADV7180_PWR_MAN_ON);
-   if (ret < 0)
-   return ret;
+   if (state->powered) {
+   ret = adv7180_set_power(state, client, true);
+   if (ret)
+   return ret;
+   }
ret = init_device(client, state);
if (ret < 0)
return ret;



What is the initial state of the driver when loaded? Shouldn't probe() set the
'powered' variable to true initially?


Yep, st->powered should be set to true by default.

What's your process in general, want me to resend the whole series, or are 
you going to apply the patches that are ok?


Thanks for the quick review,
- Lars

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


Re: [RFC PATCH] [media]: of: move graph helpers from drivers/media/v4l2-core to drivers/of

2014-03-10 Thread Laurent Pinchart
Hi Grant,

On Monday 10 March 2014 14:58:15 Grant Likely wrote:
> On Mon, 10 Mar 2014 14:52:53 +0100, Laurent Pinchart wrote:
> > On Monday 10 March 2014 12:18:20 Tomi Valkeinen wrote:
> > > On 08/03/14 13:41, Grant Likely wrote:
> > > >> Ok. If we go for single directional link, the question is then: which
> > > >> way? And is the direction different for display and camera, which are
> > > >> kind of reflections of each other?
> > > > 
> > > > In general I would recommend choosing whichever device you would
> > > > sensibly think of as a master. In the camera case I would choose the
> > > > camera controller node instead of the camera itself, and in the
> > > > display case I would choose the display controller instead of the
> > > > panel. The binding author needs to choose what she things makes the
> > > > most sense, but drivers can still use if it it turns out to be
> > > > 'backwards'
> > > 
> > > I would perhaps choose the same approach, but at the same time I think
> > > it's all but clear. The display controller doesn't control the panel any
> > > more than a DMA controller controls, say, the display controller.
> > > 
> > > In fact, in earlier versions of OMAP DSS DT support I had a simpler port
> > > description, and in that I had the panel as the master (i.e. link from
> > > panel to dispc) because the panel driver uses the display controller's
> > > features to provide the panel device a data stream.
> > > 
> > > And even with the current OMAP DSS DT version, which uses the v4l2 style
> > > ports/endpoints, the driver model is still the same, and only links
> > > towards upstream are used.
> > > 
> > > So one reason I'm happy with the dual-linking is that I can easily
> > > follow the links from the downstream entities to upstream entities, and
> > > other people, who have different driver model, can easily do the
> > > opposite.
> > > 
> > > But I agree that single-linking is enough and this can be handled at
> > > runtime, even if it makes the code more complex. And perhaps requires
> > > extra data in the dts, to give the start points for the graph.
> > 
> > In theory unidirectional links in DT are indeed enough. However, let's not
> > forget the following.
> > 
> > - There's no such thing as single start points for graphs. Sure, in some
> > simple cases the graph will have a single start point, but that's not a
> > generic rule. For instance the camera graphs
> > http://ideasonboard.org/media/omap3isp.ps and
> > http://ideasonboard.org/media/eyecam.ps have two camera sensors, and thus
> > two starting points from a data flow point of view. And if you want a
> > better understanding of how complex media graphs can become, have a look
> > at http://ideasonboard.org/media/vsp1.0.pdf (that's a real world example,
> > albeit all connections are internal to the SoC in that particular case,
> > and don't need to be described in DT).
> > 
> > - There's also no such thing as a master device that can just point to
> > slave devices. Once again simple cases exist where that model could work,
> > but real world examples exist of complex pipelines with dozens of
> > elements all implemented by a separate IP core and handled by separate
> > drivers, forming a graph with long chains and branches. We thus need real
> > graph bindings.
> > 
> > - Finally, having no backlinks in DT would make the software
> > implementation very complex. We need to be able to walk the graph in a
> > generic way without having any of the IP core drivers loaded, and without
> > any specific starting point. We would thus need to parse the complete DT
> > tree, looking at all nodes and trying to find out whether they're part of
> > the graph we're trying to walk. The complexity of the operation would be
> > at best quadratic to the number of nodes in the whole DT and to the number
> > of nodes in the graph.
> 
> Not really. To being with, you cannot determine any meaning of a node
> across the tree (aside from it being an endpoint)

That's the important part. I can assume the target node of the remote-endpoint 
phandle to be an endpoint, and can thus assume that it implements the of-graph 
bindings. That's all I need to be able to walk the graph in a generic way.

> without also understanding the binding that the node is a part of. That
> means you need to have something matching against the compatible string on
> both ends of the linkage. For instance:
> 
> panel {
>   compatible = "acme,lvds-panel";
>   lvds-port: port {
>   };
> };
> 
> display-controller {
>   compatible = "encom,video";
>   port {
>   remote-endpoint = <&lvds-port>;
>   };
> };
> 
> In the above example, the encom,video driver has absolutely zero
> information about what the acme,lvds-panel binding actually implements.
> There needs to be both a driver for the "acme,lvds-panel" binding and
> one for the "encom,video" binding (even if the acme,lvds-panel binding
> is very thin and defers the functionality to the video con

Re: [RFC PATCH] [media]: of: move graph helpers from drivers/media/v4l2-core to drivers/of

2014-03-10 Thread Grant Likely
On Mon, 10 Mar 2014 14:52:53 +0100, Laurent Pinchart 
 wrote:
> On Monday 10 March 2014 12:18:20 Tomi Valkeinen wrote:
> > On 08/03/14 13:41, Grant Likely wrote:
> > >> Ok. If we go for single directional link, the question is then: which
> > >> way? And is the direction different for display and camera, which are
> > >> kind of reflections of each other?
> > > 
> > > In general I would recommend choosing whichever device you would
> > > sensibly think of as a master. In the camera case I would choose the
> > > camera controller node instead of the camera itself, and in the display
> > > case I would choose the display controller instead of the panel. The
> > > binding author needs to choose what she things makes the most sense, but
> > > drivers can still use if it it turns out to be 'backwards'
> > 
> > I would perhaps choose the same approach, but at the same time I think
> > it's all but clear. The display controller doesn't control the panel any
> > more than a DMA controller controls, say, the display controller.
> > 
> > In fact, in earlier versions of OMAP DSS DT support I had a simpler port
> > description, and in that I had the panel as the master (i.e. link from
> > panel to dispc) because the panel driver uses the display controller's
> > features to provide the panel device a data stream.
> > 
> > And even with the current OMAP DSS DT version, which uses the v4l2 style
> > ports/endpoints, the driver model is still the same, and only links
> > towards upstream are used.
> > 
> > So one reason I'm happy with the dual-linking is that I can easily
> > follow the links from the downstream entities to upstream entities, and
> > other people, who have different driver model, can easily do the opposite.
> > 
> > But I agree that single-linking is enough and this can be handled at
> > runtime, even if it makes the code more complex. And perhaps requires
> > extra data in the dts, to give the start points for the graph.
> 
> In theory unidirectional links in DT are indeed enough. However, let's not 
> forget the following.
> 
> - There's no such thing as single start points for graphs. Sure, in some 
> simple cases the graph will have a single start point, but that's not a 
> generic rule. For instance the camera graphs 
> http://ideasonboard.org/media/omap3isp.ps and 
> http://ideasonboard.org/media/eyecam.ps have two camera sensors, and thus two 
> starting points from a data flow point of view. And if you want a better 
> understanding of how complex media graphs can become, have a look at 
> http://ideasonboard.org/media/vsp1.0.pdf (that's a real world example, albeit 
> all connections are internal to the SoC in that particular case, and don't 
> need to be described in DT).
> 
> - There's also no such thing as a master device that can just point to slave 
> devices. Once again simple cases exist where that model could work, but real 
> world examples exist of complex pipelines with dozens of elements all 
> implemented by a separate IP core and handled by separate drivers, forming a 
> graph with long chains and branches. We thus need real graph bindings.
> 
> - Finally, having no backlinks in DT would make the software implementation 
> very complex. We need to be able to walk the graph in a generic way without 
> having any of the IP core drivers loaded, and without any specific starting 
> point. We would thus need to parse the complete DT tree, looking at all nodes 
> and trying to find out whether they're part of the graph we're trying to 
> walk. 
> The complexity of the operation would be at best quadratic to the number of 
> nodes in the whole DT and to the number of nodes in the graph.

Not really. To being with, you cannot determine any meaning of a node
across the tree (aside from it being an endpoint) without also
understanding the binding that the node is a part of. That means you
need to have something matching against the compatible string on both
ends of the linkage. For instance:

panel {
compatible = "acme,lvds-panel";
lvds-port: port {
};
};

display-controller {
compatible = "encom,video";
port {
remote-endpoint = <&lvds-port>;
};
};

In the above example, the encom,video driver has absolutely zero
information about what the acme,lvds-panel binding actually implements.
There needs to be both a driver for the "acme,lvds-panel" binding and
one for the "encom,video" binding (even if the acme,lvds-panel binding
is very thin and defers the functionality to the video controller).

What you want here is the drivers to register each side of the
connection. That could be modeled with something like the following
(pseudocode):

struct of_endpoint {
struct list_head list;
struct device_node *ep_node;
void *context;
void (*cb)(struct of_endpoint *ep, void *data);
}

int of_register_port(struct device *node, void (*cb)(struct of_endpoint *ep, 
void *data), void *data)
{
struct of_endpoin

Re: [RFC PATCH] [media]: of: move graph helpers from drivers/media/v4l2-core to drivers/of

2014-03-10 Thread Grant Likely
On Mon, 10 Mar 2014 12:18:20 +0200, Tomi Valkeinen  
wrote:
> On 08/03/14 13:41, Grant Likely wrote:
> 
> >> Ok. If we go for single directional link, the question is then: which
> >> way? And is the direction different for display and camera, which are
> >> kind of reflections of each other?
> > 
> > In general I would recommend choosing whichever device you would
> > sensibly think of as a master. In the camera case I would choose the
> > camera controller node instead of the camera itself, and in the display
> > case I would choose the display controller instead of the panel. The
> > binding author needs to choose what she things makes the most sense, but
> > drivers can still use if it it turns out to be 'backwards'
> 
> I would perhaps choose the same approach, but at the same time I think
> it's all but clear. The display controller doesn't control the panel any
> more than a DMA controller controls, say, the display controller.

In a sense it doesn't actually matter. You sensibly want to choose the
most likely direction that drivers would go looking for a device it
depends on, but it can be matched up at runtime regardless of the
direction chosen by the binding.

g.
--
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: [GIT PULL] Move device tree graph parsing helpers to drivers/of

2014-03-10 Thread Grant Likely
On Mon, 10 Mar 2014 10:26:30 -0300, Mauro Carvalho Chehab 
 wrote:
> Em Fri, 07 Mar 2014 18:23:30 +
> Grant Likely  escreveu:
> 
> > On Thu, 06 Mar 2014 18:13:20 +0100, Philipp Zabel  
> > wrote:
> > > Hi Mauro, Russell,
> > > 
> > > I have temporarily removed the simplified bindings at Sylwester's
> > > request and updated the branch with the acks. The following changes
> > > since commit 0414855fdc4a40da05221fc6062cccbc0c30f169:
> > > 
> > >   Linux 3.14-rc5 (2014-03-02 18:56:16 -0800)
> > > 
> > > are available in the git repository at:
> > > 
> > >   git://git.pengutronix.de/git/pza/linux.git topic/of-graph
> > > 
> > > for you to fetch changes up to d484700a36952c6675aa47dec4d7a536929aa922:
> > > 
> > >   of: Warn if of_graph_parse_endpoint is called with the root node 
> > > (2014-03-06 17:41:54 +0100)
> > 
> > Nak. I made comments that haven't been resolved yet. I've replied with
> > more detail tonight. The big issues are how drivers handle the optional
> > 'ports' node and I do not agree to the double-linkage in the binding
> > description.
> 
> If I understood well, you're requesting to revert all those six patches
> that were imported via git pull from my tree (and from Greg and Russell),
> right?
> 
> E. g. reverting those changesets:
>   d484700a3695 f2a575f67695 4329b93b283c 6ff60d397b17 4d56ed5a009b 
> fd9fdb78a9bf
> 
> as it seems that there's no easy way to revert a git pull.

All trees containing the branch would need to be reverted.

> I suspect that this will likely cause some harm when merging from our
> trees upstream.

It means any tree containing that branch *must* be rewound. See my reply
to rmk. I've made a proposal on how I could be happy with leaving the
branches alone. I'm not particularly happy, but there is a way to
resolve things without reverts or rewinds.

g.
--
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 7/7] [media] adv7180: Add support for power down

2014-03-10 Thread Hans Verkuil
Hi Lars-Peter,

See some comments below:

On 03/07/2014 05:14 PM, Lars-Peter Clausen wrote:
> The adv7180 has a low power mode in which the analog and the digital 
> processing
> section are shut down. Implement the s_power callback to let bridge drivers 
> put
> the part into low power mode when not needed.
> 
> Signed-off-by: Lars-Peter Clausen 
> ---
>  drivers/media/i2c/adv7180.c | 52 
> -
>  1 file changed, 42 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index 623cec5..8271362 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -127,6 +127,7 @@ struct adv7180_state {
>   int irq;
>   v4l2_std_id curr_norm;
>   boolautodetect;
> + boolpowered;
>   u8  input;
>  };
>  #define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler,  \
> @@ -311,6 +312,39 @@ out:
>   return ret;
>  }
>  
> +static int adv7180_set_power(struct adv7180_state *state,
> + struct i2c_client *client, bool on)
> +{
> + u8 val;
> +
> + if (on)
> + val = ADV7180_PWR_MAN_ON;
> + else
> + val = ADV7180_PWR_MAN_OFF;
> +
> + return i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG, val);
> +}
> +
> +static int adv7180_s_power(struct v4l2_subdev *sd, int on)
> +{
> + struct adv7180_state *state = to_state(sd);
> + struct i2c_client *client = v4l2_get_subdevdata(sd);
> + int ret;
> +
> + ret = mutex_lock_interruptible(&state->mutex);
> + if (ret)
> + return ret;
> +
> + ret = adv7180_set_power(state, client, on);
> + if (ret)
> + goto out;
> +
> + state->powered = on;
> +out:

I would change this to:

if (!ret)
state->powered = on;

and drop the 'goto'.

> + mutex_unlock(&state->mutex);
> + return ret;
> +}
> +
>  static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl)
>  {
>   struct v4l2_subdev *sd = to_adv7180_sd(ctrl);
> @@ -441,6 +475,7 @@ static const struct v4l2_subdev_video_ops 
> adv7180_video_ops = {
>  
>  static const struct v4l2_subdev_core_ops adv7180_core_ops = {
>   .s_std = adv7180_s_std,
> + .s_power = adv7180_s_power,
>  };
>  
>  static const struct v4l2_subdev_ops adv7180_ops = {
> @@ -640,13 +675,9 @@ static const struct i2c_device_id adv7180_id[] = {
>  static int adv7180_suspend(struct device *dev)
>  {
>   struct i2c_client *client = to_i2c_client(dev);
> - int ret;
> + struct adv7180_state *state = to_state(sd);
>  
> - ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG,
> - ADV7180_PWR_MAN_OFF);
> - if (ret < 0)
> - return ret;
> - return 0;
> + return adv7180_set_power(state, client, false);
>  }
>  
>  static int adv7180_resume(struct device *dev)
> @@ -656,10 +687,11 @@ static int adv7180_resume(struct device *dev)
>   struct adv7180_state *state = to_state(sd);
>   int ret;
>  
> - ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG,
> - ADV7180_PWR_MAN_ON);
> - if (ret < 0)
> - return ret;
> + if (state->powered) {
> + ret = adv7180_set_power(state, client, true);
> + if (ret)
> + return ret;
> + }
>   ret = init_device(client, state);
>   if (ret < 0)
>   return ret;
> 

What is the initial state of the driver when loaded? Shouldn't probe() set the
'powered' variable to true initially?

Regards,

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


Re: [RFC PATCH] [media]: of: move graph helpers from drivers/media/v4l2-core to drivers/of

2014-03-10 Thread Tomi Valkeinen
On 10/03/14 15:52, Laurent Pinchart wrote:

> In theory unidirectional links in DT are indeed enough. However, let's not 
> forget the following.
> 
> - There's no such thing as single start points for graphs. Sure, in some 
> simple cases the graph will have a single start point, but that's not a 
> generic rule. For instance the camera graphs 
> http://ideasonboard.org/media/omap3isp.ps and 
> http://ideasonboard.org/media/eyecam.ps have two camera sensors, and thus two 
> starting points from a data flow point of view. And if you want a better 
> understanding of how complex media graphs can become, have a look at 
> http://ideasonboard.org/media/vsp1.0.pdf (that's a real world example, albeit 
> all connections are internal to the SoC in that particular case, and don't 
> need to be described in DT).
> 
> - There's also no such thing as a master device that can just point to slave 
> devices. Once again simple cases exist where that model could work, but real 
> world examples exist of complex pipelines with dozens of elements all 
> implemented by a separate IP core and handled by separate drivers, forming a 
> graph with long chains and branches. We thus need real graph bindings.
> 
> - Finally, having no backlinks in DT would make the software implementation 
> very complex. We need to be able to walk the graph in a generic way without 
> having any of the IP core drivers loaded, and without any specific starting 
> point. We would thus need to parse the complete DT tree, looking at all nodes 
> and trying to find out whether they're part of the graph we're trying to 
> walk. 
> The complexity of the operation would be at best quadratic to the number of 
> nodes in the whole DT and to the number of nodes in the graph.

I did use plural when I said "to give the start points...".

If you have a list of starting points in the DT, a "graph helper" or
something could create a runtime representation of the graph at some
early phase during the boot, which would include backlinks. The
individual drivers could use that runtime graph, instead of the DT graph.

But it still sounds considerably more complex than double-links in DT.

 Tomi




signature.asc
Description: OpenPGP digital signature


[REVIEWv1 PATCH 7/7] mem2mem_testdev: improve field handling

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

try_fmt should just set field to NONE and not return an error if
a different field was passed.

buf_prepare should check if the field passed in from userspace has a
supported field value. At the moment only NONE is supported and ANY
is mapped to NONE.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/mem2mem_testdev.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index dec8092..4f3096b 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -516,19 +516,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void 
*priv,
 
 static int vidioc_try_fmt(struct v4l2_format *f, struct m2mtest_fmt *fmt)
 {
-   enum v4l2_field field;
-
-   field = f->fmt.pix.field;
-
-   if (field == V4L2_FIELD_ANY)
-   field = V4L2_FIELD_NONE;
-   else if (V4L2_FIELD_NONE != field)
-   return -EINVAL;
-
/* V4L2 specification suggests the driver corrects the format struct
 * if any of the dimensions is unsupported */
-   f->fmt.pix.field = field;
-
if (f->fmt.pix.height < MIN_H)
f->fmt.pix.height = MIN_H;
else if (f->fmt.pix.height > MAX_H)
@@ -542,6 +531,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct 
m2mtest_fmt *fmt)
f->fmt.pix.width &= ~DIM_ALIGN_MASK;
f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
+   f->fmt.pix.field = V4L2_FIELD_NONE;
f->fmt.pix.priv = 0;
 
return 0;
@@ -760,6 +750,15 @@ static int m2mtest_buf_prepare(struct vb2_buffer *vb)
dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type);
 
q_data = get_q_data(ctx, vb->vb2_queue->type);
+   if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
+   if (vb->v4l2_buf.field == V4L2_FIELD_ANY)
+   vb->v4l2_buf.field = V4L2_FIELD_NONE;
+   if (vb->v4l2_buf.field != V4L2_FIELD_NONE) {
+   dprintk(ctx->dev, "%s field isn't supported\n",
+   __func__);
+   return -EINVAL;
+   }
+   }
 
if (vb2_plane_size(vb, 0) < q_data->sizeimage) {
dprintk(ctx->dev, "%s data will not fit into plane (%lu < 
%lu)\n",
-- 
1.9.0

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


[REVIEWv1 PATCH 3/7] mem2mem_testdev: set priv to 0

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

v4l2_compliance fix.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/mem2mem_testdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index 104d863..c4b54f8 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -532,6 +532,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct 
m2mtest_fmt *fmt)
f->fmt.pix.width &= ~DIM_ALIGN_MASK;
f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
+   f->fmt.pix.priv = 0;
 
return 0;
 }
-- 
1.9.0

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


[REVIEWv1 PATCH 2/7] mem2mem_testdev: pick default format with try_fmt.

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

This resolves an issue raised by v4l2-compliance: if the given format does
not exist, then pick a default format.

While there is an exception regarding this for TV capture drivers, this
m2m driver should do the right thing.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/mem2mem_testdev.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index 5c6067d..104d863 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -543,7 +543,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void 
*priv,
struct m2mtest_ctx *ctx = file2ctx(file);
 
fmt = find_format(f);
-   if (!fmt || !(fmt->types & MEM2MEM_CAPTURE)) {
+   if (!fmt) {
+   f->fmt.pix.pixelformat = formats[0].fourcc;
+   fmt = find_format(f);
+   }
+   if (!(fmt->types & MEM2MEM_CAPTURE)) {
v4l2_err(&ctx->dev->v4l2_dev,
 "Fourcc format (0x%08x) invalid.\n",
 f->fmt.pix.pixelformat);
@@ -561,7 +565,11 @@ static int vidioc_try_fmt_vid_out(struct file *file, void 
*priv,
struct m2mtest_ctx *ctx = file2ctx(file);
 
fmt = find_format(f);
-   if (!fmt || !(fmt->types & MEM2MEM_OUTPUT)) {
+   if (!fmt) {
+   f->fmt.pix.pixelformat = formats[0].fourcc;
+   fmt = find_format(f);
+   }
+   if (!(fmt->types & MEM2MEM_OUTPUT)) {
v4l2_err(&ctx->dev->v4l2_dev,
 "Fourcc format (0x%08x) invalid.\n",
 f->fmt.pix.pixelformat);
-- 
1.9.0

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


[REVIEWv1 PATCH 1/7] mem2mem_testdev: use 40ms default transfer time.

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

The default of 1 second is a bit painful, switch to a 25 Hz framerate.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/mem2mem_testdev.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index 4bb5e88..5c6067d 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -60,9 +60,7 @@ MODULE_PARM_DESC(debug, "activates debug info");
 #define MEM2MEM_VID_MEM_LIMIT  (16 * 1024 * 1024)
 
 /* Default transaction time in msec */
-#define MEM2MEM_DEF_TRANSTIME  1000
-/* Default number of buffers per transaction */
-#define MEM2MEM_DEF_TRANSLEN   1
+#define MEM2MEM_DEF_TRANSTIME  40
 #define MEM2MEM_COLOR_STEP (0xff >> 4)
 #define MEM2MEM_NUM_TILES  8
 
@@ -804,10 +802,10 @@ static const struct v4l2_ctrl_config 
m2mtest_ctrl_trans_time_msec = {
.id = V4L2_CID_TRANS_TIME_MSEC,
.name = "Transaction Time (msec)",
.type = V4L2_CTRL_TYPE_INTEGER,
-   .def = 1001,
+   .def = MEM2MEM_DEF_TRANSTIME,
.min = 1,
.max = 10001,
-   .step = 100,
+   .step = 1,
 };
 
 static const struct v4l2_ctrl_config m2mtest_ctrl_trans_num_bufs = {
-- 
1.9.0

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


[REVIEWv1 PATCH 5/7] mem2mem_testdev: return pending buffers in stop_streaming()

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

To keep the vb2 buffer administration in balance stop_streaming() must
return any pending buffers to the vb2 framework.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/mem2mem_testdev.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index 8e2aed2..1ba1a83 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -768,10 +768,31 @@ static void m2mtest_buf_queue(struct vb2_buffer *vb)
v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
 }
 
+static int m2mtest_stop_streaming(struct vb2_queue *q)
+{
+   struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
+   struct vb2_buffer *vb;
+   unsigned long flags;
+
+   for (;;) {
+   if (V4L2_TYPE_IS_OUTPUT(q->type))
+   vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
+   else
+   vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
+   if (vb == NULL)
+   return 0;
+   spin_lock_irqsave(&ctx->dev->irqlock, flags);
+   v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR);
+   spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
+   }
+   return 0;
+}
+
 static struct vb2_ops m2mtest_qops = {
.queue_setup = m2mtest_queue_setup,
.buf_prepare = m2mtest_buf_prepare,
.buf_queue   = m2mtest_buf_queue,
+   .stop_streaming  = m2mtest_stop_streaming,
.wait_prepare= vb2_ops_wait_prepare,
.wait_finish = vb2_ops_wait_finish,
 };
-- 
1.9.0

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


[REVIEWv1 PATCH 6/7] mem2mem_testdev: fix field, sequence and time copying

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

- Set the sequence counters correctly.
- Copy timestamps, timecode, relevant buffer flags and field from
  the received buffer to the outgoing buffer.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/mem2mem_testdev.c | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index 1ba1a83..dec8092 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -112,6 +112,7 @@ struct m2mtest_q_data {
unsigned intwidth;
unsigned intheight;
unsigned intsizeimage;
+   unsigned intsequence;
struct m2mtest_fmt  *fmt;
 };
 
@@ -234,12 +235,21 @@ static int device_process(struct m2mtest_ctx *ctx,
bytes_left = bytesperline - tile_w * MEM2MEM_NUM_TILES;
w = 0;
 
+   out_vb->v4l2_buf.sequence = get_q_data(ctx, 
V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++;
+   in_vb->v4l2_buf.sequence = q_data->sequence++;
memcpy(&out_vb->v4l2_buf.timestamp,
&in_vb->v4l2_buf.timestamp,
sizeof(struct timeval));
-   out_vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
-   out_vb->v4l2_buf.flags |=
-   in_vb->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   if (in_vb->v4l2_buf.flags & V4L2_BUF_FLAG_TIMECODE)
+   memcpy(&out_vb->v4l2_buf.timecode, &in_vb->v4l2_buf.timecode,
+   sizeof(struct v4l2_timecode));
+   out_vb->v4l2_buf.field = in_vb->v4l2_buf.field;
+   out_vb->v4l2_buf.flags = in_vb->v4l2_buf.flags &
+   (V4L2_BUF_FLAG_TIMECODE |
+V4L2_BUF_FLAG_KEYFRAME |
+V4L2_BUF_FLAG_PFRAME |
+V4L2_BUF_FLAG_BFRAME |
+V4L2_BUF_FLAG_TSTAMP_SRC_MASK);
 
switch (ctx->mode) {
case MEM2MEM_HFLIP | MEM2MEM_VFLIP:
@@ -765,9 +775,19 @@ static int m2mtest_buf_prepare(struct vb2_buffer *vb)
 static void m2mtest_buf_queue(struct vb2_buffer *vb)
 {
struct m2mtest_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
+
v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
 }
 
+static int m2mtest_start_streaming(struct vb2_queue *q, unsigned count)
+{
+   struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
+   struct m2mtest_q_data *q_data = get_q_data(ctx, q->type);
+
+   q_data->sequence = 0;
+   return 0;
+}
+
 static int m2mtest_stop_streaming(struct vb2_queue *q)
 {
struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
@@ -792,6 +812,7 @@ static struct vb2_ops m2mtest_qops = {
.queue_setup = m2mtest_queue_setup,
.buf_prepare = m2mtest_buf_prepare,
.buf_queue   = m2mtest_buf_queue,
+   .start_streaming = m2mtest_start_streaming,
.stop_streaming  = m2mtest_stop_streaming,
.wait_prepare= vb2_ops_wait_prepare,
.wait_finish = vb2_ops_wait_finish,
-- 
1.9.0

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


[REVIEWv1 PATCH 4/7] mem2mem_testdev: add USERPTR support.

2014-03-10 Thread Hans Verkuil
From: Hans Verkuil 

There is no reason why we shouldn't enable this here.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/mem2mem_testdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index c4b54f8..8e2aed2 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -782,7 +782,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, 
struct vb2_queue *ds
int ret;
 
src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-   src_vq->io_modes = VB2_MMAP | VB2_DMABUF;
+   src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
src_vq->drv_priv = ctx;
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->ops = &m2mtest_qops;
@@ -795,7 +795,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, 
struct vb2_queue *ds
return ret;
 
dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-   dst_vq->io_modes = VB2_MMAP | VB2_DMABUF;
+   dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
dst_vq->drv_priv = ctx;
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->ops = &m2mtest_qops;
-- 
1.9.0

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


[REVIEWv1 PATCH 0/7] mem2mem_testdev: fixes and minor enhancements

2014-03-10 Thread Hans Verkuil
This patch series fixes a number of v4l2-compliance problems and some small
enhancements (a better default transfer time and adding USERPTR support).

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


  1   2   >