Increase max exposure value to 255 from 26 for pac207

2011-10-27 Thread Marco Diego Aurélio Mesquita
Hi Devs!

There's a patch I sent some time ago[1] to increase the max exposure
value on pac207 based webcams. I see no problem with the patch, it has
survived hours of tests and is a simple on-liner.

It has been in queue for months now, and I really would like to get it
merged. Please, is there anything I can do about it?

[1] http://patchwork.linuxtv.org/patch/6850/
--
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


Switching input during capture

2011-10-27 Thread Gilles Gigan
Hi,
I would like to know what is the correct way to switch the current
video input during capture on a card with a single BT878 chip and 4
inputs 
(http://store.bluecherry.net/products/PV%252d143-%252d-4-port-video-capture-card-%2830FPS%29-%252d-OEM.html).
I tried doing it in two ways:
- using VIDIOC_S_INPUT to change the current input. While this works,
the next captured frame shows video from the old input in its top half
and video from the new input in the bottom half.
- I tried setting the input field to the new input and flags to
V4L2_BUF_FLAG_INPUT in the struct v4l2_buffer passed to VIDIOC_QBUF
when enqueuing buffers. However, when doing so, the ioctl fails
altogether, and I cannot enqueue any buffers with the
V4L2_BUF_FLAG_INPUT flag set.
Is there another way of doing it ? or is there a way to synchronise
the input change (when using VIDIOC_S_INPUT) so it happens in between
2 frames and produces a clean switch ?
Thanks
Gilles
--
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] Make use of media bus pixel codes in adv7170 driver

2011-10-27 Thread Christian Gmeiner
The ADV7170/ADV7171 can operate in either 8-bit or 16-bit YCrCb Mode.

* 8-Bit YCrCb Mode
This default mode accepts multiplexed YCrCb inputs through
the P7-P0 pixel inputs. The inputs follow the sequence Cb0, Y0
Cr0, Y1 Cb1, Y2, etc. The Y, Cb and Cr data are input on a
rising clock edge.

* 16-Bit YCrCb Mode
This mode accepts Y inputs through the P7–P0 pixel inputs and
multiplexed CrCb inputs through the P15–P8 pixel inputs. The
data is loaded on every second rising edge of CLOCK. The inputs
follow the sequence Cb0, Y0 Cr0, Y1 Cb1, Y2, etc.

Signed-off-by: Christian Gmeiner 
---
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 23ba5c3..29c253b 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -64,6 +64,11 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev 
*sd)
 
 static char *inputs[] = { "pass_through", "play_back" };
 
+static enum v4l2_mbus_pixelcode adv7170_codes[] = {
+   V4L2_MBUS_FMT_UYVY8_2X8,
+   V4L2_MBUS_FMT_UYVY8_1X16,
+};
+
 /* --- */
 
 static inline int adv7170_write(struct v4l2_subdev *sd, u8 reg, u8 value)
@@ -258,6 +263,60 @@ static int adv7170_s_routing(struct v4l2_subdev *sd,
return 0;
 }
 
