videobuf mmap deadlock

2013-11-01 Thread Pete Eberlein
The patch videobuf_vm_{open,close} race fixes 
https://linuxtv.org/patch/18365/ introduced a deadlock in 3.11.


My driver uses videobuf_vmalloc initialized with ext_lock set to NULL.
My driver's mmap function calls videobuf_mmap_mapper
videobuf_mmap_mapper calls videobuf_queue_lock on q
videobuf_mmap_mapper calls  __videobuf_mmap_mapper
 __videobuf_mmap_mapper calls videobuf_vm_open
videobuf_vm_open calls videobuf_queue_lock on q (introduced by above patch)
deadlocked

This is not an issue if ext_lock is non-NULL, since videobuf_queue_lock 
is a no-op in that case.


Did I do something wrong, or is this a valid regression?

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


Re: [GIT PULL] go7007 firmware updates

2013-05-28 Thread Pete Eberlein

Hi Hans,

On 05/27/2013 12:56 PM, Hans Verkuil wrote:

I can revert the rename action,  but I would rather not do it. I

 believe there are good reasons for doing this, especially since the
 current situation is effectively broken anyway due to the missing
 firmware files.

 If you really don't want to rename the two S2250 files, then I'll
 make a patch reverting those to the original filename.

 Pete, if you have an opinion regarding this, please let us know.
 After all, it concerns a Sensoray device.

I am okay with the change of the firmware filenames.  I've changed them 
myself several times in the past before it got into kernel staging.



Regards,


 Hans


Regards,
Pete
--
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] go7007: Fix 2250 urb type

2011-11-18 Thread Pete Eberlein
commit a846d8fce9e8be30046be3c512982bd0345e7015
Author: Pete Eberlein p...@sensoray.com
Date:   Fri Nov 18 10:00:15 2011 -0800

go7007: Fix 2250 urb type

The 2250 board uses bulk endpoint for interrupt handling,
and should use a bulk urb instead of an int urb.

Signed-off-by: Pete Eberlein p...@sensoray.com

diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 3db3b0a..cffb0b3 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1054,7 +1054,13 @@ static int go7007_usb_probe(struct usb_interface *intf,
else
go-hpi_ops = go7007_usb_onboard_hpi_ops;
go-hpi_context = usb;
-   usb_fill_int_urb(usb-intr_urb, usb-usbdev,
+   if (go-board_id == GO7007_BOARDID_SENSORAY_2250)
+   usb_fill_bulk_urb(usb-intr_urb, usb-usbdev,
+   usb_rcvbulkpipe(usb-usbdev, 4),
+   usb-intr_urb-transfer_buffer, 2*sizeof(u16),
+   go7007_usb_readinterrupt_complete, go);
+   else
+   usb_fill_int_urb(usb-intr_urb, usb-usbdev,
usb_rcvintpipe(usb-usbdev, 4),
usb-intr_urb-transfer_buffer, 2*sizeof(u16),
go7007_usb_readinterrupt_complete, go, 8);


--
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] s2255drv: atomic submit urb in completion handler

2011-04-01 Thread Pete Eberlein
An usb_submit_urb should be atomic in a completion handler. This fixes
BUG: scheduling while atomic messages.

Signed-off-by: Pete Eberlein p...@sensoray.com

diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index f5a46c4..85c3158 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -2406,7 +2406,7 @@ static void read_pipe_completion(struct urb *purb)
  read_pipe_completion, pipe_info);
 
