Re: [RFC PATCH] ivtv-alsa: regression fix: remove __init from ivtv_alsa_load

2013-02-07 Thread Andy Walls
Hans Verkuil  wrote:

>On Thu February 7 2013 22:58:53 Andy Walls wrote:
>> Hans Verkuil  wrote:
>> 
>> >Andy,
>> >
>> >Please review this patch. This fix probably should be fast-tracked
>to
>> >3.8 and
>> >queued for stable 3.7.
>> >
>> >ivtv-alsa kept crashing my machine every time I loaded it, and this
>is
>> >the
>> >cause.
>> >
>> >Regards,
>> >
>> >Hans
>> >
>> >This function is called after initialization, so it should never be
>> >marked
>> >__init!
>> >
>> >Signed-off-by: Hans Verkuil 
>> >---
>> > drivers/media/pci/ivtv/ivtv-alsa-main.c |2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> >diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c
>> >b/drivers/media/pci/ivtv/ivtv-alsa-main.c
>> >index 4a221c6..e970cfa 100644
>> >--- a/drivers/media/pci/ivtv/ivtv-alsa-main.c
>> >+++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c
>> >@@ -205,7 +205,7 @@ err_exit:
>> >return ret;
>> > }
>> > 
>> >-static int __init ivtv_alsa_load(struct ivtv *itv)
>> >+static int ivtv_alsa_load(struct ivtv *itv)
>> > {
>> >struct v4l2_device *v4l2_dev = &itv->v4l2_dev;
>> >struct ivtv_stream *s;
>> 
>> Hans,
>> 
>> I concur.  Now I have to check cx18 for the same problem.
>
>Hmm, there is the same problem in cx18 as well:
>
>static int __init cx18_alsa_load(struct cx18 *cx)
>
>Checking some more I saw that this __init annotation was added only in
>3.8,
>both for ivtv and cx18 (so 3.7 is fine).
>
>Ah, I see that Mauro added __init accidentally when fixing some
>compiler
>warnings in ivtv and cx18.
>
>I'll make a pull request tomorrow morning removing the __init from
>ivtv_alsa_load
>and cx18_alsa_load and ask Mauro to fast-track this regression.
>
>I assume I have your SoB for this?
>
>Regards,
>
>   Hans
>
>> 
>> Your patch looks good.
>> 
>> Reviewed-by: Andy Walls 
>> Signed-off-by: Andy Walls 
>> 
>> Regards,
>> Andy  
>> 

Yes.

Signed-off-by: Andy Walls 

-Andy
--
To unsubscribe from this list: send the line "unsubscribe 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] ivtv-alsa: regression fix: remove __init from ivtv_alsa_load

2013-02-07 Thread Hans Verkuil
On Thu February 7 2013 22:58:53 Andy Walls wrote:
> Hans Verkuil  wrote:
> 
> >Andy,
> >
> >Please review this patch. This fix probably should be fast-tracked to
> >3.8 and
> >queued for stable 3.7.
> >
> >ivtv-alsa kept crashing my machine every time I loaded it, and this is
> >the
> >cause.
> >
> >Regards,
> >
> > Hans
> >
> >This function is called after initialization, so it should never be
> >marked
> >__init!
> >
> >Signed-off-by: Hans Verkuil 
> >---
> > drivers/media/pci/ivtv/ivtv-alsa-main.c |2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c
> >b/drivers/media/pci/ivtv/ivtv-alsa-main.c
> >index 4a221c6..e970cfa 100644
> >--- a/drivers/media/pci/ivtv/ivtv-alsa-main.c
> >+++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c
> >@@ -205,7 +205,7 @@ err_exit:
> > return ret;
> > }
> > 
> >-static int __init ivtv_alsa_load(struct ivtv *itv)
> >+static int ivtv_alsa_load(struct ivtv *itv)
> > {
> > struct v4l2_device *v4l2_dev = &itv->v4l2_dev;
> > struct ivtv_stream *s;
> 
> Hans,
> 
> I concur.  Now I have to check cx18 for the same problem.

Hmm, there is the same problem in cx18 as well:

static int __init cx18_alsa_load(struct cx18 *cx)

Checking some more I saw that this __init annotation was added only in 3.8,
both for ivtv and cx18 (so 3.7 is fine).

Ah, I see that Mauro added __init accidentally when fixing some compiler
warnings in ivtv and cx18.

I'll make a pull request tomorrow morning removing the __init from 
ivtv_alsa_load
and cx18_alsa_load and ask Mauro to fast-track this regression.

I assume I have your SoB for this?

Regards,

Hans

> 
> Your patch looks good.
> 
> Reviewed-by: Andy Walls 
> Signed-off-by: Andy Walls 
> 
> Regards,
> Andy  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 1/8] stk-webcam: various fixes.

2013-02-07 Thread Arvydas Sidorenko
On Wed, Feb 6, 2013 at 8:32 AM, Hans Verkuil  wrote:
>
> I've improved v4l2-compliance a bit, but I've also pushed a fix (I hope) to
> my git branch.
>
> It's great if you can test this!
>

$ v4l2-compliance -d /dev/video0
Driver Info:
Driver name   : stk
Card type : stk
Bus info  : usb-:00:1d.7-8
Driver version: 3.1.0
Capabilities  : 0x8501
Video Capture
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x0501
Video Capture
Read/Write
Streaming

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

Required ioctls:
test VIDIOC_QUERYCAP: OK

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

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

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

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
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

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: 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: 4 Private Controls: 0

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

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
warn: v4l2-test-formats.cpp(565): TRY_FMT cannot handle an 
invalid
pixelformat. This may or may not be a problem.
See http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
for more information.
test VIDIOC_TRY_FMT: OK
warn: v4l2-test-formats.cpp(723): S_FMT cannot handle an invalid
pixelformat. This may or may not be a problem.
See http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
for more information.
warn: v4l2-test-formats.cpp(658): Could not set fmt1
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 ioctls:
fail: v4l2-test-buffers.cpp(166): doioctl(node->node2, 
VIDIOC_REQBUFS, &bufs)
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL

Total: 38, Succeeded: 37, Failed: 1, Warnings: 3


On top of that it generates some dmesg output:
[   70.514849] stkwebcam 5-8:1.0: =  START STATUS
=
[   70.514856] stkwebcam 5-8:1.0: Brightness: 96
[   70.514860] stkwebcam 5-8:1.0: Horizontal Flip: true
[   70.514863] stkwebcam 5-8:1.0: Vertical Flip: true
[   70.514866] stkwebcam 5-8:1.0: ==  END STATUS
==
[   70.596727] stkwebcam: OmniVision sensor detected, id 9652 at address 60
[   70.859490] stkwebcam: isobufs already allocated. Bad
[   70.859977] stkwebcam: isobuf data already allocated
[   70.860502] stkwebcam: Killing URB
[   70.860990] stkwebcam: isobuf data already allocated
[   70.861478] stkwebcam: Killing URB
[   70.862088] stkwebcam: isobuf data already allocated
[   70.862834] stkwebcam: Killing URB
[   70.863594] stkwebcam: sio_bufs already allocated
[   70.864319] stkwebcam: isobufs already allocated. Bad
[   70.865057] stkwebcam: isobuf data already allocated
[   70.865752] stkwebcam: Killing URB
[   70.866490] stkwebcam: isobuf data already allocated
[   70.867275] stkwebcam: Killing URB
[   70.867980] stkwebcam: isobuf data already allocated
[   70.868721] stkwebcam: Killing URB
[   70.869464] stkwebcam: sio_bufs already allocated
[   70.870244] stkwebcam: isobufs already allocated. Bad
[   70.870968] stkwebcam: isobuf data already allocated
[   70.871704] stkwebcam: Killing URB
[   70.872440] stkwebcam: isobuf data already allocated
[   70.873181] stkwebcam: Killing 

[PATCH RFC] s3c-camif: Fail on insufficient number of allocated buffers

2013-02-07 Thread Sylwester Nawrocki
Ensure the driver gets always at least its minimum required
number of buffers allocated by checking actual number of
allocated buffers in vb2_reqbufs(). And free any partially
allocated buffer queue with signaling an error to user space.

Without this patch applications may wait forever to dequeue
a filled buffer, because the hardware didn't even start after
VIDIOC_STREAMON, VIDIOC_QBUF calls, due to insufficient number
of empty buffers.

Reported-by: Alexander Nestorov 
Signed-off-by: Sylwester Nawrocki 
---
 drivers/media/platform/s3c-camif/camif-capture.c |   15 +++
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/s3c-camif/camif-capture.c 
b/drivers/media/platform/s3c-camif/camif-capture.c
index a55793c..b8466f3 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -934,12 +934,19 @@ static int s3c_camif_reqbufs(struct file *file, void 
*priv,
vp->owner = NULL;

ret = vb2_reqbufs(&vp->vb_queue, rb);
-   if (!ret) {
-   vp->reqbufs_count = rb->count;
-   if (vp->owner == NULL && rb->count > 0)
-   vp->owner = priv;
+   if (ret < 0)
+   return ret;
+
+   if (rb->count && rb->count < CAMIF_REQ_BUFS_MIN) {
+   rb->count = 0;
+   vb2_reqbufs(&vp->vb_queue, rb);
+   ret = -ENOMEM;
}

+   vp->reqbufs_count = rb->count;
+   if (vp->owner == NULL && rb->count > 0)
+   vp->owner = priv;
+
return ret;
 }

--
1.7.4.1

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


Re: Hi again

2013-02-07 Thread Sylwester Nawrocki

On 02/07/2013 12:53 AM, Sylwester Nawrocki wrote:

root@mini2440:~ echo 100 > /sys/module/videobuf2_core/parameters/debug

root@mini2440:~ gst-launch -v v4l2src device=/dev/video0 queue-size=2
! video/x-raw-yuv,format='(fourcc)'YV12 ! ffmpegcolorspace ! fbdevsink

root@mini2440:~ dmesg -c
[ 1907.11] s3c-camif s3c2440-camif: dma_alloc_coherent of size
12582912 failed
[ 1907.115000] vb2: Failed allocating memory for buffer 1

The error is ignored here, it should all fail at this point.

[ 1907.12] vb2: Buffer 0, plane 0 offset 0x
[ 1907.125000] vb2: Allocated 1 buffers, 1 plane(s) each
[ 1907.22] vb2: Buffer 0, plane 0 successfully mapped
[ 1907.225000] vb2: qbuf of buffer 0 succeeded
[ 1907.23] vb2: Streamon successful


I've found there is a bug in the driver. It happens that only one buffer
out of two gets allocated and the minimum required for the driver to start
streaming is 2. I've pushed a patch fixing this bug [1] to the 3.7 based
testing/s3c-camif branch. I'll post it to LMML in a minute.

It won't really solve your problem, but at least there is now clear
indication what's wrong, and the application should not get stuck. Please
check you CMA memory region size. I suspect that you use the default 16 MB
and it allows you to allocate only one buffer. 16 MB might still be
sufficient for 1280x1024 - OV9650's maximum resolution. Anyway, it might
be worth to check what CONFIG_CMA_SIZE_MBYTES is set to.
(Device drivers -> Generic Driver Options -> Contiguous Memory Allocator)


[23:07] which is also why it freezes (doesn't output
buffers) instead of giving an error when you try to set that
resolution


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


Re: [RFC PATCH] ivtv-alsa: regression fix: remove __init from ivtv_alsa_load

2013-02-07 Thread Andy Walls
Hans Verkuil  wrote:

>Andy,
>
>Please review this patch. This fix probably should be fast-tracked to
>3.8 and
>queued for stable 3.7.
>
>ivtv-alsa kept crashing my machine every time I loaded it, and this is
>the
>cause.
>
>Regards,
>
>   Hans
>
>This function is called after initialization, so it should never be
>marked
>__init!
>
>Signed-off-by: Hans Verkuil 
>---
> drivers/media/pci/ivtv/ivtv-alsa-main.c |2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c
>b/drivers/media/pci/ivtv/ivtv-alsa-main.c
>index 4a221c6..e970cfa 100644
>--- a/drivers/media/pci/ivtv/ivtv-alsa-main.c
>+++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c
>@@ -205,7 +205,7 @@ err_exit:
>   return ret;
> }
> 
>-static int __init ivtv_alsa_load(struct ivtv *itv)
>+static int ivtv_alsa_load(struct ivtv *itv)
> {
>   struct v4l2_device *v4l2_dev = &itv->v4l2_dev;
>   struct ivtv_stream *s;
>-- 
>1.7.10.4

Hans,

I concur.  Now I have to check cx18 for the same problem.

Your patch looks good.

Reviewed-by: Andy Walls 
Signed-off-by: Andy Walls 

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


[PATCH] [media] mantis: add remote control support

2013-02-07 Thread Jan Klötzke
The embedded UART is apparently used to receive decoded IR (RC5?) codes.
Forward these scan codes to the RC framework and (where known) add
corresponding mapping tables to translate them into regular keys.

This patch has been tested on a TechniSat CableStar HD2. Other rc-maps
were taken from Christoph Pinkl's patch
(http://patchwork.linuxtv.org/patch/7217/) and the s2-liplianin
repository. The major difference to Christoph's patch is a reworked
interrupt handling of the UART because the RX interrupt is apparently
level triggered and requires masking until the FIFO is read by the UART
worker.

Signed-off-by: Jan Klötzke 
---
 drivers/media/pci/mantis/hopper_cards.c|   13 ++-
 drivers/media/pci/mantis/mantis_cards.c|   60 +---
 drivers/media/pci/mantis/mantis_common.h   |   33 ++-
 drivers/media/pci/mantis/mantis_dma.c  |5 +-
 drivers/media/pci/mantis/mantis_i2c.c  |8 +-
 drivers/media/pci/mantis/mantis_input.c|  103 +++-
 drivers/media/pci/mantis/mantis_input.h|   28 ++
 drivers/media/pci/mantis/mantis_pcmcia.c   |4 +-
 drivers/media/pci/mantis/mantis_uart.c |   62 ++--
 drivers/media/rc/keymaps/Makefile  |4 +
 drivers/media/rc/keymaps/rc-technisat-ts35.c   |   76 ++
 .../media/rc/keymaps/rc-terratec-cinergy-c-pci.c   |   88 +
 .../media/rc/keymaps/rc-terratec-cinergy-s2-hd.c   |   86 
 drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c   |   98 +++
 include/media/rc-map.h |4 +
 15 files changed, 524 insertions(+), 148 deletions(-)
 create mode 100644 drivers/media/pci/mantis/mantis_input.h
 create mode 100644 drivers/media/rc/keymaps/rc-technisat-ts35.c
 create mode 100644 drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c
 create mode 100644 drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c
 create mode 100644 drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c

diff --git a/drivers/media/pci/mantis/hopper_cards.c 
b/drivers/media/pci/mantis/hopper_cards.c
index 6fe9fe5..8a76244 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -106,6 +106,9 @@ static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
}
if (stat & MANTIS_INT_IRQ1) {
dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
+   spin_lock(&mantis->intmask_lock);
+   mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ1, 
MANTIS_INT_MASK);
+   spin_unlock(&mantis->intmask_lock);
schedule_work(&mantis->uart_work);
}
if (stat & MANTIS_INT_OCERR) {
@@ -154,6 +157,7 @@ static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
 static int hopper_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *pci_id)
 {
+   struct mantis_pci_drvdata *drvdata;
struct mantis_pci *mantis;
struct mantis_hwconfig *config;
int err = 0;
@@ -165,12 +169,16 @@ static int hopper_pci_probe(struct pci_dev *pdev,
goto fail0;
}
 
+   drvdata = (struct mantis_pci_drvdata *) 
pci_id->driver_data;
mantis->num = devs;
mantis->verbose = verbose;
mantis->pdev= pdev;
-   config  = (struct mantis_hwconfig *) 
pci_id->driver_data;
+   config  = drvdata->hwconfig;
config->irq_handler = &hopper_irq_handler;
mantis->hwconfig= config;
+   mantis->rc_map_name = drvdata->rc_map_name;
+
+   spin_lock_init(&mantis->intmask_lock);
 
err = mantis_pci_init(mantis);
if (err) {
@@ -247,7 +255,8 @@ static void hopper_pci_remove(struct pci_dev *pdev)
 }
 
 static struct pci_device_id hopper_pci_table[] = {
-   MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config),
+   MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config,
+   NULL),
{ }
 };
 
diff --git a/drivers/media/pci/mantis/mantis_cards.c 
b/drivers/media/pci/mantis/mantis_cards.c
index 932a0d7..7fdc9798 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "dmxdev.h"
 #include "dvbdev.h"
@@ -49,6 +50,7 @@
 #include "mantis_pci.h"
 #include "mantis_i2c.h"
 #include "mantis_reg.h"
+#include "mantis_input.h"
 
 static unsigned int verbose;
 module_param(verbose, int, 0644);
@@ -114,6 +116,9 @@ static irqreturn_t mantis_irq_handler(int irq, void *dev_id)
}
if (stat & MANTIS_INT_IRQ1) {
dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
+   spin_lock(&mantis->intmask_lock);
+   mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ1, 
MANTIS_INT_MASK);
+  

cron job: media_tree daily build: ERRORS

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

Results of the daily build of media_tree:

date:   Thu Feb  7 19:00:18 CET 2013
git branch: for_v3.9
git hash:   248ac368ce4b3cd36515122d888403909d7a2500
gcc version:i686-linux-gcc (GCC) 4.7.2
host hardware:  x86_64
host os:3.8.03-marune

linux-git-arm-davinci: WARNINGS
linux-git-arm-exynos: ERRORS
linux-git-arm-omap: WARNINGS
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.14-i686: WARNINGS
linux-2.6.32.27-i686: WARNINGS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: WARNINGS
linux-3.2.37-i686: WARNINGS
linux-3.3.8-i686: WARNINGS
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-rc4-i686: ERRORS
linux-2.6.31.14-x86_64: WARNINGS
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: WARNINGS
linux-3.2.37-x86_64: WARNINGS
linux-3.3.8-x86_64: WARNINGS
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-rc4-x86_64: ERRORS
apps: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The 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


[PATCH v2 13/13] em28xx: do not claim VBI support if the device is a camera

2013-02-07 Thread Frank Schäfer
Avoids registering a VBI device and streaming in VBI-mode if the device is a
camera.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-core.c |5 +
 1 Datei geändert, 5 Zeilen hinzugefügt(+)

diff --git a/drivers/media/usb/em28xx/em28xx-core.c 
b/drivers/media/usb/em28xx/em28xx-core.c
index 3905570..a6e88db 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -681,6 +681,11 @@ int em28xx_vbi_supported(struct em28xx *dev)
if (disable_vbi == 1)
return 0;
 
+   if (dev->board.is_webcam)
+   return 0;
+
+   /* FIXME: check subdevices for VBI support */
+
if (dev->chip_id == CHIP_ID_EM2860 ||
dev->chip_id == CHIP_ID_EM2883)
return 1;
-- 
1.7.10.4

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


[PATCH v2 11/13] em28xx: make ioctl VIDIOC_DBG_G_CHIP_IDENT available without CONFIG_VIDEO_ADV_DEBUG selected

2013-02-07 Thread Frank Schäfer
VIDIOC_DBG_G_CHIP_IDENT is a "normal" and not an "advanced" debug functionality.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |   27 +--
 1 Datei geändert, 13 Zeilen hinzugefügt(+), 14 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index dd05cfb..2020faa 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1204,19 +1204,6 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
return 0;
 }
 
-#ifdef CONFIG_VIDEO_ADV_DEBUG
-static int em28xx_reg_len(int reg)
-{
-   switch (reg) {
-   case EM28XX_R40_AC97LSB:
-   case EM28XX_R30_HSCALELOW:
-   case EM28XX_R32_VSCALELOW:
-   return 2;
-   default:
-   return 1;
-   }
-}
-
 static int vidioc_g_chip_ident(struct file *file, void *priv,
   struct v4l2_dbg_chip_ident *chip)
 {
@@ -1239,6 +1226,18 @@ static int vidioc_g_chip_ident(struct file *file, void 
*priv,
return 0;
 }
 
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int em28xx_reg_len(int reg)
+{
+   switch (reg) {
+   case EM28XX_R40_AC97LSB:
+   case EM28XX_R30_HSCALELOW:
+   case EM28XX_R32_VSCALELOW:
+   return 2;
+   default:
+   return 1;
+   }
+}
 
 static int vidioc_g_register(struct file *file, void *priv,
 struct v4l2_dbg_register *reg)
@@ -1662,10 +1661,10 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_s_frequency = vidioc_s_frequency,
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
+   .vidioc_g_chip_ident= vidioc_g_chip_ident,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register  = vidioc_g_register,
.vidioc_s_register  = vidioc_s_register,
-   .vidioc_g_chip_ident= vidioc_g_chip_ident,
 #endif
 };
 
-- 
1.7.10.4

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


[PATCH v2 12/13] em28xx: make ioctl VIDIOC_DBG_G_CHIP_IDENT available for radio devices

2013-02-07 Thread Frank Schäfer
Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |1 +
 1 Datei geändert, 1 Zeile hinzugefügt(+)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 2020faa..5e360e0 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1691,6 +1691,7 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
.vidioc_s_frequency   = vidioc_s_frequency,
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
+   .vidioc_g_chip_ident  = vidioc_g_chip_ident,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register= vidioc_g_register,
.vidioc_s_register= vidioc_s_register,
-- 
1.7.10.4

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


[PATCH v2 09/13] em28xx: VIDIOC_G_TUNER: remove unneeded setting of tuner type

