Re: [PATCH 2/3] ts2020: add ts2020 tuner driver

2012-05-08 Thread Konstantin Dimitrov
On Tue, May 8, 2012 at 9:32 AM, Igor M. Liplianin  wrote:
> On 7 Ð¼Ð°Ñ  2012 00:22:30 Konstantin Dimitrov wrote:
>> add separate ts2020 tuner driver
>>
>> Signed-off-by: Konstantin Dimitrov 
>>
>> --- a/linux/drivers/media/dvb/frontends/Kconfig       2012-04-20
>> 06:45:55.0 +0300
>> +++ b/linux/drivers/media/dvb/frontends/Kconfig       2012-05-07
>> 00:58:26.888543350 +0300
>> @@ -221,6 +221,13 @@
>>       help
>>         A DVB-S tuner module. Say Y when you want to support this frontend.
>>
>> +config DVB_TS2020
>> +     tristate "Montage Tehnology TS2020 based tuners"
>> +     depends on DVB_CORE && I2C
>> +     default m if DVB_FE_CUSTOMISE
>> +     help
>> +       A DVB-S/S2 silicon tuner. Say Y when you want to support this tuner.
>> +
>>  config DVB_DS3000
>>       tristate "Montage Tehnology DS3000 based"
>>       depends on DVB_CORE && I2C
>> --- a/linux/drivers/media/dvb/frontends/Makefile      2012-04-20
>> 06:45:55.0 +0300
>> +++ b/linux/drivers/media/dvb/frontends/Makefile      2012-05-07
>> 00:54:44.624546145 +0300
>> @@ -87,6 +87,7 @@
>>  obj-$(CONFIG_DVB_EC100) += ec100.o
>>  obj-$(CONFIG_DVB_HD29L2) += hd29l2.o
>>  obj-$(CONFIG_DVB_DS3000) += ds3000.o
>> +obj-$(CONFIG_DVB_TS2020) += ts2020.o
>>  obj-$(CONFIG_DVB_MB86A16) += mb86a16.o
>>  obj-$(CONFIG_DVB_MB86A20S) += mb86a20s.o
>>  obj-$(CONFIG_DVB_IX2505V) += ix2505v.o
>> --- a/linux/drivers/media/dvb/frontends/ts2020.h      2012-05-07
>> 01:36:49.876514403 +0300
>> +++ b/linux/drivers/media/dvb/frontends/ts2020.h      2012-05-07
>> 01:12:54.148532449 +0300
>> @@ -0,0 +1,68 @@
>> +/*
>> +    Montage Technology TS2020 - Silicon Tuner driver
>> +    Copyright (C) 2009-2012 Konstantin Dimitrov 
>> +
>> +    Copyright (C) 2009-2012 TurboSight.com
>> +
>> +    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, write to the Free Software
>> +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>> + */
>> +
>> +#ifndef TS2020_H
>> +#define TS2020_H
>> +
>> +#include 
>> +
>> +struct ts2020_config {
>> +     u8 tuner_address;
>> +};
>> +
>> +struct ts2020_state {
>> +     struct i2c_adapter *i2c;
>> +     const struct ts2020_config *config;
>> +     struct dvb_frontend *frontend;
>> +     int status;
>> +};
>> +
>> +#if defined(CONFIG_DVB_TS2020) || \
>> +     (defined(CONFIG_DVB_TS2020_MODULE) && defined(MODULE))
>> +
>> +extern struct dvb_frontend *ts2020_attach(
>> +     struct dvb_frontend *fe,
>> +     const struct ts2020_config *config,
>> +     struct i2c_adapter *i2c);
>> +
>> +extern int ts2020_get_signal_strength(
>> +     struct dvb_frontend *fe,
>> +     u16 *strength);
>> +#else
>> +static inline struct dvb_frontend *ts2020_attach(
>> +     struct dvb_frontend *fe,
>> +     const struct ts2020_config *config,
>> +     struct i2c_adapter *i2c)
>> +{
>> +     printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
>> +     return NULL;
>> +}
>> +
>> +static inline int ts2020_get_signal_strength(
>> +     struct dvb_frontend *fe,
>> +     u16 *strength)
>> +{
>> +     printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
>> +     return NULL;
>> +}
>> +#endif
>> +
>> +#endif /* TS2020_H */
>> --- a/linux/drivers/media/dvb/frontends/ts2020_cfg.h  2012-05-07
>> 01:36:59.836514279 +0300
>> +++ b/linux/drivers/media/dvb/frontends/ts2020_cfg.h  2012-05-07
>> 01:12:56.248532422 +0300
>> @@ -0,0 +1,64 @@
>> +/*
>> +    Montage Technology TS2020 - Silicon Tuner driver
>> +    Copyright (C) 2009-2012 Konstantin Dimitrov 
>> +
>> +    Copyright (C) 2009-2012 TurboSight.com
>> +
>> +    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, write to the Free Software
>> +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>> + */
>> +
>> +static int ts2020_get_frequency(struct dvb_frontend *fe, u32 *frequency

Re: [PATCH v2 1/1] v4l2: use __u32 rather than enums in ioctl() structs

2012-05-08 Thread Sakari Ailus
Hi Hans,

Thanks for your coments.

Hans Verkuil wrote:
> On Mon May 7 2012 16:27:49 Sakari Ailus wrote:
>> From: Rémi Denis-Courmont 
>>
>> V4L2 uses the enum type in IOCTL arguments in IOCTLs that were defined until
>> the use of enum was considered less than ideal. Recently Rémi Denis-Courmont
>> brought up the issue by proposing a patch to convert the enums to unsigned:
>>
>> http://www.spinics.net/lists/linux-media/msg46167.html>
>>
>> This sparked a long discussion where another solution to the issue was
>> proposed: two sets of IOCTL structures, one with __u32 and the other with
>> enums, and conversion code between the two:
>>
>> http://www.spinics.net/lists/linux-media/msg47168.html>
>>
>> Both approaches implement a complete solution that resolves the problem. The
>> first one is simple but requires assuming enums and __u32 are the same in
>> size (so we won't break the ABI) while the second one is more complex and
>> less clean but does not require making that assumption.
>>
>> The issue boils down to whether enums are fundamentally different from __u32
>> or not, and can the former be substituted by the latter. During the
>> discussion it was concluded that the __u32 has the same size as enums on all
>> archs Linux is supported: it has not been shown that replacing those enums
>> in IOCTL arguments would break neither source or binary compatibility. If no
>> such reason is found, just replacing the enums with __u32s is the way to go.
>>
>> This is what this patch does. This patch is slightly different from Remi's
>> first RFC (link above): it uses __u32 instead of unsigned and also changes
>> the arguments of VIDIOC_G_PRIORITY and VIDIOC_S_PRIORITY.
>>
>> Signed-off-by: Rémi Denis-Courmont 
>> Signed-off-by: Sakari Ailus 
>> ---
>> Changes since v1:
>>
>> - Fixes according to comments by Hans Verkuil:
>>   - Update documentation
>>   - Also remove enums in compat32 code
>>
>>  Documentation/DocBook/media/v4l/io.xml |   12 +++--
>>  .../DocBook/media/v4l/vidioc-create-bufs.xml   |   10 +++--
>>  Documentation/DocBook/media/v4l/vidioc-cropcap.xml |4 +-
>>  .../DocBook/media/v4l/vidioc-enum-fmt.xml  |4 +-
>>  Documentation/DocBook/media/v4l/vidioc-g-crop.xml  |4 +-
>>  Documentation/DocBook/media/v4l/vidioc-g-fmt.xml   |2 +-
>>  .../DocBook/media/v4l/vidioc-g-frequency.xml   |6 +-
>>  Documentation/DocBook/media/v4l/vidioc-g-parm.xml  |5 +-
>>  .../DocBook/media/v4l/vidioc-g-sliced-vbi-cap.xml  |2 +-
>>  Documentation/DocBook/media/v4l/vidioc-g-tuner.xml |2 +-
>>  .../DocBook/media/v4l/vidioc-queryctrl.xml |2 +-
>>  Documentation/DocBook/media/v4l/vidioc-reqbufs.xml |7 ++-
>>  .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|5 +-
>>  drivers/media/video/v4l2-compat-ioctl32.c  |   12 +++---
>>  include/linux/videodev2.h  |   46 
>> ++--
>>  15 files changed, 65 insertions(+), 58 deletions(-)
>>
>> diff --git a/Documentation/DocBook/media/v4l/io.xml 
>> b/Documentation/DocBook/media/v4l/io.xml
>> index b815929..fd6aca2 100644
>> --- a/Documentation/DocBook/media/v4l/io.xml
>> +++ b/Documentation/DocBook/media/v4l/io.xml
>> @@ -543,12 +543,13 @@ and can range from zero to the number of buffers 
>> allocated
>>  with the &VIDIOC-REQBUFS; ioctl (&v4l2-requestbuffers; 
>> count) minus one.
>>
>>
>> -&v4l2-buf-type;
>> +__u32
> 
> The problem with replacing &v4l2-buf-type; by __u32 is that you loose the link
> to the v4l2-buf-type enum.
> 
>>  type
>>  
>>  Type of the buffer, same as &v4l2-format;
> 
> I would change this to something like:
> 
> Type of the buffer (see enum &v4l2-buf-type;), same as...
> 
> Same for all the other similar cases. Annoying, I know, but I believe it is
> important to have these links available.

The links are available in each of the spots enums were replaced. In
many cases they already existed so I haven't added new ones in that
case. The typical from I've used is "See ." This
could be mentioned to have more direct relation to the enum.

In many cases the IOCTL documentation itself specifies the valid values.
Especially in those cases the enum should be given as reference only.
Perhaps it'll also make sense to revisit these places where e.g. only
some buffer types are mentioned to be valid in a context of an IOCTL,
but this is out of the scope of this patch IMO.

>> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
>> index 5a09ac3..585e4b4 100644
>> --- a/include/linux/videodev2.h
>> +++ b/include/linux/videodev2.h
>> @@ -292,10 +292,10 @@ struct v4l2_pix_format {
>>  __u32   width;
>>  __u32   height;
>>  __u32   pixelformat;
>> -enum v4l2_field field;
>> +__u32   field;
> 
> Same here: you need a comment like "/* see enum v4l2_field */" to keep the
> association between the field

Re: Re: [PATCH 2/3] ts2020: add ts2020 tuner driver

2012-05-08 Thread Igor M. Liplianin
On 8 мая 2012 10:09:47 Konstantin Dimitrov wrote:
> On Tue, May 8, 2012 at 9:32 AM, Igor M. Liplianin  wrote:
> > On 7 Ð¼Ð°Ñ  2012 00:22:30 Konstantin Dimitrov wrote:
> >> add separate ts2020 tuner driver
> >> 
> >> Signed-off-by: Konstantin Dimitrov 
> >> 
> >> --- a/linux/drivers/media/dvb/frontends/Kconfig       2012-04-20
> >> 06:45:55.0 +0300
> >> +++ b/linux/drivers/media/dvb/frontends/Kconfig       2012-05-07
> >> 00:58:26.888543350 +0300
> >> @@ -221,6 +221,13 @@
> >> Â  Â  Â  help
> >> Â  Â  Â  Â  A DVB-S tuner module. Say Y when you want to support this
> >> frontend.
> >> 
> >> +config DVB_TS2020
> >> + Â  Â  tristate "Montage Tehnology TS2020 based tuners"
> >> + Â  Â  depends on DVB_CORE && I2C
> >> + Â  Â  default m if DVB_FE_CUSTOMISE
> >> + Â  Â  help
> >> + Â  Â  Â  A DVB-S/S2 silicon tuner. Say Y when you want to support this
> >> tuner. +
> >> Â config DVB_DS3000
> >> Â  Â  Â  tristate "Montage Tehnology DS3000 based"
> >> Â  Â  Â  depends on DVB_CORE && I2C
> >> --- a/linux/drivers/media/dvb/frontends/Makefile      2012-04-20
> >> 06:45:55.0 +0300
> >> +++ b/linux/drivers/media/dvb/frontends/Makefile      2012-05-07
> >> 00:54:44.624546145 +0300
> >> @@ -87,6 +87,7 @@
> >> Â obj-$(CONFIG_DVB_EC100) += ec100.o
> >> Â obj-$(CONFIG_DVB_HD29L2) += hd29l2.o
> >> Â obj-$(CONFIG_DVB_DS3000) += ds3000.o
> >> +obj-$(CONFIG_DVB_TS2020) += ts2020.o
> >> Â obj-$(CONFIG_DVB_MB86A16) += mb86a16.o
> >> Â obj-$(CONFIG_DVB_MB86A20S) += mb86a20s.o
> >> Â obj-$(CONFIG_DVB_IX2505V) += ix2505v.o
> >> --- a/linux/drivers/media/dvb/frontends/ts2020.h      2012-05-07
> >> 01:36:49.876514403 +0300
> >> +++ b/linux/drivers/media/dvb/frontends/ts2020.h      2012-05-07
> >> 01:12:54.148532449 +0300
> >> @@ -0,0 +1,68 @@
> >> +/*
> >> + Â  Â Montage Technology TS2020 - Silicon Tuner driver
> >> + Â  Â Copyright (C) 2009-2012 Konstantin Dimitrov
> >> 
> >> +
> >> + Â  Â Copyright (C) 2009-2012 TurboSight.com
> >> +
> >> + Â  Â 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, write to the Free Software
> >> + Â  Â Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> >> + */
> >> +
> >> +#ifndef TS2020_H
> >> +#define TS2020_H
> >> +
> >> +#include 
> >> +
> >> +struct ts2020_config {
> >> + Â  Â  u8 tuner_address;
> >> +};
> >> +
> >> +struct ts2020_state {
> >> + Â  Â  struct i2c_adapter *i2c;
> >> + Â  Â  const struct ts2020_config *config;
> >> + Â  Â  struct dvb_frontend *frontend;
> >> + Â  Â  int status;
> >> +};
> >> +
> >> +#if defined(CONFIG_DVB_TS2020) || \
> >> + Â  Â  (defined(CONFIG_DVB_TS2020_MODULE) && defined(MODULE))
> >> +
> >> +extern struct dvb_frontend *ts2020_attach(
> >> + Â  Â  struct dvb_frontend *fe,
> >> + Â  Â  const struct ts2020_config *config,
> >> + Â  Â  struct i2c_adapter *i2c);
> >> +
> >> +extern int ts2020_get_signal_strength(
> >> + Â  Â  struct dvb_frontend *fe,
> >> + Â  Â  u16 *strength);
> >> +#else
> >> +static inline struct dvb_frontend *ts2020_attach(
> >> + Â  Â  struct dvb_frontend *fe,
> >> + Â  Â  const struct ts2020_config *config,
> >> + Â  Â  struct i2c_adapter *i2c)
> >> +{
> >> + Â  Â  printk(KERN_WARNING "%s: driver disabled by Kconfig\n", 
__func__);
> >> + Â  Â  return NULL;
> >> +}
> >> +
> >> +static inline int ts2020_get_signal_strength(
> >> + Â  Â  struct dvb_frontend *fe,
> >> + Â  Â  u16 *strength)
> >> +{
> >> + Â  Â  printk(KERN_WARNING "%s: driver disabled by Kconfig\n", 
__func__);
> >> + Â  Â  return NULL;
> >> +}
> >> +#endif
> >> +
> >> +#endif /* TS2020_H */
> >> --- a/linux/drivers/media/dvb/frontends/ts2020_cfg.h  2012-05-07
> >> 01:36:59.836514279 +0300
> >> +++ b/linux/drivers/media/dvb/frontends/ts2020_cfg.h  2012-05-07
> >> 01:12:56.248532422 +0300
> >> @@ -0,0 +1,64 @@
> >> +/*
> >> + Â  Â Montage Technology TS2020 - Silicon Tuner driver
> >> + Â  Â Copyright (C) 2009-2012 Konstantin Dimitrov
> >> 
> >> +
> >> + Â  Â Copyright (C) 2009-2012 TurboSight.com
> >> +
> >> + Â  Â 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 

[PATCH 1/2] TeVii DVB-S s421 and s632 cards support

2012-05-08 Thread Igor M. Liplianin
DVB-S chip is Montage m88rs2000, so initial patch is simple.

Signed-off-by: Igor M. Liplianin diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
index 451c5a7..4b2d190 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -1,9 +1,9 @@
 /* DVB USB framework compliant Linux driver for the
  *	DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
- *	TeVii S600, S630, S650, S660, S480,
+ *	TeVii S600, S630, S650, S660, S480, S421, S632
  *	Prof 1100, 7500,
  *	Geniatech SU3000 Cards
- * Copyright (C) 2008-2011 Igor M. Liplianin (liplia...@me.by)
+ * Copyright (C) 2008-2012 Igor M. Liplianin (liplia...@me.by)
  *
  *	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
@@ -27,6 +27,7 @@
 #include "stv6110.h"
 #include "stb6100.h"
 #include "stb6100_proc.h"
+#include "m88rs2000.h"
 
 #ifndef USB_PID_DW2102
 #define USB_PID_DW2102 0x2102
@@ -68,6 +69,14 @@
 #define USB_PID_PROF_1100 0xb012
 #endif
 
+#ifndef USB_PID_TEVII_S421
+#define USB_PID_TEVII_S421 0xd421
+#endif
+
+#ifndef USB_PID_TEVII_S632
+#define USB_PID_TEVII_S632 0xd632
+#endif
+
 #define DW210X_READ_MSG 0
 #define DW210X_WRITE_MSG 1
 
@@ -538,7 +547,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
 		}
 		/*case 0x55: cx24116
 		case 0x6a: stv0903
-		case 0x68: ds3000, stv0903
+		case 0x68: ds3000, stv0903, rs2000
 		case 0x60: ts2020, stv6110, stb6100
 		case 0xa0: eeprom */
 		default: {
@@ -987,6 +996,38 @@ static struct ds3000_config su3000_ds3000_config = {
 	.ci_mode = 1,
 };
 
+static u8 m88rs2000_inittab[] = {
+	DEMOD_WRITE, 0x9a, 0x30,
+	DEMOD_WRITE, 0x00, 0x01,
+	WRITE_DELAY, 0x19, 0x00,
+	DEMOD_WRITE, 0x00, 0x00,
+	DEMOD_WRITE, 0x9a, 0xb0,
+	DEMOD_WRITE, 0x81, 0xc1,
+	TUNER_WRITE, 0x42, 0x73,
+	TUNER_WRITE, 0x05, 0x07,
+	TUNER_WRITE, 0x20, 0x27,
+	TUNER_WRITE, 0x07, 0x02,
+	TUNER_WRITE, 0x11, 0xff,
+	TUNER_WRITE, 0x60, 0xf9,
+	TUNER_WRITE, 0x08, 0x01,
+	TUNER_WRITE, 0x00, 0x41,
+	DEMOD_WRITE, 0x81, 0x81,
+	DEMOD_WRITE, 0x86, 0xc6,
+	DEMOD_WRITE, 0x9a, 0x30,
+	DEMOD_WRITE, 0xf0, 0x80,
+	DEMOD_WRITE, 0xf1, 0xbf,
+	DEMOD_WRITE, 0xb0, 0x45,
+	DEMOD_WRITE, 0xb2, 0x01,
+	DEMOD_WRITE, 0x9a, 0xb0,
+	0xff, 0xaa, 0xff
+};
+
+static struct m88rs2000_config s421_m88rs2000_config = {
+	.demod_addr = 0x68,
+	.tuner_addr = 0x60,
+	.inittab = m88rs2000_inittab,
+};
+
 static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
 {
 	struct dvb_tuner_ops *tuner_ops = NULL;
@@ -1214,6 +1255,24 @@ static int su3000_frontend_attach(struct dvb_usb_adapter *d)
 	return 0;
 }
 
+static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d)
+{
+	u8 obuf[] = { 0x51 };
+	u8 ibuf[] = { 0 };
+
+	if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
+		err("command 0x51 transfer failed.");
+
+	d->fe_adap[0].fe = dvb_attach(m88rs2000_attach, &s421_m88rs2000_config,
+	&d->dev->i2c_adap);
+	if (d->fe_adap[0].fe == NULL)
+		return -EIO;
+
+	info("Attached m88rs2000!\n");
+
+	return 0;
+}
+
 static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
 {
 	dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
@@ -1451,6 +1510,8 @@ enum dw2102_table_entry {
 	TEVII_S480_1,
 	TEVII_S480_2,
 	X3M_SPC1400HD,
+	TEVII_S421,
+	TEVII_S632,
 };
 
 static struct usb_device_id dw2102_table[] = {
@@ -1469,6 +1530,8 @@ static struct usb_device_id dw2102_table[] = {
 	[TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
 	[TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
 	[X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
+	[TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
+	[TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
 	{ }
 };
 
@@ -1818,6 +1881,19 @@ static struct dvb_usb_device_description d7500 = {
 	{NULL},
 };
 
+struct dvb_usb_device_properties *s421;
+static struct dvb_usb_device_description d421 = {
+	"TeVii S421 PCI",
+	{&dw2102_table[TEVII_S421], NULL},
+	{NULL},
+};
+
+static struct dvb_usb_device_description d632 = {
+	"TeVii S632 USB",
+	{&dw2102_table[TEVII_S632], NULL},
+	{NULL},
+};
+
 static struct dvb_usb_device_properties su3000_properties = {
 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
 	.usb_ctrl = DEVICE_SPECIFIC,
@@ -1915,6 +1991,20 @@ static int dw2102_probe(struct usb_interface *intf,
 	p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
 	p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
 
+
+	s421 = kmemdup(&su3000_properties,
+		   sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
+	if (!s421) {
+		kfree(p1100);
+		kfree(s660);
+		kfree(p7500);
+		return -ENOMEM;
+	}
+	s421->num_device_descs = 2;
+	s421->devices[0] = d421;
+	s421->devices[1] = d632;
+	s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach;
+
 	if (0 == dvb_usb_device_init(intf, &dw2102_properties,
 			THIS_MODULE, NULL, adapter_nr) ||
 	0 == dvb_usb_device_init(intf, &dw2104_properties,
@@ -1929,6 +2019,8 @@ s

Re: [PATCH for v3.5] v4l2-event: fix regression with initial event handling.

2012-05-08 Thread Hans de Goede

Hi,

Good one, ACK.

Acked-by: Hans de Goede 

Regards,

Hans

On 05/07/2012 10:53 PM, Hans Verkuil wrote:

From: Hans Verkuil

If the V4L2_EVENT_SUB_FL_SEND_INITIAL was set, then the application expects
to receive an initial event of the initial value of the control.

However, commit c53c2549333b340e2662dc64ec81323476b69a97 that added the new
v4l2_subscribed_event_ops introduced a regression: while the code still queued
that initial event the __v4l2_event_queue_fh() function was modified to ignore
such requests if sev->elems was 0 (meaning that the event subscription wasn't
finished yet).

And sev->elems was only set to a non-zero value after the add operation
returned.

This patch fixes this by passing the elems value to the add function. Then the
add function can set it before queuing the initial event.

Signed-off-by: Hans Verkuil
---
  drivers/media/video/uvc/uvc_ctrl.c |5 -
  drivers/media/video/v4l2-ctrls.c   |5 -
  drivers/media/video/v4l2-event.c   |2 +-
  include/media/v4l2-event.h |2 +-
  4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/uvc/uvc_ctrl.c 
b/drivers/media/video/uvc/uvc_ctrl.c
index 28363b7..f3bd66c 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -1250,7 +1250,7 @@ static void uvc_ctrl_send_events(struct uvc_fh *handle,
}
  }

-static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev)
+static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned 
elems)
  {
struct uvc_fh *handle = container_of(sev->fh, struct uvc_fh, vfh);
struct uvc_control_mapping *mapping;
@@ -1278,6 +1278,9 @@ static int uvc_ctrl_add_event(struct 
v4l2_subscribed_event *sev)

uvc_ctrl_fill_event(handle->chain,&ev, ctrl, mapping, val,
changes);
+   /* Mark the queue as active, allowing this initial
+  event to be accepted. */
+   sev->elems = elems;
v4l2_event_queue_fh(sev->fh,&ev);
}

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index ae544d8..20873c2 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -2424,7 +2424,7 @@ int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
  }
  EXPORT_SYMBOL(v4l2_ctrl_s_ctrl);

-static int v4l2_ctrl_add_event(struct v4l2_subscribed_event *sev)
+static int v4l2_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned 
elems)
  {
struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id);

@@ -2441,6 +2441,9 @@ static int v4l2_ctrl_add_event(struct 
v4l2_subscribed_event *sev)
if (!(ctrl->flags&  V4L2_CTRL_FLAG_WRITE_ONLY))
changes |= V4L2_EVENT_CTRL_CH_VALUE;
fill_event(&ev, ctrl, changes);
+   /* Mark the queue as active, allowing this initial
+  event to be accepted. */
+   sev->elems = elems;
v4l2_event_queue_fh(sev->fh,&ev);
}
v4l2_ctrl_unlock(ctrl);
diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c
index 60b4e2e..ef2a33c 100644
--- a/drivers/media/video/v4l2-event.c
+++ b/drivers/media/video/v4l2-event.c
@@ -239,7 +239,7 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
}

if (sev->ops&&  sev->ops->add) {
-   int ret = sev->ops->add(sev);
+   int ret = sev->ops->add(sev, elems);
if (ret) {
sev->ops = NULL;
v4l2_event_unsubscribe(fh, sub);
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
index 88fa9a1..2885a81 100644
--- a/include/media/v4l2-event.h
+++ b/include/media/v4l2-event.h
@@ -85,7 +85,7 @@ struct v4l2_kevent {
* @merge:   Optional callback that can merge event 'old' into event 'new'.
*/
  struct v4l2_subscribed_event_ops {
-   int  (*add)(struct v4l2_subscribed_event *sev);
+   int  (*add)(struct v4l2_subscribed_event *sev, unsigned elems);
void (*del)(struct v4l2_subscribed_event *sev);
void (*replace)(struct v4l2_event *old, const struct v4l2_event *new);
void (*merge)(const struct v4l2_event *old, struct v4l2_event *new);

--
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] TeVii DVB-S s421 and s632 cards support, rs2000 part

2012-05-08 Thread Igor M. Liplianin
One register needs to be changed to TS to work. So we use separate inittab.

Signed-off-by: Igor M. Liplianin 
diff --git a/drivers/media/dvb/frontends/m88rs2000.c b/drivers/media/dvb/frontends/m88rs2000.c
index 045ee5a..547230d 100644
--- a/drivers/media/dvb/frontends/m88rs2000.c
+++ b/drivers/media/dvb/frontends/m88rs2000.c
@@ -442,7 +442,11 @@ static int m88rs2000_init(struct dvb_frontend *fe)
 
 	deb_info("m88rs2000: init chip\n");
 	/* Setup frontend from shutdown/cold */
-	ret = m88rs2000_tab_set(state, m88rs2000_setup);
+	if (state->config->inittab)
+		ret = m88rs2000_tab_set(state,
+(struct inittab *)state->config->inittab);
+	else
+		ret = m88rs2000_tab_set(state, m88rs2000_setup);
 
 	return ret;
 }


m88rs2000: LNB voltage control implemented

2012-05-08 Thread Igor M. Liplianin
Trival patch to get it working with my cards stuff.

Signed-off-by: Igor M. Liplianin diff --git a/drivers/media/dvb/frontends/m88rs2000.c b/drivers/media/dvb/frontends/m88rs2000.c
index 547230d..f6d6e39 100644
--- a/drivers/media/dvb/frontends/m88rs2000.c
+++ b/drivers/media/dvb/frontends/m88rs2000.c
@@ -416,9 +416,25 @@ static int m88rs2000_tab_set(struct m88rs2000_state *state,
 
 static int m88rs2000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t volt)
 {
-	deb_info("%s: %s\n", __func__,
-		volt == SEC_VOLTAGE_13 ? "SEC_VOLTAGE_13" :
-		volt == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" : "??");
+	struct m88rs2000_state *state = fe->demodulator_priv;
+	u8 data;
+
+	data = m88rs2000_demod_read(state, 0xb2);
+	data |= 0x03; /* bit0 V/H, bit1 off/on */
+
+	switch (volt) {
+	case SEC_VOLTAGE_18:
+		data &= ~0x03;
+		break;
+	case SEC_VOLTAGE_13:
+		data &= ~0x03;
+		data |= 0x01;
+		break;
+	case SEC_VOLTAGE_OFF:
+		break;
+	}
+
+	m88rs2000_demod_write(state, 0xb2, data);
 
 	return 0;
 }


[PATCH] media_build: fix backport patches removing et61x251 hunks

2012-05-08 Thread Gianluca Gennari
The old et61x251 driver has been removed:

http://git.linuxtv.org/media_tree.git/commit/04ef052419ac61f28c6b7eafbe5d8e82c02bbee2

so let's delete the related hunks from the media_build backport patches.

Signed-off-by: Gianluca Gennari 
---
 backports/api_version.patch |6 --
 backports/pr_fmt.patch  |   24 
 2 files changed, 0 insertions(+), 30 deletions(-)

diff --git a/backports/api_version.patch b/backports/api_version.patch
index 147221c..9bd9348 100644
--- a/backports/api_version.patch
+++ b/backports/api_version.patch
@@ -1,9 +1,3 @@
-diff --git a/drivers/media/video/et61x251/et61x251_core.c 
b/drivers/media/video/et61x251/et61x251_core.c
 a/drivers/media/video/et61x251/et61x251_core.c
-+++ b/drivers/media/video/et61x251/et61x251_core.c
-@@ -1582,1 +1582,1 @@ et61x251_vidioc_querycap(struct et61x251
--  .version = LINUX_VERSION_CODE,
-+  .version = V4L2_VERSION,
 diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c 
b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
 +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
diff --git a/backports/pr_fmt.patch b/backports/pr_fmt.patch
index e6db18e..5561d6f 100644
--- a/backports/pr_fmt.patch
+++ b/backports/pr_fmt.patch
@@ -322,30 +322,6 @@ index ffd8bc7..c38d97d 100644
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  
  #include "cx25821-video.h"
-diff --git a/drivers/media/video/et61x251/et61x251_core.c 
b/drivers/media/video/et61x251/et61x251_core.c
-index 5539f09..8cdf5b6 100644
 a/drivers/media/video/et61x251/et61x251_core.c
-+++ b/drivers/media/video/et61x251/et61x251_core.c
-@@ -18,6 +18,7 @@
-  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *
-  ***/
- 
-+#undef pr_fmt
- #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
- 
- #include 
-diff --git a/drivers/media/video/et61x251/et61x251_tas5130d1b.c 
b/drivers/media/video/et61x251/et61x251_tas5130d1b.c
-index ced2e16..3977c93 100644
 a/drivers/media/video/et61x251/et61x251_tas5130d1b.c
-+++ b/drivers/media/video/et61x251/et61x251_tas5130d1b.c
-@@ -19,6 +19,7 @@
-  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *
-  ***/
- 
-+#undef pr_fmt
- #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
- 
- #include "et61x251_sensor.h"
 diff --git a/drivers/media/video/gspca/benq.c 
b/drivers/media/video/gspca/benq.c
 index 9769f17..e9b1052 100644
 --- a/drivers/media/video/gspca/benq.c
-- 
1.7.0.4

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


Re: [PATCH] media_build: fix backport patches removing et61x251 hunks

2012-05-08 Thread Hans Verkuil
On Tuesday 08 May 2012 10:42:49 Gianluca Gennari wrote:
> The old et61x251 driver has been removed:
> 
> http://git.linuxtv.org/media_tree.git/commit/04ef052419ac61f28c6b7eafbe5d8e82c02bbee2
> 
> so let's delete the related hunks from the media_build backport patches.

Thanks!

Committed.

Regards,

Hans

> 
> Signed-off-by: Gianluca Gennari 
> ---
>  backports/api_version.patch |6 --
>  backports/pr_fmt.patch  |   24 
>  2 files changed, 0 insertions(+), 30 deletions(-)
> 
> diff --git a/backports/api_version.patch b/backports/api_version.patch
> index 147221c..9bd9348 100644
> --- a/backports/api_version.patch
> +++ b/backports/api_version.patch
> @@ -1,9 +1,3 @@
> -diff --git a/drivers/media/video/et61x251/et61x251_core.c 
> b/drivers/media/video/et61x251/et61x251_core.c
>  a/drivers/media/video/et61x251/et61x251_core.c
> -+++ b/drivers/media/video/et61x251/et61x251_core.c
> -@@ -1582,1 +1582,1 @@ et61x251_vidioc_querycap(struct et61x251
> --.version = LINUX_VERSION_CODE,
> -+.version = V4L2_VERSION,
>  diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c 
> b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
>  --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
>  +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
> diff --git a/backports/pr_fmt.patch b/backports/pr_fmt.patch
> index e6db18e..5561d6f 100644
> --- a/backports/pr_fmt.patch
> +++ b/backports/pr_fmt.patch
> @@ -322,30 +322,6 @@ index ffd8bc7..c38d97d 100644
>   #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>   
>   #include "cx25821-video.h"
> -diff --git a/drivers/media/video/et61x251/et61x251_core.c 
> b/drivers/media/video/et61x251/et61x251_core.c
> -index 5539f09..8cdf5b6 100644
>  a/drivers/media/video/et61x251/et61x251_core.c
> -+++ b/drivers/media/video/et61x251/et61x251_core.c
> -@@ -18,6 +18,7 @@
> -  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *
> -  
> ***/
> - 
> -+#undef pr_fmt
> - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> - 
> - #include 
> -diff --git a/drivers/media/video/et61x251/et61x251_tas5130d1b.c 
> b/drivers/media/video/et61x251/et61x251_tas5130d1b.c
> -index ced2e16..3977c93 100644
>  a/drivers/media/video/et61x251/et61x251_tas5130d1b.c
> -+++ b/drivers/media/video/et61x251/et61x251_tas5130d1b.c
> -@@ -19,6 +19,7 @@
> -  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *
> -  
> ***/
> - 
> -+#undef pr_fmt
> - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> - 
> - #include "et61x251_sensor.h"
>  diff --git a/drivers/media/video/gspca/benq.c 
> b/drivers/media/video/gspca/benq.c
>  index 9769f17..e9b1052 100644
>  --- a/drivers/media/video/gspca/benq.c
> 
--
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: [PATCHv5 08/13] v4l: vb2-dma-contig: add support for scatterlist in userptr mode

2012-05-08 Thread Laurent Pinchart
Hi Subash,

On Monday 07 May 2012 20:08:25 Subash Patel wrote:
> Hello Thomasz, Laurent,
> 
> I found an issue in the function vb2_dc_pages_to_sgt() below. I saw that
> during the attach, the size of the SGT and size requested mis-matched
> (by atleast 8k bytes). Hence I made a small correction to the code as
> below. I could then attach the importer properly.

Thank you for the report.

Could you print the content of the sglist (number of chunks and size of each 
chunk) before and after your modifications, as well as the values of n_pages, 
offset and size ?

> On 04/20/2012 08:15 PM, Tomasz Stanislawski wrote:

[snip]

> > +static struct sg_table *vb2_dc_pages_to_sgt(struct page **pages,
> > +   unsigned int n_pages, unsigned long offset, unsigned long size)
> > +{
> > +   struct sg_table *sgt;
> > +   unsigned int chunks;
> > +   unsigned int i;
> > +   unsigned int cur_page;
> > +   int ret;
> > +   struct scatterlist *s;
> > +
> > +   sgt = kzalloc(sizeof *sgt, GFP_KERNEL);
> > +   if (!sgt)
> > +   return ERR_PTR(-ENOMEM);
> > +
> > +   /* compute number of chunks */
> > +   chunks = 1;
> > +   for (i = 1; i<  n_pages; ++i)
> > +   if (pages[i] != pages[i - 1] + 1)
> > +   ++chunks;
> > +
> > +   ret = sg_alloc_table(sgt, chunks, GFP_KERNEL);
> > +   if (ret) {
> > +   kfree(sgt);
> > +   return ERR_PTR(-ENOMEM);
> > +   }
> > +
> > +   /* merging chunks and putting them into the scatterlist */
> > +   cur_page = 0;
> > +   for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
> > +   unsigned long chunk_size;
> > +   unsigned int j;
> 
>   size = PAGE_SIZE;
> 
> > +
> > +   for (j = cur_page + 1; j<  n_pages; ++j)
> 
>   for (j = cur_page + 1; j < n_pages; ++j) {
> 
> > +   if (pages[j] != pages[j - 1] + 1)
> > +   break;
> 
>   size += PAGE
>   }
> 
> > +
> > +   chunk_size = ((j - cur_page)<<  PAGE_SHIFT) - offset;
> > +   sg_set_page(s, pages[cur_page], min(size, chunk_size), offset);
> 
>   [DELETE] size -= chunk_size;
> 
> > +   offset = 0;
> > +   cur_page = j;
> > +   }
> > +
> > +   return sgt;
> > +}

-- 
Regards,

Laurent Pinchart

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


[PATCH v3] scatterlist: add sg_alloc_table_from_pages function

2012-05-08 Thread Tomasz Stanislawski
This patch adds a new constructor for an sg table. The table is constructed
from an array of struct pages. All contiguous chunks of the pages are merged
into a single sg nodes. A user may provide an offset and a size of a buffer if
the buffer is not page-aligned.

The function is dedicated for DMABUF exporters which often perform conversion
from an page array to a scatterlist. Moreover the scatterlist should be
squashed in order to save memory and to speed-up the process of DMA mapping
using dma_map_sg.

The code is based on the patch 'v4l: vb2-dma-contig: add support for
scatterlist in userptr mode' and hints from Laurent Pinchart.

Signed-off-by: Tomasz Stanislawski 
Signed-off-by: Kyungmin Park 
---
 include/linux/scatterlist.h |4 +++
 lib/scatterlist.c   |   64 +++
 2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index ac9586d..7b600da 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -214,6 +214,10 @@ void sg_free_table(struct sg_table *);
 int __sg_alloc_table(struct sg_table *, unsigned int, unsigned int, gfp_t,
 sg_alloc_fn *);
 int sg_alloc_table(struct sg_table *, unsigned int, gfp_t);
+int sg_alloc_table_from_pages(struct sg_table *sgt,
+   struct page **pages, unsigned int n_pages,
+   unsigned long offset, unsigned long size,
+   gfp_t gfp_mask);

 size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
   void *buf, size_t buflen);
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 6096e89..85868a1 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -319,6 +319,70 @@ int sg_alloc_table(struct sg_table *table, unsigned int 
nents, gfp_t gfp_mask)
 EXPORT_SYMBOL(sg_alloc_table);

 /**
+ * sg_alloc_table_from_pages - Allocate and initialize an sg table from
+ *an array of pages
+ * @sgt:   The sg table header to use
+ * @pages: Pointer to an array of page pointers
+ * @n_pages:   Number of pages in the pages array
+ * @offset: Offset from start of the first page to the start of a buffer
+ * @size:   Number of valid bytes in the buffer (after offset)
+ * @gfp_mask:  GFP allocation mask
+ *
+ *  Description:
+ *Allocate and initialize an sg table from a list of pages. Continuous
+ *ranges of the pages are squashed into a single scatterlist node. A user
+ *may provide an offset at a start and a size of valid data in a buffer
+ *specified by the page array. The returned sg table is released by
+ *sg_free_table.
+ *
+ * Returns:
+ *   0 on success, negative error on failure
+ **/
+int sg_alloc_table_from_pages(struct sg_table *sgt,
+   struct page **pages, unsigned int n_pages,
+   unsigned long offset, unsigned long size,
+   gfp_t gfp_mask)
+{
+   unsigned int chunks;
+   unsigned int i;
+   unsigned int cur_page;
+   int ret;
+   struct scatterlist *s;
+
+   /* compute number of contiguous chunks */
+   chunks = 1;
+   for (i = 1; i < n_pages; ++i)
+   if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1]) + 1)
+   ++chunks;
+
+   ret = sg_alloc_table(sgt, chunks, gfp_mask);
+   if (unlikely(ret))
+   return ret;
+
+   /* merging chunks and putting them into the scatterlist */
+   cur_page = 0;
+   for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
+   unsigned long chunk_size;
+   unsigned int j;
+
+   /* looking for the end of the current chunk */
+   for (j = cur_page + 1; j < n_pages; ++j)
+   if (page_to_pfn(pages[j]) !=
+   page_to_pfn(pages[j - 1]) + 1)
+   break;
+
+   chunk_size = ((j - cur_page) << PAGE_SHIFT) - offset;
+   sg_set_page(s, pages[cur_page], min(size, chunk_size), offset);
+   size -= chunk_size;
+   offset = 0;
+   cur_page = j;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(sg_alloc_table_from_pages);
+
+/**
  * sg_miter_start - start mapping iteration over a sg list
  * @miter: sg mapping iter to be started
  * @sgl: sg list to iterate over
-- 
1.7.5.4

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


Re: [PATCH v3] scatterlist: add sg_alloc_table_from_pages function

2012-05-08 Thread Daniel Vetter
On Tue, May 08, 2012 at 11:50:33AM +0200, Tomasz Stanislawski wrote:
> This patch adds a new constructor for an sg table. The table is constructed
> from an array of struct pages. All contiguous chunks of the pages are merged
> into a single sg nodes. A user may provide an offset and a size of a buffer if
> the buffer is not page-aligned.
> 
> The function is dedicated for DMABUF exporters which often perform conversion
> from an page array to a scatterlist. Moreover the scatterlist should be
> squashed in order to save memory and to speed-up the process of DMA mapping
> using dma_map_sg.
> 
> The code is based on the patch 'v4l: vb2-dma-contig: add support for
> scatterlist in userptr mode' and hints from Laurent Pinchart.
> 
> Signed-off-by: Tomasz Stanislawski 
> Signed-off-by: Kyungmin Park 

Looks neat and useful and we could use this to kill the copy in
drm_prime.c. So

Acked-by: Daniel Vetter 
> ---
>  include/linux/scatterlist.h |4 +++
>  lib/scatterlist.c   |   64 
> +++
>  2 files changed, 68 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index ac9586d..7b600da 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -214,6 +214,10 @@ void sg_free_table(struct sg_table *);
>  int __sg_alloc_table(struct sg_table *, unsigned int, unsigned int, gfp_t,
>sg_alloc_fn *);
>  int sg_alloc_table(struct sg_table *, unsigned int, gfp_t);
> +int sg_alloc_table_from_pages(struct sg_table *sgt,
> + struct page **pages, unsigned int n_pages,
> + unsigned long offset, unsigned long size,
> + gfp_t gfp_mask);
> 
>  size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
>  void *buf, size_t buflen);
> diff --git a/lib/scatterlist.c b/lib/scatterlist.c
> index 6096e89..85868a1 100644
> --- a/lib/scatterlist.c
> +++ b/lib/scatterlist.c
> @@ -319,6 +319,70 @@ int sg_alloc_table(struct sg_table *table, unsigned int 
> nents, gfp_t gfp_mask)
>  EXPORT_SYMBOL(sg_alloc_table);
> 
>  /**
> + * sg_alloc_table_from_pages - Allocate and initialize an sg table from
> + *  an array of pages
> + * @sgt: The sg table header to use
> + * @pages:   Pointer to an array of page pointers
> + * @n_pages: Number of pages in the pages array
> + * @offset: Offset from start of the first page to the start of a buffer
> + * @size:   Number of valid bytes in the buffer (after offset)
> + * @gfp_mask:GFP allocation mask
> + *
> + *  Description:
> + *Allocate and initialize an sg table from a list of pages. Continuous
> + *ranges of the pages are squashed into a single scatterlist node. A user
> + *may provide an offset at a start and a size of valid data in a buffer
> + *specified by the page array. The returned sg table is released by
> + *sg_free_table.
> + *
> + * Returns:
> + *   0 on success, negative error on failure
> + **/
> +int sg_alloc_table_from_pages(struct sg_table *sgt,
> + struct page **pages, unsigned int n_pages,
> + unsigned long offset, unsigned long size,
> + gfp_t gfp_mask)
> +{
> + unsigned int chunks;
> + unsigned int i;
> + unsigned int cur_page;
> + int ret;
> + struct scatterlist *s;
> +
> + /* compute number of contiguous chunks */
> + chunks = 1;
> + for (i = 1; i < n_pages; ++i)
> + if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1]) + 1)
> + ++chunks;
> +
> + ret = sg_alloc_table(sgt, chunks, gfp_mask);
> + if (unlikely(ret))
> + return ret;
> +
> + /* merging chunks and putting them into the scatterlist */
> + cur_page = 0;
> + for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
> + unsigned long chunk_size;
> + unsigned int j;
> +
> + /* looking for the end of the current chunk */
> + for (j = cur_page + 1; j < n_pages; ++j)
> + if (page_to_pfn(pages[j]) !=
> + page_to_pfn(pages[j - 1]) + 1)
> + break;
> +
> + chunk_size = ((j - cur_page) << PAGE_SHIFT) - offset;
> + sg_set_page(s, pages[cur_page], min(size, chunk_size), offset);
> + size -= chunk_size;
> + offset = 0;
> + cur_page = j;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(sg_alloc_table_from_pages);
> +
> +/**
>   * sg_miter_start - start mapping iteration over a sg list
>   * @miter: sg mapping iter to be started
>   * @sgl: sg list to iterate over
> -- 
> 1.7.5.4
> 
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Mail: dan...@ffwll.ch
Mobile: +41 (0)79 365 57 48
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of 

[PATCH] af9015: various small changes and clean-ups

2012-05-08 Thread Antti Palosaari
Clean-up dvb_usb_device_properties and fix errors
reported by checkpatch.pl.

Some other very minor changes. Functionality remains
untouched.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb/dvb-usb/af9015.c |  495 +++
 1 files changed, 212 insertions(+), 283 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/af9015.c 
b/drivers/media/dvb/dvb-usb/af9015.c
index 7e70ea5..677fed7 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -244,8 +244,7 @@ static int af9015_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
u8 uninitialized_var(mbox), addr_len;
struct req_t req;
 
-/* TODO: implement bus lock
-
+/*
 The bus lock is needed because there is two tuners both using same I2C-address.
 Due to that the only way to select correct tuner is use demodulator I2C-gate.
 
@@ -789,7 +788,7 @@ static void af9015_set_remote_config(struct usb_device 
*udev,
/* try to load remote based USB ID */
if (!props->rc.core.rc_codes)
props->rc.core.rc_codes = af9015_rc_setup_match(
-   (vid << 16) + pid, af9015_rc_setup_usbids);
+   (vid << 16) | pid, af9015_rc_setup_usbids);
 
/* try to load remote based USB iManufacturer string */
if (!props->rc.core.rc_codes && vid == USB_VID_AFATECH) {
@@ -1220,8 +1219,8 @@ static int af9015_af9013_frontend_attach(struct 
dvb_usb_adapter *adap)
}
 
/* attach demodulator */
-   adap->fe_adap[0].fe = dvb_attach(af9013_attach, 
&af9015_af9013_config[adap->id],
-   &adap->dev->i2c_adap);
+   adap->fe_adap[0].fe = dvb_attach(af9013_attach,
+   &af9015_af9013_config[adap->id], &adap->dev->i2c_adap);
 
/*
 * AF9015 firmware does not like if it gets interrupted by I2C adapter
@@ -1324,14 +1323,15 @@ static int af9015_tuner_attach(struct dvb_usb_adapter 
*adap)
switch (af9015_af9013_config[adap->id].tuner) {
case AF9013_TUNER_MT2060:
case AF9013_TUNER_MT2060_2:
-   ret = dvb_attach(mt2060_attach, adap->fe_adap[0].fe, 
&adap->dev->i2c_adap,
-   &af9015_mt2060_config,
+   ret = dvb_attach(mt2060_attach, adap->fe_adap[0].fe,
+   &adap->dev->i2c_adap, &af9015_mt2060_config,
af9015_config.mt2060_if1[adap->id])
== NULL ? -ENODEV : 0;
break;
case AF9013_TUNER_QT1010:
case AF9013_TUNER_QT1010A:
-   ret = dvb_attach(qt1010_attach, adap->fe_adap[0].fe, 
&adap->dev->i2c_adap,
+   ret = dvb_attach(qt1010_attach, adap->fe_adap[0].fe,
+   &adap->dev->i2c_adap,
&af9015_qt1010_config) == NULL ? -ENODEV : 0;
break;
case AF9013_TUNER_TDA18271:
@@ -1434,69 +1434,85 @@ enum af9015_usb_table_entry {
 };
 
 static struct usb_device_id af9015_usb_table[] = {
-   [AFATECH_9015] =
-   {USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9015)},
-   [AFATECH_9016] =
-   {USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9016)},
-   [WINFAST_DTV_GOLD] =
-   {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_GOLD)},
-   [PINNACLE_PCTV_71E] =
-   {USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV71E)},
-   [KWORLD_PLUSTV_399U] =
-   {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U)},
-   [TINYTWIN] = {USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TINYTWIN)},
-   [AZUREWAVE_TU700] =
-   {USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_AZUREWAVE_AD_TU700)},
-   [TERRATEC_AF9015] = {USB_DEVICE(USB_VID_TERRATEC,
+   [AFATECH_9015] = {
+   USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9015)},
+   [AFATECH_9016] = {
+   USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9016)},
+   [WINFAST_DTV_GOLD] = {
+   USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_GOLD)},
+   [PINNACLE_PCTV_71E] = {
+   USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV71E)},
+   [KWORLD_PLUSTV_399U] = {
+   USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U)},
+   [TINYTWIN] = {
+   USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TINYTWIN)},
+   [AZUREWAVE_TU700] = {
+   USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_AZUREWAVE_AD_TU700)},
+   [TERRATEC_AF9015] = {
+   USB_DEVICE(USB_VID_TERRATEC,
USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2)},
-   [KWORLD_PLUSTV_PC160] =
-   {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_2T)},
-   [AVERTV_VOLAR_X] =
-   {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X)},
-   [XTENSIONS_380U] =
-   {USB_DEVICE(USB_VID_XTENSIONS, USB_PID_XTENSIONS_XD_380)},
-   [MSI_DIGIVOX_DUO] =
-   {USB_DEVICE(USB_VID_MSI_2

Re: [PATCH/RFC v4 10/12] V4L: Add auto focus targets to the selections API

2012-05-08 Thread Sylwester Nawrocki
Hi Sakari!

On 05/06/2012 08:22 PM, Sakari Ailus wrote:
> Hi Sylwester,
> 
> Thanks for the patch.
> 
> Sylwester Nawrocki wrote:
>> The camera automatic focus algorithms may require setting up
>> a spot or rectangle coordinates or multiple such parameters.
>>
>> The automatic focus selection targets are introduced in order
>> to allow applications to query and set such coordinates. Those
>> selections are intended to be used together with the automatic
>> focus controls available in the camera control class.
> 
> Have you thought about multiple autofocus windows, and how could they be
> implemented on top of this patch?
> 
> I'm not saying that we should implement them now, but at least we should
> think how we _would_ implement them when needed. They aren't that exotic
> functionality these days after all.
> 
> I'd guess this would involve an additional bitmask control and defining
> a set of new targets. A comment in the source might help here ---
> perhaps a good rule is to start new ranges at 0x1000 as you're doing
> already.

There was also an idea to convert part of the reserved[] field to a window
index IIRC. Not sure which approach is better. I didn't want to make any
assumptions about features I don't have exact knowledge about, neither that
I currently need. The large offset in the auto focus target is to better
indicate they are really different than current selection targets we have,
I also had in mind reserving a target pool for AF targets as you are
pointing out.
That said I'm not really sure right now what additional exact comments
would need to be added.
Hopefully there isn't anything blocking further expansion in this patches.

I didn't decided yet if I want to send this selection/auto focus patches
out for v3.5. I'm also considering dropping just the V4L2_AUTO_FOCUS_AREA
control from "12/12 V4L: Add camera auto focus controls" patch this time.

The bitmask control for multiple windows selection makes a lot of sense
to me. I suppose it would be better to use an additional 'index' field
in the selection data structures for AF window selection.

>> Signed-off-by: Sylwester Nawrocki 
>> Signed-off-by: Kyungmin Park 
>> ---
>>  Documentation/DocBook/media/v4l/selection-api.xml  |   33 
>> +++-
>>  .../DocBook/media/v4l/vidioc-g-selection.xml   |   11 +++
>>  include/linux/videodev2.h  |5 +++
>>  3 files changed, 48 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/DocBook/media/v4l/selection-api.xml 
>> b/Documentation/DocBook/media/v4l/selection-api.xml
>> index b299e47..490d29a 100644
>> --- a/Documentation/DocBook/media/v4l/selection-api.xml
>> +++ b/Documentation/DocBook/media/v4l/selection-api.xml
>> @@ -1,6 +1,6 @@
>>  
>>  
>> -  Experimental API for cropping, composing and scaling
>> +  Experimental selections API
>>  
>>
>>  Experimental
>> @@ -9,6 +9,10 @@
>>  interface and may change in the future.
>>
>>  
>> + 
>> +
>> + Image cropping, composing and scaling
>> +
>>
>>  Introduction
>>  
>> @@ -321,5 +325,32 @@ V4L2_BUF_TYPE_VIDEO_OUTPUT  for other 
>> devices
>>
>>  
>> 
>> + 
>> +
>> +   
>> + Automatic focus regions of interest
>> +
>> + The camera automatic focus algorithms may require configuration of
>> +regions of interest in form of rectangle or spot coordinates. The automatic
>> +focus selection targets allow applications to query and set such 
>> coordinates.
>> +Those selections are intended to be used together with the
>> +V4L2_CID_AUTO_FOCUS_AREA > linkend="camera-controls">
>> +camera class control. The V4L2_SEL_TGT_AUTO_FOCUS_ACTUAL
>> + target is used for querying or setting actual spot or rectangle
>> +coordinates, while V4L2_SEL_TGT_AUTO_FOCUS_BOUNDS 
>> target
>> +determines bounds for a single spot or rectangle.
>> +These selections are only effective when the 
>> V4L2_CID_AUTO_FOCUS_AREA
>> +control is set to V4L2_AUTO_FOCUS_AREA_SPOT 
>> or
>> +V4L2_AUTO_FOCUS_AREA_RECTANGLE. The new coordinates 
>> shall
>> +be accepted and applied to hardware when the focus area control value is
>> +changed and also during a &VIDIOC-S-SELECTION; ioctl call, only when the 
>> focus
>> +area control is already set to required value.
>> +
>> + For the V4L2_AUTO_FOCUS_AREA_SPOT case, the 
>> selection
>> +rectangle  width and 
>> height
>> +are not used, i.e. shall be set to 0 by applications and ignored by drivers 
>> for
>> +the &VIDIOC-S-SELECTION; ioctl and shall be ignored by applications for the
>> +&VIDIOC-G-SELECTION; ioctl.
>> +   
>>  
>>  
>> diff --git a/Documentation/DocBook/media/v4l/vidioc-g-selection.xml 
>> b/Documentation/DocBook/media/v4l/vidioc-g-selection.xml
>> index bb04eff..87df4da 100644
>> --- a/Documentation/DocBook/media/v4l/vidioc-g-selection.xml
>> +++ b/Documentation/DocBook/media/v4l/vidioc-g-selection.xml
>> @@ -195,6 +195,17 @@ exist no rectangle  that satisfies the 
>> constraints.
>>  0x0103
>>  The active area a

Re: Capturing from MT9J003 Camera on DM3730 using Previewer and Resizer

2012-05-08 Thread Laurent Pinchart
Hi Neil,

On Monday 07 May 2012 16:59:22 Neil Johnson wrote:
> Linux-media list,
> 
> We've recently had some success capturing from the MT9J003 Aptina camera on
> a DM3730 board (custom board).

Nice work. I hope to see a MT9J003 driver being posted to the list in the 
future ;-)

> We have been able to prove this functionality by adapting the MT9P031 driver
> from Linux-3.0.tar.gz (we downloaded the tarball and patched from there).
> The exact URL for that version of the kernel is:
> 
> http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.bz2
> 
> We have been working off of this kernel and using the media-ctl and
> yavta applications to manipulate pipelines and test out the capture
> interface.  Everything seems to work okay up through capturing from
> the CCDC output (/dev/video2), but once we try to send the data
> through the previewer or resizer, the app hangs at "start streaming"
> or the call to the DQBUF ioctl.
> 
> The resolution we're capturing is a little odd: 912x688 (that happens
> to be the recommended resolution according to one of Aptina's
> manuals).  The pipeline that works looks like this:
> 
> Start CCDC Pipeline==
> #! /bin/sh
> 
> #
> # Configure media-controller pipeline for MT9J003
> #
> media-ctl -r
> media-ctl -l '"mt9j003 2-0010":0->"OMAP3 ISP CCDC":0[1]'
> media-ctl -l '"OMAP3 ISP CCDC":1->"OMAP3 ISP CCDC output":0[1]'
> media-ctl -f '"mt9j003 2-0010":0[SGRBG12 916x688]'
> media-ctl -f '"OMAP3 ISP CCDC":0[SGRBG10 916x688]'
> media-ctl -f '"OMAP3 ISP CCDC":1[SGRBG10 916x688]'
> 
> ./yavta -p -f SGRBG10 -s 912x688 -n 4 --capture=5 -F `media-ctl -e
> "OMAP3 ISP CCDC output"` --file=./images/img#.raw
> End CCDC Pipeline==
> =
> 
> That spits out nice images which I can demosaic using post-processing
> tools, and I get an actual image.
> 
> The following pipeline does not work properly:
> Start Preview Pipeline=
> #! /bin/sh
> 
> #
> # Configure media-controller pipeline for MT9J003
> #
> media-ctl -r
> media-ctl -l '"mt9j003 2-0010":0->"OMAP3 ISP CCDC":0[1]'
> media-ctl -l '"OMAP3 ISP CCDC":2->"OMAP3 ISP preview":0[1]'
> media-ctl -l '"OMAP3 ISP preview":1->"OMAP3 ISP preview output":0[1]'
> media-ctl -f '"mt9j003 2-0010":0[SGRBG12 916x688]'
> media-ctl -f  '"OMAP3 ISP CCDC":0 [SGRBG10 916x688]'
> media-ctl -f  '"OMAP3 ISP CCDC":1 [SGRBG10 916x688]'
> media-ctl -f  '"OMAP3 ISP preview":0 [SGRBG10 916x687]'
> media-ctl -f  '"OMAP3 ISP preview":1 [UYVY 898x679]'
> 
> # Now capture:
> ./yavta -p -f UYVY -s 898x679 -n 4 --capture=5 -F `media-ctl -e "OMAP3
> ISP preview output"` --file=./images/img#.uyvy
> =End Preview Pipeline==
> 
> When I run this preview capture script (from /dev/video4), the
> application hangs after going into streaming mode on the sensor.
> Here's the output when running the preview pipeline script (with some
> annotations, and some printk's inserted):
> 
> =Start output=
> root@cobra3530p7303:~# ./grab_preview_yavta
> * preview_link_setup: drivers/media/video/omap3isp/isppreview.c, 1923
> * preview_link_setup: drivers/media/video/omap3isp/isppreview.c, 1923
> 
> 
> cobra_mt9j003_cam_reset: Resetting MT9J003 camera, active = 0
> Setting MT9J003 Coarse Int Time to 24000
>   Confirmed: set coarse int time to 24000
> mt9j003_set_format:754 Called mt9j003_get_format
> * preview_init_formats: drivers/media/video/omap3isp/isppreview.c, 1861
> * preview_set_format: drivers/media/video/omap3isp/isppreview.c, 1826
> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
> * pad = 0 (0=sink(input), 1=src(output))
> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
> * pad = 1 (0=sink(input), 1=src(output))
> * preview_set_format: drivers/media/video/omap3isp/isppreview.c, 1826
> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
> * pad = 0 (0=sink(input), 1=src(output))
> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
> * pad = 1 (0=sink(input), 1=src(output))
> * preview_init_formats: drivers/media/video/omap3isp/isppreview.c, 1861
> * preview_set_format: drivers/media/video/omap3isp/isppreview.c, 1826
> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
> * pad = 0 (0=sink(input), 1=src(output))
> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
> * pad = 1 (0=sink(input), 1=src(output))
> * preview_set_format: drivers/media/video/omap3isp/isppreview.c, 1826
> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
> * pad = 1 (0=sink(input), 1=src(output))
> cobra_mt9j003_cam_reset: Resetting MT9J003 camera, active = 0
> Number of arguments = 12
> Last argument = /dev/video4
> Setting MT9J003 Coarse Int Time to 24000
>   Confirmed: set coarse i

Re: [PATCH] mt9v032: Correct the logic for the auto-exposure setting

2012-05-08 Thread Laurent Pinchart
Hi Kartik,

Thank you for the patch.

On Wednesday 02 May 2012 18:19:08 Kartik Mohta wrote:
> The driver uses the ctrl value passed in as a bool to determine whether
> to enable auto-exposure, but the auto-exposure setting is defined as an
> enum where AUTO has a value of 0 and MANUAL has a value of 1. This leads
> to a reversed logic where if you send in AUTO, it actually sets manual
> exposure and vice-versa.
> 
> Signed-off-by: Kartik Mohta 
> ---
>  drivers/media/video/mt9v032.c |8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/video/mt9v032.c b/drivers/media/video/mt9v032.c
> index 75e253a..8ea8737 100644
> --- a/drivers/media/video/mt9v032.c
> +++ b/drivers/media/video/mt9v032.c
> @@ -470,6 +470,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
>   container_of(ctrl->handler, struct mt9v032, ctrls);
>   struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev);
>   u16 data;
> + int aec_value;
> 
>   switch (ctrl->id) {
>   case V4L2_CID_AUTOGAIN:
> @@ -480,8 +481,13 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
>   return mt9v032_write(client, MT9V032_ANALOG_GAIN, ctrl->val);
> 
>   case V4L2_CID_EXPOSURE_AUTO:
> + if(ctrl->val == V4L2_EXPOSURE_MANUAL)
> + aec_value = 0;
> + else
> + aec_value = 1;
> +
>   return mt9v032_update_aec_agc(mt9v032, MT9V032_AEC_ENABLE,
> -   ctrl->val);
> +   aec_value);

What about just

return mt9v032_update_aec_agc(mt9v032, MT9V032_AEC_ENABLE,
  !ctrl->val);

If you're fine with that change I'll modify the patch accordingly, there's no 
need to resubmit (I'll of course keep the patch attribution).

> 
>   case V4L2_CID_EXPOSURE:
>   return mt9v032_write(client, MT9V032_TOTAL_SHUTTER_WIDTH,

-- 
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 v3] scatterlist: add sg_alloc_table_from_pages function

2012-05-08 Thread Laurent Pinchart
Hi Tomasz,

Thank you for the patch.

On Tuesday 08 May 2012 11:50:33 Tomasz Stanislawski wrote:
> This patch adds a new constructor for an sg table. The table is constructed
> from an array of struct pages. All contiguous chunks of the pages are merged
> into a single sg nodes. A user may provide an offset and a size of a buffer
> if the buffer is not page-aligned.
> 
> The function is dedicated for DMABUF exporters which often perform
> conversion from an page array to a scatterlist. Moreover the scatterlist
> should be squashed in order to save memory and to speed-up the process of
> DMA mapping using dma_map_sg.
> 
> The code is based on the patch 'v4l: vb2-dma-contig: add support for
> scatterlist in userptr mode' and hints from Laurent Pinchart.
> 
> Signed-off-by: Tomasz Stanislawski 
> Signed-off-by: Kyungmin Park 

Acked-by: Laurent Pinchart 

> ---
>  include/linux/scatterlist.h |4 +++
>  lib/scatterlist.c   |   64
> +++ 2 files changed, 68
> insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index ac9586d..7b600da 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -214,6 +214,10 @@ void sg_free_table(struct sg_table *);
>  int __sg_alloc_table(struct sg_table *, unsigned int, unsigned int, gfp_t,
>sg_alloc_fn *);
>  int sg_alloc_table(struct sg_table *, unsigned int, gfp_t);
> +int sg_alloc_table_from_pages(struct sg_table *sgt,
> + struct page **pages, unsigned int n_pages,
> + unsigned long offset, unsigned long size,
> + gfp_t gfp_mask);
> 
>  size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
>  void *buf, size_t buflen);
> diff --git a/lib/scatterlist.c b/lib/scatterlist.c
> index 6096e89..85868a1 100644
> --- a/lib/scatterlist.c
> +++ b/lib/scatterlist.c
> @@ -319,6 +319,70 @@ int sg_alloc_table(struct sg_table *table, unsigned int
> nents, gfp_t gfp_mask) EXPORT_SYMBOL(sg_alloc_table);
> 
>  /**
> + * sg_alloc_table_from_pages - Allocate and initialize an sg table from
> + *  an array of pages
> + * @sgt: The sg table header to use
> + * @pages:   Pointer to an array of page pointers
> + * @n_pages: Number of pages in the pages array
> + * @offset: Offset from start of the first page to the start of a
> buffer + * @size:   Number of valid bytes in the buffer (after offset)
> + * @gfp_mask:GFP allocation mask
> + *
> + *  Description:
> + *Allocate and initialize an sg table from a list of pages. Continuous
> + *ranges of the pages are squashed into a single scatterlist node. A
> user + *may provide an offset at a start and a size of valid data in a
> buffer + *specified by the page array. The returned sg table is
> released by + *sg_free_table.
> + *
> + * Returns:
> + *   0 on success, negative error on failure
> + **/
> +int sg_alloc_table_from_pages(struct sg_table *sgt,
> + struct page **pages, unsigned int n_pages,
> + unsigned long offset, unsigned long size,
> + gfp_t gfp_mask)
> +{
> + unsigned int chunks;
> + unsigned int i;
> + unsigned int cur_page;
> + int ret;
> + struct scatterlist *s;
> +
> + /* compute number of contiguous chunks */
> + chunks = 1;
> + for (i = 1; i < n_pages; ++i)
> + if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1]) + 1)
> + ++chunks;
> +
> + ret = sg_alloc_table(sgt, chunks, gfp_mask);
> + if (unlikely(ret))
> + return ret;
> +
> + /* merging chunks and putting them into the scatterlist */
> + cur_page = 0;
> + for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
> + unsigned long chunk_size;
> + unsigned int j;
> +
> + /* looking for the end of the current chunk */
> + for (j = cur_page + 1; j < n_pages; ++j)
> + if (page_to_pfn(pages[j]) !=
> + page_to_pfn(pages[j - 1]) + 1)
> + break;
> +
> + chunk_size = ((j - cur_page) << PAGE_SHIFT) - offset;
> + sg_set_page(s, pages[cur_page], min(size, chunk_size), offset);
> + size -= chunk_size;
> + offset = 0;
> + cur_page = j;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(sg_alloc_table_from_pages);
> +
> +/**
>   * sg_miter_start - start mapping iteration over a sg list
>   * @miter: sg mapping iter to be started
>   * @sgl: sg list to iterate over

-- 
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: [PATCHv5 08/13] v4l: vb2-dma-contig: add support for scatterlist in userptr mode

2012-05-08 Thread Subash Patel

Hi Laurent,

On 05/08/2012 02:44 PM, Laurent Pinchart wrote:

Hi Subash,

On Monday 07 May 2012 20:08:25 Subash Patel wrote:

Hello Thomasz, Laurent,

I found an issue in the function vb2_dc_pages_to_sgt() below. I saw that
during the attach, the size of the SGT and size requested mis-matched
(by atleast 8k bytes). Hence I made a small correction to the code as
below. I could then attach the importer properly.


Thank you for the report.

Could you print the content of the sglist (number of chunks and size of each
chunk) before and after your modifications, as well as the values of n_pages,
offset and size ?
I will put back all the printk's and generate this. As of now, my setup 
has changed and will do this when I get sometime.



On 04/20/2012 08:15 PM, Tomasz Stanislawski wrote:


[snip]


+static struct sg_table *vb2_dc_pages_to_sgt(struct page **pages,
+   unsigned int n_pages, unsigned long offset, unsigned long size)
+{
+   struct sg_table *sgt;
+   unsigned int chunks;
+   unsigned int i;
+   unsigned int cur_page;
+   int ret;
+   struct scatterlist *s;
+
+   sgt = kzalloc(sizeof *sgt, GFP_KERNEL);
+   if (!sgt)
+   return ERR_PTR(-ENOMEM);
+
+   /* compute number of chunks */
+   chunks = 1;
+   for (i = 1; i<   n_pages; ++i)
+   if (pages[i] != pages[i - 1] + 1)
+   ++chunks;
+
+   ret = sg_alloc_table(sgt, chunks, GFP_KERNEL);
+   if (ret) {
+   kfree(sgt);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   /* merging chunks and putting them into the scatterlist */
+   cur_page = 0;
+   for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
+   unsigned long chunk_size;
+   unsigned int j;


size = PAGE_SIZE;


+
+   for (j = cur_page + 1; j<   n_pages; ++j)


for (j = cur_page + 1; j<  n_pages; ++j) {


+   if (pages[j] != pages[j - 1] + 1)
+   break;


size += PAGE
}


+
+   chunk_size = ((j - cur_page)<<   PAGE_SHIFT) - offset;
+   sg_set_page(s, pages[cur_page], min(size, chunk_size), offset);


[DELETE] size -= chunk_size;


+   offset = 0;
+   cur_page = j;
+   }
+
+   return sgt;
+}



Regards,
Subash
--
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: v4l2-ctrls: Add forward declaration of struct file

2012-05-08 Thread Hans Verkuil
On Sun 29 April 2012 18:30:24 Laurent Pinchart wrote:
> On Monday 23 April 2012 13:29:11 Laurent Pinchart wrote:
> > This fixes the following warning:
> > 
> > In file included from drivers/media/video/v4l2-subdev.c:29:
> > include/media/v4l2-ctrls.h:501: warning: 'struct file' declared inside
> > parameter list
> > include/media/v4l2-ctrls.h:501: warning: its scope is only this
> > definition or declaration, which is probably not what you want
> > include/media/v4l2-ctrls.h:509: warning: 'struct file' declared inside
> > parameter list
> 
> Ping ? Should I include this in my next pull request ?

Acked-by: Hans Verkuil 

Regards,

Hans

> 
> > Signed-off-by: Laurent Pinchart 
> > ---
> >  include/media/v4l2-ctrls.h |1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
> > index 33907a9..9022e1c 100644
> > --- a/include/media/v4l2-ctrls.h
> > +++ b/include/media/v4l2-ctrls.h
> > @@ -25,6 +25,7 @@
> >  #include 
> > 
> >  /* forward references */
> > +struct file;
> >  struct v4l2_ctrl_handler;
> >  struct v4l2_ctrl_helper;
> >  struct v4l2_ctrl;
> 
> 
--
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: GENIUS TV-GO A12 tv analog card

2012-05-08 Thread Ezequiel Garcia
Hi Sebastián,

On Mon, May 7, 2012 at 11:49 PM, Sebastián Misuraca
 wrote:
> Ezequiel,
>
> Thanks for the reply.

No problem.

> I am going to watch the video and make the correct patch. When i finished i
> will send again.

Great. If you have *any* problems, feel free to ask.

Also, I suggest you avoid top-posting
(answering mail in top of original one) in the future.
People around here don't like it.

Good luck,
Ezequiel.
--
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


[RFCv1] DVB-USB improvements

2012-05-08 Thread Antti Palosaari
Factors behind the changes are mostly coming from the fact current 
struct dvb_usb_device_properties contains so many static configuration 
options. You cannot change single dvb_usb_device_properties easily 
(safely) at runtime since it is usually driver global struct and thus 
shared between all the DVB USB driver instances. That fits just fine for 
the traditional devices where all configuration is same for the devices 
having single USB ID. Nowadays we have more and more devices that are 
based of chipset vendor reference designs - even using just single USB 
ID chipset vendor have given for that chipset. These reference designs 
still varies much about used chips and configurations. Configuring 
different base chips, USB-bridge, demod, tuner, and also peripheral 
properties like dual tuners, remotes and CI is needed to do runtime 
because of single USB ID is used for that all.


My personal innovator behind all these is problems I met when developing 
AF9015 and AF9035 drivers. Also RTL2831U and RTL2832U are kinda similar 
and have given some more motivation.


Here is small list what I am planning to do. It is surely so much work 
that everything is not possible, but lets try to select most important 
and easiest as a higher priority.



resume / suspend support
---
* very important feature
* crashes currently when DVB USB tries to download firmware when 
resuming from suspend


read_config1
---
* new callback to do initial tweaks
* very first callback
* is that really needed?

read_mac_address => read_config2
---
* rename it read_config2 or read_config if read_config1 is not 
implemented at all

* rename old callback and extend it usage as a more general
* only 8 devices use currently
* when returned mac != 0 => print mac address as earlier, otherwise work 
as a general callback


new callback init()
---
* called after tuner attach to initialize rest of device
* good place to do some general settings
  - configure endpoints
  - configure remote controller
  - configure + attach CI

change DVB-USB to dynamic debug
---
* use Kernel new dynamic debugs instead of own proprietary system

download_firmware
---
* struct usb_device => struct dvb_usb_device
* we need access for the DVB USB driver state in every callback

identify_state
---
* struct usb_device => struct dvb_usb_device
* we need access for the DVB USB driver state in every callback

attach all given adapter frontends as once
---
* for the MFE devices attach all frontends as once
* deregister all frontends if error returned
* small effect only for MFE

attach all given adapter tuners as once
---
* deregister all frontends if error returned
* small effect only for MFE

make remote dynamically configurable
---
* default keytable mapped same level with USB-ID & device name etc.
* there is generally 3 things that could be mapped to USB ID
  - USB IDs (cold + warm)
  - device name
  - remote controller keytable
  - all the others could be resolved & configured dynamically
* it is not only keytable but whole remote should be changed dynamically 
configurable


make stream dynamically configurable
---
* we need change stream parameters in certain situations
  - there is multiple endpoints but shared MFE
  - need to set params according to stream bandwidth (USB1.1, DVB-T, 
DVB-C2 in same device)
  - leave old static configrations as those are but add callbacks to 
get new values at runtime


dynamically growing device list in dvb_usb_device_properties
---
* currently number of devices are limited statically
* there is devices having ~50 or more IDs which means multiple 
dvb_usb_device_properties are needed


dynamic USB ID support
---
* currently not supported by DVB USB

analog support for the DVB USB
---
* currently not supported by DVB USB
* I have no experience
* em28xx can be converted?



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


[PATCH] mt9p031: Add support for core and I/O regulators

2012-05-08 Thread Laurent Pinchart
The regulators are optional. If present, enable them when powering the
sensor up, and disable them when powering it down.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/video/mt9p031.c |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
index 8f061d9..d0b8e36 100644
--- a/drivers/media/video/mt9p031.c
+++ b/drivers/media/video/mt9p031.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -121,6 +122,9 @@ struct mt9p031 {
struct mutex power_lock; /* lock to protect power_count */
int power_count;
 
+   struct regulator *vdd_core;
+   struct regulator *vdd_io;
+
enum mt9p031_model model;
struct aptina_pll pll;
int reset;
@@ -264,6 +268,12 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031)
usleep_range(1000, 2000);
}
 
+   /* Bring up the supplies */
+   if (mt9p031->vdd_core)
+   regulator_enable(mt9p031->vdd_core);
+   if (mt9p031->vdd_io)
+   regulator_enable(mt9p031->vdd_io);
+
/* Emable clock */
if (mt9p031->pdata->set_xclk)
mt9p031->pdata->set_xclk(&mt9p031->subdev,
@@ -285,6 +295,11 @@ static void mt9p031_power_off(struct mt9p031 *mt9p031)
usleep_range(1000, 2000);
}
 
+   if (mt9p031->vdd_io)
+   regulator_disable(mt9p031->vdd_io);
+   if (mt9p031->vdd_core)
+   regulator_disable(mt9p031->vdd_core);
+
if (mt9p031->pdata->set_xclk)
mt9p031->pdata->set_xclk(&mt9p031->subdev, 0);
 }
@@ -950,6 +965,9 @@ static int mt9p031_probe(struct i2c_client *client,
mt9p031->model = did->driver_data;
mt9p031->reset = -1;
 
+   mt9p031->vdd_core = devm_regulator_get(&client->dev, "cam_core");
+   mt9p031->vdd_io = devm_regulator_get(&client->dev, "cam_io");
+
v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4);
 
v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
-- 
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] mt9v032: Correct the logic for the auto-exposure setting

