[PATCH] [media] s5p-mfc: Modify encoder buffer alloc sequence

2013-03-15 Thread Arun Kumar K
MFC v6 needs minimum number of capture buffers to be queued
for encoder depending on the stream type and profile.
For achieving this the sequence for allocating buffers at
the encoder is modified similar to that of decoder.
The new sequence is as follows:

1) Set format on CAPTURE plane
2) REQBUF on CAPTURE
3) QBUFS and STREAMON on CAPTURE
4) G_CTRL to get minimum buffers for OUTPUT plane
5) REQBUF on OUTPUT with the minimum buffers given by driver

This also fixes the crash happeninig during multi instance encoder-
decoder simultaneous run due to memory allocation happening from
interrupt context.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   98 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |7 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   95 +-
 4 files changed, 147 insertions(+), 54 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 4f6b553..46ca986 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -557,6 +557,16 @@ static struct mfc_control controls[] = {
.step = 1,
.default_value = 0,
},
+   {
+   .id = V4L2_CID_MIN_BUFFERS_FOR_OUTPUT,
+   .type = V4L2_CTRL_TYPE_INTEGER,
+   .name = Minimum number of output bufs,
+   .minimum = 1,
+   .maximum = 32,
+   .step = 1,
+   .default_value = 1,
+   .is_volatile = 1,
+   },
 };
 
 #define NUM_CTRLS ARRAY_SIZE(controls)
@@ -661,18 +671,17 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
vb2_buffer_done(dst_mb-b, VB2_BUF_STATE_DONE);
spin_unlock_irqrestore(dev-irqlock, flags);
}
-   if (IS_MFCV6(dev)) {
-   ctx-state = MFCINST_HEAD_PARSED; /* for INIT_BUFFER cmd */
-   } else {
+
+   if (!IS_MFCV6(dev)) {
ctx-state = MFCINST_RUNNING;
if (s5p_mfc_ctx_ready(ctx))
set_work_bit_irqsave(ctx);
s5p_mfc_hw_call(dev-mfc_ops, try_run, dev);
-   }
-
-   if (IS_MFCV6(dev))
+   } else {
ctx-dpb_count = s5p_mfc_hw_call(dev-mfc_ops,
get_enc_dpb_count, dev);
+   ctx-state = MFCINST_HEAD_PARSED;
+   }
 
return 0;
 }
@@ -1055,15 +1064,13 @@ static int vidioc_reqbufs(struct file *file, void *priv,
}
ctx-capture_state = QUEUE_BUFS_REQUESTED;
 
-   if (!IS_MFCV6(dev)) {
-   ret = s5p_mfc_hw_call(ctx-dev-mfc_ops,
-   alloc_codec_buffers, ctx);
-   if (ret) {
-   mfc_err(Failed to allocate encoding 
buffers\n);
-   reqbufs-count = 0;
-   ret = vb2_reqbufs(ctx-vq_dst, reqbufs);
-   return -ENOMEM;
-   }
+   ret = s5p_mfc_hw_call(ctx-dev-mfc_ops,
+   alloc_codec_buffers, ctx);
+   if (ret) {
+   mfc_err(Failed to allocate encoding buffers\n);
+   reqbufs-count = 0;
+   ret = vb2_reqbufs(ctx-vq_dst, reqbufs);
+   return -ENOMEM;
}
} else if (reqbufs-type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
if (ctx-output_state != QUEUE_FREE) {
@@ -1071,12 +1078,35 @@ static int vidioc_reqbufs(struct file *file, void *priv,
ctx-output_state);
return -EINVAL;
}
+
+   if (IS_MFCV6(dev)) {
+   if (!ctx-dpb_count) {
+   mfc_err(Streamon on CAPTURE plane should be\n
+   done first\n);
+   return -EINVAL;
+   }
+   /* Check for min encoder buffers */
+   if (reqbufs-count  ctx-dpb_count) {
+   mfc_err(Minimum %d output buffers needed\n,
+   ctx-dpb_count);
+   return -EINVAL;
+   }
+   }
+
ret = vb2_reqbufs(ctx-vq_src, reqbufs);
if (ret != 0) {
mfc_err(error in vb2_reqbufs() for E(S)\n);
return ret;
}
ctx-output_state = QUEUE_BUFS_REQUESTED;
+
+   if (IS_MFCV6(dev)) {
+   /* Run init encoder buffers */
+   s5p_mfc_hw_call(dev-mfc_ops, 

Re: [PATCH] [media] ir: IR_RX51 only works on OMAP2

2013-03-15 Thread Timo Kokkonen
On 03.14 2013 22:56:44, Arnd Bergmann wrote:
 This driver can be enabled on OMAP1 at the moment, which breaks
 allyesconfig for that platform. Let's mark it OMAP2PLUS-only
 in Kconfig, since that is the only thing it builds on.
 

Acked-by: Timo Kokkonen timo.t.kokko...@iki.fi

Thanks!

 Signed-off-by: Arnd Bergmann a...@arndb.de
 Cc: Mauro Carvalho Chehab mche...@redhat.com
 Cc: Timo Kokkonen timo.t.kokko...@iki.fi
 Cc: Tony Lindgren t...@atomide.com
 Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
 Cc: linux-media@vger.kernel.org
 ---
 Mauro, please apply for 3.9
 
  drivers/media/rc/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
 index 19f3563..5a79c33 100644
 --- a/drivers/media/rc/Kconfig
 +++ b/drivers/media/rc/Kconfig
 @@ -291,7 +291,7 @@ config IR_TTUSBIR
  
  config IR_RX51
   tristate Nokia N900 IR transmitter diode
 - depends on OMAP_DM_TIMER  LIRC  !ARCH_MULTIPLATFORM
 + depends on OMAP_DM_TIMER  ARCH_OMAP2PLUS  LIRC  
 !ARCH_MULTIPLATFORM
   ---help---
  Say Y or M here if you want to enable support for the IR
  transmitter diode built in the Nokia N900 (RX51) device.
 -- 
 1.8.1.2
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: msp3400 problem in linux-3.7.0

2013-03-15 Thread Benjamin Schindler

I just tried to apply the patch, but it does not apply cleanly:

metis linux # patch -p1  /home/benjamin/Downloads/bttv-patch.txt
patching file drivers/media/pci/bt8xx/bttv-driver.c
Hunk #1 FAILED at 2007.
Hunk #2 FAILED at 2024.
Hunk #3 succeeded at 4269 with fuzz 2 (offset 34 lines).
Hunk #4 succeeded at 4414 (offset 34 lines).
2 out of 4 hunks FAILED -- saving rejects to file 
drivers/media/pci/bt8xx/bttv-driver.c.rej

patching file drivers/media/pci/bt8xx/bttvp.h

I then tried applying it manually, which I think worked. But it did not 
fix the problem. Given that the patch did not apply cleanly, may be I 
should either use the media git tree or wait for 3.10.


I just realized that this was on a 3.7.10 kernel (not 3.7.0, but that 
probably does not make much of a difference)


Regards
Benjamin

On 14.03.2013 08:44, Hans Verkuil wrote:

On Thu March 14 2013 08:13:29 Benjamin Schindler wrote:

Hi Hans

Thank you for the prompt response. I will try this once I'm home again.
Which patch is responsible for fixing it? Just so I can track it once it
lands upstream.


There is a whole series of bttv fixes that I did that will appear in 3.10.

But the patch that is probably responsible for fixing it is this one:

http://git.linuxtv.org/media_tree.git/commit/76ea992a036c4a5d3bc606a79ef775dd32fd3daa

I say 'probably' because I am not 100% certain that that is the main fix.
I'm 99% certain, though :-)

As mentioned, it was part of a much longer patch series, so there may be other
patches involved in this particular problem, but I don't think so.

If you can perhaps test just that single patch then that would be useful
information. If that fixes the problem then that's a candidate for 'stable'
kernels.


I have one more question - the wiki states the the WinTV-HVR-5500 is not
yet supported (as of June 2011) - is there an update on this? It's the
only DVB-C card I can buy in the local stores here


No idea. I do V4L2, not DVB :-) Hopefully someone else knows.

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: msp3400 problem in linux-3.7.0

2013-03-15 Thread Hans Verkuil
On Fri March 15 2013 10:56:51 Benjamin Schindler wrote:
 I just tried to apply the patch, but it does not apply cleanly:
 
 metis linux # patch -p1  /home/benjamin/Downloads/bttv-patch.txt
 patching file drivers/media/pci/bt8xx/bttv-driver.c
 Hunk #1 FAILED at 2007.
 Hunk #2 FAILED at 2024.
 Hunk #3 succeeded at 4269 with fuzz 2 (offset 34 lines).
 Hunk #4 succeeded at 4414 (offset 34 lines).
 2 out of 4 hunks FAILED -- saving rejects to file 
 drivers/media/pci/bt8xx/bttv-driver.c.rej
 patching file drivers/media/pci/bt8xx/bttvp.h
 
 I then tried applying it manually, which I think worked. But it did not 
 fix the problem. Given that the patch did not apply cleanly, may be I 
 should either use the media git tree or wait for 3.10.

You might want to try the media git tree (if only so that we know that it
really fixes your problem). 3.10 will be another 5 months or so before that
is released.

Regards,

Hans

 
 I just realized that this was on a 3.7.10 kernel (not 3.7.0, but that 
 probably does not make much of a difference)
 
 Regards
 Benjamin
 
 On 14.03.2013 08:44, Hans Verkuil wrote:
  On Thu March 14 2013 08:13:29 Benjamin Schindler wrote:
  Hi Hans
 
  Thank you for the prompt response. I will try this once I'm home again.
  Which patch is responsible for fixing it? Just so I can track it once it
  lands upstream.
 
  There is a whole series of bttv fixes that I did that will appear in 3.10.
 
  But the patch that is probably responsible for fixing it is this one:
 
  http://git.linuxtv.org/media_tree.git/commit/76ea992a036c4a5d3bc606a79ef775dd32fd3daa
 
  I say 'probably' because I am not 100% certain that that is the main fix.
  I'm 99% certain, though :-)
 
  As mentioned, it was part of a much longer patch series, so there may be 
  other
  patches involved in this particular problem, but I don't think so.
 
  If you can perhaps test just that single patch then that would be useful
  information. If that fixes the problem then that's a candidate for 'stable'
  kernels.
 
  I have one more question - the wiki states the the WinTV-HVR-5500 is not
  yet supported (as of June 2011) - is there an update on this? It's the
  only DVB-C card I can buy in the local stores here
 
  No idea. I do V4L2, not DVB :-) Hopefully someone else knows.
 
  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
 
--
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 2/5] v4l2: add const to argument of write-only s_tuner ioctl.

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

This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/cx25840/cx25840-core.c |2 +-
 drivers/media/i2c/msp3400-driver.c   |2 +-
 drivers/media/i2c/saa6588.c  |2 +-
 drivers/media/i2c/saa717x.c  |2 +-
 drivers/media/i2c/tda9840.c  |2 +-
 drivers/media/i2c/tvaudio.c  |2 +-
 drivers/media/i2c/vp27smpx.c |2 +-
 drivers/media/pci/bt8xx/bttv-driver.c|   11 +++
 drivers/media/pci/cx18/cx18-av-core.c|2 +-
 drivers/media/pci/cx18/cx18-ioctl.c  |2 +-
 drivers/media/pci/cx23885/cx23885-417.c  |2 +-
 drivers/media/pci/cx23885/cx23885-video.c|2 +-
 drivers/media/pci/cx25821/cx25821-video.c|2 +-
 drivers/media/pci/cx25821/cx25821-video.h|2 +-
 drivers/media/pci/cx88/cx88-blackbird.c  |2 +-
 drivers/media/pci/cx88/cx88-video.c  |9 ++---
 drivers/media/pci/ivtv/ivtv-gpio.c   |2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c  |2 +-
 drivers/media/pci/saa7134/saa7134-video.c|4 ++--
 drivers/media/pci/saa7146/mxb.c  |2 +-
 drivers/media/pci/saa7164/saa7164-encoder.c  |2 +-
 drivers/media/pci/saa7164/saa7164-vbi.c  |2 +-
 drivers/media/pci/ttpci/av7110_v4l.c |2 +-
 drivers/media/radio/dsbr100.c|2 +-
 drivers/media/radio/radio-cadet.c|2 +-
 drivers/media/radio/radio-isa.c  |2 +-
 drivers/media/radio/radio-ma901.c|2 +-
 drivers/media/radio/radio-miropcm20.c|8 +---
 drivers/media/radio/radio-mr800.c|2 +-
 drivers/media/radio/radio-sf16fmi.c  |2 +-
 drivers/media/radio/radio-tea5764.c  |2 +-
 drivers/media/radio/radio-tea5777.c  |7 +++
 drivers/media/radio/radio-timb.c |2 +-
 drivers/media/radio/radio-wl1273.c   |2 +-
 drivers/media/radio/si470x/radio-si470x-common.c |2 +-
 drivers/media/radio/tef6862.c|2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c  |2 +-
 drivers/media/usb/au0828/au0828-video.c  |4 +---
 drivers/media/usb/cx231xx/cx231xx-video.c|4 ++--
 drivers/media/usb/cx231xx/cx231xx.h  |2 +-
 drivers/media/usb/em28xx/em28xx-video.c  |4 ++--
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c |2 +-
 drivers/media/usb/tlg2300/pd-radio.c |2 +-
 drivers/media/usb/tlg2300/pd-video.c |2 +-
 drivers/media/usb/tm6000/tm6000-video.c  |8 ++--
 drivers/media/usb/usbvision/usbvision-video.c|2 +-
 drivers/media/v4l2-core/tuner-core.c |2 +-
 drivers/staging/media/go7007/go7007-v4l2.c   |2 +-
 include/media/v4l2-ioctl.h   |2 +-
 include/media/v4l2-subdev.h  |2 +-
 sound/i2c/other/tea575x-tuner.c  |2 +-
 51 files changed, 68 insertions(+), 75 deletions(-)

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c 
b/drivers/media/i2c/cx25840/cx25840-core.c
index f4339ed..234b7c6 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -1881,7 +1881,7 @@ static int cx25840_g_tuner(struct v4l2_subdev *sd, struct 
v4l2_tuner *vt)
return 0;
 }
 
-static int cx25840_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
+static int cx25840_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt)
 {
struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/i2c/msp3400-driver.c 
b/drivers/media/i2c/msp3400-driver.c
index 77053ba..54a9dd3 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -535,7 +535,7 @@ static int msp_g_tuner(struct v4l2_subdev *sd, struct 
v4l2_tuner *vt)
return 0;
 }
 
-static int msp_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
+static int msp_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt)
 {
struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/i2c/saa6588.c b/drivers/media/i2c/saa6588.c
index 0caac50..b4e1ccb 100644
--- a/drivers/media/i2c/saa6588.c
+++ b/drivers/media/i2c/saa6588.c
@@ -435,7 +435,7 @@ static int saa6588_g_tuner(struct v4l2_subdev *sd, struct 
v4l2_tuner *vt)
return 0;
 }
 
-static int saa6588_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
+static int saa6588_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt)
 {
struct saa6588 *s = to_saa6588(sd);
 
diff 

[REVIEW PATCH 1/5] v4l2: add const to argument of write-only s_frequency ioctl.

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

This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/cx25840/cx25840-core.c |2 +-
 drivers/media/i2c/msp3400-driver.c   |2 +-
 drivers/media/i2c/tvaudio.c  |2 +-
 drivers/media/i2c/upd64031a.c|2 +-
 drivers/media/i2c/wm8775.c   |2 +-
 drivers/media/pci/bt8xx/bttv-driver.c|   14 ---
 drivers/media/pci/cx18/cx18-av-core.c|2 +-
 drivers/media/pci/cx18/cx18-ioctl.c  |2 +-
 drivers/media/pci/cx18/cx18-ioctl.h  |2 +-
 drivers/media/pci/cx23885/cx23885-417.c  |2 +-
 drivers/media/pci/cx23885/cx23885-video.c|8 ++--
 drivers/media/pci/cx23885/cx23885.h  |2 +-
 drivers/media/pci/cx25821/cx25821-video.c|4 +-
 drivers/media/pci/cx25821/cx25821-video.h|4 +-
 drivers/media/pci/cx88/cx88-blackbird.c  |2 +-
 drivers/media/pci/cx88/cx88-video.c  |   10 +++--
 drivers/media/pci/cx88/cx88.h|2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c  |2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.h  |2 +-
 drivers/media/pci/saa7134/saa7134-video.c|2 +-
 drivers/media/pci/saa7146/mxb.c  |4 +-
 drivers/media/pci/saa7164/saa7164-encoder.c  |2 +-
 drivers/media/pci/saa7164/saa7164-vbi.c  |2 +-
 drivers/media/pci/ttpci/av7110_v4l.c |2 +-
 drivers/media/radio/dsbr100.c|2 +-
 drivers/media/radio/radio-cadet.c|   46 +++---
 drivers/media/radio/radio-isa.c  |9 +++--
 drivers/media/radio/radio-keene.c|9 +++--
 drivers/media/radio/radio-ma901.c|2 +-
 drivers/media/radio/radio-miropcm20.c|4 +-
 drivers/media/radio/radio-mr800.c|2 +-
 drivers/media/radio/radio-sf16fmi.c  |2 +-
 drivers/media/radio/radio-si4713.c   |2 +-
 drivers/media/radio/radio-tea5764.c  |2 +-
 drivers/media/radio/radio-tea5777.c  |2 +-
 drivers/media/radio/radio-timb.c |2 +-
 drivers/media/radio/radio-wl1273.c   |2 +-
 drivers/media/radio/si470x/radio-si470x-common.c |2 +-
 drivers/media/radio/si4713-i2c.c |5 +--
 drivers/media/radio/tef6862.c|2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c  |6 +--
 drivers/media/usb/au0828/au0828-video.c  |2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c|7 ++--
 drivers/media/usb/cx231xx/cx231xx.h  |2 +-
 drivers/media/usb/em28xx/em28xx-video.c  |7 ++--
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c |2 +-
 drivers/media/usb/tlg2300/pd-radio.c |2 +-
 drivers/media/usb/tlg2300/pd-video.c |5 ++-
 drivers/media/usb/tm6000/tm6000-video.c  |2 +-
 drivers/media/usb/usbvision/usbvision-video.c|2 +-
 drivers/media/v4l2-core/tuner-core.c |2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c |2 +-
 drivers/staging/media/go7007/go7007-v4l2.c   |2 +-
 include/media/v4l2-ioctl.h   |2 +-
 include/media/v4l2-subdev.h  |2 +-
 sound/i2c/other/tea575x-tuner.c  |4 +-
 56 files changed, 116 insertions(+), 110 deletions(-)

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c 
b/drivers/media/i2c/cx25840/cx25840-core.c
index f4149eb..f4339ed 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -1835,7 +1835,7 @@ static int cx25840_s_audio_routing(struct v4l2_subdev *sd,
return set_input(client, state-vid_input, input);
 }
 
-static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency 
*freq)
+static int cx25840_s_frequency(struct v4l2_subdev *sd, const struct 
v4l2_frequency *freq)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
diff --git a/drivers/media/i2c/msp3400-driver.c 
b/drivers/media/i2c/msp3400-driver.c
index 766305f..77053ba 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -445,7 +445,7 @@ static int msp_s_radio(struct v4l2_subdev *sd)
return 0;
 }
 