2013-02-07 Thread Frank Schäfer
The tuner type is set by the v4l2-core based on the device type.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |1 -
 1 Datei geändert, 1 Zeile entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index af3e70a..319d0ee 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1493,7 +1493,6 @@ static int radio_g_tuner(struct file *file, void *priv,
return -EINVAL;
 
strcpy(t->name, "Radio");
-   t->type = V4L2_TUNER_RADIO;
 
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
 
-- 
1.7.10.4

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


[PATCH v2 10/13] em28xx: remove obsolete device state checks from the ioctl functions

2013-02-07 Thread Frank Schäfer
v4l2_device_disconnect() is called when the device is disconnected, so that the
v4l2-core rejects all ioctl calls.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |   43 ---
 1 Datei geändert, 43 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 319d0ee..dd05cfb 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -799,15 +799,6 @@ const struct v4l2_ctrl_ops em28xx_ctrl_ops = {
.s_ctrl = em28xx_s_ctrl,
 };
 
-static int check_dev(struct em28xx *dev)
-{
-   if (dev->disconnected) {
-   em28xx_errdev("v4l2 ioctl: device not present\n");
-   return -ENODEV;
-   }
-   return 0;
-}
-
 static void get_scale(struct em28xx *dev,
unsigned int width, unsigned int height,
unsigned int *hscale, unsigned int *vscale)
@@ -957,11 +948,6 @@ static int vidioc_g_std(struct file *file, void *priv, 
v4l2_std_id *norm)
 {
struct em28xx_fh   *fh  = priv;
struct em28xx  *dev = fh->dev;
-   intrc;
-
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
 
*norm = dev->norm;
 
@@ -972,11 +958,6 @@ static int vidioc_querystd(struct file *file, void *priv, 
v4l2_std_id *norm)
 {
struct em28xx_fh   *fh  = priv;
struct em28xx  *dev = fh->dev;
-   intrc;
-
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
 
v4l2_device_call_all(&dev->v4l2_dev, 0, video, querystd, norm);
 
@@ -988,13 +969,9 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id *norm)
struct em28xx_fh   *fh  = priv;
struct em28xx  *dev = fh->dev;
struct v4l2_format f;
-   intrc;
 
if (*norm == dev->norm)
return 0;
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
 
if (dev->streaming_users > 0)
return -EBUSY;
@@ -1101,11 +1078,6 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int i)
 {
struct em28xx_fh   *fh  = priv;
struct em28xx  *dev = fh->dev;
-   intrc;
-
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
 
if (i >= MAX_EM28XX_INPUT)
return -EINVAL;
@@ -1180,11 +1152,6 @@ static int vidioc_g_tuner(struct file *file, void *priv,
 {
struct em28xx_fh  *fh  = priv;
struct em28xx *dev = fh->dev;
-   int   rc;
-
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
 
if (0 != t->index)
return -EINVAL;
@@ -1200,11 +1167,6 @@ static int vidioc_s_tuner(struct file *file, void *priv,
 {
struct em28xx_fh  *fh  = priv;
struct em28xx *dev = fh->dev;
-   int   rc;
-
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
 
if (0 != t->index)
return -EINVAL;
@@ -1231,11 +1193,6 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
 {
struct em28xx_fh  *fh  = priv;
struct em28xx *dev = fh->dev;
-   int   rc;
-
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
 
if (0 != f->tuner)
return -EINVAL;
-- 
1.7.10.4

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


[PATCH v2 08/13] em28xx: get rid of duplicate function vidioc_s_fmt_vbi_cap()

2013-02-07 Thread Frank Schäfer
vidioc_s_fmt_vbi_cap() is a 100% duplicate of vidioc_g_fmt_vbi_cap() and
therefore can be removed.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |   31 +--
 1 Datei geändert, 1 Zeile hinzugefügt(+), 30 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index edd29ae..af3e70a 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1480,35 +1480,6 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void 
*priv,
return 0;
 }
 
-static int vidioc_s_fmt_vbi_cap(struct file *file, void *priv,
-   struct v4l2_format *format)
-{
-   struct em28xx_fh  *fh  = priv;
-   struct em28xx *dev = fh->dev;
-
-   format->fmt.vbi.samples_per_line = dev->vbi_width;
-   format->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
-   format->fmt.vbi.offset = 0;
-   format->fmt.vbi.flags = 0;
-   format->fmt.vbi.sampling_rate = 675 * 4 / 2;
-   format->fmt.vbi.count[0] = dev->vbi_height;
-   format->fmt.vbi.count[1] = dev->vbi_height;
-   memset(format->fmt.vbi.reserved, 0, sizeof(format->fmt.vbi.reserved));
-
-   /* Varies by video standard (NTSC, PAL, etc.) */
-   if (dev->norm & V4L2_STD_525_60) {
-   /* NTSC */
-   format->fmt.vbi.start[0] = 10;
-   format->fmt.vbi.start[1] = 273;
-   } else if (dev->norm & V4L2_STD_625_50) {
-   /* PAL */
-   format->fmt.vbi.start[0] = 6;
-   format->fmt.vbi.start[1] = 318;
-   }
-
-   return 0;
-}
-
 /* --- */
 /* RADIO ESPECIFIC IOCTLS  */
 /* --- */
@@ -1707,7 +1678,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_s_fmt_vid_cap   = vidioc_s_fmt_vid_cap,
.vidioc_g_fmt_vbi_cap   = vidioc_g_fmt_vbi_cap,
.vidioc_try_fmt_vbi_cap = vidioc_g_fmt_vbi_cap,
-   .vidioc_s_fmt_vbi_cap   = vidioc_s_fmt_vbi_cap,
+   .vidioc_s_fmt_vbi_cap   = vidioc_g_fmt_vbi_cap,
.vidioc_enum_framesizes = vidioc_enum_framesizes,
.vidioc_g_audio = vidioc_g_audio,
.vidioc_s_audio = vidioc_s_audio,
-- 
1.7.10.4

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


[PATCH v2 07/13] em28xx: remove ioctl VIDIOC_CROPCAP

2013-02-07 Thread Frank Schäfer
The em28xx driver doesn't support the VIDIOC_G_CROP and VIDIOC_S_CROP ioctls,
so VIDIOC_CROPCAP is useless and has the potential to confuse applications,
because it can be interpreted as indicator for cropping support.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |   21 -
 1 Datei geändert, 21 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 6172d59..edd29ae 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1364,26 +1364,6 @@ static int vidioc_s_register(struct file *file, void 
*priv,
 #endif
 
 
-static int vidioc_cropcap(struct file *file, void *priv,
-   struct v4l2_cropcap *cc)
-{
-   struct em28xx_fh  *fh  = priv;
-   struct em28xx *dev = fh->dev;
-
-   if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   return -EINVAL;
-
-   cc->bounds.left = 0;
-   cc->bounds.top = 0;
-   cc->bounds.width = dev->width;
-   cc->bounds.height = dev->height;
-   cc->defrect = cc->bounds;
-   cc->pixelaspect.numerator = 54; /* 4:3 FIXME: remove magic numbers */
-   cc->pixelaspect.denominator = 59;
-
-   return 0;
-}
-
 static int vidioc_querycap(struct file *file, void  *priv,
struct v4l2_capability *cap)
 {
@@ -1731,7 +1711,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_enum_framesizes = vidioc_enum_framesizes,
.vidioc_g_audio = vidioc_g_audio,
.vidioc_s_audio = vidioc_s_audio,
-   .vidioc_cropcap = vidioc_cropcap,
 
.vidioc_reqbufs = vb2_ioctl_reqbufs,
.vidioc_create_bufs = vb2_ioctl_create_bufs,
-- 
1.7.10.4

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


[PATCH v2 06/13] em28xx: make ioctls VIDIOC_G/S_PARM working for VBI devices

2013-02-07 Thread Frank Schäfer
With the current code V4L2_BUF_TYPE_VIDEO_CAPTURE is accepted only, but for VBI
devices only buffer type V4L2_BUF_TYPE_VBI_CAPTURE is used/valid.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |6 --
 1 Datei geändert, 6 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index d4dc5b2..6172d59 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1024,9 +1024,6 @@ static int vidioc_g_parm(struct file *file, void *priv,
struct em28xx  *dev = fh->dev;
int rc = 0;
 
-   if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   return -EINVAL;
-
p->parm.capture.readbuffers = EM28XX_MIN_BUF;
if (dev->board.is_webcam)
rc = v4l2_device_call_until_err(&dev->v4l2_dev, 0,
@@ -1044,9 +1041,6 @@ static int vidioc_s_parm(struct file *file, void *priv,
struct em28xx_fh   *fh  = priv;
struct em28xx  *dev = fh->dev;
 
-   if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   return -EINVAL;
-
p->parm.capture.readbuffers = EM28XX_MIN_BUF;
return v4l2_device_call_until_err(&dev->v4l2_dev, 0, video, s_parm, p);
 }
-- 
1.7.10.4

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


[PATCH v2 05/13] em28xx: disable ioctl VIDIOC_S_PARM for VBI devices

2013-02-07 Thread Frank Schäfer
VIDIOC_S_PARM doesn't make sense for VBI device nodes, because we don't support
selecting the number of read buffers to use.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |1 +
 1 Datei geändert, 1 Zeile hinzugefügt(+)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index c76714d..d4dc5b2 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1920,6 +1920,7 @@ int em28xx_register_analog_devices(struct em28xx *dev)
dev->vbi_dev->queue->lock = &dev->vb_vbi_queue_lock;
 
/* disable inapplicable ioctls */
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_S_PARM);
if (dev->tuner_type == TUNER_ABSENT) {
v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_G_TUNER);
v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_S_TUNER);
-- 
1.7.10.4

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


[PATCH v2 04/13] em28xx: use v4l2_disable_ioctl() to disable ioctl VIDIOC_S_PARM

2013-02-07 Thread Frank Schäfer
Instead of checking the device type and returning -ENOTTY inside the ioctl
function, use v4l2_disable_ioctl() to disable the ioctl VIDIOC_S_PARM if the
device is not a camera.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |5 ++---
 1 Datei geändert, 2 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 378d8a1..c76714d 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1044,9 +1044,6 @@ static int vidioc_s_parm(struct file *file, void *priv,
struct em28xx_fh   *fh  = priv;
struct em28xx  *dev = fh->dev;
 
-   if (!dev->board.is_webcam)
-   return -ENOTTY;
-
if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
 
@@ -1891,6 +1888,8 @@ int em28xx_register_analog_devices(struct em28xx *dev)
v4l2_disable_ioctl(dev->vdev, VIDIOC_QUERYSTD);
v4l2_disable_ioctl(dev->vdev, VIDIOC_G_STD);
v4l2_disable_ioctl(dev->vdev, VIDIOC_S_STD);
+   } else {
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_S_PARM);
}
if (dev->tuner_type == TUNER_ABSENT) {
v4l2_disable_ioctl(dev->vdev, VIDIOC_G_TUNER);
-- 
1.7.10.4

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


[PATCH v2 02/13] em28xx: disable tuner related ioctls for video and VBI devices without tuner

2013-02-07 Thread Frank Schäfer
Disable the ioctls VIDIOC_G_TUNER, VIDIOC_S_TUNER, VIDIOC_G_FREQUENCY and
VIDIOC_S_FREQUENCY for video and VBI devices without tuner.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |   14 ++
 1 Datei geändert, 14 Zeilen hinzugefügt(+)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 7f1f37c..dd2e31c 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1899,6 +1899,12 @@ int em28xx_register_analog_devices(struct em28xx *dev)
v4l2_disable_ioctl(dev->vdev, VIDIOC_G_STD);
v4l2_disable_ioctl(dev->vdev, VIDIOC_S_STD);
}
+   if (dev->tuner_type == TUNER_ABSENT) {
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_G_TUNER);
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_S_TUNER);
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_G_FREQUENCY);
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_S_FREQUENCY);
+   }
 
/* register v4l2 video video_device */
ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
@@ -1917,6 +1923,14 @@ int em28xx_register_analog_devices(struct em28xx *dev)
dev->vbi_dev->queue = &dev->vb_vbiq;
dev->vbi_dev->queue->lock = &dev->vb_vbi_queue_lock;
 
+   /* disable inapplicable ioctls */
+   if (dev->tuner_type == TUNER_ABSENT) {
+   v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_G_TUNER);
+   v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_S_TUNER);
+   v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_G_FREQUENCY);
+   v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_S_FREQUENCY);
+   }
+
/* register v4l2 vbi video_device */
ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
vbi_nr[dev->devno]);
-- 
1.7.10.4

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


[PATCH v2 03/13] em28xx: use v4l2_disable_ioctl() to disable ioctls VIDIOC_G_AUDIO and VIDIOC_S_AUDIO

2013-02-07 Thread Frank Schäfer
Instead of checking the device type and returning -EINVAL inside the ioctl
functions, use v4l2_disable_ioctl() to disable the ioctls VIDIOC_G_AUDIO and
VIDIOC_S_AUDIO if the device doesn't support audio.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |   15 ---
 1 Datei geändert, 8 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index dd2e31c..378d8a1 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1130,9 +1130,6 @@ static int vidioc_g_audio(struct file *file, void *priv, 
struct v4l2_audio *a)
struct em28xx_fh   *fh= priv;
struct em28xx  *dev   = fh->dev;
 
-   if (!dev->audio_mode.has_audio)
-   return -EINVAL;
-
switch (a->index) {
case EM28XX_AMUX_VIDEO:
strcpy(a->name, "Television");
@@ -1173,10 +1170,6 @@ static int vidioc_s_audio(struct file *file, void *priv, 
const struct v4l2_audio
struct em28xx_fh   *fh  = priv;
struct em28xx  *dev = fh->dev;
 
-
-   if (!dev->audio_mode.has_audio)
-   return -EINVAL;
-
if (a->index >= MAX_EM28XX_INPUT)
return -EINVAL;
if (0 == INPUT(a->index)->type)
@@ -1905,6 +1898,10 @@ int em28xx_register_analog_devices(struct em28xx *dev)
v4l2_disable_ioctl(dev->vdev, VIDIOC_G_FREQUENCY);
v4l2_disable_ioctl(dev->vdev, VIDIOC_S_FREQUENCY);
}
+   if (!dev->audio_mode.has_audio) {
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_G_AUDIO);
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_S_AUDIO);
+   }
 
/* register v4l2 video video_device */
ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
@@ -1930,6 +1927,10 @@ int em28xx_register_analog_devices(struct em28xx *dev)
v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_G_FREQUENCY);
v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_S_FREQUENCY);
}
+   if (!dev->audio_mode.has_audio) {
+   v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_G_AUDIO);
+   v4l2_disable_ioctl(dev->vbi_dev, VIDIOC_S_AUDIO);
+   }
 
/* register v4l2 vbi video_device */
ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
-- 
1.7.10.4

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


[PATCH v2 01/13] em28xx: use v4l2_disable_ioctl() to disable ioctls VIDIOC_QUERYSTD, VIDIOC_G/S_STD

2013-02-07 Thread Frank Schäfer
Instead of checking the device type and returning -ENOTTY inside the ioctl
functions, use v4l2_disable_ioctl() to disable the ioctls VIDIOC_QUERYSTD,
VIDIOC_G_STD and VIDIOC_S_STD if the device is a camera.

Signed-off-by: Frank Schäfer 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c |   13 +++--
 1 Datei geändert, 7 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 2eabf2a..7f1f37c 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -959,8 +959,6 @@ static int vidioc_g_std(struct file *file, void *priv, 
v4l2_std_id *norm)
struct em28xx  *dev = fh->dev;
intrc;
 
-   if (dev->board.is_webcam)
-   return -ENOTTY;
rc = check_dev(dev);
if (rc < 0)
return rc;
@@ -976,8 +974,6 @@ static int vidioc_querystd(struct file *file, void *priv, 
v4l2_std_id *norm)
struct em28xx  *dev = fh->dev;
intrc;
 
-   if (dev->board.is_webcam)
-   return -ENOTTY;
rc = check_dev(dev);
if (rc < 0)
return rc;
@@ -994,8 +990,6 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id *norm)
struct v4l2_format f;
intrc;
 
-   if (dev->board.is_webcam)
-   return -ENOTTY;
if (*norm == dev->norm)
return 0;
rc = check_dev(dev);
@@ -1899,6 +1893,13 @@ int em28xx_register_analog_devices(struct em28xx *dev)
dev->vdev->queue = &dev->vb_vidq;
dev->vdev->queue->lock = &dev->vb_queue_lock;
 
+   /* disable inapplicable ioctls */
+   if (dev->board.is_webcam) {
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_QUERYSTD);
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_G_STD);
+   v4l2_disable_ioctl(dev->vdev, VIDIOC_S_STD);
+   }
+
/* register v4l2 video video_device */
ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
   video_nr[dev->devno]);
-- 
1.7.10.4

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


[PATCH v2 00/13] em28xx: ioctl fixes/clean-ups

2013-02-07 Thread Frank Schäfer
This patch series addresses some issues with the ioctl code of the em28xx 
driver:
Patches 1-5 and 11+12 fix and clean up the enabling/disabling of the ioctls 
depending on the device type and equipment.
Patches 6-10 remove some obsolete/useless code.
Patch 13 improves the VBI support detection and device node registration.

Changes since v1:
- added patch 11

Frank Schäfer (13):
  em28xx: use v4l2_disable_ioctl() to disable ioctls VIDIOC_QUERYSTD,
VIDIOC_G/S_STD
  em28xx: disable tuner related ioctls for video and VBI devices
without tuner
  em28xx: use v4l2_disable_ioctl() to disable ioctls VIDIOC_G_AUDIO and
VIDIOC_S_AUDIO
  em28xx: use v4l2_disable_ioctl() to disable ioctl VIDIOC_S_PARM
  em28xx: disable ioctl VIDIOC_S_PARM for VBI devices
  em28xx: make ioctls VIDIOC_G/S_PARM working for VBI devices
  em28xx: remove ioctl VIDIOC_CROPCAP
  em28xx: get rid of duplicate function vidioc_s_fmt_vbi_cap()
  em28xx: VIDIOC_G_TUNER: remove unneeded setting of tuner type
  em28xx: remove obsolete device state checks from the ioctl functions
  em28xx: make ioctl VIDIOC_DBG_G_CHIP_IDENT available without
CONFIG_VIDEO_ADV_DEBUG selected
  em28xx: make ioctl VIDIOC_DBG_G_CHIP_IDENT available for radio
devices
  em28xx: do not claim VBI support if the device is a camera

 drivers/media/usb/em28xx/em28xx-core.c  |5 +
 drivers/media/usb/em28xx/em28xx-video.c |  178 ---
 2 Dateien geändert, 52 Zeilen hinzugefügt(+), 131 Zeilen entfernt(-)

-- 
1.7.10.4

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


[PATCH RFC v6] [media] Add a V4L2 OF parser

2013-02-07 Thread Sylwester Nawrocki
From: Guennadi Liakhovetski 

Add a V4L2 OF parser, implementing bindings documented in
Documentation/devicetree/bindings/media/video-interfaces.txt.

Signed-off-by: Guennadi Liakhovetski 
[s.nawro...@samsung.com: various corrections and improvements
since the initial version]
Signed-off-by: Sylwester Nawrocki 
---

Changes since v5:
 - renamed v4l2_of_parse_mipi_csi2_bus -> v4l2_of_parse_csi_bus,
 - corrected v4l2_of_get_remote_port_parent() function declaration
   for !CONFIG_OF,
 - reworked v4l2_of_get_next_endpoint() function to consider the
   'port' nodes can be grouped under optional 'ports' node,
 - added kerneldoc description for v4l2_of_get_next_endpoint()
   function.

This patch and the related bindings documentation can be browsed at:
http://git.linuxtv.org/snawrocki/samsung.git/devicetree

Changes since v4:
 - reworked v4l2_of_get_remote_port() function to consider cases
   where 'port' nodes are grouped in a parent 'ports' node,
 - rearranged struct v4l2_of_endpoint and related changes added
   in the parser code,
 - added kerneldoc description for struct v4l2_of_endpoint,
 - s/link/endpoint in the comments,
---
 drivers/media/v4l2-core/Makefile  |3 +
 drivers/media/v4l2-core/v4l2-of.c |  260 +
 include/media/v4l2-of.h   |   98 ++
 3 files changed, 361 insertions(+)
 create mode 100644 drivers/media/v4l2-core/v4l2-of.c
 create mode 100644 include/media/v4l2-of.h

diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index a9d3552..00c4a19 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -9,6 +9,9 @@ videodev-objs   :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o 
v4l2-fh.o \
 ifeq ($(CONFIG_COMPAT),y)
   videodev-objs += v4l2-compat-ioctl32.o
 endif
+ifeq ($(CONFIG_OF),y)
+  videodev-objs += v4l2-of.o
+endif

 obj-$(CONFIG_VIDEO_DEV) += videodev.o
 obj-$(CONFIG_VIDEO_V4L2_INT_DEVICE) += v4l2-int-device.o
diff --git a/drivers/media/v4l2-core/v4l2-of.c 
b/drivers/media/v4l2-core/v4l2-of.c
new file mode 100644
index 000..0bf1f75
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -0,0 +1,260 @@
+/*
+ * V4L2 OF binding parsing library
+ *
+ * Copyright (C) 2012 Renesas Electronics Corp.
+ * Author: Guennadi Liakhovetski 
+ *
+ * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/**
+ * v4l2_of_parse_csi_bus() - parse MIPI CSI-2 bus properties
+ * @node: pointer to endpoint device_node
+ * @endpoint: pointer to v4l2_of_endpoint data structure
+ *
+ * Return: 0 on success or negative error value otherwise.
+ */
+int v4l2_of_parse_csi_bus(const struct device_node *node,
+ struct v4l2_of_endpoint *endpoint)
+{
+   struct v4l2_mbus_mipi_csi2 *mipi_csi2 = &endpoint->mbus.mipi_csi2;
+   u32 data_lanes[ARRAY_SIZE(mipi_csi2->data_lanes)];
+   struct property *prop;
+   const __be32 *lane = NULL;
+   u32 v;
+   int i = 0;
+
+   prop = of_find_property(node, "data-lanes", NULL);
+   if (!prop)
+   return -EINVAL;
+   do {
+   lane = of_prop_next_u32(prop, lane, &data_lanes[i]);
+   } while (lane && i++ < ARRAY_SIZE(data_lanes));
+
+   mipi_csi2->num_data_lanes = i;
+   while (i--)
+   mipi_csi2->data_lanes[i] = data_lanes[i];
+
+   if (!of_property_read_u32(node, "clock-lanes", &v))
+   mipi_csi2->clock_lane = v;
+
+   if (of_get_property(node, "clock-noncontinuous", &v))
+   endpoint->mbus.flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
+
+   return 0;
+}
+EXPORT_SYMBOL(v4l2_of_parse_csi_bus);
+
+/**
+ * v4l2_of_parse_parallel_bus() - parse parallel bus properties
+ * @node: pointer to endpoint device_node
+ * @endpoint: pointer to v4l2_of_endpoint data structure
+ */
+void v4l2_of_parse_parallel_bus(const struct device_node *node,
+   struct v4l2_of_endpoint *endpoint)
+{
+   unsigned int flags = 0;
+   u32 v;
+
+   if (WARN_ON(!endpoint))
+   return;
+
+   if (!of_property_read_u32(node, "hsync-active", &v))
+   flags |= v ? V4L2_MBUS_HSYNC_ACTIVE_HIGH :
+   V4L2_MBUS_HSYNC_ACTIVE_LOW;
+
+   if (!of_property_read_u32(node, "vsync-active", &v))
+   flags |= v ? V4L2_MBUS_VSYNC_ACTIVE_HIGH :
+   V4L2_MBUS_VSYNC_ACTIVE_LOW;
+
+   if (!of_property_read_u32(node, "pclk-sample", &v))
+   flags |= v ? V4L2_MBUS_PCLK_SAMPLE_RISING :
+   V4L2_MBUS_PCLK_SAMPLE_FALLING;
+
+   if (!of_property_read_u32(node, "field-even-active", &v))
+   flags |= v ? V4L2_MBUS_FIELD_EVEN_HIGH 

[PATCH] em28xx: fix analog streaming with USB bulk transfers

2013-02-07 Thread Frank Schäfer
With the conversion to videobuf2, some unnecessary calls of
em28xx_set_alternate() have been removed. It is now called at analog streaming
start only.
This has unveiled a bug that causes USB bulk transfers to fail with all urbs
having status -EVOERFLOW.
The reason is, that for bulk transfers usb_set_interface() needs to be called
even if the previous alt setting was the same (side note: bulk transfers seem
to work only with alt=0).
While it seems to be NOT necessary for isoc transfers, it's reasonable to just
call usb_set_interface() unconditionally in em28xx_set_alternate().
Also add a comment that explains the issue to prevent regressions in the future.

Signed-off-by: Frank Schäfer 
---
 drivers/media/usb/em28xx/em28xx-core.c |   43 
 1 Datei geändert, 22 Zeilen hinzugefügt(+), 21 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-core.c 
b/drivers/media/usb/em28xx/em28xx-core.c
index 80f87bb..3905570 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -811,12 +811,12 @@ int em28xx_resolution_set(struct em28xx *dev)
 /* Set USB alternate setting for analog video */
 int em28xx_set_alternate(struct em28xx *dev)
 {
-   int errCode, prev_alt = dev->alt;
+   int errCode;
int i;
unsigned int min_pkt_size = dev->width * 2 + 4;
 
/* NOTE: for isoc transfers, only alt settings > 0 are allowed
-for bulk transfers, use alt=0 as default value */
+bulk transfers seem to work only with alt=0 ! */
dev->alt = 0;
if ((alt > 0) && (alt < dev->num_alt)) {
em28xx_coredbg("alternate forced to %d\n", dev->alt);
@@ -847,25 +847,26 @@ int em28xx_set_alternate(struct em28xx *dev)
}
 
 set_alt:
-   if (dev->alt != prev_alt) {
-   if (dev->analog_xfer_bulk) {
-   dev->max_pkt_size = 512; /* USB 2.0 spec */
-   dev->packet_multiplier = EM28XX_BULK_PACKET_MULTIPLIER;
-   } else { /* isoc */
-   em28xx_coredbg("minimum isoc packet size: %u 
(alt=%d)\n",
-  min_pkt_size, dev->alt);
-   dev->max_pkt_size =
- dev->alt_max_pkt_size_isoc[dev->alt];
-   dev->packet_multiplier = EM28XX_NUM_ISOC_PACKETS;
-   }
-   em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n",
-  dev->alt, dev->max_pkt_size);
-   errCode = usb_set_interface(dev->udev, 0, dev->alt);
-   if (errCode < 0) {
-   em28xx_errdev("cannot change alternate number to %d 
(error=%i)\n",
-   dev->alt, errCode);
-   return errCode;
-   }
+   /* NOTE: for bulk transfers, we need to call usb_set_interface()
+* even if the previous settings were the same. Otherwise streaming
+* fails with all urbs having status = -EOVERFLOW ! */
+   if (dev->analog_xfer_bulk) {
+   dev->max_pkt_size = 512; /* USB 2.0 spec */
+   dev->packet_multiplier = EM28XX_BULK_PACKET_MULTIPLIER;
+   } else { /* isoc */
+   em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n",
+  min_pkt_size, dev->alt);
+   dev->max_pkt_size =
+ dev->alt_max_pkt_size_isoc[dev->alt];
+   dev->packet_multiplier = EM28XX_NUM_ISOC_PACKETS;
+   }
+   em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n",
+  dev->alt, dev->max_pkt_size);
+   errCode = usb_set_interface(dev->udev, 0, dev->alt);
+   if (errCode < 0) {
+   em28xx_errdev("cannot change alternate number to %d 
(error=%i)\n",
+ dev->alt, errCode);
+   return errCode;
}
return 0;
 }