+static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
+   enum v4l2_mbus_pixelcode *code)
+{
+   if (index >= ARRAY_SIZE(adv7170_codes))
+   return -EINVAL;
+
+   *code = adv7170_codes[index];
+   return 0;
+}
+
+static int adv7170_g_fmt(struct v4l2_subdev *sd,
+   struct v4l2_mbus_framefmt *mf)
+{
+   u8 val = adv7170_read(sd, 0x7);
+
+   if ((val & 0x40) == (1 << 6))
+   mf->code = V4L2_MBUS_FMT_UYVY8_1X16;
+   else
+   mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
+
+   mf->colorspace  = V4L2_COLORSPACE_SMPTE170M;
+   mf->width   = 0;
+   mf->height  = 0;
+   mf->field   = V4L2_FIELD_ANY;
+
+   return 0;
+}
+
+static int adv7170_s_fmt(struct v4l2_subdev *sd,
+   struct v4l2_mbus_framefmt *mf)
+{
+   u8 val = adv7170_read(sd, 0x7);
+   int ret;
+
+   switch (mf->code) {
+   case V4L2_MBUS_FMT_UYVY8_2X8:
+   val &= ~0x40;
+   break;
+
+   case V4L2_MBUS_FMT_UYVY8_1X16:
+   val |= 0x40;
+   break;
+
+   default:
+   v4l2_dbg(1, debug, sd,
+   "illegal v4l2_mbus_framefmt code: %d\n", mf->code);
+   return -EINVAL;
+   }
+
+   ret = adv7170_write(sd, 0x7, val);
+
+   return ret;
+}
+
 static int adv7170_g_chip_ident(struct v4l2_subdev *sd, struct 
v4l2_dbg_chip_ident *chip)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -274,6 +333,9 @@ static const struct v4l2_subdev_core_ops adv7170_core_ops = 
{
 static const struct v4l2_subdev_video_ops adv7170_video_ops = {
.s_std_output = adv7170_s_std_output,
.s_routing = adv7170_s_routing,
+   .s_mbus_fmt = adv7170_s_fmt,
+   .g_mbus_fmt = adv7170_g_fmt,
+   .enum_mbus_fmt  = adv7170_enum_fmt,
 };
 
 static const struct v4l2_subdev_ops adv7170_ops = {
--
1.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: WARNINGS

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

Results of the daily build of media_tree:

date:Thu Oct 27 19:00:20 CEST 2011
git hash:a63366b935456dd0984f237642f6d4001dcf8017
gcc version:  i686-linux-gcc (GCC) 4.6.1
host hardware:x86_64
host os:  3.0-4.slh.7-amd64

linux-git-armv5: WARNINGS
linux-git-armv5-davinci: WARNINGS
linux-git-armv5-ixp: WARNINGS
linux-git-armv5-omap2: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
linux-git-x86_64: WARNINGS
linux-2.6.31.12-i686: WARNINGS
linux-2.6.32.6-i686: WARNINGS
linux-2.6.33-i686: WARNINGS
linux-2.6.34-i686: WARNINGS
linux-2.6.35.3-i686: WARNINGS
linux-2.6.36-i686: WARNINGS
linux-2.6.37-i686: WARNINGS
linux-2.6.38.2-i686: WARNINGS
linux-2.6.39.1-i686: WARNINGS
linux-3.0-i686: WARNINGS
linux-3.1-i686: WARNINGS
linux-2.6.31.12-x86_64: WARNINGS
linux-2.6.32.6-x86_64: WARNINGS
linux-2.6.33-x86_64: WARNINGS
linux-2.6.34-x86_64: WARNINGS
linux-2.6.35.3-x86_64: WARNINGS
linux-2.6.36-x86_64: WARNINGS
linux-2.6.37-x86_64: WARNINGS
linux-2.6.38.2-x86_64: WARNINGS
linux-2.6.39.1-x86_64: WARNINGS
linux-3.0-x86_64: WARNINGS
linux-3.1-x86_64: WARNINGS
spec-git: WARNINGS
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The V4L-DVB specification 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: [RFC 0/3] omap3isp: add BT656 support

2011-10-27 Thread Enrico
On Thu, Oct 13, 2011 at 5:04 PM, Javier Martinez Canillas
 wrote:
> On Tue, Oct 11, 2011 at 5:08 PM, Enrico Butera  
> wrote:
>> This patch series add support for BT656 to omap3isp. It is based
>> on patches from Deepthy Ravi and Javier Martinez Canillas.
>>
>> To be applied on top of omap3isp-omap3isp-yuv branch at:
>>
>> git.linuxtv.org/pinchartl/media.git
>>
>> Enrico Butera (2):
>>  omap3isp: ispvideo: export isp_video_mbus_to_pix
>>  omap3isp: ispccdc: configure CCDC registers and add BT656 support
>>
>> Javier Martinez Canillas (1):
>>  omap3isp: ccdc: Add interlaced field mode to platform data
>>
>>  drivers/media/video/omap3isp/ispccdc.c  |  143 
>> ++-
>>  drivers/media/video/omap3isp/ispccdc.h  |    1 +
>>  drivers/media/video/omap3isp/ispreg.h   |    1 +
>>  drivers/media/video/omap3isp/ispvideo.c |    2 +-
>>  drivers/media/video/omap3isp/ispvideo.h |    4 +-
>>  include/media/omap3isp.h                |    3 +
>>  6 files changed, 129 insertions(+), 25 deletions(-)
>>
>> --
>> 1.7.4.1
>>
>
> Hello Laurent, Sakari and Deepthy,
>
> Did you take a look at Enrico's patches?
>
> We (Enrico, Gary and me) really want to add support both for
> interlaced mode and BT.656 video data format to the ISP driver.
>
> We are putting a lot of effort to this task but need the help of
> someone who knows better than use the ISP internals. So, we will be
> very happy if you can help us with this. We will address any issue you
> find with the patches.
>
> Right know we can get video in YUV format (CCDC BT.656 decoding and
> deinterlacing is already working) from the CCDC ouput pad
> (/dev/video2) but we have some ghosting effect and don't know what is
> causing this nor how to fix.
>
> Thank a lot and best regards,
>
> --
> Javier Martínez Canillas
> (+34) 682 39 81 69
> Barcelona, Spain

Ping?

Enrico
--
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] v4l: mt9p031/mt9t001: Use i2c_smbus_{read|write}_word_swapped()

2011-10-27 Thread Jean Delvare
On Sat, 22 Oct 2011 10:57:54 +0200, Laurent Pinchart wrote:
> The MT9P031 and MT9T001 sensors transfer 16-bit data on the I2C bus in
> swapped order. Let the I2C core handle byte order by using the
> i2c_smbus_{read|write}_word_swapped() functions.
> 
> Signed-off-by: Laurent Pinchart 

As far as I can tell, this fixes a bug too, the original code would not
work on big-endian machines.

Acked-by: Jean Delvare 

> ---
>  drivers/media/video/mt9p031.c |5 ++---
>  drivers/media/video/mt9t001.c |5 ++---
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
> index 5cfa39f..aa01c4b 100644
> --- a/drivers/media/video/mt9p031.c
> +++ b/drivers/media/video/mt9p031.c
> @@ -131,13 +131,12 @@ static struct mt9p031 *to_mt9p031(struct v4l2_subdev 
> *sd)
>  
>  static int mt9p031_read(struct i2c_client *client, u8 reg)
>  {
> - s32 data = i2c_smbus_read_word_data(client, reg);
> - return data < 0 ? data : be16_to_cpu(data);
> + return i2c_smbus_read_word_swapped(client, reg);
>  }
>  
>  static int mt9p031_write(struct i2c_client *client, u8 reg, u16 data)
>  {
> - return i2c_smbus_write_word_data(client, reg, cpu_to_be16(data));
> + return i2c_smbus_write_word_swapped(client, reg, data);
>  }
>  
>  static int mt9p031_set_output_control(struct mt9p031 *mt9p031, u16 clear,
> diff --git a/drivers/media/video/mt9t001.c b/drivers/media/video/mt9t001.c
> index cac1416..2ea6a08 100644
> --- a/drivers/media/video/mt9t001.c
> +++ b/drivers/media/video/mt9t001.c
> @@ -132,13 +132,12 @@ static inline struct mt9t001 *to_mt9t001(struct 
> v4l2_subdev *sd)
>  
>  static int mt9t001_read(struct i2c_client *client, u8 reg)
>  {
> - s32 data = i2c_smbus_read_word_data(client, reg);
> - return data < 0 ? data : be16_to_cpu(data);
> + return i2c_smbus_read_word_swapped(client, reg);
>  }
>  
>  static int mt9t001_write(struct i2c_client *client, u8 reg, u16 data)
>  {
> - return i2c_smbus_write_word_data(client, reg, cpu_to_be16(data));
> + return i2c_smbus_write_word_swapped(client, reg, data);
>  }
>  
>  static int mt9t001_set_output_control(struct mt9t001 *mt9t001, u16 clear,


-- 
Jean Delvare
--
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 5/6] v4l2-event: Add v4l2_subscribed_event_ops

2011-10-27 Thread Laurent Pinchart
Hi Hans,

On Thursday 27 October 2011 13:18:02 Hans de Goede wrote:
> Just like with ctrl events, drivers may want to get called back on
> listener add / remove for other event types too. Rather then special
> casing all of this in subscribe / unsubscribe event it is better to
> use ops for this.
> 
> Signed-off-by: Hans de Goede 
> ---
>  drivers/media/video/ivtv/ivtv-ioctl.c  |2 +-
>  drivers/media/video/omap3isp/ispccdc.c |2 +-
>  drivers/media/video/omap3isp/ispstat.c |2 +-
>  drivers/media/video/pwc/pwc-v4l.c  |2 +-
>  drivers/media/video/v4l2-event.c   |   42 ++---
>  drivers/media/video/vivi.c |2 +-
>  include/media/v4l2-event.h |   24 +-

Haven't you forgotten to update Documentation/video4linux/v4l2-framework.txt ?

>  7 files changed, 54 insertions(+), 22 deletions(-)

[snip]

> diff --git a/drivers/media/video/v4l2-event.c
> b/drivers/media/video/v4l2-event.c index 3d27300..2dd9252 100644
> --- a/drivers/media/video/v4l2-event.c
> +++ b/drivers/media/video/v4l2-event.c
> @@ -131,14 +131,14 @@ static void __v4l2_event_queue_fh(struct v4l2_fh *fh,
> const struct v4l2_event *e sev->first = sev_pos(sev, 1);
>   fh->navailable--;
>   if (sev->elems == 1) {
> - if (sev->replace) {
> - sev->replace(&kev->event, ev);
> + if (sev->ops && sev->ops->replace) {
> + sev->ops->replace(&kev->event, ev);
>   copy_payload = false;
>   }
> - } else if (sev->merge) {
> + } else if (sev->ops && sev->ops->merge) {
>   struct v4l2_kevent *second_oldest =
>   sev->events + sev_pos(sev, 0);
> - sev->merge(&kev->event, &second_oldest->event);
> + sev->ops->merge(&kev->event, &second_oldest->event);
>   }
>   }
> 
> @@ -207,8 +207,14 @@ static void ctrls_merge(const struct v4l2_event *old,
> struct v4l2_event *new) new->u.ctrl.changes |= old->u.ctrl.changes;
>  }
> 
> +const struct v4l2_subscribed_event_ops ctrl_ops = {

Shouldn't this be static const ?

> + .replace = ctrls_replace,
> + .merge = ctrls_merge,
> +};
> +
>  int v4l2_event_subscribe(struct v4l2_fh *fh,
> -  struct v4l2_event_subscription *sub, unsigned elems)
> +  struct v4l2_event_subscription *sub, unsigned elems,
> +  const struct v4l2_subscribed_event_ops *ops)
>  {
>   struct v4l2_subscribed_event *sev, *found_ev;
>   struct v4l2_ctrl *ctrl = NULL;
> @@ -236,9 +242,9 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
>   sev->flags = sub->flags;
>   sev->fh = fh;
>   sev->elems = elems;
> + sev->ops = ops;
>   if (ctrl) {
> - sev->replace = ctrls_replace;
> - sev->merge = ctrls_merge;
> + sev->ops = &ctrl_ops;
>   }

You can remove the brackets here.

> 
>   spin_lock_irqsave(&fh->vdev->fh_lock, flags);
> @@ -247,10 +253,22 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
>   list_add(&sev->list, &fh->subscribed);
>   spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
> 
> - /* v4l2_ctrl_add_event uses a mutex, so do this outside the spin lock */
> - if (found_ev)
> + if (found_ev) {
>   kfree(sev);
> - else if (ctrl)
> + return 0; /* Already listening */
> + }
> +
> + if (sev->ops && sev->ops->add) {
> + int ret = sev->ops->add(sev);
> + if (ret) {
> + sev->ops = NULL;
> + v4l2_event_unsubscribe(fh, sub);
> + return ret;
> + }
> + }
> +
> + /* v4l2_ctrl_add_event uses a mutex, so do this outside the spin lock */
> + if (ctrl)
>   v4l2_ctrl_add_event(ctrl, sev);
> 
>   return 0;
> @@ -307,6 +325,10 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
>   }
> 
>   spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
> +
> + if (sev && sev->ops && sev->ops->del)
> + sev->ops->del(sev);
> +
>   if (sev && sev->type == V4L2_EVENT_CTRL) {
>   struct v4l2_ctrl *ctrl = v4l2_ctrl_find(fh->ctrl_handler, 
> sev->id);
> 

-- 
Regards,

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


Re: [PATCH 4/6] v4l2-event: Don't set sev->fh to NULL on unsubcribe

2011-10-27 Thread Laurent Pinchart
Hi Hans,

On Thursday 27 October 2011 13:18:01 Hans de Goede wrote:
> 1: There is no reason for this after v4l2_event_unsubscribe releases the
> spinlock nothing is holding a reference to the sev anymore except for the
> local reference in the v4l2_event_unsubscribe function.
> 
> 2: Setting sev->fh to NULL causes problems for the del op added in the next
> patch of this series, since this op needs a way to get to its own data
> structures, and typically this will be done by using container_of on an
> embedded v4l2_fh struct.
> 
> Signed-off-by: Hans de Goede 

Acked-by: Laurent Pinchart 

While reviewing the patch I noticed that v4l2_event_unsubscribe_all() calls 
v4l2_event_unsubscribe(), which performs control lookup again. Is there a 
reason for that, instead of handling event unsubscription directly in 
v4l2_event_unsubscribe_all() ?

> ---
>  drivers/media/video/v4l2-event.c |1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/media/video/v4l2-event.c
> b/drivers/media/video/v4l2-event.c index 01cbb7f..3d27300 100644
> --- a/drivers/media/video/v4l2-event.c
> +++ b/drivers/media/video/v4l2-event.c
> @@ -304,7 +304,6 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
>   }
>   }
>   list_del(&sev->list);
> - sev->fh = NULL;
>   }
> 
>   spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);