if (pipe_info-state != 0) {
-   if (usb_submit_urb(pipe_info-stream_urb, GFP_KERNEL)) {
+   if (usb_submit_urb(pipe_info-stream_urb, GFP_ATOMIC)) {
dev_err(dev-udev-dev, error submitting urb\n);
}
} else {


--
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: Volunteers needed: BKL removal: replace .ioctl by .unlocked_ioctl

2010-12-20 Thread Pete Eberlein
On Sat, 2010-12-18 at 12:31 +0100, Hans Verkuil wrote:
 Hi all,
 
 Now that the BKL patch series has been merged in 2.6.37 it is time to work
 on replacing .ioctl by .unlocked_ioctl in all v4l drivers.
 
 I've made an inventory of all drivers that still use .ioctl and I am looking
 for volunteers to tackle one or more drivers.
 
 I have CCed this email to the maintainers of the various drivers (if I know
 who it is) in the hope that we can get this conversion done as quickly as
 possible.
 
 If I have added your name to a driver, then please confirm if you are able to
 work on it or not. If you can't work on it, but you know someone else, then
 let me know as well.

 s2255drv (Pete Eberlein)

I'll work on this one.

 Staging driver list:
 
 go7007 (Pete Eberlein)

And this one.

Regards,
Pete Eberlein

--
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 03/16] go7007: Add MODULE_DEVICE_TABLE to the go7007 I2C modules

2010-10-07 Thread Pete Eberlein
Acked-by: Pete Eberlein p...@sensoray.com

On Fri, 2010-09-24 at 16:14 +0200, Laurent Pinchart wrote:
 The device table is required to load modules based on modaliases.
 
 Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  drivers/staging/go7007/wis-ov7640.c |1 +
  drivers/staging/go7007/wis-saa7113.c|1 +
  drivers/staging/go7007/wis-saa7115.c|1 +
  drivers/staging/go7007/wis-sony-tuner.c |1 +
  drivers/staging/go7007/wis-tw2804.c |1 +
  drivers/staging/go7007/wis-tw9903.c |1 +
  drivers/staging/go7007/wis-uda1342.c|1 +
  7 files changed, 7 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/staging/go7007/wis-ov7640.c 
 b/drivers/staging/go7007/wis-ov7640.c
 index 4f0cbdd..6bc9470 100644
 --- a/drivers/staging/go7007/wis-ov7640.c
 +++ b/drivers/staging/go7007/wis-ov7640.c
 @@ -81,6 +81,7 @@ static const struct i2c_device_id wis_ov7640_id[] = {
   { wis_ov7640, 0 },
   { }
  };
 +MODULE_DEVICE_TABLE(i2c, wis_ov7640_id);
  
  static struct i2c_driver wis_ov7640_driver = {
   .driver = {
 diff --git a/drivers/staging/go7007/wis-saa7113.c 
 b/drivers/staging/go7007/wis-saa7113.c
 index 72f5c1f..05e0e10 100644
 --- a/drivers/staging/go7007/wis-saa7113.c
 +++ b/drivers/staging/go7007/wis-saa7113.c
 @@ -308,6 +308,7 @@ static const struct i2c_device_id wis_saa7113_id[] = {
   { wis_saa7113, 0 },
   { }
  };
 +MODULE_DEVICE_TABLE(i2c, wis_saa7113_id);
  
  static struct i2c_driver wis_saa7113_driver = {
   .driver = {
 diff --git a/drivers/staging/go7007/wis-saa7115.c 
 b/drivers/staging/go7007/wis-saa7115.c
 index cd950b6..46cff59 100644
 --- a/drivers/staging/go7007/wis-saa7115.c
 +++ b/drivers/staging/go7007/wis-saa7115.c
 @@ -441,6 +441,7 @@ static const struct i2c_device_id wis_saa7115_id[] = {
   { wis_saa7115, 0 },
   { }
  };
 +MODULE_DEVICE_TABLE(i2c, wis_saa7115_id);
  
  static struct i2c_driver wis_saa7115_driver = {
   .driver = {
 diff --git a/drivers/staging/go7007/wis-sony-tuner.c 
 b/drivers/staging/go7007/wis-sony-tuner.c
 index 981c9b3..8f1b7d4 100644
 --- a/drivers/staging/go7007/wis-sony-tuner.c
 +++ b/drivers/staging/go7007/wis-sony-tuner.c
 @@ -692,6 +692,7 @@ static const struct i2c_device_id wis_sony_tuner_id[] = {
   { wis_sony_tuner, 0 },
   { }
  };
 +MODULE_DEVICE_TABLE(i2c, wis_sony_tuner_id);
  
  static struct i2c_driver wis_sony_tuner_driver = {
   .driver = {
 diff --git a/drivers/staging/go7007/wis-tw2804.c 
 b/drivers/staging/go7007/wis-tw2804.c
 index ee28a99..5b218c5 100644
 --- a/drivers/staging/go7007/wis-tw2804.c
 +++ b/drivers/staging/go7007/wis-tw2804.c
 @@ -331,6 +331,7 @@ static const struct i2c_device_id wis_tw2804_id[] = {
   { wis_tw2804, 0 },
   { }
  };
 +MODULE_DEVICE_TABLE(i2c, wis_tw2804_id);
  
  static struct i2c_driver wis_tw2804_driver = {
   .driver = {
 diff --git a/drivers/staging/go7007/wis-tw9903.c 
 b/drivers/staging/go7007/wis-tw9903.c
 index 80d4726..9230f4a 100644
 --- a/drivers/staging/go7007/wis-tw9903.c
 +++ b/drivers/staging/go7007/wis-tw9903.c
 @@ -313,6 +313,7 @@ static const struct i2c_device_id wis_tw9903_id[] = {
   { wis_tw9903, 0 },
   { }
  };
 +MODULE_DEVICE_TABLE(i2c, wis_tw9903_id);
  
  static struct i2c_driver wis_tw9903_driver = {
   .driver = {
 diff --git a/drivers/staging/go7007/wis-uda1342.c 
 b/drivers/staging/go7007/wis-uda1342.c
 index 5c4eb49..0127be2 100644
 --- a/drivers/staging/go7007/wis-uda1342.c
 +++ b/drivers/staging/go7007/wis-uda1342.c
 @@ -86,6 +86,7 @@ static const struct i2c_device_id wis_uda1342_id[] = {
   { wis_uda1342, 0 },
   { }
  };
 +MODULE_DEVICE_TABLE(i2c, wis_uda1342_id);
  
  static struct i2c_driver wis_uda1342_driver = {
   .driver = {


--
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 05/16] go7007: Don't use module names to load I2C modules

2010-10-07 Thread Pete Eberlein
Acked-by: Pete Eberlein p...@sensoray.com

On Fri, 2010-09-24 at 16:14 +0200, Laurent Pinchart wrote:
 With the v4l2_i2c_new_subdev* functions now supporting loading modules
 based on modaliases, replace the hardcoded module name passed to those
 functions by NULL.
 
 All corresponding I2C modules have been checked, and all of them include
 a module aliases table with names corresponding to what the go7007
 driver uses.
 
 Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  drivers/staging/go7007/go7007-driver.c |   43 ++-
  1 files changed, 3 insertions(+), 40 deletions(-)
 
 diff --git a/drivers/staging/go7007/go7007-driver.c 
 b/drivers/staging/go7007/go7007-driver.c
 index 372a7c6..0a1d925 100644
 --- a/drivers/staging/go7007/go7007-driver.c
 +++ b/drivers/staging/go7007/go7007-driver.c
 @@ -194,51 +194,15 @@ int go7007_reset_encoder(struct go7007 *go)
   * Attempt to instantiate an I2C client by ID, probably loading a module.
   */
  static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
 -int id, int addr)
 +int addr)
  {
   struct go7007 *go = i2c_get_adapdata(adapter);
   struct v4l2_device *v4l2_dev = go-v4l2_dev;
 - char *modname;
  
 - switch (id) {
 - case I2C_DRIVERID_WIS_SAA7115:
 - modname = wis-saa7115;
 - break;
 - case I2C_DRIVERID_WIS_SAA7113:
 - modname = wis-saa7113;
 - break;
 - case I2C_DRIVERID_WIS_UDA1342:
 - modname = wis-uda1342;
 - break;
 - case I2C_DRIVERID_WIS_SONY_TUNER:
 - modname = wis-sony-tuner;
 - break;
 - case I2C_DRIVERID_WIS_TW9903:
 - modname = wis-tw9903;
 - break;
 - case I2C_DRIVERID_WIS_TW2804:
 - modname = wis-tw2804;
 - break;
 - case I2C_DRIVERID_WIS_OV7640:
 - modname = wis-ov7640;
 - break;
 - case I2C_DRIVERID_S2250:
 - modname = s2250;
 - break;
 - default:
 - modname = NULL;
 - break;
 - }
 -
 - if (v4l2_i2c_new_subdev(v4l2_dev, adapter, modname, type, addr, NULL))
 + if (v4l2_i2c_new_subdev(v4l2_dev, adapter, NULL, type, addr, NULL))
   return 0;
  
 - if (modname != NULL)
 - printk(KERN_INFO
 - go7007: probing for module %s failed\n, modname);
 - else
 - printk(KERN_INFO
 - go7007: sensor %u seems to be unsupported!\n, id);
 + printk(KERN_INFO go7007: probing for module i2c:%s failed\n, type);
   return -1;
  }
  
 @@ -277,7 +241,6 @@ int go7007_register_encoder(struct go7007 *go)
   for (i = 0; i  go-board_info-num_i2c_devs; ++i)
   init_i2c_module(go-i2c_adapter,
   go-board_info-i2c_devs[i].type,
 - go-board_info-i2c_devs[i].id,
   go-board_info-i2c_devs[i].addr);
   if (go-board_id == GO7007_BOARDID_ADLINK_MPG24)
   i2c_clients_command(go-i2c_adapter,


--
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 04/16] go7007: Fix the TW2804 I2C type name

2010-10-07 Thread Pete Eberlein
Acked-by: Pete Eberlein p...@sensoray.com

On Fri, 2010-09-24 at 16:14 +0200, Laurent Pinchart wrote:
 The TW2804 I2C sub-device type name was incorrectly set to wis_twTW2804
 for the adlink mpg24 board. Rename it to wis_tw2804.
 
 Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  drivers/staging/go7007/go7007-usb.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/staging/go7007/go7007-usb.c 
 b/drivers/staging/go7007/go7007-usb.c
 index 20ed930..bea9f4d 100644
 --- a/drivers/staging/go7007/go7007-usb.c
 +++ b/drivers/staging/go7007/go7007-usb.c
 @@ -394,7 +394,7 @@ static struct go7007_usb_board board_adlink_mpg24 = {
   .num_i2c_devs= 1,
   .i2c_devs= {
   {
 - .type   = wis_twTW2804,
 + .type   = wis_tw2804,
   .id = I2C_DRIVERID_WIS_TW2804,
   .addr   = 0x00, /* yes, really */
   },


--
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] go7007: MJPEG buffer overflow

2010-09-23 Thread Pete Eberlein
The go7007 driver has a potential buffer overflow and pointer corruption
bug which causes a crash while capturing MJPEG. The motion detection
(MODET) active_map array can be overflowed by JPEG frame data that
emulates a MODET start code. The active_map overflow overwrites the
active_buf pointer, causing a crash.

The JPEG data that emulated MODET start code was being removed from the
output, resulting in garbled JPEG frames. Therefore ignore MODET start
codes when MODET is not enabled. 

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff --git a/drivers/staging/go7007/go7007-driver.c 
b/drivers/staging/go7007/go7007-driver.c
index 372a7c6..34d21e2 100644
--- a/drivers/staging/go7007/go7007-driver.c
+++ b/drivers/staging/go7007/go7007-driver.c
@@ -393,7 +393,8 @@ static void write_bitmap_word(struct go7007 *go)
for (i = 0; i  16; ++i) {
y = (((go-parse_length - 1)  3) + i) / (go-width  4);
x = (((go-parse_length - 1)  3) + i) % (go-width  4);
-   go-active_map[stride * y + (x  3)] |=
+   if (stride * y + (x  3)  sizeof(go-active_map))
+   go-active_map[stride * y + (x  3)] |=
(go-modet_word  1)  (x  0x7);
go-modet_word = 1;
}
@@ -485,6 +486,15 @@ void go7007_parse_video_stream(struct go7007 *go, u8 *buf, 
int length)
}
break;
case STATE_00_00_01:
+   if (buf[i] == 0xF8  go-modet_enable == 0) {
+   /* MODET start code, but MODET not enabled */
+   store_byte(go-active_buf, 0x00);
+   store_byte(go-active_buf, 0x00);
+   store_byte(go-active_buf, 0x01);
+   store_byte(go-active_buf, 0xF8);
+   go-state = STATE_DATA;
+   break;
+   }
/* If this is the start of a new MPEG frame,
 * get a new buffer */
if ((go-format == GO7007_FORMAT_MPEG1 ||


--
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: [2.6.35] usb 2.0 em28xx kernel panic general protection fault: 0000 [#1] SMP RIP: 0010:[ffffffffa004fbc5] [ffffffffa004fbc5] em28xx_isoc_copy_vbi+0x62e/0x812 [em28xx]

2010-08-11 Thread Pete Eberlein
On Wed, 2010-08-11 at 09:25 +0200, Sander Eikelenboom wrote:
 Hello Devin,
 
 Yes it's completely reproducible for a change:
 
 ffmpeg -f video4linux -r 25 -s 720x576 -i /dev/video0 out.flv
 gave an error:

Use -f video4linux2.

The -f video4linux option uses the old video4linux1 API.  I have seen
similar strange behavior when I used that ffmpeg option with a v4l2
driver I am developing.  Also, ffmpeg does not use libv4l.


 serveerstertje:/mnt/software/software# ffmpeg -f video4linux -r 25 -s 720x576 
 -i  /dev/video0 out.flv
 FFmpeg version r11872+debian_0.svn20080206-18+lenny1, Copyright (c) 2000-2008 
 Fa brice Bellard, et al.
   configuration: --enable-gpl --enable-libfaad --enable-pp --enable-swscaler 
 --e nable-x11grab --prefix=/usr --enable-libgsm --enable-libtheora 
 --enable-libvorbi s --enable-pthreads --disable-strip --enable-libdc1394 
 --enable-shared --disable -static
   libavutil version: 49.6.0
   libavcodec version: 51.50.0
   libavformat version: 52.7.0
   libavdevice version: 52.0.0
   built on Jan 25 2010 18:27:39, gcc: 4.3.2
 Input #0, video4linux, from '/dev/video0':
   Duration: N/A, start: 1281511364.644674, bitrate: 165888 kb/s
 Stream #0.0: Video: rawvideo, yuyv422, 720x576 [PAR 0:1 DAR 0:1], 165888 
 kb/ s, 25.00 tb(r)
 File 'out.flv' already exists. Overwrite ? [y/N] y
 Output #0, flv, to 'out.flv':
 Stream #0.0: Video: flv, yuv420p, 720x576 [PAR 0:1 DAR 0:1], q=2-31, 200 
 kb/ s, 25.00 tb(c)
 Stream mapping:
   Stream #0.0 - #0.0
 Press [q] to stop encoding
 VIDIOCMCAPTURE: Invalid argument
 frame=1 fps=  0 q=3.0 Lsize=  38kB time=0.0 bitrate=7687.6kbits/s
 video:37kB audio:0kB global headers:0kB muxing overhead 0.530927%
 
 
 
 So I tried just:
 
 ffmpeg -i /dev/video0 out.flv
 
 That makes it oops allways and instantly.
 
 --
 
 Sander
 
 
 
 
 Wednesday, August 11, 2010, 4:33:28 AM, you wrote:
 
  On Tue, Aug 10, 2010 at 6:57 PM, Sander Eikelenboom
  li...@eikelenboom.it wrote:
  Hello Devin,
 
  It's a k-world, which used to work fine (altough with another program, but 
  I can't use that since it seems at least 2 other bugs prevent me from 
  using my VM's :-)
  It's this model  
  http://global.kworld-global.com/main/prod_in.aspx?mnuid=1248modid=6pcid=47ifid=17prodid=104
 
  Tried to grab with ffmpeg.
 
  Is it reproducible?  Or did it just happen once?  If you have a
  sequence to reproduce, can you provide the command line you used, etc?
 
  Devin
 
 
 
 


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


Re: [RFC/PATCH v2 06/10] media: Entities, pads and links enumeration

2010-07-22 Thread Pete Eberlein
On Thu, 2010-07-22 at 17:20 +0200, Laurent Pinchart wrote:
  Laurent Pinchart wrote:
  
  ...
  
   diff --git a/Documentation/media-framework.txt
   b/Documentation/media-framework.txt index 3acc62b..16c0177 100644
   --- a/Documentation/media-framework.txt
   +++ b/Documentation/media-framework.txt
   @@ -270,3 +270,137 @@ required, drivers don't need to provide a set_power
 
 [snip]
 
   +The media_user_pad, media_user_link and media_user_links structure are 
   defined
   +as
  
  I have a comment on naming. These are user space structures, sure, but
  do we want that fact to be visible in the names of the structures? I
  would just drop the user_ out and make the naming as good as possible in
  user space. That is much harder to change later than naming inside the
  kernel.
 
 I agree.
 
  That change causes a lot of clashes in naming since the equivalent
  kernel structure is there as well. Those could have _k postfix, for
  example, to differentiate them from user space names. I don't really
  have a good suggestion how they should be called.
 
 Maybe media_k_* ? I'm not very happy with that name either though.

What do you think about a single underscore prefix for the kernel
structures, used commonly to indicate that a declaration is limited?



--
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: Chicony Electronics 04f2:b1b4 webcam device unsupported (yet)

2010-07-16 Thread Pete Eberlein
On Fri, 2010-07-16 at 18:32 +0200, Michael Kromer wrote:
 Hi,
 
 I have bought myself a rather new Lenovo Thinkpad X100e, and there is no
 support for the webcam device in the current (2.6.34) kernel (yet).
 2.6.35 doesn't seem to have a driver for it either. Is there any
 possibility for one of you guys to take a look at it?

The descriptors look like a standard USB Video Class device.  Do you
have the uvcvideo module loaded?  Then have a look at your dmesg output
to see why it isn't working.



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


vivi videobuf bug with tvtime

2010-07-02 Thread Pete Eberlein
There's a problem with the tvtime application that affects recent v4l2
drivers.  The tvtime application works fine the first time you run it,
but the second time tvtime is run, the call to VIDIOC_REQBUFS fails with
EBUSY.  

The problem is that tvtime does a VIDIOC_STREAMOFF, then VIDIOC_QBUF a
few times before closing the fd.  This only affects v4l2 drivers that
store the 'struct videobuf_queue vb_vidq' in the dev struct.  It doesn't
affect older drivers that store that struct in the driver fh struct.
The videobuf_reqbufs call is returning from this statement:
videobuf-core.c: in videobuf_reqbufs()
if (!list_empty(q-stream)) {
dprintk(1, reqbufs: stream running\n);
retval = -EBUSY;
goto done;
}

Is tvtime abusing the API, or is this a videobuf buf?  My opinion is
that applications shouldn't be able to force the driver into an unusable
state.

Here's the debug kernel log starting at the streamoff:
[ 4862.871055] vivi: VIDIOC_STREAMOFF
[ 4862.871061] vivi-000: buffer_release
[ 4862.871063] vivi-000: free_buffer, state: 6
[ 4862.871065] vivi-000: free_buffer: freed
[ 4862.871066] vivi-000: buffer_release
[ 4862.871068] vivi-000: free_buffer, state: 5
[ 4862.871069] vivi-000: free_buffer: freed
[ 4862.871071] vivi-000: buffer_release
[ 4862.871073] vivi-000: free_buffer, state: 5
[ 4862.871074] vivi-000: free_buffer: freed
[ 4862.871076] vivi-000: buffer_release
[ 4862.871077] vivi-000: free_buffer, state: 6
[ 4862.871079] vivi-000: free_buffer: freed
[ 4862.871081] vivi-000: vivi_stop_generating
[ 4862.871087] vivi-000: thread: exit
[ 4862.871108] vivi: VIDIOC_QBUF
[ 4862.87] vbuf: qbuf: requesting next field
[ 4862.871113] vivi-000: buffer_prepare, field=4
[ 4862.871138] vbuf: qbuf: succeded
[ 4862.871140] vivi: VIDIOC_QBUF
[ 4862.871142] vbuf: qbuf: requesting next field
[ 4862.871144] vivi-000: buffer_prepare, field=4
[ 4862.871167] vbuf: qbuf: succeded
[ 4862.871169] vivi: VIDIOC_QBUF
[ 4862.871171] vbuf: qbuf: requesting next field
[ 4862.871173] vivi-000: buffer_prepare, field=4
[ 4862.871196] vbuf: qbuf: succeded
[ 4862.871198] vivi: VIDIOC_QBUF
[ 4862.871200] vbuf: qbuf: requesting next field
[ 4862.871202] vivi-000: buffer_prepare, field=4
[ 4862.871225] vbuf: qbuf: succeded
[ 4862.871498] vivi-000: vivi_stop_generating
[ 4862.871500] vivi-000: close called (dev=video0)
[ 4865.031222] vivi: VIDIOC_QUERYCAP
[ 4865.031232] vivi: VIDIOC_ENUMINPUT
[ 4865.031235] vivi: VIDIOC_ENUMINPUT
[ 4865.031238] vivi: VIDIOC_ENUMINPUT
[ 4865.031241] vivi: VIDIOC_ENUMINPUT
[ 4865.031244] vivi: VIDIOC_ENUMINPUT
[ 4865.031265] vivi: v4l1 ioctl 'v', dir=r-, #198 (0x800476c6)
[ 4865.031273] vivi: VIDIOC_S_INPUT
[ 4865.031298] vivi: VIDIOC_G_INPUT
[ 4865.031305] vivi: VIDIOC_ENUMINPUT
[ 4865.031312] vivi: VIDIOC_G_STD
[ 4865.031318] vivi: VIDIOC_S_STD
[ 4865.031324] vivi: VIDIOC_G_TUNER
[ 4865.031482] vivi: VIDIOC_S_FMT
[ 4865.031490] vivi: VIDIOC_TRY_FMT
[ 4865.031497] vivi: VIDIOC_REQBUFS
[ 4865.031504] vbuf: reqbufs: stream running
[ 4865.031519] vivi-000: vivi_stop_generating
[ 4865.031525] vivi-000: close called (dev=video0)


--
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] Staging: saa7134-go7007: replace dma_sync_single with dma_sync_single_for_cpu

2010-05-13 Thread Pete Eberlein
Thanks, Tomonori.

Does this need to get submitted to the linux-media tree as well, or will
this patch get pulled automatically from Linus' tree?

Thanks,
Pete Eberlein

On Thu, 2010-05-13 at 12:45 +0900, FUJITA Tomonori wrote:
 dma_sync_single() is deprecated and will be removed soon.
 
 No functional change since dma_sync_single is the wrapper of
 dma_sync_single_for_cpu.
 
 saa7134-go7007.c is commented out but anyway let's replace it.
 
 Signed-off-by: FUJITA Tomonori fujita.tomon...@lab.ntt.co.jp
 ---
  drivers/staging/go7007/saa7134-go7007.c |8 
  1 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/staging/go7007/saa7134-go7007.c 
 b/drivers/staging/go7007/saa7134-go7007.c
 index b25d7d2..0d36ce7 100644
 --- a/drivers/staging/go7007/saa7134-go7007.c
 +++ b/drivers/staging/go7007/saa7134-go7007.c
 @@ -242,13 +242,13 @@ static void saa7134_go7007_irq_ts_done(struct 
 saa7134_dev *dev,
   printk(KERN_DEBUG saa7134-go7007: irq: lost %ld\n,
   (status  16)  0x0f);
   if (status  0x10) {
 - dma_sync_single(dev-pci-dev,
 - saa-bottom_dma, PAGE_SIZE, DMA_FROM_DEVICE);
 + dma_sync_single_for_cpu(dev-pci-dev,
 + saa-bottom_dma, PAGE_SIZE, 
 DMA_FROM_DEVICE);
   go7007_parse_video_stream(go, saa-bottom, PAGE_SIZE);
   saa_writel(SAA7134_RS_BA2(5), cpu_to_le32(saa-bottom_dma));
   } else {
 - dma_sync_single(dev-pci-dev,
 - saa-top_dma, PAGE_SIZE, DMA_FROM_DEVICE);
 + dma_sync_single_for_cpu(dev-pci-dev,
 + saa-top_dma, PAGE_SIZE, 
 DMA_FROM_DEVICE);
   go7007_parse_video_stream(go, saa-top, PAGE_SIZE);
   saa_writel(SAA7134_RS_BA1(5), cpu_to_le32(saa-top_dma));
   }


--
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/5] sony-tuner: Subdev conversion from wis-sony-tuner

2010-02-12 Thread Pete Eberlein
On Fri, 2010-02-12 at 12:29 +0100, Hans Verkuil wrote:
 On Friday 12 February 2010 01:33:07 Pete Eberlein wrote:
  From: Pete Eberlein p...@sensoray.com
  
  This is a subdev conversion of the go7007 wis-sony-tuner i2c driver,
  and places it with the other tuner drivers.  This obsoletes the
  wis-sony-tuner driver in the go7007 staging directory.
 
 Thanks! Here is a quick review...

Thanks, please have a look at my questions below:


  +#include media/v4l2-i2c-drv.h
 
 The v4l2-i2c-drv.h is to be used only for drivers that also need to be 
 compiled
 for kernels  2.6.26. If I am not mistaken that is the case for this driver,
 right? I remember you mentioning that customers of yours use this on such old
 kernels. Just making sure.

My company, Sensoray, doesn't have any products that use this tuner.
This driver was orignally written by Micronas to support their go7007
chip in the Plextor TV402U models.  I don't have the datasheet or know
much about tuners anyway.  I used the v4l2-i2c-drv.h since it seems like
a good idea at the time.  What should I use instead?

  +static int sony_tuner_g_frequency(struct v4l2_subdev *sd,
  + struct v4l2_frequency *freq)
  +{
  +   struct sony_tuner *t = to_state(sd);
  +
  +   freq-frequency = t-freq;
 
 You need to check both the tuner and type field of struct v4l2_frequency here.

What should I check v4l2_frequency-tuner against?  The v4l2 docs say
that it should be the same as the struct v4l2_tuner index field, which
only the parent device driver knows.

  +static int sony_tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner 
  *vt)
  +{
  +   struct sony_tuner *t = to_state(sd);
  +
  +   memset(vt, 0, sizeof(*vt));
 
 No need to memset, that's already been done by the v4l core.

Ok.

 You should check the vt-index field here.

The parent device driver knows the index and checks it already.  However
this could be a problem if there are multiple tuner that use this subdev
driver.  Is there some function to tell a tuner subdev what its index
should be?

  +   strcpy(vt-name, Television);
 
 Please use strlcpy.

Ok.

  +   vt-type = V4L2_TUNER_ANALOG_TV;
  +   vt-rangelow = 0UL; /* does anything use these? */
  +   vt-rangehigh = 0xUL;
 
 If you know the minimum and maximum frequencies then you should set them
 here. Applications that scan for channel will typically use this.

I don't know the frequencies to use.  There are some numbers in the
struct sony_tunertype sony_tuners[], but I'm not sure what they mean.

 Regards,
 
   Hans

Thanks for your review.

Pete


--
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/5 v2] sony-tuner: Subdev conversion from wis-sony-tuner

2010-02-12 Thread Pete Eberlein
On Fri, 2010-02-12 at 22:03 +0100, Hans Verkuil wrote:
+#include media/v4l2-i2c-drv.h
   
   The v4l2-i2c-drv.h is to be used only for drivers that also need to be 
   compiled
   for kernels  2.6.26. If I am not mistaken that is the case for this 
   driver,
   right? I remember you mentioning that customers of yours use this on such 
   old
   kernels. Just making sure.
  
  My company, Sensoray, doesn't have any products that use this tuner.
  This driver was orignally written by Micronas to support their go7007
  chip in the Plextor TV402U models.  I don't have the datasheet or know
  much about tuners anyway.  I used the v4l2-i2c-drv.h since it seems like
  a good idea at the time.  What should I use instead?
 
 We way i2c devices are handled changed massively in kernel 2.6.26. In order to
 stay backwards compatible with older kernels the v4l2-i2c-drv.h header was
 introduced. However, this is a bit of a hack and any i2c driver that does not
 need it shouldn't use it.
 
 So only if an i2c driver is *never* used by parent drivers that have to 
 support
 kernels  2.6.26, then can it drop the v4l2-i2c-drv.h. An example of such an
 i2c driver is tvp514x.c.
 
 Eventually support for such old kernels will be dropped and the v4l2-i2c-drv.h
 header will disappear altogether, but that's not going to happen anytime soon.
 
 What this means for go7007 is that you have to decide whether you want this
 go7007 driver to work only for kernels = 2.6.26, or whether it should also
 work for older kernels. My understanding is that Sensoray wants to be able to
 compile go7007 for older kernels. In that case the use of v4l2-i2c-drv.h is
 correct. Note that this is not about whether any of *Sensoray's* products use
 a particular i2c device, but whether the *go7007* driver uses it.
 
 I hope this clarifies this.

Yes it does, thank you.  We do want to allow our customers to use the
go7007 driver with our products on older kernels, so I would like to
keep the v4l2-i2c-drv.h for now.  I've addressed your other comments in
the revised patch:


From: Pete Eberlein p...@sensoray.com

This is a subdev conversion of the go7007 wis-sony-tuner i2c driver,
and places it with the other tuner drivers.  This obsoletes the
wis-sony-tuner driver in the go7007 staging directory.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r 27ee8e515b18 -r 1cf1bf4e616f 
linux/Documentation/video4linux/CARDLIST.tuner
--- a/linux/Documentation/video4linux/CARDLIST.tunerWed Feb 10 11:25:59 
2010 -0800
+++ b/linux/Documentation/video4linux/CARDLIST.tunerFri Feb 12 14:27:39 
2010 -0800
@@ -81,3 +81,6 @@
 tuner=81 - Partsnic (Daewoo) PTI-5NF05
 tuner=82 - Philips CU1216L
 tuner=83 - NXP TDA18271
+tuner=84 - Sony PAL+SECAM (BTF-PG472Z)
+tuner=85 - Sony NTSC_JP (BTF-PK467Z)
+tuner=86 - Sony NTSC (BTF-PB463Z)
diff -r 27ee8e515b18 -r 1cf1bf4e616f linux/drivers/media/common/tuners/Kconfig
--- a/linux/drivers/media/common/tuners/Kconfig Wed Feb 10 11:25:59 2010 -0800
+++ b/linux/drivers/media/common/tuners/Kconfig Fri Feb 12 14:27:39 2010 -0800
@@ -179,4 +179,12 @@
help
  A driver for the silicon tuner MAX2165 from Maxim.
 
+config MEDIA_TUNER_SONY
+   tristate Sony TV tuner
+   depends on VIDEO_MEDIA  I2C
+   default m if MEDIA_TUNER_CUSTOMISE
+   help
+ A driver for the Sony tuners BTF-PG472Z, BTF-PK467Z, BTF-PB463Z.
+
+
 endif # MEDIA_TUNER_CUSTOMISE
diff -r 27ee8e515b18 -r 1cf1bf4e616f linux/drivers/media/common/tuners/Makefile
--- a/linux/drivers/media/common/tuners/MakefileWed Feb 10 11:25:59 
2010 -0800
+++ b/linux/drivers/media/common/tuners/MakefileFri Feb 12 14:27:39 
2010 -0800
@@ -24,6 +24,7 @@
 obj-$(CONFIG_MEDIA_TUNER_MXL5007T) += mxl5007t.o
 obj-$(CONFIG_MEDIA_TUNER_MC44S803) += mc44s803.o
 obj-$(CONFIG_MEDIA_TUNER_MAX2165) += max2165.o
+obj-$(CONFIG_MEDIA_TUNER_SONY) += sony-tuner.o
 
 EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
 EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
diff -r 27ee8e515b18 -r 1cf1bf4e616f 
linux/drivers/media/common/tuners/sony-tuner.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/linux/drivers/media/common/tuners/sony-tuner.cFri Feb 12 14:27:39 
2010 -0800
@@ -0,0 +1,677 @@
+/*
+ * Copyright (C) 2005-2006 Micronas USA Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/module.h
+#include

[PATCH 1/5] go7007: driver id cleanup

2010-02-11 Thread Pete Eberlein
From: Pete Eberlein p...@sensoray.com

Removed the I2C_DRIVERID_WIS usage from the device configurations, since
the type parameter is all that is needed to probe the chip driver module.
Eventually wis-i2c.h will be removed.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r 690055993011 -r 2d2a250ca33b 
linux/drivers/staging/go7007/go7007-driver.c
--- a/linux/drivers/staging/go7007/go7007-driver.c  Sun Feb 07 22:26:10 
2010 -0200
+++ b/linux/drivers/staging/go7007/go7007-driver.c  Wed Feb 10 11:25:59 
2010 -0800
@@ -35,7 +35,6 @@
 #include media/v4l2-common.h
 
 #include go7007-priv.h
-#include wis-i2c.h
 
 /*
  * Wait for an interrupt to be delivered from the GO7007SB and return
@@ -191,51 +190,20 @@
  * Attempt to instantiate an I2C client by ID, probably loading a module.
  */
 static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
-  int id, int addr)
+  int addr)
 {
struct go7007 *go = i2c_get_adapdata(adapter);
struct v4l2_device *v4l2_dev = go-v4l2_dev;
-   char *modname;
 
-   switch (id) {
-   case I2C_DRIVERID_WIS_SAA7115:
-   modname = wis-saa7115;
-   break;
-   case I2C_DRIVERID_WIS_SAA7113:
-   modname = wis-saa7113;
-   break;
-   case I2C_DRIVERID_WIS_UDA1342:
-   modname = wis-uda1342;
-   break;
-   case I2C_DRIVERID_WIS_SONY_TUNER:
-   modname = wis-sony-tuner;
-   break;
-   case I2C_DRIVERID_WIS_TW9903:
-   modname = wis-tw9903;
-   break;
-   case I2C_DRIVERID_WIS_TW2804:
-   modname = wis-tw2804;
-   break;
-   case I2C_DRIVERID_WIS_OV7640:
-   modname = wis-ov7640;
-   break;
-   case I2C_DRIVERID_S2250:
-   modname = s2250;
-   break;
-   default:
-   modname = NULL;
-   break;
-   }
-
-   if (v4l2_i2c_new_subdev(v4l2_dev, adapter, modname, type, addr, NULL))
+   if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, type, addr, NULL))
return 0;
 
-   if (modname != NULL)
+   if (type != NULL)
printk(KERN_INFO
-   go7007: probing for module %s failed\n, modname);
+   go7007: probing for module %s failed\n, type);
else
printk(KERN_INFO
-   go7007: sensor %u seems to be unsupported!\n, id);
+   go7007: sensor seems to be unsupported!\n);
return -1;
 }
 
@@ -274,11 +242,16 @@
for (i = 0; i  go-board_info-num_i2c_devs; ++i)
init_i2c_module(go-i2c_adapter,
go-board_info-i2c_devs[i].type,
-   go-board_info-i2c_devs[i].id,
go-board_info-i2c_devs[i].addr);
-   if (go-board_id == GO7007_BOARDID_ADLINK_MPG24)
-   i2c_clients_command(go-i2c_adapter,
-   DECODER_SET_CHANNEL, go-channel_number);
+   if (go-board_id == GO7007_BOARDID_ADLINK_MPG24) {
+   int channel = go-channel_number;
+   struct v4l2_priv_tun_config config = {
+   .tuner  = go-tuner_type,
+   .priv   = channel,
+   };
+   v4l2_device_call_all(go-v4l2_dev, 0, tuner, s_config,
+   config);
+   }
}
if (go-board_info-flags  GO7007_BOARD_HAS_AUDIO) {
go-audio_enabled = 1;
diff -r 690055993011 -r 2d2a250ca33b linux/drivers/staging/go7007/go7007-priv.h
--- a/linux/drivers/staging/go7007/go7007-priv.hSun Feb 07 22:26:10 
2010 -0200
+++ b/linux/drivers/staging/go7007/go7007-priv.hWed Feb 10 11:25:59 
2010 -0800
@@ -90,7 +90,6 @@
int num_i2c_devs;
struct {
const char *type;
-   int id;
int addr;
} i2c_devs[4];
int num_inputs;
@@ -288,3 +287,14 @@
 /* snd-go7007.c */
 int go7007_snd_init(struct go7007 *go);
 int go7007_snd_remove(struct go7007 *go);
+
+/* Flag to indicate that the client needs to be accessed with SCCB semantics */
+/* We re-use the I2C_M_TEN value so the flag passes through the masks in the
+ * core I2C code.  Major kludge, but the I2C layer ain't exactly flexible. */
+#defineI2C_CLIENT_SCCB 0x10
+
+/* Sony tuner types */
+
+#define TUNER_SONY_BTF_PG472Z  200
+#define TUNER_SONY_BTF_PK467Z  201
+#define TUNER_SONY_BTF_PB463Z  202
diff -r 690055993011 -r 2d2a250ca33b linux/drivers/staging/go7007/go7007-usb.c
--- a/linux/drivers/staging/go7007/go7007-usb.c Sun Feb 07 22:26:10 2010 -0200
+++ b/linux/drivers/staging/go7007/go7007-usb.c

[PATCH 0/5] go7007 staging changes

2010-02-11 Thread Pete Eberlein
Hello.

This series moves most of the subdevice drivers used by the go7007
driver out of the staging directory.  The sony-tuner, ov7640, tw2804 and
tw9903 are converted to use the v4l2_subdev API, and the wis- versions
are made obsolete.  The wis-saa7113 and wis-saa7115 drivers are
obsolete, and don't add anything not already in the existing saa7113 and
saa7115 video decoder drivers.  The audio chip driver wis-uda1342
doesn't belong in 

If these changes are accepted, it should be determined if the go7007
driver can be moved out of staging, or what work remains to be done.

Pete Eberlein

[PATCH 1/5] go7007: driver id cleanup
[PATCH 2/5] sony-tuner: Subdev conversion from wis-sony-tuner
[PATCH 3/5] tw2804: video decoder subdev conversion
[PATCH 4/5] tw9903: video decoder subdev conversion
[PATCH 5/5] ov7640: sensor driver subdev conversion

 b/linux/drivers/media/common/tuners/sony-tuner.c |  695 +++
 b/linux/drivers/media/video/ov7640.c |  141 
 b/linux/drivers/media/video/tw2804.c |  398 +
 b/linux/drivers/media/video/tw9903.c |  370 
 linux/Documentation/video4linux/CARDLIST.tuner   |3 
 linux/drivers/media/common/tuners/Kconfig|8 
 linux/drivers/media/common/tuners/Makefile   |1 
 linux/drivers/media/common/tuners/tuner-types.c  |   12 
 linux/drivers/media/video/Kconfig|   19 
 linux/drivers/media/video/Makefile   |3 
 linux/drivers/staging/go7007/go7007-driver.c |   55 -
 linux/drivers/staging/go7007/go7007-priv.h   |   18 
 linux/drivers/staging/go7007/go7007-usb.c|   30 
 linux/drivers/staging/go7007/wis-i2c.h   |   11 
 linux/drivers/staging/go7007/wis-ov7640.c|2 
 linux/drivers/staging/go7007/wis-sony-tuner.c|2 
 linux/include/media/tuner.h  |4 
 linux/include/media/v4l2-chip-ident.h|1 
 18 files changed, 1692 insertions(+), 81 deletions(-)



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


[PATCH 3/5] tw2804: video decoder subdev conversion

2010-02-11 Thread Pete Eberlein
From: Pete Eberlein p...@sensoray.com

This is a subdev conversion of wis-tw2804 video decoder from the
staging go7007 directory.  This obsoletes the wis-tw2804 driver.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/Kconfig
--- a/linux/drivers/media/video/Kconfig Wed Feb 10 15:06:05 2010 -0800
+++ b/linux/drivers/media/video/Kconfig Thu Feb 11 14:34:39 2010 -0800
@@ -368,6 +368,12 @@
  To compile this driver as a module, choose M here: the
  module will be called saa7191.
 
+config VIDEO_TW2804
+   tristate Techwell 2804 video decoder
+   depends on VIDEO_V4L2  I2C
+   ---help---
+ Support for the Techwell 2804 video decoder.
+
 config VIDEO_TVP514X
tristate Texas Instruments TVP514x video decoder
depends on VIDEO_V4L2  I2C
diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/Makefile
--- a/linux/drivers/media/video/MakefileWed Feb 10 15:06:05 2010 -0800
+++ b/linux/drivers/media/video/MakefileThu Feb 11 14:34:39 2010 -0800
@@ -71,6 +71,7 @@
 obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o
 obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
 obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o
+obj-$(CONFIG_VIDEO_TW2804) += tw2804.o
 
 obj-$(CONFIG_SOC_CAMERA_MT9M001)   += mt9m001.o
 obj-$(CONFIG_SOC_CAMERA_MT9M111)   += mt9m111.o
diff -r f7edcbfeb63c -r 024987c00f06 linux/drivers/media/video/tw2804.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/linux/drivers/media/video/tw2804.cThu Feb 11 14:34:39 2010 -0800
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 2005-2006 Micronas USA Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/i2c.h
+#include linux/videodev2.h
+#include linux/ioctl.h
+#include media/v4l2-device.h
+#include media/v4l2-i2c-drv.h
+
+MODULE_DESCRIPTION(TW2804 I2C subdev driver);
+MODULE_LICENSE(GPL v2);
+
+struct tw2804 {
+   struct v4l2_subdev sd;
+   int channel;
+   v4l2_std_id norm;
+   int brightness;
+   int contrast;
+   int saturation;
+   int hue;
+};
+
+static inline struct tw2804 *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct tw2804, sd);
+}
+
+static u8 global_registers[] =
+{
+   0x39, 0x00,
+   0x3a, 0xff,
+   0x3b, 0x84,
+   0x3c, 0x80,
+   0x3d, 0x80,
+   0x3e, 0x82,
+   0x3f, 0x82,
+   0xff, 0xff, /* Terminator (reg 0xff does not exist) */
+};
+
+static u8 channel_registers[] =
+{
+   0x01, 0xc4,
+   0x02, 0xa5,
+   0x03, 0x20,
+   0x04, 0xd0,
+   0x05, 0x20,
+   0x06, 0xd0,
+   0x07, 0x88,
+   0x08, 0x20,
+   0x09, 0x07,
+   0x0a, 0xf0,
+   0x0b, 0x07,
+   0x0c, 0xf0,
+   0x0d, 0x40,
+   0x0e, 0xd2,
+   0x0f, 0x80,
+   0x10, 0x80,
+   0x11, 0x80,
+   0x12, 0x80,
+   0x13, 0x1f,
+   0x14, 0x00,
+   0x15, 0x00,
+   0x16, 0x00,
+   0x17, 0x00,
+   0x18, 0xff,
+   0x19, 0xff,
+   0x1a, 0xff,
+   0x1b, 0xff,
+   0x1c, 0xff,
+   0x1d, 0xff,
+   0x1e, 0xff,
+   0x1f, 0xff,
+   0x20, 0x07,
+   0x21, 0x07,
+   0x22, 0x00,
+   0x23, 0x91,
+   0x24, 0x51,
+   0x25, 0x03,
+   0x26, 0x00,
+   0x27, 0x00,
+   0x28, 0x00,
+   0x29, 0x00,
+   0x2a, 0x00,
+   0x2b, 0x00,
+   0x2c, 0x00,
+   0x2d, 0x00,
+   0x2e, 0x00,
+   0x2f, 0x00,
+   0x30, 0x00,
+   0x31, 0x00,
+   0x32, 0x00,
+   0x33, 0x00,
+   0x34, 0x00,
+   0x35, 0x00,
+   0x36, 0x00,
+   0x37, 0x00,
+   0xff, 0xff, /* Terminator (reg 0xff does not exist) */
+};
+
+static int write_reg(struct v4l2_subdev *sd, u8 reg, u8 value, int channel)
+{
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+   return i2c_smbus_write_byte_data(client, reg | (channel  6), value);
+}
+
+static int write_regs(struct v4l2_subdev *sd, u8 *regs, int channel)
+{
+   int i;
+
+   for (i = 0; regs[i] != 0xff; i += 2)
+   if (write_reg(sd, regs[i], regs[i + 1], channel)  0)
+   return -1;
+   return 0;
+}
+
+static int tw2804_s_config(struct v4l2_subdev *sd,
+  const struct v4l2_priv_tun_config *config)
+{
+   struct tw2804 *dec

[PATCH 2/5] sony-tuner: Subdev conversion from wis-sony-tuner

2010-02-11 Thread Pete Eberlein
From: Pete Eberlein p...@sensoray.com

This is a subdev conversion of the go7007 wis-sony-tuner i2c driver,
and places it with the other tuner drivers.  This obsoletes the
wis-sony-tuner driver in the go7007 staging directory.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r 2d2a250ca33b -r 628119533574 
linux/Documentation/video4linux/CARDLIST.tuner
--- a/linux/Documentation/video4linux/CARDLIST.tunerWed Feb 10 11:25:59 
2010 -0800
+++ b/linux/Documentation/video4linux/CARDLIST.tunerThu Feb 11 15:21:11 
2010 -0800
@@ -81,3 +81,6 @@
 tuner=81 - Partsnic (Daewoo) PTI-5NF05
 tuner=82 - Philips CU1216L
 tuner=83 - NXP TDA18271
+tuner=84 - Sony PAL+SECAM (BTF-PG472Z)
+tuner=85 - Sony NTSC_JP (BTF-PK467Z)
+tuner=86 - Sony NTSC (BTF-PB463Z)
diff -r 2d2a250ca33b -r 628119533574 linux/drivers/media/common/tuners/Kconfig
--- a/linux/drivers/media/common/tuners/Kconfig Wed Feb 10 11:25:59 2010 -0800
+++ b/linux/drivers/media/common/tuners/Kconfig Thu Feb 11 15:21:11 2010 -0800
@@ -179,4 +179,12 @@
help
  A driver for the silicon tuner MAX2165 from Maxim.
 
+config MEDIA_TUNER_SONY
+   tristate Sony TV tuner
+   depends on VIDEO_MEDIA  I2C
+   default m if MEDIA_TUNER_CUSTOMISE
+   help
+ A driver for the Sony tuners BTF-PG472Z, BTF-PK467Z, BTF-PB463Z.
+
+
 endif # MEDIA_TUNER_CUSTOMISE
diff -r 2d2a250ca33b -r 628119533574 linux/drivers/media/common/tuners/Makefile
--- a/linux/drivers/media/common/tuners/MakefileWed Feb 10 11:25:59 
2010 -0800
+++ b/linux/drivers/media/common/tuners/MakefileThu Feb 11 15:21:11 
2010 -0800
@@ -24,6 +24,7 @@
 obj-$(CONFIG_MEDIA_TUNER_MXL5007T) += mxl5007t.o
 obj-$(CONFIG_MEDIA_TUNER_MC44S803) += mc44s803.o
 obj-$(CONFIG_MEDIA_TUNER_MAX2165) += max2165.o
+obj-$(CONFIG_MEDIA_TUNER_SONY) += sony-tuner.o
 
 EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
 EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
diff -r 2d2a250ca33b -r 628119533574 
linux/drivers/media/common/tuners/sony-tuner.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/linux/drivers/media/common/tuners/sony-tuner.cThu Feb 11 15:21:11 
2010 -0800
@@ -0,0 +1,695 @@
+/*
+ * Copyright (C) 2005-2006 Micronas USA Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/i2c.h
+#include linux/videodev2.h
+#include media/tuner.h
+#include media/v4l2-common.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-device.h
+#include media/v4l2-i2c-drv.h
+
+MODULE_DESCRIPTION(Sony TV Tuner driver);
+MODULE_LICENSE(GPL v2);
+
+/* #define MPX_DEBUG */
+
+/* AS(IF/MPX) pin:  LOW  HIGH/OPEN
+ * IF/MPX address:   0x42/0x40   0x43/0x44
+ */
+#define IF_I2C_ADDR0x43
+#define MPX_I2C_ADDR   0x44
+
+static v4l2_std_id force_band;
+static char force_band_str[] = -;
+module_param_string(force_band, force_band_str, sizeof(force_band_str), 0644);
+static int force_mpx_mode = -1;
+module_param(force_mpx_mode, int, 0644);
+
+/* Store tuner info in the same format as tuner.c, so maybe we can put the
+ * Sony tuner support in there. */
+struct sony_tunertype {
+   char *name;
+   unsigned char Vendor; /* unused here */
+   unsigned char Type; /* unused here */
+
+   unsigned short thresh1; /*  band switch VHF_LO = VHF_HI */
+   unsigned short thresh2; /*  band switch VHF_HI = UHF */
+   unsigned char VHF_L;
+   unsigned char VHF_H;
+   unsigned char UHF;
+   unsigned char config;
+   unsigned short IFPCoff;
+};
+
+/* This array is indexed by (tuner_type - TUNER_SONY_BTF_PG472Z) */
+static struct sony_tunertype sony_tuners[] = {
+   { Sony PAL+SECAM (BTF-PG472Z), 0, 0,
+ 16*144.25, 16*427.25, 0x01, 0x02, 0x04, 0xc6, 623},
+   { Sony NTSC_JP (BTF-PK467Z), 0, 0,
+ 16*220.25, 16*467.25, 0x01, 0x02, 0x04, 0xc6, 940},
+   { Sony NTSC (BTF-PB463Z), 0, 0,
+ 16*130.25, 16*364.25, 0x01, 0x02, 0x04, 0xc6, 732},
+};
+
+struct sony_tuner {
+   struct v4l2_subdev sd;
+   int type;
+   v4l2_std_id std;
+   unsigned int freq;
+   int mpxmode;
+   u32 audmode;
+};
+
+static inline struct sony_tuner *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct sony_tuner, sd);
+}
+
+/* Basically the same as default_set_tv_freq() in tuner.c */
+static int set_freq(struct i2c_client *client

Re: go7007 driver -- which program you use for capture

2010-01-14 Thread Pete Eberlein
On Thu, 2010-01-14 at 15:03 -0500, TJ wrote:

 Pete, Question: I was looking through the code and noticed that you turned 
 s2250
 driver into v4l2_subdev and go7007 driver initializes it as such and passes it
 calls via call_all (v4l2_device_call_until_err). How does that affect other
 drivers? Does that mean they all need to re-written as v4l2_subdev?

That is correct.  The other drivers do not work until they are all
converted to the subdev interface.  I'm working on the other drivers
now.  I've finished ov7640 and have started on saa7113.

Once the subdev driver conversions are completed, we should be able to
move the go7007 driver out of staging.

Pete

--
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] s2250: Fix write_reg i2c address

2010-01-13 Thread Pete Eberlein
The kernel i2c model uses right-aligned 7-bit i2c addresses, but the
2250 firmware uses an 8-bit address in the usb vendor request.  A
previous patch by Jean Delvare shifted the i2c addresses 1 bit to the
right, and this patch fixes the write_reg function to shift it back
before sending the vendor request.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r 3a4be7d7dabd -r 134a95c0d98b linux/drivers/staging/go7007/s2250-board.c
--- a/linux/drivers/staging/go7007/s2250-board.cSun Jan 03 17:04:42 
2010 +
+++ b/linux/drivers/staging/go7007/s2250-board.cWed Jan 13 14:11:48 
2010 -0800
@@ -159,7 +159,7 @@
struct go7007 *go = i2c_get_adapdata(client-adapter);
struct go7007_usb *usb;
int rc;
-   int dev_addr = client-addr;
+   int dev_addr = client-addr  1;  /* firmware wants 8-bit address */
u8 *buf;
 
if (go == NULL)


--
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: go7007 driver -- which program you use for capture

2010-01-12 Thread Pete Eberlein
On Fri, 2010-01-08 at 14:07 -0500, TJ wrote:
 Pete and anybody else out there with go7007 devices, what do you use for 
 capture?

I used a modified capture.c, based on
http://v4l2spec.bytesex.org/v4l2spec/capture.c 

In the init_device(void) function, use:

fmt.type= V4L2_BUF_TYPE_VIDEO_CAPTURE;
switch (G_size) {
case 0:
fmt.fmt.pix.height = 640;
fmt.fmt.pix.width = 480;
break;
case 1:
fmt.fmt.pix.height = 320;
fmt.fmt.pix.width = 240;
break;
}
switch (type) {
case TYPE_MJPEG:
printf(MJPEG\n);
  fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
  break;
case TYPE_MPEG1:
case TYPE_MPEG2:
case TYPE_MPEG4:
  fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
  break;
}

fmt.fmt.pix.field   = V4L2_FIELD_ANY;

if (-1 == xioctl (fd, VIDIOC_S_FMT, fmt))
errno_exit (VIDIOC_S_FMT);

/* Note VIDIOC_S_FMT may change width and height. */

/* Buggy driver paranoia. */
min = fmt.fmt.pix.width * 2;
if (fmt.fmt.pix.bytesperline  min)
fmt.fmt.pix.bytesperline = min;
min = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height;
if (fmt.fmt.pix.sizeimage  min)
fmt.fmt.pix.sizeimage = min;

/* optional MPEG parameters */
if( type != TYPE_MJPEG) {
struct v4l2_control ctrl;

ctrl.id = V4L2_CID_MPEG_VIDEO_ENCODING;
switch (type) {
case TYPE_MPEG1:
ctrl.value = V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
break;
case TYPE_MPEG2:
ctrl.value = V4L2_MPEG_VIDEO_ENCODING_MPEG_2;
break;
case TYPE_MPEG4:
ctrl.value = V4L2_MPEG_VIDEO_ENCODING_MPEG_4_SP;
break;
}

if (0 != xioctl (fd, VIDIOC_S_CTRL, ctrl)) {
printf(could not set video encoding\n);
}

ctrl.id = V4L2_CID_MPEG_VIDEO_BITRATE;
ctrl.value = G_br;
if (0 != xioctl (fd, VIDIOC_S_CTRL, ctrl)) {
printf(could not change bitrate\n);
}
}

 Without GO7007 ioctls, I was only able to get vlc to capture in MJPEG format.

Does VLC try to change video parameters after starting the stream?  The
driver currently doesn't allow that.  I think I've seen xawtv try to do
that too.

Pete



--
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/5] go7007: Add struct v4l2_device.

2009-11-10 Thread Pete Eberlein
From: Pete Eberlein p...@sensoray.com

This adds a struct v4l2_device to the go7007 device struct and registers
it during v4l2 initialization.  The v4l2_device registration overwrites
the go-dev device_data, which is a struct usb_interface with intfdata set
to the struct go7007.  This changes intfdata to point to the struct
v4l2_device inside struct go7007, which is what v4l2_device_register will
also set it to (and warn about non-null drvdata on register.)  Since usb
disconnect can happen any time, this intfdata should always be present.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r 19c0469c02c3 -r a603ad1e6a1c 
linux/drivers/staging/go7007/go7007-driver.c
--- a/linux/drivers/staging/go7007/go7007-driver.c  Sat Nov 07 15:51:01 
2009 -0200
+++ b/linux/drivers/staging/go7007/go7007-driver.c  Tue Nov 10 10:41:56 
2009 -0800
@@ -49,7 +49,7 @@
go-hpi_ops-read_interrupt(go);
if (wait_event_timeout(go-interrupt_waitq,
go-interrupt_available, 5*HZ)  0) {
-   v4l2_err(go-video_dev, timeout waiting for read interrupt\n);
+   v4l2_err(go-v4l2_dev, timeout waiting for read interrupt\n);
return -1;
}
if (!go-interrupt_available)
@@ -315,7 +315,7 @@
 
if (go7007_send_firmware(go, fw, fw_len)  0 ||
go7007_read_interrupt(go, intr_val, intr_data)  0) {
-   v4l2_err(go-video_dev, error transferring firmware\n);
+   v4l2_err(go-v4l2_dev, error transferring firmware\n);
rv = -1;
goto start_error;
}
@@ -324,7 +324,7 @@
go-parse_length = 0;
go-seen_frame = 0;
if (go7007_stream_start(go)  0) {
-   v4l2_err(go-video_dev, error starting stream transfer\n);
+   v4l2_err(go-v4l2_dev, error starting stream transfer\n);
rv = -1;
goto start_error;
}
@@ -420,7 +420,7 @@
for (i = 0; i  length; ++i) {
if (go-active_buf != NULL 
go-active_buf-bytesused = GO7007_BUF_SIZE - 3) {
-   v4l2_info(go-video_dev, dropping oversized frame\n);
+   v4l2_info(go-v4l2_dev, dropping oversized frame\n);
go-active_buf-offset -= go-active_buf-bytesused;
go-active_buf-bytesused = 0;
go-active_buf-modet_active = 0;
@@ -668,7 +668,7 @@
if (i2c_del_adapter(go-i2c_adapter) == 0)
go-i2c_adapter_online = 0;
else
-   v4l2_err(go-video_dev,
+   v4l2_err(go-v4l2_dev,
error removing I2C adapter!\n);
}
 
diff -r 19c0469c02c3 -r a603ad1e6a1c linux/drivers/staging/go7007/go7007-priv.h
--- a/linux/drivers/staging/go7007/go7007-priv.hSat Nov 07 15:51:01 
2009 -0200
+++ b/linux/drivers/staging/go7007/go7007-priv.hTue Nov 10 10:41:56 
2009 -0800
@@ -21,6 +21,8 @@
  * user-space applications.
  */
 
+#include media/v4l2-device.h
+
 struct go7007;
 
 /* IDs to activate board-specific support code */
@@ -167,6 +169,7 @@
int channel_number; /* for multi-channel boards like Adlink PCI-MPG24 */
char name[64];
struct video_device *video_dev;
+   struct v4l2_device v4l2_dev;
int ref_count;
enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status;
spinlock_t spinlock;
@@ -240,6 +243,11 @@
unsigned short interrupt_data;
 };
 
+static inline struct go7007 *to_go7007(struct v4l2_device *v4l2_dev)
+{
+   return container_of(v4l2_dev, struct go7007, v4l2_dev);
+}
+
 /* All of these must be called with the hpi_lock mutex held! */
 #define go7007_interface_reset(go) \
((go)-hpi_ops-interface_reset(go))
diff -r 19c0469c02c3 -r a603ad1e6a1c linux/drivers/staging/go7007/go7007-usb.c
--- a/linux/drivers/staging/go7007/go7007-usb.c Sat Nov 07 15:51:01 2009 -0200
+++ b/linux/drivers/staging/go7007/go7007-usb.c Tue Nov 10 10:41:56 2009 -0800
@@ -1057,7 +1057,7 @@
usb_rcvintpipe(usb-usbdev, 4),
usb-intr_urb-transfer_buffer, 2*sizeof(u16),
go7007_usb_readinterrupt_complete, go, 8);
-   usb_set_intfdata(intf, go);
+   usb_set_intfdata(intf, go-v4l2_dev);
 
/* Boot the GO7007 */
if (go7007_boot_encoder(go, go-board_info-flags 
@@ -1233,7 +1233,7 @@
 
 static void go7007_usb_disconnect(struct usb_interface *intf)
 {
-   struct go7007 *go = usb_get_intfdata(intf);
+   struct go7007 *go = to_go7007(usb_get_intfdata(intf));
struct go7007_usb *usb = go-hpi_context;
struct urb *vurb, *aurb;
int i;
diff -r 19c0469c02c3 -r a603ad1e6a1c linux/drivers/staging/go7007/go7007-v4l2.c
--- a/linux/drivers/staging/go7007/go7007-v4l2.cSat Nov 07 15:51:01 
2009 -0200

[PATCH 2/5] s2250: Mutex function usage.

2009-11-10 Thread Pete Eberlein
From: Pete Eberlein p...@sensoray.com

Fix mutex function usage, which was overlooked in a previous patch.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r a603ad1e6a1c -r 99e4a0cf6788 linux/drivers/staging/go7007/s2250-board.c
--- a/linux/drivers/staging/go7007/s2250-board.cTue Nov 10 10:41:56 
2009 -0800
+++ b/linux/drivers/staging/go7007/s2250-board.cTue Nov 10 10:47:34 
2009 -0800
@@ -261,7 +261,7 @@
 
memset(buf, 0xcd, 6);
usb = go-hpi_context;
-   if (down_interruptible(usb-i2c_lock) != 0) {
+   if (mutex_lock_interruptible(usb-i2c_lock) != 0) {
printk(KERN_INFO i2c lock failed\n);
kfree(buf);
return -EINTR;
@@ -270,7 +270,7 @@
kfree(buf);
return -EFAULT;
}
-   up(usb-i2c_lock);
+   mutex_unlock(usb-i2c_lock);
 
*val = (buf[0]  8) | buf[1];
kfree(buf);

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


[PATCH 3/5] s2250: Change module structure

2009-11-10 Thread Pete Eberlein
From: Pete Eberlein p...@sensoray.com

The s2250-board i2c module was converted to use v4l2-i2c-drv.h in
preparation for its subdev conversion.  This change prevented the
s2250-loader from being initialized within the same module due to
the module_init and module_exit function definitions in v4l2-i2c-drv.h.
Therefore, s2250-loader is now its own module, and the header for
exporting s2250-loader functions is no longer needed.

The s2250 i2c module name was 2220-board in some places, and was
changed to s2250.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r 99e4a0cf6788 -r 5fe2031944d4 linux/drivers/staging/go7007/Makefile
--- a/linux/drivers/staging/go7007/Makefile Tue Nov 10 10:47:34 2009 -0800
+++ b/linux/drivers/staging/go7007/Makefile Tue Nov 10 10:54:51 2009 -0800
@@ -5,7 +5,7 @@
 
 obj-$(CONFIG_VIDEO_GO7007) += go7007.o
 obj-$(CONFIG_VIDEO_GO7007_USB) += go7007-usb.o
-obj-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD) += s2250.o
+obj-$(CONFIG_VIDEO_GO7007_USB_S2250_BOARD) += s2250.o s2250-loader.o
 obj-$(CONFIG_VIDEO_GO7007_SAA7113) += wis-saa7113.o
 obj-$(CONFIG_VIDEO_GO7007_OV7640) += wis-ov7640.o
 obj-$(CONFIG_VIDEO_GO7007_SAA7115) += wis-saa7115.o
@@ -17,7 +17,7 @@
 go7007-objs += go7007-v4l2.o go7007-driver.o go7007-i2c.o go7007-fw.o \
snd-go7007.o
 
-s2250-objs += s2250-board.o s2250-loader.o
+s2250-objs += s2250-board.o
 
 # Uncomment when the saa7134 patches get into upstream
 #ifneq ($(CONFIG_VIDEO_SAA7134),)
diff -r 99e4a0cf6788 -r 5fe2031944d4 
linux/drivers/staging/go7007/go7007-driver.c
--- a/linux/drivers/staging/go7007/go7007-driver.c  Tue Nov 10 10:47:34 
2009 -0800
+++ b/linux/drivers/staging/go7007/go7007-driver.c  Tue Nov 10 10:54:51 
2009 -0800
@@ -219,7 +219,7 @@
modname = wis-ov7640;
break;
case I2C_DRIVERID_S2250:
-   modname = s2250-board;
+   modname = s2250;
break;
default:
modname = NULL;
diff -r 99e4a0cf6788 -r 5fe2031944d4 linux/drivers/staging/go7007/go7007-usb.c
--- a/linux/drivers/staging/go7007/go7007-usb.c Tue Nov 10 10:47:34 2009 -0800
+++ b/linux/drivers/staging/go7007/go7007-usb.c Tue Nov 10 10:54:51 2009 -0800
@@ -425,7 +425,7 @@
.num_i2c_devs= 1,
.i2c_devs= {
{
-   .type   = s2250_board,
+   .type   = s2250,
.id = I2C_DRIVERID_S2250,
.addr   = 0x43,
},
diff -r 99e4a0cf6788 -r 5fe2031944d4 linux/drivers/staging/go7007/s2250-board.c
--- a/linux/drivers/staging/go7007/s2250-board.cTue Nov 10 10:47:34 
2009 -0800
+++ b/linux/drivers/staging/go7007/s2250-board.cTue Nov 10 10:54:51 
2009 -0800
@@ -20,10 +20,13 @@
 #include linux/usb.h
 #include linux/i2c.h
 #include linux/videodev2.h
+#include media/v4l2-device.h
 #include media/v4l2-common.h
-#include s2250-loader.h
+#include media/v4l2-i2c-drv.h
 #include go7007-priv.h
-#include wis-i2c.h
+
+MODULE_DESCRIPTION(Sensoray 2250/2251 i2c v4l2 subdev driver);
+MODULE_LICENSE(GPL v2);
 
 #define TLV320_ADDRESS  0x34
 #define VPX322_ADDR_ANALOGCONTROL1 0x02
@@ -575,7 +578,7 @@
dec-audio = audio;
i2c_set_clientdata(client, dec);
 
-   printk(KERN_DEBUG
+   printk(KERN_INFO
   s2250: initializing video decoder on %s\n,
   adapter-name);
 
@@ -648,46 +651,20 @@
return 0;
 }
 
+#if LINUX_VERSION_CODE = KERNEL_VERSION(2, 6, 26)
 static struct i2c_device_id s2250_id[] = {
-   { s2250_board, 0 },
+   { s2250, 0 },
{ }
 };
+MODULE_DEVICE_TABLE(i2c, s2250_id);
 
-static struct i2c_driver s2250_driver = {
-   .driver = {
-   .name   = Sensoray 2250 board driver,
-   },
-   .probe  = s2250_probe,
-   .remove = s2250_remove,
-   .command= s2250_command,
-   .id_table   = s2250_id,
+#endif
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+   .name = s2250,
+   .probe = s2250_probe,
+   .remove = s2250_remove,
+   .command = s2250_command,
+#if LINUX_VERSION_CODE = KERNEL_VERSION(2, 6, 26)
+   .id_table = s2250_id,
+#endif
 };
-
-static int __init s2250_init(void)
-{
-   int r;
-
-   r = s2250loader_init();
-   if (r  0)
-   return r;
-
-   r = i2c_add_driver(s2250_driver);
-   if (r  0)
-   s2250loader_cleanup();
-
-   return r;
-}
-
-static void __exit s2250_cleanup(void)
-{
-   i2c_del_driver(s2250_driver);
-
-   s2250loader_cleanup();
-}
-
-module_init(s2250_init);
-module_exit(s2250_cleanup);
-
-MODULE_AUTHOR();
-MODULE_DESCRIPTION(Board driver for Sensoryray 2250);
-MODULE_LICENSE(GPL v2);
diff -r 99e4a0cf6788 -r 5fe2031944d4 linux/drivers/staging/go7007/s2250-loader.c
--- a/linux/drivers/staging/go7007/s2250-loader.c   Tue Nov

[PATCH 4/5] s2250: subdev conversion

2009-11-10 Thread Pete Eberlein
From: Pete Eberlein p...@sensoray.com

Convert the s2250 i2c driver to use v4l2 subdev interface.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r 5fe2031944d4 -r a44341b7bf67 linux/drivers/staging/go7007/s2250-board.c
--- a/linux/drivers/staging/go7007/s2250-board.cTue Nov 10 10:54:51 
2009 -0800
+++ b/linux/drivers/staging/go7007/s2250-board.cTue Nov 10 10:56:51 
2009 -0800
@@ -23,6 +23,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-common.h
 #include media/v4l2-i2c-drv.h
+#include media/v4l2-subdev.h
 #include go7007-priv.h
 
 MODULE_DESCRIPTION(Sensoray 2250/2251 i2c v4l2 subdev driver);
@@ -115,6 +116,7 @@
 };
 
 struct s2250 {
+   struct v4l2_subdev sd;
v4l2_std_id std;
int input;
int brightness;
@@ -126,6 +128,11 @@
struct i2c_client *audio;
 };
 
+static inline struct s2250 *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct s2250, sd);
+}
+
 /* from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
 static int go7007_usb_vendor_request(struct go7007 *go, u16 request,
u16 value, u16 index, void *transfer_buffer, int length, int in)
@@ -309,253 +316,262 @@
 }
 
 
-static int s2250_command(struct i2c_client *client,
-unsigned int cmd, void *arg)
+/* - */
+
+static int s2250_s_video_routing(struct v4l2_subdev *sd, u32 input, u32 output,
+u32 config)
 {
-   struct s2250 *dec = i2c_get_clientdata(client);
+   struct s2250 *state = to_state(sd);
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   int vidsys;
 
-   switch (cmd) {
-   case VIDIOC_S_INPUT:
-   {
-   int vidsys;
-   int *input = arg;
+   vidsys = (state-std == V4L2_STD_NTSC) ? 0x01 : 0x00;
+   if (input == 0) {
+   /* composite */
+   write_reg_fp(client, 0x20, 0x020 | vidsys);
+   write_reg_fp(client, 0x21, 0x662);
+   write_reg_fp(client, 0x140, 0x060);
+   } else if (input == 1) {
+   /* S-Video */
+   write_reg_fp(client, 0x20, 0x040 | vidsys);
+   write_reg_fp(client, 0x21, 0x666);
+   write_reg_fp(client, 0x140, 0x060);
+   } else {
+   return -EINVAL;
+   }
+   state-input = input;
+   return 0;
+}
 
-   vidsys = (dec-std == V4L2_STD_NTSC) ? 0x01 : 0x00;
-   if (*input == 0) {
-   /* composite */
-   write_reg_fp(client, 0x20, 0x020 | vidsys);
-   write_reg_fp(client, 0x21, 0x662);
-   write_reg_fp(client, 0x140, 0x060);
-   } else {
-   /* S-Video */
-   write_reg_fp(client, 0x20, 0x040 | vidsys);
-   write_reg_fp(client, 0x21, 0x666);
-   write_reg_fp(client, 0x140, 0x060);
-   }
-   dec-input = *input;
+static int s2250_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
+{
+   struct s2250 *state = to_state(sd);
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   u16 vidsource;
+
+   vidsource = (state-input == 1) ? 0x040 : 0x020;
+   switch (norm) {
+   case V4L2_STD_NTSC:
+   write_regs_fp(client, vid_regs_fp);
+   write_reg_fp(client, 0x20, vidsource | 1);
break;
+   case V4L2_STD_PAL:
+   write_regs_fp(client, vid_regs_fp);
+   write_regs_fp(client, vid_regs_fp_pal);
+   write_reg_fp(client, 0x20, vidsource);
+   break;
+   default:
+   return -EINVAL;
}
-   case VIDIOC_S_STD:
-   {
-   v4l2_std_id *std = arg;
-   u16 vidsource;
+   state-std = norm;
+   return 0;
+}
 
-   vidsource = (dec-input == 1) ? 0x040 : 0x020;
-   dec-std = *std;
-   switch (dec-std) {
-   case V4L2_STD_NTSC:
-   write_regs_fp(client, vid_regs_fp);
-   write_reg_fp(client, 0x20, vidsource | 1);
-   break;
-   case V4L2_STD_PAL:
-   write_regs_fp(client, vid_regs_fp);
-   write_regs_fp(client, vid_regs_fp_pal);
-   write_reg_fp(client, 0x20, vidsource);
-   break;
-   default:
-   return -EINVAL;
-   }
-   break;
-   }
-   case VIDIOC_QUERYCTRL:
-   {
-   struct v4l2_queryctrl *ctrl = arg;
-   static const u32 user_ctrls[] = {
-   V4L2_CID_BRIGHTNESS,
-   V4L2_CID_CONTRAST,
-   V4L2_CID_SATURATION,
-   V4L2_CID_HUE

[PATCH 5/5] go7007: subdev conversion

2009-11-10 Thread Pete Eberlein
From: Pete Eberlein p...@sensoray.com

Convert the go7007 driver to v4l2 subdev interface, using v4l2 i2c
subdev functions instead of i2c functions directly.  The v4l2 ioctl ops
functions call subdev ops instead of i2c commands.

Priority: normal

Signed-off-by: Pete Eberlein p...@sensoray.com

diff -r a44341b7bf67 -r 76b500418fae 
linux/drivers/staging/go7007/go7007-driver.c
--- a/linux/drivers/staging/go7007/go7007-driver.c  Tue Nov 10 10:56:51 
2009 -0800
+++ b/linux/drivers/staging/go7007/go7007-driver.c  Tue Nov 10 11:20:10 
2009 -0800
@@ -193,7 +193,8 @@
 static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
   int id, int addr)
 {
-   struct i2c_board_info info;
+   struct go7007 *go = i2c_get_adapdata(adapter);
+   struct v4l2_device *v4l2_dev = go-v4l2_dev;
char *modname;
 
switch (id) {
@@ -225,14 +226,10 @@
modname = NULL;
break;
}
-   if (modname != NULL)
-   request_module(modname);
 
-   memset(info, 0, sizeof(struct i2c_board_info));
-   info.addr = addr;
-   strlcpy(info.type, type, I2C_NAME_SIZE);
-   if (!i2c_new_device(adapter, info))
+   if (v4l2_i2c_new_subdev(v4l2_dev, adapter, modname, type, addr, NULL))
return 0;
+
if (modname != NULL)
printk(KERN_INFO
go7007: probing for module %s failed\n, modname);
@@ -262,6 +259,11 @@
if (ret  0)
return -1;
 
+   /* v4l2 init must happen before i2c subdevs */
+   ret = go7007_v4l2_init(go);
+   if (ret  0)
+   return ret;
+
if (!go-i2c_adapter_online 
go-board_info-flags  GO7007_BOARD_USE_ONBOARD_I2C) {
if (go7007_i2c_init(go)  0)
@@ -282,7 +284,7 @@
go-audio_enabled = 1;
go7007_snd_init(go);
}
-   return go7007_v4l2_init(go);
+   return 0;
 }
 EXPORT_SYMBOL(go7007_register_encoder);
 
diff -r a44341b7bf67 -r 76b500418fae linux/drivers/staging/go7007/go7007-v4l2.c
--- a/linux/drivers/staging/go7007/go7007-v4l2.cTue Nov 10 10:56:51 
2009 -0800
+++ b/linux/drivers/staging/go7007/go7007-v4l2.cTue Nov 10 11:20:10 
2009 -0800
@@ -29,6 +29,7 @@
 #include linux/videodev2.h
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
+#include media/v4l2-subdev.h
 #include linux/i2c.h
 #include linux/mutex.h
 #include linux/uaccess.h
@@ -46,6 +47,9 @@
 #defineV4L2_MPEG_VIDEO_ENCODING_MPEG_4   3
 #endif
 
+#define call_all(dev, o, f, args...) \
+   v4l2_device_call_until_err(dev, 0, o, f, ##args)
+
 static void deactivate_buffer(struct go7007_buffer *gobuf)
 {
int i;
@@ -247,19 +251,23 @@
go-modet_map[i] = 0;
 
if (go-board_info-sensor_flags  GO7007_SENSOR_SCALING) {
-   struct video_decoder_resolution res;
+   struct v4l2_format res;
 
-   res.width = width;
+   if (fmt != NULL) {
+   res = *fmt;
+   } else {
+   res.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+   res.fmt.pix.width = width;
+   }
+
if (height  sensor_height / 2) {
-   res.height = height / 2;
+   res.fmt.pix.height = height / 2;
go-encoder_v_halve = 0;
} else {
-   res.height = height;
+   res.fmt.pix.height = height;
go-encoder_v_halve = 1;
}
-   if (go-i2c_adapter_online)
-   i2c_clients_command(go-i2c_adapter,
-   DECODER_SET_RESOLUTION, res);
+   call_all(go-v4l2_dev, video, s_fmt, res);
} else {
if (width = sensor_width / 4) {
go-encoder_h_halve = 1;
@@ -385,7 +393,7 @@
 }
 #endif
 
-static int mpeg_queryctrl(struct v4l2_queryctrl *ctrl)
+static int mpeg_query_ctrl(struct v4l2_queryctrl *ctrl)
 {
static const u32 mpeg_ctrls[] = {
V4L2_CID_MPEG_CLASS,
@@ -973,51 +981,35 @@
   struct v4l2_queryctrl *query)
 {
struct go7007 *go = ((struct go7007_file *) priv)-go;
+   int id = query-id;
 
-   if (!go-i2c_adapter_online)
-   return -EIO;
+   if (0 == call_all(go-v4l2_dev, core, queryctrl, query))
+   return 0;
 
-   i2c_clients_command(go-i2c_adapter, VIDIOC_QUERYCTRL, query);
-
-   return (!query-name[0]) ? mpeg_queryctrl(query) : 0;
+   query-id = id;
+   return mpeg_query_ctrl(query);
 }
 
 static int vidioc_g_ctrl(struct file *file, void *priv,
struct v4l2_control *ctrl)
 {
struct go7007 *go = ((struct go7007_file *) priv)-go;
-   struct v4l2_queryctrl query;
 
-   if (!go-i2c_adapter_online