cron job: media_tree daily build: ERRORS

2015-01-23 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:   Sat Jan 24 04:00:19 CET 2015
git branch: test
git hash:   1fc77d013ba85a29e2edfaba02fd21e8c8187fae
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-41-g6c2d743
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:3.18.0-1.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: ERRORS
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.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
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.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16-i686: OK
linux-3.17.8-i686: OK
linux-3.18-i686: OK
linux-3.19-rc4-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
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.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18-x86_64: OK
linux-3.19-rc4-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Saturday.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: [GIT PULL for v3.19-rc6] media fixes

2015-01-23 Thread Linus Torvalds
On Sat, Jan 24, 2015 at 1:26 AM, Mauro Carvalho Chehab
 wrote:
>
> Please pull from:
>   git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
> media/v3.19-4

That does not exist.

The tip of that linux-media tree does match the commit you claim is
the tip but that's just the unsigned 'master' branch/. The tag you
list just doesn't exist at all. There's a v3.19-3, but no 4.

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


[PATCH v5] media: au0828 - convert to use videobuf2

2015-01-23 Thread Shuah Khan
Convert au0828 to use videobuf2. Tested with NTSC.
Tested video and vbi devices with xawtv, tvtime,
and vlc. Ran v4l2-compliance to ensure there are
no failures. 

Video compliance test results summary:
Total: 75, Succeeded: 75, Failed: 0, Warnings: 18

Vbi compliance test results summary:
Total: 75, Succeeded: 75, Failed: 0, Warnings: 0

Signed-off-by: Shuah Khan 
---
Changes since patch v4:
- Updated commit log with correct compliance test
  results.
Changes since patch v3:
- Removed unnecessary ret = 0 in au0828_v4l2_open()
- Rest of the patches in the v3 series are good.
  No need to resend them.

 drivers/media/usb/au0828/Kconfig|   2 +-
 drivers/media/usb/au0828/au0828-vbi.c   | 122 ++--
 drivers/media/usb/au0828/au0828-video.c | 962 
 drivers/media/usb/au0828/au0828.h   |  61 +-
 4 files changed, 443 insertions(+), 704 deletions(-)

diff --git a/drivers/media/usb/au0828/Kconfig b/drivers/media/usb/au0828/Kconfig
index 1d410ac..78b797e 100644
--- a/drivers/media/usb/au0828/Kconfig
+++ b/drivers/media/usb/au0828/Kconfig
@@ -4,7 +4,7 @@ config VIDEO_AU0828
depends on I2C && INPUT && DVB_CORE && USB
select I2C_ALGOBIT
select VIDEO_TVEEPROM
-   select VIDEOBUF_VMALLOC
+   select VIDEOBUF2_VMALLOC
select DVB_AU8522_DTV if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_MXL5007T if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/usb/au0828/au0828-vbi.c 
b/drivers/media/usb/au0828/au0828-vbi.c
index 932d24f..f67247c 100644
--- a/drivers/media/usb/au0828/au0828-vbi.c
+++ b/drivers/media/usb/au0828/au0828-vbi.c
@@ -28,111 +28,67 @@
 #include 
 #include 
 
-static unsigned int vbibufs = 5;
-module_param(vbibufs, int, 0644);
-MODULE_PARM_DESC(vbibufs, "number of vbi buffers, range 2-32");
-
 /* -- */
 
-static void
-free_buffer(struct videobuf_queue *vq, struct au0828_buffer *buf)
+static int vbi_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
+  unsigned int *nbuffers, unsigned int *nplanes,
+  unsigned int sizes[], void *alloc_ctxs[])
 {
-   struct au0828_fh *fh  = vq->priv_data;
-   struct au0828_dev*dev = fh->dev;
-   unsigned long flags = 0;
-   if (in_interrupt())
-   BUG();
-
-   /* We used to wait for the buffer to finish here, but this didn't work
-  because, as we were keeping the state as VIDEOBUF_QUEUED,
-  videobuf_queue_cancel marked it as finished for us.
-  (Also, it could wedge forever if the hardware was misconfigured.)
-
-  This should be safe; by the time we get here, the buffer isn't
-  queued anymore. If we ever start marking the buffers as
-  VIDEOBUF_ACTIVE, it won't be, though.
-   */
-   spin_lock_irqsave(&dev->slock, flags);
-   if (dev->isoc_ctl.vbi_buf == buf)
-   dev->isoc_ctl.vbi_buf = NULL;
-   spin_unlock_irqrestore(&dev->slock, flags);
+   struct au0828_dev *dev = vb2_get_drv_priv(vq);
+   unsigned long img_size = dev->vbi_width * dev->vbi_height * 2;
+   unsigned long size;
 
-   videobuf_vmalloc_free(&buf->vb);
-   buf->vb.state = VIDEOBUF_NEEDS_INIT;
-}
-
-static int
-vbi_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
-{
-   struct au0828_fh *fh  = q->priv_data;
-   struct au0828_dev*dev = fh->dev;
+   size = fmt ? (fmt->fmt.vbi.samples_per_line *
+   (fmt->fmt.vbi.count[0] + fmt->fmt.vbi.count[1])) : img_size;
+   if (size < img_size)
+   return -EINVAL;
 
-   *size = dev->vbi_width * dev->vbi_height * 2;
+   *nplanes = 1;
+   sizes[0] = size;
 
-   if (0 == *count)
-   *count = vbibufs;
-   if (*count < 2)
-   *count = 2;
-   if (*count > 32)
-   *count = 32;
return 0;
 }
 
-static int
-vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
-   enum v4l2_field field)
+static int vbi_buffer_prepare(struct vb2_buffer *vb)
 {
-   struct au0828_fh *fh  = q->priv_data;
-   struct au0828_dev*dev = fh->dev;
+   struct au0828_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
struct au0828_buffer *buf = container_of(vb, struct au0828_buffer, vb);
-   int  rc = 0;
+   unsigned long size;
 
-   buf->vb.size = dev->vbi_width * dev->vbi_height * 2;
+   size = dev->vbi_width * dev->vbi_height * 2;
 
-   if (0 != buf->vb.baddr  &&  buf->vb.bsize < buf->vb.size)
+   if (vb2_plane_size(vb, 0) < size) {
+   pr_err("%s data will not fit into plane (%lu < %lu)\n",
+   __func__, vb2_plane_size(vb, 0), size);
return -EINVAL;
-
-   buf->vb.width  = dev->vbi_width;
-   buf->vb.height = dev->vbi_height;
-   buf-

Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Devin Heitmueller
Hi Shuah,

> TRY_FMT and S_FMT both don't handle invalid pixelformats. Looks like
> there is reason behind this based on the comments:
>
>  /* format->fmt.pix.width only support 720 and height 480 */
> if (width != 720)
> width = 720;
> if (height != 480)
> height = 480;

This actually isn't a bug, and in fact I believe the v4l2-compliance
tool prints out a URL to a thread you should read.  It has to do with
the HVR-950q hardware delivering UYVY video and the behavior being
unspecified for how non-supported pixel formats should be handled
until relatively recently.  As a result, it behaves that way so apps
like tvtime don't break due to expecting legacy behavior.

It has nothing to do with the resolution - in fact the driver is doing
exactly what it is supposed to (if you provide an unsupported
resolution, the driver is supposed to pass back a resolution that is
good and still return success).  It's the application's responsibility
to look at the resolution in the struct after the ioctl call and make
sure it hasn't changed (and if it has, the app should adjust its
expectations accordingly).

Devin

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


Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Shuah Khan
On 01/23/2015 12:17 PM, Shuah Khan wrote:
> On 01/23/2015 08:00 AM, Shuah Khan wrote:
>> On 01/23/2015 02:50 AM, Hans Verkuil wrote:
>>> Hi Shuah,
>>>
>>> On 01/23/2015 12:42 AM, Shuah Khan wrote:
 Convert au0828 to use videobuf2. Tested with NTSC.
 Tested video and vbi devices with xawtv, tvtime,
 and vlc. Ran v4l2-compliance to ensure there are
 no regressions. video now has no failures and vbi
 has 3 fewer failures.

 video before:
 test VIDIOC_G_FMT: FAIL 3 failures
 Total: 72, Succeeded: 69, Failed: 3, Warnings: 0

 Video after:
 Total: 72, Succeeded: 72, Failed: 0, Warnings: 18

 vbi before:
 test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
 test VIDIOC_EXPBUF: FAIL
 test USERPTR: FAIL
 Total: 72, Succeeded: 66, Failed: 6, Warnings: 0

 vbi after:
 test VIDIOC_QUERYCAP: FAIL
 test MMAP: FAIL
 Total: 78, Succeeded: 75, Failed: 3, Warnings: 0
>>>
>>> There shouldn't be any fails for VBI. That really needs to be fixed.
>>> Esp. the QUERYCAP fail should be easy to fix.
>>>
>>> BTW, can you paste the full v4l2-compliance output next time? That's
>>> more informative than just these summaries.
>>>
>>
>> I will re-run the tests and fix it and resend the patch. I think I was
>> seeing querycap compliance failure when run with -V0 option and not when
>> I run it without. I can attach the full log.
>>
> 
> Hi Hans,
> 
> Finally some sanity. When I ran the compliance test on vbi device
> with incorrect options, hence it was treated as a video device which
> explains the following fail message:
> fail: v4l2-compliance.cpp(347): node->is_video && !(dcaps & video_caps)
>   test VIDIOC_QUERYCAP: FAIL
> 
> This is my bad - I must have did command recall and just changed the
> device file. Sorry for the confusion.
> 
> Re-ran the test correctly this time and I don't see any querycap errors.
> Please see attached files for vbi and video. I will resend the patch
> with updated change log with the correct results.
> 
TRY_FMT and S_FMT both don't handle invalid pixelformats. Looks like
there is reason behind this based on the comments:

 /* format->fmt.pix.width only support 720 and height 480 */
if (width != 720)
width = 720;
if (height != 480)
height = 480;

-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Shuah Khan
On 01/23/2015 08:00 AM, Shuah Khan wrote:
> On 01/23/2015 02:50 AM, Hans Verkuil wrote:
>> Hi Shuah,
>>
>> On 01/23/2015 12:42 AM, Shuah Khan wrote:
>>> Convert au0828 to use videobuf2. Tested with NTSC.
>>> Tested video and vbi devices with xawtv, tvtime,
>>> and vlc. Ran v4l2-compliance to ensure there are
>>> no regressions. video now has no failures and vbi
>>> has 3 fewer failures.
>>>
>>> video before:
>>> test VIDIOC_G_FMT: FAIL 3 failures
>>> Total: 72, Succeeded: 69, Failed: 3, Warnings: 0
>>>
>>> Video after:
>>> Total: 72, Succeeded: 72, Failed: 0, Warnings: 18
>>>
>>> vbi before:
>>> test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
>>> test VIDIOC_EXPBUF: FAIL
>>> test USERPTR: FAIL
>>> Total: 72, Succeeded: 66, Failed: 6, Warnings: 0
>>>
>>> vbi after:
>>> test VIDIOC_QUERYCAP: FAIL
>>> test MMAP: FAIL
>>> Total: 78, Succeeded: 75, Failed: 3, Warnings: 0
>>
>> There shouldn't be any fails for VBI. That really needs to be fixed.
>> Esp. the QUERYCAP fail should be easy to fix.
>>
>> BTW, can you paste the full v4l2-compliance output next time? That's
>> more informative than just these summaries.
>>
> 
> I will re-run the tests and fix it and resend the patch. I think I was
> seeing querycap compliance failure when run with -V0 option and not when
> I run it without. I can attach the full log.
> 

Hi Hans,

Finally some sanity. When I ran the compliance test on vbi device
with incorrect options, hence it was treated as a video device which
explains the following fail message:
fail: v4l2-compliance.cpp(347): node->is_video && !(dcaps & video_caps)
test VIDIOC_QUERYCAP: FAIL

This is my bad - I must have did command recall and just changed the
device file. Sorry for the confusion.

Re-ran the test correctly this time and I don't see any querycap errors.
Please see attached files for vbi and video. I will resend the patch
with updated change log with the correct results.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
Driver Info:
Driver name   : au0828
Card type : Hauppauge HVR950Q
Bus info  : usb-:00:10.1-2
Driver version: 3.19.0
Capabilities  : 0x85230011
Video Capture
VBI Capture
Tuner
Audio
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x05230010
VBI Capture
Tuner
Audio
Read/Write
Streaming
Extended Pix Format

Compliance test for device /dev/vbi0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second vbi open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK
test VIDIOC_G/S_FREQUENCY: OK
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK
Inputs: 3 Audio Inputs: 2 Tuners: 1

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 5 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not 
Supported)
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer io

[PATCH 03/21] [media] coda: remove context debugfs entry last

2015-01-23 Thread Philipp Zabel
Do not remove the per-context debugfs directory before the
per-buffer debugfs entries contained therein.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 1cc4e90..9a0ee11 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1693,8 +1693,6 @@ static int coda_release(struct file *file)
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, "Releasing instance %p\n",
 ctx);
 
-   debugfs_remove_recursive(ctx->debugfs_entry);
-
if (ctx->inst_type == CODA_INST_DECODER)
coda_bit_stream_end_flag(ctx);
 
@@ -1728,6 +1726,7 @@ static int coda_release(struct file *file)
clear_bit(ctx->idx, &dev->instance_mask);
if (ctx->ops->release)
ctx->ops->release(ctx);
+   debugfs_remove_recursive(ctx->debugfs_entry);
kfree(ctx);
 
return 0;
-- 
2.1.4

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


[PATCH 11/21] [media] coda: fix width validity check when starting to decode

2015-01-23 Thread Philipp Zabel
From: Markus Pargmann 

Compare rounded up width to fit into bytesperline.

Signed-off-by: Markus Pargmann 
Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-bit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index d81635d..6ecfd29 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1431,9 +1431,10 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
height = val & CODA7_PICHEIGHT_MASK;
}
 
-   if (width > q_data_dst->width || height > q_data_dst->height) {
+   if (width > q_data_dst->bytesperline || height > q_data_dst->height) {
v4l2_err(&dev->v4l2_dev, "stream is %dx%d, not %dx%d\n",
-width, height, q_data_dst->width, q_data_dst->height);
+width, height, q_data_dst->bytesperline,
+q_data_dst->height);
return -EINVAL;
}
 
-- 
2.1.4

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


[PATCH 08/21] [media] coda: properly clear f_cap in coda_s_fmt_vid_out

2015-01-23 Thread Philipp Zabel
Properly zero the structure on the stack before using it.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index af8a4d6..7a6cb08 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -674,6 +674,7 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
 
ctx->colorspace = f->fmt.pix.colorspace;
 
+   memset(&f_cap, 0, sizeof(f_cap));
f_cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
coda_g_fmt(file, priv, &f_cap);
f_cap.fmt.pix.width = f->fmt.pix.width;
-- 
2.1.4

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