-- 
1.7.10.4

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


Re: omap3isp - set_xclk dont work

2013-02-07 Thread Adriano Martins
Hi Laurent,

2013/2/7 Laurent Pinchart :
> Hi Adriano,
>
> On Wednesday 06 February 2013 11:26:43 Adriano Martins wrote:
>> Hi,
>>
>> I have 2 boards with DM3730 processor, a beagleboard  and a custom board.
>> The omap3isp is working in both boards, any error is seen. On beagleboard I
>> can see the xclka, then the sensor is detected and the driver is load
>> correctly. But, in the custom board, every seem work, there are no errors
>> too. But I can't see the xclka signal.
>>
>> The hardware is ok. Because, I load another driver that uses the camera bus.
>> The xclka is working.
>>
>> it is the same processor, same kernel version, same driver. Why, it work in
>> one, and not another.
>>
>> Someone can help me? please.
>
> The XCLK clocks currently require special handling in board code, with the
> sensor calling back to board code when it wants to turn the clock on/off, and
> board code calling the set_xclk isp operation. Does your board code perform
> that operation ?

Yes, my board code has implemented the function.

I do a stupid mistake. My board code have not the mux settings in
these pins, including the XCLKA.
Now, I can see the clock.

Sorry for spend your time.

Thank you.

Regards
Adriano Martins
--
To unsubscribe from this list: send the line "unsubscribe 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: On MIPI-CSI2 YUV420 formats and V4L2 Media Bus formats

2013-02-07 Thread Laurent Pinchart
Hi Antonio,

On Wednesday 06 February 2013 23:33:47 Antonio Ospite wrote:
> On Wed, 30 Jan 2013 01:23:48 +0100 Laurent Pinchart wrote:
> > On Monday 28 January 2013 13:22:10 Antonio Ospite wrote:
> > > Hi,
> > > 
> > > looking at the MIPI Alliance Specification for Camera Serial Interface
> > > 2 (I'll call it MIPI-CSI2 from now on, the document I am referring to
> > > is mentioned at [1] and available at [2]), I see there is an YUV420 8
> > > bit format (MIPI Data Type 0x18) specified with interleaved components
> > > 
> > > in the form of:
> > >   ... (odd lines)
> > >   UYVYUYVY... (even lines)
> > > 
> > > With even lines twice the size of odd lines.
> > > Such format is also supported by some sensors, for instance ov5640, and
> > > by MIPI-CSI2 receivers like OMAP4 ISS.
> > > 
> > > The doubt I have is: how should I represent those formats as media bus
> > > formats?
> > 
> > We likely need new media bus formats to describe those.
> 
> OK, I'll think to some names if I am going to actually use them.
> 
> > > I've seen that some drivers (sensors and SoC, for instance[3]) tend to
> > > identify the MIPI-CSI2 format above (0x18) with media bus formats like
> > > V4L2_MBUS_FMT_UYVY8_1_5X8 (actually the code above uses
> > > V4L2_MBUS_FMT_YUYV8_1_5X8 is this OK?), but from the v4l2 documentation
> > > [4] I understand that this format is supposed to have data in this
> > > 
> > > configuration:
> > >   ...
> > >   ...
> > >   ...
> > >   ...
> > >   ...
> > >   ...
> > 
> > Not exactly, the UYVY8_1_5X8 is transmits Y, U and V samples as UYYVYY...
> 
> Wait, am I misunderstanding the documentation at
> http://kernel.org/doc/htmldocs/media/subdev.html#v4l2-mbus-pixelcode-yuv8
> ? From the tables there it looks like that in UYVY8_1_5X8 the
> components are not interleaved on the same line, only the lines are.

Yes there's a misunderstanding. The table shows how bits are layed in in 
samples transmitted on the bus. The first sample transmits a U byte (8 bits, 
u7 to u0), the next two samples two Y bytes, the next sample a V byte, ... 
Every line does contain Y, U and V data.

> And that's why I was believing the code in [3] which maps YUYV8_1_5X8 (line
> interleaved, according to my interpretation of the v4l doc) to the MIPI-CSI2
> 0x18 format (components interleaved), was inaccurate (in the sense that I
> would have expected another [new] media bus format).
> 
> > > That is with interleaved lines, but NOT interleaved components. Should
> > > new media bus formats be added for .../UYVYUYVY...?
> > 
> > Yes, I think so.
> > 
> > > Another doubt I have is: how is the .../UYVYUYVY... data supposed
> > > to be processed in userspace? Is the MIPI Receiver (i.e, the SoC)
> > > expected to be able to convert it to a more usable format like YUV420P
> > > or NV12/NV21? Or are there applications capable of handling this data
> > > directly, or efficiently convert them to planar or semi-planar YUV420
> > > formats?
> > 
> > The bridge (receiver and DMA engine) driver will expose V4L2 pixel formats
> > corresponding to the bridge capabilities. If the bridge can store the
> > above stream in memory in NV12 it will expose that to applications. If the
> > bridge stores data in memory as described above, it will just expose that
> > format (it seems to correspond to the V4L2 M420 pixel format), and
> > applications will need to handle that explicitly.
> 
> I see, so what I can get in userspace obviously depends on the hardware
> _and_ the driver (i.e. how complete it is in exposing the hardware
> capabilities), but that means that if a bridge can transparently pass
> the data it gets from the sensor (in a given mediabus format) we could
> have as many pixelformats as we have media bus formats, I know these
> latter won't be added in practice, but is my reasoning right in
> principle? Each mediabus format is a possible candidate for a new
> pixelformat. Maybe I am asking the obvious but I am trying to complete
> my understanding about the relationship between media bus formats and
> pixelformats.

That's nearly correct. Let's say that you have two sensors that generate YUYV 
4:2:2 packed data. The first one has an 8-bit parallel bus and transmits 
samples as Y0 U0 Y1 V0 Y2 U2 Y3 V2... The second one has a 16-bit parallel bus 
and transmits samples as Y0U0 Y1V0 Y2U2 Y3V2... Both would result in the same 
pixel format in memory, even though they are different media bus pixel codes.

Other than that, yes, your understanding is correct.

> BTW that M420 format you mention is a bit different, from what I can
> see[6] it is something like a "line interleaved NV12":
> 
>   ...
>   ...
>   UVUV...
>   ...
>   ...
>   UVUV...
>   
> 
> [6]
> http://www.linuxtv.org/downloads/v4l-dvb-apis/V4L2-PIX-FMT-M420.html
> 
> So still another variation  on the theme :) Or am I still reading the
> documentation the wrong way?

You're right, my bad.

> > > In particular I am curios if the O

[RFC PATCH] ivtv-alsa: regression fix: remove __init from ivtv_alsa_load

2013-02-07 Thread Hans Verkuil
Andy,

Please review this patch. This fix probably should be fast-tracked to 3.8 and
queued for stable 3.7.

ivtv-alsa kept crashing my machine every time I loaded it, and this is the
cause.

Regards,

Hans

This function is called after initialization, so it should never be marked
__init!

Signed-off-by: Hans Verkuil 
---
 drivers/media/pci/ivtv/ivtv-alsa-main.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c 
b/drivers/media/pci/ivtv/ivtv-alsa-main.c
index 4a221c6..e970cfa 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-main.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c
@@ -205,7 +205,7 @@ err_exit:
return ret;
 }
 