-- 
Regards,

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


Re: [PATCH 3/6] v4l2-event: Remove pending events from fh event queue when unsubscribing

2011-10-27 Thread Laurent Pinchart
Hi Hans,

On Thursday 27 October 2011 13:18:00 Hans de Goede wrote:
> The kev pointers inside the pending events queue (the available queue) of
> the fh point to data inside the sev, unsubscribing frees the sev, thus
> making these pointers point to freed memory!
> 
> This patch fixes these dangling pointers in the available queue by removing
> all matching pending events on unsubscription.
> 
> Signed-off-by: Hans de Goede 

Acked-by: Laurent Pinchart 

> ---
>  drivers/media/video/v4l2-event.c |8 
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/media/video/v4l2-event.c
> b/drivers/media/video/v4l2-event.c index 9f56f18..01cbb7f 100644
> --- a/drivers/media/video/v4l2-event.c
> +++ b/drivers/media/video/v4l2-event.c
> @@ -284,6 +284,7 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
>  struct v4l2_event_subscription *sub)
>  {
>   struct v4l2_subscribed_event *sev;
> + struct v4l2_kevent *kev, *next;
>   unsigned long flags;
> 
>   if (sub->type == V4L2_EVENT_ALL) {
> @@ -295,6 +296,13 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
> 
>   sev = v4l2_event_subscribed(fh, sub->type, sub->id);
>   if (sev != NULL) {
> + /* Remove any pending events for this subscription */
> + list_for_each_entry_safe(kev, next, &fh->available, list) {
> + if (kev->sev == sev) {
> + list_del(&kev->list);
> + fh->navailable--;
> + }
> + }
>   list_del(&sev->list);
>   sev->fh = NULL;
>   }

-- 
Regards,

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


Re: [PATCH 2/6] v4l2-event: Deny subscribing with a type of V4L2_EVENT_ALL

2011-10-27 Thread Laurent Pinchart
Hi Hans,

On Thursday 27 October 2011 13:17:59 Hans de Goede wrote:
> Signed-off-by: Hans de Goede 

This brings the code in sync with the documentation, thanks.

Acked-by: Laurent Pinchart 

> ---
>  drivers/media/video/v4l2-event.c |3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/media/video/v4l2-event.c
> b/drivers/media/video/v4l2-event.c index 53b190c..9f56f18 100644
> --- a/drivers/media/video/v4l2-event.c
> +++ b/drivers/media/video/v4l2-event.c
> @@ -215,6 +215,9 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
>   unsigned long flags;
>   unsigned i;
> 
> + if (sub->type == V4L2_EVENT_ALL)
> + return -EINVAL;
> +
>   if (elems < 1)
>   elems = 1;
>   if (sub->type == V4L2_EVENT_CTRL) {

-- 
Regards,

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


[PATCH 2/2] uvcvideo: Add support for control events

2011-10-27 Thread Hans de Goede
Signed-off-by: Hans de Goede 
---
 drivers/media/video/uvc/uvc_ctrl.c |  104 
 drivers/media/video/uvc/uvc_v4l2.c |   51 -
 drivers/media/video/uvc/uvcvideo.h |9 +++
 3 files changed, 161 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/uvc/uvc_ctrl.c 
b/drivers/media/video/uvc/uvc_ctrl.c
index 1a2c1a3..b9486e5 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "uvcvideo.h"
 
@@ -1308,6 +1309,107 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
 }
 
 /* --
+ * Ctrl event handling
+ */
+
+static void uvc_ctrl_fill_event(struct uvc_video_chain *chain,
+   struct v4l2_event *ev,
+   struct uvc_control *ctrl,
+   struct uvc_control_mapping *mapping,
+   u32 value, u32 changes)
+{
+   struct v4l2_queryctrl v4l2_ctrl;
+
+   __uvc_query_v4l2_ctrl(chain, ctrl, mapping, &v4l2_ctrl);
+
+   memset(ev->reserved, 0, sizeof(ev->reserved));
+   ev->type = V4L2_EVENT_CTRL;
+   ev->id = v4l2_ctrl.id;
+   ev->u.ctrl.value = value;
+   ev->u.ctrl.changes = changes;
+   ev->u.ctrl.type = v4l2_ctrl.type;
+   ev->u.ctrl.flags = v4l2_ctrl.flags;
+   ev->u.ctrl.minimum = v4l2_ctrl.minimum;
+   ev->u.ctrl.maximum = v4l2_ctrl.maximum;
+   ev->u.ctrl.step = v4l2_ctrl.step;
+   ev->u.ctrl.default_value = v4l2_ctrl.default_value;
+}
+
+void uvc_ctrl_send_event(struct uvc_fh *handle,
+   struct v4l2_ext_control *xctrl)
+{
+   struct v4l2_event ev;
+   struct v4l2_subscribed_event *sev;
+   struct uvc_control *ctrl;
+   struct uvc_control_mapping *mapping;
+
+   ctrl = uvc_find_control(handle->chain, xctrl->id, &mapping);
+
+   if (list_empty(&mapping->ev_subs))
+   return;
+
+   uvc_ctrl_fill_event(handle->chain, &ev, ctrl, mapping, xctrl->value,
+   V4L2_EVENT_CTRL_CH_VALUE);
+
+   list_for_each_entry(sev, &mapping->ev_subs, node)
+   if (sev->fh && (sev->fh != &handle->vfh ||
+(sev->flags & V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK)))
+   v4l2_event_queue_fh(sev->fh, &ev);
+}
+
+static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev)
+{
+   struct uvc_fh *handle = container_of(sev->fh, struct uvc_fh, vfh);
+   struct uvc_control *ctrl;
+   struct uvc_control_mapping *mapping;
+   int ret;
+
+   ret = mutex_lock_interruptible(&handle->chain->ctrl_mutex);
+   if (ret < 0)
+   return -ERESTARTSYS;
+
+   ctrl = uvc_find_control(handle->chain, sev->id, &mapping);
+   if (ctrl == NULL) {
+   ret = -EINVAL;
+   goto done;
+   }
+
+   list_add_tail(&sev->node, &mapping->ev_subs);
+   if (sev->flags & V4L2_EVENT_SUB_FL_SEND_INITIAL) {
+   struct v4l2_event ev;
+   struct v4l2_ext_control xctrl = { .value = 0 };
+   u32 changes = V4L2_EVENT_CTRL_CH_FLAGS;
+
+   if (__uvc_ctrl_get(handle->chain, ctrl, mapping, &xctrl) == 0)
+   changes |= V4L2_EVENT_CTRL_CH_VALUE;
+
+   uvc_ctrl_fill_event(handle->chain, &ev, ctrl, mapping,
+   xctrl.value, changes);
+   v4l2_event_queue_fh(sev->fh, &ev);
+   }
+
+done:
+   mutex_unlock(&handle->chain->ctrl_mutex);
+   return ret;
+}
+
+static void uvc_ctrl_del_event(struct v4l2_subscribed_event *sev)
+{
+   struct uvc_fh *handle = container_of(sev->fh, struct uvc_fh, vfh);
+
+   mutex_lock(&handle->chain->ctrl_mutex);
+   list_del(&sev->node);
+   mutex_unlock(&handle->chain->ctrl_mutex);
+}
+
+const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops = {
+   .add = uvc_ctrl_add_event,
+   .del = uvc_ctrl_del_event,
+   .replace = v4l2_ctrl_replace,
+   .merge = v4l2_ctrl_merge,
+};
+
+/* --
  * Dynamic controls
  */
 
@@ -1652,6 +1754,8 @@ static int __uvc_ctrl_add_mapping(struct uvc_device *dev,
if (map == NULL)
return -ENOMEM;
 
+   INIT_LIST_HEAD(&map->ev_subs);
+
size = sizeof(*mapping->menu_info) * mapping->menu_count;
map->menu_info = kmemdup(mapping->menu_info, size, GFP_KERNEL);
if (map->menu_info == NULL) {
diff --git a/drivers/media/video/uvc/uvc_v4l2.c 
b/drivers/media/video/uvc/uvc_v4l2.c
index dadf11f..1c577a3 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -25,6 +25,7 @@
 
 #include 
 #include 
+#include 
 
 #include "uvcvideo.h"
 
@@ -495,6 +496,8 @@ static int uvc_v4l2_open(struct file *file)
}
}
 
+   v4l2_fh_init(&handle->vfh, stream->vdev);
+   v4l2_fh_add(&handle->vfh);
handle->chain = stream-

[PATCH 1/2] uvcvideo: Refactor uvc_ctrl_get and query

2011-10-27 Thread Hans de Goede
This is a preparation patch for adding ctrl event support.

Signed-off-by: Hans de Goede 
---
 drivers/media/video/uvc/uvc_ctrl.c |   62 +---
 1 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/drivers/media/video/uvc/uvc_ctrl.c 
b/drivers/media/video/uvc/uvc_ctrl.c
index 254d326..1a2c1a3 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -886,24 +886,14 @@ static int uvc_ctrl_populate_cache(struct uvc_video_chain 
*chain,
return 0;
 }
 
-int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
+static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
+   struct uvc_control *ctrl,
+   struct uvc_control_mapping *mapping,
struct v4l2_queryctrl *v4l2_ctrl)
 {
-   struct uvc_control *ctrl;
-   struct uvc_control_mapping *mapping;
struct uvc_menu_info *menu;
unsigned int i;
-   int ret;
-
-   ret = mutex_lock_interruptible(&chain->ctrl_mutex);
-   if (ret < 0)
-   return -ERESTARTSYS;
-
-   ctrl = uvc_find_control(chain, v4l2_ctrl->id, &mapping);
-   if (ctrl == NULL) {
-   ret = -EINVAL;
-   goto done;
-   }
+   int ret = 0;
 
memset(v4l2_ctrl, 0, sizeof *v4l2_ctrl);
v4l2_ctrl->id = mapping->id;
@@ -972,6 +962,28 @@ int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
  uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
 
 done:
+   return ret;
+}
+
+int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
+   struct v4l2_queryctrl *v4l2_ctrl)
+{
+   struct uvc_control *ctrl;
+   struct uvc_control_mapping *mapping;
+   int ret;
+
+   ret = mutex_lock_interruptible(&chain->ctrl_mutex);
+   if (ret < 0)
+   return -ERESTARTSYS;
+
+   ctrl = uvc_find_control(chain, v4l2_ctrl->id, &mapping);
+   if (ctrl == NULL) {
+   ret = -EINVAL;
+   goto done;
+   }
+
+   ret = __uvc_query_v4l2_ctrl(chain, ctrl, mapping, v4l2_ctrl);
+done:
mutex_unlock(&chain->ctrl_mutex);
return ret;
 }