-static int msp_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
+static int msp_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequency 
*freq)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c
index 4c91b35..4b12c51 100644
--- a/drivers/media/i2c/tvaudio.c
+++ b/drivers/media/i2c/tvaudio.c
@@ -1817,7 +1817,7 @@ static int tvaudio_s_std(struct v4l2_subdev *sd, 

[REVIEW PATCH 3/5] v4l2: pass std by value to the write-only s_std ioctl.

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

This ioctl is defined as IOW, so pass the argument by value instead of by
reference. I could have chosen to add const instead, but this is 1) easier
to handle in drivers and 2) consistent with the s_std subdev operation.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/common/saa7146/saa7146_video.c|4 ++--
 drivers/media/parport/pms.c |4 ++--
 drivers/media/pci/bt8xx/bttv-driver.c   |6 +++---
 drivers/media/pci/cx18/cx18-driver.c|2 +-
 drivers/media/pci/cx18/cx18-ioctl.c |   10 +-
 drivers/media/pci/cx18/cx18-ioctl.h |2 +-
 drivers/media/pci/cx23885/cx23885-417.c |6 +++---
 drivers/media/pci/cx23885/cx23885-video.c   |4 ++--
 drivers/media/pci/cx25821/cx25821-video.c   |6 +++---
 drivers/media/pci/cx25821/cx25821-video.h   |2 +-
 drivers/media/pci/cx88/cx88-blackbird.c |4 ++--
 drivers/media/pci/cx88/cx88-video.c |4 ++--
 drivers/media/pci/ivtv/ivtv-driver.c|4 ++--
 drivers/media/pci/ivtv/ivtv-firmware.c  |4 ++--
 drivers/media/pci/ivtv/ivtv-ioctl.c |   18 +-
 drivers/media/pci/ivtv/ivtv-ioctl.h |4 ++--
 drivers/media/pci/saa7134/saa7134-empress.c |2 +-
 drivers/media/pci/saa7134/saa7134-video.c   |   14 +++---
 drivers/media/pci/saa7134/saa7134.h |2 +-
 drivers/media/pci/saa7164/saa7164-encoder.c |8 
 drivers/media/pci/saa7164/saa7164-vbi.c |8 
 drivers/media/pci/sta2x11/sta2x11_vip.c |   18 +-
 drivers/media/pci/zoran/zoran_driver.c  |4 ++--
 drivers/media/platform/blackfin/bfin_capture.c  |6 +++---
 drivers/media/platform/davinci/vpbe.c   |8 
 drivers/media/platform/davinci/vpbe_display.c   |2 +-
 drivers/media/platform/davinci/vpfe_capture.c   |   12 ++--
 drivers/media/platform/davinci/vpif_capture.c   |6 +++---
 drivers/media/platform/davinci/vpif_display.c   |   10 +-
 drivers/media/platform/fsl-viu.c|6 +++---
 drivers/media/platform/marvell-ccic/mcam-core.c |2 +-
 drivers/media/platform/s5p-tv/mixer_video.c |4 ++--
 drivers/media/platform/sh_vou.c |   12 ++--
 drivers/media/platform/soc_camera/soc_camera.c  |4 ++--
 drivers/media/platform/timblogiw.c  |6 +++---
 drivers/media/platform/via-camera.c |2 +-
 drivers/media/platform/vino.c   |   10 +-
 drivers/media/usb/au0828/au0828-video.c |4 ++--
 drivers/media/usb/cx231xx/cx231xx-417.c |4 ++--
 drivers/media/usb/cx231xx/cx231xx-video.c   |6 +++---
 drivers/media/usb/em28xx/em28xx-video.c |8 
 drivers/media/usb/hdpvr/hdpvr-video.c   |4 ++--
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c|4 ++--
 drivers/media/usb/s2255/s2255drv.c  |8 
 drivers/media/usb/stk1160/stk1160-v4l.c |4 ++--
 drivers/media/usb/tlg2300/pd-video.c|8 
 drivers/media/usb/tm6000/tm6000-video.c |6 +++---
 drivers/media/usb/usbvision/usbvision-video.c   |4 ++--
 drivers/media/v4l2-core/v4l2-ioctl.c|6 +++---
 drivers/staging/media/davinci_vpfe/vpfe_video.c |6 +++---
 drivers/staging/media/dt3155v4l/dt3155v4l.c |4 ++--
 drivers/staging/media/go7007/go7007-v4l2.c  |   16 
 drivers/staging/media/solo6x10/v4l2-enc.c   |2 +-
 drivers/staging/media/solo6x10/v4l2.c   |2 +-
 include/media/davinci/vpbe.h|2 +-
 include/media/v4l2-ioctl.h  |2 +-
 56 files changed, 165 insertions(+), 165 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_video.c 
b/drivers/media/common/saa7146/saa7146_video.c
index 4143d61..fe907f2 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -832,7 +832,7 @@ static int vidioc_g_std(struct file *file, void *fh, 
v4l2_std_id *norm)
}
*/
 
-static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id)
+static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id id)
 {
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)-dev;
struct saa7146_vv *vv = dev-vv_data;
@@ -856,7 +856,7 @@ static int vidioc_s_std(struct file *file, void *fh, 
v4l2_std_id *id)
}
 
for (i = 0; i  dev-ext_vv_data-num_stds; i++)
-   if (*id  dev-ext_vv_data-stds[i].id)
+   if (id  dev-ext_vv_data-stds[i].id)
break;
if (i != dev-ext_vv_data-num_stds) {
vv-standard = dev-ext_vv_data-stds[i];
diff --git a/drivers/media/parport/pms.c b/drivers/media/parport/pms.c
index 77f9c92..66c957a 

[REVIEW PATCH 0/5] v4l2: constify _IOW ioctls

2013-03-15 Thread Hans Verkuil
This is the second and last phase of ensuring that the arguments of write-only
ioctls in V4L2 are const. The first phase was 4-5 months ago and added const
to s_crop, s_modulator, s_audio, s_audout, (un)subscribe_event, s_freq_hw_seek,
s_jpegcomp and s_fbuf.

This second phase adds const to s_frequency, s_tuner, s_std and s_register.
Actually, for s_std it doesn't add const but changes it to pass the std by
value which is more consistent in that particular case.

As a result drivers will be aware when they are implementing write-only ioctls
(and I saw a few drivers attempting to return data back to the user), and the
v4l2 core will know that drivers won't change the argument of a write-only
ioctls which simplifies the core debug code.

The changes have been compile-tested with the linux-media daily build but
I may have missed some more exotic architectures.

Ideally I would like to have this merged fairly early on so we have enough
time to shake out any remaining compile problems.

Regards,

Hans

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


[REVIEW PATCH 5/5] v4l2-ioctl: simplify debug code.

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

The core debug code can now be simplified since all the write-only ioctls are
now const and will not modify the data they pass to the drivers.

So instead of logging write-only ioctls before the driver is called this can
now be done afterwards, which is cleaner when it comes to error reporting as
well.

This also fixes a logic error in the debugging code where there was one 'else'
too many.

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

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2abd13a..b3fe148 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2147,11 +2147,6 @@ static long __video_do_ioctl(struct file *file,
}
 
write_only = _IOC_DIR(cmd) == _IOC_WRITE;
-   if (write_only  debug  V4L2_DEBUG_IOCTL) {
-   v4l_printk_ioctl(video_device_node_name(vfd), cmd);
-   pr_cont(: );
-   info-debug(arg, write_only);
-   }
if (info-flags  INFO_FL_STD) {
typedef int (*vidioc_op)(struct file *file, void *fh, void *p);
const void *p = vfd-ioctl_ops;
@@ -2170,16 +2165,10 @@ static long __video_do_ioctl(struct file *file,
 
 done:
if (debug) {
-   if (write_only  debug  V4L2_DEBUG_IOCTL) {
-   if (ret  0)
-   printk(KERN_DEBUG %s: error %ld\n,
-   video_device_node_name(vfd), ret);
-   return ret;
-   }
v4l_printk_ioctl(video_device_node_name(vfd), cmd);
if (ret  0)
-   pr_cont(: error %ld\n, ret);
-   else if (debug == V4L2_DEBUG_IOCTL)
+   pr_cont(: error %ld, ret);
+   if (debug == V4L2_DEBUG_IOCTL)
pr_cont(\n);
else if (_IOC_DIR(cmd) == _IOC_NONE)
info-debug(arg, write_only);
-- 
1.7.10.4

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


[REVIEW PATCH 4/5] v4l2: add const to argument of write-only s_register ioctl.

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

This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/dvb-frontends/au8522_decoder.c|2 +-
 drivers/media/i2c/ad9389b.c |2 +-
 drivers/media/i2c/adv7183.c |2 +-
 drivers/media/i2c/adv7604.c |2 +-
 drivers/media/i2c/ak881x.c  |2 +-
 drivers/media/i2c/cs5345.c  |2 +-
 drivers/media/i2c/cx25840/cx25840-core.c|2 +-
 drivers/media/i2c/m52790.c  |2 +-
 drivers/media/i2c/mt9m032.c |2 +-
 drivers/media/i2c/mt9v011.c |2 +-
 drivers/media/i2c/ov7670.c  |2 +-
 drivers/media/i2c/saa7115.c |2 +-
 drivers/media/i2c/saa7127.c |2 +-
 drivers/media/i2c/saa717x.c |2 +-
 drivers/media/i2c/soc_camera/mt9m001.c  |2 +-
 drivers/media/i2c/soc_camera/mt9m111.c  |2 +-
 drivers/media/i2c/soc_camera/mt9t031.c  |2 +-
 drivers/media/i2c/soc_camera/mt9t112.c  |2 +-
 drivers/media/i2c/soc_camera/mt9v022.c  |2 +-
 drivers/media/i2c/soc_camera/ov2640.c   |2 +-
 drivers/media/i2c/soc_camera/ov5642.c   |2 +-
 drivers/media/i2c/soc_camera/ov6650.c   |2 +-
 drivers/media/i2c/soc_camera/ov772x.c   |2 +-
 drivers/media/i2c/soc_camera/ov9640.c   |2 +-
 drivers/media/i2c/soc_camera/ov9740.c   |2 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c   |2 +-
 drivers/media/i2c/soc_camera/tw9910.c   |2 +-
 drivers/media/i2c/tvp5150.c |2 +-
 drivers/media/i2c/tvp7002.c |2 +-
 drivers/media/i2c/upd64031a.c   |2 +-
 drivers/media/i2c/upd64083.c|2 +-
 drivers/media/i2c/vs6624.c  |2 +-
 drivers/media/pci/bt8xx/bttv-driver.c   |5 +--
 drivers/media/pci/cx18/cx18-av-core.c   |2 +-
 drivers/media/pci/cx18/cx18-ioctl.c |   36 +++-
 drivers/media/pci/cx23885/cx23885-ioctl.c   |9 ++--
 drivers/media/pci/cx23885/cx23885-ioctl.h   |2 +-
 drivers/media/pci/cx23885/cx23888-ir.c  |2 +-
 drivers/media/pci/cx25821/cx25821-video.c   |2 +-
 drivers/media/pci/cx25821/cx25821-video.h   |2 +-
 drivers/media/pci/cx88/cx88-video.c |2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c |   51 ---
 drivers/media/pci/saa7134/saa7134-video.c   |2 +-
 drivers/media/pci/saa7146/mxb.c |3 +-
 drivers/media/pci/saa7164/saa7164-encoder.c |2 +-
 drivers/media/platform/blackfin/bfin_capture.c  |2 +-
 drivers/media/platform/davinci/vpbe_display.c   |2 +-
 drivers/media/platform/davinci/vpif_capture.c   |3 +-
 drivers/media/platform/davinci/vpif_display.c   |3 +-
 drivers/media/platform/marvell-ccic/mcam-core.c |2 +-
 drivers/media/platform/sh_vou.c |2 +-
 drivers/media/platform/soc_camera/soc_camera.c  |2 +-
 drivers/media/usb/au0828/au0828-video.c |2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c   |2 +-
 drivers/media/usb/cx231xx/cx231xx.h |2 +-
 drivers/media/usb/em28xx/em28xx-video.c |2 +-
 drivers/media/usb/gspca/gspca.c |2 +-
 drivers/media/usb/gspca/gspca.h |8 ++--
 drivers/media/usb/gspca/pac7302.c   |2 +-
 drivers/media/usb/gspca/sn9c20x.c   |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.h |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c|2 +-
 drivers/media/usb/stk1160/stk1160-v4l.c |2 +-
 drivers/media/usb/usbvision/usbvision-video.c   |2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c|2 +-
 include/media/v4l2-ioctl.h  |2 +-
 include/media/v4l2-subdev.h |2 +-
 68 files changed, 115 insertions(+), 123 deletions(-)

diff --git a/drivers/media/dvb-frontends/au8522_decoder.c 
b/drivers/media/dvb-frontends/au8522_decoder.c
index 5243ba6..526902b 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -583,7 +583,7 @@ static int au8522_g_register(struct v4l2_subdev *sd,
 }
 
 static int au8522_s_register(struct v4l2_subdev *sd,
-struct v4l2_dbg_register *reg)
+const struct v4l2_dbg_register *reg)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct au8522_state *state = to_state(sd);
diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index c2886b6..58344b6 100644
--- 

Re: [PATCH 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-15 Thread Fabio Porcedda
On Thu, Mar 14, 2013 at 3:06 PM, Sascha Hauer s.ha...@pengutronix.de wrote:
 On Thu, Mar 14, 2013 at 01:58:05PM +, Arnd Bergmann wrote:
 On Thursday 14 March 2013, Fabio Porcedda wrote:
  This patch converts the drivers to use the
  module_platform_driver_probe() macro which makes the code smaller and
  a bit simpler.
 
  Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
  Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
  Cc: Arnd Bergmann a...@arndb.de
  ---
   drivers/misc/atmel_pwm.c  | 12 +---
   drivers/misc/ep93xx_pwm.c | 13 +
   2 files changed, 2 insertions(+), 23 deletions(-)

 The patch itself seems fine, but there are two issues around it:

 * The PWM drivers should really get moved to drivers/pwm and converted to 
 the new
   PWM subsystem. I don't know if Hartley or Hans-Christian have plans to do
   that already.

 * Regarding the use of module_platform_driver_probe, I'm a little worried 
 about
   the interactions with deferred probing. I don't think there are any 
 regressions,
   but we should probably make people aware that one cannot return 
 -EPROBE_DEFER
   from a platform_driver_probe function.

The use of module_platform_driver_probe() doesn't change anything about that,
it's exactly the same thing as using return platform_driver_probe().
I'm right or I'm missing something? Maybe are you just speaking about
the misuse of platform_driver_probe?

Best regards
Fabio Porcedda


 I'm worried about this aswell. I think platform_driver_probe shouldn't
 be used anymore. Even if a driver does not explicitly make use of
 -EPROBE_DEFER, it leaks in very quickly if a driver for example uses a
 regulator and just returns the error value from regulator_get.

 Sascha

 --
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
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 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-15 Thread Arnd Bergmann
On Friday 15 March 2013, Fabio Porcedda wrote:
  * Regarding the use of module_platform_driver_probe, I'm a little worried 
  about
the interactions with deferred probing. I don't think there are any 
  regressions,
but we should probably make people aware that one cannot return 
  -EPROBE_DEFER
from a platform_driver_probe function.
 
 The use of module_platform_driver_probe() doesn't change anything about that,
 it's exactly the same thing as using return platform_driver_probe().
 I'm right or I'm missing something? Maybe are you just speaking about
 the misuse of platform_driver_probe?

Yes, that was what I meant. The point is that if we need to review or remove
all uses of platform_driver_probe, it would be better not to introduce a
module_platform_driver_probe() interface to make it easier to use.

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


Re: [REVIEW PATCH 1/5] v4l2: add const to argument of write-only s_frequency ioctl.

2013-03-15 Thread Laurent Pinchart
Hi Hans,

Thanks for the patch.

On Friday 15 March 2013 11:27:21 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 This ioctl is defined as IOW, so pass the argument as const.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

[snip]

 diff --git a/drivers/media/radio/radio-isa.c
 b/drivers/media/radio/radio-isa.c index fe0a4f8..0c1e27b 100644
 --- a/drivers/media/radio/radio-isa.c
 +++ b/drivers/media/radio/radio-isa.c
 @@ -102,17 +102,18 @@ static int radio_isa_s_tuner(struct file *file, void
 *priv, }
 
  static int radio_isa_s_frequency(struct file *file, void *priv,
 - struct v4l2_frequency *f)
 + const struct v4l2_frequency *f)
  {
   struct radio_isa_card *isa = video_drvdata(file);
 + u32 freq = f-frequency;
   int res;
 
   if (f-tuner != 0 || f-type != V4L2_TUNER_RADIO)
   return -EINVAL;
 - f-frequency = clamp(f-frequency, FREQ_LOW, FREQ_HIGH);
 - res = isa-drv-ops-s_frequency(isa, f-frequency);
 + freq = clamp(freq, FREQ_LOW, FREQ_HIGH);

Micro-optimization here, you could just declare

u32 freq;

above and then write

freq = clamp(f-frequency, FREQ_LOW, FREQ_HIGH);

 + res = isa-drv-ops-s_frequency(isa, freq);
   if (res == 0)
 - isa-freq = f-frequency;
 + isa-freq = freq;
   return res;
  }
 
 diff --git a/drivers/media/radio/radio-keene.c
 b/drivers/media/radio/radio-keene.c index 296941a..a90b7a8 100644
 --- a/drivers/media/radio/radio-keene.c
 +++ b/drivers/media/radio/radio-keene.c
 @@ -82,9 +82,12 @@ static inline struct keene_device *to_keene_dev(struct
 v4l2_device *v4l2_dev) /* Set frequency (if non-0), PA, mute and turn
 on/off the FM transmitter. */ static int keene_cmd_main(struct keene_device
 *radio, unsigned freq, bool play) {
 - unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
 + unsigned short freq_send;
   int ret;
 
 + if (freq)
 + freq = clamp(freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);

There was no similar if (freq) in the function below, doesn't this change the 
behaviour ?

 + freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
   radio-buffer[0] = 0x00;
   radio-buffer[1] = 0x50;
   radio-buffer[2] = (freq_send  8)  0xff;
 @@ -215,14 +218,12 @@ static int vidioc_s_modulator(struct file *file, void
 *priv, }
 
  static int vidioc_s_frequency(struct file *file, void *priv,
 - struct v4l2_frequency *f)
 + const struct v4l2_frequency *f)
  {
   struct keene_device *radio = video_drvdata(file);
 
   if (f-tuner != 0 || f-type != V4L2_TUNER_RADIO)
   return -EINVAL;
 - f-frequency = clamp(f-frequency,
 - FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);
   return keene_cmd_main(radio, f-frequency, true);
  }
 

[snip]

 diff --git a/drivers/media/radio/radio-miropcm20.c
 b/drivers/media/radio/radio-miropcm20.c index 3d0ff44..2b8d31d 100644
 --- a/drivers/media/radio/radio-miropcm20.c
 +++ b/drivers/media/radio/radio-miropcm20.c
 @@ -131,14 +131,14 @@ static int vidioc_g_frequency(struct file *file, void
 *priv,
 
 
  static int vidioc_s_frequency(struct file *file, void *priv,
 - struct v4l2_frequency *f)
 + const struct v4l2_frequency *f)
  {
   struct pcm20 *dev = video_drvdata(file);
 
   if (f-tuner != 0 || f-type != V4L2_TUNER_RADIO)
   return -EINVAL;
 
 - dev-freq = clamp(f-frequency, 87 * 16000U, 108 * 16000U);
 + dev-freq = clamp_t(u32, f-frequency, 87 * 16000U, 108 * 16000U);

f-frequency and the two clamp boundaries are unsigned, did clamp() throw a 
warning ?

   pcm20_setfreq(dev, dev-freq);
   return 0;
  }

[snip]

 diff --git a/drivers/media/usb/tlg2300/pd-video.c
 b/drivers/media/usb/tlg2300/pd-video.c index dab0ca3..8ef7c8c 100644
 --- a/drivers/media/usb/tlg2300/pd-video.c
 +++ b/drivers/media/usb/tlg2300/pd-video.c
 @@ -1079,10 +1079,11 @@ static int set_frequency(struct poseidon *pd, u32
 *frequency) }
 
  static int vidioc_s_frequency(struct file *file, void *fh,
 - struct v4l2_frequency *freq)
 + const struct v4l2_frequency *freq)
  {
   struct front_face *front = fh;
   struct poseidon *pd = front-pd;
 + u32 frequency = freq-frequency;
 
   if (freq-tuner)
   return -EINVAL;
 @@ -1090,7 +1091,7 @@ static int vidioc_s_frequency(struct file *file, void
 *fh, pd-pm_suspend = pm_video_suspend;
   pd-pm_resume = pm_video_resume;
  #endif
 - return set_frequency(pd, freq-frequency);
 + return set_frequency(pd, frequency);

Wouldn't it be better to pass the frequency by value to set_frequency() ?

  }
 

[snip]

 diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
 index b137a5e..1a82a50 100644
 --- a/include/media/v4l2-subdev.h
 

Re: dvb-apps: Additional channels for Netherlands

2013-03-15 Thread Oliver Schinagl

On 15-03-13 00:33, Dmitry Katsubo wrote:

On 11.03.2013 13:10, Oliver Schinagl wrote:

and what is interesting the comments refer to radio-stations only.

TV zenderlijst is pure DVB-T frequencies. I have not found a single FM
frequency there. Note that if you open it via their website, there are
two lists, FM zenderlijst and TV zenderlijst.

I see. I think I have overlooked something.


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

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

Great! Thanks for updating the nl-All file. What will be the dvb-apps
future version which will include the fix?
We've split the dvb-tables from dvb-apps, so never :p I'll work in the 
next few weeks on having 'releases' when there are changes so that 
package maintainers can start picking it up.


Also what is the relation between git repo you've referred and this repo:
http://linuxtv.org/hg/dvb-apps/log/f3a70b206f0f/util/scan/dvb-t/nl-All
?


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

You're absolutely correct. Perhaps that is the reason why I cannot watch
TV on 522 MHz.

Very likly ;)



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

Still I cannot make them working. More exactly:

This works (722 MHz):
xine dvb://Nederland 1
xine dvb://Nederland 2
xine dvb://Nederland 3

These do not (522 MHz and 698 MHz):
xine dvb://Nickelodeon
xine dvb://RTL 4
...

I don't 522 or 698 MHz, RTL4 is on 768 MHz here in Eindhoven.

Try scanning with w_scan; wscan tells you exactly where what exactly is. 
It can produce an inital scanning file. Send me and I'll fix it up for you.


It can be the case the signal is better on 722 MHz... Could you share
your channels.conf? Are there any specific options you pass to scan
utility? But it's likely I need to buy better antenna. Can scan utility
show the signal level?
Try tzap to tune to a channel, depending on your driver, it should 
output some rudimentary signal strength.
Signal is indeed important, Remember that RTL4 etc are all encrypted and 
need  a hardware cam or softcam (oscam) to properly work.


Thanks.



--
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 V1 0/8] Add a driver for somagic smi2021