-static int __init ivtv_alsa_load(struct ivtv *itv)
+static int ivtv_alsa_load(struct ivtv *itv)
 {
struct v4l2_device *v4l2_dev = &itv->v4l2_dev;
struct ivtv_stream *s;
-- 
1.7.10.4

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


[PATCH 1/4] fc0011: fp/fa value overflow fix

2013-02-07 Thread Michael Büsch
Assign the maximum instead of masking with the maximum on value overflow.

Signed-off-by: Michael Buesch 

---

Index: linux/drivers/media/tuners/fc0011.c
===
--- linux.orig/drivers/media/tuners/fc0011.c2012-10-22 16:11:27.634183359 
+0200
+++ linux/drivers/media/tuners/fc0011.c 2012-10-22 16:13:29.140465225 +0200
@@ -247,8 +247,8 @@
fa += 8;
}
if (fp > 0x1F) {
-   fp &= 0x1F;
-   fa &= 0xF;
+   fp = 0x1F;
+   fa = 0xF;
}
if (fa >= fp) {
dev_warn(&priv->i2c->dev,


-- 
Greetings, Michael.

PGP: 908D8B0E


signature.asc
Description: PGP signature


[PATCH 4/4] fc0011: Return early, if the frequency is already tuned

2013-02-07 Thread Michael Büsch
Return early, if we already tuned to a frequency.

Signed-off-by: Michael Buesch 

---

Index: linux/drivers/media/tuners/fc0011.c
===
--- linux.orig/drivers/media/tuners/fc0011.c2013-01-01 23:25:40.0 
+0100
+++ linux/drivers/media/tuners/fc0011.c 2013-01-01 23:27:44.985089712 +0100
@@ -187,6 +187,9 @@
u8 fa, fp, vco_sel, vco_cal;
u8 regs[FC11_NR_REGS] = { };
 
+   if (priv->frequency == p->frequency)
+   return 0;
+
regs[FC11_REG_7] = 0x0F;
regs[FC11_REG_8] = 0x3E;
regs[FC11_REG_10] = 0xB8;


-- 
Greetings, Michael.

PGP: 908D8B0E


signature.asc
Description: PGP signature


[PATCH 2/4] fc0011: Fix xin value clamping

2013-02-07 Thread Michael Büsch
Fix the xin value clamping and use clamp_t().

Signed-off-by: Michael Buesch 

---

Index: linux/drivers/media/tuners/fc0011.c
===
--- linux.orig/drivers/media/tuners/fc0011.c2012-10-22 16:13:29.140465225 
+0200
+++ linux/drivers/media/tuners/fc0011.c 2012-10-22 16:15:46.915056243 +0200
@@ -183,8 +183,7 @@
unsigned int i, vco_retries;
u32 freq = p->frequency / 1000;
u32 bandwidth = p->bandwidth_hz / 1000;
-   u32 fvco, xin, xdiv, xdivr;
-   u16 frac;
+   u32 fvco, xin, frac, xdiv, xdivr;
u8 fa, fp, vco_sel, vco_cal;
u8 regs[FC11_NR_REGS] = { };
 
@@ -227,12 +226,8 @@
frac += 32786;
if (!frac)
xin = 0;
-   else if (frac < 511)
-   xin = 512;
-   else if (frac < 65026)
-   xin = frac;
else
-   xin = 65024;
+   xin = clamp_t(u32, frac, 512, 65024);
regs[FC11_REG_XINHI] = xin >> 8;
regs[FC11_REG_XINLO] = xin;
 


-- 
Greetings, Michael.

PGP: 908D8B0E


signature.asc
Description: PGP signature


[PATCH 3/4] fc0011: Add some sanity checks and cleanups

2013-02-07 Thread Michael Büsch
Add some sanity checks to the calculations and make the REG_16 register write 
consistent
with the other ones.

Signed-off-by: Michael Buesch 

---

Index: linux/drivers/media/tuners/fc0011.c
===
--- linux.orig/drivers/media/tuners/fc0011.c2012-10-22 16:15:46.0 
+0200
+++ linux/drivers/media/tuners/fc0011.c 2012-10-22 16:17:15.280720317 +0200
@@ -220,6 +220,7 @@
 
/* Calc XIN. The PLL reference frequency is 18 MHz. */
xdiv = fvco / 18000;
+   WARN_ON(xdiv > 0xFF);
frac = fvco - xdiv * 18000;
frac = (frac << 15) / 18000;
if (frac >= 16384)
@@ -346,6 +347,8 @@
vco_cal &= FC11_VCOCAL_VALUEMASK;
 
switch (vco_sel) {
+   default:
+   WARN_ON(1);
case 0:
if (vco_cal < 8) {
regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | 
FC11_VCOSEL_2);
@@ -427,7 +430,8 @@
err = fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]);
if (err)
return err;
-   err = fc0011_writereg(priv, FC11_REG_16, 0xB);
+   regs[FC11_REG_16] = 0xB;
+   err = fc0011_writereg(priv, FC11_REG_16, regs[FC11_REG_16]);
if (err)
return err;
 


-- 
Greetings, Michael.

PGP: 908D8B0E


signature.asc
Description: PGP signature


Re: omap3isp - set_xclk dont work

2013-02-07 Thread Laurent Pinchart
Hi Adriano,

On Wednesday 06 February 2013 11:26:43 Adriano Martins wrote:
> Hi,
> 
> I have 2 boards with DM3730 processor, a beagleboard  and a custom board. 
> The omap3isp is working in both boards, any error is seen. On beagleboard I
> can see the xclka, then the sensor is detected and the driver is load
> correctly. But, in the custom board, every seem work, there are no errors
> too. But I can't see the xclka signal.
> 
> The hardware is ok. Because, I load another driver that uses the camera bus.
> The xclka is working.
> 
> it is the same processor, same kernel version, same driver. Why, it work in
> one, and not another.
> 
> Someone can help me? please.

The XCLK clocks currently require special handling in board code, with the 
sensor calling back to board code when it wants to turn the clock on/off, and 
board code calling the set_xclk isp operation. Does your board code perform 
that operation ?

-- 
Regards,

Laurent Pinchart

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


[PATCH v3] media: add support for decoder as one of media entity types

2013-02-07 Thread Prabhakar Lad
From: Manjunath Hadli 

A lot of SOCs including Texas Instruments Davinci family mainly use
video decoders as input devices. This patch adds a flag
'MEDIA_ENT_T_V4L2_SUBDEV_DECODER' media entity type for decoder's.
Along side updates the documentation for this media entity type.

Signed-off-by: Manjunath Hadli 
Signed-off-by: Lad, Prabhakar 
Cc: Rob Landley 
Cc: Mauro Carvalho Chehab 
Reviewed-by: Sylwester Nawrocki 
---
 Changes for v3:
 1: Fixed Nit pointed by Sylwester.

 Changes for v2:
 1: Sending as a separate patch.
 2: Added documentation for the added media entity type.
 3: Improved the commit message.
 
 .../DocBook/media/v4l/media-ioc-enum-entities.xml  |   10 ++
 include/uapi/linux/media.h |2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml 
b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
index 576b68b..116c301 100644
--- a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
+++ b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
@@ -272,6 +272,16 @@
MEDIA_ENT_T_V4L2_SUBDEV_LENS
Lens controller
  
+ 
+   MEDIA_ENT_T_V4L2_SUBDEV_DECODER
+   Video decoder, the basic function of the video decoder is to
+   accept analogue video from a wide variety of sources such as
+   broadcast, DVD players, cameras and video cassette recorders, in
+   either NTSC, PAL or HD format and still occasionally SECAM, separate
+   it into its component parts, luminance and chrominance, and output
+   it in some digital video standard, with appropriate embedded timing
+   signals.
+ 

   
 
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 0ef8833..ed49574 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -56,6 +56,8 @@ struct media_device_info {
 #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)
 #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH  (MEDIA_ENT_T_V4L2_SUBDEV + 2)
 #define MEDIA_ENT_T_V4L2_SUBDEV_LENS   (MEDIA_ENT_T_V4L2_SUBDEV + 3)
+/* A converter of analogue video to its digital representation. */
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER(MEDIA_ENT_T_V4L2_SUBDEV + 4)
 
 #define MEDIA_ENT_FL_DEFAULT   (1 << 0)
 
-- 
1.7.0.4

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


[PATCH 3/3] reservation: Add tests to lib/locking-selftest.c.

2013-02-07 Thread Maarten Lankhorst
This stresses the lockdep code in some ways specifically useful to
reservations. It adds checks for most of the common locking errors.

Since the lockdep tests were originally written to stress the
reservation code, I duplicated some of the definitions into
lib/locking-selftest.c for now.

This will be cleaned up later when the api for reservations is
accepted. I don't expect the tests to change, since the discussion
is mostly about the fence aspect of reservations.

Signed-off-by: Maarten Lankhorst 
---
 lib/locking-selftest.c |  522 ++--
 1 file changed, 503 insertions(+), 19 deletions(-)

diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 7aae0f2..a3959af 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -26,6 +26,67 @@
  */
 static unsigned int debug_locks_verbose;
 
+/*
+ * These definitions are from the reservation objects patch series.
+ * For now we have to define it ourselves here. These definitions will
+ * be removed upon acceptance of that patch series.
+ */
+static const char reservation_object_name[] = "reservation_object";
+static struct lock_class_key reservation_object_class;
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+static const char reservation_ticket_name[] = "reservation_ticket";
+static struct lock_class_key reservation_ticket_class;
+#endif
+
+struct reservation_object {
+   struct ticket_mutex lock;
+};
+
+struct reservation_ticket {
+   unsigned long seqno;
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+   struct lockdep_map dep_map;
+#endif
+};
+
+static inline void
+reservation_object_init(struct reservation_object *obj)
+{
+   __ticket_mutex_init(&obj->lock, reservation_object_name,
+   &reservation_object_class);
+}
+
+static inline void
+reservation_object_fini(struct reservation_object *obj)
+{
+   mutex_destroy(&obj->lock.base);
+}
+
+static inline void
+reservation_ticket_init(struct reservation_ticket *t)
+{
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+   /*
+* Make sure we are not reinitializing a held ticket:
+*/
+
+   debug_check_no_locks_freed((void *)t, sizeof(*t));
+   lockdep_init_map(&t->dep_map, reservation_ticket_name,
+&reservation_ticket_class, 0);
+#endif
+   mutex_acquire(&t->dep_map, 0, 0, _THIS_IP_);
+   t->seqno = 5;
+}
+
+static inline void
+reservation_ticket_fini(struct reservation_ticket *t)
+{
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+   mutex_release(&t->dep_map, 0, _THIS_IP_);
+   t->seqno = 0;
+#endif
+}
+
 static int __init setup_debug_locks_verbose(char *str)
 {
get_option(&str, &debug_locks_verbose);
@@ -42,6 +103,7 @@ __setup("debug_locks_verbose=", setup_debug_locks_verbose);
 #define LOCKTYPE_RWLOCK0x2
 #define LOCKTYPE_MUTEX 0x4
 #define LOCKTYPE_RWSEM 0x8
+#define LOCKTYPE_RESERVATION   0x10
 
 /*
  * Normal standalone locks, for the circular and irq-context
@@ -920,11 +982,17 @@ GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion_soft)
 static void reset_locks(void)
 {
local_irq_disable();
+   lockdep_free_key_range(&reservation_object_class, 1);
+   lockdep_free_key_range(&reservation_ticket_class, 1);
+
I1(A); I1(B); I1(C); I1(D);
I1(X1); I1(X2); I1(Y1); I1(Y2); I1(Z1); I1(Z2);
lockdep_reset();
I2(A); I2(B); I2(C); I2(D);
init_shared_classes();
+
+   memset(&reservation_object_class, 0, sizeof(reservation_object_class));
+   memset(&reservation_ticket_class, 0, sizeof(reservation_ticket_class));
local_irq_enable();
 }
 
@@ -938,7 +1006,6 @@ static int unexpected_testcase_failures;
 static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
 {
unsigned long saved_preempt_count = preempt_count();
-   int expected_failure = 0;
 
WARN_ON(irqs_disabled());
 
@@ -946,26 +1013,16 @@ static void dotest(void (*testcase_fn)(void), int 
expected, int lockclass_mask)
/*
 * Filter out expected failures:
 */
+   if (debug_locks != expected) {
 #ifndef CONFIG_PROVE_LOCKING
-   if ((lockclass_mask & LOCKTYPE_SPIN) && debug_locks != expected)
-   expected_failure = 1;
-   if ((lockclass_mask & LOCKTYPE_RWLOCK) && debug_locks != expected)
-   expected_failure = 1;
-   if ((lockclass_mask & LOCKTYPE_MUTEX) && debug_locks != expected)
-   expected_failure = 1;
-   if ((lockclass_mask & LOCKTYPE_RWSEM) && debug_locks != expected)
-   expected_failure = 1;
+   expected_testcase_failures++;
+   printk("failed|");
+#else
+   unexpected_testcase_failures++;
+   printk("FAILED|");
+
+   dump_stack();
 #endif
-   if (debug_locks != expected) {
-   if (expected_failure) {
-   expected_testcase_failures++;
-   printk("failed|");
-   } else {
-   unexpected_testca

[PATCH 1/3] arch: make __mutex_fastpath_lock_retval return whether fastpath succeeded or not.

2013-02-07 Thread Maarten Lankhorst
This will allow me to call functions that have multiple arguments if fastpath 
fails.
This is required to support ticket mutexes, because they need to be able to 
pass an
extra argument to the fail function.

Originally I duplicated the functions, by adding 
__mutex_fastpath_lock_retval_arg.
This ended up being just a duplication of the existing function, so a way to 
test
if fastpath was called ended up being better.

This also cleaned up the reservation mutex patch some by being able to call an
atomic_set instead of atomic_xchg, and making it easier to detect if the wrong
unlock function was previously used.

Signed-off-by: Maarten Lankhorst 
---
 arch/ia64/include/asm/mutex.h|   10 --
 arch/powerpc/include/asm/mutex.h |   10 --
 arch/sh/include/asm/mutex-llsc.h |4 ++--
 arch/x86/include/asm/mutex_32.h  |   11 ---
 arch/x86/include/asm/mutex_64.h  |   11 ---
 include/asm-generic/mutex-dec.h  |   10 --
 include/asm-generic/mutex-null.h |2 +-
 include/asm-generic/mutex-xchg.h |   10 --
 kernel/mutex.c   |   32 ++--
 9 files changed, 41 insertions(+), 59 deletions(-)

diff --git a/arch/ia64/include/asm/mutex.h b/arch/ia64/include/asm/mutex.h
index bed73a6..f41e66d 100644
--- a/arch/ia64/include/asm/mutex.h
+++ b/arch/ia64/include/asm/mutex.h
@@ -29,17 +29,15 @@ __mutex_fastpath_lock(atomic_t *count, void 
(*fail_fn)(atomic_t *))
  *  __mutex_fastpath_lock_retval - try to take the lock by moving the count
  * from 1 to a 0 value
  *  @count: pointer of type atomic_t
- *  @fail_fn: function to call if the original value was not 1
  *
- * Change the count from 1 to a value lower than 1, and call  if
- * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
- * or anything the slow path function returns.
+ * Change the count from 1 to a value lower than 1. This function returns 0
+ * if the fastpath succeeds, or -1 otherwise.
  */
 static inline int
-__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
+__mutex_fastpath_lock_retval(atomic_t *count)
 {
if (unlikely(ia64_fetchadd4_acq(count, -1) != 1))
-   return fail_fn(count);
+   return -1;
return 0;
 }
 
diff --git a/arch/powerpc/include/asm/mutex.h b/arch/powerpc/include/asm/mutex.h
index 5399f7e..127ab23 100644
--- a/arch/powerpc/include/asm/mutex.h
+++ b/arch/powerpc/include/asm/mutex.h
@@ -82,17 +82,15 @@ __mutex_fastpath_lock(atomic_t *count, void 
(*fail_fn)(atomic_t *))
  *  __mutex_fastpath_lock_retval - try to take the lock by moving the count
  * from 1 to a 0 value
  *  @count: pointer of type atomic_t
- *  @fail_fn: function to call if the original value was not 1
  *
- * Change the count from 1 to a value lower than 1, and call  if
- * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
- * or anything the slow path function returns.
+ * Change the count from 1 to a value lower than 1. This function returns 0
+ * if the fastpath succeeds, or -1 otherwise.
  */
 static inline int
-__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
+__mutex_fastpath_lock_retval(atomic_t *count)
 {
if (unlikely(__mutex_dec_return_lock(count) < 0))
-   return fail_fn(count);
+   return -1;
return 0;
 }
 
diff --git a/arch/sh/include/asm/mutex-llsc.h b/arch/sh/include/asm/mutex-llsc.h
index 090358a..dad29b6 100644
--- a/arch/sh/include/asm/mutex-llsc.h
+++ b/arch/sh/include/asm/mutex-llsc.h
@@ -37,7 +37,7 @@ __mutex_fastpath_lock(atomic_t *count, void 
(*fail_fn)(atomic_t *))
 }
 
 static inline int
-__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
+__mutex_fastpath_lock_retval(atomic_t *count)
 {
int __done, __res;
 
@@ -51,7 +51,7 @@ __mutex_fastpath_lock_retval(atomic_t *count, int 
(*fail_fn)(atomic_t *))
: "t");
 
if (unlikely(!__done || __res != 0))
-   __res = fail_fn(count);
+   __res = -1;
 
return __res;
 }
diff --git a/arch/x86/include/asm/mutex_32.h b/arch/x86/include/asm/mutex_32.h
index 03f90c8..b7f6b34 100644
--- a/arch/x86/include/asm/mutex_32.h
+++ b/arch/x86/include/asm/mutex_32.h
@@ -42,17 +42,14 @@ do {
\
  *  __mutex_fastpath_lock_retval - try to take the lock by moving the count
  * from 1 to a 0 value
  *  @count: pointer of type atomic_t
- *  @fail_fn: function to call if the original value was not 1
  *
- * Change the count from 1 to a value lower than 1, and call  if it
- * wasn't 1 originally. This function returns 0 if the fastpath succeeds,
- * or anything the slow path function returns
+ * Change the count from 1 to a value lower than 1. This function returns 0
+ * if the fastpath succeeds, or 1 otherwise.
  */
-static inline int

[PATCH 2/3] mutex: add support for reservation style locks

2013-02-07 Thread Maarten Lankhorst
GPU's do operations that commonly involve many buffers.  Those buffers
can be shared across contexts/processes, exist in different memory
domains (for example VRAM vs system memory), and so on.  And with
PRIME / dmabuf, they can even be shared across devices.  So there are
a handful of situations where the driver needs to wait for buffers to
become ready.  If you think about this in terms of waiting on a buffer
mutex for it to become available, this presents a problem because
there is no way to guarantee that buffers appear in a execbuf/batch in
the same order in all contexts.  That is directly under control of
userspace, and a result of the sequence of GL calls that an application
makes.  Which results in the potential for deadlock.  The problem gets
more complex when you consider that the kernel may need to migrate the
buffer(s) into VRAM before the GPU operates on the buffer(s), which
may in turn require evicting some other buffers (and you don't want to
evict other buffers which are already queued up to the GPU), but for a
simplified understanding of the problem you can ignore this.

The algorithm that TTM came up with for dealing with this problem is
quite simple.  For each group of buffers (execbuf) that need to be
locked, the caller would be assigned a unique reservation_id, from a
global counter.  In case of deadlock in the process of locking all the
buffers associated with a execbuf, the one with the lowest
reservation_id wins, and the one with the higher reservation_id
unlocks all of the buffers that it has already locked, and then tries
again.

How it is used:
---

A very simplified version:

int lock_execbuf(execbuf)
{
struct buf *res_buf = NULL;

/* acquiring locks, before queuing up to GPU: */
seqno = assign_global_seqno();

retry:
for (buf in execbuf->buffers) {
if (buf == res_buf) {
res_buf = NULL;
continue;
}
ret = mutex_reserve_lock(&buf->lock, seqno);
if (ret < 0)
goto err;
}

/* now everything is good to go, submit job to GPU: */
...

return 0;

err:
for (all buf2 before buf in execbuf->buffers)
mutex_unreserve_unlock(&buf2->lock);
if (res_buf)
mutex_unreserve_unlock(&res_buf->lock);

if (ret == -EAGAIN) {
/* we lost out in a seqno race, lock and retry.. */
mutex_reserve_lock_slow(&buf->lock, seqno);
res_buf = buf;
goto retry;
}

return ret;
}

int unlock_execbuf(execbuf)
{
/* when GPU is finished; */
for (buf in execbuf->buffers)
mutex_unreserve_unlock(&buf->lock);
}

Functions:
--

mutex_reserve_lock, and mutex_reserve_lock_interruptible:
  Lock a buffer with a reservation_id set. reservation_id must not be
  set to 0, since this is a special value that means no reservation_id.

  Normally if reservation_id is not set, or is older than the
  reservation_id that's currently set on the mutex, the behavior will
  be to wait normally.  However, if  the reservation_id is newer than
  the current reservation_id, -EAGAIN will be returned.

  These functions will return -EDEADLK instead of -EAGAIN if
  reservation_id is the same as the reservation_id that's attempted to
  lock the mutex with, since in that case you presumably attempted to
  lock the same lock twice.

mutex_reserve_lock_slow and mutex_reserve_lock_intr_slow:
  Similar to mutex_reserve_lock, except it won't backoff with -EAGAIN.
  This is useful when mutex_reserve_lock failed with -EAGAIN, and you
  unreserved all buffers so no deadlock can occur.

mutex_unreserve_unlock:
   Unlock a buffer reserved with one of the mutex_reserve_*lock* calls.

Missing at the moment, maybe TODO?
  * Check if lockdep warns if you unlock a lock that other locks were nested
to.
- spin_lock(m);
  spin_lock_nest_lock(a, m);
  spin_unlock(m);
  spin_unlock(a);
  It would be nice if this would give a splat on spin_unlock(m),
  I'm not 100% sure if it does right now, though..
  * In the *_slow calls, maybe add a check to ensure no other locks of the same
lockdep class are nested in the lock we have to nest to?
- This is making sure that mutex_unreserve_unlock have been called on all 
other locks.

Design:
  I chose for ticket_mutex to encapsulate struct mutex, so the extra memory 
usage and
  atomic set on init will only happen when you deliberately create a ticket 
lock.

  Since the mutexes are mostly meant to protect buffer object serialization in 
ttm, not
  much contention is expected. I could be slightly smarter with wakeups, but 
this would
  be at the expense at adding a field to struct mutex_waiter. This would add
  overhead to all cases where normal mutexes are used, and ticket_mutexes are 
less
  performance sensitive anyway since they only protect buffer object

Re: [RFCv1 PATCH 00/20] cx231xx: v4l2-compliance fixes

2013-02-07 Thread Devin Heitmueller
Hi Hans,

On Thu, Feb 7, 2013 at 10:08 AM, Hans Verkuil  wrote:
> On Tue January 29 2013 17:41:29 Devin Heitmueller wrote:
>> On Tue, Jan 29, 2013 at 11:32 AM, Hans Verkuil  wrote:
>> > I will take a closer look at the vbi support, though.. It would be nice to 
>> > get
>> > that working.
>>
>> FYI:  I had the VBI support working when I submitted the driver
>> upstream (at least for NTSC CC).  If it doesn't work, then somebody
>> broke it.
>
> OK, I did some more tests and it turned out to be related to the no_alt_vanc
> setting in the board definitions. If it is 1, then usb_set_interface() is
> never called and the endpoint is never created.
>
> It's unclear to me if this means that if no_alt_vanc is set, then the vbi node
> should be disabled. It seems that way.
>
> Unfortunately, of the three cx231xx devices I have no_alt_vanc is set on two
> and the third (Hauppauge EXETER) is the one where the tda18271 tuner has
> issues: it always gets errors when writing to it. It used to load correctly
> about 10% of the time in the past, but now I can't get it to work at all.
>
> Devin, I think you said once that you knew what is going on. Do you have
> any code that I can try to make it work again?

The following will cause the tuner to initialize properly.
Unfortunately it's only half a fix because it results in the digital
demod driving the AGC, which will conflict the AGC being driven by the
Polaris when in analog mode.

Still, it should be enough to allow you to play with the VBI support
assuming you test with the baseband inputs.

Devin

--- cx231xx-avcore.c.orig   2013-01-17 11:47:40.0 -0500
+++ cx231xx-avcore.c2013-01-24 09:02:25.833076332 -0500
@@ -2207,6 +2207,7 @@
u8 value[4] = { 0, 0, 0, 0 };
u32 tmp = 0;
int status = 0;
+   int demod_reset_high = 0;

if (dev->power_mode != mode)
dev->power_mode = mode;
@@ -2406,9 +2407,25 @@

msleep(PWR_SLEEP_INTERVAL);

+   /* For Hauppauge devices based on the ldgt3305, the 3305 will hold SDA
+  low from powerup until 10ms after the device is brought out of reset.
+  As a result, we need to *always* bring the device out of reset if
+  PWR_TUNER_EN is enabled (since we have a shared power plane for both
+  the tuner and demod).  If you fail to bring the chip out of reset
+  *and* wait 10ms, the i2c bus will get jammed.  This is a vendor
+  documented limitation of the lgdt3305 demodulator */
+   if ((tmp & PWR_TUNER_EN) &&
+   (dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER)) {
+   demod_reset_high = 1;
+   }
+
/* For power saving, only enable Pwr_resetout_n
   when digital TV is selected. */
if (mode == POLARIS_AVMODE_DIGITAL) {
+   demod_reset_high = 1;
+   }
+
+   if (demod_reset_high) {
tmp |= PWR_RESETOUT_EN;
value[0] = (u8) tmp;
value[1] = (u8) (tmp >> 8);




-- 
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: [RFCv1 PATCH 00/20] cx231xx: v4l2-compliance fixes

2013-02-07 Thread Hans Verkuil
On Tue January 29 2013 17:41:29 Devin Heitmueller wrote:
> On Tue, Jan 29, 2013 at 11:32 AM, Hans Verkuil  wrote:
> > I will take a closer look at the vbi support, though.. It would be nice to 
> > get
> > that working.
> 
> FYI:  I had the VBI support working when I submitted the driver
> upstream (at least for NTSC CC).  If it doesn't work, then somebody
> broke it.

OK, I did some more tests and it turned out to be related to the no_alt_vanc
setting in the board definitions. If it is 1, then usb_set_interface() is
never called and the endpoint is never created.

It's unclear to me if this means that if no_alt_vanc is set, then the vbi node
should be disabled. It seems that way.

Unfortunately, of the three cx231xx devices I have no_alt_vanc is set on two
and the third (Hauppauge EXETER) is the one where the tda18271 tuner has
issues: it always gets errors when writing to it. It used to load correctly
about 10% of the time in the past, but now I can't get it to work at all.

Devin, I think you said once that you knew what is going on. Do you have
any code that I can try to make it work again?

I did manage to stream vbi, but with a non-functioning tuner I can't check
if it really works or not.

Regards,

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


Re: [RFC PATCH v2 2/5] drm/edid: temporarily exposing generic edid-read interface from drm

2013-02-07 Thread Daniel Vetter
On Thu, Feb 7, 2013 at 1:09 PM, Rahul Sharma  wrote:
> It exposes generic interface from drm_edid.c to get the edid data and length
> by any display entity. Once I get clear idea about edid handling in CDF, I 
> need
> to revert these temporary changes.

Just a quick reply about edid reading: One of the key results (at
least imo) of the fosdem cdf discussion was that we need to split up
the different parts of it clearly (i.e. abstract panel interface, dsi
support, discovery/dev matching, ...) to have more flexibility. One
idea is also to not use the panel interface for e.g. hdmi transcoders,
but only use the bus support (like dsi), since transcoders which
connect to external devices like hdmi need to expose _much_ more
features to the master driver and so it's better to have tighter
integration. Some of the things which need close cooperation between
drivers are e.g. edid reading, hotplug handling,
bpp/colorspace/restricted range stuff, ... I didn't read through the
patch which requires the exported drm edid stuff, but maybe this helps
a bit.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe 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: af9035 test needed!

2013-02-07 Thread Andre Heider
Hi,

On Thu, Jan 31, 2013 at 2:46 PM, Michael Krufky  wrote:
> Hey guys... somehow this email slipped through my filters :-(  I see
> it now, and I'll give a look over the patch this weekend.

I suspect the merge window opens soon, so... *poke* ;)
Any chance for 3.9?

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


[RFC PATCHv2 18/18] tlg2300: update MAINTAINERS file.

2013-02-07 Thread Hans Verkuil
Remove two maintainers: telegent.com no longer exists, so those email
addresses are invalid as well.

Added myself as co-maintainer and change the status to 'Odd Fixes'.

Changes since v1: Added myself as co-maintainer and change the status to
'Odd Fixes'.

Huang: can you Ack this? Once patches 01/18 and 18/18 are Acked I will post
a pull request for this whole series (patches 02-17 are unchanged so I'm
not reposting them).

Regards,

Hans

Signed-off-by: Hans Verkuil 
---
 MAINTAINERS |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5334229..9a83a1c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6794,9 +6794,8 @@ F:drivers/clocksource
 
 TLG2300 VIDEO4LINUX-2 DRIVER
 M: Huang Shijie 
-M: Kang Yong 
-M: Zhang Xiaobing 
-S: Supported
+M: Hans Verkuil 
+S: Odd Fixes
 F: drivers/media/usb/tlg2300
 
 SC1200 WDT DRIVER
-- 
1.7.10.4

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


Re: [PATCH v2] media: add support for decoder as one of media entity types

2013-02-07 Thread Prabhakar Lad
Hi Sylwester,

On Thu, Feb 7, 2013 at 5:18 PM, Sylwester Nawrocki
 wrote:
> Hi Prabhakar,
>
> On 01/28/2013 12:50 PM, Prabhakar Lad wrote:
>> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
>> index 0ef8833..dac06d7 100644
>> --- a/include/uapi/linux/media.h
>> +++ b/include/uapi/linux/media.h
>> @@ -56,6 +56,8 @@ struct media_device_info {
>>  #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR   (MEDIA_ENT_T_V4L2_SUBDEV + 1)
>>  #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH(MEDIA_ENT_T_V4L2_SUBDEV + 2)
>>  #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3)
>> +/* DECODER: Converts analogue video to digital */
>
> The patch looks good to me, I would just change this comment to
> something like:
>
> /* A converter of analogue video to its digital representation. */
>
> But that's really a nitpicking.
>
OK will fix it and post a v3.

Regards,
--Prabhakar

>> +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER  (MEDIA_ENT_T_V4L2_SUBDEV + 4)
>>
>>  #define MEDIA_ENT_FL_DEFAULT (1 << 0)
>
> Reviewed-by: Sylwester Nawrocki 
>
> --
>
> Thanks,
> Sylwester
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCHv2 01/18] tlg2300: use correct device parent.

2013-02-07 Thread Hans Verkuil
Set the correct parent for v4l2_device_register and don't set the name
anymore (that's now deduced from the parent). Also remove an unnecessary
forward reference and fix two weird looking log messages.

Changes since v1: don't set v4l2_dev.name anymore as per Huang's suggestion.
Huang: can you Ack this?

Regards,

Hans

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/tlg2300/pd-main.c |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-main.c 
b/drivers/media/usb/tlg2300/pd-main.c
index 7b1f6eb..247d6ac 100644
--- a/drivers/media/usb/tlg2300/pd-main.c
+++ b/drivers/media/usb/tlg2300/pd-main.c
@@ -55,7 +55,6 @@ MODULE_PARM_DESC(debug_mode, "0 = disable, 1 = enable, 2 = 
verbose");
 
 #define TLG2300_FIRMWARE "tlg2300_firmware.bin"
 static const char *firmware_name = TLG2300_FIRMWARE;
-static struct usb_driver poseidon_driver;
 static LIST_HEAD(pd_device_list);
 
 /*
@@ -316,7 +315,7 @@ static int poseidon_suspend(struct usb_interface *intf, 
pm_message_t msg)
if (get_pm_count(pd) <= 0 && !in_hibernation(pd)) {
pd->msg.event = PM_EVENT_AUTO_SUSPEND;
pd->pm_resume = NULL; /*  a good guard */
-   printk(KERN_DEBUG "\n\t+ TLG2300 auto suspend +\n\n");
+   printk(KERN_DEBUG "TLG2300 auto suspend\n");
}
return 0;
}
@@ -331,7 +330,7 @@ static int poseidon_resume(struct usb_interface *intf)
 
if (!pd)
return 0;
-   printk(KERN_DEBUG "\n\t ++ TLG2300 resume ++\n\n");
+   printk(KERN_DEBUG "TLG2300 resume\n");
 
if (!is_working(pd)) {
if (PM_EVENT_AUTO_SUSPEND == pd->msg.event)
@@ -431,15 +430,11 @@ static int poseidon_probe(struct usb_interface *interface,
usb_set_intfdata(interface, pd);
 
if (new_one) {
-   struct device *dev = &interface->dev;
-
logpm(pd);
mutex_init(&pd->lock);
 
/* register v4l2 device */
-   snprintf(pd->v4l2_dev.name, sizeof(pd->v4l2_dev.name), "%s %s",
-   dev->driver->name, dev_name(dev));
-   ret = v4l2_device_register(NULL, &pd->v4l2_dev);
+   ret = v4l2_device_register(&interface->dev, &pd->v4l2_dev);
 
/* register devices in directory /dev */
ret = pd_video_init(pd);
@@ -530,7 +525,7 @@ module_init(poseidon_init);
 module_exit(poseidon_exit);
 
 MODULE_AUTHOR("Telegent Systems");
-MODULE_DESCRIPTION("For tlg2300-based USB device ");
+MODULE_DESCRIPTION("For tlg2300-based USB device");
 MODULE_LICENSE("GPL");
 MODULE_VERSION("0.0.2");
 MODULE_FIRMWARE(TLG2300_FIRMWARE);
-- 
1.7.10.4

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


Re: [GIT PULL FOR v3.9] Move cx2341x from media/i2c to media/common

2013-02-07 Thread Sakari Ailus
Hi Laurent,

On Wed, Feb 06, 2013 at 10:41:16AM +0100, Laurent Pinchart wrote:
> On Wednesday 06 February 2013 07:16:04 Mauro Carvalho Chehab wrote:
> > Em Wed, 6 Feb 2013 08:46:35 +0100 Hans Verkuil escreveu:
> > > At least aptina-pll.c, smiapp-pll.c and tveeprom.c all have some
> > > relationship with i2c.
> > 
> > True, but none of the three are actually i2c drivers; they're just shared
> > functions used by drivers helper code.
> > 
> > Hmm...
> > 
> > $ git grep aptina-pll.h drivers/media/
> > drivers/media/i2c/aptina-pll.c:#include "aptina-pll.h"
> > drivers/media/i2c/mt9m032.c:#include "aptina-pll.h"
> > drivers/media/i2c/mt9p031.c:#include "aptina-pll.h"
> > 
> > $ git grep smiapp-pll.h drivers/media/
> > drivers/media/i2c/smiapp-pll.c:#include "smiapp-pll.h"
> > drivers/media/i2c/smiapp-pll.h: * drivers/media/i2c/smiapp-pll.h
> > drivers/media/i2c/smiapp/smiapp.h:#include "smiapp-pll.h"
> > 
> > $ git grep smiapp.h drivers/media/
> > drivers/media/i2c/smiapp/smiapp-core.c:#include "smiapp.h"
> > drivers/media/i2c/smiapp/smiapp-limits.c:#include "smiapp.h"
> > drivers/media/i2c/smiapp/smiapp-quirk.c:#include "smiapp.h"
> > drivers/media/i2c/smiapp/smiapp-regs.c:#include "smiapp.h"
> > drivers/media/i2c/smiapp/smiapp.h: * drivers/media/i2c/smiapp/smiapp.h
> > drivers/media/i2c/smiapp/smiapp.h:#include 
> > 
> > It could make sense to keep those two on I2c,
> 
> I'd like that :-) Those helper functions will likely never be used by non-I2C 
> drivers. If they are we can reconsider moving them to common/, but for now it 
> makes sense to keep them in i2c/ in my opinion.

Ack to that. I2c is the bus for the time being but the CSI-3 is
bi-directional:

http://www.design-reuse.com/sip/30046/mipi-csi-3-camera-serial-interface-receiver/>

The sensors using that bus may well have entirely different PLLs though.

-- 
Kind regards,

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


[REVIEW PATCH V4 00/12] [media] marvell-ccic: add soc camera support in marvell-ccic driver

2013-02-07 Thread Albert Wang
The following patches series will add soc_camera support in marvell-ccic driver

Patch set V4 - Change log:
- remove the first patch of V3 which had been queued in tree
- merge [PATCH 09/15-12/15] of V3 to [PATCH 10/12] of V4
- use soc_camera mode replace the old mode for maintain in the future
- correct some errors of implementation in mcam_ctlr_image()
- change get_mcam() function name to vq_to_mcam()
- use proper words replace some inaccurate wordings in description
- add [PATCH 08/12] to rename varablies for avoiding CamelCase warning
- adjust patch sequence and move [PATCH 14/15] of V3 to [PATCH 09/12] 
of V4
- change some functions implementation include spliting into 2 
functions and decreasing parameters

Patch set V3 - Change log:
- correct and enhance the implementation of some functions
- replace most of preprocessor instruction with runtime detect
- use devm_clk_get and devm_gpio_request which were missed in previous 
version
- change code format in some funcions: replace if-else with switch
- change some confused variable names
- remove unnecessary functions: buf_init, buf_cleanup ...
- remove unnecessary keyword: inline, extern ...
- remove unnecessary include header file name
- remove duplicated and unused code
- remove unnecessary initialization of ret variable
- [PATCH 09/15] change description

Patch set V2 - Change log:
- remove register definition patch
- split big patch to some small patches
- split mcam-core.c to mcam-core.c and mcam-core-standard.c
- add mcam-core-soc.c for soc camera support
- split 3 frame buffers support patch into 2 patches

Patch set V1 - Log:
- add mmp register definition
- add soc_camera support on mcam core and mmp driver
- add 3 frames buffers support in DMA_CONTIG mode

Thanks
Albert Wang

--
Albert Wang (7):
  [media] marvell-ccic: reset ccic phy when stop streaming for stability
  [media] marvell-ccic: switch to resource managed allocation and request
  [media] marvell-ccic: rename B_DMA* to avoid CamelCase warning
  [media] marvell-ccic: use unsigned int type replace int type
  [media] marvell-ccic: add soc_camera support for marvell-ccic driver
  [media] marvell-ccic: add dma burst support for marvell-ccic driver
  [media] marvell-ccic: add 3 frame buffers support in DMA_CONTIG mode

Libin Yang (5):
  [media] marvell-ccic: add MIPI support for marvell-ccic driver
  [media] marvell-ccic: add clock tree support for marvell-ccic driver
  [media] marvell-ccic: refine mcam_set_contig_buffer function
  [media] marvell-ccic: add new formats support for marvell-ccic driver
  [media] marvell-ccic: add SOF/EOF pair check for marvell-ccic driver

 drivers/media/platform/Makefile   |4 +-
 drivers/media/platform/marvell-ccic/Kconfig   |6 +-
 drivers/media/platform/marvell-ccic/cafe-driver.c |2 +-
 drivers/media/platform/marvell-ccic/mcam-core.c   | 1362 ++---
 drivers/media/platform/marvell-ccic/mcam-core.h   |  102 +-
 drivers/media/platform/marvell-ccic/mmp-driver.c  |  306 +++--
 include/media/mmp-camera.h|   16 +
 7 files changed, 941 insertions(+), 857 deletions(-)

-- 
1.7.9.5

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


[REVIEW PATCH V4 12/12] [media] marvell-ccic: add 3 frame buffers support in DMA_CONTIG mode

2013-02-07 Thread Albert Wang
This patch adds support of 3 frame buffers in DMA-contiguous mode.

In current DMA_CONTIG mode, only 2 frame buffers can be supported.
Actually, Marvell CCIC can support 2 or 3 frame buffers.

Currently 3 frame buffers mode will be used by default.
To use 2 frame buffers mode, can do:
  #define MAX_FRAME_BUFS 2
in mcam-core.h.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
Acked-by: Jonathan Corbet 
---
 drivers/media/platform/marvell-ccic/mcam-core.c |   59 +--
 drivers/media/platform/marvell-ccic/mcam-core.h |   13 +
 2 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index f206e3c..33fce6c 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -494,13 +494,32 @@ static void mcam_set_contig_buffer(struct mcam_camera 
*cam, unsigned int frame)
struct mcam_vb_buffer *buf;
struct v4l2_pix_format *fmt = &cam->pix_format;
 
-   /*
-* If there are no available buffers, go into single mode
-*/
if (list_empty(&cam->buffers)) {
-   buf = cam->vb_bufs[frame ^ 0x1];
-   set_bit(CF_SINGLE_BUFFER, &cam->flags);
-   cam->frame_state.singles++;
+   /*
+* If there are no available buffers
+* go into single buffer mode
+*
+* If CCIC use Two Buffers mode
+* will use another remaining frame buffer
+* frame 0 -> buf 1
+* frame 1 -> buf 0
+*
+* If CCIC use Three Buffers mode
+* will use the 2rd remaining frame buffer
+* frame 0 -> buf 2
+* frame 1 -> buf 0
+* frame 2 -> buf 1
+*/
+   buf = cam->vb_bufs[(frame + (MAX_FRAME_BUFS - 1))
+   % MAX_FRAME_BUFS];
+   if (cam->frame_state.usebufs == 0)
+   cam->frame_state.usebufs++;
+   else {
+   set_bit(CF_SINGLE_BUFFER, &cam->flags);
+   cam->frame_state.singles++;
+   if (cam->frame_state.usebufs < 2)
+   cam->frame_state.usebufs++;
+   }
} else {
/*
 * OK, we have a buffer we can use.
@@ -509,15 +528,15 @@ static void mcam_set_contig_buffer(struct mcam_camera 
*cam, unsigned int frame)
queue);
list_del_init(&buf->queue);
clear_bit(CF_SINGLE_BUFFER, &cam->flags);
+   if (cam->frame_state.usebufs != (3 - MAX_FRAME_BUFS))
+   cam->frame_state.usebufs--;
}
 
cam->vb_bufs[frame] = buf;
-   mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR, buf->yuv_p.y);
+   mcam_reg_write(cam, REG_Y0BAR + (frame << 2), buf->yuv_p.y);
if (mcam_fmt_is_planar(fmt->pixelformat)) {
-   mcam_reg_write(cam, frame == 0 ?
-   REG_U0BAR : REG_U1BAR, buf->yuv_p.u);
-   mcam_reg_write(cam, frame == 0 ?
-   REG_V0BAR : REG_V1BAR, buf->yuv_p.v);
+   mcam_reg_write(cam, REG_U0BAR + (frame << 2), buf->yuv_p.u);
+   mcam_reg_write(cam, REG_V0BAR + (frame << 2), buf->yuv_p.v);
}
 }
 
@@ -526,10 +545,14 @@ static void mcam_set_contig_buffer(struct mcam_camera 
*cam, unsigned int frame)
  */
 static void mcam_ctlr_dma_contig(struct mcam_camera *cam)
 {
-   mcam_reg_set_bit(cam, REG_CTRL1, C1_TWOBUFS);
-   cam->nbufs = 2;
-   mcam_set_contig_buffer(cam, 0);
-   mcam_set_contig_buffer(cam, 1);
+   unsigned int frame;
+
+   cam->nbufs = MAX_FRAME_BUFS;
+   for (frame = 0; frame < cam->nbufs; frame++)
+   mcam_set_contig_buffer(cam, frame);
+
+   if (cam->nbufs == 2)
+   mcam_reg_set_bit(cam, REG_CTRL1, C1_TWOBUFS);
 }
 
 /*
@@ -1068,6 +1091,12 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, 
unsigned int count)
for (frame = 0; frame < cam->nbufs; frame++)
clear_bit(CF_FRAME_SOF0 + frame, &cam->flags);
 
+   /*
+*  If CCIC use Two Buffers mode, init usebufs == 1
+*  If CCIC use Three Buffers mode, init usebufs == 0
+*/
+   cam->frame_state.usebufs = 3 - MAX_FRAME_BUFS;
+
return mcam_read_setup(cam);
 }
 
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h 
b/drivers/media/platform/marvell-ccic/mcam-core.h
index 0accdbb..6fffa14 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -44,6 +44,15 @@ enum mcam_state {
 };
 #define MAX_DMA_BUFS 3
 
+#ifdef MCAM_MODE_DMA_CONTIG
+/*
+ * CCIC can support at most 3 

[REVIEW PATCH V4 10/12] [media] marvell-ccic: add soc_camera support for marvell-ccic driver

2013-02-07 Thread Albert Wang
This patch adds the soc_camera mode support in marvell-ccic driver.
It also removes the old mode for maintaining single mode in the future.

Signed-off-by: Libin Yang 
Signed-off-by: Albert Wang 
---
 drivers/media/platform/Makefile  |4 +-
 drivers/media/platform/marvell-ccic/Kconfig  |6 +-
 drivers/media/platform/marvell-ccic/mcam-core.c  | 1084 +++---
 drivers/media/platform/marvell-ccic/mcam-core.h  |   27 +-
 drivers/media/platform/marvell-ccic/mmp-driver.c |   73 +-
 include/media/mmp-camera.h   |5 +
 6 files changed, 402 insertions(+), 797 deletions(-)

diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 4817d28..1a345c8 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -11,8 +11,6 @@ obj-$(CONFIG_VIDEO_TIMBERDALE)+= timblogiw.o
 obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
 
 obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o
-obj-$(CONFIG_VIDEO_CAFE_CCIC) += marvell-ccic/
-obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/
 
 obj-$(CONFIG_VIDEO_OMAP2)  += omap2cam.o
 obj-$(CONFIG_VIDEO_OMAP3)  += omap3isp/
@@ -43,6 +41,8 @@ obj-$(CONFIG_ARCH_DAVINCI)+= davinci/
 obj-$(CONFIG_VIDEO_SH_VOU) += sh_vou.o
 
 obj-$(CONFIG_SOC_CAMERA)   += soc_camera/
+obj-$(CONFIG_VIDEO_CAFE_CCIC)  += marvell-ccic/
+obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/
 
 obj-y  += davinci/
 
diff --git a/drivers/media/platform/marvell-ccic/Kconfig 
b/drivers/media/platform/marvell-ccic/Kconfig
index bf739e3..7fa3c62 100755
--- a/drivers/media/platform/marvell-ccic/Kconfig
+++ b/drivers/media/platform/marvell-ccic/Kconfig
@@ -10,14 +10,14 @@ config VIDEO_CAFE_CCIC
  generation OLPC systems.
 
 config VIDEO_MMP_CAMERA
-   tristate "Marvell Armada 610 integrated camera controller support"
+   tristate "Marvell Armada integrated camera controller support"
depends on ARCH_MMP && I2C && VIDEO_V4L2
-   select VIDEO_OV7670
select I2C_GPIO
+   select VIDEOBUF2_DMA_CONTIG
select VIDEOBUF2_DMA_SG
---help---
  This is a Video4Linux2 driver for the integrated camera
- controller found on Marvell Armada 610 application
+ controller found on Marvell Armada application
  processors (and likely beyond).  This is the controller found
  in OLPC XO 1.75 systems.
 
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index b668f2b..16ba045 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -24,10 +24,11 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "mcam-core.h"
 
@@ -99,84 +100,38 @@ MODULE_PARM_DESC(buffer_mode,
 #define CF_FRAME_SOF2   9
 
 #define sensor_call(cam, o, f, args...) \
-   v4l2_subdev_call(cam->sensor, o, f, ##args)
-
-static struct mcam_format_struct {
-   __u8 *desc;
-   __u32 pixelformat;
-   int bpp;   /* Bytes per pixel */
-   bool planar;
-   enum v4l2_mbus_pixelcode mbus_code;
-} mcam_formats[] = {
-   {
-   .desc   = "YUYV 4:2:2",
-   .pixelformat= V4L2_PIX_FMT_YUYV,
-   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
-   .bpp= 2,
-   .planar = false,
-   },
-   {
-   .desc   = "UYVY 4:2:2",
-   .pixelformat= V4L2_PIX_FMT_UYVY,
-   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
-   .bpp= 2,
-   .planar = false,
-   },
-   {
-   .desc   = "YUV 4:2:2 PLANAR",
-   .pixelformat= V4L2_PIX_FMT_YUV422P,
-   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
-   .bpp= 2,
-   .planar = true,
-   },
-   {
-   .desc   = "YUV 4:2:0 PLANAR",
-   .pixelformat= V4L2_PIX_FMT_YUV420,
-   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
-   .bpp= 2,
-   .planar = true,
-   },
+   v4l2_subdev_call(soc_camera_to_subdev(cam->icd), o, f, ##args)
+
+static const struct soc_mbus_pixelfmt mcam_formats[] = {
{
-   .desc   = "YVU 4:2:0 PLANAR",
-   .pixelformat= V4L2_PIX_FMT_YVU420,
-   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
-   .bpp= 2,
-   .planar = true,
+   .fourcc = V4L2_PIX_FMT_UYVY,
+   .name = "YUV422PACKED",
+   .bits_per_sample = 8,
+   .packing = SOC_MBUS_PACKING_2X8_PADLO,
+   .order = SOC_MBUS_ORDER_LE,
},
{
-   .desc   = "RGB 444",
-   .pixelfor

[REVIEW PATCH V4 11/12] [media] marvell-ccic: add dma burst support for marvell-ccic driver

2013-02-07 Thread Albert Wang
This patch adds the dma burst size config support for marvell-ccic.
Developer can set the dma burst size in specified board driver.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
Acked-by: Jonathan Corbet 
---
 drivers/media/platform/marvell-ccic/mcam-core.c  |3 ++-
 drivers/media/platform/marvell-ccic/mcam-core.h  |8 
 drivers/media/platform/marvell-ccic/mmp-driver.c |   11 +++
 include/media/mmp-camera.h   |1 +
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 16ba045..f206e3c 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1218,7 +1218,8 @@ static int mcam_camera_add_device(struct 
soc_camera_device *icd)
mcam_ctlr_power_up(mcam);
mcam_ctlr_stop(mcam);
mcam_set_config_needed(mcam, 1);
-   mcam_reg_write(mcam, REG_CTRL1, C1_RESERVED | C1_DMAPOSTED);
+   mcam_reg_write(mcam, REG_CTRL1,
+   mcam->burst | C1_RESERVED | C1_DMAPOSTED);
mcam_reg_write(mcam, REG_CLKCTRL,
(mcam->mclk_src << 29) | mcam->mclk_div);
cam_dbg(mcam, "camera: set sensor mclk = %dMHz\n", mcam->mclk_min);
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h 
b/drivers/media/platform/marvell-ccic/mcam-core.h
index 12af7d2..0accdbb 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -108,6 +108,7 @@ struct mcam_camera {
short int use_smbus;/* SMBUS or straight I2c? */
enum mcam_buffer_mode buffer_mode;
 
+   u32 burst;
int mclk_min;
int mclk_src;
int mclk_div;
@@ -347,10 +348,9 @@ int mccic_resume(struct mcam_camera *cam);
 #define   C1_DESC_3WORD   0x0200   /* Three-word descriptors used */
 #define  C1_444ALPHA 0x00f0/* Alpha field in RGB444 */
 #define  C1_ALPHA_SHFT   20
-#define  C1_DMAB32   0x/* 32-byte DMA burst */
-#define  C1_DMAB16   0x0200/* 16-byte DMA burst */
-#define  C1_DMAB64   0x0400/* 64-byte DMA burst */
-#define  C1_DMAB_MASK0x0600
+#define  C1_DMAB64   0x/* 64-byte DMA burst */
+#define  C1_DMAB128  0x0200/* 128-byte DMA burst */
+#define  C1_DMAB256  0x0400/* 256-byte DMA burst */
 #define  C1_TWOBUFS  0x0800/* Use only two DMA buffers */
 #define  C1_PWRDWN   0x1000/* Power down */
 #define   C1_DMAPOSTED   0x4000/* DMA Posted Select */
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c 
b/drivers/media/platform/marvell-ccic/mmp-driver.c
index 3d5db24..3fd6a46 100755
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -360,6 +360,17 @@ static int mmpcam_probe(struct platform_device *pdev)
mcam->lane = pdata->lane;
/* set B_DMA_CONTIG as default */
mcam->buffer_mode = B_DMA_CONTIG;
+   switch (pdata->dma_burst) {
+   case 128:
+   mcam->burst = C1_DMAB128;
+   break;
+   case 256:
+   mcam->burst = C1_DMAB256;
+   break;
+   default:
+   mcam->burst = C1_DMAB64;
+   break;
+   }
INIT_LIST_HEAD(&mcam->buffers);
/*
 * Get our I/O memory.
diff --git a/include/media/mmp-camera.h b/include/media/mmp-camera.h
index 513d846..44234dd 100755
--- a/include/media/mmp-camera.h
+++ b/include/media/mmp-camera.h
@@ -13,6 +13,7 @@ struct mmp_camera_platform_data {
int mclk_src;
int mclk_div;
int chip_id;
+   u32 dma_burst;
/*
 * MIPI support
 */
-- 
1.7.9.5

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


[REVIEW PATCH V4 09/12] [media] marvell-ccic: use unsigned int type replace int type

2013-02-07 Thread Albert Wang
This patch uses unsigned int type replace int type in marvell-ccic.
These variables: frame number, buf number, irq... should be unsigned.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
Acked-by: Jonathan Corbet 
---
 drivers/media/platform/marvell-ccic/mcam-core.c  |   22 +++---
 drivers/media/platform/marvell-ccic/mcam-core.h  |2 +-
 drivers/media/platform/marvell-ccic/mmp-driver.c |2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 939c430..b668f2b 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -233,7 +233,7 @@ static inline struct mcam_vb_buffer *vb_to_mvb(struct 
vb2_buffer *vb)
 /*
  * Hand a completed buffer back to user space.
  */
-static void mcam_buffer_done(struct mcam_camera *cam, int frame,
+static void mcam_buffer_done(struct mcam_camera *cam, unsigned int frame,
struct vb2_buffer *vbuf)
 {
vbuf->v4l2_buf.bytesused = cam->pix_format.sizeimage;
@@ -260,7 +260,7 @@ static void mcam_buffer_done(struct mcam_camera *cam, int 
frame,
  */
 static void mcam_reset_buffers(struct mcam_camera *cam)
 {
-   int i;
+   unsigned int i;
 
cam->next_buf = -1;
for (i = 0; i < cam->nbufs; i++) {
@@ -344,7 +344,7 @@ static int mcam_config_mipi(struct mcam_camera *mcam, int 
enable)
  */
 static int mcam_alloc_dma_bufs(struct mcam_camera *cam, int loadtime)
 {
-   int i;
+   unsigned int i;
 
mcam_set_config_needed(cam, 1);
if (loadtime)
@@ -385,7 +385,7 @@ static int mcam_alloc_dma_bufs(struct mcam_camera *cam, int 
loadtime)
 
 static void mcam_free_dma_bufs(struct mcam_camera *cam)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i < cam->nbufs; i++) {
dma_free_coherent(cam->dev, cam->dma_buf_size,
@@ -424,7 +424,7 @@ static void mcam_ctlr_dma_vmalloc(struct mcam_camera *cam)
 static void mcam_frame_tasklet(unsigned long data)
 {
struct mcam_camera *cam = (struct mcam_camera *) data;
-   int i;
+   unsigned int i;
unsigned long flags;
struct mcam_vb_buffer *buf;
 
@@ -472,7 +472,7 @@ static int mcam_check_dma_buffers(struct mcam_camera *cam)
return 0;
 }
 
-static void mcam_vmalloc_done(struct mcam_camera *cam, int frame)
+static void mcam_vmalloc_done(struct mcam_camera *cam, unsigned int frame)
 {
tasklet_schedule(&cam->s_tasklet);
 }
@@ -521,7 +521,7 @@ static bool mcam_fmt_is_planar(__u32 pfmt)
  * space.  In this way, we always have a buffer to DMA to and don't
  * have to try to play games stopping and restarting the controller.
  */
-static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
+static void mcam_set_contig_buffer(struct mcam_camera *cam, unsigned int frame)
 {
struct mcam_vb_buffer *buf;
struct v4l2_pix_format *fmt = &cam->pix_format;
@@ -567,7 +567,7 @@ static void mcam_ctlr_dma_contig(struct mcam_camera *cam)
 /*
  * Frame completion handling.
  */
-static void mcam_dma_contig_done(struct mcam_camera *cam, int frame)
+static void mcam_dma_contig_done(struct mcam_camera *cam, unsigned int frame)
 {
struct mcam_vb_buffer *buf = cam->vb_bufs[frame];
 
@@ -643,7 +643,7 @@ static void mcam_ctlr_dma_sg(struct mcam_camera *cam)
  * safely change the DMA descriptor array here and restart things
  * (assuming there's another buffer waiting to go).
  */
-static void mcam_dma_sg_done(struct mcam_camera *cam, int frame)
+static void mcam_dma_sg_done(struct mcam_camera *cam, unsigned int frame)
 {
struct mcam_vb_buffer *buf = cam->vb_bufs[0];
 
@@ -1051,7 +1051,7 @@ static int mcam_vb_queue_setup(struct vb2_queue *vq,
void *alloc_ctxs[])
 {
struct mcam_camera *cam = vb2_get_drv_priv(vq);
-   int minbufs = (cam->buffer_mode == B_DMA_CONTIG) ? 3 : 2;
+   unsigned int minbufs = (cam->buffer_mode == B_DMA_CONTIG) ? 3 : 2;
 
sizes[0] = cam->pix_format.sizeimage;
*num_planes = 1; /* Someday we have to support planar formats... */
@@ -1855,7 +1855,7 @@ static struct video_device mcam_v4l_template = {
 /*
  * Interrupt handler stuff
  */
-static void mcam_frame_complete(struct mcam_camera *cam, int frame)
+static void mcam_frame_complete(struct mcam_camera *cam, unsigned int frame)
 {
/*
 * Basic frame housekeeping.
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h 
b/drivers/media/platform/marvell-ccic/mcam-core.h
index 263767e..4cb68e0 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -163,7 +163,7 @@ struct mcam_camera {
 
/* Mode-specific ops, set at open time */
void (*dma_setup)(struct mcam_camera *cam);
-   void (*frame_complete)(struct mcam_camera *cam, int frame);
+   void (*frame_complete)(struct mcam_camera *cam, uns

[REVIEW PATCH V4 07/12] [media] marvell-ccic: switch to resource managed allocation and request

2013-02-07 Thread Albert Wang
This patch switchs to resource managed allocation and request in mmp-driver.
It can remove free resource operations.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
Acked-by: Jonathan Corbet 
---
 drivers/media/platform/marvell-ccic/mmp-driver.c |   65 --
 1 file changed, 22 insertions(+), 43 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c 
b/drivers/media/platform/marvell-ccic/mmp-driver.c
index 818abf3..d355840 100755
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -342,7 +342,7 @@ static int mmpcam_probe(struct platform_device *pdev)
if (!pdata)
return -ENODEV;
 
-   cam = kzalloc(sizeof(*cam), GFP_KERNEL);
+   cam = devm_kzalloc(&pdev->dev, sizeof(*cam), GFP_KERNEL);
if (cam == NULL)
return -ENOMEM;
cam->pdev = pdev;
@@ -359,10 +359,9 @@ static int mmpcam_probe(struct platform_device *pdev)
mcam->bus_type = pdata->bus_type;
mcam->dphy = pdata->dphy;
/* mosetly it won't happen. dphy is an array in pdata, but in case .. */
-   if (unlikely(mcam->dphy == NULL)) {
-   ret = -EINVAL;
-   goto out_free;
-   }
+   if (unlikely(mcam->dphy == NULL))
+   return -EINVAL;
+
mcam->mipi_enabled = 0;
mcam->lane = pdata->lane;
mcam->chip_id = V4L2_IDENT_ARMADA610;
@@ -374,14 +373,12 @@ static int mmpcam_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
dev_err(&pdev->dev, "no iomem resource!\n");
-   ret = -ENODEV;
-   goto out_free;
+   return -ENODEV;
}
-   mcam->regs = ioremap(res->start, resource_size(res));
+   mcam->regs = devm_request_and_ioremap(&pdev->dev, res);
if (mcam->regs == NULL) {
dev_err(&pdev->dev, "MMIO ioremap fail\n");
-   ret = -ENODEV;
-   goto out_free;
+   return -ENODEV;
}
/*
 * Power/clock memory is elsewhere; get it too.  Perhaps this
@@ -390,44 +387,43 @@ static int mmpcam_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res == NULL) {
dev_err(&pdev->dev, "no power resource!\n");
-   ret = -ENODEV;
-   goto out_unmap1;
+   return -ENODEV;
}
-   cam->power_regs = ioremap(res->start, resource_size(res));
+   cam->power_regs = devm_request_and_ioremap(&pdev->dev, res);
if (cam->power_regs == NULL) {
dev_err(&pdev->dev, "power MMIO ioremap fail\n");
-   ret = -ENODEV;
-   goto out_unmap1;
+   return -ENODEV;
}
 
ret = mcam_init_clk(mcam, pdata);
if (ret)
-   goto out_unmap2;
+   return ret;
/*
 * Find the i2c adapter.  This assumes, of course, that the
 * i2c bus is already up and functioning.
 */
mcam->i2c_adapter = platform_get_drvdata(pdata->i2c_device);
if (mcam->i2c_adapter == NULL) {
-   ret = -ENODEV;
dev_err(&pdev->dev, "No i2c adapter\n");
-   goto out_unmap2;
+   return -ENODEV;
}
/*
 * Sensor GPIO pins.
 */
-   ret = gpio_request(pdata->sensor_power_gpio, "cam-power");
+   ret = devm_gpio_request(&pdev->dev, pdata->sensor_power_gpio,
+   "cam-power");
if (ret) {
dev_err(&pdev->dev, "Can't get sensor power gpio %d",
pdata->sensor_power_gpio);
-   goto out_unmap2;
+   return ret;
}
gpio_direction_output(pdata->sensor_power_gpio, 0);
-   ret = gpio_request(pdata->sensor_reset_gpio, "cam-reset");
+   ret = devm_gpio_request(&pdev->dev, pdata->sensor_reset_gpio,
+   "cam-reset");
if (ret) {
dev_err(&pdev->dev, "Can't get sensor reset gpio %d",
pdata->sensor_reset_gpio);
-   goto out_gpio;
+   return ret;
}
gpio_direction_output(pdata->sensor_reset_gpio, 0);
/*
@@ -436,7 +432,7 @@ static int mmpcam_probe(struct platform_device *pdev)
mmpcam_power_up(mcam);
ret = mccic_register(mcam);
if (ret)
-   goto out_gpio2;
+   goto out_power_down;
/*
 * Finally, set up our IRQ now that the core is ready to
 * deal with it.
@@ -447,8 +443,8 @@ static int mmpcam_probe(struct platform_device *pdev)
goto out_unregister;
}
cam->irq = res->start;
-   ret = request_irq(cam->irq, mmpcam_irq, IRQF_SHARED,
-   "mmp-camera", mcam);
+   re

[REVIEW PATCH V4 08/12] [media] marvell-ccic: rename B_DMA* to avoid CamelCase warning

2013-02-07 Thread Albert Wang
This patch renames the B_vmalloc/B_DMA_contig/B_DMA_sg to
B_VMALLOC/B_DMA_CONTIG/B_DMA_SG variables to avoid CamelCase warning
reported by the checkpatch.pl script.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
---
 drivers/media/platform/marvell-ccic/cafe-driver.c |2 +-
 drivers/media/platform/marvell-ccic/mcam-core.c   |   38 ++---
 drivers/media/platform/marvell-ccic/mcam-core.h   |   12 +++
 drivers/media/platform/marvell-ccic/mmp-driver.c  |2 +-
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c 
b/drivers/media/platform/marvell-ccic/cafe-driver.c
index d030f9b..f85f119 100755
--- a/drivers/media/platform/marvell-ccic/cafe-driver.c
+++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
@@ -486,7 +486,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
 * We *might* be able to run DMA_contig, especially on a system
 * with CMA in it.
 */
-   mcam->buffer_mode = B_vmalloc;
+   mcam->buffer_mode = B_VMALLOC;
/*
 * Get set up on the PCI bus.
 */
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 29c68f1..939c430 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -554,7 +554,7 @@ static void mcam_set_contig_buffer(struct mcam_camera *cam, 
int frame)
 }
 
 /*
- * Initial B_DMA_contig setup.
+ * Initial B_DMA_CONTIG setup.
  */
 static void mcam_ctlr_dma_contig(struct mcam_camera *cam)
 {
@@ -611,7 +611,7 @@ static void mcam_sg_next_buffer(struct mcam_camera *cam)
 }
 
 /*
- * Initial B_DMA_sg setup
+ * Initial B_DMA_SG setup
  */
 static void mcam_ctlr_dma_sg(struct mcam_camera *cam)
 {
@@ -1005,7 +1005,7 @@ static int mcam_read_setup(struct mcam_camera *cam)
 * Configuration.  If we still don't have DMA buffers,
 * make one last, desperate attempt.
 */
-   if (cam->buffer_mode == B_vmalloc && cam->nbufs == 0 &&
+   if (cam->buffer_mode == B_VMALLOC && cam->nbufs == 0 &&
mcam_alloc_dma_bufs(cam, 0))
return -ENOMEM;
 
@@ -1051,13 +1051,13 @@ static int mcam_vb_queue_setup(struct vb2_queue *vq,
void *alloc_ctxs[])
 {
struct mcam_camera *cam = vb2_get_drv_priv(vq);
-   int minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2;
+   int minbufs = (cam->buffer_mode == B_DMA_CONTIG) ? 3 : 2;
 
sizes[0] = cam->pix_format.sizeimage;
*num_planes = 1; /* Someday we have to support planar formats... */
if (*nbufs < minbufs)
*nbufs = minbufs;
-   if (cam->buffer_mode == B_DMA_contig)
+   if (cam->buffer_mode == B_DMA_CONTIG)
alloc_ctxs[0] = cam->vb_alloc_ctx;
return 0;
 }
@@ -1144,7 +1144,7 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 * destination.  So go into a wait state and hope they
 * give us buffers soon.
 */
-   if (cam->buffer_mode != B_vmalloc && list_empty(&cam->buffers)) {
+   if (cam->buffer_mode != B_VMALLOC && list_empty(&cam->buffers)) {
cam->state = S_BUFWAIT;
return 0;
}
@@ -1285,7 +1285,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
vq->drv_priv = cam;
INIT_LIST_HEAD(&cam->buffers);
switch (cam->buffer_mode) {
-   case B_DMA_contig:
+   case B_DMA_CONTIG:
 #ifdef MCAM_MODE_DMA_CONTIG
vq->ops = &mcam_vb2_ops;
vq->mem_ops = &vb2_dma_contig_memops;
@@ -1295,7 +1295,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
cam->frame_complete = mcam_dma_contig_done;
 #endif
break;
-   case B_DMA_sg:
+   case B_DMA_SG:
 #ifdef MCAM_MODE_DMA_SG
vq->ops = &mcam_vb2_sg_ops;
vq->mem_ops = &vb2_dma_sg_memops;
@@ -1304,7 +1304,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
cam->frame_complete = mcam_dma_sg_done;
 #endif
break;
-   case B_vmalloc:
+   case B_VMALLOC:
 #ifdef MCAM_MODE_VMALLOC
tasklet_init(&cam->s_tasklet, mcam_frame_tasklet,
(unsigned long) cam);
@@ -1324,7 +1324,7 @@ static void mcam_cleanup_vb2(struct mcam_camera *cam)
 {
vb2_queue_release(&cam->vb_queue);
 #ifdef MCAM_MODE_DMA_CONTIG
-   if (cam->buffer_mode == B_DMA_contig)
+   if (cam->buffer_mode == B_DMA_CONTIG)
vb2_dma_contig_cleanup_ctx(cam->vb_alloc_ctx);
 #endif
 }
@@ -1536,7 +1536,7 @@ static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, 
void *priv,
/*
 * Make sure we have appropriate DMA buffers.
 */
-   if (cam->buffer_mode == B_vmalloc) {
+   if (cam->buffer_mode == B_VMALLOC) {
ret = mcam_check_dma_buffers(cam);
if (ret)
   

[REVIEW PATCH V4 06/12] [media] marvell-ccic: add SOF/EOF pair check for marvell-ccic driver

2013-02-07 Thread Albert Wang
From: Libin Yang 

This patch adds the SOFx/EOFx pair check for marvell-ccic.

When switching format, the last EOF may not arrive when stop streamning.
And the EOF will be detected in the next start streaming.

Must ensure clear the left over frame flags before every really start streaming.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
Acked-by: Jonathan Corbet 
Acked-by: Guennadi Liakhovetski 
---
 drivers/media/platform/marvell-ccic/mcam-core.c |   30 ---
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 0f9604e..29c68f1 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -94,6 +94,9 @@ MODULE_PARM_DESC(buffer_mode,
 #define CF_CONFIG_NEEDED 4 /* Must configure hardware */
 #define CF_SINGLE_BUFFER 5 /* Running with a single buffer */
 #define CF_SG_RESTART   6  /* SG restart needed */
+#define CF_FRAME_SOF0   7  /* Frame 0 started */
+#define CF_FRAME_SOF1   8
+#define CF_FRAME_SOF2   9
 
 #define sensor_call(cam, o, f, args...) \
v4l2_subdev_call(cam->sensor, o, f, ##args)
@@ -260,8 +263,10 @@ static void mcam_reset_buffers(struct mcam_camera *cam)
int i;
 
cam->next_buf = -1;
-   for (i = 0; i < cam->nbufs; i++)
+   for (i = 0; i < cam->nbufs; i++) {
clear_bit(i, &cam->flags);
+   clear_bit(CF_FRAME_SOF0 + i, &cam->flags);
+   }
 }
 
 static inline int mcam_needs_config(struct mcam_camera *cam)
@@ -1125,6 +1130,7 @@ static void mcam_vb_wait_finish(struct vb2_queue *vq)
 static int mcam_vb_start_streaming(struct vb2_queue *vq, unsigned int count)
 {
struct mcam_camera *cam = vb2_get_drv_priv(vq);
+   unsigned int frame;
 
if (cam->state != S_IDLE) {
INIT_LIST_HEAD(&cam->buffers);
@@ -1142,6 +1148,14 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, 
unsigned int count)
cam->state = S_BUFWAIT;
return 0;
}
+
+   /*
+* Ensure clear the left over frame flags
+* before every really start streaming
+*/
+   for (frame = 0; frame < cam->nbufs; frame++)
+   clear_bit(CF_FRAME_SOF0 + frame, &cam->flags);
+
return mcam_read_setup(cam);
 }
 
@@ -1883,9 +1897,11 @@ int mccic_irq(struct mcam_camera *cam, unsigned int irqs)
 * each time.
 */
for (frame = 0; frame < cam->nbufs; frame++)
-   if (irqs & (IRQ_EOF0 << frame)) {
+   if (irqs & (IRQ_EOF0 << frame) &&
+   test_bit(CF_FRAME_SOF0 + frame, &cam->flags)) {
mcam_frame_complete(cam, frame);
handled = 1;
+   clear_bit(CF_FRAME_SOF0 + frame, &cam->flags);
if (cam->buffer_mode == B_DMA_sg)
break;
}
@@ -1894,9 +1910,15 @@ int mccic_irq(struct mcam_camera *cam, unsigned int irqs)
 * code assumes that we won't get multiple frame interrupts
 * at once; may want to rethink that.
 */
-   if (irqs & (IRQ_SOF0 | IRQ_SOF1 | IRQ_SOF2)) {
+   for (frame = 0; frame < cam->nbufs; frame++) {
+   if (irqs & (IRQ_SOF0 << frame)) {
+   set_bit(CF_FRAME_SOF0 + frame, &cam->flags);
+   handled = IRQ_HANDLED;
+   }
+   }
+
+   if (handled == IRQ_HANDLED) {
set_bit(CF_DMA_ACTIVE, &cam->flags);
-   handled = 1;
if (cam->buffer_mode == B_DMA_sg)
mcam_ctlr_stop(cam);
}
-- 
1.7.9.5

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


[REVIEW PATCH V4 05/12] [media] marvell-ccic: add new formats support for marvell-ccic driver

2013-02-07 Thread Albert Wang
From: Libin Yang 

This patch adds the new formats support for marvell-ccic.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
---
 drivers/media/platform/marvell-ccic/mcam-core.c |  189 +++
 drivers/media/platform/marvell-ccic/mcam-core.h |6 +
 2 files changed, 162 insertions(+), 33 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index f89fce7..0f9604e 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -102,6 +102,7 @@ static struct mcam_format_struct {
__u8 *desc;
__u32 pixelformat;
int bpp;   /* Bytes per pixel */
+   bool planar;
enum v4l2_mbus_pixelcode mbus_code;
 } mcam_formats[] = {
{
@@ -109,24 +110,56 @@ static struct mcam_format_struct {
.pixelformat= V4L2_PIX_FMT_YUYV,
.mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
.bpp= 2,
+   .planar = false,
+   },
+   {
+   .desc   = "UYVY 4:2:2",
+   .pixelformat= V4L2_PIX_FMT_UYVY,
+   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
+   .bpp= 2,
+   .planar = false,
+   },
+   {
+   .desc   = "YUV 4:2:2 PLANAR",
+   .pixelformat= V4L2_PIX_FMT_YUV422P,
+   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
+   .bpp= 2,
+   .planar = true,
+   },
+   {
+   .desc   = "YUV 4:2:0 PLANAR",
+   .pixelformat= V4L2_PIX_FMT_YUV420,
+   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
+   .bpp= 2,
+   .planar = true,
+   },
+   {
+   .desc   = "YVU 4:2:0 PLANAR",
+   .pixelformat= V4L2_PIX_FMT_YVU420,
+   .mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
+   .bpp= 2,
+   .planar = true,
},
{
.desc   = "RGB 444",
.pixelformat= V4L2_PIX_FMT_RGB444,
.mbus_code  = V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE,
.bpp= 2,
+   .planar = false,
},
{
.desc   = "RGB 565",
.pixelformat= V4L2_PIX_FMT_RGB565,
.mbus_code  = V4L2_MBUS_FMT_RGB565_2X8_LE,
.bpp= 2,
+   .planar = false,
},
{
.desc   = "Raw RGB Bayer",
.pixelformat= V4L2_PIX_FMT_SBGGR8,
.mbus_code  = V4L2_MBUS_FMT_SBGGR8_1X8,
-   .bpp= 1
+   .bpp= 1,
+   .planar = false,
},
 };
 #define N_MCAM_FMTS ARRAY_SIZE(mcam_formats)
@@ -169,6 +202,12 @@ struct mcam_dma_desc {
u32 segment_len;
 };
 
+struct yuv_pointer_t {
+   dma_addr_t y;
+   dma_addr_t u;
+   dma_addr_t v;
+};
+
 /*
  * Our buffer type for working with videobuf2.  Note that the vb2
  * developers have decreed that struct vb2_buffer must be at the
@@ -180,6 +219,7 @@ struct mcam_vb_buffer {
struct mcam_dma_desc *dma_desc; /* Descriptor virtual address */
dma_addr_t dma_desc_pa; /* Descriptor physical address */
int dma_desc_nent;  /* Number of mapped descriptors */
+   struct yuv_pointer_t yuv_p;
 };
 
 static inline struct mcam_vb_buffer *vb_to_mvb(struct vb2_buffer *vb)
@@ -459,6 +499,15 @@ static inline int mcam_check_dma_buffers(struct 
mcam_camera *cam)
 /*
  * DMA-contiguous code.
  */
+
+static bool mcam_fmt_is_planar(__u32 pfmt)
+{
+   struct mcam_format_struct *f;
+
+   f = mcam_find_format(pfmt);
+   return f->planar;
+}
+
 /*
  * Set up a contiguous buffer for the given frame.  Here also is where
  * the underrun strategy is set: if there is no buffer available, reuse
@@ -470,6 +519,8 @@ static inline int mcam_check_dma_buffers(struct mcam_camera 
*cam)
 static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
 {
struct mcam_vb_buffer *buf;
+   struct v4l2_pix_format *fmt = &cam->pix_format;
+
/*
 * If there are no available buffers, go into single mode
 */
@@ -488,8 +539,13 @@ static void mcam_set_contig_buffer(struct mcam_camera 
*cam, int frame)
}
 
cam->vb_bufs[frame] = buf;
-   mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
-   vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
+   mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR, buf->yuv_p.y);
+   if (mcam_fmt_is_planar(fmt->pixelformat)) {
+   mcam_reg_write(cam, frame == 0 ?
+   REG_U0BAR : REG_U1BAR, buf-

[REVIEW PATCH V4 04/12] [media] marvell-ccic: refine mcam_set_contig_buffer function

2013-02-07 Thread Albert Wang
From: Libin Yang 

This patch refines mcam_set_contig_buffer() in mcam core.
It can remove redundant code line and enhance readability.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
Acked-by: Guennadi Liakhovetski 
Acked-by: Jonathan Corbet 
---
 drivers/media/platform/marvell-ccic/mcam-core.c |   21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index a32df35..f89fce7 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -475,22 +475,21 @@ static void mcam_set_contig_buffer(struct mcam_camera 
*cam, int frame)
 */
if (list_empty(&cam->buffers)) {
buf = cam->vb_bufs[frame ^ 0x1];
-   cam->vb_bufs[frame] = buf;
-   mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
-   vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
set_bit(CF_SINGLE_BUFFER, &cam->flags);
cam->frame_state.singles++;
-   return;
+   } else {
+   /*
+* OK, we have a buffer we can use.
+*/
+   buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer,
+   queue);
+   list_del_init(&buf->queue);
+   clear_bit(CF_SINGLE_BUFFER, &cam->flags);
}
-   /*
-* OK, we have a buffer we can use.
-*/
-   buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer, queue);
-   list_del_init(&buf->queue);
+
+   cam->vb_bufs[frame] = buf;
mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
-   cam->vb_bufs[frame] = buf;
-   clear_bit(CF_SINGLE_BUFFER, &cam->flags);
 }
 
 /*
-- 
1.7.9.5

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


[REVIEW PATCH V4 03/12] [media] marvell-ccic: reset ccic phy when stop streaming for stability

2013-02-07 Thread Albert Wang
This patch adds the reset ccic phy operation when stop streaming.

Stop streaming without reset ccic phy, the next start streaming
may be unstable.
Also need add CCIC2 definition when PXA688/PXA2128 support dual ccics.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
Acked-by: Jonathan Corbet 
Acked-by: Guennadi Liakhovetski 
---
 drivers/media/platform/marvell-ccic/mcam-core.c  |6 ++
 drivers/media/platform/marvell-ccic/mcam-core.h  |2 ++
 drivers/media/platform/marvell-ccic/mmp-driver.c |   25 ++
 3 files changed, 33 insertions(+)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 7e178d8..a32df35 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1045,6 +1045,12 @@ static int mcam_vb_stop_streaming(struct vb2_queue *vq)
return -EINVAL;
mcam_ctlr_stop_dma(cam);
/*
+* Reset the CCIC PHY after stopping streaming,
+* otherwise, the CCIC may be unstable.
+*/
+   if (cam->ctlr_reset)
+   cam->ctlr_reset(cam);
+   /*
 * VB2 reclaims the buffers, so we need to forget
 * about them.
 */
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h 
b/drivers/media/platform/marvell-ccic/mcam-core.h
index 2b2dc06..ec43630 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -104,6 +104,7 @@ struct mcam_camera {
short int use_smbus;/* SMBUS or straight I2c? */
enum mcam_buffer_mode buffer_mode;
 
+   int ccic_id;
enum v4l2_mbus_type bus_type;
/* MIPI support */
int *dphy;
@@ -120,6 +121,7 @@ struct mcam_camera {
void (*plat_power_up) (struct mcam_camera *cam);
void (*plat_power_down) (struct mcam_camera *cam);
void (*calc_dphy) (struct mcam_camera *cam);
+   void (*ctlr_reset) (struct mcam_camera *cam);
 
/*
 * Everything below here is private to the mcam core and
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c 
b/drivers/media/platform/marvell-ccic/mmp-driver.c
index 2fe0324..818abf3 100755
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -105,6 +105,7 @@ static struct mmp_camera *mmpcam_find_device(struct 
platform_device *pdev)
 #define CPU_SUBSYS_PMU_BASE0xd4282800
 #define REG_CCIC_DCGCR 0x28/* CCIC dyn clock gate ctrl reg */
 #define REG_CCIC_CRCR  0x50/* CCIC clk reset ctrl reg  */
+#define REG_CCIC2_CRCR 0xf4/* CCIC2 clk reset ctrl reg */
 
 static void mcam_clk_enable(struct mcam_camera *mcam)
 {
@@ -179,6 +180,28 @@ static void mmpcam_power_down(struct mcam_camera *mcam)
mcam_clk_disable(mcam);
 }
 
+void mcam_ctlr_reset(struct mcam_camera *mcam)
+{
+   unsigned long val;
+   struct mmp_camera *cam = mcam_to_cam(mcam);
+
+   if (mcam->ccic_id) {
+   /*
+* Using CCIC2
+*/
+   val = ioread32(cam->power_regs + REG_CCIC2_CRCR);
+   iowrite32(val & ~0x2, cam->power_regs + REG_CCIC2_CRCR);
+   iowrite32(val | 0x2, cam->power_regs + REG_CCIC2_CRCR);
+   } else {
+   /*
+* Using CCIC1
+*/
+   val = ioread32(cam->power_regs + REG_CCIC_CRCR);
+   iowrite32(val & ~0x2, cam->power_regs + REG_CCIC_CRCR);
+   iowrite32(val | 0x2, cam->power_regs + REG_CCIC_CRCR);
+   }
+}
+
 /*
  * calc the dphy register values
  * There are three dphy registers being used.
@@ -328,9 +351,11 @@ static int mmpcam_probe(struct platform_device *pdev)
mcam = &cam->mcam;
mcam->plat_power_up = mmpcam_power_up;
mcam->plat_power_down = mmpcam_power_down;
+   mcam->ctlr_reset = mcam_ctlr_reset;
mcam->calc_dphy = mmpcam_calc_dphy;
mcam->dev = &pdev->dev;
mcam->use_smbus = 0;
+   mcam->ccic_id = pdev->id;
mcam->bus_type = pdata->bus_type;
mcam->dphy = pdata->dphy;
/* mosetly it won't happen. dphy is an array in pdata, but in case .. */
-- 
1.7.9.5

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


[REVIEW PATCH V4 01/12] [media] marvell-ccic: add MIPI support for marvell-ccic driver

2013-02-07 Thread Albert Wang
From: Libin Yang 

This patch adds the MIPI support for marvell-ccic.
Board driver should determine whether using MIPI or not.

Signed-off-by: Albert Wang 
Signed-off-by: Libin Yang 
---
 drivers/media/platform/marvell-ccic/mcam-core.c  |   66 +
 drivers/media/platform/marvell-ccic/mcam-core.h  |   28 +-
 drivers/media/platform/marvell-ccic/mmp-driver.c |  113 +-
 include/media/mmp-camera.h   |   10 ++
 4 files changed, 214 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 7012913f..7e178d8 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -253,6 +254,39 @@ static void mcam_ctlr_stop(struct mcam_camera *cam)
mcam_reg_clear_bit(cam, REG_CTRL0, C0_ENABLE);
 }
 
+static int mcam_config_mipi(struct mcam_camera *mcam, int enable)
+{
+   if (mcam->bus_type == V4L2_MBUS_CSI2 && enable) {
+   /* Using MIPI mode and enable MIPI */
+   cam_dbg(mcam, "camera: DPHY3=0x%x, DPHY5=0x%x, DPHY6=0x%x\n",
+   mcam->dphy[0], mcam->dphy[1], mcam->dphy[2]);
+   mcam_reg_write(mcam, REG_CSI2_DPHY3, mcam->dphy[0]);
+   mcam_reg_write(mcam, REG_CSI2_DPHY5, mcam->dphy[1]);
+   mcam_reg_write(mcam, REG_CSI2_DPHY6, mcam->dphy[2]);
+
+   if (mcam->mipi_enabled == 0) {
+   BUG_ON(mcam->lane > 4 || mcam->lane <= 0);
+   /*
+* 0x41 actives 1 lane
+* 0x43 actives 2 lanes
+* 0x45 actives 3 lanes (never happen)
+* 0x47 actives 4 lanes
+*/
+   mcam_reg_write(mcam, REG_CSI2_CTRL0,
+   CSI2_C0_MIPI_EN | CSI2_C0_ACT_LANE(mcam->lane));
+   mcam->mipi_enabled = 1;
+   }
+   } else {
+   /* Using Parallel mode or disable MIPI */
+   mcam_reg_write(mcam, REG_CSI2_CTRL0, 0x0);
+   mcam_reg_write(mcam, REG_CSI2_DPHY3, 0x0);
+   mcam_reg_write(mcam, REG_CSI2_DPHY5, 0x0);
+   mcam_reg_write(mcam, REG_CSI2_DPHY6, 0x0);
+   mcam->mipi_enabled = 0;
+   }
+   return 0;
+}
+
 /* --- */
 
 #ifdef MCAM_MODE_VMALLOC
@@ -656,6 +690,13 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
 */
mcam_reg_write_mask(cam, REG_CTRL0, C0_SIF_HVSYNC,
C0_SIFM_MASK);
+
+   /*
+* This field controls the generation of EOF(DVP only)
+*/
+   if (cam->bus_type != V4L2_MBUS_CSI2)
+   mcam_reg_set_bit(cam, REG_CTRL0,
+   C0_EOF_VSYNC | C0_VEDGE_CTRL);
 }
 
 
@@ -886,6 +927,16 @@ static int mcam_read_setup(struct mcam_camera *cam)
spin_lock_irqsave(&cam->dev_lock, flags);
clear_bit(CF_DMA_ACTIVE, &cam->flags);
mcam_reset_buffers(cam);
+   /*
+* Update CSI2_DPHY value
+*/
+   if (cam->calc_dphy)
+   cam->calc_dphy(cam);
+   cam_dbg(cam, "camera: DPHY sets: dphy3=0x%x, dphy5=0x%x, dphy6=0x%x\n",
+   cam->dphy[0], cam->dphy[1], cam->dphy[2]);
+   ret = mcam_config_mipi(cam, 1);
+   if (ret < 0)
+   return ret;
mcam_ctlr_irq_enable(cam);
cam->state = S_STREAMING;
if (!test_bit(CF_SG_RESTART, &cam->flags))
@@ -1551,6 +1602,16 @@ static int mcam_v4l_open(struct file *filp)
mcam_set_config_needed(cam, 1);
}
(cam->users)++;
+   if (cam->bus_type == V4L2_MBUS_CSI2) {
+   cam->pll1 = devm_clk_get(cam->dev, "pll1");
+   if (IS_ERR_OR_NULL(cam->pll1) && cam->dphy[2] == 0) {
+   cam_err(cam, "Could not get pll1 clock\n");
+   if (IS_ERR(cam->pll1))
+   ret = PTR_ERR(cam->pll1);
+   else
+   ret = -EINVAL;
+   }
+   }
 out:
mutex_unlock(&cam->s_mutex);
return ret;
@@ -1569,10 +1630,15 @@ static int mcam_v4l_release(struct file *filp)
if (cam->users == 0) {
mcam_ctlr_stop_dma(cam);
mcam_cleanup_vb2(cam);
+   mcam_config_mipi(cam, 0);
mcam_ctlr_power_down(cam);
if (cam->buffer_mode == B_vmalloc && alloc_bufs_at_read)
mcam_free_dma_bufs(cam);
}
+   if (cam->bus_type == V4L2_MBUS_CSI2) {
+   devm_clk_put(cam->dev, cam->pll1);
+   cam->pll1 = NULL;
+   }
mutex_unlock(&cam->s_mutex);
return 0;
 }
diff --git a/d

[REVIEW PATCH V4 02/12] [media] marvell-ccic: add clock tree support for marvell-ccic driver

2013-02-07 Thread Albert Wang
From: Libin Yang 

This patch adds the clock tree support for marvell-ccic.

Signed-off-by: Libin Yang 
Signed-off-by: Albert Wang 
Acked-by: Jonathan Corbet 
---
 drivers/media/platform/marvell-ccic/mcam-core.h  |4 ++
 drivers/media/platform/marvell-ccic/mmp-driver.c |   47 ++
 2 files changed, 51 insertions(+)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h 
b/drivers/media/platform/marvell-ccic/mcam-core.h
index f73a801..2b2dc06 100755
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -82,6 +82,8 @@ struct mcam_frame_state {
unsigned int delivered;
 };
 
+#define NR_MCAM_CLK 3
+
 /*
  * A description of one of our devices.
  * Locking: controlled by s_mutex.  Certain fields, however, require
@@ -109,6 +111,8 @@ struct mcam_camera {
int lane;   /* lane number */
 
struct clk *pll1;
+   /* clock tree support */
+   struct clk *clk[NR_MCAM_CLK];
 
/*
 * Callbacks from the core to the platform code.
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c 
b/drivers/media/platform/marvell-ccic/mmp-driver.c
index 7ab01e9..2fe0324 100755
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -35,6 +35,8 @@ MODULE_ALIAS("platform:mmp-camera");
 MODULE_AUTHOR("Jonathan Corbet ");
 MODULE_LICENSE("GPL");
 
+static char *mcam_clks[] = {"CCICAXICLK", "CCICFUNCLK", "CCICPHYCLK"};
+
 struct mmp_camera {
void *power_regs;
struct platform_device *pdev;
@@ -104,6 +106,26 @@ static struct mmp_camera *mmpcam_find_device(struct 
platform_device *pdev)
 #define REG_CCIC_DCGCR 0x28/* CCIC dyn clock gate ctrl reg */
 #define REG_CCIC_CRCR  0x50/* CCIC clk reset ctrl reg  */
 
+static void mcam_clk_enable(struct mcam_camera *mcam)
+{
+   unsigned int i;
+
+   for (i = 0; i < NR_MCAM_CLK; i++) {
+   if (mcam->clk[i])
+   clk_enable(mcam->clk[i]);
+   }
+}
+
+static void mcam_clk_disable(struct mcam_camera *mcam)
+{
+   int i;
+
+   for (i = NR_MCAM_CLK - 1; i >= 0; i--) {
+   if (mcam->clk[i])
+   clk_disable(mcam->clk[i]);
+   }
+}
+
 /*
  * Power control.
  */
@@ -134,6 +156,8 @@ static void mmpcam_power_up(struct mcam_camera *mcam)
mdelay(5);
gpio_set_value(pdata->sensor_reset_gpio, 1); /* reset is active low */
mdelay(5);
+
+   mcam_clk_enable(mcam);
 }
 
 static void mmpcam_power_down(struct mcam_camera *mcam)
@@ -151,6 +175,8 @@ static void mmpcam_power_down(struct mcam_camera *mcam)
pdata = cam->pdev->dev.platform_data;
gpio_set_value(pdata->sensor_power_gpio, 0);
gpio_set_value(pdata->sensor_reset_gpio, 0);
+
+   mcam_clk_disable(mcam);
 }
 
 /*
@@ -263,6 +289,23 @@ static irqreturn_t mmpcam_irq(int irq, void *data)
return IRQ_RETVAL(handled);
 }
 
+static int mcam_init_clk(struct mcam_camera *mcam,
+   struct mmp_camera_platform_data *pdata)
+{
+   unsigned int i;
+
+   for (i = 0; i < NR_MCAM_CLK; i++) {
+   if (mcam_clks[i] != NULL) {
+   mcam->clk[i] = devm_clk_get(mcam->dev, mcam_clks[i]);
+   if (IS_ERR(mcam->clk[i])) {
+   dev_err(mcam->dev, "Could not get clk: %s\n",
+   mcam_clks[i]);
+   return PTR_ERR(mcam->clk[i]);
+   }
+   }
+   }
+   return 0;
+}
 
 static int mmpcam_probe(struct platform_device *pdev)
 {
@@ -331,6 +374,10 @@ static int mmpcam_probe(struct platform_device *pdev)
ret = -ENODEV;
goto out_unmap1;
}
+
+   ret = mcam_init_clk(mcam, pdata);
+   if (ret)
+   goto out_unmap2;
/*
 * Find the i2c adapter.  This assumes, of course, that the
 * i2c bus is already up and functioning.
-- 
1.7.9.5

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


[RFC PATCH v2 5/5] alsa/soc: add hdmi audio card using cdf based hdmi codec

2013-02-07 Thread Rahul Sharma
It registers hdmi-audio card to ALSA framework which associates i2s dai and
cdf based hdmi audio codec.

Signed-off-by: Rahul Sharma 
---
 sound/soc/samsung/Kconfig  |   8 ++
 sound/soc/samsung/Makefile |   2 +
 sound/soc/samsung/hdmi.c   | 260 +
 3 files changed, 270 insertions(+)
 create mode 100644 sound/soc/samsung/hdmi.c

diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 90e7e66..d5b92ab 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -185,6 +185,14 @@ config SND_SOC_SMDK_WM8994_PCM
help
  Say Y if you want to add support for SoC audio on the SMDK
 
+config SND_SOC_EXYNOS_HDMI_AUDIO
+   tristate "SoC I2S Audio support for HDMI"
+   depends on SND_SOC_SAMSUNG && DRM_EXYNOS_HDMI_CDF
+   select SND_SAMSUNG_I2S
+   select SND_SOC_EXYNOS_HDMI_CODEC
+   help
+   Say Y if you want to add support for hdmi audio on the Exynos.
+
 config SND_SOC_SPEYSIDE
tristate "Audio support for Wolfson Speyside"
depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410
diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile
index 709f605..ab1c151 100644
--- a/sound/soc/samsung/Makefile
+++ b/sound/soc/samsung/Makefile
@@ -8,6 +8,7 @@ snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o
 snd-soc-samsung-spdif-objs := spdif.o
 snd-soc-pcm-objs := pcm.o
 snd-soc-i2s-objs := i2s.o
+snd-soc-hdmi-objs := hdmi.o
 
 obj-$(CONFIG_SND_SOC_SAMSUNG) += snd-soc-s3c24xx.o
 obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o
@@ -18,6 +19,7 @@ obj-$(CONFIG_SND_SAMSUNG_SPDIF) += snd-soc-samsung-spdif.o
 obj-$(CONFIG_SND_SAMSUNG_PCM) += snd-soc-pcm.o
 obj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-i2s.o
 obj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-idma.o
+obj-$(CONFIG_SND_SOC_EXYNOS_HDMI_AUDIO) += snd-soc-hdmi.o
 
 # S3C24XX Machine Support
 snd-soc-jive-wm8750-objs := jive_wm8750.o
diff --git a/sound/soc/samsung/hdmi.c b/sound/soc/samsung/hdmi.c
new file mode 100644
index 000..a600a84
--- /dev/null
+++ b/sound/soc/samsung/hdmi.c
@@ -0,0 +1,260 @@
+/*
+ * ALSA SoC Card driver for HDMI audio on Samsung Exynos processors.
+ * Copyright (C) 2013 Samsung corp.
+ * Author: Rahul Sharma 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "i2s.h"
+
+/* platform device pointer for eynos hdmi audio device. */
+static struct platform_device *exynos_hdmi_audio_pdev;
+
+static int set_epll_rate(unsigned long rate)
+{
+   int ret;
+   struct clk *fout_epll;
+
+   fout_epll = clk_get(NULL, "fout_epll");
+
+   if (IS_ERR(fout_epll))
+   return PTR_ERR(fout_epll);
+
+   if (rate == clk_get_rate(fout_epll))
+   goto out;
+
+   ret = clk_set_rate(fout_epll, rate);
+   if (ret < 0)
+   goto out;
+
+out:
+   clk_put(fout_epll);
+
+   return 0;
+}
+
+static int hdmi_hw_params(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params)
+{
+   struct snd_soc_pcm_runtime *rtd = substream->private_data;
+   struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+   int bfs, psr, rfs, ret;
+   unsigned long rclk;
+   unsigned long xtal;
+   struct clk *xtal_clk;
+
+   dev_dbg(rtd->dev, "[%d][%s]\n", __LINE__, __func__);
+
+   switch (params_format(params)) {
+   case SNDRV_PCM_FORMAT_U24:
+   case SNDRV_PCM_FORMAT_S24:
+   bfs = 48;
+   break;
+   case SNDRV_PCM_FORMAT_U16_LE:
+   case SNDRV_PCM_FORMAT_S16_LE:
+   bfs = 32;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   switch (params_rate(params)) {
+   case 16000:
+   case 22050:
+   case 24000:
+   case 32000:
+   case 44100:
+   case 48000:
+   case 88200:
+   case 96000:
+   if (bfs == 48)
+   rfs = 384;
+   else
+   rfs = 256;
+   break;
+   case 64000:
+   rfs = 384;
+   break;
+   case 8000:
+   case 11025:
+   case 12000:
+   if (bfs == 48)
+   rfs = 768;
+   else
+   rfs = 512;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   rclk = params_rate(params) * rfs;
+
+   switch (rclk) {
+   case 4096000:
+   case 5644800:
+   case 6144000:
+   case 8467200:
+   case 9216000:
+   psr = 8;
+   break;

[RFC PATCH v2 4/5] alsa/soc: add hdmi audio codec based on cdf

2013-02-07 Thread Rahul Sharma
V2:
- DAPM and JACK control to hdmi codec.

This patch registers hdmi-audio codec to the ALSA framework. This is the second
client to the hdmi panel. Once notified by the CDF Core it proceeds towards
audio setting and audio control. It also subscribes for hpd notification to
implement hpd related audio requirements.

Signed-off-by: Rahul Sharma 
---
 sound/soc/codecs/Kconfig |   3 +
 sound/soc/codecs/Makefile|   2 +
 sound/soc/codecs/exynos_hdmi_audio.c | 424 +++
 3 files changed, 429 insertions(+)
 create mode 100644 sound/soc/codecs/exynos_hdmi_audio.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 3a84782..d3e0874 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -512,3 +512,6 @@ config SND_SOC_ML26124
 
 config SND_SOC_TPA6130A2
tristate
+
+config SND_SOC_EXYNOS_HDMI_CODEC
+   tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index f6e8e36..388da28 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -115,6 +115,7 @@ snd-soc-wm9705-objs := wm9705.o
 snd-soc-wm9712-objs := wm9712.o
 snd-soc-wm9713-objs := wm9713.o
 snd-soc-wm-hubs-objs := wm_hubs.o
+snd-soc-exynos-hdmi-audio-objs := exynos_hdmi_audio.o
 
 # Amp
 snd-soc-max9877-objs := max9877.o
@@ -236,6 +237,7 @@ obj-$(CONFIG_SND_SOC_WM9712)+= snd-soc-wm9712.o
 obj-$(CONFIG_SND_SOC_WM9713)   += snd-soc-wm9713.o
 obj-$(CONFIG_SND_SOC_WM_ADSP)  += snd-soc-wm-adsp.o
 obj-$(CONFIG_SND_SOC_WM_HUBS)  += snd-soc-wm-hubs.o
+obj-$(CONFIG_SND_SOC_EXYNOS_HDMI_CODEC)+= snd-soc-exynos-hdmi-audio.o
 
 # Amp
 obj-$(CONFIG_SND_SOC_MAX9877)  += snd-soc-max9877.o
diff --git a/sound/soc/codecs/exynos_hdmi_audio.c 
b/sound/soc/codecs/exynos_hdmi_audio.c
new file mode 100644
index 000..e2cf94c
--- /dev/null
+++ b/sound/soc/codecs/exynos_hdmi_audio.c
@@ -0,0 +1,424 @@
+/*
+ * ALSA SoC codec driver for HDMI audio on Samsung Exynos processors.
+ * Copyright (C) 2013 Samsung corp.
+ * Author: Rahul Sharma 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define get_ctx(dev) ((struct hdmi_audio_context *)platform_get_drvdata\
+   (to_platform_device((struct device *)dev)))
+
+/* platform device pointer for eynos hdmi audio codec device. */
+static struct platform_device *exynos_hdmi_codec_pdev;
+
+struct hdmi_audio_context {
+   struct platform_device  *pdev;
+   atomic_tplugged;
+   atomic_tenabled;
+   struct workqueue_struct *event_wq;
+   struct delayed_work hotplug_work;
+   struct display_entity_audio_params  audio_params;
+   struct display_entity   *entity;
+   struct display_entity_notifier  notf;
+   struct display_event_subscriber subscriber;
+   struct snd_soc_jack hdmi_jack;
+};
+
+static int exynos_hdmi_audio_hw_params(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params,
+   struct snd_soc_dai *dai)
+{
+   struct snd_soc_codec *codec = dai->codec;
+   struct hdmi_audio_context *ctx = snd_soc_codec_get_drvdata(codec);
+   int ret;
+
+   dev_dbg(codec->dev, "[%d] %s\n", __LINE__, __func__);
+
+   /* report failure if hdmi sink is unplugged. */
+   if (!atomic_read(&ctx->plugged))
+   return -ENODEV;
+
+   ctx->audio_params.type = DISPLAY_ENTITY_AUDIO_I2S;
+
+   switch (params_channels(params)) {
+   case 6:
+   case 4:
+   case 2:
+   case 1:
+   ctx->audio_params.channels = params_channels(params);
+   break;
+   default:
+   dev_err(codec->dev, "%d channels not supported\n",
+   params_channels(params));
+   return -EINVAL;
+   }
+
+   switch (params_format(params)) {
+   case SNDRV_PCM_FORMAT_S8:
+   ctx->audio_params.bits_per_sample = 8;
+   break;
+   case SNDRV_PCM_FORMAT_S16_LE:
+   ctx->audio_params.bits_per_sample = 12;
+   break;
+   case SNDRV_PCM_FORMAT_S24_LE:
+   ctx->audio_params.bits_per_sample = 16;
+   break;
+   default:
+   dev_err(codec->dev, "Format(%d) not supported\n",
+   params_format(params));
+   return -EINVAL;
+   }
+
+   switch (par

[RFC PATCH v2 3/5] drm/exynos: moved drm hdmi driver to cdf framework

2013-02-07 Thread Rahul Sharma
This patch implements exynos_hdmi_cdf.c which is a glue component between
exynos DRM and hdmi cdf panel. It is a platform driver register through
exynos_drm_drv.c. Exynos_hdmi.c is modified to register hdmi as display panel.
exynos_hdmi_cdf.c registers for exynos hdmi display entity and if successful,
proceeds for mode setting.

Signed-off-by: Rahul Sharma 
---
 drivers/gpu/drm/exynos/Kconfig   |   6 +
 drivers/gpu/drm/exynos/Makefile  |   1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  24 ++
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |   1 +
 drivers/gpu/drm/exynos/exynos_hdmi.c | 445 ---
 drivers/gpu/drm/exynos/exynos_hdmi_cdf.c | 370 +
 include/video/exynos_hdmi.h  |  25 ++
 7 files changed, 658 insertions(+), 214 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_hdmi_cdf.c
 create mode 100644 include/video/exynos_hdmi.h

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 1d1f1e5..309e62a 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -34,6 +34,12 @@ config DRM_EXYNOS_HDMI
help
  Choose this option if you want to use Exynos HDMI for DRM.
 
+config DRM_EXYNOS_HDMI_CDF
+   bool "Exynos DRM HDMI using CDF"
+   depends on DRM_EXYNOS_HDMI && DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_TV
+   help
+ Choose this option if you want to use Exynos HDMI for DRM using CDF.
+
 config DRM_EXYNOS_VIDI
bool "Exynos DRM Virtual Display"
depends on DRM_EXYNOS
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 639b49e..e946ed6 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -20,5 +20,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)+= exynos_drm_ipp.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)+= exynos_drm_fimc.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR) += exynos_drm_rotator.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_GSC) += exynos_drm_gsc.o
+exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI_CDF) += exynos_hdmi_cdf.o
 
 obj-$(CONFIG_DRM_EXYNOS)   += exynosdrm.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 3da5c2d..7876c3c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -40,6 +40,9 @@
 /* platform device pointer for eynos drm device. */
 static struct platform_device *exynos_drm_pdev;
 
+/* platform device pointer for eynos hdmi cdf device. */
+static struct platform_device *exynos_hdmi_cdf_pdev;
+
 static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
 {
struct exynos_drm_private *private;
@@ -331,6 +334,18 @@ static int __init exynos_drm_init(void)
 #endif
 
 #ifdef CONFIG_DRM_EXYNOS_HDMI
+
+   ret = platform_driver_register(&hdmi_cdf_driver);
+   if (ret < 0)
+   goto out_hdmi_cdf_driver;
+
+   exynos_hdmi_cdf_pdev = platform_device_register_simple(
+   "exynos-hdmi-cdf", -1, NULL, 0);
+   if (IS_ERR_OR_NULL(exynos_hdmi_cdf_pdev)) {
+   ret = PTR_ERR(exynos_hdmi_cdf_pdev);
+   goto out_hdmi_cdf_device;
+   }
+
ret = platform_driver_register(&hdmi_driver);
if (ret < 0)
goto out_hdmi;
@@ -438,6 +453,13 @@ out_common_hdmi:
 out_mixer:
platform_driver_unregister(&hdmi_driver);
 out_hdmi:
+
+out_hdmi_cdf_device:
+   platform_device_unregister(exynos_hdmi_cdf_pdev);
+
+out_hdmi_cdf_driver:
+   platform_driver_unregister(&hdmi_cdf_driver);
+
 #endif
 
 #ifdef CONFIG_DRM_EXYNOS_FIMD
@@ -480,6 +502,8 @@ static void __exit exynos_drm_exit(void)
platform_driver_unregister(&exynos_drm_common_hdmi_driver);
platform_driver_unregister(&mixer_driver);
platform_driver_unregister(&hdmi_driver);
+   platform_driver_unregister(&hdmi_cdf_driver);
+   platform_device_unregister(exynos_hdmi_cdf_pdev);
 #endif
 
 #ifdef CONFIG_DRM_EXYNOS_VIDI
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index b9e51bc..961fe14 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -332,6 +332,7 @@ void exynos_platform_device_hdmi_unregister(void);
 extern struct platform_driver fimd_driver;
 extern struct platform_driver hdmi_driver;
 extern struct platform_driver mixer_driver;
+extern struct platform_driver hdmi_cdf_driver;
 extern struct platform_driver exynos_drm_common_hdmi_driver;
 extern struct platform_driver vidi_driver;
 extern struct platform_driver g2d_driver;
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 6f844b1..548cd32 100755
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -34,13 +34,12 @@
 #include 
 #include 
 #include 
+#include 
+#include "video/exynos_hdmi.h"
 #include 
 
 #include 
 
-#include "exynos_drm_drv.h"
-#includ

[RFC PATCH v2 2/5] drm/edid: temporarily exposing generic edid-read interface from drm

2013-02-07 Thread Rahul Sharma
It exposes generic interface from drm_edid.c to get the edid data and length
by any display entity. Once I get clear idea about edid handling in CDF, I need
to revert these temporary changes.

Signed-off-by: Rahul Sharma 
---
 drivers/gpu/drm/drm_edid.c | 88 ++
 1 file changed, 88 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 5a3770f..567a565 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "drm_edid_modes.h"
@@ -386,6 +387,93 @@ out:
return NULL;
 }
 
+int generic_drm_do_get_edid(struct i2c_adapter *adapter,
+   struct display_entity_edid *edid)
+{
+   int i, j = 0, valid_extensions = 0;
+   u8 *block, *new;
+   bool print_bad_edid = 0;
+
+   block = kmalloc(EDID_LENGTH, GFP_KERNEL);
+   if (!block)
+   return -ENOMEM;
+
+   /* base block fetch */
+   for (i = 0; i < 4; i++) {
+   if (drm_do_probe_ddc_edid(adapter, block, 0, EDID_LENGTH))
+   goto out;
+   if (drm_edid_block_valid(block, 0, print_bad_edid))
+   break;
+   if (i == 0 && drm_edid_is_zero(block, EDID_LENGTH))
+   goto carp;
+   }
+   if (i == 4)
+   goto carp;
+
+   /* if there's no extensions, we're done */
+   if (block[0x7e] == 0) {
+   edid->edid = block;
+   edid->len = EDID_LENGTH;
+   return 0;
+   }
+
+   new = krealloc(block, (block[0x7e] + 1) * EDID_LENGTH, GFP_KERNEL);
+   if (!new)
+   goto out;
+   block = new;
+   edid->len = (block[0x7e] + 1) * EDID_LENGTH;
+
+   for (j = 1; j <= block[0x7e]; j++) {
+   for (i = 0; i < 4; i++) {
+   if (drm_do_probe_ddc_edid(adapter,
+ block + (valid_extensions + 1) * EDID_LENGTH,
+ j, EDID_LENGTH))
+   goto out;
+   if (drm_edid_block_valid(block + (valid_extensions + 1)*
+   EDID_LENGTH, j, print_bad_edid)) {
+   valid_extensions++;
+   break;
+   }
+   }
+   if (i == 4)
+   DRM_DEBUG_KMS("Ignoring inv lock %d.\n", j);
+   }
+
+   if (valid_extensions != block[0x7e]) {
+   block[EDID_LENGTH-1] += block[0x7e] - valid_extensions;
+   block[0x7e] = valid_extensions;
+   new = krealloc(block, (valid_extensions + 1)*
+   EDID_LENGTH, GFP_KERNEL);
+   if (!new)
+   goto out;
+   block = new;
+   edid->len = (valid_extensions + 1) * EDID_LENGTH;
+   }
+
+   edid->edid = block;
+   return 0;
+
+carp:
+   if (print_bad_edid)
+   DRM_DEBUG_KMS("[ERROR]: EDID block %d invalid.\n", j);
+
+out:
+   kfree(block);
+   return -ENOMEM;
+}
+
+
+int generic_drm_get_edid(struct i2c_adapter *adapter,
+   struct display_entity_edid *edid)
+{
+   int ret = -EINVAL;
+   if (drm_probe_ddc(adapter))
+   ret = generic_drm_do_get_edid(adapter, edid);
+
+   return ret;
+}
+EXPORT_SYMBOL(generic_drm_get_edid);
+
 /**
  * Probe DDC presence.
  *
-- 
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 v2] media: add support for decoder as one of media entity types

2013-02-07 Thread Sylwester Nawrocki
Hi Prabhakar,

On 01/28/2013 12:50 PM, Prabhakar Lad wrote:
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index 0ef8833..dac06d7 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -56,6 +56,8 @@ struct media_device_info {
>  #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR   (MEDIA_ENT_T_V4L2_SUBDEV + 1)
>  #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH(MEDIA_ENT_T_V4L2_SUBDEV + 2)
>  #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3)
> +/* DECODER: Converts analogue video to digital */

The patch looks good to me, I would just change this comment to
something like:

/* A converter of analogue video to its digital representation. */

But that's really a nitpicking.

> +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER  (MEDIA_ENT_T_V4L2_SUBDEV + 4)
>  
>  #define MEDIA_ENT_FL_DEFAULT (1 << 0)

Reviewed-by: Sylwester Nawrocki 

--

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


[RFC PATCH v2 1/5] video: display: add event handling, set mode and hdmi ops to cdf core

2013-02-07 Thread Rahul Sharma
This patch adds
1) Event Notification to CDF Core:
Adds simple event notification mechanism supports multiple
subscribers. This is used for hot-plug notification to the clients
of hdmi display i.e. exynos-drm and alsa-codec. CDF Core maintains
multiple subscriber list. When entity reports a event Core will
route it to all of them. Un-superscription is not implemented which
can be done if notification callback is Null.

2) set_mode to generic ops:
It is meaningful for a panel like hdmi which supports multiple
resolutions.

HDMI needs conversion of Display Modes to Standard Display Timings.
Though, it can be done within the driver but seems more meaningful
if set_mode is called with Timing Details provided by CDF Core.

3) Provision for platform specific interfaces through void *private in display
entity:

It has added void *private to display entity which can be used to
expose interfaces which are very much specific to a particular platform.

In exynos, hpd is connected to the soc via gpio bus. During initial
hdmi poweron, hpd interrupt is not raised as there is no change in the
gpio status. This is solved by providing a platform specific interface
which is queried by the drm to get the hpd state. This interface may
not be required by all platforms.

4) hdmi ops:
get_edid: to query raw EDID data and length from the panel.
check_mode: To check if a given mode is supported by exynos HDMI IP
"AND" Connected HDMI Sink (tv/monitor).
init_audio: Configure hdmi audio registers for Audio interface type
(i2s/ spdif), SF, Audio Channels, BPS.
set_audiostate: enable disable audio.

Signed-off-by: Rahul Sharma 
---
 drivers/video/display/display-core.c |  85 +++
 include/video/display.h  | 111 ++-
 2 files changed, 193 insertions(+), 3 deletions(-)

diff --git a/drivers/video/display/display-core.c 
b/drivers/video/display/display-core.c
index 55a7399..12fb882 100644
--- a/drivers/video/display/display-core.c
+++ b/drivers/video/display/display-core.c
@@ -99,6 +99,14 @@ int display_entity_get_modes(struct display_entity *entity,
 }
 EXPORT_SYMBOL_GPL(display_entity_get_modes);
 
+int display_entity_set_mode(struct display_entity *entity,
+  const struct videomode *mode)
+{
+   if (!entity->opt_ctrl.hdmi || !entity->ops.ctrl->set_mode)
+   return 0;
+   return entity->ops.ctrl->set_mode(entity, mode);
+}
+EXPORT_SYMBOL_GPL(display_entity_set_mode);
 /**
 * display_entity_get_size - Get display entity physical size
 * @entity: The display entity
@@ -140,6 +148,37 @@ int display_entity_get_params(struct display_entity 
*entity,
 }
 EXPORT_SYMBOL_GPL(display_entity_get_params);
 
+int display_entity_subscribe_event(struct display_entity *entity,
+   struct display_event_subscriber *subscriber)
+{
+   if (!entity || !subscriber || !subscriber->notify)
+   return -EINVAL;
+
+   mutex_lock(&entity->entity_mutex);
+   list_add_tail(&subscriber->list, &entity->list_subscribers);
+   mutex_unlock(&entity->entity_mutex);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(display_entity_subscribe_event);
+
+int display_entity_notify_event_subscriber(struct display_entity *entity,
+   enum display_entity_event_type type, unsigned int value)
+{
+   struct display_event_subscriber *subscriber;
+
+   if (!entity || type < 0)
+   return -EINVAL;
+
+   mutex_lock(&entity->entity_mutex);
+   list_for_each_entry(subscriber, &entity->list_subscribers, list) {
+   subscriber->notify(entity, type, value, subscriber->context);
+   }
+   mutex_unlock(&entity->entity_mutex);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(display_entity_notify_event_subscriber);
+
 /* 
-
 * Video operations
 */
@@ -312,6 +351,9 @@ int __must_check __display_entity_register(struct 
display_entity *entity,
kref_init(&entity->ref);
entity->owner = owner;
entity->state = DISPLAY_ENTITY_STATE_OFF;
+   entity->list_subscribers.next = &entity->list_subscribers;
+   entity->list_subscribers.prev = &entity->list_subscribers;
+   mutex_init(&entity->entity_mutex);
 
mutex_lock(&display_entity_mutex);
list_add(&entity->list, &display_entity_list);
@@ -357,6 +399,49 @@ void display_entity_unregister(struct display_entity 
*entity)
 }
 EXPORT_SYMBOL_GPL(display_entity_unregister);
 
+/* 
-
+ * Display Entity Hdmi ops
+ */
+
+int display_entity_hdmi_get_edid(struct display_entity *entity,
+   struct display_entity_edid *edid)
+{
+   if (!entity->opt_ctrl.hdmi || !

[RFC PATCH v2 0/5] exynos-hdmi to CDF compliant display driver

2013-02-07 Thread Rahul Sharma
V2:
1) Adding hdmi sound card using cdf based hdmi audio codec.
2) DAPM and JACK control to hdmi codec.
3) Offload event handler by adding work queue.
4) Rework based on v1 comments.

Tested for:
1) Mode setting and switching using modetest.
2) Video with HPD and Power related scenarios.
3) Audio playback with Hotplug-Scenarios.
4) DAPM control for hdmi playback.

Pending:
1) Not moved exynos_hdmi to driver/video/display since it will make it
difficult to analyze the code changes.

V1:
This patch set is a proposal to change Exynos Drm Hdmi driver to a CDF
complaint panel driver. This migration serves 2 purposes. One is to eliminate
duplication due to v4l and drm hdmi drivers. Second is to add support for Hdmi
audio ALSA codec which is not possible with drm/v4l hdmi driver (specially for
exynos as hdmi audio and hdmi core registers are intermixed.).

This patch series is based on the Second RFC of CDF from Laurent Pinchart,
(http://lists.freedesktop.org/archives/dri-devel/2012-November/030888.html)
applied to 'for-next' branch at
git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung.git.

[PATCH 1/4] video: display: add event handling, set mode and hdmi ops to cdf
core

This patch adds:
1) Event Notification to CDF Core:
Adds simple event notification mechanism supports multiple
subscribers. This is used for hot-plug notification to the clients
of hdmi display i.e. exynos-drm and alsa-codec. CDF Core maintains
multiple subscriber list. When entity reports a event Core will
route it to all of them. Un-subscription is not implemented which
can be done if notification callback is Null.

2) set_mode to generic ops:
It is meaningful for a panel like hdmi which supports multiple
resolutions.

HDMI needs conversion of Display Modes to Standard Display Timings.
Though, it can be done within the driver but seems more meaningful
if set_mode is called with Timing Details provided by CDF Core.

3) Provision for platform specific interfaces through void *private in display
entity:

It has added void *private to display entity which can be used to
expose interfaces which are very much specific to a particular platform.

In exynos, hpd is connected to the soc via gpio bus. During initial
hdmi poweron, hpd interrupt is not raised as there is no change in the
gpio status. This is solved by providing a platform specific interface
which is queried by the drm to get the hpd state. This interface may
not be required by all platforms.

4) hdmi ops:
get_edid: to query raw EDID data and length from the panel.
check_mode: To check if a given mode is supported by exynos HDMI IP
"AND" Connected HDMI Sink (tv/monitor).
init_audio: Configure hdmi audio registers for Audio interface type
(i2s/ spdif), SF, Audio Channels, BPS.
set_audiostate: enable disable audio.

[PATCH 2/4] drm/edid: temporarily exposing generic edid-read interface from drm

It exposes generic interface from drm_edid.c to get the edid data and length
by any display entity. Once I get clear idea about edid handling in CDF, I need
to revert these temporary changes.

[PATCH 3/4] drm/exynos: moved drm hdmi driver to cdf framework

This patch implements exynos_hdmi_cdf.c which is a glue component between
exynos DRM and hdmi cdf panel. It is a platform driver register through
exynos_drm_drv.c. Exynos_hdmi.c is modified to register hdmi as display panel.
exynos_hdmi_cdf.c registers for exynos hdmi display entity and if successful,
proceeds for mode setting.

[PATCH 4/4] alsa/soc: add hdmi audio codec based on cdf

It registers hdmi-audio codec to the ALSA framework. This is the second client
to the hdmi panel. Once notified by the CDF Core it proceeds towards audio
setting and audio control. It also subscribes for hpd notification to implement
hpd related audio requirements.

Rahul Sharma (5):
  video: display: add event handling, set mode and hdmi ops to cdf core
  drm/edid: temporarily exposing generic edid-read interface from drm
  drm/exynos: moved drm hdmi driver to cdf framework
  alsa/soc: add hdmi audio codec based on cdf
  alsa/soc: add hdmi audio card using cdf based hdmi codec

 drivers/gpu/drm/drm_edid.c   |  88 ++
 drivers/gpu/drm/exynos/Kconfig   |   6 +
 drivers/gpu/drm/exynos/Makefile  |   1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  24 ++
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |   1 +
 drivers/gpu/drm/exynos/exynos_hdmi.c | 445 ---
 drivers/gpu/drm/exynos/exynos_hdmi_cdf.c | 370 +
 drivers/video/display/display-core.c |  85 ++
 include/video/display.h  | 111 +++-
 include/video/exynos_hdmi.h  |  25 ++
 sound/soc/codecs/Kconfig |   3 +
 sound/soc/codecs/Makefile|   2 +
 sound/soc/codec

[PATCH] tm6000: fix an uninitialized variable.

2013-02-07 Thread Hans Verkuil
tm6000_poll could use an uninitialized buf pointer. Move the buf-handling
code inside the 'if' that initializes the buf pointer.

Signed-off-by: Hans Verkuil 
Reported-by: Dan Carpenter 
---
 drivers/media/usb/tm6000/tm6000-video.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/tm6000/tm6000-video.c 
b/drivers/media/usb/tm6000/tm6000-video.c
index eab2341..1a68579 100644
--- a/drivers/media/usb/tm6000/tm6000-video.c
+++ b/drivers/media/usb/tm6000/tm6000-video.c
@@ -1455,14 +1455,14 @@ __tm6000_poll(struct file *file, struct 
poll_table_struct *wait)
if (list_empty(&fh->vb_vidq.stream))
return res | POLLERR;
buf = list_entry(fh->vb_vidq.stream.next, struct tm6000_buffer, 
vb.stream);
+   poll_wait(file, &buf->vb.done, wait);
+   if (buf->vb.state == VIDEOBUF_DONE ||
+   buf->vb.state == VIDEOBUF_ERROR)
+   return res | POLLIN | POLLRDNORM;
} else if (req_events & (POLLIN | POLLRDNORM)) {
/* read() capture */
return res | videobuf_poll_stream(file, &fh->vb_vidq, wait);
}
-   poll_wait(file, &buf->vb.done, wait);
-   if (buf->vb.state == VIDEOBUF_DONE ||
-   buf->vb.state == VIDEOBUF_ERROR)
-   return res | POLLIN | POLLRDNORM;
return res;
 }
 
-- 
1.7.10.4

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


Re: [media] tm6000: add support for control events and prio handling

2013-02-07 Thread Hans Verkuil
On Thu 7 February 2013 11:44:54 Dan Carpenter wrote:
> Hello Hans Verkuil,
> 
> The patch 770056c47fbb: "[media] tm6000: add support for control
> events and prio handling" from Sep 11, 2012, leads to the following
> Smatch warning:
> "drivers/media/usb/tm6000/tm6000-video.c:1462 __tm6000_poll()
>error: potentially dereferencing uninitialized 'buf'."
> 
> drivers/media/usb/tm6000/tm6000-video.c
>   1453  if (!is_res_read(fh->dev, fh)) {
>   1454  /* streaming capture */
>   1455  if (list_empty(&fh->vb_vidq.stream))
>   1456  return res | POLLERR;
>   1457  buf = list_entry(fh->vb_vidq.stream.next, struct 
> tm6000_buffer, vb.stream);
>   1458  } else if (req_events & (POLLIN | POLLRDNORM)) {
>   1459  /* read() capture */
>   1460  return res | videobuf_poll_stream(file, &fh->vb_vidq, 
> wait);
>   1461  }
> 
> If we don't hit either side of the if else statement then buf is
> uninitialized.

Oops! Thanks for catching this. I'll post a patch immediately.

Regards,

Hans

> 
>   1462  poll_wait(file, &buf->vb.done, wait);
>   1463  if (buf->vb.state == VIDEOBUF_DONE ||
>   1464  buf->vb.state == VIDEOBUF_ERROR)
>   1465  return res | POLLIN | POLLRDNORM;
>   1466  return res;
> 
> regards,
> dan carpenter
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


re: [media] tm6000: add support for control events and prio handling

2013-02-07 Thread Dan Carpenter
Hello Hans Verkuil,

The patch 770056c47fbb: "[media] tm6000: add support for control
events and prio handling" from Sep 11, 2012, leads to the following
Smatch warning:
"drivers/media/usb/tm6000/tm6000-video.c:1462 __tm6000_poll()
 error: potentially dereferencing uninitialized 'buf'."

drivers/media/usb/tm6000/tm6000-video.c
  1453  if (!is_res_read(fh->dev, fh)) {
  1454  /* streaming capture */
  1455  if (list_empty(&fh->vb_vidq.stream))
  1456  return res | POLLERR;
  1457  buf = list_entry(fh->vb_vidq.stream.next, struct 
tm6000_buffer, vb.stream);
  1458  } else if (req_events & (POLLIN | POLLRDNORM)) {
  1459  /* read() capture */
  1460  return res | videobuf_poll_stream(file, &fh->vb_vidq, 
wait);
  1461  }

If we don't hit either side of the if else statement then buf is
uninitialized.

  1462  poll_wait(file, &buf->vb.done, wait);
  1463  if (buf->vb.state == VIDEOBUF_DONE ||
  1464  buf->vb.state == VIDEOBUF_ERROR)
  1465  return res | POLLIN | POLLRDNORM;
  1466  return res;

regards,
dan carpenter

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


Re: [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap

2013-02-07 Thread Sumit Semwal

Hi John,

On Thursday 07 February 2013 05:33 AM, John Sheu wrote:

From: John Sheu 

Callers to dma_buf_mmap expect to fput() the vma struct's vm_file
themselves on failure.  Not restoring the struct's data on failure
causes a double-decrement of the vm_file's refcount.
Thanks for your patch; could you please re-send it to the correct, 
relevant lists and me (as the maintainer of dma-buf) rather than just to 
linux-media ml?


I just chanced to see this patch, otherwise it could easily have slipped 
past me (and other interested parties).


You could run scripts/get_maintainer.pl on your patch to find out the 
right lists / email IDs to CC.


Thanks and best regards,
~Sumit.


Signed-off-by: John Sheu 
---
  drivers/base/dma-buf.c | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index a3f79c4..01daf9c 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -446,6 +446,9 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
  int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
 unsigned long pgoff)
  {
+   struct file *oldfile;
+   int ret;
+
if (WARN_ON(!dmabuf || !vma))
return -EINVAL;

@@ -459,14 +462,21 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct 
vm_area_struct *vma,
return -EINVAL;

/* readjust the vma */
-   if (vma->vm_file)
-   fput(vma->vm_file);
-
+   oldfile = vma->vm_file;
vma->vm_file = get_file(dmabuf->file);

vma->vm_pgoff = pgoff;

-   return dmabuf->ops->mmap(dmabuf, vma);
+   ret = dmabuf->ops->mmap(dmabuf, vma);
+   if (ret) {
+   /* restore old parameters on failure */
+   vma->vm_file = oldfile;
+   fput(dmabuf->file);
+   } else {
+   if (oldfile)
+   fput(oldfile);
+   }
+   return ret;
  }
  EXPORT_SYMBOL_GPL(dma_buf_mmap);




--
To unsubscribe from this list: send the line "unsubscribe 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] dvb-usb: check for invalid length in ttusb_process_muxpack()

2013-02-07 Thread Dan Carpenter
This patch is driven by a static checker warning.

The ttusb_process_muxpack() function is only called from
ttusb_process_frame().  Before calling, it verifies that len >= 2.  The
problem is that len == 2 is not valid and would lead to an array
underflow.

Odd number values for len are also invalid and would lead to reading
past the end of the array.

Signed-off-by: Dan Carpenter 
---
v2: Moved the check from the caller into the function.  Added a check
for odd values.  Added an error message.  Increment the numinvalid
counter.

diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c 
b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
index 5b682cc..e407185 100644
--- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
@@ -561,6 +561,13 @@ static void ttusb_process_muxpack(struct ttusb *ttusb, 
const u8 * muxpack,
 {
u16 csum = 0, cc;
int i;
+
+   if (len < 4 || len & 0x1) {
+   pr_warn("%s: muxpack has invalid len %d\n", __func__, len);
+   numinvalid++;
+   return;
+   }
+
for (i = 0; i < len; i += 2)
csum ^= le16_to_cpup((__le16 *) (muxpack + i));
if (csum) {
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html