@@ -1135,17 +1147,16 @@ done:
return ret;
 }
 
-int uvc_ctrl_get(struct uvc_video_chain *chain,
+static int __uvc_ctrl_get(struct uvc_video_chain *chain,
+   struct uvc_control *ctrl,
+   struct uvc_control_mapping *mapping,
struct v4l2_ext_control *xctrl)
 {
-   struct uvc_control *ctrl;
-   struct uvc_control_mapping *mapping;
struct uvc_menu_info *menu;
unsigned int i;
int ret;
 
-   ctrl = uvc_find_control(chain, xctrl->id, &mapping);
-   if (ctrl == NULL || (ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0)
+   if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0)
return -EINVAL;
 
if (!ctrl->loaded) {
@@ -1175,6 +1186,19 @@ int uvc_ctrl_get(struct uvc_video_chain *chain,
return 0;
 }
 
+int uvc_ctrl_get(struct uvc_video_chain *chain,
+   struct v4l2_ext_control *xctrl)
+{
+   struct uvc_control *ctrl;
+   struct uvc_control_mapping *mapping;
+
+   ctrl = uvc_find_control(chain, xctrl->id, &mapping);
+   if (ctrl == NULL)
+   return -EINVAL;
+
+   return __uvc_ctrl_get(chain, ctrl, mapping, xctrl);
+}
+
 int uvc_ctrl_set(struct uvc_video_chain *chain,
struct v4l2_ext_control *xctrl)
 {
-- 
1.7.7

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


uvcvideo: Add support for control events

2011-10-27 Thread Hans de Goede
Hi All,

This patch set adds support for control events to the uvcvideo driver. Note
this patch set depends on the "Various ctrl and event frame work patches"
set which I just send out.

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


[PATCH 6/6] v4l2-ctrls: Use v4l2_subscribed_event_ops

2011-10-27 Thread Hans de Goede
Signed-off-by: Hans de Goede 
---
 drivers/media/video/ivtv/ivtv-ioctl.c |3 +-
 drivers/media/video/pwc/pwc-v4l.c |2 +-
 drivers/media/video/v4l2-ctrls.c  |   56 +++--
 drivers/media/video/v4l2-event.c  |   39 ---
 drivers/media/video/vivi.c|2 +-
 include/media/v4l2-ctrls.h|7 ++--
 6 files changed, 53 insertions(+), 56 deletions(-)

diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index 9aec8a0..72fd74f 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1455,8 +1455,9 @@ static int ivtv_subscribe_event(struct v4l2_fh *fh, 
struct v4l2_event_subscripti
switch (sub->type) {
case V4L2_EVENT_VSYNC:
case V4L2_EVENT_EOS:
-   case V4L2_EVENT_CTRL:
return v4l2_event_subscribe(fh, sub, 0, NULL);
+   case V4L2_EVENT_CTRL:
+   return v4l2_event_subscribe(fh, sub, 0, &v4l2_ctrl_sub_ev_ops);
default:
return -EINVAL;
}
diff --git a/drivers/media/video/pwc/pwc-v4l.c 
b/drivers/media/video/pwc/pwc-v4l.c
index 7f159bf..afc5b15 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -1138,7 +1138,7 @@ static int pwc_subscribe_event(struct v4l2_fh *fh,
 {
switch (sub->type) {
case V4L2_EVENT_CTRL:
-   return v4l2_event_subscribe(fh, sub, 0, NULL);
+   return v4l2_event_subscribe(fh, sub, 0, &v4l2_ctrl_sub_ev_ops);
default:
return -EINVAL;
}
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 69e24f4..c4dec20 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -2329,10 +2329,22 @@ int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
 }
 EXPORT_SYMBOL(v4l2_ctrl_s_ctrl);
 
-void v4l2_ctrl_add_event(struct v4l2_ctrl *ctrl,
-   struct v4l2_subscribed_event *sev)
+static int v4l2_ctrl_add_event(struct v4l2_subscribed_event *sev)
 {
-   v4l2_ctrl_lock(ctrl);
+   struct v4l2_ctrl_handler *hdl = sev->fh->ctrl_handler;
+   struct v4l2_ctrl_ref *ref;
+   struct v4l2_ctrl *ctrl;
+   int ret = 0;
+
+   mutex_lock(&hdl->lock);
+
+   ref = find_ref(hdl, sev->id);
+   if (!ref) {
+   ret = -EINVAL;
+   goto leave;
+   }
+   ctrl = ref->ctrl;
+
list_add_tail(&sev->node, &ctrl->ev_subs);
if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS &&
(sev->flags & V4L2_EVENT_SUB_FL_SEND_INITIAL)) {
@@ -2344,15 +2356,39 @@ void v4l2_ctrl_add_event(struct v4l2_ctrl *ctrl,
fill_event(&ev, ctrl, changes);
v4l2_event_queue_fh(sev->fh, &ev);
}
-   v4l2_ctrl_unlock(ctrl);
+leave:
+   mutex_unlock(&hdl->lock);
+   return ret;
 }
-EXPORT_SYMBOL(v4l2_ctrl_add_event);
 
-void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl,
-   struct v4l2_subscribed_event *sev)
+static void v4l2_ctrl_del_event(struct v4l2_subscribed_event *sev)
 {
-   v4l2_ctrl_lock(ctrl);
+   struct v4l2_ctrl_handler *hdl = sev->fh->ctrl_handler;
+
+   mutex_lock(&hdl->lock);
list_del(&sev->node);
-   v4l2_ctrl_unlock(ctrl);
+   mutex_unlock(&hdl->lock);
 }
-EXPORT_SYMBOL(v4l2_ctrl_del_event);
+
+void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new)
+{
+   u32 old_changes = old->u.ctrl.changes;
+
+   old->u.ctrl = new->u.ctrl;
+   old->u.ctrl.changes |= old_changes;
+}
+EXPORT_SYMBOL(v4l2_ctrl_replace);
+
+void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new)
+{
+   new->u.ctrl.changes |= old->u.ctrl.changes;
+}
+EXPORT_SYMBOL(v4l2_ctrl_merge);
+
+const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops = {
+   .add = v4l2_ctrl_add_event,
+   .del = v4l2_ctrl_del_event,
+   .replace = v4l2_ctrl_replace,
+   .merge = v4l2_ctrl_merge,
+};
+EXPORT_SYMBOL(v4l2_ctrl_sub_ev_ops);
diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c
index 2dd9252..2f5ee7b 100644
--- a/drivers/media/video/v4l2-event.c
+++ b/drivers/media/video/v4l2-event.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -194,30 +193,11 @@ int v4l2_event_pending(struct v4l2_fh *fh)
 }
 EXPORT_SYMBOL_GPL(v4l2_event_pending);
 
-static void ctrls_replace(struct v4l2_event *old, const struct v4l2_event *new)
-{
-   u32 old_changes = old->u.ctrl.changes;
-
-   old->u.ctrl = new->u.ctrl;
-   old->u.ctrl.changes |= old_changes;
-}
-
-static void ctrls_merge(const struct v4l2_event *old, struct v4l2_event *new)
-{
-   new->u.ctrl.changes |= old->u.ctrl.changes;
-}
-
-const struct v4l2_subscribed_event_ops ctrl_ops = {
-   .replace = ctrls_replace,
-   .merge = ctrls_merge,
-};
-
 int v4l2_event_subscribe(struct

[PATCH 5/6] v4l2-event: Add v4l2_subscribed_event_ops

2011-10-27 Thread Hans de Goede
Just like with ctrl events, drivers may want to get called back on
listener add / remove for other event types too. Rather then special
casing all of this in subscribe / unsubscribe event it is better to
use ops for this.

Signed-off-by: Hans de Goede 
---
 drivers/media/video/ivtv/ivtv-ioctl.c  |2 +-
 drivers/media/video/omap3isp/ispccdc.c |2 +-
 drivers/media/video/omap3isp/ispstat.c |2 +-
 drivers/media/video/pwc/pwc-v4l.c  |2 +-
 drivers/media/video/v4l2-event.c   |   42 ---
 drivers/media/video/vivi.c |2 +-
 include/media/v4l2-event.h |   24 +-
 7 files changed, 54 insertions(+), 22 deletions(-)

diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index ecafa69..9aec8a0 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1456,7 +1456,7 @@ static int ivtv_subscribe_event(struct v4l2_fh *fh, 
struct v4l2_event_subscripti
case V4L2_EVENT_VSYNC:
case V4L2_EVENT_EOS:
case V4L2_EVENT_CTRL:
-   return v4l2_event_subscribe(fh, sub, 0);
+   return v4l2_event_subscribe(fh, sub, 0, NULL);
default:
return -EINVAL;
}
diff --git a/drivers/media/video/omap3isp/ispccdc.c 
b/drivers/media/video/omap3isp/ispccdc.c
index 40b141c..b6da736 100644
--- a/drivers/media/video/omap3isp/ispccdc.c
+++ b/drivers/media/video/omap3isp/ispccdc.c
@@ -1700,7 +1700,7 @@ static int ccdc_subscribe_event(struct v4l2_subdev *sd, 
struct v4l2_fh *fh,
if (sub->id != 0)
return -EINVAL;
 
-   return v4l2_event_subscribe(fh, sub, OMAP3ISP_CCDC_NEVENTS);
+   return v4l2_event_subscribe(fh, sub, OMAP3ISP_CCDC_NEVENTS, NULL);
 }
 
 static int ccdc_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
diff --git a/drivers/media/video/omap3isp/ispstat.c 
b/drivers/media/video/omap3isp/ispstat.c
index 8080659..4f337a2 100644
--- a/drivers/media/video/omap3isp/ispstat.c
+++ b/drivers/media/video/omap3isp/ispstat.c
@@ -1049,7 +1049,7 @@ int omap3isp_stat_subscribe_event(struct v4l2_subdev 
*subdev,
if (sub->type != stat->event_type)
return -EINVAL;
 
-   return v4l2_event_subscribe(fh, sub, STAT_NEVENTS);
+   return v4l2_event_subscribe(fh, sub, STAT_NEVENTS, NULL);
 }
 
 int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
diff --git a/drivers/media/video/pwc/pwc-v4l.c 
b/drivers/media/video/pwc/pwc-v4l.c
index 68e1323..7f159bf 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -1138,7 +1138,7 @@ static int pwc_subscribe_event(struct v4l2_fh *fh,
 {
switch (sub->type) {
case V4L2_EVENT_CTRL:
-   return v4l2_event_subscribe(fh, sub, 0);
+   return v4l2_event_subscribe(fh, sub, 0, NULL);
default:
return -EINVAL;
}
diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c
index 3d27300..2dd9252 100644
--- a/drivers/media/video/v4l2-event.c
+++ b/drivers/media/video/v4l2-event.c
@@ -131,14 +131,14 @@ static void __v4l2_event_queue_fh(struct v4l2_fh *fh, 
const struct v4l2_event *e
sev->first = sev_pos(sev, 1);
fh->navailable--;
if (sev->elems == 1) {
-   if (sev->replace) {
-   sev->replace(&kev->event, ev);
+   if (sev->ops && sev->ops->replace) {
+   sev->ops->replace(&kev->event, ev);
copy_payload = false;
}
-   } else if (sev->merge) {
+   } else if (sev->ops && sev->ops->merge) {
struct v4l2_kevent *second_oldest =
sev->events + sev_pos(sev, 0);
-   sev->merge(&kev->event, &second_oldest->event);
+   sev->ops->merge(&kev->event, &second_oldest->event);
}
}
 
@@ -207,8 +207,14 @@ static void ctrls_merge(const struct v4l2_event *old, 
struct v4l2_event *new)
new->u.ctrl.changes |= old->u.ctrl.changes;
 }
 
+const struct v4l2_subscribed_event_ops ctrl_ops = {
+   .replace = ctrls_replace,
+   .merge = ctrls_merge,
+};
+
 int v4l2_event_subscribe(struct v4l2_fh *fh,
-struct v4l2_event_subscription *sub, unsigned elems)
+struct v4l2_event_subscription *sub, unsigned elems,
+const struct v4l2_subscribed_event_ops *ops)
 {
struct v4l2_subscribed_event *sev, *found_ev;
struct v4l2_ctrl *ctrl = NULL;
@@ -236,9 +242,9 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
sev->flags = sub->flags;
sev->fh = fh;
sev->elems = elems;
+   sev->ops = ops;
if (ctrl) {
-   sev->replace = ctrls_replace;
-  

[PATCH 4/6] v4l2-event: Don't set sev->fh to NULL on unsubcribe

2011-10-27 Thread Hans de Goede
1: There is no reason for this after v4l2_event_unsubscribe releases the
spinlock nothing is holding a reference to the sev anymore except for the
local reference in the v4l2_event_unsubscribe function.

2: Setting sev->fh to NULL causes problems for the del op added in the next
patch of this series, since this op needs a way to get to its own data
structures, and typically this will be done by using container_of on an
embedded v4l2_fh struct.

Signed-off-by: Hans de Goede 
---
 drivers/media/video/v4l2-event.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c
index 01cbb7f..3d27300 100644
--- a/drivers/media/video/v4l2-event.c
+++ b/drivers/media/video/v4l2-event.c
@@ -304,7 +304,6 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
}
}
list_del(&sev->list);
-   sev->fh = NULL;
}
 
spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
-- 
1.7.7

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


[PATCH 3/6] v4l2-event: Remove pending events from fh event queue when unsubscribing

2011-10-27 Thread Hans de Goede
The kev pointers inside the pending events queue (the available queue) of the
fh point to data inside the sev, unsubscribing frees the sev, thus making these
pointers point to freed memory!

This patch fixes these dangling pointers in the available queue by removing
all matching pending events on unsubscription.

Signed-off-by: Hans de Goede 
---
 drivers/media/video/v4l2-event.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c
index 9f56f18..01cbb7f 100644
--- a/drivers/media/video/v4l2-event.c
+++ b/drivers/media/video/v4l2-event.c
@@ -284,6 +284,7 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
   struct v4l2_event_subscription *sub)
 {
struct v4l2_subscribed_event *sev;
+   struct v4l2_kevent *kev, *next;
unsigned long flags;
 
if (sub->type == V4L2_EVENT_ALL) {
@@ -295,6 +296,13 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
 
sev = v4l2_event_subscribed(fh, sub->type, sub->id);
if (sev != NULL) {
+   /* Remove any pending events for this subscription */
+   list_for_each_entry_safe(kev, next, &fh->available, list) {
+   if (kev->sev == sev) {
+   list_del(&kev->list);
+   fh->navailable--;
+   }
+   }
list_del(&sev->list);
sev->fh = NULL;
}
-- 
1.7.7

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


[PATCH 2/6] v4l2-event: Deny subscribing with a type of V4L2_EVENT_ALL

2011-10-27 Thread Hans de Goede
Signed-off-by: Hans de Goede 
---
 drivers/media/video/v4l2-event.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c
index 53b190c..9f56f18 100644
--- a/drivers/media/video/v4l2-event.c
+++ b/drivers/media/video/v4l2-event.c
@@ -215,6 +215,9 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
unsigned long flags;
unsigned i;
 
+   if (sub->type == V4L2_EVENT_ALL)
+   return -EINVAL;
+
if (elems < 1)
elems = 1;
if (sub->type == V4L2_EVENT_CTRL) {
-- 
1.7.7

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


[PATCH 1/6] v4l2-ctrl: Send change events to all fh for auto cluster slave controls

2011-10-27 Thread Hans de Goede
Otherwise the fh changing the master control won't get the inactive state
change event for the slave controls.

Signed-off-by: Hans de Goede 
---
 drivers/media/video/v4l2-ctrls.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index fc8666a..69e24f4 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -945,6 +945,7 @@ static void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl 
*ctrl,
if (ctrl->cluster[0]->has_volatiles)
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
}
+   fh = NULL;
}
if (changed || update_inactive) {
/* If a control was changed that was not one of the controls
-- 
1.7.7

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


Various ctrl and event frame work patches

2011-10-27 Thread Hans de Goede
Hi All,

This patch set obsoletes my previous "add v4l2_subscribed_event_ops" set,
while working on adding support for ctrl-events to the uvc driver I found
a few bugs in the event code, which this patchset fixes.

Regards,

Hans



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


Re: [PATCH 4/9] mm: MIGRATE_CMA migration type added

2011-10-27 Thread Michal Nazarewicz

On Tue, 18 Oct 2011 06:08:26 -0700, Mel Gorman  wrote:

This does mean that MIGRATE_CMA also does not have a per-cpu list.
I don't know if that matters to you but all allocations using
MIGRATE_CMA will take the zone lock.


On Mon, 24 Oct 2011 21:32:45 +0200, Michal Nazarewicz  wrote:

This is sort of an artefact of my misunderstanding of pcp lists in the
past.  I'll have to re-evaluate the decision not to include CMA on pcp
list.


Actually sorry.  My comment above is somehow invalid.

The CMA does not need to be on pcp list because CMA pages are never allocated
via standard kmalloc() and friends.  Because of the fallbacks in rmqueue_bulk()
the CMA pages end up being added to a pcp list of the MOVABLE type and so when
kmallec() allocates an MOVABLE page it can end up grabbing a CMA page.

So it's quite OK that CMA does not have its own pcp list as the list would
not be used anyway.

--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
--
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] Digital Devices Cine CT V6 support

2011-10-27 Thread COEXSI


> -Original Message-
> From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
> ow...@vger.kernel.org] On Behalf Of Ralph Metzler
> Sent: lundi 24 octobre 2011 20:31
> To: S é bastien RAILLARD (COEXSI)
> Cc: 'Linux Media Mailing List'
> Subject: RE: [DVB] Digital Devices Cine CT V6 support
> 
> Sébastien RAILLARD (COEXSI) writes:
>  > I've seen a new parameter "ts_loop", can you explain how it's
> working?
>  > Is-it for sending the stream from the demodulator directly to the CAM
> > reader?
> 
> No, it is mainly for testing. It declares one TAB as loopback, which
> means that the data output is directly connected to the input.
> 
> For redirecting a stream through a CI see the "redirect" attribute.
> I don't know if my small redirect readme was included in the package I
> sent to Oliver. So, I attached it below.
> 
> 
> -Ralph
> 
> 
> 
> Redirection of TS streams through CI modules is now supported through
> /sys/class/ddbridge/ddbridge0/redirect.
> It only works with cards based on the ddbridge PCIe bridge, not with
> nGene based cards.
> 
> It is set up in such a way that you can write "AB CD" to a "redirect"
> attribute and data from input B of card A is then piped through port D
> (meaning TAB (D+1) which uses output D and input 2*D for CI io) of card
> C and then shows up in the demux device belonging to input B (input
> (B&1) of TAB (B/2+1)) of card A.
> 
> E.g.:
> 
> echo "00 01" > /sys/class/ddbridge/ddbridge0/redirect
> 
> will pipe input 0 of card 0 through CI at port 1 (TAB 2) of card 0.
> 

Dear Ralph,

I've made two diagrams (see below) to explain the numbering based on your
explanation and the driver code source.
I hope they are right and it can help for understanding the octopus bridge.

The good news with the new redirect function is we can emulate the
traditional CAM handling and then use the current DVB software without
modification.

Best regards,
Sebastien.


  OCTOPUS BRIDGE

++
  Tuner 0 -> Input 0 -> ||
| Port 0 - TAB 1 | -> Output 0
  Tuner 1 -> Input 1 -> ||
++
  Tuner 0 -> Input 2 -> ||
| Port 1 - TAB 2 | -> Output 1
  Tuner 1 -> Input 3 -> ||
++
  Tuner 0 -> Input 4 -> ||
| Port 2 - TAB 3 | -> Output 2
  Tuner 1 -> Input 5 -> ||
++
  Tuner 0 -> Input 6 -> ||
| Port 3 - TAB 4 | -> Output 3
  Tuner 1 -> Input 7 -> ||
++


 CineS2 v6 + 2 CAM Readers

++
  Tuner 0 -> Input 0 -> ||
| Port 0 - TAB 1 | -> Output 0
  Tuner 1 -> Input 1 -> | DVB-S2 |
++
 Input 2 -> ||
| Port 1 - TAB 2 | -> Output 1
 Input 3 -> ||
++
CAM 0 -> Input 4 -> ||
| Port 2 - TAB 3 | -> Output 2 -> CAM 0
 Input 5 -> |   CAM  |
++
CAM 1 -> Input 6 -> ||
| Port 3 - TAB 4 | -> Output 3 -> CAM 1
 Input 7 -> |   CAM  |
++

Two redirections to set : 

* "X0 X2" (input #0 to port #2)
* "X1 X3" (input #1 to port #3)

Where X is the device number.


> Redirection should only be done right after loading the driver (or
> booting if the driver is built-in) and before using the devices in any
> way.
> 
> --
> 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