2012-05-08 Thread Kartik Mohta
Hi,

On Tue, May 8, 2012 at 7:12 AM, Laurent Pinchart
 wrote:
> Hi Kartik,
>
> Thank you for the patch.
>
> On Wednesday 02 May 2012 18:19:08 Kartik Mohta wrote:
>> The driver uses the ctrl value passed in as a bool to determine whether
>> to enable auto-exposure, but the auto-exposure setting is defined as an
>> enum where AUTO has a value of 0 and MANUAL has a value of 1. This leads
>> to a reversed logic where if you send in AUTO, it actually sets manual
>> exposure and vice-versa.
>>
>> Signed-off-by: Kartik Mohta 
>> ---
>>  drivers/media/video/mt9v032.c |    8 +++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/video/mt9v032.c b/drivers/media/video/mt9v032.c
>> index 75e253a..8ea8737 100644
>> --- a/drivers/media/video/mt9v032.c
>> +++ b/drivers/media/video/mt9v032.c
>> @@ -470,6 +470,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
>>                       container_of(ctrl->handler, struct mt9v032, ctrls);
>>       struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev);
>>       u16 data;
>> +     int aec_value;
>>
>>       switch (ctrl->id) {
>>       case V4L2_CID_AUTOGAIN:
>> @@ -480,8 +481,13 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
>>               return mt9v032_write(client, MT9V032_ANALOG_GAIN, ctrl->val);
>>
>>       case V4L2_CID_EXPOSURE_AUTO:
>> +             if(ctrl->val == V4L2_EXPOSURE_MANUAL)
>> +                     aec_value = 0;
>> +             else
>> +                     aec_value = 1;
>> +
>>               return mt9v032_update_aec_agc(mt9v032, MT9V032_AEC_ENABLE,
>> -                                           ctrl->val);
>> +                                           aec_value);
>
> What about just
>
>                return mt9v032_update_aec_agc(mt9v032, MT9V032_AEC_ENABLE,
>                                              !ctrl->val);
>
> If you're fine with that change I'll modify the patch accordingly, there's no
> need to resubmit (I'll of course keep the patch attribution).
>

That should work since the only supported exposure modes are auto and
manual with enum values 0 and 1 respectively, but then aren't you
depending on the values of the enum to not change in the future? Also
the change gives an impression that the value is a bool which it is
not. If that is fine, you can change it.

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


Terratec Cinergy S2 USB HD Rev.2

2012-05-08 Thread Igor M. Liplianin
Terratec Cinergy S2 USB HD Rev.2 support.

Signed-off-by: Igor M. Liplianin diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
index 7ced62d..9a7a333 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -1243,6 +1243,13 @@ static int su3000_frontend_attach(struct dvb_usb_adapter *d)
 {
 	u8 obuf[3] = { 0xe, 0x80, 0 };
 	u8 ibuf[] = { 0 };
+	
+	if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
+		err("command 0x0e transfer failed.");
+
+	obuf[0] = 0xe;
+	obuf[1] = 0x02;
+	obuf[2] = 1;
 
 	if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
 		err("command 0x0e transfer failed.");
@@ -1536,6 +1543,7 @@ enum dw2102_table_entry {
 	X3M_SPC1400HD,
 	TEVII_S421,
 	TEVII_S632,
+	TERRATEC_CINERGY_S2_R2,
 };
 
 static struct usb_device_id dw2102_table[] = {
@@ -1556,6 +1564,7 @@ static struct usb_device_id dw2102_table[] = {
 	[X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
 	[TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
 	[TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
+	[TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00b0)},
 	{ }
 };
 
@@ -1957,7 +1966,7 @@ static struct dvb_usb_device_properties su3000_properties = {
 		}},
 		}
 	},
-	.num_device_descs = 3,
+	.num_device_descs = 4,
 	.devices = {
 		{ "SU3000HD DVB-S USB2.0",
 			{ &dw2102_table[GENIATECH_SU3000], NULL },
@@ -1971,6 +1980,10 @@ static struct dvb_usb_device_properties su3000_properties = {
 			{ &dw2102_table[X3M_SPC1400HD], NULL },
 			{ NULL },
 		},
+		{ "Terratec Cinergy S2 USB HD Rev.2",
+			{ &dw2102_table[TERRATEC_CINERGY_S2_R2], NULL },
+			{ NULL },
+		},
 	}
 };
 

Re: Capturing from MT9J003 Camera on DM3730 using Previewer and Resizer

2012-05-08 Thread Neil Johnson
Laurent,

Thanks for your quick reply.  I will take a look at better debugging
the interrupts and possibly updating to something newer than kernel
3.0.  I'm hoping this isn't simply an issue with a badly constructed
media-ctl pipeline, but I like your suggestion of just setting formats
on the source and sink of the pipeline and letting the drivers do the
mangling.

Neil



On Tue, May 8, 2012 at 4:59 AM, Laurent Pinchart
 wrote:
> Hi Neil,
>
> On Monday 07 May 2012 16:59:22 Neil Johnson wrote:
>> Linux-media list,
>>
>> We've recently had some success capturing from the MT9J003 Aptina camera on
>> a DM3730 board (custom board).
>
> Nice work. I hope to see a MT9J003 driver being posted to the list in the
> future ;-)
>
>> We have been able to prove this functionality by adapting the MT9P031 driver
>> from Linux-3.0.tar.gz (we downloaded the tarball and patched from there).
>> The exact URL for that version of the kernel is:
>>
>> http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.bz2
>>
>> We have been working off of this kernel and using the media-ctl and
>> yavta applications to manipulate pipelines and test out the capture
>> interface.  Everything seems to work okay up through capturing from
>> the CCDC output (/dev/video2), but once we try to send the data
>> through the previewer or resizer, the app hangs at "start streaming"
>> or the call to the DQBUF ioctl.
>>
>> The resolution we're capturing is a little odd: 912x688 (that happens
>> to be the recommended resolution according to one of Aptina's
>> manuals).  The pipeline that works looks like this:
>>
>> Start CCDC Pipeline==
>> #! /bin/sh
>>
>> #
>> # Configure media-controller pipeline for MT9J003
>> #
>> media-ctl -r
>> media-ctl -l '"mt9j003 2-0010":0->"OMAP3 ISP CCDC":0[1]'
>> media-ctl -l '"OMAP3 ISP CCDC":1->"OMAP3 ISP CCDC output":0[1]'
>> media-ctl -f '"mt9j003 2-0010":0[SGRBG12 916x688]'
>> media-ctl -f '"OMAP3 ISP CCDC":0[SGRBG10 916x688]'
>> media-ctl -f '"OMAP3 ISP CCDC":1[SGRBG10 916x688]'
>>
>> ./yavta -p -f SGRBG10 -s 912x688 -n 4 --capture=5 -F `media-ctl -e
>> "OMAP3 ISP CCDC output"` --file=./images/img#.raw
>> End CCDC Pipeline==
>> =
>>
>> That spits out nice images which I can demosaic using post-processing
>> tools, and I get an actual image.
>>
>> The following pipeline does not work properly:
>> Start Preview Pipeline=
>> #! /bin/sh
>>
>> #
>> # Configure media-controller pipeline for MT9J003
>> #
>> media-ctl -r
>> media-ctl -l '"mt9j003 2-0010":0->"OMAP3 ISP CCDC":0[1]'
>> media-ctl -l '"OMAP3 ISP CCDC":2->"OMAP3 ISP preview":0[1]'
>> media-ctl -l '"OMAP3 ISP preview":1->"OMAP3 ISP preview output":0[1]'
>> media-ctl -f '"mt9j003 2-0010":0[SGRBG12 916x688]'
>> media-ctl -f  '"OMAP3 ISP CCDC":0 [SGRBG10 916x688]'
>> media-ctl -f  '"OMAP3 ISP CCDC":1 [SGRBG10 916x688]'
>> media-ctl -f  '"OMAP3 ISP preview":0 [SGRBG10 916x687]'
>> media-ctl -f  '"OMAP3 ISP preview":1 [UYVY 898x679]'
>>
>> # Now capture:
>> ./yavta -p -f UYVY -s 898x679 -n 4 --capture=5 -F `media-ctl -e "OMAP3
>> ISP preview output"` --file=./images/img#.uyvy
>> =End Preview Pipeline==
>>
>> When I run this preview capture script (from /dev/video4), the
>> application hangs after going into streaming mode on the sensor.
>> Here's the output when running the preview pipeline script (with some
>> annotations, and some printk's inserted):
>>
>> =Start output=
>> root@cobra3530p7303:~# ./grab_preview_yavta
>> * preview_link_setup: drivers/media/video/omap3isp/isppreview.c, 1923
>> * preview_link_setup: drivers/media/video/omap3isp/isppreview.c, 1923
>>
>>
>> cobra_mt9j003_cam_reset: Resetting MT9J003 camera, active = 0
>> Setting MT9J003 Coarse Int Time to 24000
>>   Confirmed: set coarse int time to 24000
>> mt9j003_set_format:754 Called mt9j003_get_format
>> * preview_init_formats: drivers/media/video/omap3isp/isppreview.c, 1861
>> * preview_set_format: drivers/media/video/omap3isp/isppreview.c, 1826
>> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
>>     * pad = 0 (0=sink(input), 1=src(output))
>> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
>>     * pad = 1 (0=sink(input), 1=src(output))
>> * preview_set_format: drivers/media/video/omap3isp/isppreview.c, 1826
>> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
>>     * pad = 0 (0=sink(input), 1=src(output))
>> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
>>     * pad = 1 (0=sink(input), 1=src(output))
>> * preview_init_formats: drivers/media/video/omap3isp/isppreview.c, 1861
>> * preview_set_format: drivers/media/video/omap3isp/isppreview.c, 1826
>> * preview_try_format: drivers/media/video/omap3isp/isppreview.c, 1633
>>     * pad = 0 (0=sink(input), 1=src(

[PATCH] V4L: marvell-ccic: (cosmetic) remove redundant variable assignment

2012-05-08 Thread Guennadi Liakhovetski
The "ret = 0" assignment in mcam_vidioc_s_fmt_vid_cap() is redundant,
because at that location "ret" is anyway guaranteed to be == 0.

Signed-off-by: Guennadi Liakhovetski 
---
 drivers/media/video/marvell-ccic/mcam-core.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/marvell-ccic/mcam-core.c 
b/drivers/media/video/marvell-ccic/mcam-core.c
index 996ac34..ce2b7b4 100644
--- a/drivers/media/video/marvell-ccic/mcam-core.c
+++ b/drivers/media/video/marvell-ccic/mcam-core.c
@@ -1356,7 +1356,6 @@ static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, 
void *priv,
goto out;
}
mcam_set_config_needed(cam, 1);
-   ret = 0;
 out:
mutex_unlock(&cam->s_mutex);
return ret;
-- 
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] V4L: soc-camera: (cosmetic) use a more explicit name for a host handler