2013-03-15 Thread Ezequiel Garcia
On Thu, Mar 14, 2013 at 03:06:56PM +0100, Jon Arne Jørgensen wrote:
 This patch-set will add a driver for the Somagic SMI2021 chip.
 
 This chip is found inside different usb video-capture devices.
 Most of them are branded as EasyCap, but there also seems to be
 some other brands selling devices with this chip.
 
 This driver is split into two modules, where one is called smi2021-bootloader,
 and the other is just called smi2021.
 
 The bootloader is responsible for the upload of a firmware that is needed by 
 some
 versions of the devices.
 
 All Somagic devices that need firmware seems to identify themselves
 with the usb product id 0x0007. There is no way for the kernel to know
 what firmware to upload to the device without user interaction.
 
 If there is only one firmware present on the computer, the kernel
 will upload that firmware to any device that identifies as 0x0007.
 If there are multiple Somagic firmwares present, the user will have to pass
 a module parameter to the smi2021-bootloader module to tell what firmware to 
 use.
 

Nice job!

I have some minor comments on each patch, but also I don't agree
with the patch splitting: what's the point in splitting and sending
one patch per file?

It doesn't make it any easier to review, so why don't you just
send one patch: Introduce smi2021 driver?

The rule is one patch per change, and I believe this whole patchset
is just one change: adding a new driver.

-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.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: [REVIEW PATCH 2/5] v4l2: add const to argument of write-only s_tuner ioctl.

2013-03-15 Thread Laurent Pinchart
Hi Hans,

Thanks for the patch.

On Friday 15 March 2013 11:27:22 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 This ioctl is defined as IOW, so pass the argument as const.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com

-- 
Regards,

Laurent Pinchart

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


Re: [RFC V1 1/8] smi2021: Add the header file