[PATCH 13/21] [media] coda: issue seq_end_work during stop_streaming

2015-01-23 Thread Philipp Zabel
This patch queues seq_end_work and flushes the queue during stop_streaming
and clears the ctx->initialized flag. This allows to start streaming again
after stopping streaming without releasing the context.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 611d737..6ea7e0a 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1323,6 +1323,10 @@ static void coda_stop_streaming(struct vb2_queue *q)
if (!ctx->streamon_out && !ctx->streamon_cap) {
struct coda_buffer_meta *meta;
 
+   if (ctx->ops->seq_end_work) {
+   queue_work(dev->workqueue, &ctx->seq_end_work);
+   flush_work(&ctx->seq_end_work);
+   }
mutex_lock(&ctx->bitstream_mutex);
while (!list_empty(&ctx->buffer_meta_list)) {
meta = list_first_entry(&ctx->buffer_meta_list,
@@ -1333,6 +1337,7 @@ static void coda_stop_streaming(struct vb2_queue *q)
mutex_unlock(&ctx->bitstream_mutex);
kfifo_init(&ctx->bitstream_fifo,
ctx->bitstream.vaddr, ctx->bitstream.size);
+   ctx->initialized = 0;
ctx->runcounter = 0;
ctx->aborting = 0;
}
-- 
2.1.4

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


[PATCH 10/21] [media] coda: clear RET_DEC_PIC_SUCCESS flag in prepare_decode

2015-01-23 Thread Philipp Zabel
To make sure a set RET_DEC_PIC_SUCCESS flag is not a leftover from
a previous successful run, clear it in prepare_decode.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-bit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index 6b00a45..d81635d 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1666,6 +1666,9 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
 
coda_kfifo_sync_to_device_full(ctx);
 
+   /* Clear decode success flag */
+   coda_write(dev, 0, CODA_RET_DEC_PIC_SUCCESS);
+
coda_command_async(ctx, CODA_COMMAND_PIC_RUN);
 
return 0;
-- 
2.1.4

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


[PATCH 16/21] [media] coda: switch BIT decoder source queue to vmalloc

2015-01-23 Thread Philipp Zabel
Since we have to copy from input buffers into the bitstream ringbuffer
with the CPU, there is no need for contiguous DMA buffers on the decoder
input side.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/Kconfig| 1 +
 drivers/media/platform/coda/coda-common.c | 6 --
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 765bffb..74c2101 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -140,6 +140,7 @@ config VIDEO_CODA
depends on HAS_DMA
select SRAM
select VIDEOBUF2_DMA_CONTIG
+   select VIDEOBUF2_VMALLOC
select V4L2_MEM2MEM_DEV
select GENERIC_ALLOCATOR
---help---
diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index f7fc355..24d9f8a 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "coda.h"
 
@@ -1121,6 +1122,7 @@ static int coda_queue_setup(struct vb2_queue *vq,
*nplanes = 1;
sizes[0] = size;
 
+   /* Set to vb2-dma-contig allocator context, ignored by vb2-vmalloc */
alloc_ctxs[0] = ctx->dev->alloc_ctx;
 
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
@@ -1567,8 +1569,8 @@ int coda_decoder_queue_init(void *priv, struct vb2_queue 
*src_vq,
int ret;
 
src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-   src_vq->io_modes = VB2_DMABUF | VB2_MMAP;
-   src_vq->mem_ops = &vb2_dma_contig_memops;
+   src_vq->io_modes = VB2_DMABUF | VB2_MMAP | VB2_USERPTR;
+   src_vq->mem_ops = &vb2_vmalloc_memops;
 
ret = coda_queue_init(priv, src_vq);
if (ret)
-- 
2.1.4

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


[PATCH 09/21] [media] coda: initialize SRAM on probe

2015-01-23 Thread Philipp Zabel
Zeroing the SRAM on probe helps with debugging SRAM contents.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 7a6cb08..5386b2c 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -2174,6 +2174,7 @@ static int coda_probe(struct platform_device *pdev)
if (!dev->iram.vaddr) {
dev_warn(&pdev->dev, "unable to alloc iram\n");
} else {
+   memset(dev->iram.vaddr, 0, dev->iram.size);
dev->iram.blob.data = dev->iram.vaddr;
dev->iram.blob.size = dev->iram.size;
dev->iram.dentry = debugfs_create_blob("iram", 0644,
-- 
2.1.4

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


[PATCH 19/21] [media] coda: add support for contexts that do not use the BIT processor

2015-01-23 Thread Philipp Zabel
In preparation for CODA9 JPEG support, allow contexts that
control hardware units directly, without the BIT processor.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 42 +--
 drivers/media/platform/coda/coda.h|  1 +
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 40074fa..2defa4b 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -181,6 +181,7 @@ struct coda_video_device {
const char *name;
enum coda_inst_type type;
const struct coda_context_ops *ops;
+   bool direct;
u32 src_formats[CODA_MAX_FORMATS];
u32 dst_formats[CODA_MAX_FORMATS];
 };
@@ -953,7 +954,7 @@ static int coda_job_ready(void *m2m_priv)
return 0;
}
 
-   if (ctx->inst_type == CODA_INST_DECODER) {
+   if (ctx->inst_type == CODA_INST_DECODER && ctx->use_bit) {
struct list_head *meta;
bool stream_end;
int num_metas;
@@ -1161,7 +1162,7 @@ static void coda_buf_queue(struct vb2_buffer *vb)
 * In the decoder case, immediately try to copy the buffer into the
 * bitstream ringbuffer and mark it as ready to be dequeued.
 */
-   if (ctx->inst_type == CODA_INST_DECODER &&
+   if (ctx->use_bit && ctx->inst_type == CODA_INST_DECODER &&
vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
/*
 * For backwards compatibility, queuing an empty buffer marks
@@ -1262,7 +1263,7 @@ static int coda_start_streaming(struct vb2_queue *q, 
unsigned int count)
return 0;
 
/* Allow BIT decoder device_run with no new buffers queued */
-   if (ctx->inst_type == CODA_INST_DECODER)
+   if (ctx->inst_type == CODA_INST_DECODER && ctx->use_bit)
v4l2_m2m_set_src_buffered(ctx->fh.m2m_ctx, true);
 
ctx->gopcounter = ctx->params.gop_size - 1;
@@ -1626,6 +1627,7 @@ static int coda_open(struct file *file)
ctx->cvd = to_coda_video_device(vdev);
ctx->inst_type = ctx->cvd->type;
ctx->ops = ctx->cvd->ops;
+   ctx->use_bit = !ctx->cvd->direct;
init_completion(&ctx->completion);
INIT_WORK(&ctx->pic_run_work, coda_pic_run_work);
if (ctx->ops->seq_end_work)
@@ -1680,22 +1682,24 @@ static int coda_open(struct file *file)
 
ctx->fh.ctrl_handler = &ctx->ctrls;
 
-   ret = coda_alloc_context_buf(ctx, &ctx->parabuf,
-CODA_PARA_BUF_SIZE, "parabuf");
-   if (ret < 0) {
-   v4l2_err(&dev->v4l2_dev, "failed to allocate parabuf");
-   goto err_dma_alloc;
-   }
+   if (ctx->use_bit) {
+   ret = coda_alloc_context_buf(ctx, &ctx->parabuf,
+CODA_PARA_BUF_SIZE, "parabuf");
+   if (ret < 0) {
+   v4l2_err(&dev->v4l2_dev, "failed to allocate parabuf");
+   goto err_dma_alloc;
+   }
 
-   ctx->bitstream.size = CODA_MAX_FRAME_SIZE;
-   ctx->bitstream.vaddr = dma_alloc_writecombine(
-   &dev->plat_dev->dev, ctx->bitstream.size,
-   &ctx->bitstream.paddr, GFP_KERNEL);
-   if (!ctx->bitstream.vaddr) {
-   v4l2_err(&dev->v4l2_dev,
-"failed to allocate bitstream ringbuffer");
-   ret = -ENOMEM;
-   goto err_dma_writecombine;
+   ctx->bitstream.size = CODA_MAX_FRAME_SIZE;
+   ctx->bitstream.vaddr = dma_alloc_writecombine(
+   &dev->plat_dev->dev, ctx->bitstream.size,
+   &ctx->bitstream.paddr, GFP_KERNEL);
+   if (!ctx->bitstream.vaddr) {
+   v4l2_err(&dev->v4l2_dev,
+"failed to allocate bitstream ringbuffer");
+   ret = -ENOMEM;
+   goto err_dma_writecombine;
+   }
}
kfifo_init(&ctx->bitstream_fifo,
ctx->bitstream.vaddr, ctx->bitstream.size);
@@ -1743,7 +1747,7 @@ static int coda_release(struct file *file)
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, "Releasing instance %p\n",
 ctx);
 
-   if (ctx->inst_type == CODA_INST_DECODER)
+   if (ctx->inst_type == CODA_INST_DECODER && ctx->use_bit)
coda_bit_stream_end_flag(ctx);
 
/* If this instance is running, call .job_abort and wait for it to end 
*/
diff --git a/drivers/media/platform/coda/coda.h 
b/drivers/media/platform/coda/coda.h
index 2ddfe51..0c35cd5 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -235,6 +235,7 @@ struct coda_ctx {
u32 frame_mem_ctrl;
int   

[PATCH 02/21] [media] coda: bitrate can only be set in kbps steps

2015-01-23 Thread Philipp Zabel
Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 39330a7..1cc4e90 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1407,7 +1407,7 @@ static const struct v4l2_ctrl_ops coda_ctrl_ops = {
 static void coda_encode_ctrls(struct coda_ctx *ctx)
 {
v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
-   V4L2_CID_MPEG_VIDEO_BITRATE, 0, 32767000, 1, 0);
+   V4L2_CID_MPEG_VIDEO_BITRATE, 0, 32767000, 1000, 0);
v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
V4L2_CID_MPEG_VIDEO_GOP_SIZE, 1, 60, 1, 16);
v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
-- 
2.1.4

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


[PATCH 17/21] [media] coda: make seq_end_work optional

2015-01-23 Thread Philipp Zabel
In preparation for CODA9 JPEG support, which doesn't have to call
SEQ_END on the BIT processor.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 24d9f8a..40074fa 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -921,7 +921,8 @@ static void coda_pic_run_work(struct work_struct *work)
ctx->ops->finish_run(ctx);
}
 
-   if (ctx->aborting || (!ctx->streamon_cap && !ctx->streamon_out))
+   if ((ctx->aborting || (!ctx->streamon_cap && !ctx->streamon_out)) &&
+   ctx->ops->seq_end_work)
queue_work(dev->workqueue, &ctx->seq_end_work);
 
mutex_unlock(&dev->coda_mutex);
@@ -1627,7 +1628,8 @@ static int coda_open(struct file *file)
ctx->ops = ctx->cvd->ops;
init_completion(&ctx->completion);
INIT_WORK(&ctx->pic_run_work, coda_pic_run_work);
-   INIT_WORK(&ctx->seq_end_work, ctx->ops->seq_end_work);
+   if (ctx->ops->seq_end_work)
+   INIT_WORK(&ctx->seq_end_work, ctx->ops->seq_end_work);
v4l2_fh_init(&ctx->fh, video_devdata(file));
file->private_data = &ctx->fh;
v4l2_fh_add(&ctx->fh);
@@ -1748,7 +1750,7 @@ static int coda_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
 
/* In case the instance was not running, we still need to call SEQ_END 
*/
-   if (ctx->initialized) {
+   if (ctx->initialized && ctx->ops->seq_end_work) {
queue_work(dev->workqueue, &ctx->seq_end_work);
flush_work(&ctx->seq_end_work);
}
-- 
2.1.4

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


[PATCH 01/21] [media] coda: fix encoder rate control parameter masks

2015-01-23 Thread Philipp Zabel
This patch fixes the ENC_SEQ_RC_PARA initial delay and bitrate masks.
These bit fields are 15 bit wide, not 7 bit.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda_regs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/coda/coda_regs.h 
b/drivers/media/platform/coda/coda_regs.h
index 8e015b8..7d02624 100644
--- a/drivers/media/platform/coda/coda_regs.h
+++ b/drivers/media/platform/coda/coda_regs.h
@@ -304,9 +304,9 @@
 #defineCODA_RATECONTROL_AUTOSKIP_OFFSET31
 #defineCODA_RATECONTROL_AUTOSKIP_MASK  0x01
 #defineCODA_RATECONTROL_INITIALDELAY_OFFSET16
-#defineCODA_RATECONTROL_INITIALDELAY_MASK  0x7f
+#defineCODA_RATECONTROL_INITIALDELAY_MASK  0x7fff
 #defineCODA_RATECONTROL_BITRATE_OFFSET 1
-#defineCODA_RATECONTROL_BITRATE_MASK   0x7f
+#defineCODA_RATECONTROL_BITRATE_MASK   0x7fff
 #defineCODA_RATECONTROL_ENABLE_OFFSET  0
 #defineCODA_RATECONTROL_ENABLE_MASK0x01
 #define CODA_CMD_ENC_SEQ_RC_BUF_SIZE   0x1b0
-- 
2.1.4

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


[PATCH 21/21] [media] coda: simplify check in coda_buf_queue

2015-01-23 Thread Philipp Zabel
Now that the bitstream buffer is only allocated for the BIT decoder
case, we can use bitstream.size to check for bitstream ringbuffer
operation.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index c19f4b7..3118076 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1154,6 +1154,7 @@ static int coda_buf_prepare(struct vb2_buffer *vb)
 static void coda_buf_queue(struct vb2_buffer *vb)
 {
struct coda_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
+   struct vb2_queue *vq = vb->vb2_queue;
struct coda_q_data *q_data;
 
q_data = get_q_data(ctx, vb->vb2_queue->type);
@@ -1162,8 +1163,7 @@ static void coda_buf_queue(struct vb2_buffer *vb)
 * In the decoder case, immediately try to copy the buffer into the
 * bitstream ringbuffer and mark it as ready to be dequeued.
 */
-   if (ctx->use_bit && ctx->inst_type == CODA_INST_DECODER &&
-   vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+   if (ctx->bitstream.size && vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
/*
 * For backwards compatibility, queuing an empty buffer marks
 * the stream end
-- 
2.1.4

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


[PATCH 04/21] [media] coda: move meta out of padding

2015-01-23 Thread Philipp Zabel
Handle an empty buffer metadata list without crashing. This can happen
if the decoder is fed a broken stream, or multiple compressed frames in
a single queued buffer.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-bit.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index b4029ae..f6cf337 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1565,6 +1565,7 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
struct vb2_buffer *dst_buf;
struct coda_dev *dev = ctx->dev;
struct coda_q_data *q_data_dst;
+   struct coda_buffer_meta *meta;
u32 reg_addr, reg_stride;
 
dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
@@ -1643,12 +1644,12 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
coda_write(dev, ctx->iram_info.axi_sram_use,
CODA7_REG_BIT_AXI_SRAM_USE);
 
-   if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG) {
-   struct coda_buffer_meta *meta;
+   meta = list_first_entry_or_null(&ctx->buffer_meta_list,
+   struct coda_buffer_meta, list);
+
+   if (meta && ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG) {
 
/* If this is the last buffer in the bitstream, add padding */
-   meta = list_first_entry(&ctx->buffer_meta_list,
- struct coda_buffer_meta, list);
if (meta->end == (ctx->bitstream_fifo.kfifo.in &
  ctx->bitstream_fifo.kfifo.mask)) {
static unsigned char buf[512];
-- 
2.1.4

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


[PATCH 05/21] [media] coda: adjust sequence offset after unexpected decoded frame

2015-01-23 Thread Philipp Zabel
From: Lucas Stach 

If userspace doesn't properly separate the bitstream input into
individual frames (which may happen for example on slightly
corrupted streams) the CODA hardware may decode more frames
than we expect. We already log an error in this case, but it's
also necessary to adjust the sequence offset. Otherwise we
spam the log with a sequence number mismatch on every frame
frame after the unexpected one.

Signed-off-by: Lucas Stach 
---
 drivers/media/platform/coda/coda-bit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index f6cf337..6b00a45 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1822,6 +1822,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
memset(&ctx->frame_metas[decoded_idx], 0,
   sizeof(struct coda_buffer_meta));
ctx->frame_metas[decoded_idx].sequence = val;
+   ctx->sequence_offset++;
}
mutex_unlock(&ctx->bitstream_mutex);
 
-- 
2.1.4

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


[PATCH 14/21] [media] coda: don't ever use subsampling ping-pong buffers as reconstructed reference buffers

2015-01-23 Thread Philipp Zabel
On i.MX6, two subsampling ping-pong buffers are used for motion estimation and
deblocking They should not be counted as framebuffers, or they will be also used
to store reconstructed frames, causing visible artifacts in P-frames.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-bit.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index 6ecfd29..7c5 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -718,6 +718,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)
struct vb2_buffer *buf;
int gamma, ret, value;
u32 dst_fourcc;
+   int num_fb;
u32 stride;
 
q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
@@ -983,12 +984,14 @@ static int coda_start_encoding(struct coda_ctx *ctx)
v4l2_err(v4l2_dev, "failed to allocate framebuffers\n");
goto out;
}
+   num_fb = 2;
stride = q_data_src->bytesperline;
} else {
ctx->num_internal_frames = 0;
+   num_fb = 0;
stride = 0;
}
-   coda_write(dev, ctx->num_internal_frames, CODA_CMD_SET_FRAME_BUF_NUM);
+   coda_write(dev, num_fb, CODA_CMD_SET_FRAME_BUF_NUM);
coda_write(dev, stride, CODA_CMD_SET_FRAME_BUF_STRIDE);
 
if (dev->devtype->product == CODA_7541) {
-- 
2.1.4

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


[PATCH 07/21] [media] coda: fix try_fmt_vid_out colorspace setting

2015-01-23 Thread Philipp Zabel
v4l2-compliance complains about invalid colorspace settings being accepted
on the output side. This patch only allows REC709 and JPEG.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index ea54337..af8a4d6 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -592,7 +592,11 @@ static int coda_try_fmt_vid_out(struct file *file, void 
*priv,
if (ret < 0)
return ret;
 
-   if (!f->fmt.pix.colorspace) {
+   switch (f->fmt.pix.colorspace) {
+   case V4L2_COLORSPACE_REC709:
+   case V4L2_COLORSPACE_JPEG:
+   break;
+   default:
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_JPEG)
f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
else
-- 
2.1.4

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


[PATCH 15/21] [media] coda: add coda_estimate_sizeimage and use it in set_defaults

2015-01-23 Thread Philipp Zabel
Call coda_estimate_sizeimage from both try_fmt and set_defaults to
avoid this v4l2-compliance warning on the h.264 decoder video device:

G_FMT: 1920x1088, 32315559, 1, 1920, 1048576, 3, 0, 0, feedcafe
TRY/S_FMT: 1920x1088, 32315559, 1, 1920, 3133440, 3, 0, 0, feedcafe
fail: v4l2-test-formats.cpp(948): Video Capture: S_FMT(G_FMT) != G_FMT

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 38 +++
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 6ea7e0a..f7fc355 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -468,6 +468,18 @@ static int coda_try_pixelformat(struct coda_ctx *ctx, 
struct v4l2_format *f)
return 0;
 }
 
+static unsigned int coda_estimate_sizeimage(struct coda_ctx *ctx, u32 
sizeimage,
+   u32 width, u32 height)
+{
+   /*
+* This is a rough estimate for sensible compressed buffer
+* sizes (between 1 and 16 bits per pixel). This could be
+* improved by better format specific worst case estimates.
+*/
+   return round_up(clamp(sizeimage, width * height / 8,
+width * height * 2), PAGE_SIZE);
+}
+
 static int coda_try_fmt(struct coda_ctx *ctx, const struct coda_codec *codec,
struct v4l2_format *f)
 {
@@ -513,15 +525,10 @@ static int coda_try_fmt(struct coda_ctx *ctx, const 
struct coda_codec *codec,
case V4L2_PIX_FMT_H264:
case V4L2_PIX_FMT_MPEG4:
f->fmt.pix.bytesperline = 0;
-   /*
-* This is a rough estimate for sensible compressed buffer
-* sizes (between 1 and 16 bits per pixel). This could be
-* improved by better format specific worst case estimates.
-*/
-   f->fmt.pix.sizeimage = round_up(clamp(f->fmt.pix.sizeimage,
-   f->fmt.pix.width * f->fmt.pix.height / 8,
-   f->fmt.pix.width * f->fmt.pix.height * 2),
-   PAGE_SIZE);
+   f->fmt.pix.sizeimage = coda_estimate_sizeimage(ctx,
+   f->fmt.pix.sizeimage,
+   f->fmt.pix.width,
+   f->fmt.pix.height);
break;
default:
BUG();
@@ -1056,13 +1063,14 @@ static void coda_set_tiled_map_type(struct coda_ctx 
*ctx, int tiled_map_type)
 
 static void set_default_params(struct coda_ctx *ctx)
 {
-   unsigned int max_w, max_h, size;
+   unsigned int max_w, max_h, usize, csize;
 
ctx->codec = coda_find_codec(ctx->dev, ctx->cvd->src_formats[0],
 ctx->cvd->dst_formats[0]);
max_w = min(ctx->codec->max_w, 1920U);
max_h = min(ctx->codec->max_h, 1088U);
-   size = max_w * max_h * 3 / 2;
+   usize = max_w * max_h * 3 / 2;
+   csize = coda_estimate_sizeimage(ctx, usize, max_w, max_h);
 
ctx->params.codec_mode = ctx->codec->mode;
ctx->colorspace = V4L2_COLORSPACE_REC709;
@@ -1077,14 +1085,14 @@ static void set_default_params(struct coda_ctx *ctx)
ctx->q_data[V4L2_M2M_DST].height = max_h;
if (ctx->codec->src_fourcc == V4L2_PIX_FMT_YUV420) {
ctx->q_data[V4L2_M2M_SRC].bytesperline = max_w;
-   ctx->q_data[V4L2_M2M_SRC].sizeimage = size;
+   ctx->q_data[V4L2_M2M_SRC].sizeimage = usize;
ctx->q_data[V4L2_M2M_DST].bytesperline = 0;
-   ctx->q_data[V4L2_M2M_DST].sizeimage = round_up(size, PAGE_SIZE);
+   ctx->q_data[V4L2_M2M_DST].sizeimage = csize;
} else {
ctx->q_data[V4L2_M2M_SRC].bytesperline = 0;
-   ctx->q_data[V4L2_M2M_SRC].sizeimage = round_up(size, PAGE_SIZE);
+   ctx->q_data[V4L2_M2M_SRC].sizeimage = csize;
ctx->q_data[V4L2_M2M_DST].bytesperline = max_w;
-   ctx->q_data[V4L2_M2M_DST].sizeimage = size;
+   ctx->q_data[V4L2_M2M_DST].sizeimage = usize;
}
ctx->q_data[V4L2_M2M_SRC].rect.width = max_w;
ctx->q_data[V4L2_M2M_SRC].rect.height = max_h;
-- 
2.1.4

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


[PATCH 12/21] [media] coda: remove unused isequence, reset qsequence in stop_streaming

2015-01-23 Thread Philipp Zabel
The isequence counter is never used, qsequence counts the buffers queued into
the bit decoder bitstream ringbuffer. It needs to be reset in stop_streaming.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 2 +-
 drivers/media/platform/coda/coda.h| 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 5386b2c..611d737 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1304,7 +1304,7 @@ static void coda_stop_streaming(struct vb2_queue *q)
 
coda_bit_stream_end_flag(ctx);
 
-   ctx->isequence = 0;
+   ctx->qsequence = 0;
 
while ((buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx)))
v4l2_m2m_buf_done(buf, VB2_BUF_STATE_ERROR);
diff --git a/drivers/media/platform/coda/coda.h 
b/drivers/media/platform/coda/coda.h
index 5dd47e5..2ddfe51 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -198,7 +198,6 @@ struct coda_ctx {
int initialized;
int streamon_out;
int streamon_cap;
-   u32 isequence;
u32 qsequence;
u32 osequence;
u32 sequence_offset;
-- 
2.1.4

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


[PATCH 20/21] [media] coda: allocate bitstream ringbuffer only for BIT decoder

2015-01-23 Thread Philipp Zabel
The BIT encoder does not use a per-context bitstream ringbuffer as it encodes
directly into the videobuf2 capture queue's buffers. Avoid allocation of the
bitstream ringbuffer for encoder contexts.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 2defa4b..c19f4b7 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1689,7 +1689,8 @@ static int coda_open(struct file *file)
v4l2_err(&dev->v4l2_dev, "failed to allocate parabuf");
goto err_dma_alloc;
}
-
+   }
+   if (ctx->use_bit && ctx->inst_type == CODA_INST_DECODER) {
ctx->bitstream.size = CODA_MAX_FRAME_SIZE;
ctx->bitstream.vaddr = dma_alloc_writecombine(
&dev->plat_dev->dev, ctx->bitstream.size,
-- 
2.1.4

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


[PATCH 06/21] [media] coda: fix job_ready debug reporting for bitstream decoding

2015-01-23 Thread Philipp Zabel
Clarify whether job_ready returns false because the context is on hold, waiting
for new input buffers, whether there are not enough input buffers to fill two
into the bitstream, or whether there is not enough data in the bitstream buffer
for the bitstream reader hardware to read a whole frame.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 46 +--
 1 file changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 9a0ee11..ea54337 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -939,15 +939,43 @@ static int coda_job_ready(void *m2m_priv)
return 0;
}
 
-   if (ctx->hold ||
-   ((ctx->inst_type == CODA_INST_DECODER) &&
-!v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) &&
-(coda_get_bitstream_payload(ctx) < 512) &&
-!(ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG))) {
-   v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
-"%d: not ready: not enough bitstream data.\n",
-ctx->idx);
-   return 0;
+   if (ctx->inst_type == CODA_INST_DECODER) {
+   struct list_head *meta;
+   bool stream_end;
+   int num_metas;
+   int src_bufs;
+
+   if (ctx->hold && !v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx)) 
{
+   v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
+"%d: not ready: on hold for more buffers.\n",
+ctx->idx);
+   return 0;
+   }
+
+   stream_end = ctx->bit_stream_param &
+CODA_BIT_STREAM_END_FLAG;
+
+   num_metas = 0;
+   list_for_each(meta, &ctx->buffer_meta_list)
+   num_metas++;
+
+   src_bufs = v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx);
+
+   if (!stream_end && (num_metas + src_bufs) < 2) {
+   v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
+"%d: not ready: need 2 buffers available (%d, 
%d)\n",
+ctx->idx, num_metas, src_bufs);
+   return 0;
+   }
+
+
+   if (!v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) &&
+   !stream_end && (coda_get_bitstream_payload(ctx) < 512)) {
+   v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
+"%d: not ready: not enough bitstream data 
(%d).\n",
+ctx->idx, coda_get_bitstream_payload(ctx));
+   return 0;
+   }
}
 
if (ctx->aborting) {
-- 
2.1.4

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


[PATCH 18/21] [media] coda: free context buffers under buffer mutex

2015-01-23 Thread Philipp Zabel
Make sure the buffer_mutex lock is taken in coda_bit_release
while coda_free_framebuffers and coda_free_context_buffers
are called.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-bit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index 7c5..856b542 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1319,8 +1319,10 @@ static void coda_seq_end_work(struct work_struct *work)
 
 static void coda_bit_release(struct coda_ctx *ctx)
 {
+   mutex_lock(&ctx->buffer_mutex);
coda_free_framebuffers(ctx);
coda_free_context_buffers(ctx);
+   mutex_unlock(&ctx->buffer_mutex);
 }
 
 const struct coda_context_ops coda_bit_encode_ops = {
-- 
2.1.4

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


[PATCH 00/21] CODA fixes and vmalloc input

2015-01-23 Thread Philipp Zabel
Hi,

this is a series of various fixes that should increase stability
in the face of broken streams and just general use of the CODA driver.
They range from crash fixes to issues uncovered by v4l2-compliance.
The CODA9 subsampling buffers patch fixes encoder image corruption.

Also, the BIT decoder input queue is switched to vmalloc memory, and the
bitstream buffer and sequence end work are made optional for future
CODA9 JPEG support.

regards
Philipp

Lucas Stach (1):
  [media] coda: adjust sequence offset after unexpected decoded frame

Markus Pargmann (1):
  [media] coda: fix width validity check when starting to decode

Philipp Zabel (19):
  [media] coda: fix encoder rate control parameter masks
  [media] coda: bitrate can only be set in kbps steps
  [media] coda: remove context debugfs entry last
  [media] coda: move meta out of padding
  [media] coda: fix job_ready debug reporting for bitstream decoding
  [media] coda: fix try_fmt_vid_out colorspace setting
  [media] coda: properly clear f_cap in coda_s_fmt_vid_out
  [media] coda: initialize SRAM on probe
  [media] coda: clear RET_DEC_PIC_SUCCESS flag in prepare_decode
  [media] coda: remove unused isequence, reset qsequence in
stop_streaming
  [media] coda: issue seq_end_work during stop_streaming
  [media] coda: don't ever use subsampling ping-pong buffers as
reconstructed reference buffers
  [media] coda: add coda_estimate_sizeimage and use it in set_defaults
  [media] coda: switch BIT decoder source queue to vmalloc
  [media] coda: make seq_end_work optional
  [media] coda: free context buffers under buffer mutex
  [media] coda: add support for contexts that do not use the BIT
processor
  [media] coda: allocate bitstream ringbuffer only for BIT decoder
  [media] coda: simplify check in coda_buf_queue

 drivers/media/platform/Kconfig|   1 +
 drivers/media/platform/coda/coda-bit.c|  25 +++--
 drivers/media/platform/coda/coda-common.c | 161 --
 drivers/media/platform/coda/coda.h|   2 +-
 drivers/media/platform/coda/coda_regs.h   |   4 +-
 5 files changed, 130 insertions(+), 63 deletions(-)

-- 
2.1.4

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


Re: [RFC PATCH 0/3] Introduce IIO interface for fingerprint sensors

2015-01-23 Thread Florian Echtler
Hello Teodora,

On 23.01.2015 14:05, Baluta, Teodora wrote:
> The fingerprint sensor acts more like a scanner device, so the
> closest type is the V4L2_CAP_VIDEO_CAPTURE. However, this is not a
> perfect match because the driver only sends an image, once, when
> triggered. Would it be a better alternative to define a new
> capability type? Or it would be acceptable to simply have a video
> device with no frame buffer or frame rate and the user space
> application to read from the character device /dev/videoX?
Sorry if I jump in here right in the middle of this discussion, but some
time ago, I wrote a fingerprint sensor driver for the Siemens ID Mouse
(still part of the kernel AFAICT) which acts as a misc device and just
creates a character device node that can be used to directly read a PGM
file.

Maybe this would be a slightly simpler approach than pulling in all the
streaming-optimized features of V4L2?

Best, Florian
-- 
SENT FROM MY DEC VT50 TERMINAL



signature.asc
Description: OpenPGP digital signature


[PATCH v2 13/15] [media] adv7180: Add I2P support

2015-01-23 Thread Lars-Peter Clausen
Some of the devices supported by this driver have a interlaced-to-
progressive converter which can optionally be enabled. This patch adds
support for enabling and disabling the I2P converter on such devices.

I2P mode can be enabled by selecting V4L2_FIELD_NONE instead of
V4L2_FIELD_INTERLACED for the format.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 156 +---
 1 file changed, 148 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 868a677..4d789c7 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -124,6 +124,7 @@
 #define ADV7180_REG_NTSC_V_BIT_END 0x00E6
 #define ADV7180_NTSC_V_BIT_END_MANUAL_NVEND0x4F
 
+#define ADV7180_REG_VPP_SLAVE_ADDR 0xFD
 #define ADV7180_REG_CSI_SLAVE_ADDR 0xFE
 
 #define ADV7180_CSI_REG_PWRDN  0x00
@@ -161,12 +162,14 @@
 #define ADV7182_INPUT_DIFF_CVBS_AIN7_AIN8 0x11
 
 #define ADV7180_DEFAULT_CSI_I2C_ADDR 0x44
+#define ADV7180_DEFAULT_VPP_I2C_ADDR 0x42
 
 struct adv7180_state;
 
 #define ADV7180_FLAG_RESET_POWERED BIT(0)
 #define ADV7180_FLAG_V2BIT(1)
 #define ADV7180_FLAG_MIPI_CSI2 BIT(2)
+#define ADV7180_FLAG_I2P   BIT(3)
 
 struct adv7180_chip_info {
unsigned int flags;
@@ -190,7 +193,9 @@ struct adv7180_state {
struct i2c_client   *client;
unsigned intregister_page;
struct i2c_client   *csi_client;
+   struct i2c_client   *vpp_client;
const struct adv7180_chip_info *chip_info;
+   enum v4l2_field field;
 };
 
 static struct adv7180_state *ctrl_to_adv7180(struct v4l2_ctrl *ctrl)
@@ -236,6 +241,12 @@ static int adv7180_set_video_standard(struct adv7180_state 
*state,
return state->chip_info->set_std(state, std);
 }
 
+static int adv7180_vpp_write(struct adv7180_state *state, unsigned int reg,
+   unsigned int value)
+{
+   return i2c_smbus_write_byte_data(state->vpp_client, reg, value);
+}
+
 static v4l2_std_id adv7180_std_to_v4l2(u8 status1)
 {
/* in case V4L2_IN_ST_NO_SIGNAL */
@@ -440,6 +451,8 @@ static int adv7180_set_power(struct adv7180_state *state, 
bool on)
adv7180_csi_write(state, 0xD8, 0x65);
adv7180_csi_write(state, 0xE0, 0x09);
adv7180_csi_write(state, 0x2C, 0x00);
+   if (state->field == V4L2_FIELD_NONE)
+   adv7180_csi_write(state, 0x1D, 0x80);
adv7180_csi_write(state, 0x00, 0x00);
} else {
adv7180_csi_write(state, 0x00, 0x80);
@@ -559,25 +572,97 @@ static int adv7180_mbus_fmt(struct v4l2_subdev *sd,
 
fmt->code = MEDIA_BUS_FMT_YUYV8_2X8;
fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
-   fmt->field = V4L2_FIELD_INTERLACED;
fmt->width = 720;
fmt->height = state->curr_norm & V4L2_STD_525_60 ? 480 : 576;
 
return 0;
 }
 
+static int adv7180_set_field_mode(struct adv7180_state *state)
+{
+   if (!(state->chip_info->flags & ADV7180_FLAG_I2P))
+   return 0;
+
+   if (state->field == V4L2_FIELD_NONE) {
+   if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
+   adv7180_csi_write(state, 0x01, 0x20);
+   adv7180_csi_write(state, 0x02, 0x28);
+   adv7180_csi_write(state, 0x03, 0x38);
+   adv7180_csi_write(state, 0x04, 0x30);
+   adv7180_csi_write(state, 0x05, 0x30);
+   adv7180_csi_write(state, 0x06, 0x80);
+   adv7180_csi_write(state, 0x07, 0x70);
+   adv7180_csi_write(state, 0x08, 0x50);
+   }
+   adv7180_vpp_write(state, 0xa3, 0x00);
+   adv7180_vpp_write(state, 0x5b, 0x00);
+   adv7180_vpp_write(state, 0x55, 0x80);
+   } else {
+   if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
+   adv7180_csi_write(state, 0x01, 0x18);
+   adv7180_csi_write(state, 0x02, 0x18);
+   adv7180_csi_write(state, 0x03, 0x30);
+   adv7180_csi_write(state, 0x04, 0x20);
+   adv7180_csi_write(state, 0x05, 0x28);
+   adv7180_csi_write(state, 0x06, 0x40);
+   adv7180_csi_write(state, 0x07, 0x58);
+   adv7180_csi_write(state, 0x08, 0x30);
+   }
+   adv7180_vpp_write(state, 0xa3, 0x70);
+   adv7180_vpp_write(state, 0x5b, 0x80);
+   adv7180_vpp_write(state, 0x55, 0x00);
+   }
+
+   return 0;
+}
+
 static int adv7180_get_pad_format(struct v4l2_subdev *sd,
  struct v4l2_subdev_fh *fh,
  struct v4l2_subdev

[PATCH v2 09/15] [media] adv7180: Prepare for multi-chip support

2015-01-23 Thread Lars-Peter Clausen
The adv7180 is part of a larger family of device, which have all a very
similar register map layout. This patch prepares the adv7180 driver for
support for multiple different devices. For now the only difference we care
about is the number of input channel configurations. Also the way the input
format is configured slightly differs between some devices.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 187 ++--
 1 file changed, 130 insertions(+), 57 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 4d9bcc8..e3f91d5 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -32,23 +32,24 @@
 #include 
 #include 
 
+#define ADV7180_STD_AD_PAL_BG_NTSC_J_SECAM 0x0
+#define ADV7180_STD_AD_PAL_BG_NTSC_J_SECAM_PED 0x1
+#define ADV7180_STD_AD_PAL_N_NTSC_J_SECAM  0x2
+#define ADV7180_STD_AD_PAL_N_NTSC_M_SECAM  0x3
+#define ADV7180_STD_NTSC_J 0x4
+#define ADV7180_STD_NTSC_M 0x5
+#define ADV7180_STD_PAL60  0x6
+#define ADV7180_STD_NTSC_443   0x7
+#define ADV7180_STD_PAL_BG 0x8
+#define ADV7180_STD_PAL_N  0x9
+#define ADV7180_STD_PAL_M  0xa
+#define ADV7180_STD_PAL_M_PED  0xb
+#define ADV7180_STD_PAL_COMB_N 0xc
+#define ADV7180_STD_PAL_COMB_N_PED 0xd
+#define ADV7180_STD_PAL_SECAM  0xe
+#define ADV7180_STD_PAL_SECAM_PED  0xf
+
 #define ADV7180_REG_INPUT_CONTROL  0x
-#define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM   0x00
-#define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM_PED 0x10
-#define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_J_SECAM0x20
-#define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_M_SECAM0x30
-#define ADV7180_INPUT_CONTROL_NTSC_J   0x40
-#define ADV7180_INPUT_CONTROL_NTSC_M   0x50
-#define ADV7180_INPUT_CONTROL_PAL600x60
-#define ADV7180_INPUT_CONTROL_NTSC_443 0x70
-#define ADV7180_INPUT_CONTROL_PAL_BG   0x80
-#define ADV7180_INPUT_CONTROL_PAL_N0x90
-#define ADV7180_INPUT_CONTROL_PAL_M0xa0
-#define ADV7180_INPUT_CONTROL_PAL_M_PED0xb0
-#define ADV7180_INPUT_CONTROL_PAL_COMB_N   0xc0
-#define ADV7180_INPUT_CONTROL_PAL_COMB_N_PED   0xd0
-#define ADV7180_INPUT_CONTROL_PAL_SECAM0xe0
-#define ADV7180_INPUT_CONTROL_PAL_SECAM_PED0xf0
 #define ADV7180_INPUT_CONTROL_INSEL_MASK   0x0f
 
 #define ADV7180_REG_EXTENDED_OUTPUT_CONTROL0x0004
@@ -121,6 +122,30 @@
 #define ADV7180_REG_NTSC_V_BIT_END 0x00E6
 #define ADV7180_NTSC_V_BIT_END_MANUAL_NVEND0x4F
 
+#define ADV7180_INPUT_CVBS_AIN1 0x00
+#define ADV7180_INPUT_CVBS_AIN2 0x01
+#define ADV7180_INPUT_CVBS_AIN3 0x02
+#define ADV7180_INPUT_CVBS_AIN4 0x03
+#define ADV7180_INPUT_CVBS_AIN5 0x04
+#define ADV7180_INPUT_CVBS_AIN6 0x05
+#define ADV7180_INPUT_SVIDEO_AIN1_AIN2 0x06
+#define ADV7180_INPUT_SVIDEO_AIN3_AIN4 0x07
+#define ADV7180_INPUT_SVIDEO_AIN5_AIN6 0x08
+#define ADV7180_INPUT_YPRPB_AIN1_AIN2_AIN3 0x09
+#define ADV7180_INPUT_YPRPB_AIN4_AIN5_AIN6 0x0a
+
+struct adv7180_state;
+
+#define ADV7180_FLAG_RESET_POWERED BIT(0)
+
+struct adv7180_chip_info {
+   unsigned int flags;
+   unsigned int valid_input_mask;
+   int (*set_std)(struct adv7180_state *st, unsigned int std);
+   int (*select_input)(struct adv7180_state *st, unsigned int input);
+   int (*init)(struct adv7180_state *state);
+};
+
 struct adv7180_state {
struct v4l2_ctrl_handler ctrl_hdl;
struct v4l2_subdev  sd;
@@ -134,6 +159,7 @@ struct adv7180_state {
 
struct i2c_client   *client;
unsigned intregister_page;
+   const struct adv7180_chip_info *chip_info;
 };
 
 static struct adv7180_state *ctrl_to_adv7180(struct v4l2_ctrl *ctrl)
@@ -167,6 +193,11 @@ static int adv7180_read(struct adv7180_state *state, 
unsigned int reg)
return i2c_smbus_read_byte_data(state->client, reg & 0xff);
 }
 
+static int adv7180_set_video_standard(struct adv7180_state *state,
+   unsigned int std)
+{
+   return state->chip_info->set_std(state, std);
+}
 
 static v4l2_std_id adv7180_std_to_v4l2(u8 status1)
 {
@@ -199,22 +230,22 @@ static v4l2_std_id adv7180_std_to_v4l2(u8 status1)
 static int v4l2_std_to_adv7180(v4l2_std_id std)
 {
if (std == V4L2_STD_PAL_60)
-   return ADV7180_INPUT_CONTROL_PAL60;
+   return ADV7180_STD_PAL60;
if (std == V4L2_STD_NTSC_443)
-   return ADV7180_INPUT_CONTROL_NTSC_443;
+   return ADV7180_STD_NTSC_443;
 

[PATCH v2 06/15] [media] adv7180: Reset the device before initialization

2015-01-23 Thread Lars-Peter Clausen
Reset the device when initializing it so it is in a good known state and the
assumed register settings matche the actual register settings.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index cc05db9..eeb5a4a 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define ADV7180_REG_INPUT_CONTROL  0x
 #define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM   0x00
@@ -524,6 +525,9 @@ static int init_device(struct adv7180_state *state)
 
mutex_lock(&state->mutex);
 
+   adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES);
+   usleep_range(2000, 1);
+
/* Initialize adv7180 */
/* Enable autodetection */
if (state->autodetect) {
@@ -696,14 +700,14 @@ static int adv7180_resume(struct device *dev)
struct adv7180_state *state = to_state(sd);
int ret;
 
-   if (state->powered) {
-   ret = adv7180_set_power(state, true);
-   if (ret)
-   return ret;
-   }
ret = init_device(state);
if (ret < 0)
return ret;
+
+   ret = adv7180_set_power(state, state->powered);
+   if (ret)
+   return ret;
+
return 0;
 }
 
-- 
1.8.0

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


[PATCH v2 08/15] [media] adv7180: Consolidate video mode setting

2015-01-23 Thread Lars-Peter Clausen
We have basically the same code to set the video standard in init_device()
and adv7180_s_std(). Factor this out into a common helper function.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 67 ++---
 1 file changed, 32 insertions(+), 35 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 349cae3..4d9bcc8 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -304,37 +304,54 @@ static int adv7180_g_input_status(struct v4l2_subdev *sd, 
u32 *status)
return ret;
 }
 
-static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
+static int adv7180_program_std(struct adv7180_state *state)
 {
-   struct adv7180_state *state = to_state(sd);
-   int ret = mutex_lock_interruptible(&state->mutex);
-   if (ret)
-   return ret;
+   int ret;
 
-   /* all standards -> autodetect */
-   if (std == V4L2_STD_ALL) {
+   if (state->autodetect) {
ret = adv7180_write(state, ADV7180_REG_INPUT_CONTROL,
ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM
| state->input);
if (ret < 0)
-   goto out;
+   return ret;
 
__adv7180_status(state, NULL, &state->curr_norm);
-   state->autodetect = true;
} else {
-   ret = v4l2_std_to_adv7180(std);
+   ret = v4l2_std_to_adv7180(state->curr_norm);
if (ret < 0)
-   goto out;
+   return ret;
 
ret = adv7180_write(state, ADV7180_REG_INPUT_CONTROL,
ret | state->input);
if (ret < 0)
+   return ret;
+   }
+
+   return 0;
+}
+
+static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
+{
+   struct adv7180_state *state = to_state(sd);
+   int ret = mutex_lock_interruptible(&state->mutex);
+
+   if (ret)
+   return ret;
+
+   /* all standards -> autodetect */
+   if (std == V4L2_STD_ALL) {
+   state->autodetect = true;
+   } else {
+   /* Make sure we can support this std */
+   ret = v4l2_std_to_adv7180(std);
+   if (ret < 0)
goto out;
 
state->curr_norm = std;
state->autodetect = false;
}
-   ret = 0;
+
+   ret = adv7180_program_std(state);
 out:
mutex_unlock(&state->mutex);
return ret;
@@ -547,30 +564,10 @@ static int init_device(struct adv7180_state *state)
adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES);
usleep_range(2000, 1);
 
-   /* Initialize adv7180 */
-   /* Enable autodetection */
-   if (state->autodetect) {
-   ret = adv7180_write(state, ADV7180_REG_INPUT_CONTROL,
-   ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM
- | state->input);
-   if (ret < 0)
-   goto out_unlock;
-
-   ret = adv7180_write(state, ADV7180_REG_AUTODETECT_ENABLE,
- ADV7180_AUTODETECT_DEFAULT);
-   if (ret < 0)
-   goto out_unlock;
-   } else {
-   ret = v4l2_std_to_adv7180(state->curr_norm);
-   if (ret < 0)
-   goto out_unlock;
-
-   ret = adv7180_write(state, ADV7180_REG_INPUT_CONTROL,
- ret | state->input);
-   if (ret < 0)
-   goto out_unlock;
+   ret = adv7180_program_std(state);
+   if (ret)
+   goto out_unlock;
 
-   }
/* ITU-R BT.656-4 compatible */
ret = adv7180_write(state, ADV7180_REG_EXTENDED_OUTPUT_CONTROL,
ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS);
-- 
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


[PATCH v2 11/15] [media] adv7180: Add support for the adv7280/adv7281/adv7282

2015-01-23 Thread Lars-Peter Clausen
This patch adds support for the adv7280/adv7281/adv7282 devices to the
adv7180 driver. They are very similar to the adv7182, the main difference
from the drivers point of view are some different tuning constants for
improved video performance.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 56 +++--
 1 file changed, 54 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 4e518d5..ea6695c 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -158,6 +158,7 @@
 struct adv7180_state;
 
 #define ADV7180_FLAG_RESET_POWERED BIT(0)
+#define ADV7180_FLAG_V2BIT(1)
 
 struct adv7180_chip_info {
unsigned int flags;
@@ -638,9 +639,18 @@ static int adv7180_select_input(struct adv7180_state 
*state, unsigned int input)
 
 static int adv7182_init(struct adv7180_state *state)
 {
+   if (state->chip_info->flags & ADV7180_FLAG_V2) {
+   /* ADI recommended writes for improved video quality */
+   adv7180_write(state, 0x0080, 0x51);
+   adv7180_write(state, 0x0081, 0x51);
+   adv7180_write(state, 0x0082, 0x68);
+   adv7180_write(state, 0x0004, 0x17);
+   } else {
+   adv7180_write(state, 0x0004, 0x07);
+   }
+
/* ADI required writes */
adv7180_write(state, 0x0003, 0x0c);
-   adv7180_write(state, 0x0004, 0x07);
adv7180_write(state, 0x0013, 0x00);
adv7180_write(state, 0x001d, 0x40);
 
@@ -697,6 +707,13 @@ static unsigned int adv7182_lbias_settings[][3] = {
[ADV7182_INPUT_TYPE_YPBPR] = { 0x0B, 0x4E, 0xC0 },
 };
 
+static unsigned int adv7280_lbias_settings[][3] = {
+   [ADV7182_INPUT_TYPE_CVBS] = { 0xCD, 0x4E, 0x80 },
+   [ADV7182_INPUT_TYPE_DIFF_CVBS] = { 0xC0, 0x4E, 0x80 },
+   [ADV7182_INPUT_TYPE_SVIDEO] = { 0x0B, 0xCE, 0x80 },
+   [ADV7182_INPUT_TYPE_YPBPR] = { 0x0B, 0x4E, 0xC0 },
+};
+
 static int adv7182_select_input(struct adv7180_state *state, unsigned int 
input)
 {
enum adv7182_input_type input_type;
@@ -725,7 +742,10 @@ static int adv7182_select_input(struct adv7180_state 
*state, unsigned int input)
break;
}
 
-   lbias = adv7182_lbias_settings[input_type];
+   if (state->chip_info->flags & ADV7180_FLAG_V2)
+   lbias = adv7280_lbias_settings[input_type];
+   else
+   lbias = adv7182_lbias_settings[input_type];
 
for (i = 0; i < ARRAY_SIZE(adv7182_lbias_settings[0]); i++)
adv7180_write(state, 0x0052 + i, lbias[i]);
@@ -784,6 +804,35 @@ static const struct adv7180_chip_info adv7182_info = {
.select_input = adv7182_select_input,
 };
 
+static const struct adv7180_chip_info adv7280_info = {
+   .flags = ADV7180_FLAG_V2,
+   .valid_input_mask = BIT(ADV7182_INPUT_CVBS_AIN1) |
+   BIT(ADV7182_INPUT_CVBS_AIN2) |
+   BIT(ADV7182_INPUT_CVBS_AIN3) |
+   BIT(ADV7182_INPUT_CVBS_AIN4) |
+   BIT(ADV7182_INPUT_SVIDEO_AIN1_AIN2) |
+   BIT(ADV7182_INPUT_SVIDEO_AIN3_AIN4) |
+   BIT(ADV7182_INPUT_YPRPB_AIN1_AIN2_AIN3),
+   .init = adv7182_init,
+   .set_std = adv7182_set_std,
+   .select_input = adv7182_select_input,
+};
+
+static const struct adv7180_chip_info adv7281_info = {
+   .flags = ADV7180_FLAG_V2,
+   .valid_input_mask = BIT(ADV7182_INPUT_CVBS_AIN1) |
+   BIT(ADV7182_INPUT_CVBS_AIN2) |
+   BIT(ADV7182_INPUT_CVBS_AIN7) |
+   BIT(ADV7182_INPUT_CVBS_AIN8) |
+   BIT(ADV7182_INPUT_SVIDEO_AIN1_AIN2) |
+   BIT(ADV7182_INPUT_SVIDEO_AIN7_AIN8) |
+   BIT(ADV7182_INPUT_DIFF_CVBS_AIN1_AIN2) |
+   BIT(ADV7182_INPUT_DIFF_CVBS_AIN7_AIN8),
+   .init = adv7182_init,
+   .set_std = adv7182_set_std,
+   .select_input = adv7182_select_input,
+};
+
 static int init_device(struct adv7180_state *state)
 {
int ret;
@@ -930,6 +979,9 @@ static int adv7180_remove(struct i2c_client *client)
 static const struct i2c_device_id adv7180_id[] = {
{ "adv7180", (kernel_ulong_t)&adv7180_info },
{ "adv7182", (kernel_ulong_t)&adv7182_info },
+   { "adv7280", (kernel_ulong_t)&adv7280_info },
+   { "adv7281", (kernel_ulong_t)&adv7281_info },
+   { "adv7282", (kernel_ulong_t)&adv7281_info },
{},
 };
 MODULE_DEVICE_TABLE(i2c, adv7180_id);
-- 
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


[PATCH v2 15/15] [media] Add MAINTAINERS entry for the adv7180

2015-01-23 Thread Lars-Peter Clausen
Add myself as the maintainer for the adv7180 video subdev driver.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 MAINTAINERS | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4318f34..22bb77e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -659,6 +659,13 @@ L: linux-media@vger.kernel.org
 S: Maintained
 F: drivers/media/i2c/ad9389b*
 
+ANALOG DEVICES INC ADV7180 DRIVER
+M: Lars-Peter Clausen 
+L: linux-media@vger.kernel.org
+W: http://ez.analog.com/community/linux-device-drivers
+S: Supported
+F: drivers/media/i2c/adv7180.c
+
 ANALOG DEVICES INC ADV7511 DRIVER
 M: Hans Verkuil 
 L: linux-media@vger.kernel.org
-- 
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


[PATCH v2 12/15] [media] adv7180: Add support for the adv7280-m/adv7281-m/adv7281-ma/adv7282-m

2015-01-23 Thread Lars-Peter Clausen
This patch adds support for the adv7280-m/adv2781-m/adv7281-ma/adv7282-m
devices to the adv7180 driver. They are very similar to the
adv7280/adv7281/adv7282 but instead of parallel video out they feature a
MIPI CSI2 transmitter.

The CSI2 transmitter is configured via a separate I2C address, so we need to
register a dummy device for it.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 170 +++-
 1 file changed, 154 insertions(+), 16 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index ea6695c..868a677 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -124,6 +124,11 @@
 #define ADV7180_REG_NTSC_V_BIT_END 0x00E6
 #define ADV7180_NTSC_V_BIT_END_MANUAL_NVEND0x4F
 
+#define ADV7180_REG_CSI_SLAVE_ADDR 0xFE
+
+#define ADV7180_CSI_REG_PWRDN  0x00
+#define ADV7180_CSI_PWRDN  0x80
+
 #define ADV7180_INPUT_CVBS_AIN1 0x00
 #define ADV7180_INPUT_CVBS_AIN2 0x01
 #define ADV7180_INPUT_CVBS_AIN3 0x02
@@ -155,10 +160,13 @@
 #define ADV7182_INPUT_DIFF_CVBS_AIN5_AIN6 0x10
 #define ADV7182_INPUT_DIFF_CVBS_AIN7_AIN8 0x11
 
+#define ADV7180_DEFAULT_CSI_I2C_ADDR 0x44
+
 struct adv7180_state;
 
 #define ADV7180_FLAG_RESET_POWERED BIT(0)
 #define ADV7180_FLAG_V2BIT(1)
+#define ADV7180_FLAG_MIPI_CSI2 BIT(2)
 
 struct adv7180_chip_info {
unsigned int flags;
@@ -181,6 +189,7 @@ struct adv7180_state {
 
struct i2c_client   *client;
unsigned intregister_page;
+   struct i2c_client   *csi_client;
const struct adv7180_chip_info *chip_info;
 };
 
@@ -215,6 +224,12 @@ static int adv7180_read(struct adv7180_state *state, 
unsigned int reg)
return i2c_smbus_read_byte_data(state->client, reg & 0xff);
 }
 
+static int adv7180_csi_write(struct adv7180_state *state, unsigned int reg,
+   unsigned int value)
+{
+   return i2c_smbus_write_byte_data(state->csi_client, reg, value);
+}
+
 static int adv7180_set_video_standard(struct adv7180_state *state,
unsigned int std)
 {
@@ -407,13 +422,31 @@ out:
 static int adv7180_set_power(struct adv7180_state *state, bool on)
 {
u8 val;
+   int ret;
 
if (on)
val = ADV7180_PWR_MAN_ON;
else
val = ADV7180_PWR_MAN_OFF;
 
-   return adv7180_write(state, ADV7180_REG_PWR_MAN, val);
+   ret = adv7180_write(state, ADV7180_REG_PWR_MAN, val);
+   if (ret)
+   return ret;
+
+   if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
+   if (on) {
+   adv7180_csi_write(state, 0xDE, 0x02);
+   adv7180_csi_write(state, 0xD2, 0xF7);
+   adv7180_csi_write(state, 0xD8, 0x65);
+   adv7180_csi_write(state, 0xE0, 0x09);
+   adv7180_csi_write(state, 0x2C, 0x00);
+   adv7180_csi_write(state, 0x00, 0x00);
+   } else {
+   adv7180_csi_write(state, 0x00, 0x80);
+   }
+   }
+
+   return 0;
 }
 
 static int adv7180_s_power(struct v4l2_subdev *sd, int on)
@@ -550,13 +583,22 @@ static int adv7180_set_pad_format(struct v4l2_subdev *sd,
 static int adv7180_g_mbus_config(struct v4l2_subdev *sd,
 struct v4l2_mbus_config *cfg)
 {
-   /*
-* The ADV7180 sensor supports BT.601/656 output modes.
-* The BT.656 is default and not yet configurable by s/w.
-*/
-   cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
-V4L2_MBUS_DATA_ACTIVE_HIGH;
-   cfg->type = V4L2_MBUS_BT656;
+   struct adv7180_state *state = to_state(sd);
+
+   if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
+   cfg->type = V4L2_MBUS_CSI2;
+   cfg->flags = V4L2_MBUS_CSI2_1_LANE |
+   V4L2_MBUS_CSI2_CHANNEL_0 |
+   V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+   } else {
+   /*
+* The ADV7180 sensor supports BT.601/656 output modes.
+* The BT.656 is default and not yet configurable by s/w.
+*/
+   cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
+V4L2_MBUS_DATA_ACTIVE_HIGH;
+   cfg->type = V4L2_MBUS_BT656;
+   }
 
return 0;
 }
@@ -639,20 +681,32 @@ static int adv7180_select_input(struct adv7180_state 
*state, unsigned int input)
 
 static int adv7182_init(struct adv7180_state *state)
 {
+   if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2)
+   adv7180_write(state, ADV7180_REG_CSI_SLAVE_ADDR,
+   ADV7180_DEFAULT_CSI_I2C_ADDR << 1);
+
if (state->chip_info->flags & ADV7180_FLAG_V2) {
/* ADI recommended writes for improved video quality */

[PATCH v2 14/15] [media] adv7180: Add fast switch support

2015-01-23 Thread Lars-Peter Clausen
In fast switch mode the adv7180 (and similar) can lock onto a new signal
faster when switching between different inputs. As a downside though it is
no longer able to auto-detect the incoming format.

The fast switch mode is exposed as a boolean v4l control that allows
userspace applications to either enable or disable fast switch mode.

Signed-off-by: Lars-Peter Clausen 
--
Changes since v1:
* Reserve private control range and use it for the fast switch control
* Changed control name from "Fast switch" to "Fast Switch"
---
 drivers/media/i2c/adv7180.c| 29 +
 include/uapi/linux/v4l2-controls.h |  4 
 2 files changed, 33 insertions(+)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 4d789c7..ee73b29 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -127,6 +127,9 @@
 #define ADV7180_REG_VPP_SLAVE_ADDR 0xFD
 #define ADV7180_REG_CSI_SLAVE_ADDR 0xFE
 
+#define ADV7180_REG_FLCONTROL 0x40e0
+#define ADV7180_FLCONTROL_FL_ENABLE 0x1
+
 #define ADV7180_CSI_REG_PWRDN  0x00
 #define ADV7180_CSI_PWRDN  0x80
 
@@ -164,6 +167,8 @@
 #define ADV7180_DEFAULT_CSI_I2C_ADDR 0x44
 #define ADV7180_DEFAULT_VPP_I2C_ADDR 0x42
 
+#define V4L2_CID_ADV_FAST_SWITCH   (V4L2_CID_USER_ADV7180_BASE + 0x00)
+
 struct adv7180_state;
 
 #define ADV7180_FLAG_RESET_POWERED BIT(0)
@@ -509,6 +514,18 @@ static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl)
break;
ret = adv7180_write(state, ADV7180_REG_SD_SAT_CR, val);
break;
+   case V4L2_CID_ADV_FAST_SWITCH:
+   if (ctrl->val) {
+   /* ADI required write */
+   adv7180_write(state, 0x80d9, 0x44);
+   adv7180_write(state, ADV7180_REG_FLCONTROL,
+   ADV7180_FLCONTROL_FL_ENABLE);
+   } else {
+   /* ADI required write */
+   adv7180_write(state, 0x80d9, 0xc4);
+   adv7180_write(state, ADV7180_REG_FLCONTROL, 0x00);
+   }
+   break;
default:
ret = -EINVAL;
}
@@ -521,6 +538,16 @@ static const struct v4l2_ctrl_ops adv7180_ctrl_ops = {
.s_ctrl = adv7180_s_ctrl,
 };
 
+static const struct v4l2_ctrl_config adv7180_ctrl_fast_switch = {
+   .ops = &adv7180_ctrl_ops,
+   .id = V4L2_CID_ADV_FAST_SWITCH,
+   .name = "Fast Switching",
+   .type = V4L2_CTRL_TYPE_BOOLEAN,
+   .min = 0,
+   .max = 1,
+   .step = 1,
+};
+
 static int adv7180_init_controls(struct adv7180_state *state)
 {
v4l2_ctrl_handler_init(&state->ctrl_hdl, 4);
@@ -537,6 +564,8 @@ static int adv7180_init_controls(struct adv7180_state 
*state)
v4l2_ctrl_new_std(&state->ctrl_hdl, &adv7180_ctrl_ops,
  V4L2_CID_HUE, ADV7180_HUE_MIN,
  ADV7180_HUE_MAX, 1, ADV7180_HUE_DEF);
+   v4l2_ctrl_new_custom(&state->ctrl_hdl, &adv7180_ctrl_fast_switch, NULL);
+
state->sd.ctrl_handler = &state->ctrl_hdl;
if (state->ctrl_hdl.error) {
int err = state->ctrl_hdl.error;
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index 661f119..9f6e108 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -170,6 +170,10 @@ enum v4l2_colorfx {
  * We reserve 16 controls for this driver. */
 #define V4L2_CID_USER_SAA7134_BASE (V4L2_CID_USER_BASE + 0x1060)
 
+/* The base for the adv7180 driver controls.
+ * We reserve 16 controls for this driver. */
+#define V4L2_CID_USER_ADV7180_BASE (V4L2_CID_USER_BASE + 0x1070)
+
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls
  * and the 'MPEG' part of the define is historical */
-- 
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


[PATCH v2 07/15] [media] adv7180: Add media controller support

2015-01-23 Thread Lars-Peter Clausen
Add media controller support to the adv7180 driver by registering a media
entity instance for it as well as implementing pad ops for configuring the
format.

As there currently don't seem to be any users of the video ops format
operations those are removed as well in this patch.

Also set the V4L2_SUBDEV_FL_HAS_DEVNODE flag for the subdevice so it is
possible to create a subdevice device node.

Since the driver now depends on VIDEO_V4L2_SUBDEV_API all drivers which
select the driver need to depend on that symbol as well.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/Kconfig |  2 +-
 drivers/media/i2c/adv7180.c   | 50 +++
 drivers/media/pci/sta2x11/Kconfig |  1 +
 drivers/media/platform/Kconfig|  2 +-
 4 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index ca84543..f37890a 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -177,7 +177,7 @@ comment "Video decoders"
 
 config VIDEO_ADV7180
tristate "Analog Devices ADV7180 decoder"
-   depends on VIDEO_V4L2 && I2C
+   depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
---help---
  Support for the Analog Devices ADV7180 video decoder.
 
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index eeb5a4a..349cae3 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -124,6 +124,7 @@
 struct adv7180_state {
struct v4l2_ctrl_handler ctrl_hdl;
struct v4l2_subdev  sd;
+   struct media_padpad;
struct mutexmutex; /* mutual excl. when accessing chip */
int irq;
v4l2_std_id curr_norm;
@@ -442,13 +443,14 @@ static void adv7180_exit_controls(struct adv7180_state 
*state)
v4l2_ctrl_handler_free(&state->ctrl_hdl);
 }
 
-static int adv7180_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index,
-u32 *code)
+static int adv7180_enum_mbus_code(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_mbus_code_enum *code)
 {
-   if (index > 0)
+   if (code->index != 0)
return -EINVAL;
 
-   *code = MEDIA_BUS_FMT_YUYV8_2X8;
+   code->code = MEDIA_BUS_FMT_YUYV8_2X8;
 
return 0;
 }
@@ -467,6 +469,20 @@ static int adv7180_mbus_fmt(struct v4l2_subdev *sd,
return 0;
 }
 
+static int adv7180_get_pad_format(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_format *format)
+{
+   return adv7180_mbus_fmt(sd, &format->format);
+}
+
+static int adv7180_set_pad_format(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_format *format)
+{
+   return adv7180_mbus_fmt(sd, &format->format);
+}
+
 static int adv7180_g_mbus_config(struct v4l2_subdev *sd,
 struct v4l2_mbus_config *cfg)
 {
@@ -486,10 +502,6 @@ static const struct v4l2_subdev_video_ops 
adv7180_video_ops = {
.querystd = adv7180_querystd,
.g_input_status = adv7180_g_input_status,
.s_routing = adv7180_s_routing,
-   .enum_mbus_fmt = adv7180_enum_mbus_fmt,
-   .try_mbus_fmt = adv7180_mbus_fmt,
-   .g_mbus_fmt = adv7180_mbus_fmt,
-   .s_mbus_fmt = adv7180_mbus_fmt,
.g_mbus_config = adv7180_g_mbus_config,
 };
 
@@ -497,9 +509,16 @@ static const struct v4l2_subdev_core_ops adv7180_core_ops 
= {
.s_power = adv7180_s_power,
 };
 
+static const struct v4l2_subdev_pad_ops adv7180_pad_ops = {
+   .enum_mbus_code = adv7180_enum_mbus_code,
+   .set_fmt = adv7180_set_pad_format,
+   .get_fmt = adv7180_get_pad_format,
+};
+
 static const struct v4l2_subdev_ops adv7180_ops = {
.core = &adv7180_core_ops,
.video = &adv7180_video_ops,
+   .pad = &adv7180_pad_ops,
 };
 
 static irqreturn_t adv7180_irq(int irq, void *devid)
@@ -630,20 +649,28 @@ static int adv7180_probe(struct i2c_client *client,
state->input = 0;
sd = &state->sd;
v4l2_i2c_subdev_init(sd, client, &adv7180_ops);
+   sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
 
ret = adv7180_init_controls(state);
if (ret)
goto err_unreg_subdev;
-   ret = init_device(state);
+
+   state->pad.flags = MEDIA_PAD_FL_SOURCE;
+   sd->entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+   ret = media_entity_init(&sd->entity, 1, &state->pad, 0);
if (ret)
goto err_free_ctrl;
 
+   ret = init_device(state);
+   if (ret)
+   goto err_media_entity_cleanup;
+
if (state->irq) {
ret = request_threaded_irq(client->irq, NULL, adv7180_irq,
  

[PATCH v2 05/15] [media] adv7180: Do implicit register paging

2015-01-23 Thread Lars-Peter Clausen
The ad7180 has multiple register pages which can be switched between by
writing to a register. Currently the driver manually switches between pages
whenever a register outside of the default register map is accessed and
switches back after it has been accessed. This is a bit tedious and also
potential source for bugs.

This patch adds two helper functions that take care of switching between
pages and reading/writing the register. The register numbers for registers
are updated to encode both the page (in the upper 8-bits) and the register
(in the lower 8-bits) numbers.

Having multiple pages means that a register access is not a single atomic
i2c_smbus_write_byte_data() or i2c_smbus_read_byte_data() call and we need
to make sure that concurrent register access does not race against each
other.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 206 ++--
 1 file changed, 105 insertions(+), 101 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 00ba845..cc05db9 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -31,7 +31,7 @@
 #include 
 #include 
 
-#define ADV7180_REG_INPUT_CONTROL  0x00
+#define ADV7180_REG_INPUT_CONTROL  0x
 #define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM   0x00
 #define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM_PED 0x10
 #define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_J_SECAM0x20
@@ -50,28 +50,28 @@
 #define ADV7180_INPUT_CONTROL_PAL_SECAM_PED0xf0
 #define ADV7180_INPUT_CONTROL_INSEL_MASK   0x0f
 
-#define ADV7180_REG_EXTENDED_OUTPUT_CONTROL0x04
+#define ADV7180_REG_EXTENDED_OUTPUT_CONTROL0x0004
 #define ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS0xC5
 
 #define ADV7180_REG_AUTODETECT_ENABLE  0x07
 #define ADV7180_AUTODETECT_DEFAULT 0x7f
 /* Contrast */
-#define ADV7180_REG_CON0x08/*Unsigned */
+#define ADV7180_REG_CON0x0008  /*Unsigned */
 #define ADV7180_CON_MIN0
 #define ADV7180_CON_DEF128
 #define ADV7180_CON_MAX255
 /* Brightness*/
-#define ADV7180_REG_BRI0x0a/*Signed */
+#define ADV7180_REG_BRI0x000a  /*Signed */
 #define ADV7180_BRI_MIN-128
 #define ADV7180_BRI_DEF0
 #define ADV7180_BRI_MAX127
 /* Hue */
-#define ADV7180_REG_HUE0x0b/*Signed, inverted */
+#define ADV7180_REG_HUE0x000b  /*Signed, inverted */
 #define ADV7180_HUE_MIN-127
 #define ADV7180_HUE_DEF0
 #define ADV7180_HUE_MAX128
 
-#define ADV7180_REG_CTRL   0x0e
+#define ADV7180_REG_CTRL   0x000e
 #define ADV7180_CTRL_IRQ_SPACE 0x20
 
 #define ADV7180_REG_PWR_MAN0x0f
@@ -79,7 +79,7 @@
 #define ADV7180_PWR_MAN_OFF0x24
 #define ADV7180_PWR_MAN_RES0x80
 
-#define ADV7180_REG_STATUS10x10
+#define ADV7180_REG_STATUS10x0010
 #define ADV7180_STATUS1_IN_LOCK0x01
 #define ADV7180_STATUS1_AUTOD_MASK 0x70
 #define ADV7180_STATUS1_AUTOD_NTSM_M_J 0x00
@@ -91,33 +91,33 @@
 #define ADV7180_STATUS1_AUTOD_PAL_COMB 0x60
 #define ADV7180_STATUS1_AUTOD_SECAM_5250x70
 
-#define ADV7180_REG_IDENT 0x11
+#define ADV7180_REG_IDENT 0x0011
 #define ADV7180_ID_7180 0x18
 
-#define ADV7180_REG_ICONF1 0x40
+#define ADV7180_REG_ICONF1 0x0040
 #define ADV7180_ICONF1_ACTIVE_LOW  0x01
 #define ADV7180_ICONF1_PSYNC_ONLY  0x10
 #define ADV7180_ICONF1_ACTIVE_TO_CLR   0xC0
 /* Saturation */
-#define ADV7180_REG_SD_SAT_CB  0xe3/*Unsigned */
-#define ADV7180_REG_SD_SAT_CR  0xe4/*Unsigned */
+#define ADV7180_REG_SD_SAT_CB  0x00e3  /*Unsigned */
+#define ADV7180_REG_SD_SAT_CR  0x00e4  /*Unsigned */
 #define ADV7180_SAT_MIN0
 #define ADV7180_SAT_DEF128
 #define ADV7180_SAT_MAX255
 
 #define ADV7180_IRQ1_LOCK  0x01
 #define ADV7180_IRQ1_UNLOCK0x02
-#define ADV7180_REG_ISR1   0x42
-#define ADV7180_REG_ICR1   0x43
-#define ADV7180_REG_IMR1   0x44
-#define ADV7180_REG_IMR2   0x48
+#define ADV7180_REG_ISR1   0x0042
+#define ADV7180_REG_ICR1   0x0043
+#define ADV7180_REG_IMR1   0x0044
+#define ADV7180_REG_IMR2   0x0048
 #define ADV7180_IRQ3_AD_CHANGE 0x08
-#define ADV7180_REG_ISR3   0x4A
-#define ADV7180_REG_ICR3   0x4B
-#define ADV7180_REG_IMR3   0x4C
+#define ADV7180_REG_ISR3   0x004A
+#define ADV7180_REG_ICR3   0x004B
+#define ADV7180_REG_IMR3   0x004C
 #define ADV7180_REG_IMR4   0x50
 
-#define ADV7180_REG_NTSC_V_BIT_END 0xE6
+#define ADV7180_REG_NTSC_V_BIT_END 0x00E6
 #define ADV7180_NTSC_V_BIT_END_MANUAL_NVEND0x4F
 
 struct adv7180_state {
@

[PATCH v2 10/15] [media] adv7180: Add support for the adv7182

2015-01-23 Thread Lars-Peter Clausen
This patch adds support for the adv7182 to the adv7180 driver. The adv7182
is similar to the adv7180, the main difference from the driver's point of
view is how the video input and how the input format are selected.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 149 
 1 file changed, 149 insertions(+)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index e3f91d5..4e518d5 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -52,6 +52,8 @@
 #define ADV7180_REG_INPUT_CONTROL  0x
 #define ADV7180_INPUT_CONTROL_INSEL_MASK   0x0f
 
+#define ADV7182_REG_INPUT_VIDSEL   0x0002
+
 #define ADV7180_REG_EXTENDED_OUTPUT_CONTROL0x0004
 #define ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS0xC5
 
@@ -134,6 +136,25 @@
 #define ADV7180_INPUT_YPRPB_AIN1_AIN2_AIN3 0x09
 #define ADV7180_INPUT_YPRPB_AIN4_AIN5_AIN6 0x0a
 
+#define ADV7182_INPUT_CVBS_AIN1 0x00
+#define ADV7182_INPUT_CVBS_AIN2 0x01
+#define ADV7182_INPUT_CVBS_AIN3 0x02
+#define ADV7182_INPUT_CVBS_AIN4 0x03
+#define ADV7182_INPUT_CVBS_AIN5 0x04
+#define ADV7182_INPUT_CVBS_AIN6 0x05
+#define ADV7182_INPUT_CVBS_AIN7 0x06
+#define ADV7182_INPUT_CVBS_AIN8 0x07
+#define ADV7182_INPUT_SVIDEO_AIN1_AIN2 0x08
+#define ADV7182_INPUT_SVIDEO_AIN3_AIN4 0x09
+#define ADV7182_INPUT_SVIDEO_AIN5_AIN6 0x0a
+#define ADV7182_INPUT_SVIDEO_AIN7_AIN8 0x0b
+#define ADV7182_INPUT_YPRPB_AIN1_AIN2_AIN3 0x0c
+#define ADV7182_INPUT_YPRPB_AIN4_AIN5_AIN6 0x0d
+#define ADV7182_INPUT_DIFF_CVBS_AIN1_AIN2 0x0e
+#define ADV7182_INPUT_DIFF_CVBS_AIN3_AIN4 0x0f
+#define ADV7182_INPUT_DIFF_CVBS_AIN5_AIN6 0x10
+#define ADV7182_INPUT_DIFF_CVBS_AIN7_AIN8 0x11
+
 struct adv7180_state;
 
 #define ADV7180_FLAG_RESET_POWERED BIT(0)
@@ -615,6 +636,118 @@ static int adv7180_select_input(struct adv7180_state 
*state, unsigned int input)
return adv7180_write(state, ADV7180_REG_INPUT_CONTROL, ret);
 }
 
+static int adv7182_init(struct adv7180_state *state)
+{
+   /* ADI required writes */
+   adv7180_write(state, 0x0003, 0x0c);
+   adv7180_write(state, 0x0004, 0x07);
+   adv7180_write(state, 0x0013, 0x00);
+   adv7180_write(state, 0x001d, 0x40);
+
+   return 0;
+}
+
+static int adv7182_set_std(struct adv7180_state *state, unsigned int std)
+{
+   return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL, std << 4);
+}
+
+enum adv7182_input_type {
+   ADV7182_INPUT_TYPE_CVBS,
+   ADV7182_INPUT_TYPE_DIFF_CVBS,
+   ADV7182_INPUT_TYPE_SVIDEO,
+   ADV7182_INPUT_TYPE_YPBPR,
+};
+
+static enum adv7182_input_type adv7182_get_input_type(unsigned int input)
+{
+   switch (input) {
+   case ADV7182_INPUT_CVBS_AIN1:
+   case ADV7182_INPUT_CVBS_AIN2:
+   case ADV7182_INPUT_CVBS_AIN3:
+   case ADV7182_INPUT_CVBS_AIN4:
+   case ADV7182_INPUT_CVBS_AIN5:
+   case ADV7182_INPUT_CVBS_AIN6:
+   case ADV7182_INPUT_CVBS_AIN7:
+   case ADV7182_INPUT_CVBS_AIN8:
+   return ADV7182_INPUT_TYPE_CVBS;
+   case ADV7182_INPUT_SVIDEO_AIN1_AIN2:
+   case ADV7182_INPUT_SVIDEO_AIN3_AIN4:
+   case ADV7182_INPUT_SVIDEO_AIN5_AIN6:
+   case ADV7182_INPUT_SVIDEO_AIN7_AIN8:
+   return ADV7182_INPUT_TYPE_SVIDEO;
+   case ADV7182_INPUT_YPRPB_AIN1_AIN2_AIN3:
+   case ADV7182_INPUT_YPRPB_AIN4_AIN5_AIN6:
+   return ADV7182_INPUT_TYPE_YPBPR;
+   case ADV7182_INPUT_DIFF_CVBS_AIN1_AIN2:
+   case ADV7182_INPUT_DIFF_CVBS_AIN3_AIN4:
+   case ADV7182_INPUT_DIFF_CVBS_AIN5_AIN6:
+   case ADV7182_INPUT_DIFF_CVBS_AIN7_AIN8:
+   return ADV7182_INPUT_TYPE_DIFF_CVBS;
+   default: /* Will never happen */
+   return 0;
+   }
+}
+
+/* ADI recommended writes to registers 0x52, 0x53, 0x54 */
+static unsigned int adv7182_lbias_settings[][3] = {
+   [ADV7182_INPUT_TYPE_CVBS] = { 0xCB, 0x4E, 0x80 },
+   [ADV7182_INPUT_TYPE_DIFF_CVBS] = { 0xC0, 0x4E, 0x80 },
+   [ADV7182_INPUT_TYPE_SVIDEO] = { 0x0B, 0xCE, 0x80 },
+   [ADV7182_INPUT_TYPE_YPBPR] = { 0x0B, 0x4E, 0xC0 },
+};
+
+static int adv7182_select_input(struct adv7180_state *state, unsigned int 
input)
+{
+   enum adv7182_input_type input_type;
+   unsigned int *lbias;
+   unsigned int i;
+   int ret;
+
+   ret = adv7180_write(state, ADV7180_REG_INPUT_CONTROL, input);
+   if (ret)
+   return ret;
+
+   /* Reset clamp circuitry - ADI recommended writes */
+   adv7180_write(state, 0x809c, 0x00);
+   adv7180_write(state, 0x809c, 0xff);
+
+   input_type = adv7182_get_input_type(input);
+
+   switch (input_type) {
+   case ADV7182_INPUT_TYPE_CVBS:
+   case ADV7182_INPUT_TYPE_DIFF_CVBS:
+   /* ADI recommends to use the SH1 filter */
+   adv7180_write(state, 0x0017, 0x41);
+   break;
+   default:
+   adv

[PATCH v2 04/15] [media] adv7180: Cleanup register define naming

2015-01-23 Thread Lars-Peter Clausen
Consistently prefix register defines with ADV7180_REG. Also remove the "ADI"
from register names, the ADV7180 prefix should provide enough of a namespace
separation.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 105 ++--
 1 file changed, 52 insertions(+), 53 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index f2508abe..00ba845 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -31,7 +31,7 @@
 #include 
 #include 
 
-#define ADV7180_INPUT_CONTROL_REG  0x00
+#define ADV7180_REG_INPUT_CONTROL  0x00
 #define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM   0x00
 #define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM_PED 0x10
 #define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_J_SECAM0x20
@@ -50,36 +50,36 @@
 #define ADV7180_INPUT_CONTROL_PAL_SECAM_PED0xf0
 #define ADV7180_INPUT_CONTROL_INSEL_MASK   0x0f
 
-#define ADV7180_EXTENDED_OUTPUT_CONTROL_REG0x04
+#define ADV7180_REG_EXTENDED_OUTPUT_CONTROL0x04
 #define ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS0xC5
 
-#define ADV7180_AUTODETECT_ENABLE_REG  0x07
+#define ADV7180_REG_AUTODETECT_ENABLE  0x07
 #define ADV7180_AUTODETECT_DEFAULT 0x7f
 /* Contrast */
-#define ADV7180_CON_REG0x08/*Unsigned */
+#define ADV7180_REG_CON0x08/*Unsigned */
 #define ADV7180_CON_MIN0
 #define ADV7180_CON_DEF128
 #define ADV7180_CON_MAX255
 /* Brightness*/
-#define ADV7180_BRI_REG0x0a/*Signed */
+#define ADV7180_REG_BRI0x0a/*Signed */
 #define ADV7180_BRI_MIN-128
 #define ADV7180_BRI_DEF0
 #define ADV7180_BRI_MAX127
 /* Hue */
-#define ADV7180_HUE_REG0x0b/*Signed, inverted */
+#define ADV7180_REG_HUE0x0b/*Signed, inverted */
 #define ADV7180_HUE_MIN-127
 #define ADV7180_HUE_DEF0
 #define ADV7180_HUE_MAX128
 
-#define ADV7180_ADI_CTRL_REG   0x0e
-#define ADV7180_ADI_CTRL_IRQ_SPACE 0x20
+#define ADV7180_REG_CTRL   0x0e
+#define ADV7180_CTRL_IRQ_SPACE 0x20
 
-#define ADV7180_PWR_MAN_REG0x0f
+#define ADV7180_REG_PWR_MAN0x0f
 #define ADV7180_PWR_MAN_ON 0x04
 #define ADV7180_PWR_MAN_OFF0x24
 #define ADV7180_PWR_MAN_RES0x80
 
-#define ADV7180_STATUS1_REG0x10
+#define ADV7180_REG_STATUS10x10
 #define ADV7180_STATUS1_IN_LOCK0x01
 #define ADV7180_STATUS1_AUTOD_MASK 0x70
 #define ADV7180_STATUS1_AUTOD_NTSM_M_J 0x00
@@ -91,33 +91,33 @@
 #define ADV7180_STATUS1_AUTOD_PAL_COMB 0x60
 #define ADV7180_STATUS1_AUTOD_SECAM_5250x70
 
-#define ADV7180_IDENT_REG 0x11
+#define ADV7180_REG_IDENT 0x11
 #define ADV7180_ID_7180 0x18
 
-#define ADV7180_ICONF1_ADI 0x40
+#define ADV7180_REG_ICONF1 0x40
 #define ADV7180_ICONF1_ACTIVE_LOW  0x01
 #define ADV7180_ICONF1_PSYNC_ONLY  0x10
 #define ADV7180_ICONF1_ACTIVE_TO_CLR   0xC0
 /* Saturation */
-#define ADV7180_SD_SAT_CB_REG  0xe3/*Unsigned */
-#define ADV7180_SD_SAT_CR_REG  0xe4/*Unsigned */
+#define ADV7180_REG_SD_SAT_CB  0xe3/*Unsigned */
+#define ADV7180_REG_SD_SAT_CR  0xe4/*Unsigned */
 #define ADV7180_SAT_MIN0
 #define ADV7180_SAT_DEF128
 #define ADV7180_SAT_MAX255
 
 #define ADV7180_IRQ1_LOCK  0x01
 #define ADV7180_IRQ1_UNLOCK0x02
-#define ADV7180_ISR1_ADI   0x42
-#define ADV7180_ICR1_ADI   0x43
-#define ADV7180_IMR1_ADI   0x44
-#define ADV7180_IMR2_ADI   0x48
+#define ADV7180_REG_ISR1   0x42
+#define ADV7180_REG_ICR1   0x43
+#define ADV7180_REG_IMR1   0x44
+#define ADV7180_REG_IMR2   0x48
 #define ADV7180_IRQ3_AD_CHANGE 0x08
-#define ADV7180_ISR3_ADI   0x4A
-#define ADV7180_ICR3_ADI   0x4B
-#define ADV7180_IMR3_ADI   0x4C
-#define ADV7180_IMR4_ADI   0x50
+#define ADV7180_REG_ISR3   0x4A
+#define ADV7180_REG_ICR3   0x4B
+#define ADV7180_REG_IMR3   0x4C
+#define ADV7180_REG_IMR4   0x50
 
-#define ADV7180_NTSC_V_BIT_END_REG 0xE6
+#define ADV7180_REG_NTSC_V_BIT_END 0xE6
 #define ADV7180_NTSC_V_BIT_END_MANUAL_NVEND0x4F
 
 struct adv7180_state {
@@ -198,7 +198,7 @@ static u32 adv7180_status_to_v4l2(u8 status1)
 static int __adv7180_status(struct i2c_client *client, u32 *status,
v4l2_std_id *std)
 {
-   int status1 = i2c_smbus_read_byte_data(client, ADV7180_STATUS1_REG);
+   int status1 = i2c_smbus_read_byte_data(client, ADV7180_REG_STATUS1);
 
if (status1 < 0)
return status1;
@@ -249,

[PATCH v2 02/15] [media] adv7180: Pass correct flags to request_threaded_irq()

2015-01-23 Thread Lars-Peter Clausen
Most IRQ controllers support different types of interrupts. The adv7180
generates falling edge interrupts, so make sure to pass IRQF_TRIGGER_FALLING
to request_threaded_irq() so the IRQ controller is configured for the
correct mode.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 172e4a2..f424a4d 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -632,7 +632,8 @@ static int adv7180_probe(struct i2c_client *client,
 
if (state->irq) {
ret = request_threaded_irq(client->irq, NULL, adv7180_irq,
-  IRQF_ONESHOT, KBUILD_MODNAME, state);
+  IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
+  KBUILD_MODNAME, state);
if (ret)
goto err_free_ctrl;
}
-- 
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


[PATCH v2 00/15] [media] adv7180: Add support for more chip variants

2015-01-23 Thread Lars-Peter Clausen
Changes from v1:
* Reserved custom user control range for the fast switch control
* Dropped the free-run mode control patch for now. The controls should
  probably be standardized first, but that is going to be a different
  patch series.

Original cover letter below:

The adv7180 is part of a larger family of chips which all implement
different features from a feature superset. This patch series step by step
extends the current adv7180 with features from the superset that are
currently not supported and gradually adding support for more variations of
the chip.

The first half of this series contains fixes and cleanups while the second
half adds new features and support for new chips


Lars-Peter Clausen (15):
  [media] adv7180: Do not request the IRQ again during resume
  [media] adv7180: Pass correct flags to request_threaded_irq()
  [media] adv7180: Use inline function instead of macro
  [media] adv7180: Cleanup register define naming
  [media] adv7180: Do implicit register paging
  [media] adv7180: Reset the device before initialization
  [media] adv7180: Add media controller support
  [media] adv7180: Consolidate video mode setting
  [media] adv7180: Prepare for multi-chip support
  [media] adv7180: Add support for the adv7182
  [media] adv7180: Add support for the adv7280/adv7281/adv7282
  [media] adv7180: Add support for the
adv7280-m/adv7281-m/adv7281-ma/adv7282-m
  [media] adv7180: Add I2P support
  [media] adv7180: Add fast switch support
  [media] Add MAINTAINERS entry for the adv7180

 MAINTAINERS|7 +
 drivers/media/i2c/Kconfig  |2 +-
 drivers/media/i2c/adv7180.c| 1016 +---
 drivers/media/pci/sta2x11/Kconfig  |1 +
 drivers/media/platform/Kconfig |2 +-
 include/uapi/linux/v4l2-controls.h |4 +
 6 files changed, 831 insertions(+), 201 deletions(-)

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


[PATCH v2 03/15] [media] adv7180: Use inline function instead of macro

2015-01-23 Thread Lars-Peter Clausen
Use a inline function instead of a macro for the container_of helper for
getting the driver's state struct from a control. A inline function has the
advantage that it is more typesafe and nicer in general.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index f424a4d..f2508abe 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -130,9 +130,11 @@ struct adv7180_state {
boolpowered;
u8  input;
 };
-#define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler,\
-   struct adv7180_state,   \
-   ctrl_hdl)->sd)
+
+static struct adv7180_state *ctrl_to_adv7180(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl->handler, struct adv7180_state, ctrl_hdl);
+}
 
 static v4l2_std_id adv7180_std_to_v4l2(u8 status1)
 {
@@ -345,9 +347,8 @@ static int adv7180_s_power(struct v4l2_subdev *sd, int on)
 
 static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   struct v4l2_subdev *sd = to_adv7180_sd(ctrl);
-   struct adv7180_state *state = to_state(sd);
-   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   struct adv7180_state *state = ctrl_to_adv7180(ctrl);
+   struct i2c_client *client = v4l2_get_subdevdata(&state->sd);
int ret = mutex_lock_interruptible(&state->mutex);
int val;
 
-- 
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


[PATCH v2 01/15] [media] adv7180: Do not request the IRQ again during resume

2015-01-23 Thread Lars-Peter Clausen
Currently the IRQ is requested from within the init_device() function. This
function is not only called during device probe, but also during resume
causing the driver to try to request the IRQ again. Move requesting the IRQ
from init_device() to the probe function to make sure that it is only
requested once.

Signed-off-by: Lars-Peter Clausen 
Acked-by: Hans Verkuil 
---
 drivers/media/i2c/adv7180.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index bffe6eb..172e4a2 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -553,11 +553,6 @@ static int init_device(struct i2c_client *client, struct 
adv7180_state *state)
 
/* register for interrupts */
if (state->irq > 0) {
-   ret = request_threaded_irq(state->irq, NULL, adv7180_irq,
-  IRQF_ONESHOT, KBUILD_MODNAME, state);
-   if (ret)
-   return ret;
-
ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG,
ADV7180_ADI_CTRL_IRQ_SPACE);
if (ret < 0)
@@ -597,7 +592,6 @@ static int init_device(struct i2c_client *client, struct 
adv7180_state *state)
return 0;
 
 err:
-   free_irq(state->irq, state);
return ret;
 }
 
@@ -636,6 +630,13 @@ static int adv7180_probe(struct i2c_client *client,
if (ret)
goto err_free_ctrl;
 
+   if (state->irq) {
+   ret = request_threaded_irq(client->irq, NULL, adv7180_irq,
+  IRQF_ONESHOT, KBUILD_MODNAME, state);
+   if (ret)
+   goto err_free_ctrl;
+   }
+
ret = v4l2_async_register_subdev(sd);
if (ret)
goto err_free_irq;
-- 
1.8.0

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


Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Shuah Khan
On 01/23/2015 02:50 AM, Hans Verkuil wrote:
> Hi Shuah,
> 
> On 01/23/2015 12:42 AM, Shuah Khan wrote:
>> Convert au0828 to use videobuf2. Tested with NTSC.
>> Tested video and vbi devices with xawtv, tvtime,
>> and vlc. Ran v4l2-compliance to ensure there are
>> no regressions. video now has no failures and vbi
>> has 3 fewer failures.
>>
>> video before:
>> test VIDIOC_G_FMT: FAIL 3 failures
>> Total: 72, Succeeded: 69, Failed: 3, Warnings: 0
>>
>> Video after:
>> Total: 72, Succeeded: 72, Failed: 0, Warnings: 18
>>
>> vbi before:
>> test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
>> test VIDIOC_EXPBUF: FAIL
>> test USERPTR: FAIL
>> Total: 72, Succeeded: 66, Failed: 6, Warnings: 0
>>
>> vbi after:
>> test VIDIOC_QUERYCAP: FAIL
>> test MMAP: FAIL
>> Total: 78, Succeeded: 75, Failed: 3, Warnings: 0
> 
> There shouldn't be any fails for VBI. That really needs to be fixed.
> Esp. the QUERYCAP fail should be easy to fix.
> 
> BTW, can you paste the full v4l2-compliance output next time? That's
> more informative than just these summaries.
> 

I will re-run the tests and fix it and resend the patch. I think I was
seeing querycap compliance failure when run with -V0 option and not when
I run it without. I can attach the full log.

thanks,
-- Shuah

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
--
To unsubscribe from this list: send the line "unsubscribe 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.19-rc6] media fixes

2015-01-23 Thread Mauro Carvalho Chehab
Hi Linus,

Please pull from:
  git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
media/v3.19-4

For:
  - Fix some race conditions caused by a regression on videobuf2;
  - Fix a interrupt release bug on cx23885;
  - Fix support for Mygica T230 and HVR4400;
  - Fix compilation breakage when USB is not selected on tlg2300;
  - Fix capabilities report on ompa3isp, soc-camera, rcar_vin and pvrusb2;

Regards,
Mauro

-

The following changes since commit 427ae153c65ad7a08288d86baf99000569627d03:

  [media] bq/c-qcam, w9966, pms: move to staging in preparation for removal 
(2014-12-16 23:21:44 -0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
media/v3.19-4

for you to fetch changes up to 2c0108e1c02f9fc95f465adc4d2ce1ad8688290a:

  [media] omap3isp: Correctly set QUERYCAP capabilities (2015-01-21 21:09:11 
-0200)


media fixes for v3.19-rc6


Guennadi Liakhovetski (1):
  [media] soc-camera: fix device capabilities in multiple camera host 
drivers

Hans Verkuil (3):
  [media] vb2: fix vb2_thread_stop race conditions
  [media] pvrusb2: fix missing device_caps in querycap
  [media] cx23885: fix free interrupt bug

Jonathan McDowell (1):
  [media] Fix Mygica T230 support

Matthias Schwarzott (1):
  [media] cx23885: Split Hauppauge WinTV Starburst from HVR4400 card entry

Mauro Carvalho Chehab (1):
  [media] tlg2300: Fix media dependencies

Nobuhiro Iwamatsu (1):
  [media] rcar_vin: Update device_caps and capabilities in querycap

Sakari Ailus (1):
  [media] omap3isp: Correctly set QUERYCAP capabilities

 drivers/media/pci/cx23885/cx23885-cards.c  | 23 +++--
 drivers/media/pci/cx23885/cx23885-core.c   |  4 ++--
 drivers/media/pci/cx23885/cx23885-dvb.c| 11 ++
 drivers/media/pci/cx23885/cx23885.h|  1 +
 drivers/media/platform/omap3isp/ispvideo.c |  7 +--
 drivers/media/platform/soc_camera/atmel-isi.c  |  5 +++--
 drivers/media/platform/soc_camera/mx2_camera.c |  3 ++-
 drivers/media/platform/soc_camera/mx3_camera.c |  3 ++-
 drivers/media/platform/soc_camera/omap1_camera.c   |  3 ++-
 drivers/media/platform/soc_camera/pxa_camera.c |  3 ++-
 drivers/media/platform/soc_camera/rcar_vin.c   |  4 +++-
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  4 +++-
 drivers/media/usb/dvb-usb/cxusb.c  |  2 +-
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c   | 24 --
 drivers/media/v4l2-core/videobuf2-core.c   | 19 -
 drivers/staging/media/tlg2300/Kconfig  |  1 +
 16 files changed, 77 insertions(+), 40 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


RE: [RFC PATCH 0/3] Introduce IIO interface for fingerprint sensors

2015-01-23 Thread Baluta, Teodora
Hi,

Thanks for the reply, Sylwester! I am considering v4l2 now and I have some 
questions/comments below.

> -Original Message-
> From: linux-iio-ow...@vger.kernel.org [mailto:linux-iio-
> ow...@vger.kernel.org] On Behalf Of Sylwester Nawrocki
> Sent: Thursday, January 15, 2015 7:38 PM
> To: Baluta, Teodora; Jonathan Cameron
> Cc: Mauro Carvalho Chehab; Lars-Peter Clausen; Linux Kernel Mailing List;
> linux-iio; LMML; Hans Verkuil
> Subject: Re: [RFC PATCH 0/3] Introduce IIO interface for fingerprint sensors
> 
> On 14/01/15 18:14, Baluta, Teodora wrote:
> > On Vi, 2014-12-26 at 11:13 +, Jonathan Cameron wrote:
> >> On 18/12/14 16:51, Lars-Peter Clausen wrote:
> >>> Adding V4L folks to Cc for more input.
> >>
> >> Thanks Lars - we definitely would need the v4l guys to agree to a
> >> driver like this going in IIO. (not that I'm convinced it should!)
> >>
> >>> On 12/08/2014 03:10 PM, Baluta, Teodora wrote:
>  Hello,
> 
>  On Vi, 2014-12-05 at 02:15 +, Jonathan Cameron wrote:
> > On 04/12/14 13:00, Teodora Baluta wrote:
> >> This patchset adds support for fingerprint sensors through the IIO
> interface.
> >> This way userspace applications collect information in a uniform
> >> way. All processing would be done in the upper layers as suggested
> in [0].
> >>
> >> In order to test out this proposal, a minimal implementation for
> >> UPEK's TouchChip Fingerprint Sensor via USB is also available.
> >> Although there is an existing implementation in userspace for USB
> >> fingerprint devices, including this particular device, the driver
> >> represents a proof of concept of how fingerprint sensors could be
> >> integrated in the IIO framework regardless of the used bus. For
> >> lower power requirements, the SPI bus is preferred and a kernel
> driver implementation makes more sense.
> >
> > So why not v4l?  These are effectively image sensors..
> 
>  Well, here's why I don't think v4l would be the best option:
> 
>  - an image scanner could be implemented in the v4l subsystem, but
>  it seems far more complicated for a simple fingerprint scanner - it
>  usually has drivers for webcams, TVs or video streaming devices.
>  The v4l subsystem (with all its support for colorspace, decoders,
>  image compression, frame control) seems a bit of an overkill for a
>  very straightforward fingerprint imaging sensor.
> >
> >> Whilst those are there, I would doubt the irrelevant bits would put
> >> much burden on a fingerprint scanning driver.  Been a while since I
> >> did anything in that area though so I could be wrong!
> 
> IMO V4L is much better fit for this kind of devices than IIO. You can use 
> just a
> subset of the API, it shouldn't take much effort to write a simple
> v4l2 capture driver, supporting fixed (probably vendor/chip specific) image
> format.  I'm not sure if it's better to use the v4l2 controls [1], define a 
> new
> v4l2 controls class for the fingerprint scanner processing features, rather 
> than
> trying to pass raw data to user space and interpret it then in some library.  
> I
> know there has been resistance to allowing passing unknown binary blobs to
> user space, due to possible abuses.
> 
> [1] Documentation/video4linux/v4l2-controls.txt
>

   
The fingerprint sensor acts more like a scanner device, so the closest type is 
the V4L2_CAP_VIDEO_CAPTURE. However, this is not a perfect match because the 
driver only sends an image, once, when triggered. Would it be a better 
alternative to define a new capability type? Or it would be acceptable to 
simply have a video device with no frame buffer or frame rate and the user 
space application to read from the character device /dev/videoX?

>  - a fingerprint device could also send out a processed information,
>  not just the image of a fingerprint. This means that the processing
>  is done in hardware - the UPEK TouchStrip chipset in libfprint has
>  this behavior (see [0]). So, the IIO framework would support a
>  uniform way of handling fingerprint devices that either do
>  processing in software or in hardware.
> 
> You can use the v4l2 controls API for that, which also supports events.
> The controls could be made read only.
> It would be interesting to list what kind of features these could be.

Looking through the controls API, they seem to be a good fit.

> 
> >> This is more interesting, but does that map well to IIO style
> >> channels anyway?  If not we are going to end up with a whole new
> >> interface which ever subsystem is used for the image side of things.
> 
>  The way I see it now, for processed fingerprint information, an IIO
>  device could have an IIO_FINGERPRINT channel with a modifier and
>  only the sensitivity threshold attribute set. We would also need
>  t

Re: [RFC v2 3/7] cec: add new framework for cec support.

2015-01-23 Thread Sean Young
On Thu, Jan 22, 2015 at 05:04:35PM +0100, Kamil Debski wrote:
> Add the CEC framework.
-snip-
> +Remote control handling
> +---
> +
> +The CEC framework provides two ways of handling the key messages of remote
> +control. In the first case, the CEC framework will handle these messages and
> +provide the keypressed via the RC framework. In the second case the messages
> +related to the key down/up events are not parsed by the framework and are
> +passed to the userspace as raw messages.
> +
> +Switching between these modes is done with a special ioctl.
> +
> +#define CEC_G_KEY_PASSTHROUGH_IOR('a', 10, __u8)
> +#define CEC_S_KEY_PASSTHROUGH_IOW('a', 11, __u8)
> +#define CEC_KEY_PASSTHROUGH_DISABLE  0
> +#define CEC_KEY_PASSTHROUGH_ENABLE   1

This is ugly. This ioctl stops keypresses from going to rc-core. The cec 
device is still registered with rc-core but no keys will be passed to it. 
This could also be handled by loading an empty keymap; this way the input 
layer will still receive scancodes but no keypresses.

> +static ssize_t cec_read(struct file *filp, char __user *buf,
> + size_t sz, loff_t *off)
> +{
> + struct cec_devnode *cecdev = cec_devnode_data(filp);
> +
> + if (!cec_devnode_is_registered(cecdev))
> + return -EIO;
> + return 0;
> +}
> +
> +static ssize_t cec_write(struct file *filp, const char __user *buf,
> + size_t sz, loff_t *off)
> +{
> + struct cec_devnode *cecdev = cec_devnode_data(filp);
> +
> + if (!cec_devnode_is_registered(cecdev))
> + return -EIO;
> + return 0;
> +}

Both read and write do nothing; they should either -ENOSYS or the fuctions
should be removed.


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


Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Hans Verkuil
Hi Shuah,

On 01/23/2015 12:42 AM, Shuah Khan wrote:
> Convert au0828 to use videobuf2. Tested with NTSC.
> Tested video and vbi devices with xawtv, tvtime,
> and vlc. Ran v4l2-compliance to ensure there are
> no regressions. video now has no failures and vbi
> has 3 fewer failures.
> 
> video before:
> test VIDIOC_G_FMT: FAIL 3 failures
> Total: 72, Succeeded: 69, Failed: 3, Warnings: 0
> 
> Video after:
> Total: 72, Succeeded: 72, Failed: 0, Warnings: 18
> 
> vbi before:
> test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
> test VIDIOC_EXPBUF: FAIL
> test USERPTR: FAIL
> Total: 72, Succeeded: 66, Failed: 6, Warnings: 0
> 
> vbi after:
> test VIDIOC_QUERYCAP: FAIL
> test MMAP: FAIL
> Total: 78, Succeeded: 75, Failed: 3, Warnings: 0

There shouldn't be any fails for VBI. That really needs to be fixed.
Esp. the QUERYCAP fail should be easy to fix.

BTW, can you paste the full v4l2-compliance output next time? That's
more informative than just these summaries.

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