2012-05-08 Thread Guennadi Liakhovetski
Use "enum_framesizes" instead of "enum_fsizes" to more precisely follow
the name of the respective ioctl().

Signed-off-by: Guennadi Liakhovetski 
---
 drivers/media/video/soc_camera.c |   14 +++---
 include/media/soc_camera.h   |2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index eb25756..b980f99 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -257,13 +257,13 @@ static int soc_camera_g_std(struct file *file, void 
*priv, v4l2_std_id *a)
return v4l2_subdev_call(sd, core, g_std, a);
 }
 
-static int soc_camera_enum_fsizes(struct file *file, void *fh,
+static int soc_camera_enum_framesizes(struct file *file, void *fh,
 struct v4l2_frmsizeenum *fsize)
 {
struct soc_camera_device *icd = file->private_data;
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
 
-   return ici->ops->enum_fsizes(icd, fsize);
+   return ici->ops->enum_framesizes(icd, fsize);
 }
 
 static int soc_camera_reqbufs(struct file *file, void *priv,
@@ -1241,8 +1241,8 @@ static int default_s_parm(struct soc_camera_device *icd,
return v4l2_subdev_call(sd, video, s_parm, parm);
 }
 
-static int default_enum_fsizes(struct soc_camera_device *icd,
- struct v4l2_frmsizeenum *fsize)
+static int default_enum_framesizes(struct soc_camera_device *icd,
+  struct v4l2_frmsizeenum *fsize)
 {
int ret;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
@@ -1295,8 +1295,8 @@ int soc_camera_host_register(struct soc_camera_host *ici)
ici->ops->set_parm = default_s_parm;
if (!ici->ops->get_parm)
ici->ops->get_parm = default_g_parm;
-   if (!ici->ops->enum_fsizes)
-   ici->ops->enum_fsizes = default_enum_fsizes;
+   if (!ici->ops->enum_framesizes)
+   ici->ops->enum_framesizes = default_enum_framesizes;
 
mutex_lock(&list_lock);
list_for_each_entry(ix, &hosts, list) {
@@ -1386,7 +1386,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = 
{
.vidioc_s_input  = soc_camera_s_input,
.vidioc_s_std= soc_camera_s_std,
.vidioc_g_std= soc_camera_g_std,
-   .vidioc_enum_framesizes  = soc_camera_enum_fsizes,
+   .vidioc_enum_framesizes  = soc_camera_enum_framesizes,
.vidioc_reqbufs  = soc_camera_reqbufs,
.vidioc_querybuf = soc_camera_querybuf,
.vidioc_qbuf = soc_camera_qbuf,
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index b5c2b6c..00039d8 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -97,7 +97,7 @@ struct soc_camera_host_ops {
int (*set_bus_param)(struct soc_camera_device *);
int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *);
int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *);
-   int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum 
*);
+   int (*enum_framesizes)(struct soc_camera_device *, struct 
v4l2_frmsizeenum *);
unsigned int (*poll)(struct file *, poll_table *);
 };
 
-- 
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] V4L: mx2-camera: avoid overflowing 32-bits

2012-05-08 Thread Guennadi Liakhovetski
In mx2_camera_try_fmt(), when applying i.MX25 restrictions to frame sizes,
the height is checked to be <= 0x. But later an integer multiplication
height * 4 * 0x3 is performed, which will overflow even for bounded
height values. This patch switches to using 64-bit multiplication and
division to avoid overflowing.

Signed-off-by: Guennadi Liakhovetski 
---

Any objections anyone?

 drivers/media/video/mx2_camera.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 18afaee..ae1420b 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1367,8 +1368,8 @@ static int mx2_camera_try_fmt(struct soc_camera_device 
*icd,
/* Check against the CSIRXCNT limit */
if (pix->sizeimage > 4 * 0x3) {
/* Adjust geometry, preserve aspect ratio */
-   unsigned int new_height = int_sqrt(4 * 0x3 *
-   pix->height / pix->bytesperline);
+   unsigned int new_height = int_sqrt(div_u64(0x3ULL *
+   4 * pix->height, pix->bytesperline));
pix->width = new_height * pix->width / pix->height;
pix->height = new_height;
pix->bytesperline = soc_mbus_bytes_per_line(pix->width,
-- 
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


Re: [PATCH] mt9v032: Correct the logic for the auto-exposure setting

2012-05-08 Thread Laurent Pinchart
Hi Kartik,

On Tuesday 08 May 2012 11:51:29 Kartik Mohta wrote:
> On Tue, May 8, 2012 at 7:12 AM, Laurent Pinchart wrote:
> > On Wednesday 02 May 2012 18:19:08 Kartik Mohta wrote:
> >> The driver uses the ctrl value passed in as a bool to determine whether
> >> to enable auto-exposure, but the auto-exposure setting is defined as an
> >> enum where AUTO has a value of 0 and MANUAL has a value of 1. This leads
> >> to a reversed logic where if you send in AUTO, it actually sets manual
> >> exposure and vice-versa.
> >> 
> >> Signed-off-by: Kartik Mohta 
> >> ---
> >>  drivers/media/video/mt9v032.c |8 +++-
> >>  1 file changed, 7 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/media/video/mt9v032.c
> >> b/drivers/media/video/mt9v032.c
> >> index 75e253a..8ea8737 100644
> >> --- a/drivers/media/video/mt9v032.c
> >> +++ b/drivers/media/video/mt9v032.c
> >> @@ -470,6 +470,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
> >>   container_of(ctrl->handler, struct mt9v032, ctrls);
> >>   struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev);
> >>   u16 data;
> >> + int aec_value;
> >> 
> >>   switch (ctrl->id) {
> >>   case V4L2_CID_AUTOGAIN:
> >> @@ -480,8 +481,13 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
> >>   return mt9v032_write(client, MT9V032_ANALOG_GAIN,
> >> ctrl->val);
> >> 
> >>   case V4L2_CID_EXPOSURE_AUTO:
> >> + if(ctrl->val == V4L2_EXPOSURE_MANUAL)
> >> + aec_value = 0;
> >> + else
> >> + aec_value = 1;
> >> +
> >>   return mt9v032_update_aec_agc(mt9v032, MT9V032_AEC_ENABLE,
> >> -   ctrl->val);
> >> +   aec_value);
> > 
> > What about just
> > 
> >return mt9v032_update_aec_agc(mt9v032, MT9V032_AEC_ENABLE,
> >  !ctrl->val);
> > 
> > If you're fine with that change I'll modify the patch accordingly, there's
> > no need to resubmit (I'll of course keep the patch attribution).
> 
> That should work since the only supported exposure modes are auto and manual
> with enum values 0 and 1 respectively, but then aren't you depending on the
> values of the enum to not change in the future?

The values are part of the V4L2 public API so they can't change.

> Also the change gives an impression that the value is a bool which it is
> not. If that is fine, you can change it.

OK thank you.

-- 
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] V4L: soc-camera: (cosmetic) use a more explicit name for a host handler

2012-05-08 Thread Aguirre, Sergio
Hi Guennadi,

On Tue, May 8, 2012 at 12:00 PM, Guennadi Liakhovetski
 wrote:
> Use "enum_framesizes" instead of "enum_fsizes" to more precisely follow
> the name of the respective ioctl().
>
> Signed-off-by: Guennadi Liakhovetski 

Looks good to me!

I'll redo my patch following this ioctl name matching.

Reviewed-by: Sergio Aguirre 

Regards,
Sergio

> ---
>  drivers/media/video/soc_camera.c |   14 +++---
>  include/media/soc_camera.h       |    2 +-
>  2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/video/soc_camera.c 
> b/drivers/media/video/soc_camera.c
> index eb25756..b980f99 100644
> --- a/drivers/media/video/soc_camera.c
> +++ b/drivers/media/video/soc_camera.c
> @@ -257,13 +257,13 @@ static int soc_camera_g_std(struct file *file, void 
> *priv, v4l2_std_id *a)
>        return v4l2_subdev_call(sd, core, g_std, a);
>  }
>
> -static int soc_camera_enum_fsizes(struct file *file, void *fh,
> +static int soc_camera_enum_framesizes(struct file *file, void *fh,
>                                         struct v4l2_frmsizeenum *fsize)
>  {
>        struct soc_camera_device *icd = file->private_data;
>        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
>
> -       return ici->ops->enum_fsizes(icd, fsize);
> +       return ici->ops->enum_framesizes(icd, fsize);
>  }
>
>  static int soc_camera_reqbufs(struct file *file, void *priv,
> @@ -1241,8 +1241,8 @@ static int default_s_parm(struct soc_camera_device *icd,
>        return v4l2_subdev_call(sd, video, s_parm, parm);
>  }
>
> -static int default_enum_fsizes(struct soc_camera_device *icd,
> -                         struct v4l2_frmsizeenum *fsize)
> +static int default_enum_framesizes(struct soc_camera_device *icd,
> +                                  struct v4l2_frmsizeenum *fsize)
>  {
>        int ret;
>        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
> @@ -1295,8 +1295,8 @@ int soc_camera_host_register(struct soc_camera_host 
> *ici)
>                ici->ops->set_parm = default_s_parm;
>        if (!ici->ops->get_parm)
>                ici->ops->get_parm = default_g_parm;
> -       if (!ici->ops->enum_fsizes)
> -               ici->ops->enum_fsizes = default_enum_fsizes;
> +       if (!ici->ops->enum_framesizes)
> +               ici->ops->enum_framesizes = default_enum_framesizes;
>
>        mutex_lock(&list_lock);
>        list_for_each_entry(ix, &hosts, list) {
> @@ -1386,7 +1386,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops 
> = {
>        .vidioc_s_input          = soc_camera_s_input,
>        .vidioc_s_std            = soc_camera_s_std,
>        .vidioc_g_std            = soc_camera_g_std,
> -       .vidioc_enum_framesizes  = soc_camera_enum_fsizes,
> +       .vidioc_enum_framesizes  = soc_camera_enum_framesizes,
>        .vidioc_reqbufs          = soc_camera_reqbufs,
>        .vidioc_querybuf         = soc_camera_querybuf,
>        .vidioc_qbuf             = soc_camera_qbuf,
> diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
> index b5c2b6c..00039d8 100644
> --- a/include/media/soc_camera.h
> +++ b/include/media/soc_camera.h
> @@ -97,7 +97,7 @@ struct soc_camera_host_ops {
>        int (*set_bus_param)(struct soc_camera_device *);
>        int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *);
>        int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *);
> -       int (*enum_fsizes)(struct soc_camera_device *, struct 
> v4l2_frmsizeenum *);
> +       int (*enum_framesizes)(struct soc_camera_device *, struct 
> v4l2_frmsizeenum *);
>        unsigned int (*poll)(struct file *, poll_table *);
>  };
>
> --
> 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


Re: [PATCH] V4L: soc-camera: (cosmetic) use a more explicit name for a host handler

2012-05-08 Thread Guennadi Liakhovetski
Hi Sergio

On Tue, 8 May 2012, Aguirre, Sergio wrote:

> Hi Guennadi,
> 
> On Tue, May 8, 2012 at 12:00 PM, Guennadi Liakhovetski
>  wrote:
> > Use "enum_framesizes" instead of "enum_fsizes" to more precisely follow
> > the name of the respective ioctl().
> >
> > Signed-off-by: Guennadi Liakhovetski 
> 
> Looks good to me!

Thanks

> I'll redo my patch following this ioctl name matching.

Well, but naming was just one doubt about your patch - and in fact the 
least important one. What about the other one - the actually important one 
- do we really want to abuse struct v4l2_frmivalenum, or we want to switch 
to the one, used for pad operations or we want to invent something new? We 
still haven't got any opinions on that...

Thanks
Guennadi

> 
> Reviewed-by: Sergio Aguirre 
> 
> Regards,
> Sergio
> 
> > ---
> >  drivers/media/video/soc_camera.c |   14 +++---
> >  include/media/soc_camera.h       |    2 +-
> >  2 files changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/media/video/soc_camera.c 
> > b/drivers/media/video/soc_camera.c
> > index eb25756..b980f99 100644
> > --- a/drivers/media/video/soc_camera.c
> > +++ b/drivers/media/video/soc_camera.c
> > @@ -257,13 +257,13 @@ static int soc_camera_g_std(struct file *file, void 
> > *priv, v4l2_std_id *a)
> >        return v4l2_subdev_call(sd, core, g_std, a);
> >  }
> >
> > -static int soc_camera_enum_fsizes(struct file *file, void *fh,
> > +static int soc_camera_enum_framesizes(struct file *file, void *fh,
> >                                         struct v4l2_frmsizeenum *fsize)
> >  {
> >        struct soc_camera_device *icd = file->private_data;
> >        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
> >
> > -       return ici->ops->enum_fsizes(icd, fsize);
> > +       return ici->ops->enum_framesizes(icd, fsize);
> >  }
> >
> >  static int soc_camera_reqbufs(struct file *file, void *priv,
> > @@ -1241,8 +1241,8 @@ static int default_s_parm(struct soc_camera_device 
> > *icd,
> >        return v4l2_subdev_call(sd, video, s_parm, parm);
> >  }
> >
> > -static int default_enum_fsizes(struct soc_camera_device *icd,
> > -                         struct v4l2_frmsizeenum *fsize)
> > +static int default_enum_framesizes(struct soc_camera_device *icd,
> > +                                  struct v4l2_frmsizeenum *fsize)
> >  {
> >        int ret;
> >        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
> > @@ -1295,8 +1295,8 @@ int soc_camera_host_register(struct soc_camera_host 
> > *ici)
> >                ici->ops->set_parm = default_s_parm;
> >        if (!ici->ops->get_parm)
> >                ici->ops->get_parm = default_g_parm;
> > -       if (!ici->ops->enum_fsizes)
> > -               ici->ops->enum_fsizes = default_enum_fsizes;
> > +       if (!ici->ops->enum_framesizes)
> > +               ici->ops->enum_framesizes = default_enum_framesizes;
> >
> >        mutex_lock(&list_lock);
> >        list_for_each_entry(ix, &hosts, list) {
> > @@ -1386,7 +1386,7 @@ static const struct v4l2_ioctl_ops 
> > soc_camera_ioctl_ops = {
> >        .vidioc_s_input          = soc_camera_s_input,
> >        .vidioc_s_std            = soc_camera_s_std,
> >        .vidioc_g_std            = soc_camera_g_std,
> > -       .vidioc_enum_framesizes  = soc_camera_enum_fsizes,
> > +       .vidioc_enum_framesizes  = soc_camera_enum_framesizes,
> >        .vidioc_reqbufs          = soc_camera_reqbufs,
> >        .vidioc_querybuf         = soc_camera_querybuf,
> >        .vidioc_qbuf             = soc_camera_qbuf,
> > diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
> > index b5c2b6c..00039d8 100644
> > --- a/include/media/soc_camera.h
> > +++ b/include/media/soc_camera.h
> > @@ -97,7 +97,7 @@ struct soc_camera_host_ops {
> >        int (*set_bus_param)(struct soc_camera_device *);
> >        int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm 
> > *);
> >        int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm 
> > *);
> > -       int (*enum_fsizes)(struct soc_camera_device *, struct 
> > v4l2_frmsizeenum *);
> > +       int (*enum_framesizes)(struct soc_camera_device *, struct 
> > v4l2_frmsizeenum *);
> >        unsigned int (*poll)(struct file *, poll_table *);
> >  };
> >
> > --
> > 1.7.2.5
> >
> 

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


[GIT PULL for v3.5] Miscellaneous sensor drivers and control framework fixes

2012-05-08 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit aeebb1b3146a70bf02d0115a2be690d856d12e8c:

  [media] pvrusb2: For querystd, start with list of hardware-supported 
standards (2012-05-07 16:58:00 -0300)

are available in the git repository at:
  git://linuxtv.org/pinchartl/media.git omap3isp-sensors-next

Guennadi Liakhovetski (3):
  mt9m032: fix two dead-locks
  mt9m032: fix compilation breakage
  mt9m032: use the available subdev pointer, don't re-calculate it

Kartik Mohta (1):
  mt9v032: Correct the logic for the auto-exposure setting

Laurent Pinchart (5):
  mt9p031: Identify color/mono models using I2C device name
  mt9p031: Replace the reset board callback by a GPIO number
  mt9p031: Implement black level compensation control
  v4l: aptina-pll: Round up minimum multiplier factor value properly
  v4l: v4l2-ctrls: Add forward declaration of struct file

 drivers/media/video/Kconfig  |2 +-
 drivers/media/video/aptina-pll.c |5 +-
 drivers/media/video/mt9m032.c|9 +-
 drivers/media/video/mt9p031.c|  161 +
 drivers/media/video/mt9v032.c|2 +-
 include/media/mt9p031.h  |   19 +++--
 include/media/v4l2-ctrls.h   |1 +
 7 files changed, 165 insertions(+), 34 deletions(-)

-- 
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: [RFCv1] DVB-USB improvements

2012-05-08 Thread Markus Rechberger
On Tue, May 8, 2012 at 3:12 PM, Antti Palosaari  wrote:
> Factors behind the changes are mostly coming from the fact current struct
> dvb_usb_device_properties contains so many static configuration options. You
> cannot change single dvb_usb_device_properties easily (safely) at runtime
> since it is usually driver global struct and thus shared between all the DVB
> USB driver instances. That fits just fine for the traditional devices where
> all configuration is same for the devices having single USB ID. Nowadays we
> have more and more devices that are based of chipset vendor reference
> designs - even using just single USB ID chipset vendor have given for that
> chipset. These reference designs still varies much about used chips and
> configurations. Configuring different base chips, USB-bridge, demod, tuner,
> and also peripheral properties like dual tuners, remotes and CI is needed to
> do runtime because of single USB ID is used for that all.
>
> My personal innovator behind all these is problems I met when developing
> AF9015 and AF9035 drivers. Also RTL2831U and RTL2832U are kinda similar and
> have given some more motivation.
>
> Here is small list what I am planning to do. It is surely so much work that
> everything is not possible, but lets try to select most important and
> easiest as a higher priority.
>
>
> resume / suspend support
> ---
> * very important feature
> * crashes currently when DVB USB tries to download firmware when resuming
> from suspend
>
> read_config1
> ---
> * new callback to do initial tweaks
> * very first callback
> * is that really needed?
>
> read_mac_address => read_config2
> ---
> * rename it read_config2 or read_config if read_config1 is not implemented
> at all
> * rename old callback and extend it usage as a more general
> * only 8 devices use currently
> * when returned mac != 0 => print mac address as earlier, otherwise work as
> a general callback
>
> new callback init()
> ---
> * called after tuner attach to initialize rest of device
> * good place to do some general settings
>  - configure endpoints
>  - configure remote controller
>  - configure + attach CI
>
> change DVB-USB to dynamic debug
> ---
> * use Kernel new dynamic debugs instead of own proprietary system
>
> download_firmware
> ---
> * struct usb_device => struct dvb_usb_device
> * we need access for the DVB USB driver state in every callback
>
> identify_state
> ---
> * struct usb_device => struct dvb_usb_device
> * we need access for the DVB USB driver state in every callback
>
> attach all given adapter frontends as once
> ---
> * for the MFE devices attach all frontends as once
> * deregister all frontends if error returned
> * small effect only for MFE
>
> attach all given adapter tuners as once
> ---
> * deregister all frontends if error returned
> * small effect only for MFE
>
> make remote dynamically configurable
> ---
> * default keytable mapped same level with USB-ID & device name etc.
> * there is generally 3 things that could be mapped to USB ID
>  - USB IDs (cold + warm)
>  - device name
>  - remote controller keytable
>  - all the others could be resolved & configured dynamically
> * it is not only keytable but whole remote should be changed dynamically
> configurable
>
> make stream dynamically configurable
> ---
> * we need change stream parameters in certain situations
>  - there is multiple endpoints but shared MFE
>  - need to set params according to stream bandwidth (USB1.1, DVB-T, DVB-C2
> in same device)
>  - leave old static configrations as those are but add callbacks to get new
> values at runtime
>
> dynamically growing device list in dvb_usb_device_properties
> ---
> * currently number of devices are limited statically
> * there is devices having ~50 or more IDs which means multiple
> dvb_usb_device_properties are needed
>
> dynamic USB ID support
> ---
> * currently not supported by DVB USB
>
> analog support for the DVB USB
> ---
> * currently not supported by DVB USB
> * I have no experience
> * em28xx can be converted?
>

You might also work on a dvb library, just like libv4l has right now,
that might satisfy the streaming requests which have been made on this
mailinglist :-)

BR,
Markus

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

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

Results of the daily build of media_tree:

date:Tue May  8 19:00:18 CEST 2012
git hash:aeebb1b3146a70bf02d0115a2be690d856d12e8c
gcc version:  i686-linux-gcc (GCC) 4.6.3
host hardware:x86_64
host os:  3.1-2.slh.1-amd64

linux-git-arm-eabi-exynos: WARNINGS
linux-git-arm-eabi-omap: WARNINGS
linux-git-armv5-ixp: WARNINGS
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: OK
linux-git-x86_64: OK
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: OK
linux-3.1-i686: OK
linux-3.2.1-i686: OK
linux-3.3-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
linux-3.2.1-x86_64: WARNINGS
linux-3.3-x86_64: WARNINGS
apps: WARNINGS
spec-git: WARNINGS
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The 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: [RFCv1] DVB-USB improvements

2012-05-08 Thread Antti Palosaari

On 08.05.2012 20:55, Markus Rechberger wrote:

You might also work on a dvb library, just like libv4l has right now,
that might satisfy the streaming requests which have been made on this
mailinglist :-)


I want first fix general DVB issues I has met during these years. Maybe 
library can be done next year or so :]


Actually library has been on my mind few times, but what I see it useful 
is for example implementing channel scanner.


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


em28xx : can work on ARM beagleboard ?

2012-05-08 Thread CB

Hello,

I would like to know if someone has already used the em28xx driver on a 
beagleboard xM

(the connected device is a Dazzle DVC 100)

I have tried with an Angstrom Narcissus image and a Debian but I still 
get "select timeouts" and skipped frames with mencoded or the capture.c 
sample


Thanks in advance,

Regards,
Chris


--
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: em28xx : can work on ARM beagleboard ?

2012-05-08 Thread Antti Palosaari

On 08.05.2012 21:18, CB wrote:

I would like to know if someone has already used the em28xx driver on a
beagleboard xM
(the connected device is a Dazzle DVC 100)

I have tried with an Angstrom Narcissus image and a Debian but I still
get "select timeouts" and skipped frames with mencoded or the capture.c
sample


It should work as I know one person ran PCTV NanoStick T2 290e using 
Pandaboard which is rather similar ARM hw.

http://www.youtube.com/watch?v=Wuwyuw0y1Fo

Did you tried it on x86 hardware?

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


Re: [PATCH] V4L: soc-camera: (cosmetic) use a more explicit name for a host handler

2012-05-08 Thread Laurent Pinchart
On Tuesday 08 May 2012 19:44:11 Guennadi Liakhovetski wrote:
> On Tue, 8 May 2012, Aguirre, Sergio wrote:
> > On Tue, May 8, 2012 at 12:00 PM, Guennadi Liakhovetski wrote:
> > > Use "enum_framesizes" instead of "enum_fsizes" to more precisely follow
> > > the name of the respective ioctl().
> > > 
> > > Signed-off-by: Guennadi Liakhovetski 
> > 
> > Looks good to me!
> 
> Thanks
> 
> > I'll redo my patch following this ioctl name matching.
> 
> Well, but naming was just one doubt about your patch - and in fact the
> least important one. What about the other one - the actually important one
> - do we really want to abuse struct v4l2_frmivalenum, or we want to switch
> to the one, used for pad operations or we want to invent something new? We
> still haven't got any opinions on that...

What about switching to pad operations altogether ? :-)


-- 
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: em28xx : can work on ARM beagleboard ?

2012-05-08 Thread Devin Heitmueller
On Tue, May 8, 2012 at 2:24 PM, Antti Palosaari  wrote:
> It should work as I know one person ran PCTV NanoStick T2 290e using
> Pandaboard which is rather similar ARM hw.
> http://www.youtube.com/watch?v=Wuwyuw0y1Fo

I ran into a couple of issues related to em28xx analog on ARM.
Haven't had a chance to submit patches yet.  To answer the question
though:  yes, analog support for the em28xx is known to be broken on
ARM right now.

Devin

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


Re: em28xx : can work on ARM beagleboard ?

2012-05-08 Thread Antti Palosaari

On 08.05.2012 21:47, Devin Heitmueller wrote:

On Tue, May 8, 2012 at 2:24 PM, Antti Palosaari  wrote:

It should work as I know one person ran PCTV NanoStick T2 290e using
Pandaboard which is rather similar ARM hw.
http://www.youtube.com/watch?v=Wuwyuw0y1Fo


I ran into a couple of issues related to em28xx analog on ARM.
Haven't had a chance to submit patches yet.  To answer the question
though:  yes, analog support for the em28xx is known to be broken on
ARM right now.


Aah, OK. I missed that was analog capture device. Devin surely knows 
what he speaks.


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


Re: [media-ctl PATCH v2 1/2] New, more flexible syntax for format

2012-05-08 Thread Laurent Pinchart
Hi Sakari,

Thanks for the patch.

On Monday 07 May 2012 16:46:35 Sakari Ailus wrote:
> More flexible and extensible syntax for format which allows better usage
> of the selection API.
> 
> Signed-off-by: Sakari Ailus 
> ---
>  src/main.c   |   17 ++---
>  src/options.c|   27 +---
>  src/v4l2subdev.c |   70 ---
>  3 files changed, 74 insertions(+), 40 deletions(-)

[snip]

> diff --git a/src/options.c b/src/options.c
> index 60cf6d5..46f6bef 100644
> --- a/src/options.c
> +++ b/src/options.c
> @@ -37,8 +37,8 @@ static void usage(const char *argv0, int verbose)
>   printf("%s [options] device\n", argv0);
>   printf("-d, --device devMedia device name (default: %s)\n",
> MEDIA_DEVNAME_DEFAULT);
>   printf("-e, --entity name   Print the device name associated with 
> the
> given entity\n");
> - printf("-f, --set-formatComma-separated list of formats to
> setup\n");
> - printf("   --get-format pad Print the active format on a given 
> pad\n");
> + printf("-V, --set-v4l2 v4l2 Comma-separated list of formats to 
> setup\n");
> + printf("   --get-v4l2 pad   Print the active format on a given 
> pad\n");

I still need to think about the name change.

>   printf("-h, --help  Show verbose help and exit\n");
>   printf("-i, --interactive   Modify links interactively\n");
>   printf("-l, --links Comma-separated list of links 
> descriptors to
> setup\n");
> @@ -52,13 +52,17 @@ static void usage(const char *argv0, int verbose)
> 
>   printf("\n");
>   printf("Links and formats are defined as\n");
> - printf("\tlink= pad, '->', pad, '[', flags, ']' ;\n");
> - printf("\tformat  = pad, '[', fcc, ' ', size, [ ' ', crop ], [ '
> ', '@', frame interval ], ']' ;\n"); -printf("\tpad = 
> entity,
> ':', pad number ;\n");
> - printf("\tentity  = entity number | ( '\"', entity name, '\"' )
> ;\n"); -  printf("\tsize= width, 'x', height ;\n");
> - printf("\tcrop= '(', left, ',', top, ')', '/', size ;\n");
> - printf("\tframe interval  = numerator, '/', denominator ;\n");
> + printf("\tlink= pad, '->', pad, '[', flags, ']' ;\n");
> + printf("\tv4l2= pad, '[', v4l2-cfgs ']' ;\n");
> + printf("\tv4l2-cfgs   = v4l2-cfg [ ',' v4l2-cfg ] ;\n");
> + printf("\tv4l2-cfg= v4l2-mbusfmt | v4l2-crop\n");
> + printf("\t  | v4l2 frame interval ;\n");
> + printf("\tv4l2-mbusfmt= 'fmt:', fcc, '/', size ;\n");
> + printf("\tpad = entity, ':', pad number ;\n");
> + printf("\tentity  = entity number | ( '\"', entity name, 
> '\"'
> ) ;\n"); +printf("\tsize= width, 'x', height ;\n");
> + printf("\tv4l2-crop   = 'crop:(', left, ',', top, ')/', size
> ;\n"); +  printf("\tv4l2 frame interval = '@', numerator, '/', denominator
> ;\n"); printf("where the fields are\n");
>   printf("\tentity number   Entity numeric identifier\n");
>   printf("\tentity name Entity name (string) \n");
> @@ -77,7 +81,9 @@ static void usage(const char *argv0, int verbose)
>  static struct option opts[] = {
>   {"device", 1, 0, 'd'},
>   {"entity", 1, 0, 'e'},
> + {"set-v4l2", 1, 0, 'V'},
>   {"set-format", 1, 0, 'f'},
> + {"get-v4l2", 1, 0, OPT_GET_FORMAT},
>   {"get-format", 1, 0, OPT_GET_FORMAT},
>   {"help", 0, 0, 'h'},
>   {"interactive", 0, 0, 'i'},
> @@ -98,7 +104,7 @@ int parse_cmdline(int argc, char **argv)
>   }
> 
>   /* parse options */
> - while ((opt = getopt_long(argc, argv, "d:e:f:hil:prv", opts, NULL)) != 
-1)
> { +   while ((opt = getopt_long(argc, argv, "d:e:V:f:hil:prv", opts, NULL))
> != -1) { switch (opt) {
>   case 'd':
>   media_opts.devname = optarg;
> @@ -108,6 +114,7 @@ int parse_cmdline(int argc, char **argv)
>   media_opts.entity = optarg;
>   break;
> 
> + case 'V':
>   case 'f':
>   media_opts.formats = optarg;
>   break;
> diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c
> index a2ab0c4..6881553 100644
> --- a/src/v4l2subdev.c
> +++ b/src/v4l2subdev.c
> @@ -233,13 +233,13 @@ static int v4l2_subdev_parse_format(struct
> v4l2_mbus_framefmt *format, char *end;
> 
>   for (; isspace(*p); ++p);
> - for (end = (char *)p; !isspace(*end) && *end != '\0'; ++end);
> + for (end = (char *)p; *end != '/' && *end != '\0'; ++end);

I wouldn't change this to keep compatibility with the existing syntax.

> 
>   code = v4l2_subdev_string_to_pixelcode(p, end - p);
>   if (code == (enum v4l2_mbus_pixelcode)-1)
>   return -EINVAL;
> 
> - for (p = end; isspace(*p); ++p);
> + p = end + 1;
>  

Re: [media-ctl PATCH v2 2/2] Compose rectangle support for libv4l2subdev

2012-05-08 Thread Laurent Pinchart
Hi Sakari,

Thanks for the patch.

On Monday 07 May 2012 16:46:36 Sakari Ailus wrote:
> Signed-off-by: Sakari Ailus 

Acked-by: Laurent Pinchart 

> ---
>  src/main.c   |   14 ++
>  src/options.c|6 --
>  src/v4l2subdev.c |   32 +++-
>  3 files changed, 41 insertions(+), 11 deletions(-)
> 
> diff --git a/src/main.c b/src/main.c
> index 2f57352..a989669 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -77,6 +77,20 @@ static void v4l2_subdev_print_format(struct media_entity
> *entity, printf("\n\t\t crop:%u,%u/%ux%u", rect.left, rect.top,
>  rect.width, rect.height);
> 
> + ret = v4l2_subdev_get_selection(entity, &rect, pad,
> + V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS,
> + which);
> + if (ret == 0)
> + printf("\n\t\t compose.bounds:%u,%u/%ux%u",
> +rect.left, rect.top, rect.width, rect.height);
> +
> + ret = v4l2_subdev_get_selection(entity, &rect, pad,
> + V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL,
> + which);
> + if (ret == 0)
> + printf("\n\t\t compose:%u,%u/%ux%u",
> +rect.left, rect.top, rect.width, rect.height);
> +
>   printf("]");
>  }
> 
> diff --git a/src/options.c b/src/options.c
> index 46f6bef..8e80bd0 100644
> --- a/src/options.c
> +++ b/src/options.c
> @@ -56,12 +56,14 @@ static void usage(const char *argv0, int verbose)
>   printf("\tv4l2= pad, '[', v4l2-cfgs ']' ;\n");
>   printf("\tv4l2-cfgs   = v4l2-cfg [ ',' v4l2-cfg ] ;\n");
>   printf("\tv4l2-cfg= v4l2-mbusfmt | v4l2-crop\n");
> - printf("\t  | v4l2 frame interval ;\n");
> + printf("\t  | v4l2-compose | v4l2 frame interval
> ;\n"); printf("\tv4l2-mbusfmt= 'fmt:', fcc, '/', size ;\n");
>   printf("\tpad = entity, ':', pad number ;\n");
>   printf("\tentity  = entity number | ( '\"', entity name, 
> '\"'
> ) ;\n"); printf("\tsize= width, 'x', height ;\n");
> - printf("\tv4l2-crop   = 'crop:(', left, ',', top, ')/', size
> ;\n"); +  printf("\tv4l2-crop   = 'crop:', v4l2-rectangle ;\n");
> + printf("\tv4l2-compose= 'compose:', v4l2-rectangle ;\n");
> + printf("\tv4l2-rectangle  = '(', left, ',', top, ')/', size ;\n");
>   printf("\tv4l2 frame interval = '@', numerator, '/', denominator ;\n");
>   printf("where the fields are\n");
>   printf("\tentity number   Entity numeric identifier\n");
> diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c
> index 6881553..0abb4f4 100644
> --- a/src/v4l2subdev.c
> +++ b/src/v4l2subdev.c
> @@ -320,8 +320,8 @@ static int strhazit(const char *str, const char **p)
> 
>  static struct media_pad *v4l2_subdev_parse_pad_format(
>   struct media_device *media, struct v4l2_mbus_framefmt *format,
> - struct v4l2_rect *crop, struct v4l2_fract *interval, const char *p,
> - char **endp)
> + struct v4l2_rect *crop, struct v4l2_rect *compose,
> + struct v4l2_fract *interval, const char *p, char **endp)
>  {
>   struct media_pad *pad;
>   char *end;
> @@ -358,6 +358,15 @@ static struct media_pad *v4l2_subdev_parse_pad_format(
>   continue;
>   }
> 
> + if (!strhazit("compose:", &p)) {
> + ret = v4l2_subdev_parse_rectangle(compose, p, &end);
> + if (ret < 0)
> + return NULL;
> +
> + for (p = end; isspace(*p); p++);
> + continue;
> + }
> +
>   if (*p == '@') {
>   ret = v4l2_subdev_parse_frame_interval(interval, ++p, 
> &end);
>   if (ret < 0)
> @@ -471,30 +480,35 @@ static int v4l2_subdev_parse_setup_format(struct
> media_device *media, struct v4l2_mbus_framefmt format = { 0, 0, 0 };
>   struct media_pad *pad;
>   struct v4l2_rect crop = { -1, -1, -1, -1 };
> + struct v4l2_rect compose = crop;
>   struct v4l2_fract interval = { 0, 0 };
>   unsigned int i;
>   char *end;
>   int ret;
> 
> - pad = v4l2_subdev_parse_pad_format(media, &format, &crop, &interval,
> -p, &end);
> + pad = v4l2_subdev_parse_pad_format(media, &format, &crop, &compose,
> +&interval, p, &end);
>   if (pad == NULL) {
>   media_dbg(media, "Unable to parse format\n");
>   return -EINVAL;
>   }
> 
> - if (pad->flags & MEDIA_PAD_FL_SOURCE) {
> - ret = set_selection(pad, V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL, 
> &crop);
> + if (pad->flags & MEDIA_PAD_FL_SINK) {
> + ret = set_format(pad, &format);
>   if (ret < 0)
>   return 

Re: [media-ctl PATCH v2 1/2] New, more flexible syntax for format

2012-05-08 Thread Sakari Ailus
Hi Laurent,

Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thanks for the patch.
> 
> On Monday 07 May 2012 16:46:35 Sakari Ailus wrote:
>> More flexible and extensible syntax for format which allows better usage
>> of the selection API.
>>
>> Signed-off-by: Sakari Ailus 
>> ---
>>  src/main.c   |   17 ++---
>>  src/options.c|   27 +---
>>  src/v4l2subdev.c |   70 ---
>>  3 files changed, 74 insertions(+), 40 deletions(-)
> 
> [snip]
> 
>> diff --git a/src/options.c b/src/options.c
>> index 60cf6d5..46f6bef 100644
>> --- a/src/options.c
>> +++ b/src/options.c
>> @@ -37,8 +37,8 @@ static void usage(const char *argv0, int verbose)
>>  printf("%s [options] device\n", argv0);
>>  printf("-d, --device devMedia device name (default: %s)\n",
>> MEDIA_DEVNAME_DEFAULT);
>>  printf("-e, --entity name   Print the device name associated with 
>> the
>> given entity\n");
>> -printf("-f, --set-formatComma-separated list of formats to
>> setup\n");
>> -printf("   --get-format pad Print the active format on a given 
>> pad\n");
>> +printf("-V, --set-v4l2 v4l2 Comma-separated list of formats to 
>> setup\n");
>> +printf("   --get-v4l2 pad   Print the active format on a given 
>> pad\n");
> 
> I still need to think about the name change.
> 
>>  printf("-h, --help  Show verbose help and exit\n");
>>  printf("-i, --interactive   Modify links interactively\n");
>>  printf("-l, --links Comma-separated list of links 
>> descriptors to
>> setup\n");
>> @@ -52,13 +52,17 @@ static void usage(const char *argv0, int verbose)
>>
>>  printf("\n");
>>  printf("Links and formats are defined as\n");
>> -printf("\tlink= pad, '->', pad, '[', flags, ']' ;\n");
>> -printf("\tformat  = pad, '[', fcc, ' ', size, [ ' ', crop ], [ '
>> ', '@', frame interval ], ']' ;\n"); -   printf("\tpad = 
>> entity,
>> ':', pad number ;\n");
>> -printf("\tentity  = entity number | ( '\"', entity name, '\"' )
>> ;\n"); - printf("\tsize= width, 'x', height ;\n");
>> -printf("\tcrop= '(', left, ',', top, ')', '/', size ;\n");
>> -printf("\tframe interval  = numerator, '/', denominator ;\n");
>> +printf("\tlink= pad, '->', pad, '[', flags, ']' ;\n");
>> +printf("\tv4l2= pad, '[', v4l2-cfgs ']' ;\n");
>> +printf("\tv4l2-cfgs   = v4l2-cfg [ ',' v4l2-cfg ] ;\n");
>> +printf("\tv4l2-cfg= v4l2-mbusfmt | v4l2-crop\n");
>> +printf("\t  | v4l2 frame interval ;\n");
>> +printf("\tv4l2-mbusfmt= 'fmt:', fcc, '/', size ;\n");
>> +printf("\tpad = entity, ':', pad number ;\n");
>> +printf("\tentity  = entity number | ( '\"', entity name, 
>> '\"'
>> ) ;\n"); +   printf("\tsize= width, 'x', height ;\n");
>> +printf("\tv4l2-crop   = 'crop:(', left, ',', top, ')/', size
>> ;\n"); + printf("\tv4l2 frame interval = '@', numerator, '/', denominator
>> ;\n"); printf("where the fields are\n");
>>  printf("\tentity number   Entity numeric identifier\n");
>>  printf("\tentity name Entity name (string) \n");
>> @@ -77,7 +81,9 @@ static void usage(const char *argv0, int verbose)
>>  static struct option opts[] = {
>>  {"device", 1, 0, 'd'},
>>  {"entity", 1, 0, 'e'},
>> +{"set-v4l2", 1, 0, 'V'},
>>  {"set-format", 1, 0, 'f'},
>> +{"get-v4l2", 1, 0, OPT_GET_FORMAT},
>>  {"get-format", 1, 0, OPT_GET_FORMAT},
>>  {"help", 0, 0, 'h'},
>>  {"interactive", 0, 0, 'i'},
>> @@ -98,7 +104,7 @@ int parse_cmdline(int argc, char **argv)
>>  }
>>
>>  /* parse options */
>> -while ((opt = getopt_long(argc, argv, "d:e:f:hil:prv", opts, NULL)) != 
> -1)
>> { +  while ((opt = getopt_long(argc, argv, "d:e:V:f:hil:prv", opts, NULL))
>> != -1) { switch (opt) {
>>  case 'd':
>>  media_opts.devname = optarg;
>> @@ -108,6 +114,7 @@ int parse_cmdline(int argc, char **argv)
>>  media_opts.entity = optarg;
>>  break;
>>
>> +case 'V':
>>  case 'f':
>>  media_opts.formats = optarg;
>>  break;
>> diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c
>> index a2ab0c4..6881553 100644
>> --- a/src/v4l2subdev.c
>> +++ b/src/v4l2subdev.c
>> @@ -233,13 +233,13 @@ static int v4l2_subdev_parse_format(struct
>> v4l2_mbus_framefmt *format, char *end;
>>
>>  for (; isspace(*p); ++p);
>> -for (end = (char *)p; !isspace(*end) && *end != '\0'; ++end);
>> +for (end = (char *)p; *end != '/' && *end != '\0'; ++end);
> 
> I wouldn't change this to keep compatibility with the existing syntax.

Ok. How about allowing both '/' and ' '?

>>
>>  code = v4l2_subdev_string_to_pixelcode(p, end - p);
>>   

Re: [media-ctl PATCH v2 1/2] New, more flexible syntax for format

2012-05-08 Thread Laurent Pinchart
Hi Sakari,

On Tuesday 08 May 2012 22:43:50 Sakari Ailus wrote:
> Laurent Pinchart wrote:
> > On Monday 07 May 2012 16:46:35 Sakari Ailus wrote:
> >> More flexible and extensible syntax for format which allows better usage
> >> of the selection API.

[snip]

> >> diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c
> >> index a2ab0c4..6881553 100644
> >> --- a/src/v4l2subdev.c
> >> +++ b/src/v4l2subdev.c
> >> @@ -233,13 +233,13 @@ static int v4l2_subdev_parse_format(struct
> >> v4l2_mbus_framefmt *format, char *end;
> >> 
> >>for (; isspace(*p); ++p);
> >> 
> >> -  for (end = (char *)p; !isspace(*end) && *end != '\0'; ++end);
> >> +  for (end = (char *)p; *end != '/' && *end != '\0'; ++end);
> > 
> > I wouldn't change this to keep compatibility with the existing syntax.
> 
> Ok. How about allowing both '/' and ' '?

Do you hate the space that much ? :-) The format code and the resolution are 
not that closely related, / somehow doesn't look intuitive to me.

> >>code = v4l2_subdev_string_to_pixelcode(p, end - p);
> >>if (code == (enum v4l2_mbus_pixelcode)-1)
> >>
> >>return -EINVAL;
> >> 
> >> -  for (p = end; isspace(*p); ++p);
> >> +  p = end + 1;
> >> 
> >>width = strtoul(p, &end, 10);
> >>if (*end != 'x')
> >>
> >>return -EINVAL;
> >> 

[snip]

> >> @@ -326,30 +337,37 @@ static struct media_pad
> >> *v4l2_subdev_parse_pad_format( if (*p++ != '[')
> >> 
> >>return NULL;
> >> 
> >> -  for (; isspace(*p); ++p);
> >> +  for (;;) {
> >> +  for (; isspace(*p); p++);
> >> 
> >> -  if (isalnum(*p)) {
> >> -  ret = v4l2_subdev_parse_format(format, p, &end);
> >> -  if (ret < 0)
> >> -  return NULL;
> >> +  if (!strhazit("fmt:", &p)) {
> >> +  ret = v4l2_subdev_parse_format(format, p, &end);
> >> +  if (ret < 0)
> >> +  return NULL;
> >> 
> >> -  for (p = end; isspace(*p); p++);
> >> -  }
> >> +  p = end;
> >> +  continue;
> >> +  }
> > 
> > I'd like to keep compatibility with the existing syntax here. Checking
> > whether this is the first argument and whether it starts with an
> > uppercase letter should be enough, would you be OK with that ?
> 
> Right. I may have missed something related to keeping the compatibility.
> 
> Capital letter might not be enough in the future; for now it's ok
> though. How about this: if the string doesn't match with anything else,
> interpret it as format?

I've thought about this, but I'm not sure it's a good idea to introduce 
extensions to the existing syntax (we currently have no format starting with 
something else than an uppercase letter) as we're deprecating it.

-- 
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 1/2] V4L: soc-camera: switch to using the existing .enum_framesizes()

2012-05-08 Thread Guennadi Liakhovetski
The recently introduced .enum_mbus_fsizes() v4l2-subdev video operation is
a duplicate of the .enum_framesizes() operation, introduced earlier. Switch
soc-camera over to using the original one.

Signed-off-by: Guennadi Liakhovetski 
Cc: Qing Xu 
---
 drivers/media/video/soc_camera.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index b08696f..6707df4 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -1259,7 +1259,7 @@ static int default_enum_framesizes(struct 
soc_camera_device *icd,
/* map xlate-code to pixel_format, sensor only handle xlate-code*/
fsize_mbus.pixel_format = xlate->code;
 
-   ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &fsize_mbus);
+   ret = v4l2_subdev_call(sd, video, enum_framesizes, &fsize_mbus);
if (ret < 0)
return ret;
 
-- 
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 2/2] V4L: remove unused .enum_mbus_fsizes() subdev video operation

2012-05-08 Thread Guennadi Liakhovetski
.enum_mbus_fsizes() subdev video operation is a duplicate of
.enum_framesizes() and is unused. Remove it.

Signed-off-by: Guennadi Liakhovetski 
Cc: Qing Xu 
---
 include/media/v4l2-subdev.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index f0f3358..9e68464 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -309,8 +309,6 @@ struct v4l2_subdev_video_ops {
struct v4l2_dv_timings *timings);
int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
 enum v4l2_mbus_pixelcode *code);
-   int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
-struct v4l2_frmsizeenum *fsize);
int (*g_mbus_fmt)(struct v4l2_subdev *sd,
  struct v4l2_mbus_framefmt *fmt);
int (*try_mbus_fmt)(struct v4l2_subdev *sd,
-- 
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


Re: [PATCH 2/2] TeVii DVB-S s421 and s632 cards support, rs2000 part

2012-05-08 Thread Malcolm Priestley
On Tue, 2012-05-08 at 11:08 +0300, Igor M. Liplianin wrote:
> One register needs to be changed to TS to work. So we use separate inittab.
> 
> Signed-off-by: Igor M. Liplianin 
Acked-by: Malcolm Priestley 

differences between files attachment (rs2000dw2102.patch)
> diff --git a/drivers/media/dvb/frontends/m88rs2000.c 
> b/drivers/media/dvb/frontends/m88rs2000.c
> index 045ee5a..547230d 100644
> --- a/drivers/media/dvb/frontends/m88rs2000.c
> +++ b/drivers/media/dvb/frontends/m88rs2000.c
> @@ -442,7 +442,11 @@ static int m88rs2000_init(struct dvb_frontend *fe)
>  
>   deb_info("m88rs2000: init chip\n");
>   /* Setup frontend from shutdown/cold */
> - ret = m88rs2000_tab_set(state, m88rs2000_setup);
> + if (state->config->inittab)
> + ret = m88rs2000_tab_set(state,
> + (struct inittab *)state->config->inittab);
> + else
> + ret = m88rs2000_tab_set(state, m88rs2000_setup);
>  
>   return ret;
>  }
Regards


Malcolm


--
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: m88rs2000: LNB voltage control implemented

2012-05-08 Thread Malcolm Priestley
On Tue, 2012-05-08 at 11:25 +0300, Igor M. Liplianin wrote:
> Trival patch to get it working with my cards stuff.
> 
> Signed-off-by: Igor M. Liplianin 
Acked-by: Malcolm Priestley 

> differences between files attachment (rs2000volt.patch)
> diff --git a/drivers/media/dvb/frontends/m88rs2000.c 
> b/drivers/media/dvb/frontends/m88rs2000.c index 547230d..f6d6e39 100644 --- 
> a/drivers/media/dvb/frontends/m88rs2000.c +++ 
> b/drivers/media/dvb/frontends/m88rs2000.c @@ -416,9 +416,25 @@ static int 
> m88rs2000_tab_set(struct m88rs2000_state *state, static int 
> m88rs2000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t volt) { - 
>deb_info("%s: %s\n", __func__, -volt == SEC_VOLTAGE_13 ? 
> "SEC_VOLTAGE_13" : -   volt == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" : 
> "??"); +struct m88rs2000_state *state = fe->demodulator_priv; + u8 data; 
> + +data = m88rs2000_demod_read(state, 0xb2); + data |= 0x03; /* bit0 
> V/H, bit1 off/on */ + +   switch (volt) { +   case SEC_VOLTAGE_18: +  
> data &= ~0x03; +break; +case SEC_VOLTAGE_13: +
>   data &= ~0x03; +data |= 0x01; + break; +
> case SEC_VOLTAGE_OFF: + break; +} + +   
> m88rs2000_demod_write(state, 0xb2, data);   return 0; }
Regards


Malcolm

--
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 v3 08/10] arm: omap4panda: Add support for omap4iss camera

2012-05-08 Thread Tony Lindgren
* Sergio Aguirre  [120502 08:21]:
> This adds support for camera interface with the support for
> following sensors:
> 
> - OV5640
> - OV5650

It seems that at this point we should initialize new things like this
with DT only. We don't quite yet have the muxing in place, but I'd
rather not add yet another big platform_data file for something that
does not even need to be there for DT booted devices.

Regards,

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


Re: [media-ctl PATCH v2 1/2] New, more flexible syntax for format

2012-05-08 Thread Sakari Ailus
Hi Laurent,

Laurent Pinchart wrote:
> Hi Sakari,
> 
> On Tuesday 08 May 2012 22:43:50 Sakari Ailus wrote:
>> Laurent Pinchart wrote:
>>> On Monday 07 May 2012 16:46:35 Sakari Ailus wrote:
 More flexible and extensible syntax for format which allows better usage
 of the selection API.
> 
> [snip]
> 
 diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c
 index a2ab0c4..6881553 100644
 --- a/src/v4l2subdev.c
 +++ b/src/v4l2subdev.c
 @@ -233,13 +233,13 @@ static int v4l2_subdev_parse_format(struct
 v4l2_mbus_framefmt *format, char *end;

for (; isspace(*p); ++p);

 -  for (end = (char *)p; !isspace(*end) && *end != '\0'; ++end);
 +  for (end = (char *)p; *end != '/' && *end != '\0'; ++end);
>>>
>>> I wouldn't change this to keep compatibility with the existing syntax.
>>
>> Ok. How about allowing both '/' and ' '?
> 
> Do you hate the space that much ? :-) The format code and the resolution are 
> not that closely related, / somehow doesn't look intuitive to me.

I don't hate the space --- what I would prefer is to keep distinct sets
of configurations separated by something, and space is good for that. If
it was possible to choose pixel format without having to specify width
and height, I'd probably vote for the space.

That makes parsing easier, too, not that it would matter that much though.

code = v4l2_subdev_string_to_pixelcode(p, end - p);
if (code == (enum v4l2_mbus_pixelcode)-1)

return -EINVAL;

 -  for (p = end; isspace(*p); ++p);
 +  p = end + 1;

width = strtoul(p, &end, 10);
if (*end != 'x')

return -EINVAL;

> 
> [snip]
> 
 @@ -326,30 +337,37 @@ static struct media_pad
 *v4l2_subdev_parse_pad_format( if (*p++ != '[')

return NULL;

 -  for (; isspace(*p); ++p);
 +  for (;;) {
 +  for (; isspace(*p); p++);

 -  if (isalnum(*p)) {
 -  ret = v4l2_subdev_parse_format(format, p, &end);
 -  if (ret < 0)
 -  return NULL;
 +  if (!strhazit("fmt:", &p)) {
 +  ret = v4l2_subdev_parse_format(format, p, &end);
 +  if (ret < 0)
 +  return NULL;

 -  for (p = end; isspace(*p); p++);
 -  }
 +  p = end;
 +  continue;
 +  }
>>>
>>> I'd like to keep compatibility with the existing syntax here. Checking
>>> whether this is the first argument and whether it starts with an
>>> uppercase letter should be enough, would you be OK with that ?
>>
>> Right. I may have missed something related to keeping the compatibility.
>>
>> Capital letter might not be enough in the future; for now it's ok
>> though. How about this: if the string doesn't match with anything else,
>> interpret it as format?
> 
> I've thought about this, but I'm not sure it's a good idea to introduce 
> extensions to the existing syntax (we currently have no format starting with 
> something else than an uppercase letter) as we're deprecating it.

I'm fine with considering capital letters to begin format.

I also thing we should make parsing to return just one configuration at
a time rather than parse everything and return a bunch of structs that
may or may not have been set according to the string given by the user.

But that's for later definitely.

Cheers,

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


Re: [media-ctl PATCH v2 2/2] Compose rectangle support for libv4l2subdev

2012-05-08 Thread Sakari Ailus
Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thanks for the patch.
> 
> On Monday 07 May 2012 16:46:36 Sakari Ailus wrote:
>> Signed-off-by: Sakari Ailus 
> 
> Acked-by: Laurent Pinchart 

Thanks!

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


[GIT PULL FOR v3.5 v2] V4L2 subdev and sensor control changes

2012-05-08 Thread Sakari Ailus
Hi Mauro,

This patchset adds

- Sensor control improvements,
- link_validate() media entity and V4L2 subdev pad ops,
- Other V4L2 and media improvements (see individual patches)

The SMIA++ driver and some of the OMAP3 ISP driver improvements have been
removed from this patchset since they are now dependent on other patches for
linux-omap tree:

http://www.spinics.net/lists/linux-omap/msg69914.html>

Integer menu controls and the subdev selection support has already been
pulled.

Changes since pull for 3.5 v1:

- Rebased on top of current linux-media
- Postponed some patches

Changes since pull for 3.4 v3:

- Changed kernel revision and V4L2 changelog dates appropriately for Linux
  3.5.

Changes since pull v2:

- Fixed incorrect 4CC codes in documentation for compresed raw bayer formats

Changes since pull v1:

- Correct selection rectangle field description in subdev selection
  documentation (thanks to Sylwester)
- Use roundup() instead of ALIGN() in SMIA++ driver
- Rebased on current media_tree.git/staging/for_v3.4

---

The following changes since commit 121b3ddbe4ad17df77cb7284239be0a63d9a66bd:

  [media] media: videobuf2-dma-contig: quiet sparse noise about plain integer 
as NULL pointer (2012-05-08 14:35:14 -0300)

are available in the git repository at:
  ssh://linuxtv.org/git/sailus/media_tree.git media-for-3.5

Sakari Ailus (19):
  v4l: Image source control class
  v4l: Image processing control class
  v4l: Document raw bayer 4CC codes
  v4l: Add DPCM compressed raw bayer pixel formats
  media: Add link_validate() op to check links to the sink pad
  v4l: Improve sub-device documentation for pad ops
  v4l: Implement v4l2_subdev_link_validate()
  v4l: Allow changing control handler lock
  omap3isp: Support additional in-memory compressed bayer formats
  omap3isp: Move definitions required by board code under include/media.
  omap3isp: Move setting constaints above media_entity_pipeline_start
  omap3isp: Assume media_entity_pipeline_start may fail
  omap3isp: Add lane configuration to platform data
  omap3isp: Refactor collecting information on entities in pipeline
  omap3isp: Add information on external subdev to struct isp_pipeline
  omap3isp: Introduce isp_video_check_external_subdevs()
  omap3isp: Use external rate instead of vpcfg
  omap3isp: Default link validation for ccp2, csi2, preview and resizer
  omap3isp: Move CCDC link validation to ccdc_link_validate()

 Documentation/DocBook/media/v4l/controls.xml   |  168 +++
 Documentation/DocBook/media/v4l/pixfmt-srggb10.xml |2 +-
 .../DocBook/media/v4l/pixfmt-srggb10dpcm8.xml  |   29 ++
 Documentation/DocBook/media/v4l/pixfmt.xml |6 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |   12 +
 Documentation/media-framework.txt  |   19 ++
 Documentation/video4linux/4CCs.txt |   32 ++
 Documentation/video4linux/v4l2-framework.txt   |   21 ++
 drivers/media/media-entity.c   |   57 -
 drivers/media/video/adp1653.c  |8 +-
 drivers/media/video/omap3isp/isp.c |   14 -
 drivers/media/video/omap3isp/isp.h |5 -
 drivers/media/video/omap3isp/ispccdc.c |   71 +-
 drivers/media/video/omap3isp/ispccdc.h |   10 -
 drivers/media/video/omap3isp/ispccp2.c |1 +
 drivers/media/video/omap3isp/ispcsi2.c |1 +
 drivers/media/video/omap3isp/ispcsiphy.h   |   15 +-
 drivers/media/video/omap3isp/isppreview.c  |1 +
 drivers/media/video/omap3isp/ispresizer.c  |1 +
 drivers/media/video/omap3isp/ispvideo.c|  307 +++-
 drivers/media/video/omap3isp/ispvideo.h|3 +
 drivers/media/video/v4l2-ctrls.c   |   60 +++--
 drivers/media/video/v4l2-subdev.c  |   64 
 drivers/media/video/vivi.c |4 +-
 include/linux/videodev2.h  |   20 ++
 include/media/media-entity.h   |5 +-
 include/media/omap3isp.h   |   29 ++
 include/media/v4l2-ctrls.h |9 +-
 include/media/v4l2-subdev.h|   12 +
 29 files changed, 761 insertions(+), 225 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-srggb10dpcm8.xml
 create mode 100644 Documentation/video4linux/4CCs.txt


Kind regards,

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


Re: [PATCHv5 08/13] v4l: vb2-dma-contig: add support for scatterlist in userptr mode

2012-05-08 Thread Subash Patel

Hello Tomasz, Laurent,

I have printed some logs during the dmabuf export and attach for the SGT 
issue below. Please find it in the attachment. I hope it will be useful.


Regards,
Subash

On 05/08/2012 04:45 PM, Subash Patel wrote:

Hi Laurent,

On 05/08/2012 02:44 PM, Laurent Pinchart wrote:

Hi Subash,

On Monday 07 May 2012 20:08:25 Subash Patel wrote:

Hello Thomasz, Laurent,

I found an issue in the function vb2_dc_pages_to_sgt() below. I saw that
during the attach, the size of the SGT and size requested mis-matched
(by atleast 8k bytes). Hence I made a small correction to the code as
below. I could then attach the importer properly.


Thank you for the report.

Could you print the content of the sglist (number of chunks and size
of each
chunk) before and after your modifications, as well as the values of
n_pages,
offset and size ?

I will put back all the printk's and generate this. As of now, my setup
has changed and will do this when I get sometime.



On 04/20/2012 08:15 PM, Tomasz Stanislawski wrote:


[snip]


+static struct sg_table *vb2_dc_pages_to_sgt(struct page **pages,
+ unsigned int n_pages, unsigned long offset, unsigned long size)
+{
+ struct sg_table *sgt;
+ unsigned int chunks;
+ unsigned int i;
+ unsigned int cur_page;
+ int ret;
+ struct scatterlist *s;
+
+ sgt = kzalloc(sizeof *sgt, GFP_KERNEL);
+ if (!sgt)
+ return ERR_PTR(-ENOMEM);
+
+ /* compute number of chunks */
+ chunks = 1;
+ for (i = 1; i< n_pages; ++i)
+ if (pages[i] != pages[i - 1] + 1)
+ ++chunks;
+
+ ret = sg_alloc_table(sgt, chunks, GFP_KERNEL);
+ if (ret) {
+ kfree(sgt);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ /* merging chunks and putting them into the scatterlist */
+ cur_page = 0;
+ for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
+ unsigned long chunk_size;
+ unsigned int j;


size = PAGE_SIZE;


+
+ for (j = cur_page + 1; j< n_pages; ++j)


for (j = cur_page + 1; j< n_pages; ++j) {


+ if (pages[j] != pages[j - 1] + 1)
+ break;


size += PAGE
}


+
+ chunk_size = ((j - cur_page)<< PAGE_SHIFT) - offset;
+ sg_set_page(s, pages[cur_page], min(size, chunk_size), offset);


[DELETE] size -= chunk_size;


+ offset = 0;
+ cur_page = j;
+ }
+
+ return sgt;
+}



Regards,
Subash
[  178.545000] vb2_dc_pages_to_sgt() sgt->orig_nents=2
[  178.545000] vb2_dc_pages_to_sgt():83 cur_page=0
[  178.55] vb2_dc_pages_to_sgt():84 offset=0
[  178.555000] vb2_dc_pages_to_sgt():86 chunk_size=131072
[  178.56] vb2_dc_pages_to_sgt():89 size=4294836224
[  178.565000] vb2_dc_pages_to_sgt() sgt->orig_nents=2
[  178.57] vb2_dc_pages_to_sgt():83 cur_page=32
[  178.575000] vb2_dc_pages_to_sgt():84 offset=0
[  178.58] vb2_dc_pages_to_sgt():86 chunk_size=262144
[  178.585000] vb2_dc_pages_to_sgt():89 size=4294574080
[  178.59] vb2_dc_pages_to_sgt() sgt->orig_nents=1
[  178.595000] vb2_dc_pages_to_sgt():83 cur_page=0
[  178.60] vb2_dc_pages_to_sgt():84 offset=0
[  178.605000] vb2_dc_pages_to_sgt():86 chunk_size=8192
[  178.61] vb2_dc_pages_to_sgt():89 size=4294959104
[  178.625000] vb2_dc_pages_to_sgt() sgt->orig_nents=1
[  178.625000] vb2_dc_pages_to_sgt():83 cur_page=0
[  178.63] vb2_dc_pages_to_sgt():84 offset=0
[  178.635000] vb2_dc_pages_to_sgt():86 chunk_size=131072
[  178.64] vb2_dc_pages_to_sgt():89 size=4294836224
[  178.645000] vb2_dc_pages_to_sgt() sgt->orig_nents=1
[  178.65] vb2_dc_pages_to_sgt():83 cur_page=0
[  178.655000] vb2_dc_pages_to_sgt():84 offset=0
[  178.66] vb2_dc_pages_to_sgt():86 chunk_size=131072
[  178.665000] vb2_dc_pages_to_sgt():89 size=4294836224
[  178.67] vb2_dc_mmap: mapped dma addr 0x2006 at 0xb6e01000, size 
131072
[  178.67] vb2_dc_mmap: mapped dma addr 0x2008 at 0xb6de1000, size 
131072
[  178.68] vb2_dc_pages_to_sgt() sgt->orig_nents=2
[  178.685000] vb2_dc_pages_to_sgt():83 cur_page=0
[  178.69] vb2_dc_pages_to_sgt():84 offset=0
[  178.695000] vb2_dc_pages_to_sgt():86 chunk_size=4096
[  178.70] vb2_dc_pages_to_sgt():89 size=4294963200
[  178.705000] vb2_dc_pages_to_sgt() sgt->orig_nents=2
[  178.71] vb2_dc_pages_to_sgt():83 cur_page=1
[  178.715000] vb2_dc_pages_to_sgt():84 offset=0
[  178.715000] vb2_dc_pages_to_sgt():86 chunk_size=8192
[  178.72] vb2_dc_pages_to_sgt():89 size=4294955008
[  178.725000] vb2_dc_pages_to_sgt() sgt->orig_nents=1
[  178.73] vb2_dc_pages_to_sgt():83 cur_page=0
[  178.735000] vb2_dc_pages_to_sgt():84 offset=0
[  178.74] vb2_dc_pages_to_sgt():86 chunk_size=8192
[  178.745000] vb2_dc_pages_to_sgt():89 size=4294959104
[  178.75] vb2_dc_pages_to_sgt() sgt->orig_nents=1
[  178.755000] vb2_dc_pages_to_sgt():83 cur_page=0
[  178.76] vb2_dc_pages_to_sgt():84 offset=0
[  178.765000] vb2_dc_pages_to_sgt():86 chunk_size=131072
[  178.77] vb2_dc_pages_to_sgt():89 size=4294836224
[  178.78] vb2_dc_pages_to_sgt() sgt->orig_nents=2
[  178.78] vb2_dc_pages_to_sgt():83 cur_page=0
[  178.785000] vb2_dc_pages_to_sgt():84 offset=0
[  178.79] vb2_dc_pages_to_sgt():86 chunk_size=65536
[  178.7

Re: [PATCH 3/7] v4l2-dv-timings.h: definitions for CEA-861 and VESA DMT timings.

2012-05-08 Thread Hans Verkuil
Hi Mauro,

I've made a change to this patch. The new patch is included below and the
full patch series can be found in my timingsv4b branch:

git://linuxtv.org/hverkuil/media_tree.git timingsv4b

I've also rebased that branch to the current v3.5.

The problem is that v4l2-dv-timings.h relies on the initialization of an
anonymous union, and gcc compilers < 4.6 do not conform to the C1x standard
and need additional curly brackets.

I've changed the header to also support older gcc versions. I've tested it
with gcc-4.4/5/6/7.

I have thought about always adding those extra brackets, but based on posts
like this:

http://stackoverflow.com/questions/5063548/initialization-of-anonymous-structures-or-unions-in-c1x

that is a solution that will work for gcc (for now), but not for other 
compilers.

Regards,

Hans

v4l2-dv-timings.h: definitions for CEA-861 and VESA DMT timings.

This header contains the timings for the common CEA-861 and all VESA
DMT formats for use with the V4L2 dv_timings API.

Signed-off-by: Hans Verkuil 
Reviewed-by: Mauro Carvalho Chehab 
---
 include/linux/Kbuild|1 +
 include/linux/v4l2-dv-timings.h |  816 +++
 2 files changed, 817 insertions(+)
 create mode 100644 include/linux/v4l2-dv-timings.h

diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 3c9b616..d38b3a8 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -382,6 +382,7 @@ header-y += usbdevice_fs.h
 header-y += utime.h
 header-y += utsname.h
 header-y += uvcvideo.h
+header-y += v4l2-dv-timings.h
 header-y += v4l2-mediabus.h
 header-y += v4l2-subdev.h
 header-y += veth.h
diff --git a/include/linux/v4l2-dv-timings.h b/include/linux/v4l2-dv-timings.h
new file mode 100644
index 000..9ef8172
--- /dev/null
+++ b/include/linux/v4l2-dv-timings.h
@@ -0,0 +1,816 @@
+/*
+ * V4L2 DV timings header.
+ *
+ * Copyright (C) 2012  Hans Verkuil 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _V4L2_DV_TIMINGS_H
+#define _V4L2_DV_TIMINGS_H
+
+#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6))
+/* Sadly gcc versions older than 4.6 have a bug in how they initialize
+   anonymous unions where they require additional curly brackets.
+   This violates the C1x standard. This workaround adds the curly brackets
+   if needed. */
+#define V4L2_INIT_BT_TIMINGS(_width, args...) \
+   { .bt = { _width , ## args } }
+#else
+#define V4L2_INIT_BT_TIMINGS(_width, args...) \
+   .bt = { _width , ## args }
+#endif
+
+/* CEA-861-E timings (i.e. standard HDTV timings) */
+
+#define V4L2_DV_BT_CEA_640X480P59_94 { \
+   .type = V4L2_DV_BT_656_1120, \
+   V4L2_INIT_BT_TIMINGS(640, 480, 0, 0, \
+   25175000, 16, 96, 48, 10, 2, 33, 0, 0, 0, \
+   V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, 0) \
+}
+
+#define V4L2_DV_BT_CEA_720X480P59_94 { \
+   .type = V4L2_DV_BT_656_1120, \
+   V4L2_INIT_BT_TIMINGS(720, 480, 0, 0, \
+   2700, 16, 62, 60, 9, 6, 30, 0, 0, 0, \
+   V4L2_DV_BT_STD_CEA861, 0) \
+}
+
+#define V4L2_DV_BT_CEA_720X576P50 { \
+   .type = V4L2_DV_BT_656_1120, \
+   V4L2_INIT_BT_TIMINGS(720, 576, 0, 0, \
+   2700, 12, 64, 68, 5, 5, 39, 0, 0, 0, \
+   V4L2_DV_BT_STD_CEA861, 0) \
+}
+
+#define V4L2_DV_BT_CEA_1280X720P24 { \
+   .type = V4L2_DV_BT_656_1120, \
+   V4L2_INIT_BT_TIMINGS(1280, 720, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
+   5940, 1760, 40, 220, 5, 5, 20, 0, 0, 0, \
+   V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, \
+   V4L2_DV_FL_CAN_REDUCE_FPS) \
+}
+
+#define V4L2_DV_BT_CEA_1280X720P25 { \
+   .type = V4L2_DV_BT_656_1120, \
+   V4L2_INIT_BT_TIMINGS(1280, 720, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
+   7425, 2420, 40, 220, 5, 5, 20, 0, 0, 0, \
+   V4L2_DV_BT_STD_CEA861, 0) \
+}
+
+#define V4L2_DV_BT_CEA_1280X720P30 { \
+   .type = V4L2_DV_BT_656_1120, \
+   V4L2_INIT_BT_TIMINGS(1280, 720, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
+   7425, 1760, 40, 220, 5, 5, 20, 0, 0, 0, \
+   V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS) \
+}
+
+#define V4L2_DV_BT_CEA_1280X720P50 { \
+   .type = V4L2_DV_BT_656_1120, \
+   V4L2_