2013-03-15 Thread Ezequiel Garcia
On Thu, Mar 14, 2013 at 03:06:57PM +0100, Jon Arne Jørgensen wrote:
 This is the header file for the smi2021 module.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021.h | 228 
 
  1 file changed, 228 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021.h
 
 diff --git a/drivers/media/usb/smi2021/smi2021.h 
 b/drivers/media/usb/smi2021/smi2021.h
 new file mode 100644
 index 000..eba0fef
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021.h
 @@ -0,0 +1,228 @@
 +/***
 + * smi2021.h 
   *
 + *   
   *
 + * USB Driver for SMI2021 - EasyCap  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021
 + * http://code.google.com/p/easycap-somagic-linux/
 + *

I'm not sure how helpful it is to add external references.
Keep in mind that once mainlined, this driver will quickly evolve
and the external link can get outdated/removed/deprecated, etc.

 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *

Please note Linux kernel preferes GPL v2 *only*, and not any later
(although I'm not a lawyer).

 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com

Cool ;-)

 + *
 + */
 +
 +#ifndef SMI2021_H
 +#define SMI2021_H
 +
 +#include linux/module.h
 +#include linux/usb.h
 +#include linux/types.h
 +#include linux/spinlock_types.h
 +#include linux/slab.h
 +#include linux/i2c.h
 +
 +#include media/v4l2-event.h
 +#include media/v4l2-device.h
 +#include media/v4l2-ioctl.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-chip-ident.h
 +#include media/videobuf2-core.h
 +#include media/videobuf2-vmalloc.h
 +#include media/saa7115.h
 +
 +#include sound/core.h
 +#include sound/pcm.h
 +#include sound/pcm_params.h
 +#include sound/initval.h
 +
 +#define SMI2021_DRIVER_VERSION 0.1
 +
 +/* For ISOC */
 +#define SMI2021_MAX_PKT_SIZE 3072
 +#define SMI2021_ISOC_PACKETS 10  /* 64 */
 +#define SMI2021_ISOC_BUFS4   /* 16 */
 +#define SMI2021_ISOC_EP  0x82
 +
 +/* The structure of the array we use to send i2c settings to the device */
 +#define SMI2021_CTRL_HEAD 0x00
 +#define  SMI2021_CTRL_ADDR 0x01
 +#define SMI2021_CTRL_BM_DATA_TYPE 0x02
 +#define  SMI2021_CTRL_BM_DATA_OFFSET 0x03
 +#define  SMI2021_CTRL_DATA_SIZE 0x04
 +
 +#define SMI2021_CTRL_REG_HI 0x05
 +#define SMI2021_CTRL_REG_LO 0x06
 +#define SMI2021_CTRL_REG_VAL 0x07
 +
 +#define SMI2021_CTRL_I2C_REG 0x05
 +#define SMI2021_CTRL_I2C_VAL 0x06
 +#define SMI2021_CTRL_I2C_RCV_VAL 0x05
 +
 +/* General video constants */
 +#define SMI2021_BYTES_PER_LINE   1440
 +#define SMI2021_PAL_LINES576
 +#define SMI2021_NTSC_LINES   486
 +
 +/* Timing Referance Codes, see saa7113 datasheet */
 +#define SMI2021_TRC_EAV  0x10
 +#define SMI2021_TRC_VBI  0x20
 +#define SMI2021_TRC_FIELD_2  0x40
 +#define SMI2021_TRC  0x80
 +
 +#define DEBUG
 +#ifdef DEBUG
 +#define smi2021_dbg(fmt, args...)\
 + pr_debug(smi2021::%s:  fmt, __func__, \
 + ##args)
 +#else
 +#define smi2021_dbg(fmt, args...)
 +#endif
 +
 +#define smi2021_info(fmt, args...)   \
 + pr_info(smi2021::%s:  fmt,\
 + __func__, ##args)
 +
 +#define smi2021_warn(fmt, args...)   \
 + pr_warn(smi2021::%s:  fmt,\
 + __func__, ##args)
 +
 +#define smi2021_err(fmt, args...)\
 + pr_err(smi2021::%s:  fmt, \
 + __func__, ##args)
 +
 +enum smi2021_sync {
 + HSYNC,
 + SYNCZ1,
 + SYNCZ2,
 + TRC
 +};
 +
 +/* Buffer for one video frame */
 +struct smi2021_buffer {
 + /* Common vb2 stuff, 

Re: [REVIEW PATCH 3/5] v4l2: pass std by value to the write-only s_std ioctl.

2013-03-15 Thread Laurent Pinchart
Hi Hans,

Thanks for the patch.

On Friday 15 March 2013 11:27:23 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 This ioctl is defined as IOW, so pass the argument by value instead of by
 reference. I could have chosen to add const instead, but this is 1) easier
 to handle in drivers and 2) consistent with the s_std subdev operation.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com

[snip]

 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
 b/drivers/media/v4l2-core/v4l2-ioctl.c index 8ec8abe..d80d8af 100644
 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
 @@ -1383,15 +1383,15 @@ static int v4l_s_std(const struct v4l2_ioctl_ops
 *ops, struct file *file, void *fh, void *arg)
  {
   struct video_device *vfd = video_devdata(file);
 - v4l2_std_id *id = arg, norm;
 + v4l2_std_id id = *(v4l2_std_id *)arg, norm;

This is getting a bit hard to read, I would have split the declaration of norm 
to a separate line, but that's just nit-picking.

   int ret;
 
 - norm = (*id)  vfd-tvnorms;
 + norm = id  vfd-tvnorms;
   if (vfd-tvnorms  !norm)  /* Check if std is supported */
   return -EINVAL;
 
   /* Calls the specific handler */
 - ret = ops-vidioc_s_std(file, fh, norm);
 + ret = ops-vidioc_s_std(file, fh, norm);
 
   /* Updates standard information */
   if (ret = 0)

-- 
Regards,

Laurent Pinchart

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


Re: [REVIEW PATCH 1/5] v4l2: add const to argument of write-only s_frequency ioctl.

2013-03-15 Thread Hans Verkuil
On Fri March 15 2013 13:08:23 Laurent Pinchart wrote:
 Hi Hans,
 
 Thanks for the patch.
 
 On Friday 15 March 2013 11:27:21 Hans Verkuil wrote:
  From: Hans Verkuil hans.verk...@cisco.com
  
  This ioctl is defined as IOW, so pass the argument as const.
  
  Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 
 [snip]
 
  diff --git a/drivers/media/radio/radio-isa.c
  b/drivers/media/radio/radio-isa.c index fe0a4f8..0c1e27b 100644
  --- a/drivers/media/radio/radio-isa.c
  +++ b/drivers/media/radio/radio-isa.c
  @@ -102,17 +102,18 @@ static int radio_isa_s_tuner(struct file *file, void
  *priv, }
  
   static int radio_isa_s_frequency(struct file *file, void *priv,
  -   struct v4l2_frequency *f)
  +   const struct v4l2_frequency *f)
   {
  struct radio_isa_card *isa = video_drvdata(file);
  +   u32 freq = f-frequency;
  int res;
  
  if (f-tuner != 0 || f-type != V4L2_TUNER_RADIO)
  return -EINVAL;
  -   f-frequency = clamp(f-frequency, FREQ_LOW, FREQ_HIGH);
  -   res = isa-drv-ops-s_frequency(isa, f-frequency);
  +   freq = clamp(freq, FREQ_LOW, FREQ_HIGH);
 
 Micro-optimization here, you could just declare
 
   u32 freq;
 
 above and then write
 
   freq = clamp(f-frequency, FREQ_LOW, FREQ_HIGH);

I'd call this a nano-optimization :-)

 
  +   res = isa-drv-ops-s_frequency(isa, freq);
  if (res == 0)
  -   isa-freq = f-frequency;
  +   isa-freq = freq;
  return res;
   }
  
  diff --git a/drivers/media/radio/radio-keene.c
  b/drivers/media/radio/radio-keene.c index 296941a..a90b7a8 100644
  --- a/drivers/media/radio/radio-keene.c
  +++ b/drivers/media/radio/radio-keene.c
  @@ -82,9 +82,12 @@ static inline struct keene_device *to_keene_dev(struct
  v4l2_device *v4l2_dev) /* Set frequency (if non-0), PA, mute and turn
  on/off the FM transmitter. */ static int keene_cmd_main(struct keene_device
  *radio, unsigned freq, bool play) {
  -   unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
  +   unsigned short freq_send;
  int ret;
  
  +   if (freq)
  +   freq = clamp(freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);
 
 There was no similar if (freq) in the function below, doesn't this change the 
 behaviour ?

You are correct. Well spotted. I'll correct that.

 
  +   freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
  radio-buffer[0] = 0x00;
  radio-buffer[1] = 0x50;
  radio-buffer[2] = (freq_send  8)  0xff;
  @@ -215,14 +218,12 @@ static int vidioc_s_modulator(struct file *file, void
  *priv, }
  
   static int vidioc_s_frequency(struct file *file, void *priv,
  -   struct v4l2_frequency *f)
  +   const struct v4l2_frequency *f)
   {
  struct keene_device *radio = video_drvdata(file);
  
  if (f-tuner != 0 || f-type != V4L2_TUNER_RADIO)
  return -EINVAL;
  -   f-frequency = clamp(f-frequency,
  -   FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);
  return keene_cmd_main(radio, f-frequency, true);
   }
  
 
 [snip]
 
  diff --git a/drivers/media/radio/radio-miropcm20.c
  b/drivers/media/radio/radio-miropcm20.c index 3d0ff44..2b8d31d 100644
  --- a/drivers/media/radio/radio-miropcm20.c
  +++ b/drivers/media/radio/radio-miropcm20.c
  @@ -131,14 +131,14 @@ static int vidioc_g_frequency(struct file *file, void
  *priv,
  
  
   static int vidioc_s_frequency(struct file *file, void *priv,
  -   struct v4l2_frequency *f)
  +   const struct v4l2_frequency *f)
   {
  struct pcm20 *dev = video_drvdata(file);
  
  if (f-tuner != 0 || f-type != V4L2_TUNER_RADIO)
  return -EINVAL;
  
  -   dev-freq = clamp(f-frequency, 87 * 16000U, 108 * 16000U);
  +   dev-freq = clamp_t(u32, f-frequency, 87 * 16000U, 108 * 16000U);
 
 f-frequency and the two clamp boundaries are unsigned, did clamp() throw a 
 warning ?

Yeah. clamp uses:

typeof(val) __val = (val)

where 'val' is f-frequency, and typeof(f-frequency) == const u32. So assigning
'val' to __val gives a compiler error. clamp_t doesn't have that problem.

 
  pcm20_setfreq(dev, dev-freq);
  return 0;
   }
 
 [snip]
 
  diff --git a/drivers/media/usb/tlg2300/pd-video.c
  b/drivers/media/usb/tlg2300/pd-video.c index dab0ca3..8ef7c8c 100644
  --- a/drivers/media/usb/tlg2300/pd-video.c
  +++ b/drivers/media/usb/tlg2300/pd-video.c
  @@ -1079,10 +1079,11 @@ static int set_frequency(struct poseidon *pd, u32
  *frequency) }
  
   static int vidioc_s_frequency(struct file *file, void *fh,
  -   struct v4l2_frequency *freq)
  +   const struct v4l2_frequency *freq)
   {
  struct front_face *front = fh;
  struct poseidon *pd = front-pd;
  +   u32 frequency = freq-frequency;
  
  if (freq-tuner)
  return -EINVAL;
  @@ -1090,7 +1091,7 @@ static int vidioc_s_frequency(struct file *file, void
  *fh, pd-pm_suspend 

Re: [RFC V1 2/8] smi2021: Add smi2021_main.c

2013-03-15 Thread Ezequiel Garcia
On Thu, Mar 14, 2013 at 03:06:58PM +0100, Jon Arne Jørgensen wrote:
 This is the core of the smi2021 module.
 It will register the module with the kernel, and register the
 usb probe function.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_main.c | 339 
 +++
  1 file changed, 339 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_main.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_main.c 
 b/drivers/media/usb/smi2021/smi2021_main.c
 new file mode 100644
 index 000..cc600e7
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_main.c
 @@ -0,0 +1,339 @@
 +/***
 + * smi2021_main.c
   *
 + *   
   *
 + * USB Driver for SMI2021 - EasyCAP  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +#define VENDOR_ID 0x1c88
 +
 +static unsigned int imput;
 +module_param(imput, int, 0644);

s/imput/input

 +MODULE_PARM_DESC(input, Set default input);
 +
 +MODULE_LICENSE(GPL);
 +MODULE_AUTHOR(Jon Arne Jørgensen jonjon.arnearne--a.t--gmail.com);
 +MODULE_DESCRIPTION(SMI2021 - EasyCap);
 +MODULE_VERSION(SMI2021_DRIVER_VERSION);
 +
 +
 +struct usb_device_id smi2021_usb_device_id_table[] = {
 + { USB_DEVICE(VENDOR_ID, 0x003c) },
 + { USB_DEVICE(VENDOR_ID, 0x003d) },
 + { USB_DEVICE(VENDOR_ID, 0x003e) },
 + { USB_DEVICE(VENDOR_ID, 0x003f) },
 + { }
 +};
 +
 +MODULE_DEVICE_TABLE(usb, smi2021_usb_device_id_table);
 +
 +static unsigned short saa7113_addrs[] = {
 + 0x4a,
 + I2C_CLIENT_END
 +};
 +
 +/**/
 +/*   
  */
 +/*  Write to saa7113 
  */
 +/*   
  */
 +/**/
 +
 +inline int transfer_usb_ctrl(struct smi2021_dev *dev, u8 *data, int len)
 +{
 + return usb_control_msg(dev-udev, usb_sndctrlpipe(dev-udev, 0x00),
 + 0x01, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 + 0x0b, 0x00,
 + data, len, 1000);
 +}
 +
 +int smi2021_write_reg(struct smi2021_dev *dev, u8 addr, u16 reg, u8 val)
 +{
 + int rc;
 + u8 snd_data[8];
 +
 + memset(snd_data, 0x00, 8);
 +

I think you want ARRAY_SIZE macro here.

 + snd_data[SMI2021_CTRL_HEAD] = 0x0b;
 + snd_data[SMI2021_CTRL_ADDR] = addr;
 + snd_data[SMI2021_CTRL_DATA_SIZE] = 0x01;
 +
 + if (addr) {
 + /* This is I2C data for the saa7113 chip */
 + snd_data[SMI2021_CTRL_BM_DATA_TYPE] = 0xc0;
 + snd_data[SMI2021_CTRL_BM_DATA_OFFSET] = 0x01;
 +
 + snd_data[SMI2021_CTRL_I2C_REG] = reg;
 + snd_data[SMI2021_CTRL_I2C_VAL] = val;
 + } else {
 + /* This is register settings for the smi2021 chip */
 + snd_data[SMI2021_CTRL_BM_DATA_OFFSET] = 0x82;
 +

Mmmm... you should really avoid magic numbers: 0x82, 0xc0, 0x01...
can't you use some more meaningful macros?

 + snd_data[SMI2021_CTRL_REG_HI] = __cpu_to_be16(reg)  8;
 + snd_data[SMI2021_CTRL_REG_LO] = __cpu_to_be16(reg);
 +
 + }
 +
 + rc = transfer_usb_ctrl(dev, snd_data, 8);

ARRAY_SIZE macro again...

 + if (rc  0) {
 + 

Re: [REVIEW PATCH 4/5] v4l2: add const to argument of write-only s_register ioctl.

2013-03-15 Thread Laurent Pinchart
Hi Hans,

Thanks for the patch.

On Friday 15 March 2013 11:27:24 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 This ioctl is defined as IOW, so pass the argument as const.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

[snip]

 diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c
 b/drivers/media/pci/ivtv/ivtv-ioctl.c index 080f179..15e08aa 100644
 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c
 +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
 @@ -711,49 +711,50 @@ static int ivtv_g_chip_ident(struct file *file, void
 *fh, struct v4l2_dbg_chip_i }
 
  #ifdef CONFIG_VIDEO_ADV_DEBUG
 -static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
 +static volatile u8 __iomem *ivtv_itvc_start(struct ivtv *itv,
 + const struct v4l2_dbg_register *regs)

As you use the proper __iomem accessors I don't think you need a volatile.

  {
 - struct v4l2_dbg_register *regs = arg;
 - volatile u8 __iomem *reg_start;
 -
 - if (!capable(CAP_SYS_ADMIN))
 - return -EPERM;
   if (regs-reg = IVTV_REG_OFFSET  regs-reg  IVTV_REG_OFFSET +
 IVTV_REG_SIZE) -  reg_start = itv-reg_mem - IVTV_REG_OFFSET;
 - else if (itv-has_cx23415  regs-reg = IVTV_DECODER_OFFSET 
 + return itv-reg_mem - IVTV_REG_OFFSET;
 + if (itv-has_cx23415  regs-reg = IVTV_DECODER_OFFSET 
   regs-reg  IVTV_DECODER_OFFSET + IVTV_DECODER_SIZE)
 - reg_start = itv-dec_mem - IVTV_DECODER_OFFSET;
 - else if (regs-reg  IVTV_ENCODER_SIZE)
 - reg_start = itv-enc_mem;
 - else
 - return -EINVAL;
 -
 - regs-size = 4;
 - if (cmd == VIDIOC_DBG_G_REGISTER)
 - regs-val = readl(regs-reg + reg_start);
 - else
 - writel(regs-val, regs-reg + reg_start);
 - return 0;
 + return itv-dec_mem - IVTV_DECODER_OFFSET;
 + if (regs-reg  IVTV_ENCODER_SIZE)
 + return itv-enc_mem;
 + return NULL;
  }
 
  static int ivtv_g_register(struct file *file, void *fh, struct
 v4l2_dbg_register *reg) {
   struct ivtv *itv = fh2id(fh)-itv;
 
 - if (v4l2_chip_match_host(reg-match))
 - return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg);
 + if (v4l2_chip_match_host(reg-match)) {
 + volatile u8 __iomem *reg_start = ivtv_itvc_start(itv, reg);
 +
 + if (reg_start == NULL)
 + return -EINVAL;
 + reg-size = 4;
 + reg-val = readl(reg-reg + reg_start);
 + return 0;
 + }
   /* TODO: subdev errors should not be ignored, this should become a
  subdev helper function. */
   ivtv_call_all(itv, core, g_register, reg);
   return 0;
  }
 
 -static int ivtv_s_register(struct file *file, void *fh, struct
 v4l2_dbg_register *reg) +static int ivtv_s_register(struct file *file, void
 *fh, const struct v4l2_dbg_register *reg) {
   struct ivtv *itv = fh2id(fh)-itv;
 
 - if (v4l2_chip_match_host(reg-match))
 - return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg);
 + if (v4l2_chip_match_host(reg-match)) {
 + volatile u8 __iomem *reg_start = ivtv_itvc_start(itv, reg);
 +
 + if (reg_start == NULL)
 + return -EINVAL;
 + writel(reg-val, reg-reg + reg_start);
 + return 0;
 + }
   /* TODO: subdev errors should not be ignored, this should become a
  subdev helper function. */
   ivtv_call_all(itv, core, s_register, reg);

-- 
Regards,

Laurent Pinchart

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


Re: [REVIEW PATCH 5/5] v4l2-ioctl: simplify debug code.

2013-03-15 Thread Laurent Pinchart
Hi Hans,

Thanks for the patch.

On Friday 15 March 2013 11:27:25 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 The core debug code can now be simplified since all the write-only ioctls
 are now const and will not modify the data they pass to the drivers.
 
 So instead of logging write-only ioctls before the driver is called this can
 now be done afterwards, which is cleaner when it comes to error reporting
 as well.
 
 This also fixes a logic error in the debugging code where there was one
 'else' too many.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
  drivers/media/v4l2-core/v4l2-ioctl.c |   15 ++-
  1 file changed, 2 insertions(+), 13 deletions(-)
 
 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
 b/drivers/media/v4l2-core/v4l2-ioctl.c index 2abd13a..b3fe148 100644
 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
 @@ -2147,11 +2147,6 @@ static long __video_do_ioctl(struct file *file,
   }
 
   write_only = _IOC_DIR(cmd) == _IOC_WRITE;
 - if (write_only  debug  V4L2_DEBUG_IOCTL) {
 - v4l_printk_ioctl(video_device_node_name(vfd), cmd);
 - pr_cont(: );
 - info-debug(arg, write_only);
 - }
   if (info-flags  INFO_FL_STD) {
   typedef int (*vidioc_op)(struct file *file, void *fh, void *p);
   const void *p = vfd-ioctl_ops;
 @@ -2170,16 +2165,10 @@ static long __video_do_ioctl(struct file *file,
 
  done:
   if (debug) {
 - if (write_only  debug  V4L2_DEBUG_IOCTL) {
 - if (ret  0)
 - printk(KERN_DEBUG %s: error %ld\n,
 - video_device_node_name(vfd), ret);
 - return ret;
 - }
   v4l_printk_ioctl(video_device_node_name(vfd), cmd);
   if (ret  0)
 - pr_cont(: error %ld\n, ret);
 - else if (debug == V4L2_DEBUG_IOCTL)
 + pr_cont(: error %ld, ret);
 + if (debug == V4L2_DEBUG_IOCTL)

Shouldn't this be = V4L2_DEBUG_IOCTL ?

   pr_cont(\n);
   else if (_IOC_DIR(cmd) == _IOC_NONE)
   info-debug(arg, write_only);

-- 
Regards,

Laurent Pinchart

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


Re: [RFC V1 3/8] smi2021: Add smi2021_i2c.c

2013-03-15 Thread Ezequiel Garcia
On Thu, Mar 14, 2013 at 03:06:59PM +0100, Jon Arne Jørgensen wrote:
 This file is responsible for registering the device
 with the kernel i2c subsystem.
 v4l2 talks to the saa7113 chip of the device via i2c.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_i2c.c | 160 
 
  1 file changed, 160 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_i2c.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_i2c.c 
 b/drivers/media/usb/smi2021/smi2021_i2c.c
 new file mode 100644
 index 000..5b6f3f5
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_i2c.c
 @@ -0,0 +1,160 @@
 +/***
 + * smi2021_i2c.c 
   *
 + *   
   *
 + * USB Driver for SMI2021 - EasyCAP  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +/* The device will not return the chip_name on address 0x00.
 + * But the saa7115 i2c driver needs the chip id to match f7113
 + * if we want to use it,
 + * so we have to fake the return of this value
 + */

This comment style is wrong, check Documentation/CodingStyle.

BTW, Did you check the patches with checkpatch.pl?
(you can add checkpatch.pl as a git pre-commit hook, which I find very useful)

 +
 +static char chip_id[] = { 'x', 255, 55, 49, 49, 115, 0 };
 +static int id_ptr;
 +
 +static unsigned int i2c_debug;
 +module_param(i2c_debug, int, 0644);
 +MODULE_PARM_DESC(i2c_debug, enable debug messages [i2c]);
 +
 +#define dprint_i2c(fmt, args...) \
 +do { \
 + if (i2c_debug)  \
 + pr_debug(smi2021[i2c]::%s:  fmt, __func__, ##args);   \
 +} while (0)
 +
 +
 +static int i2c_xfer(struct i2c_adapter *i2c_adap,
 + struct i2c_msg msgs[], int num)
 +{
 + struct smi2021_dev *dev = i2c_adap-algo_data;
 +
 + switch (num) {
 + case 2: { /* Read reg */

Do you need a local scope in here?

 + if (msgs[0].len != 1 || msgs[1].len != 1) {
 + dprint_i2c(both messages must be 1 byte\n);
 + goto err_out;
 +

I think you missed a closing } here. And an opening { below...

 + if ((msgs[1].flags  I2C_M_RD) != I2C_M_RD)
 + dprint_i2c(last message should have rd flag\n);
 + goto err_out;
 + }
 +
 + if (msgs[0].buf[0] == 0) {
 + msgs[1].buf[0] = chip_id[id_ptr];
 + if (chip_id[id_ptr] != 0)
 + id_ptr += 1;
 + } else {
 + smi2021_read_reg(dev, msgs[0].addr, msgs[0].buf[0],
 + msgs[1].buf);
 + }
 + break;
 + }
 + case 1: { /* Write reg */
 + if (msgs[0].len == 0) {
 + break;
 + } else if (msgs[0].len != 2) {
 + dprint_i2c(unsupported len\n);
 + goto err_out;
 + }
 + if (msgs[0].buf[0] == 0) {
 + /* We don't handle writing to addr 0x00 */
 + break;
 + }
 +
 + smi2021_write_reg(dev, msgs[0].addr, msgs[0].buf[0],
 + msgs[0].buf[1]);
 + break;
 + }
 + default: {
 + 

Re: [RFC V1 4/8] smi2021: Add smi2021_v4l2.c

2013-03-15 Thread Ezequiel Garcia
On Thu, Mar 14, 2013 at 03:07:00PM +0100, Jon Arne Jørgensen wrote:
 This file is responsible for registering the device with the v4l2 subsystem,
 and the communication with v4l2.
 Most of the v4l2 ioctls are just passed on to vidbuf2.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_v4l2.c | 566 
 +++
  1 file changed, 566 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_v4l2.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_v4l2.c 
 b/drivers/media/usb/smi2021/smi2021_v4l2.c
 new file mode 100644
 index 000..d402093
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_v4l2.c
 @@ -0,0 +1,566 @@
 +/***
 + * smi2021_v4l2.c
   *
 + *   
   *
 + * USB Driver for smi2021 - EasyCap  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +static struct smi2021_fmt format[] = {
 + {
 + .name = 16bpp YU2, 4:2:2, packed,
 + .fourcc = V4L2_PIX_FMT_UYVY,
 + .depth = 16,
 + }
 +};
 +
 +static const int inputs = 2;

You could use ARRAY_SIZE on inputs as well?
Hardcoded values in general are a good way to have future bugs.

 +static struct smi2021_input input[] = {
 + {
 + .name = Composite,
 + .type = SAA7115_COMPOSITE0,
 + },
 + {
 + .name = S-Video,
 + .type = SAA7115_SVIDEO1,
 + }
 +};
 +
 +static void smi2021_set_input(struct smi2021_dev *dev)
 +{
 + if (dev-udev == NULL)
 + return;
 +
 + if (dev-ctl_input = inputs) {
 + smi2021_err(BUG: ctl_input to big!\n);
 + return;
 + }

Aren't you already checking for this? See vidioc_s_input.

 +
 + v4l2_device_call_all(dev-v4l2_dev, 0, video, s_routing,
 + input[dev-ctl_input].type, 0, 0);
 +}
 +
 +static int smi2021_start_streaming(struct smi2021_dev *dev)
 +{
 + u8 data[2];
 + int i, rc = 0;
 + data[0] = 0x01;
 + data[1] = 0x05;
 +
 + if (!dev-udev)
 + return -ENODEV;
 +
 + dev-sync_state = HSYNC;
 + dev-buf_count = 0;
 +
 + if (mutex_lock_interruptible(dev-v4l2_lock))
 + return -ERESTARTSYS;
 +
 + v4l2_device_call_all(dev-v4l2_dev, 0, video, s_stream, 1);
 +
 + /* The saa 7115 driver sets these wrong,
 +  * this leads to sync issues.
 +  * V_GATE1_START
 +  * V_GATE1_STOP
 +  * V_GATE1_MSB
 +  * All these should be 0x00 for this device.
 +  */
 + smi2021_write_reg(dev, 0x4a, 0x15, 0x00);
 + smi2021_write_reg(dev, 0x4a, 0x16, 0x00);
 + smi2021_write_reg(dev, 0x4a, 0x17, 0x00);

Oops, magic numbers!

 +
 + rc = usb_control_msg(dev-udev, usb_sndctrlpipe(dev-udev, 0x00),
 + 0x01, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 + 0x01, 0x00, data, sizeof(data), 1000);
 + if (rc  0) {
 + smi2021_err(Could not start device!\n);
 + goto out_unlock;
 + }
 +
 + /* It's mandatory to set alt interface before allocating isoc buffer */
 + usb_set_interface(dev-udev, 0, 2);
 +
 + smi2021_write_reg(dev, 0, 0x1740, 0x1d);
 +
 + if (!dev-isoc_ctl.num_bufs) {
 + rc = smi2021_alloc_isoc(dev);
 + if (rc  0)
 + goto out_stop_hw;
 + }
 +
 + /* submit urbs and enable IRQ */
 + for (i = 0; i  dev-isoc_ctl.num_bufs; i++) {
 + rc = 

Re: [RFC V1 5/8] smi2021: Add smi2021_video.c

2013-03-15 Thread Ezequiel Garcia
On Thu, Mar 14, 2013 at 03:07:01PM +0100, Jon Arne Jørgensen wrote:
 This file is responsible for all communication with the video hardware
 and also starting and stopping the capture.
 
 It also contains the setup and handling of the usb ISOCHRONOUS transfers.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_video.c | 543 
 ++
  1 file changed, 543 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_video.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_video.c 
 b/drivers/media/usb/smi2021/smi2021_video.c
 new file mode 100644
 index 000..48f3e80
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_video.c
 @@ -0,0 +1,543 @@
 +/***
 + * smi2021_video.c   
   *
 + *   
   *
 + * USB Driver for SMI2021 - EasyCAP  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021x
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +static void print_usb_err(struct smi2021_dev *dev, int packet, int status)
 +{
 + char *errmsg;
 +
 + switch (status) {
 + case -ENOENT:
 + errmsg = unlinked synchronuously;
 + break;
 + case -ECONNRESET:
 + errmsg = unlinked asynchronuously;
 + break;
 + case -ENOSR:
 + errmsg = Buffer error (overrun);
 + break;
 + case -EPIPE:
 + errmsg = Stalled (device not responding);
 + break;
 + case -EOVERFLOW:
 + errmsg = Babble (bad cable?);
 + break;
 + case -EPROTO:
 + errmsg = Bit-stuff error (bad cable?);
 + break;
 + case -EILSEQ:
 + errmsg = CRC/Timeout (could be anything);
 + break;
 + case -ETIME:
 + errmsg = Device does not respond;
 + break;
 + default:
 + errmsg = Unknown;
 + }
 +
 + if (packet  0) {
 + printk_ratelimited(KERN_WARNING Urb status %d [%s]\n,
 + status, errmsg);
 + } else {
 + printk_ratelimited(KERN_INFO URB packet %d, status %d [%s]\n,
 + packet, status, errmsg);
 + }
 +}
 +
 +static struct smi2021_buffer *smi2021_next_buffer(struct smi2021_dev *dev)
 +{
 + struct smi2021_buffer *buf = NULL;
 + unsigned long flags = 0;
 +
 + BUG_ON(dev-isoc_ctl.buf);
 +

You should replace BUG_ON with WARN_ON. Linus' words:
http://permalink.gmane.org/gmane.linux.kernel/1347333

 + spin_lock_irqsave(dev-buf_lock, flags);
 + if (!list_empty(dev-avail_bufs)) {
 + buf = list_first_entry(dev-avail_bufs, struct smi2021_buffer,
 + list);
 + list_del(buf-list);
 + }
 + spin_unlock_irqrestore(dev-buf_lock, flags);
 +
 + return buf;
 +}
 +
 +static void smi2021_buffer_done(struct smi2021_dev *dev)
 +{
 + struct smi2021_buffer *buf = dev-isoc_ctl.buf;
 +
 + dev-buf_count++;
 +
 + buf-vb.v4l2_buf.sequence = dev-buf_count  1;
 + buf-vb.v4l2_buf.field = V4L2_FIELD_INTERLACED;
 + buf-vb.v4l2_buf.bytesused = buf-pos;
 + do_gettimeofday(buf-vb.v4l2_buf.timestamp);
 +
 + vb2_set_plane_payload(buf-vb, 0, buf-pos);
 + vb2_buffer_done(buf-vb, VB2_BUF_STATE_DONE);
 +
 + dev-isoc_ctl.buf = NULL;
 +}
 +
 +static void copy_video(struct smi2021_dev *dev, u8 p)
 +{
 + struct smi2021_buffer *buf = dev-isoc_ctl.buf;
 +
 + int 

Re: [REVIEW PATCH 3/5] v4l2: pass std by value to the write-only s_std ioctl.

2013-03-15 Thread Jonathan Corbet
On Fri, 15 Mar 2013 11:27:23 +0100
Hans Verkuil hverk...@xs4all.nl wrote:

 diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
 b/drivers/media/platform/marvell-ccic/mcam-core.c
 index 92a33f0..76a8623 100644
 --- a/drivers/media/platform/marvell-ccic/mcam-core.c
 +++ b/drivers/media/platform/marvell-ccic/mcam-core.c
 @@ -1357,7 +1357,7 @@ static int mcam_vidioc_s_input(struct file *filp, void 
 *priv, unsigned int i)
  }
  
  /* from vivi.c */
 -static int mcam_vidioc_s_std(struct file *filp, void *priv, v4l2_std_id *a)
 +static int mcam_vidioc_s_std(struct file *filp, void *priv, v4l2_std_id a)
  {
   return 0;
  }

Hard to find much to complain about there :)

Acked-by: Jonathan Corbet cor...@lwn.net

(for the Via version too).

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


Re: [REVIEW PATCH 3/5] v4l2: pass std by value to the write-only s_std ioctl.

2013-03-15 Thread Hans Verkuil
On Fri March 15 2013 14:58:35 Mauro Carvalho Chehab wrote:
 Em Fri, 15 Mar 2013 11:27:23 +0100
 Hans Verkuil hverk...@xs4all.nl escreveu:
 
  From: Hans Verkuil hans.verk...@cisco.com
  
  This ioctl is defined as IOW, so pass the argument by value instead of by
  reference. I could have chosen to add const instead, but this is 1) easier
  to handle in drivers and 2) consistent with the s_std subdev operation.
 
 Hmm... this could potentially break userspace. I remember I saw in the past
 some code that used the returned standard. I can't remember where. It could
 be inside the V4L1 compat layer, but I think it was on some userspace app(s).
 
 Had you verify how the several different userspace apps handle S_STD?

video_usercopy doesn't call copy_to_user for write-only ioctls, so any changed
data will never make it to userspace.

If there is an app that expects to see the returned standard then they broke
many years ago :-)

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


DVB memory leak?

2013-03-15 Thread moasat
I've been fighting a situation where the kernel appears to be running out of 
memory over a period of time.  I originally had my low address space reserve 
set to 4096 and memory compaction on.  I would get this error within a few days 
of reboot:

Mar 06 19:25:03 [kernel] [168311.801139] DVBRead: page allocation failure: 
order:4, mode:0xc0d0
Mar 06 19:25:03 [kernel] [168311.801145] Pid: 15153, comm: DVBRead Tainted: G   
  C   3.7.10-gentoo #3
Mar 06 19:25:03 [kernel] [168311.801146] Call Trace:
Mar 06 19:25:03 [kernel] [168311.801160]  [810e7e3b] 
warn_alloc_failed+0xeb/0x130
Mar 06 19:25:03 [kernel] [168311.801163]  [810eaddd] ? 
__alloc_pages_direct_compact+0x1ed/0x200
Mar 06 19:25:03 [kernel] [168311.801166]  [810eb6ec] 
__alloc_pages_nodemask+0x8fc/0x9c0
Mar 06 19:25:03 [kernel] [168311.801175]  [81598943] ? 
usb_start_wait_urb+0xa3/0x160
Mar 06 19:25:03 [kernel] [168311.801179]  [81121b41] 
alloc_pages_current+0xb1/0x120
Mar 06 19:25:03 [kernel] [168311.801181]  [81597d49] ? 
usb_alloc_urb+0x19/0x50
Mar 06 19:25:03 [kernel] [168311.801184]  [810e6fe9] 
__get_free_pages+0x9/0x40
Mar 06 19:25:03 [kernel] [168311.801187]  [8112752a] 
kmalloc_order_trace+0x3a/0xb0
Mar 06 19:25:03 [kernel] [168311.801193]  [a00c9483] 
start_urb_transfer+0x83/0x1c0 [au0828]
Mar 06 19:25:03 [kernel] [168311.801197]  [a00c9698] 
au0828_dvb_start_feed+0xd8/0x100 [au0828]
Mar 06 19:25:03 [kernel] [168311.801201]  [8160a6ae] 
dmx_ts_feed_start_filtering+0x5e/0xf0
Mar 06 19:25:03 [kernel] [168311.801204]  [81607a7c] 
dvb_dmxdev_start_feed.clone.0+0xcc/0x120
Mar 06 19:25:03 [kernel] [168311.801206]  [816085ec] 
dvb_dmxdev_filter_start+0x28c/0x3b0
Mar 06 19:25:03 [kernel] [168311.801209]  [81608d8a] 
dvb_demux_do_ioctl+0x51a/0x6a0
Mar 06 19:25:03 [kernel] [168311.801211]  [81606e04] 
dvb_usercopy+0xa4/0x170
Mar 06 19:25:03 [kernel] [168311.801214]  [81608870] ? 
dvb_demux_open+0x160/0x160
Mar 06 19:25:03 [kernel] [168311.801217]  [8110ab5b] ? 
handle_mm_fault+0x13b/0x210
Mar 06 19:25:03 [kernel] [168311.801221]  [8113e344] ? 
do_filp_open+0x44/0xa0
Mar 06 19:25:03 [kernel] [168311.801224]  [81607480] 
dvb_demux_ioctl+0x10/0x20
Mar 06 19:25:03 [kernel] [168311.801226]  [81140026] 
do_vfs_ioctl+0x96/0x4f0
Mar 06 19:25:03 [kernel] [168311.801230]  [81332654] ? 
inode_has_perm.clone.25.clone.35+0x24/0x30
Mar 06 19:25:03 [kernel] [168311.801233]  [81334f40] ? 
file_has_perm+0x90/0xa0
Mar 06 19:25:03 [kernel] [168311.801236]  [81140511] 
sys_ioctl+0x91/0xa0
Mar 06 19:25:03 [kernel] [168311.801240]  [818a9b52] 
system_call_fastpath+0x16/0x1b
Mar 06 19:25:03 [kernel] [168311.801242] Mem-Info:
Mar 06 19:25:03 [kernel] [168311.801243] Node 0 DMA per-cpu:
Mar 06 19:25:03 [kernel] [168311.801246] CPU0: hi:0, btch:   1 usd:   0
Mar 06 19:25:03 [kernel] [168311.801247] CPU1: hi:0, btch:   1 usd:   0
Mar 06 19:25:03 [kernel] [168311.801249] CPU2: hi:0, btch:   1 usd:   0
Mar 06 19:25:03 [kernel] [168311.801250] CPU3: hi:0, btch:   1 usd:   0
Mar 06 19:25:03 [kernel] [168311.801251] Node 0 DMA32 per-cpu:
Mar 06 19:25:03 [kernel] [168311.801253] CPU0: hi:  186, btch:  31 usd:   0
Mar 06 19:25:03 [kernel] [168311.801255] CPU1: hi:  186, btch:  31 usd:   0
Mar 06 19:25:03 [kernel] [168311.801256] CPU2: hi:  186, btch:  31 usd:   0
Mar 06 19:25:03 [kernel] [168311.801258] CPU3: hi:  186, btch:  31 usd:   0
Mar 06 19:25:03 [kernel] [168311.801259] Node 0 Normal per-cpu:
Mar 06 19:25:03 [kernel] [168311.801260] CPU0: hi:  186, btch:  31 usd:   0
Mar 06 19:25:03 [kernel] [168311.801262] CPU1: hi:  186, btch:  31 usd:   0
Mar 06 19:25:03 [kernel] [168311.801264] CPU2: hi:  186, btch:  31 usd:   0
Mar 06 19:25:03 [kernel] [168311.801265] CPU3: hi:  186, btch:  31 usd:   0
Mar 06 19:25:03 [kernel] [168311.801269] active_anon:139468 inactive_anon:57451 
isolated_anon:0
Mar 06 19:25:03 [kernel] [168311.801269]  active_file:375632 
inactive_file:366012 isolated_file:0
Mar 06 19:25:03 [kernel] [168311.801269]  unevictable:0 dirty:556 writeback:0 
unstable:0
Mar 06 19:25:03 [kernel] [168311.801269]  free:10993 slab_reclaimable:32206 
slab_unreclaimable:6181
Mar 06 19:25:03 [kernel] [168311.801269]  mapped:11149 shmem:256 
pagetables:2768 bounce:0
Mar 06 19:25:03 [kernel] [168311.801269]  free_cma:0
Mar 06 19:25:03 [kernel] [168311.801272] Node 0 DMA free:15904kB min:28kB 
low:32kB high:40kB active_anon:0kB inactive_anon:0kB active_file:0kB 
inactive_file:0kB unevictable:0kB isolated(anon):0kB isolated(file):0kB 
present:15648kB mlocked:0kB dirty:0kB writeback:0kB mapped:0kB shmem:0kB 
slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:0kB pagetables:0kB 
unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:0 
all_unreclaimable? yes
Mar 06 19:25:03 [kernel] [168311.801277] 

Re: DVB memory leak?

2013-03-15 Thread Devin Heitmueller
On Fri, Mar 15, 2013 at 11:19 AM,  moa...@moasat.dyndns.org wrote:
 I've been fighting a situation where the kernel appears to be running out of 
 memory over a period of time.  I originally had my low address space reserve 
 set to 4096 and memory compaction on.  I would get this error within a few 
 days of reboot:

 Mar 06 19:25:03 [kernel] [168311.801139] DVBRead: page allocation failure: 
 order:4, mode:0xc0d0
 Mar 06 19:25:03 [kernel] [168311.801145] Pid: 15153, comm: DVBRead Tainted: G 
 C   3.7.10-gentoo #3
 Mar 06 19:25:03 [kernel] [168311.801146] Call Trace:
 Mar 06 19:25:03 [kernel] [168311.801160]  [810e7e3b] 
 warn_alloc_failed+0xeb/0x130
 Mar 06 19:25:03 [kernel] [168311.801163]  [810eaddd] ? 
 __alloc_pages_direct_compact+0x1ed/0x200
 Mar 06 19:25:03 [kernel] [168311.801166]  [810eb6ec] 
 __alloc_pages_nodemask+0x8fc/0x9c0
 Mar 06 19:25:03 [kernel] [168311.801175]  [81598943] ? 
 usb_start_wait_urb+0xa3/0x160
 Mar 06 19:25:03 [kernel] [168311.801179]  [81121b41] 
 alloc_pages_current+0xb1/0x120
 Mar 06 19:25:03 [kernel] [168311.801181]  [81597d49] ? 
 usb_alloc_urb+0x19/0x50
 Mar 06 19:25:03 [kernel] [168311.801184]  [810e6fe9] 
 __get_free_pages+0x9/0x40
 Mar 06 19:25:03 [kernel] [168311.801187]  [8112752a] 
 kmalloc_order_trace+0x3a/0xb0
 Mar 06 19:25:03 [kernel] [168311.801193]  [a00c9483] 
 start_urb_transfer+0x83/0x1c0 [au0828]
 Mar 06 19:25:03 [kernel] [168311.801197]  [a00c9698] 
 au0828_dvb_start_feed+0xd8/0x100 [au0828]
 Mar 06 19:25:03 [kernel] [168311.801201]  [8160a6ae] 
 dmx_ts_feed_start_filtering+0x5e/0xf0
 Mar 06 19:25:03 [kernel] [168311.801204]  [81607a7c] 
 dvb_dmxdev_start_feed.clone.0+0xcc/0x120
 Mar 06 19:25:03 [kernel] [168311.801206]  [816085ec] 
 dvb_dmxdev_filter_start+0x28c/0x3b0
 Mar 06 19:25:03 [kernel] [168311.801209]  [81608d8a] 
 dvb_demux_do_ioctl+0x51a/0x6a0
 Mar 06 19:25:03 [kernel] [168311.801211]  [81606e04] 
 dvb_usercopy+0xa4/0x170
 Mar 06 19:25:03 [kernel] [168311.801214]  [81608870] ? 
 dvb_demux_open+0x160/0x160
 Mar 06 19:25:03 [kernel] [168311.801217]  [8110ab5b] ? 
 handle_mm_fault+0x13b/0x210
 Mar 06 19:25:03 [kernel] [168311.801221]  [8113e344] ? 
 do_filp_open+0x44/0xa0
 Mar 06 19:25:03 [kernel] [168311.801224]  [81607480] 
 dvb_demux_ioctl+0x10/0x20
 Mar 06 19:25:03 [kernel] [168311.801226]  [81140026] 
 do_vfs_ioctl+0x96/0x4f0
 Mar 06 19:25:03 [kernel] [168311.801230]  [81332654] ? 
 inode_has_perm.clone.25.clone.35+0x24/0x30
 Mar 06 19:25:03 [kernel] [168311.801233]  [81334f40] ? 
 file_has_perm+0x90/0xa0
 Mar 06 19:25:03 [kernel] [168311.801236]  [81140511] 
 sys_ioctl+0x91/0xa0
 Mar 06 19:25:03 [kernel] [168311.801240]  [818a9b52] 
 system_call_fastpath+0x16/0x1b
 Mar 06 19:25:03 [kernel] [168311.801242] Mem-Info:
 Mar 06 19:25:03 [kernel] [168311.801243] Node 0 DMA per-cpu:
 Mar 06 19:25:03 [kernel] [168311.801246] CPU0: hi:0, btch:   1 usd:0
 Mar 06 19:25:03 [kernel] [168311.801247] CPU1: hi:0, btch:   1 usd:0
 Mar 06 19:25:03 [kernel] [168311.801249] CPU2: hi:0, btch:   1 usd:0
 Mar 06 19:25:03 [kernel] [168311.801250] CPU3: hi:0, btch:   1 usd:0
 Mar 06 19:25:03 [kernel] [168311.801251] Node 0 DMA32 per-cpu:
 Mar 06 19:25:03 [kernel] [168311.801253] CPU0: hi:  186, btch:  31 usd:0
 Mar 06 19:25:03 [kernel] [168311.801255] CPU1: hi:  186, btch:  31 usd:0
 Mar 06 19:25:03 [kernel] [168311.801256] CPU2: hi:  186, btch:  31 usd:0
 Mar 06 19:25:03 [kernel] [168311.801258] CPU3: hi:  186, btch:  31 usd:0
 Mar 06 19:25:03 [kernel] [168311.801259] Node 0 Normal per-cpu:
 Mar 06 19:25:03 [kernel] [168311.801260] CPU0: hi:  186, btch:  31 usd:0
 Mar 06 19:25:03 [kernel] [168311.801262] CPU1: hi:  186, btch:  31 usd:0
 Mar 06 19:25:03 [kernel] [168311.801264] CPU2: hi:  186, btch:  31 usd:0
 Mar 06 19:25:03 [kernel] [168311.801265] CPU3: hi:  186, btch:  31 usd:0
 Mar 06 19:25:03 [kernel] [168311.801269] active_anon:139468 
 inactive_anon:57451 isolated_anon:0
 Mar 06 19:25:03 [kernel] [168311.801269]  active_file:375632 
 inactive_file:366012 isolated_file:0
 Mar 06 19:25:03 [kernel] [168311.801269]  unevictable:0 dirty:556 writeback:0 
 unstable:0
 Mar 06 19:25:03 [kernel] [168311.801269]  free:10993 slab_reclaimable:32206 
 slab_unreclaimable:6181
 Mar 06 19:25:03 [kernel] [168311.801269]  mapped:11149 shmem:256 
 pagetables:2768 bounce:0
 Mar 06 19:25:03 [kernel] [168311.801269]  free_cma:0
 Mar 06 19:25:03 [kernel] [168311.801272] Node 0 DMA free:15904kB min:28kB 
 low:32kB high:40kB active_anon:0kB inactive_anon:0kB active_file:0kB 
 inactive_file:0kB unevictable:0kB isolated(anon):0kB isolated(file):0kB 
 present:15648kB mlocked:0kB dirty:0kB writeback:0kB mapped:0kB shmem:0kB 
 slab_reclaimable:0kB slab_unreclaimable:0kB 

Re: [PATCH] [media] ir: IR_RX51 only works on OMAP2

2013-03-15 Thread Tony Lindgren
* Timo Kokkonen timo.t.kokko...@iki.fi [130314 23:43]:
 On 03.14 2013 22:56:44, Arnd Bergmann wrote:
  This driver can be enabled on OMAP1 at the moment, which breaks
  allyesconfig for that platform. Let's mark it OMAP2PLUS-only
  in Kconfig, since that is the only thing it builds on.
  
 
 Acked-by: Timo Kokkonen timo.t.kokko...@iki.fi

Acked-by: Tony Lindgren t...@atomide.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: [RFC PATCH v2 2/6] bttv: audio_mux(): do not change the value of the v4l2 mute control

2013-03-15 Thread Frank Schäfer
Hi Hans,

thank you for reviewing and sorry for the delayed reply !

Am 12.03.2013 14:41, schrieb Hans Verkuil:
 On Sun 10 March 2013 22:53:50 Frank Schäfer wrote:
 There are cases where we want to call audio_mux() without changing the value 
 of
 the v4l2 mute control, for example
 - mute mute on last close
 - mute on device probing

 Signed-off-by: Frank Schäfer fschaefer@googlemail.com

 Acked-by: Hans Verkuil hans.verk...@cisco.com

 I think it might be a good idea to take this one step further: pull the
 btv-audio assignment out of audio_mux as well. In other words, audio_mux
 no longer changes the bttv state.

Yes, that should be easy to do.

 I also think that the audio_mute and audio_input functions should be
 removed, just let the code call audio_mux directly. I think that is more
 transparent and one less intermediate call.

OTOH I think they improve readability.
Anyway, this will become obsolete with the next step you're suggesting:

 A next step would be to untangle the audio routing code and mute code
 from audio_mux: that's probably the core of all the confusion. The code
 relating to the input selection should be put in a separate function that
 is called only when you really want to switch inputs.

Yeah, it would be nice if we could do that, but I'm not sure if it's
entirely possible.
Mute + automute and the selected input seem to be coupled via gpio
settings. See the first third
of function audio_mux().
I will have to take a deeper look into the code to see if splitting the
function really makes sense...

 I'm not sure if you want to spend time on that last step, if not, then just
 do the first two suggestions and I'll test the result. But without really
 going to the core of the problem (one function mixing up muting and input
 selection) it remains hard to prove correctness of the code. If you have
 some time, then it would be very nice if this mess can be resolved once and
 for all.

I've put it on my TODO list, but I'm not sure if I'll find some time for
it this weekend.

Regards,
Frank

 Regards,

   Hans

 ---
  drivers/media/pci/bt8xx/bttv-driver.c |8 
  1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

 diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
 b/drivers/media/pci/bt8xx/bttv-driver.c
 index a584d82..a082ab4 100644
 --- a/drivers/media/pci/bt8xx/bttv-driver.c
 +++ b/drivers/media/pci/bt8xx/bttv-driver.c
 @@ -999,7 +999,6 @@ audio_mux(struct bttv *btv, int input, int mute)
 bttv_tvcards[btv-c.type].gpiomask);
  signal = btread(BT848_DSTATUS)  BT848_DSTATUS_HLOC;
  
 -btv-mute = mute;
  btv-audio = input;
  
  /* automute */
 @@ -1031,7 +1030,7 @@ audio_mux(struct bttv *btv, int input, int mute)
  
  ctrl = v4l2_ctrl_find(btv-sd_msp34xx-ctrl_handler, 
 V4L2_CID_AUDIO_MUTE);
  if (ctrl)
 -v4l2_ctrl_s_ctrl(ctrl, btv-mute);
 +v4l2_ctrl_s_ctrl(ctrl, mute);
  
  /* Note: the inputs tuner/radio/extern/intern are translated
 to msp routings. This assumes common behavior for all msp3400
 @@ -1080,7 +1079,7 @@ audio_mux(struct bttv *btv, int input, int mute)
  ctrl = v4l2_ctrl_find(btv-sd_tvaudio-ctrl_handler, 
 V4L2_CID_AUDIO_MUTE);
  
  if (ctrl)
 -v4l2_ctrl_s_ctrl(ctrl, btv-mute);
 +v4l2_ctrl_s_ctrl(ctrl, mute);
  v4l2_subdev_call(btv-sd_tvaudio, audio, s_routing,
  input, 0, 0);
  }
 @@ -1088,7 +1087,7 @@ audio_mux(struct bttv *btv, int input, int mute)
  ctrl = v4l2_ctrl_find(btv-sd_tda7432-ctrl_handler, 
 V4L2_CID_AUDIO_MUTE);
  
  if (ctrl)
 -v4l2_ctrl_s_ctrl(ctrl, btv-mute);
 +v4l2_ctrl_s_ctrl(ctrl, mute);
  }
  return 0;
  }
 @@ -1300,6 +1299,7 @@ static int bttv_s_ctrl(struct v4l2_ctrl *c)
  break;
  case V4L2_CID_AUDIO_MUTE:
  audio_mute(btv, c-val);
 +btv-mute = c-val;
  break;
  case V4L2_CID_AUDIO_VOLUME:
  btv-volume_gpio(btv, c-val);


--
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 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-15 Thread H Hartley Sweeten
On Thursday, March 14, 2013 6:58 AM, Arnd Bergmann wrote:
 On Thursday 14 March 2013, Fabio Porcedda wrote:
 This patch converts the drivers to use the
 module_platform_driver_probe() macro which makes the code smaller and
 a bit simpler.
 
 Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
 Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
 Cc: Arnd Bergmann a...@arndb.de
 ---
  drivers/misc/atmel_pwm.c  | 12 +---
  drivers/misc/ep93xx_pwm.c | 13 +
  2 files changed, 2 insertions(+), 23 deletions(-)

 The patch itself seems fine, but there are two issues around it:

 * The PWM drivers should really get moved to drivers/pwm and converted to the 
 new
   PWM subsystem. I don't know if Hartley or Hans-Christian have plans to do
   that already.

Arnd,

Ill look at converting the ep93xx pwm driver to the PWM subsystem. The only 
issue is
the current driver exposes a sysfs interface that I think is not available in 
that subsystem.

* Regarding the use of module_platform_driver_probe, I'm a little worried about
  the interactions with deferred probing. I don't think there are any 
 regressions,
  but we should probably make people aware that one cannot return -EPROBE_DEFER
  from a platform_driver_probe function.

The ep93xx pwm driver does not need to use platform_driver_probe(). It can be 
changed
to use module_platform_driver() by just moving the .probe to the 
platform_driver. This
driver was added before module_platform_driver() was available and I used the
platform_driver_probe() thinking it would save a couple lines of code.

I'll change this in a bit. Right now I'm trying to work out why kernel 3.8 is 
not booting
on the ep93xx. I had 3.6.6 on my development board and 3.7 works fine but 3.8 
hangs
without uncompressing the kernel.

Regards,
Hartley



--
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 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-15 Thread Fabio Porcedda
On Fri, Mar 15, 2013 at 12:28 PM, Arnd Bergmann a...@arndb.de wrote:
 On Friday 15 March 2013, Fabio Porcedda wrote:
  * Regarding the use of module_platform_driver_probe, I'm a little worried 
  about
the interactions with deferred probing. I don't think there are any 
  regressions,
but we should probably make people aware that one cannot return 
  -EPROBE_DEFER
from a platform_driver_probe function.

 The use of module_platform_driver_probe() doesn't change anything about that,
 it's exactly the same thing as using return platform_driver_probe().
 I'm right or I'm missing something? Maybe are you just speaking about
 the misuse of platform_driver_probe?

 Yes, that was what I meant. The point is that if we need to review or remove
 all uses of platform_driver_probe, it would be better not to introduce a
 module_platform_driver_probe() interface to make it easier to use.

Just to let you know, the module_platform_driver_probe() macro is
already in v3.9-rc1 and is already used by some drivers.
In linux-next there are already many patches that use that macro.

Best regards
--
Fabio Porcedda
--
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 8/8] drivers: misc: use module_platform_driver_probe()

2013-03-15 Thread Greg Kroah-Hartman
On Thu, Mar 14, 2013 at 06:09:38PM +0100, Fabio Porcedda wrote:
 This patch converts the drivers to use the
 module_platform_driver_probe() macro which makes the code smaller and
 a bit simpler.

Someone else beat you to this fix for these files, sorry.

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


Re: DVB memory leak?

2013-03-15 Thread Moasat
From: Devin Heitmueller dheitmuel...@kernellabs.com
To: moa...@moasat.dyndns.org
Cc: linux-media@vger.kernel.org
Sent: Friday, March 15, 2013 11:06:28 AM
Subject: Re: DVB memory leak?

On Fri, Mar 15, 2013 at 11:19 AM,  moa...@moasat.dyndns.org wrote:
 I've been fighting a situation where the kernel appears to be running out of 
 memory over a period of time.  I originally had my low address space 
 reserve set to 4096 and memory compaction on.  I would get this error within 
 a few days of reboot:


There are probably a couple of different issues here.  It's possible
I've got a leak in the DVB side of the au0828 where we aren't properly
deallocating all the URBs.  Separate from that though, the allocation
failure should be returned up the stack and the application should
note the failure condition.  Either I've got a bug in the driver where
it doesn't get back to userland, or MythTV doesn't actually check the
error condition and report the failure.

I've got some other fixes coming down the pipe for that driver.  Will
take a look over the next couple of weeks and see if I can spot the
leak.

Thanks for looking into it.  It wouldn't surprise me to find out that Myth is 
not checking the error condition.  But even if it did, would that keep the card 
functioning?  As it is, the card is useless from this point on until I reboot.  
I might have to just watch logs and schedule a reboot or something until 
something changes.  If I was convinced that reloading the module would work I 
would do just that but there are some dependencies that I haven't worked out 
yet.  I will probably try this at some point to keep from having to reboot the 
entire machine.

If there's something I can help with, let me know.  I have two of these devices 
in the machine right now.  I can isolate one of them to another machine for 
testing if it would help.  I've done some kernel module development in the past 
so I sort of know my way around if you need me to try a patch or something.

Thanks!


--
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: msp3400 problem in linux-3.7.0

2013-03-15 Thread Benjamin Schindler

Hi

I think I've just been really stupid. I tried latest git, but got not 
sound. I then checked my volumes again and noticed, that the rear-mic 
channel was muted. I didn't have that channel in 3.2 (just had mic) so I 
didn't notice...


So may be sound wasn't broken after all in vanilla. Would it be of any 
interest if I were to check?


Regards
Benjamin

On 15.03.2013 10:20, Hans Verkuil wrote:

On Fri March 15 2013 10:56:51 Benjamin Schindler wrote:

I just tried to apply the patch, but it does not apply cleanly:

metis linux # patch -p1  /home/benjamin/Downloads/bttv-patch.txt
patching file drivers/media/pci/bt8xx/bttv-driver.c
Hunk #1 FAILED at 2007.
Hunk #2 FAILED at 2024.
Hunk #3 succeeded at 4269 with fuzz 2 (offset 34 lines).
Hunk #4 succeeded at 4414 (offset 34 lines).
2 out of 4 hunks FAILED -- saving rejects to file
drivers/media/pci/bt8xx/bttv-driver.c.rej
patching file drivers/media/pci/bt8xx/bttvp.h

I then tried applying it manually, which I think worked. But it did not
fix the problem. Given that the patch did not apply cleanly, may be I
should either use the media git tree or wait for 3.10.


You might want to try the media git tree (if only so that we know that it
really fixes your problem). 3.10 will be another 5 months or so before that
is released.

Regards,

Hans



I just realized that this was on a 3.7.10 kernel (not 3.7.0, but that
probably does not make much of a difference)

Regards
Benjamin

On 14.03.2013 08:44, Hans Verkuil wrote:

On Thu March 14 2013 08:13:29 Benjamin Schindler wrote:

Hi Hans

Thank you for the prompt response. I will try this once I'm home again.
Which patch is responsible for fixing it? Just so I can track it once it
lands upstream.


There is a whole series of bttv fixes that I did that will appear in 3.10.

But the patch that is probably responsible for fixing it is this one:

http://git.linuxtv.org/media_tree.git/commit/76ea992a036c4a5d3bc606a79ef775dd32fd3daa

I say 'probably' because I am not 100% certain that that is the main fix.
I'm 99% certain, though :-)

As mentioned, it was part of a much longer patch series, so there may be other
patches involved in this particular problem, but I don't think so.

If you can perhaps test just that single patch then that would be useful
information. If that fixes the problem then that's a candidate for 'stable'
kernels.


I have one more question - the wiki states the the WinTV-HVR-5500 is not
yet supported (as of June 2011) - is there an update on this? It's the
only DVB-C card I can buy in the local stores here


No idea. I do V4L2, not DVB :-) Hopefully someone else knows.

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



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


Re: DVB memory leak?

2013-03-15 Thread Devin Heitmueller
On Fri, Mar 15, 2013 at 2:45 PM, Moasat moa...@moasat.dyndns.org wrote:
 Thanks for looking into it.  It wouldn't surprise me to find out that Myth is 
 not checking the error condition.  But even if it did, would that keep the 
 card functioning?

No, it would not keep the card functioning.  But you would at least
not get zero length recordings and instead you would get an error that
something went wrong and that action was required.

The underlying problem of course is the leak - the fact that MythTV
doesn't tell you something went wrong just exacerbates the problem.

Devin

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


cron job: media_tree daily build: WARNINGS

2013-03-15 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:   Fri Mar 15 19:00:21 CET 2013
git branch: test
git hash:   4d35435d3ffb853b491f5bb21a62529cd925d660
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: WARNINGS
linux-git-arm-omap: WARNINGS
linux-git-blackfin: 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-i686: OK
linux-3.9-rc1-i686: OK
linux-2.6.31.14-x86_64: WARNINGS
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: 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-x86_64: WARNINGS
linux-3.9-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-15 Thread Arnd Bergmann
On Friday 15 March 2013, H Hartley Sweeten wrote:
 Arnd,
 
 Ill look at converting the ep93xx pwm driver to the PWM subsystem. The only 
 issue is
 the current driver exposes a sysfs interface that I think is not available in 
 that subsystem.

You can probably keep providing that interface if you have active users.

 * Regarding the use of module_platform_driver_probe, I'm a little worried 
 about
   the interactions with deferred probing. I don't think there are any 
  regressions,
   but we should probably make people aware that one cannot return 
  -EPROBE_DEFER
   from a platform_driver_probe function.
 
 The ep93xx pwm driver does not need to use platform_driver_probe(). It can be 
 changed
 to use module_platform_driver() by just moving the .probe to the 
 platform_driver. This
 driver was added before module_platform_driver() was available and I used the
 platform_driver_probe() thinking it would save a couple lines of code.
 
 I'll change this in a bit. Right now I'm trying to work out why kernel 3.8 is 
 not booting
 on the ep93xx. I had 3.6.6 on my development board and 3.7 works fine but 3.8 
 hangs
 without uncompressing the kernel.

Ok, thanks!

Arnd
--
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 v6 5/7] sh_mobile_ceu_camera: add asynchronous subdevice probing support

2013-03-15 Thread Guennadi Liakhovetski
Use the v4l2-async API to support asynchronous subdevice probing,
including the CSI2 subdevice. Synchronous probing is still supported too.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---

v6: update to the new v4l2-async API

 .../platform/soc_camera/sh_mobile_ceu_camera.c |  136 -
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  162 +++-
 include/media/sh_mobile_ceu.h  |2 +
 include/media/sh_mobile_csi2.h |2 +-
 4 files changed, 196 insertions(+), 106 deletions(-)

diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 6539f41..f1ef217 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -36,6 +36,7 @@
 #include linux/pm_runtime.h
 #include linux/sched.h
 
+#include media/v4l2-async.h
 #include media/v4l2-common.h
 #include media/v4l2-dev.h
 #include media/soc_camera.h
@@ -97,6 +98,10 @@ struct sh_mobile_ceu_buffer {
 struct sh_mobile_ceu_dev {
struct soc_camera_host ici;
struct soc_camera_device *icd;
+   /* Asynchronous CSI2 linking */
+   struct v4l2_async_subdev *csi2_asd;
+   struct v4l2_subdev *csi2_sd;
+   /* Synchronous probing compatibility */
struct platform_device *csi2_pdev;
 
unsigned int irq;
@@ -187,7 +192,6 @@ static int sh_mobile_ceu_soft_reset(struct 
sh_mobile_ceu_dev *pcdev)
udelay(1);
}
 
-
if (2 != success) {
dev_warn(icd-pdev, soft reset time out\n);
return -EIO;
@@ -536,16 +540,29 @@ static struct v4l2_subdev *find_csi2(struct 
sh_mobile_ceu_dev *pcdev)
 {
struct v4l2_subdev *sd;
 
-   if (!pcdev-csi2_pdev)
-   return NULL;
+   if (pcdev-csi2_sd)
+   return pcdev-csi2_sd;
 
-   v4l2_device_for_each_subdev(sd, pcdev-ici.v4l2_dev)
-   if (pcdev-csi2_pdev-dev == v4l2_get_subdevdata(sd))
-   return sd;
+   if (pcdev-csi2_asd) {
+   char name[] = sh-mobile-csi2;
+   v4l2_device_for_each_subdev(sd, pcdev-ici.v4l2_dev)
+   if (!strncmp(name, sd-name, sizeof(name) - 1)) {
+   pcdev-csi2_sd = sd;
+   return sd;
+   }
+   }
 
return NULL;
 }
 
+static struct v4l2_subdev *csi2_subdev(struct sh_mobile_ceu_dev *pcdev,
+  struct soc_camera_device *icd)
+{
+   struct v4l2_subdev *sd = pcdev-csi2_sd;
+
+   return sd  sd-grp_id == soc_camera_grp_id(icd) ? sd : NULL;
+}
+
 /* Called with .host_lock held */
 static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)
 {
@@ -583,8 +600,13 @@ static int sh_mobile_ceu_add_device(struct 
soc_camera_device *icd)
 * -ENODEV is special: either csi2_sd == NULL or the CSI-2 driver
 * has not found this soc-camera device among its clients
 */
-   if (ret == -ENODEV  csi2_sd)
-   csi2_sd-grp_id = 0;
+   if (csi2_sd) {
+   if (ret == -ENODEV)
+   csi2_sd-grp_id = 0;
+   else
+   dev_info(icd-parent, Using CSI-2 interface\n);
+   }
+
pcdev-icd = icd;
 
return 0;
@@ -600,8 +622,7 @@ static void sh_mobile_ceu_remove_device(struct 
soc_camera_device *icd)
BUG_ON(icd != pcdev-icd);
 
v4l2_subdev_call(csi2_sd, core, s_power, 0);
-   if (csi2_sd)
-   csi2_sd-grp_id = 0;
+
/* disable capture, disable interrupts */
ceu_write(pcdev, CEIER, 0);
sh_mobile_ceu_soft_reset(pcdev);
@@ -707,7 +728,7 @@ static void sh_mobile_ceu_set_rect(struct soc_camera_device 
*icd)
}
 
/* CSI2 special configuration */
-   if (pcdev-csi2_pdev) {
+   if (csi2_subdev(pcdev, icd)) {
in_width = ((in_width - 2) * 2);
left_offset *= 2;
}
@@ -764,13 +785,7 @@ static void capture_restore(struct sh_mobile_ceu_dev 
*pcdev, u32 capsr)
 static struct v4l2_subdev *find_bus_subdev(struct sh_mobile_ceu_dev *pcdev,
   struct soc_camera_device *icd)
 {
-   if (pcdev-csi2_pdev) {
-   struct v4l2_subdev *csi2_sd = find_csi2(pcdev);
-   if (csi2_sd  csi2_sd-grp_id == soc_camera_grp_id(icd))
-   return csi2_sd;
-   }
-
-   return soc_camera_to_subdev(icd);
+   return csi2_subdev(pcdev, icd) ? : soc_camera_to_subdev(icd);
 }
 
 #define CEU_BUS_FLAGS (V4L2_MBUS_MASTER |  \
@@ -874,7 +889,7 @@ static int sh_mobile_ceu_set_bus_param(struct 
soc_camera_device *icd)
value |= common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW ? 1  1 : 0;
value |= common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW ? 1  0 : 0;
 
-   if (pcdev-csi2_pdev) /* 

[PATCH v6 6/7] imx074: support asynchronous probing

2013-03-15 Thread Guennadi Liakhovetski
Both synchronous and asynchronous imx074 subdevice probing is supported by
this patch.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---

v6: update to new v4l2-async API, use soc_camera_power_init()

 drivers/media/i2c/soc_camera/imx074.c |   24 +---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/imx074.c 
b/drivers/media/i2c/soc_camera/imx074.c
index cee5345..74a5c3a 100644
--- a/drivers/media/i2c/soc_camera/imx074.c
+++ b/drivers/media/i2c/soc_camera/imx074.c
@@ -18,6 +18,7 @@
 #include linux/module.h
 
 #include media/soc_camera.h
+#include media/v4l2-async.h
 #include media/v4l2-clk.h
 #include media/v4l2-subdev.h
 #include media/v4l2-chip-ident.h
@@ -79,6 +80,7 @@ struct imx074 {
struct v4l2_subdev  subdev;
const struct imx074_datafmt *fmt;
struct v4l2_clk *clk;
+   struct v4l2_async_subdev_list   asdl;
 };
 
 static const struct imx074_datafmt imx074_colour_fmts[] = {
@@ -455,14 +457,28 @@ static int imx074_probe(struct i2c_client *client,
 
priv-fmt   = imx074_colour_fmts[0];
 
+   priv-asdl.subdev = priv-subdev;
+   priv-asdl.dev = client-dev;
+
priv-clk = v4l2_clk_get(priv-subdev, mclk);
-   if (IS_ERR(priv-clk))
-   return PTR_ERR(priv-clk);
+   if (IS_ERR(priv-clk)) {
+   dev_info(client-dev, Error %ld getting clock\n, 
PTR_ERR(priv-clk));
+   return -EPROBE_DEFER;
+   }
+
+   ret = soc_camera_power_init(client-dev, ssdd);
+   if (ret  0)
+   goto epwrinit;
 
ret = imx074_video_probe(client);
if (ret  0)
-   v4l2_clk_put(priv-clk);
+   goto eprobe;
 
+   return v4l2_async_subdev_register(priv-asdl);
+
+epwrinit:
+eprobe:
+   v4l2_clk_put(priv-clk);
return ret;
 }
 
@@ -471,7 +487,9 @@ static int imx074_remove(struct i2c_client *client)
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
struct imx074 *priv = to_imx074(client);
 
+   v4l2_async_subdev_unregister(priv-asdl);
v4l2_clk_put(priv-clk);
+
if (ssdd-free_bus)
ssdd-free_bus(ssdd);
 
-- 
1.7.2.5

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


[PATCH v6 4/7] soc-camera: add V4L2-async support

2013-03-15 Thread Guennadi Liakhovetski
Add support for asynchronous subdevice probing, using the v4l2-async API.
The legacy synchronous mode is still supported too, which allows to
gradually update drivers and platforms. The selected approach adds a
notifier for each struct soc_camera_device instance, i.e. for each video
device node, even when there are multiple such instances registered with a
single soc-camera host simultaneously.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---

v6: update to new v4l2-clk and v4l2-async APIs, export a new
soc_camera_power_init() functions for asynchronous subdevices to request
regulators

 drivers/media/platform/soc_camera/soc_camera.c |  494 +++-
 include/media/soc_camera.h |   23 +-
 2 files changed, 429 insertions(+), 88 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 01cd5a0..e1e4ca1 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -21,22 +21,23 @@
 #include linux/i2c.h
 #include linux/init.h
 #include linux/list.h
-#include linux/mutex.h
 #include linux/module.h
+#include linux/mutex.h
 #include linux/platform_device.h
+#include linux/pm_runtime.h
 #include linux/regulator/consumer.h
 #include linux/slab.h
-#include linux/pm_runtime.h
 #include linux/vmalloc.h
 
 #include media/soc_camera.h
+#include media/soc_mediabus.h
+#include media/v4l2-async.h
 #include media/v4l2-clk.h
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
 #include media/videobuf-core.h
 #include media/videobuf2-core.h
-#include media/soc_mediabus.h
 
 /* Default to VGA resolution */
 #define DEFAULT_WIDTH  640
@@ -47,23 +48,38 @@
 (icd)-vb_vidq.streaming : \
 vb2_is_streaming((icd)-vb2_vidq))
 
+#define MAP_MAX_NUM 32
+static DECLARE_BITMAP(device_map, MAP_MAX_NUM);
 static LIST_HEAD(hosts);
 static LIST_HEAD(devices);
-static DEFINE_MUTEX(list_lock);/* Protects the list of hosts */
+/*
+ * Protects lists and bitmaps of hosts and devices.
+ * Lock nesting: Ok to take -host_lock under list_lock.
+ */
+static DEFINE_MUTEX(list_lock);
+
+struct soc_camera_async_client {
+   struct v4l2_async_subdev *sensor;
+   struct v4l2_async_notifier notifier;
+   struct platform_device *pdev;
+};
+
+static int soc_camera_video_start(struct soc_camera_device *icd);
+static int video_dev_create(struct soc_camera_device *icd);
 
 int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc 
*ssdd,
struct v4l2_clk *clk)
 {
int ret = clk ? v4l2_clk_enable(clk) : 0;
if (ret  0) {
-   dev_err(dev, Cannot enable clock\n);
+   dev_err(dev, Cannot enable clock: %d\n, ret);
return ret;
}
ret = regulator_bulk_enable(ssdd-num_regulators,
ssdd-regulators);
if (ret  0) {
dev_err(dev, Cannot enable regulators\n);
-   goto eregenable;;
+   goto eregenable;
}
 
if (ssdd-power) {
@@ -117,6 +133,14 @@ int soc_camera_power_off(struct device *dev, struct 
soc_camera_subdev_desc *ssdd
 }
 EXPORT_SYMBOL(soc_camera_power_off);
 
+int soc_camera_power_init(struct device *dev, struct soc_camera_subdev_desc 
*ssdd)
+{
+
+   return devm_regulator_bulk_get(dev, ssdd-num_regulators,
+  ssdd-regulators);
+}
+EXPORT_SYMBOL(soc_camera_power_init);
+
 static int __soc_camera_power_on(struct soc_camera_device *icd)
 {
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
@@ -124,15 +148,20 @@ static int __soc_camera_power_on(struct soc_camera_device 
*icd)
int ret;
 
if (!icd-clk) {
+   mutex_lock(ici-clk_lock);
ret = ici-ops-add(icd);
+   mutex_unlock(ici-clk_lock);
if (ret  0)
return ret;
}
 
ret = v4l2_subdev_call(sd, core, s_power, 1);
if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV) {
-   if (!icd-clk)
+   if (!icd-clk) {
+   mutex_lock(ici-clk_lock);
ici-ops-remove(icd);
+   mutex_unlock(ici-clk_lock);
+   }
return ret;
}
 
@@ -146,8 +175,11 @@ static int __soc_camera_power_off(struct soc_camera_device 
*icd)
int ret;
 
ret = v4l2_subdev_call(sd, core, s_power, 0);
-   if (!icd-clk)
+   if (!icd-clk) {
+   mutex_lock(ici-clk_lock);
ici-ops-remove(icd);
+   mutex_unlock(ici-clk_lock);
+   }
if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV)
return ret;
 
@@ -631,8 +663,8 @@ static int soc_camera_open(struct file *file)
return 0;
 
/*
-* First four errors are 

[PATCH v6 2/7] media: V4L2: support asynchronous subdevice registration

2013-03-15 Thread Guennadi Liakhovetski
Currently bridge device drivers register devices for all subdevices
synchronously, tupically, during their probing. E.g. if an I2C CMOS sensor
is attached to a video bridge device, the bridge driver will create an I2C
device and wait for the respective I2C driver to probe. This makes linking
of devices straight forward, but this approach cannot be used with
intrinsically asynchronous and unordered device registration systems like
the Flattened Device Tree. To support such systems this patch adds an
asynchronous subdevice registration framework to V4L2. To use it respective
(e.g. I2C) subdevice drivers must register themselves with the framework.
A bridge driver on the other hand must register notification callbacks,
that will be called upon various related events.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---

v6:
1. clock name is now I2C adapter ID-I2C address
2. modified API: instead of bind-bound-unbind use register-unregister
3. removed the bind notifier callback

 drivers/media/v4l2-core/Makefile |3 +-
 drivers/media/v4l2-core/v4l2-async.c |  272 ++
 include/media/v4l2-async.h   |  105 +
 3 files changed, 379 insertions(+), 1 deletions(-)
 create mode 100644 drivers/media/v4l2-core/v4l2-async.c
 create mode 100644 include/media/v4l2-async.h

diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index aea7aea..68f815f 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -5,7 +5,8 @@
 tuner-objs :=  tuner-core.o
 
 videodev-objs  :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
-   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o
+   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o \
+   v4l2-async.o
 ifeq ($(CONFIG_COMPAT),y)
   videodev-objs += v4l2-compat-ioctl32.o
 endif
diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
new file mode 100644
index 000..ce26043
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -0,0 +1,272 @@
+/*
+ * V4L2 asynchronous subdevice registration API
+ *
+ * Copyright (C) 2012, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/device.h
+#include linux/err.h
+#include linux/i2c.h
+#include linux/list.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/notifier.h
+#include linux/platform_device.h
+#include linux/slab.h
+#include linux/types.h
+
+#include media/v4l2-async.h
+#include media/v4l2-device.h
+#include media/v4l2-subdev.h
+
+static bool match_i2c(struct device *dev, struct v4l2_async_hw_device *hw_dev)
+{
+   struct i2c_client *client = i2c_verify_client(dev);
+   return client 
+   hw_dev-bus_type == V4L2_ASYNC_BUS_I2C 
+   hw_dev-match.i2c.adapter_id == client-adapter-nr 
+   hw_dev-match.i2c.address == client-addr;
+}
+
+static bool match_platform(struct device *dev, struct v4l2_async_hw_device 
*hw_dev)
+{
+   return hw_dev-bus_type == V4L2_ASYNC_BUS_PLATFORM 
+   !strcmp(hw_dev-match.platform.name, dev_name(dev));
+}
+
+static LIST_HEAD(subdev_list);
+static LIST_HEAD(notifier_list);
+static DEFINE_MUTEX(list_lock);
+
+static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier 
*notifier,
+   struct 
v4l2_async_subdev_list *asdl)
+{
+   struct v4l2_async_subdev *asd = NULL;
+   bool (*match)(struct device *,
+ struct v4l2_async_hw_device *);
+
+   list_for_each_entry (asd, notifier-waiting, list) {
+   struct v4l2_async_hw_device *hw = asd-hw;
+   switch (hw-bus_type) {
+   case V4L2_ASYNC_BUS_SPECIAL:
+   match = hw-match.special.match;
+   if (!match)
+   /* Match always */
+   return asd;
+   break;
+   case V4L2_ASYNC_BUS_PLATFORM:
+   match = match_platform;
+   break;
+   case V4L2_ASYNC_BUS_I2C:
+   match = match_i2c;
+   break;
+   default:
+   /* Oops */
+   match = NULL;
+   dev_err(notifier-v4l2_dev ? notifier-v4l2_dev-dev : 
NULL,
+   Invalid bus-type %u on %p\n, hw-bus_type, 
asd);
+   }
+
+   if (match  match(asdl-dev, hw))
+   break;
+   }
+
+   return asd;
+}
+
+static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
+ struct v4l2_async_subdev_list 

[PATCH v6 1/7] media: V4L2: add temporary clock helpers

2013-03-15 Thread Guennadi Liakhovetski
Typical video devices like camera sensors require an external clock source.
Many such devices cannot even access their hardware registers without a
running clock. These clock sources should be controlled by their consumers.
This should be performed, using the generic clock framework. Unfortunately
so far only very few systems have been ported to that framework. This patch
adds a set of temporary helpers, mimicking the generic clock API, to V4L2.
Platforms, adopting the clock API, should switch to using it. Eventually
this temporary API should be removed.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---

v6: changed clock name to just I2C adapter ID-I2C address to avoid 
having to wait for an I2C subdevice driver to probe. Added a subdevice 
pointer to struct v4l2_clk for subdevice and bridge binding.

 drivers/media/v4l2-core/Makefile   |2 +-
 drivers/media/v4l2-core/v4l2-clk.c |  184 
 include/media/v4l2-clk.h   |   55 +++
 3 files changed, 240 insertions(+), 1 deletions(-)
 create mode 100644 drivers/media/v4l2-core/v4l2-clk.c
 create mode 100644 include/media/v4l2-clk.h

diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index a9d3552..aea7aea 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -5,7 +5,7 @@
 tuner-objs :=  tuner-core.o
 
 videodev-objs  :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
-   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o
+   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o
 ifeq ($(CONFIG_COMPAT),y)
   videodev-objs += v4l2-compat-ioctl32.o
 endif
diff --git a/drivers/media/v4l2-core/v4l2-clk.c 
b/drivers/media/v4l2-core/v4l2-clk.c
new file mode 100644
index 000..3505972
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-clk.c
@@ -0,0 +1,184 @@
+/*
+ * V4L2 clock service
+ *
+ * Copyright (C) 2012, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/atomic.h
+#include linux/errno.h
+#include linux/list.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/string.h
+
+#include media/v4l2-clk.h
+#include media/v4l2-subdev.h
+
+static DEFINE_MUTEX(clk_lock);
+static LIST_HEAD(clk_list);
+
+static struct v4l2_clk *v4l2_clk_find(const struct v4l2_subdev *sd,
+ const char *dev_id, const char *id)
+{
+   struct v4l2_clk *clk;
+
+   list_for_each_entry(clk, clk_list, list) {
+   if (!sd || !(sd-flags  V4L2_SUBDEV_FL_IS_I2C)) {
+   if (strcmp(dev_id, clk-dev_id))
+   continue;
+   } else {
+   char *i2c = strstr(dev_id, clk-dev_id);
+   if (!i2c || i2c == dev_id || *(i2c - 1) != ' ')
+   continue;
+   }
+
+   if (!id || !clk-id || !strcmp(clk-id, id))
+   return clk;
+   }
+
+   return ERR_PTR(-ENODEV);
+}
+
+struct v4l2_clk *v4l2_clk_get(struct v4l2_subdev *sd, const char *id)
+{
+   struct v4l2_clk *clk;
+
+   mutex_lock(clk_lock);
+   clk = v4l2_clk_find(sd, sd-name, id);
+
+   if (!IS_ERR(clk)  !try_module_get(clk-ops-owner))
+   clk = ERR_PTR(-ENODEV);
+   mutex_unlock(clk_lock);
+
+   if (!IS_ERR(clk)) {
+   clk-subdev = sd;
+   atomic_inc(clk-use_count);
+   }
+
+   return clk;
+}
+EXPORT_SYMBOL(v4l2_clk_get);
+
+void v4l2_clk_put(struct v4l2_clk *clk)
+{
+   if (!IS_ERR(clk)) {
+   atomic_dec(clk-use_count);
+   module_put(clk-ops-owner);
+   }
+}
+EXPORT_SYMBOL(v4l2_clk_put);
+
+int v4l2_clk_enable(struct v4l2_clk *clk)
+{
+   int ret;
+   mutex_lock(clk-lock);
+   if (++clk-enable == 1  clk-ops-enable) {
+   ret = clk-ops-enable(clk);
+   if (ret  0)
+   clk-enable--;
+   } else {
+   ret = 0;
+   }
+   mutex_unlock(clk-lock);
+   return ret;
+}
+EXPORT_SYMBOL(v4l2_clk_enable);
+
+void v4l2_clk_disable(struct v4l2_clk *clk)
+{
+   int enable;
+
+   mutex_lock(clk-lock);
+   enable = --clk-enable;
+   if (WARN(enable  0, Unbalanced %s() on %s:%s!\n, __func__,
+clk-dev_id, clk-id))
+   clk-enable++;
+   else if (!enable  clk-ops-disable)
+   clk-ops-disable(clk);
+   mutex_unlock(clk-lock);
+}
+EXPORT_SYMBOL(v4l2_clk_disable);
+
+unsigned long v4l2_clk_get_rate(struct v4l2_clk *clk)
+{
+   if (!clk-ops-get_rate)
+   return -ENOSYS;
+
+   return clk-ops-get_rate(clk);
+}
+EXPORT_SYMBOL(v4l2_clk_get_rate);
+
+int v4l2_clk_set_rate(struct v4l2_clk *clk, unsigned long rate)
+{

[PATCH v6 7/7] ARM: shmobile: convert ap4evb to asynchronously register camera subdevices

2013-03-15 Thread Guennadi Liakhovetski
Register the imx074 camera I2C and the CSI-2 platform devices directly
in board platform data instead of letting the sh_mobile_ceu_camera driver
and the soc-camera framework register them at their run-time. This uses
the V4L2 asynchronous subdevice probing capability.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---

v6: no change

 arch/arm/mach-shmobile/board-ap4evb.c |  103 +++-
 arch/arm/mach-shmobile/clock-sh7372.c |1 +
 2 files changed, 62 insertions(+), 42 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-ap4evb.c 
b/arch/arm/mach-shmobile/board-ap4evb.c
index 38f1259..450e06b 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -50,6 +50,7 @@
 #include media/sh_mobile_ceu.h
 #include media/sh_mobile_csi2.h
 #include media/soc_camera.h
+#include media/v4l2-async.h
 
 #include sound/sh_fsi.h
 #include sound/simple_card.h
@@ -871,22 +872,32 @@ static struct platform_device leds_device = {
},
 };
 
-static struct i2c_board_info imx074_info = {
-   I2C_BOARD_INFO(imx074, 0x1a),
+/* I2C */
+static struct soc_camera_subdev_desc imx074_desc;
+static struct i2c_board_info i2c0_devices[] = {
+   {
+   I2C_BOARD_INFO(ak4643, 0x13),
+   }, {
+   I2C_BOARD_INFO(imx074, 0x1a),
+   .platform_data = imx074_desc,
+   },
 };
 
-static struct soc_camera_link imx074_link = {
-   .bus_id = 0,
-   .board_info = imx074_info,
-   .i2c_adapter_id = 0,
-   .module_name= imx074,
+static struct i2c_board_info i2c1_devices[] = {
+   {
+   I2C_BOARD_INFO(r2025sd, 0x32),
+   },
 };
 
-static struct platform_device ap4evb_camera = {
-   .name   = soc-camera-pdrv,
-   .id = 0,
-   .dev= {
-   .platform_data = imx074_link,
+static struct resource csi2_resources[] = {
+   {
+   .name   = CSI2,
+   .start  = 0xffc9,
+   .end= 0xffc90fff,
+   .flags  = IORESOURCE_MEM,
+   }, {
+   .start  = intcs_evt2irq(0x17a0),
+   .flags  = IORESOURCE_IRQ,
},
 };
 
@@ -895,7 +906,7 @@ static struct sh_csi2_client_config csi2_clients[] = {
.phy= SH_CSI2_PHY_MAIN,
.lanes  = 0,/* default: 2 lanes */
.channel= 0,
-   .pdev   = ap4evb_camera,
+   .name   = imx074,
},
 };
 
@@ -906,31 +917,50 @@ static struct sh_csi2_pdata csi2_info = {
.flags  = SH_CSI2_ECC | SH_CSI2_CRC,
 };
 
-static struct resource csi2_resources[] = {
-   [0] = {
-   .name   = CSI2,
-   .start  = 0xffc9,
-   .end= 0xffc90fff,
-   .flags  = IORESOURCE_MEM,
+static struct platform_device csi2_device = {
+   .name   = sh-mobile-csi2,
+   .id = 0,
+   .num_resources  = ARRAY_SIZE(csi2_resources),
+   .resource   = csi2_resources,
+   .dev= {
+   .platform_data = csi2_info,
},
-   [1] = {
-   .start  = intcs_evt2irq(0x17a0),
-   .flags  = IORESOURCE_IRQ,
+};
+
+static struct soc_camera_async_subdev csi2_sd = {
+   .asd.hw = {
+   .bus_type = V4L2_ASYNC_BUS_PLATFORM,
+   .match.platform.name = sh-mobile-csi2.0,
},
+   .role = SOCAM_SUBDEV_DATA_PROCESSOR,
 };
 
-static struct sh_mobile_ceu_companion csi2 = {
-   .id = 0,
-   .num_resources  = ARRAY_SIZE(csi2_resources),
-   .resource   = csi2_resources,
-   .platform_data  = csi2_info,
+static struct soc_camera_async_subdev imx074_sd = {
+   .asd.hw = {
+   .bus_type = V4L2_ASYNC_BUS_I2C,
+   .match.i2c = {
+   .adapter_id = 0,
+   .address = 0x1a,
+   },
+   },
+   .role = SOCAM_SUBDEV_DATA_SOURCE,
 };
 
+static struct v4l2_async_subdev *ceu_subdevs[] = {
+   /* Single 2-element group */
+   csi2_sd.asd,
+   imx074_sd.asd,
+};
+
+/* 0-terminated array of group-sizes */
+static int ceu_subdev_sizes[] = {ARRAY_SIZE(ceu_subdevs), 0};
+
 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
.flags = SH_CEU_FLAG_USE_8BIT_BUS,
.max_width = 8188,
.max_height = 8188,
-   .csi2 = csi2,
+   .asd = ceu_subdevs,
+   .asd_sizes = ceu_subdev_sizes,
 };
 
 static struct resource ceu_resources[] = {
@@ -975,7 +1005,7 @@ static struct platform_device *ap4evb_devices[] __initdata 
= {
lcdc_device,
lcdc1_device,
ceu_device,
-   ap4evb_camera,
+   csi2_device,
meram_device,
 };
 
@@ -1070,19 +1100,6 @@ static struct i2c_board_info tsc_device = {
/*.irq is selected on ap4evb_init */
 };
 
-/* I2C */
-static struct i2c_board_info i2c0_devices[] = {
-   {
-  

[PATCH v6 0/7] V4L2 clock and async patches and soc-camera example

2013-03-15 Thread Guennadi Liakhovetski
Update of V4l2 clock and asynchronous probing patches. Various review 
comments are addressed, as described in individual patches.

Guennadi Liakhovetski (7):
  media: V4L2: add temporary clock helpers
  media: V4L2: support asynchronous subdevice registration
  media: soc-camera: switch I2C subdevice drivers to use v4l2-clk
  soc-camera: add V4L2-async support
  sh_mobile_ceu_camera: add asynchronous subdevice probing support
  imx074: support asynchronous probing
  ARM: shmobile: convert ap4evb to asynchronously register camera
subdevices

 arch/arm/mach-shmobile/board-ap4evb.c  |  103 ++--
 arch/arm/mach-shmobile/clock-sh7372.c  |1 +
 drivers/media/i2c/soc_camera/imx074.c  |   36 +-
 drivers/media/i2c/soc_camera/mt9m001.c |   17 +-
 drivers/media/i2c/soc_camera/mt9m111.c |   20 +-
 drivers/media/i2c/soc_camera/mt9t031.c |   19 +-
 drivers/media/i2c/soc_camera/mt9t112.c |   19 +-
 drivers/media/i2c/soc_camera/mt9v022.c |   17 +-
 drivers/media/i2c/soc_camera/ov2640.c  |   19 +-
 drivers/media/i2c/soc_camera/ov5642.c  |   20 +-
 drivers/media/i2c/soc_camera/ov6650.c  |   17 +-
 drivers/media/i2c/soc_camera/ov772x.c  |   15 +-
 drivers/media/i2c/soc_camera/ov9640.c  |   17 +-
 drivers/media/i2c/soc_camera/ov9640.h  |1 +
 drivers/media/i2c/soc_camera/ov9740.c  |   18 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |   17 +-
 drivers/media/i2c/soc_camera/tw9910.c  |   18 +-
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  136 +++--
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  162 +++---
 drivers/media/platform/soc_camera/soc_camera.c |  642 
 .../platform/soc_camera/soc_camera_platform.c  |2 +-
 drivers/media/v4l2-core/Makefile   |3 +-
 drivers/media/v4l2-core/v4l2-async.c   |  272 +
 drivers/media/v4l2-core/v4l2-clk.c |  184 ++
 include/media/sh_mobile_ceu.h  |2 +
 include/media/sh_mobile_csi2.h |2 +-
 include/media/soc_camera.h |   36 +-
 include/media/v4l2-async.h |  105 
 include/media/v4l2-clk.h   |   55 ++
 29 files changed, 1666 insertions(+), 309 deletions(-)
 create mode 100644 drivers/media/v4l2-core/v4l2-async.c
 create mode 100644 drivers/media/v4l2-core/v4l2-clk.c
 create mode 100644 include/media/v4l2-async.h
 create mode 100644 include/media/v4l2-clk.h

-- 
1.7.2.5

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html