Re: [PATCH] tm6000 fix i2c

2010-04-26 Thread Bee Hock Goh
wiki is your best friend. :)

http://www.linuxtv.org/wiki/index.php/Maintaining_Git_trees
http://www.linuxtv.org/wiki/index.php/Using_a_git_driver_development_tree


On Tue, Apr 27, 2010 at 1:15 PM, Dmitri Belimov  wrote:
> On Mon, 26 Apr 2010 20:58:24 +0800
> Bee Hock Goh  wrote:
>
>> thanks. This is work fine on my tm5600.
>
> Good news.
>
>> btw, can you use the git tree? There is some codes update from Stefan
>> there for the tm6000-i2c that is still not sync with hg.
>
> no problemm. Give me access and URL.
>
> With my best regards, Dmitry.
>
>> On Mon, Apr 26, 2010 at 8:25 AM, Dmitri Belimov 
>> wrote:
>> > Hi
>> >
>> > Rework last I2C patch.
>> > Set correct limit for I2C packet.
>> > Use different method for the tm5600/tm6000 and tm6010 to read word.
>> >
>> > Try this patch.
>> >
>> > diff -r 7c0b887911cf linux/drivers/staging/tm6000/tm6000-i2c.c
>> > --- a/linux/drivers/staging/tm6000/tm6000-i2c.c Mon Apr 05 22:56:43
>> > 2010 -0400 +++ b/linux/drivers/staging/tm6000/tm6000-i2c.c Mon Apr
>> > 26 04:15:56 2010 +1000 @@ -24,6 +24,7 @@
>> >  #include 
>> >  #include 
>> >  #include 
>> > +#include 
>> >
>> >  #include "compat.h"
>> >  #include "tm6000.h"
>> > @@ -45,11 +46,49 @@
>> >                        printk(KERN_DEBUG "%s at %s: " fmt, \
>> >                        dev->name, __FUNCTION__ , ##args); } while
>> > (0)
>> >
>> > +static void tm6000_i2c_reset(struct tm6000_core *dev)
>> > +{
>> > +       tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
>> > TM6000_GPIO_CLK, 0);
>> > +       msleep(15);
>> > +       tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
>> > TM6000_GPIO_CLK, 1);
>> > +       msleep(15);
>> > +}
>> > +
>> >  static int tm6000_i2c_send_regs(struct tm6000_core *dev, unsigned
>> > char addr, __u8 reg, char *buf, int len)
>> >  {
>> > -       return tm6000_read_write_usb(dev, USB_DIR_OUT |
>> > USB_TYPE_VENDOR | USB_RECIP_DEVICE,
>> > -               REQ_16_SET_GET_I2C_WR1_RDN, addr | reg << 8, 0,
>> > buf, len);
>> > +       int rc;
>> > +       unsigned int tsleep;
>> > +       unsigned int i2c_packet_limit = 16;
>> > +
>> > +       if (dev->dev_type == TM6010)
>> > +               i2c_packet_limit = 64;
>> > +
>> > +       if (!buf)
>> > +               return -1;
>> > +
>> > +       if (len < 1 || len > i2c_packet_limit){
>> > +               printk("Incorrect lenght of i2c packet = %d, limit
>> > set to %d\n",
>> > +                       len, i2c_packet_limit);
>> > +               return -1;
>> > +       }
>> > +
>> > +       /* capture mutex */
>> > +       rc = tm6000_read_write_usb(dev, USB_DIR_OUT |
>> > USB_TYPE_VENDOR |
>> > +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
>> > +               addr | reg << 8, 0, buf, len);
>> > +
>> > +       if (rc < 0) {
>> > +               /* release mutex */
>> > +               return rc;
>> > +       }
>> > +
>> > +       /* Calculate delay time, 14000us for 64 bytes */
>> > +       tsleep = ((len * 200) + 200 + 1000) / 1000;
>> > +       msleep(tsleep);
>> > +
>> > +       /* release mutex */
>> > +       return rc;
>> >  }
>> >
>> >  /* Generic read - doesn't work fine with 16bit registers */
>> > @@ -58,23 +97,41 @@
>> >  {
>> >        int rc;
>> >        u8 b[2];
>> > +       unsigned int i2c_packet_limit = 16;
>> >
>> > -       if ((dev->caps.has_zl10353) && (dev->demod_addr << 1 ==
>> > addr) && (reg % 2 == 0)) {
>> > +       if (dev->dev_type == TM6010)
>> > +               i2c_packet_limit = 64;
>> > +
>> > +       if (!buf)
>> > +               return -1;
>> > +
>> > +       if (len < 1 || len > i2c_packet_limit){
>> > +               printk("Incorrect lenght of i2c packet = %d, limit
>> > set to %d\n",
>> > +                       len, i2c_packet_limit);
>> > +               return -1;
>> > +       }
>> > +
>> > +       /* capture mutex */
>> > +       if ((dev->caps.has_zl10353) && (dev->demod_addr << 1 ==
>> > addr)
>> > +       && (reg % 2 == 0)) {
>> >                /*
>> >                 * Workaround an I2C bug when reading from zl10353
>> >                 */
>> >                reg -= 1;
>> >                len += 1;
>> >
>> > -               rc = tm6000_read_write_usb(dev, USB_DIR_IN |
>> > USB_TYPE_VENDOR | USB_RECIP_DEVICE,
>> > -                       REQ_16_SET_GET_I2C_WR1_RDN, addr | reg <<
>> > 8, 0, b, len);
>> > +               rc = tm6000_read_write_usb(dev, USB_DIR_IN |
>> > USB_TYPE_VENDOR |
>> > +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
>> > +               addr | reg << 8, 0, b, len);
>> >
>> >                *buf = b[1];
>> >        } else {
>> > -               rc = tm6000_read_write_usb(dev, USB_DIR_IN |
>> > USB_TYPE_VENDOR | USB_RECIP_DEVICE,
>> > -                       REQ_16_SET_GET_I2C_WR1_RDN, addr | reg <<
>> > 8, 0, buf, len);
>> > +               rc = tm6000_read_write_usb(dev, USB_DIR_IN |
>> > USB_TYPE_VENDOR |
>> > +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
>> > +               addr | reg << 8, 0, buf, len);
>> >        }
>> >
>> > 

Re: [PATCH] tm6000 fix i2c

2010-04-26 Thread Dmitri Belimov
On Mon, 26 Apr 2010 20:58:24 +0800
Bee Hock Goh  wrote:

> thanks. This is work fine on my tm5600.

Good news.
 
> btw, can you use the git tree? There is some codes update from Stefan
> there for the tm6000-i2c that is still not sync with hg.

no problemm. Give me access and URL.

With my best regards, Dmitry.

> On Mon, Apr 26, 2010 at 8:25 AM, Dmitri Belimov 
> wrote:
> > Hi
> >
> > Rework last I2C patch.
> > Set correct limit for I2C packet.
> > Use different method for the tm5600/tm6000 and tm6010 to read word.
> >
> > Try this patch.
> >
> > diff -r 7c0b887911cf linux/drivers/staging/tm6000/tm6000-i2c.c
> > --- a/linux/drivers/staging/tm6000/tm6000-i2c.c Mon Apr 05 22:56:43
> > 2010 -0400 +++ b/linux/drivers/staging/tm6000/tm6000-i2c.c Mon Apr
> > 26 04:15:56 2010 +1000 @@ -24,6 +24,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include "compat.h"
> >  #include "tm6000.h"
> > @@ -45,11 +46,49 @@
> >                        printk(KERN_DEBUG "%s at %s: " fmt, \
> >                        dev->name, __FUNCTION__ , ##args); } while
> > (0)
> >
> > +static void tm6000_i2c_reset(struct tm6000_core *dev)
> > +{
> > +       tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
> > TM6000_GPIO_CLK, 0);
> > +       msleep(15);
> > +       tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
> > TM6000_GPIO_CLK, 1);
> > +       msleep(15);
> > +}
> > +
> >  static int tm6000_i2c_send_regs(struct tm6000_core *dev, unsigned
> > char addr, __u8 reg, char *buf, int len)
> >  {
> > -       return tm6000_read_write_usb(dev, USB_DIR_OUT |
> > USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> > -               REQ_16_SET_GET_I2C_WR1_RDN, addr | reg << 8, 0,
> > buf, len);
> > +       int rc;
> > +       unsigned int tsleep;
> > +       unsigned int i2c_packet_limit = 16;
> > +
> > +       if (dev->dev_type == TM6010)
> > +               i2c_packet_limit = 64;
> > +
> > +       if (!buf)
> > +               return -1;
> > +
> > +       if (len < 1 || len > i2c_packet_limit){
> > +               printk("Incorrect lenght of i2c packet = %d, limit
> > set to %d\n",
> > +                       len, i2c_packet_limit);
> > +               return -1;
> > +       }
> > +
> > +       /* capture mutex */
> > +       rc = tm6000_read_write_usb(dev, USB_DIR_OUT |
> > USB_TYPE_VENDOR |
> > +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> > +               addr | reg << 8, 0, buf, len);
> > +
> > +       if (rc < 0) {
> > +               /* release mutex */
> > +               return rc;
> > +       }
> > +
> > +       /* Calculate delay time, 14000us for 64 bytes */
> > +       tsleep = ((len * 200) + 200 + 1000) / 1000;
> > +       msleep(tsleep);
> > +
> > +       /* release mutex */
> > +       return rc;
> >  }
> >
> >  /* Generic read - doesn't work fine with 16bit registers */
> > @@ -58,23 +97,41 @@
> >  {
> >        int rc;
> >        u8 b[2];
> > +       unsigned int i2c_packet_limit = 16;
> >
> > -       if ((dev->caps.has_zl10353) && (dev->demod_addr << 1 ==
> > addr) && (reg % 2 == 0)) {
> > +       if (dev->dev_type == TM6010)
> > +               i2c_packet_limit = 64;
> > +
> > +       if (!buf)
> > +               return -1;
> > +
> > +       if (len < 1 || len > i2c_packet_limit){
> > +               printk("Incorrect lenght of i2c packet = %d, limit
> > set to %d\n",
> > +                       len, i2c_packet_limit);
> > +               return -1;
> > +       }
> > +
> > +       /* capture mutex */
> > +       if ((dev->caps.has_zl10353) && (dev->demod_addr << 1 ==
> > addr)
> > +       && (reg % 2 == 0)) {
> >                /*
> >                 * Workaround an I2C bug when reading from zl10353
> >                 */
> >                reg -= 1;
> >                len += 1;
> >
> > -               rc = tm6000_read_write_usb(dev, USB_DIR_IN |
> > USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> > -                       REQ_16_SET_GET_I2C_WR1_RDN, addr | reg <<
> > 8, 0, b, len);
> > +               rc = tm6000_read_write_usb(dev, USB_DIR_IN |
> > USB_TYPE_VENDOR |
> > +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> > +               addr | reg << 8, 0, b, len);
> >
> >                *buf = b[1];
> >        } else {
> > -               rc = tm6000_read_write_usb(dev, USB_DIR_IN |
> > USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> > -                       REQ_16_SET_GET_I2C_WR1_RDN, addr | reg <<
> > 8, 0, buf, len);
> > +               rc = tm6000_read_write_usb(dev, USB_DIR_IN |
> > USB_TYPE_VENDOR |
> > +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> > +               addr | reg << 8, 0, buf, len);
> >        }
> >
> > +       /* release mutex */
> >        return rc;
> >  }
> >
> > @@ -85,8 +142,137 @@
> >  static int tm6000_i2c_recv_regs16(struct tm6000_core *dev,
> > unsigned char addr, __u16 reg, char *buf, int len)
> >  {
> > -       return tm6000_read_write_usb(dev, USB_DIR_IN |
> > USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> > -               REQ_14_SET_GET_I2C_WR2_RDN, addr, reg, buf

[PATCH] Add Elgato EyeTV Diversity to dibcom driver

2010-04-26 Thread Wolfram Sang
From: Michael Müller 

This patch introduces support for DVB-T for the following dibcom
based card: Elgato EyeTV Diversity (USB-ID: 0fd9:0011)

Support for the Elgato silver IR remote is added too (set parameter
dvb_usb_dib0700_ir_proto=0)

[wsa: rebased to current linuxtv-master]

Signed-off-by: Michael Müller 
Signed-off-by: Wolfram Sang 
Cc: Olivier Grenie 
Cc: Patrick Boettcher 
---
 drivers/media/dvb/dvb-usb/dib0700_devices.c |   46 +-
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 +
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c 
b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 2deca21..800800a 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -794,6 +794,43 @@ static struct dvb_usb_rc_key ir_codes_dib0700_table[] = {
{ 0x7a13, KEY_VOLUMEDOWN },
{ 0x7a40, KEY_POWER },
{ 0x7a41, KEY_MUTE },
+
+   /* Key codes for the Elgato EyeTV Diversity silver remote,
+  set dvb_usb_dib0700_ir_proto=0 */
+   { 0x4501, KEY_POWER },
+   { 0x4502, KEY_MUTE },
+   { 0x4503, KEY_1 },
+   { 0x4504, KEY_2 },
+   { 0x4505, KEY_3 },
+   { 0x4506, KEY_4 },
+   { 0x4507, KEY_5 },
+   { 0x4508, KEY_6 },
+   { 0x4509, KEY_7 },
+   { 0x450a, KEY_8 },
+   { 0x450b, KEY_9 },
+   { 0x450c, KEY_LAST },
+   { 0x450d, KEY_0 },
+   { 0x450e, KEY_ENTER },
+   { 0x450f, KEY_RED },
+   { 0x4510, KEY_CHANNELUP },
+   { 0x4511, KEY_GREEN },
+   { 0x4512, KEY_VOLUMEDOWN },
+   { 0x4513, KEY_OK },
+   { 0x4514, KEY_VOLUMEUP },
+   { 0x4515, KEY_YELLOW },
+   { 0x4516, KEY_CHANNELDOWN },
+   { 0x4517, KEY_BLUE },
+   { 0x4518, KEY_LEFT }, /* Skip backwards */
+   { 0x4519, KEY_PLAYPAUSE },
+   { 0x451a, KEY_RIGHT }, /* Skip forward */
+   { 0x451b, KEY_REWIND },
+   { 0x451c, KEY_L }, /* Live */
+   { 0x451d, KEY_FASTFORWARD },
+   { 0x451e, KEY_STOP }, /* 'Reveal' for Teletext */
+   { 0x451f, KEY_MENU }, /* KEY_TEXT for Teletext */
+   { 0x4540, KEY_RECORD }, /* Font 'Size' for Teletext */
+   { 0x4541, KEY_SCREEN }, /*  Full screen toggle, 'Hold' for Teletext */
+   { 0x4542, KEY_SELECT }, /* Select video input, 'Select' for Teletext */
 };
 
 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
@@ -2049,6 +2086,7 @@ struct usb_device_id dib0700_usb_id_table[] = {
 /* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
{ USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV282E) },
{ USB_DEVICE(USB_VID_DIBCOM,USB_PID_DIBCOM_STK8096GP) },
+   { USB_DEVICE(USB_VID_ELGATO,USB_PID_ELGATO_EYETV_DIVERSITY) },
{ 0 }   /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -2393,7 +2431,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
}
},
 
-   .num_device_descs = 6,
+   .num_device_descs = 7,
.devices = {
{   "DiBcom STK7070PD reference design",
{ &dib0700_usb_id_table[17], NULL },
@@ -2419,7 +2457,11 @@ struct dvb_usb_device_properties dib0700_devices[] = {
{  "Sony PlayTV",
{ &dib0700_usb_id_table[44], NULL },
{ NULL },
-   }
+   },
+   {   "Elgato EyeTV Diversity",
+   { &dib0700_usb_id_table[68], NULL },
+   { NULL },
+   },
},
.rc_interval  = DEFAULT_RC_INTERVAL,
.rc_key_map   = ir_codes_dib0700_table,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h 
b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index de1f3af..085c4e4 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -290,6 +290,7 @@
 #define USB_PID_MSI_DIGI_VOX_MINI_III   0x8807
 #define USB_PID_SONY_PLAYTV0x0003
 #define USB_PID_MYGICA_D6890xd811
+#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011
 #define USB_PID_ELGATO_EYETV_DTT   0x0021
 #define USB_PID_ELGATO_EYETV_DTT_Dlx   0x0020
 #define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD0x5000
-- 
1.7.0

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


Re: [Bugme-new] [Bug 15826] New: WARNING: at fs/proc/generic.c:317 __xlate_proc_name+0xbd/0xe0()

2010-04-26 Thread Andrew Morton

(switched to email.  Please respond via emailed reply-to-all, not via the
bugzilla web interface).

On Wed, 21 Apr 2010 12:21:18 GMT
bugzilla-dae...@bugzilla.kernel.org wrote:

> https://bugzilla.kernel.org/show_bug.cgi?id=15826
> 
>Summary: WARNING: at fs/proc/generic.c:317
> __xlate_proc_name+0xbd/0xe0()
>Product: v4l-dvb
>Version: unspecified
> Kernel Version: 2.6.34-rc5
>   Platform: All
> OS/Version: Linux
>   Tree: Mainline
> Status: NEW
>   Severity: normal
>   Priority: P1
>  Component: dvb-core
> AssignedTo: v4l-dvb_dvb-c...@kernel-bugs.osdl.org
> ReportedBy: bugzilla.kernel@boris64.net
> Regression: No
> 
> 
> Created an attachment (id=26077)
>  --> (https://bugzilla.kernel.org/attachment.cgi?id=26077)
> full dmesg
> 
> I keep getting this warning on boot. It seems to
> happen when the dvb driver for my "technisat skystar2"
> card is loaded (correct me if i'm wrong).
> 
> If you need more infos or debug stuff inside 
> my kernel config, please tell me what i need to include.
> 
> Thank you in advance.
> 
> 
> ...
> [0.739420] b2c2-flexcop: B2C2 FlexcopII/II(b)/III digital TV receiver chip
> loaded successfully
> [0.739435] flexcop-pci: will use the HW PID filter.
> [0.739438] flexcop-pci: card revision 2
> [0.739442] b2c2_flexcop_pci :04:01.0: PCI INT A -> GSI 17 (level, low)
> -> IRQ 17
> [0.739459] [ cut here ]
> [0.739463] WARNING: at fs/proc/generic.c:317 __xlate_proc_name+0xbd/0xe0()

Alexey, this sucks.  A developer goes to the warning site:

static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret,
 const char **residual)
{
const char  *cp = name, *next;
struct proc_dir_entry   *de;
int len;

de = *ret;
if (!de)
de = &proc_root;

while (1) {
next = strchr(cp, '/');
if (!next)
break;

len = next - cp;
for (de = de->subdir; de ; de = de->next) {
if (proc_match(len, cp, de))
break;
}
if (!de) {
WARN(1, "name '%s'\n", name);
return -ENOENT;
}
cp += len + 1;
}
*residual = cp;
*ret = de;
return 0;
}

and there's no hint whatsoever to tell him what the warning means, nor
how to fix it.

Please send a patch adding a nice comment to __xlate_proc_name().  Then
perhaps the DVB guys have a chance of fixing this bug.

Thanks.


> [0.739465] Hardware name: P5K
> [0.739466] name 'Technisat/B2C2 FlexCop II/IIb/III Digital TV PCI Driver'
> [0.739467] Modules linked in:
> [0.739470] Pid: 1, comm: swapper Not tainted 2.6.34-rc5-v2k11+-dbg-dirty
> #118
> [0.739471] Call Trace:
> [0.739476]  [] warn_slowpath_common+0x76/0xb0
> [0.739478]  [] warn_slowpath_fmt+0x3c/0x40
> [0.739481]  [] __xlate_proc_name+0xbd/0xe0
> [0.739483]  [] __proc_create+0x70/0x140
> [0.739486]  [] proc_mkdir_mode+0x29/0x60
> [0.739488]  [] proc_mkdir+0x11/0x20
> [0.739491]  [] register_handler_proc+0x11b/0x140
> [0.739494]  [] __setup_irq+0x1f9/0x390
> [0.739497]  [] ? flexcop_pci_isr+0x0/0x3e0
> [0.739500]  [] request_threaded_irq+0x12c/0x210
> [0.739502]  [] flexcop_pci_probe+0x1b0/0x350
> [0.739505]  [] pci_device_probe+0x75/0xa0
> [0.739509]  [] ? driver_sysfs_add+0x5a/0x90
> [0.739511]  [] driver_probe_device+0x93/0x1a0
> [0.739514]  [] __driver_attach+0x9b/0xa0
> [0.739517]  [] ? __driver_attach+0x0/0xa0
> [0.739519]  [] bus_for_each_dev+0x5e/0x90
> [0.739522]  [] driver_attach+0x19/0x20
> [0.739524]  [] bus_add_driver+0xb2/0x260
> [0.739527]  [] driver_register+0x6f/0x130
> [0.739529]  [] __pci_register_driver+0x51/0xd0
> [0.739533]  [] ? flexcop_pci_module_init+0x0/0x1b
> [0.739535]  [] flexcop_pci_module_init+0x19/0x1b
> [0.739538]  [] do_one_initcall+0x39/0x1a0
> [0.739540]  [] kernel_init+0x14d/0x1d7
> [0.739543]  [] kernel_thread_helper+0x4/0x10
> [0.739546]  [] ? kernel_init+0x0/0x1d7
> [0.739548]  [] ? kernel_thread_helper+0x0/0x10
> [0.739553] ---[ end trace 4e6b2faee55cb1bf ]---
> [0.744389] DVB: registering new adapter (FlexCop Digital TV device)
> [0.746102] b2c2-flexcop: MAC address = 00:d0:d7:0f:30:58
> [0.946350] b2c2-flexcop: found 'ST STV0299 DVB-S' .
> [0.946353] DVB: registering adapter 0 frontend 0 (ST STV0299 DVB-S)...
> [0.946422] b2c2-flexcop: initialization of 'Sky2PC/SkyStar 2 DVB-S rev 
> 2.6'
> at the 'PCI' bus controlled by a 'FlexCopIIb' complete

--
To unsubscribe from this list: send t

Re: Kworld Plus TV Hybrid PCI (DVB-T 210SE)

2010-04-26 Thread hermann pitton

Am Montag, den 26.04.2010, 21:51 +1000 schrieb 0123pe...@gmail.com:

[snip]
> >> >> > 
> >> >> > If it is a additional new regression, then mercurial bisect can find 
> >> >> > the
> >> >> > patch in question fairly quick.
> >> >> 
> >> >> That sounds like something that I should be able to do, if only 
> >> >> I'd read the instructions.  
> >> > 
> >> > It is totally up to you and all others with that hardware.
> >> 
> >> Can you provide a like for where to start reading?
> > 
> > README.patches.  
> > 
> >  Part III - Best Practices
> > 1. Community best practices
> > 2. Mercurial specific procedures
> > 3. Knowing about newer patches committed at the development repositories
> > 4. Patch submission from the community
> > 5. Identifying regressions with Mercurial
> 
> I have not found the file README.patches.  
> 

Peter, for that one.

"yum", or whatever, "install mercurial".

"hg clone http://linuxtv.org/hg/v4l-dvb";
"cd v4l-dvb"
"less README.patches"

Cheers,
Hermann


--
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: tuner XC5000 race condition??

2010-04-26 Thread Timothy D. Lenz



On 4/26/2010 11:57 AM, Timothy D. Lenz wrote:



On 4/25/2010 6:00 PM, Andy Walls wrote:

On Mon, 2010-04-26 at 10:44 +1000, Dmitri Belimov wrote:

Hi

Sometimes tuner XC5000 crashed on boot. This PC is dual-core.
It can be race condition or multi-core depend problem.

Add mutex for solve this problem is correct?


Dmitri,

This problem may be related to the firmware loading race described here:

https://bugzilla.kernel.org/show_bug.cgi?id=15294

I still have not fixed that bug yet.

But for your problem, perhaps you can try:

echo 120> /sys/class/firmware/timeout

as root in the initialization scripts to lengthen the firmware loading
timeout to 120 seconds. Maybe that will work around the crash.

I'll try and look at what is going on in your crash dumps, if I have
time.

Regards,
Andy


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



Could this problem also be related to the tuner problem I've been having
with one tuner stop tuning? Because it is on a Athlon64 x2 (dual core).
I put up logs with debug on. First set was I think about 24hrs with no
crash, then the file ext new and new2 where each copied out after the
tuner was found crashed.

http://24.255.17.209:2400/vdr/logs/

The computer hosting these logs, I hope to take down for a short while,
maybe a few hours to switch it over to raid boot. So if you can't
connect, try again later.


Keep forgetting, reply on this list doesn't go to the list unless you 
reply all or manually change the address:(


Could this problem also be related to the tuner problem I've been having 
with one tuner stop tuning? Because it is on a Athlon64 x2 (dual core). 
I put up logs with debug on. First set was I think about 24hrs with no 
crash, then the file ext new and new2 where each copied out after the 
tuner was found crashed.

--
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: faulty pac3711

2010-04-26 Thread Sigmund Skjelnes

Cheese did the job perfectly, thanks a lot.

Regards,
Sigmund

Hans de Goede wrote:

Hi,

make sure you're using the camera together with apps which are using
libv4l, such as cheese.

Regards,

Hans


On 04/25/2010 08:39 PM, skjel...@robin.no wrote:

Hi!
I'd have an Exibel snakescope TF2808 which dont make any picure on
Linux. It worked ok on windows, but I do not have windows installed any

snip, snip
--
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] v4l-dvb daily build 2.6.22 and up: ERRORS, 2.6.16-2.6.21: WARNINGS

2010-04-26 Thread Hans Verkuil
This message is generated daily by a cron job that builds v4l-dvb for
the kernels and architectures in the list below.

Results of the daily build of v4l-dvb:

date:Mon Apr 26 19:00:20 CEST 2010
path:http://www.linuxtv.org/hg/v4l-dvb
changeset:   14592:b438301e588f
git master:   f6760aa024199cfbce564311dc4bc4d47b6fb349
git media-master: 1fa9d4c07f3ddee1c054a751cd78e53e8b9050b4
gcc version:  i686-linux-gcc (GCC) 4.4.3
host hardware:x86_64
host os:  2.6.32.5

linux-2.6.32.6-armv5: OK
linux-2.6.33-armv5: OK
linux-2.6.34-rc1-armv5: OK
linux-2.6.32.6-armv5-davinci: OK
linux-2.6.33-armv5-davinci: OK
linux-2.6.34-rc1-armv5-davinci: OK
linux-2.6.32.6-armv5-ixp: OK
linux-2.6.33-armv5-ixp: OK
linux-2.6.34-rc1-armv5-ixp: OK
linux-2.6.32.6-armv5-omap2: OK
linux-2.6.33-armv5-omap2: OK
linux-2.6.34-rc1-armv5-omap2: OK
linux-2.6.22.19-i686: WARNINGS
linux-2.6.23.17-i686: WARNINGS
linux-2.6.24.7-i686: OK
linux-2.6.25.20-i686: OK
linux-2.6.26.8-i686: OK
linux-2.6.27.44-i686: OK
linux-2.6.28.10-i686: OK
linux-2.6.29.1-i686: WARNINGS
linux-2.6.30.10-i686: OK
linux-2.6.31.12-i686: OK
linux-2.6.32.6-i686: OK
linux-2.6.33-i686: OK
linux-2.6.34-rc1-i686: WARNINGS
linux-2.6.32.6-m32r: OK
linux-2.6.33-m32r: OK
linux-2.6.34-rc1-m32r: OK
linux-2.6.32.6-mips: OK
linux-2.6.33-mips: OK
linux-2.6.34-rc1-mips: OK
linux-2.6.32.6-powerpc64: OK
linux-2.6.33-powerpc64: OK
linux-2.6.34-rc1-powerpc64: WARNINGS
linux-2.6.22.19-x86_64: WARNINGS
linux-2.6.23.17-x86_64: WARNINGS
linux-2.6.24.7-x86_64: OK
linux-2.6.25.20-x86_64: OK
linux-2.6.26.8-x86_64: OK
linux-2.6.27.44-x86_64: OK
linux-2.6.28.10-x86_64: OK
linux-2.6.29.1-x86_64: WARNINGS
linux-2.6.30.10-x86_64: OK
linux-2.6.31.12-x86_64: OK
linux-2.6.32.6-x86_64: OK
linux-2.6.33-x86_64: OK
linux-2.6.34-rc1-x86_64: WARNINGS
linux-git-armv5: OK
linux-git-armv5-davinci: OK
linux-git-armv5-ixp: OK
linux-git-armv5-omap2: OK
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-x86_64: WARNINGS
spec: ERRORS
spec-git: OK
sparse: ERRORS
linux-2.6.16.62-i686: WARNINGS
linux-2.6.17.14-i686: WARNINGS
linux-2.6.18.8-i686: WARNINGS
linux-2.6.19.7-i686: WARNINGS
linux-2.6.20.21-i686: WARNINGS
linux-2.6.21.7-i686: WARNINGS
linux-2.6.16.62-x86_64: WARNINGS
linux-2.6.17.14-x86_64: WARNINGS
linux-2.6.18.8-x86_64: WARNINGS
linux-2.6.19.7-x86_64: WARNINGS
linux-2.6.20.21-x86_64: WARNINGS
linux-2.6.21.7-x86_64: WARNINGS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Monday.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


HDPVR Poor quality S-Video Capture

2010-04-26 Thread Mark Goldberg
Using the 20100401 snapshot kernel modules from ATrpms on F12, I've
noticed that the quality
of video capture from the HDPVR is significantly worse than that from a PVRUSB2,
using the S-Video input. It is less sharp and has jaggier edges on things like
on screen displays from the video source (sat TV S-video output). This
is with Mythtv
and I've tried various video output settings, ffmpeg and VDPAU
decoding, deinterlacing,
etc. This is with an NTSC 480i input.

Any suggestions would be welcome. I've compiled the modules myself and can make
any changes suggested for troubleshooting. I can also provide sample captures if
needed

Thanks,

Mark
--
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: av7110 and budget_av are broken!

2010-04-26 Thread VDR User
On Mon, Apr 26, 2010 at 6:35 AM, Mauro Carvalho Chehab
 wrote:
> You need to ask Douglas about -hg issues. He is the actual maintainer of that 
> tree.
> It is probably a good idea to merge also from fixes.git tree, but this may 
> make
> his sync process more complicated, so, it is up to him to decide how to do it.
>
> I still thinking on having a better way to have those fixes patches merged 
> earlier
> on -git, but I'll need to have some time to do some scripting and test some 
> things.

I think any progress to keep these trees in better sync is a good idea.

>> I don't actually know anyone who bothers with the git
>> tree for obvious reasons
>
> About half of the developers are submitting git requests, so it seems that
> there are people using it.

I'd expect that a portion of developers prefer git, but I was
referring to end-users -- the guys who do the majority of testing imo.
 I don't know any end-users with any intention of using the git tree.
Actually, there are quite a few who stopped updating their hg tree and
prefer to use older known working drivers because of the sync
problems/broken drivers not being fixed.  From a developer standpoint
it may be decent but to an end-user it's just turned into a big mess.
Oh well, who needs all those testers anyways? ;)

Cheers
--
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: Xawtv sparc 64bit fix

2010-04-26 Thread Guy Martin

Hi Mauro,

Thanks for the feedback. Here is the fixed version.

Cheers,
  Guy

On Sun, 25 Apr 2010 13:55:44 -0300
Mauro Carvalho Chehab  wrote:

> Guy Martin wrote:
> > 
> > Hi,
> > 
> > Here is an old patch of mine which I tried to submit in 2006 but
> > never got it. I didn't really know who was xawtv's maintainer at
> > that time.
> > 
> > 
> > 
> > The calculation to compute the 64bit alignement in struct-dump.c is
> > plain wrong. The alignment has to be computed with a structure
> > containing a char and then a 64bit integer and then substract the
> > pointer of the 64bit int to the one of the char.
> > 
> > This fix v4l-info doing a Bus Error on sparc with structs containing
> > 64 bit integer following a non 64bit field aligned on a 8 byte
> > boundary like v4l2_standard.
> > 
> > 
> > Signed-off-by: Guy Martin 
> 
> I tried to compile it (x86_64 arch) and your patch produced two
> warnings:
> 
> ../structs/struct-dump.c: In function ‘print_struct’:
> ../structs/struct-dump.c:48: warning: cast from pointer to integer of
> different size ../structs/struct-dump.c:48: warning: cast from
> pointer to integer of different size
> 
> Could you please fix it?
> 
> > 
> > 
> > Regards,
> >   Guy
> > 
> 
> 

diff --git a/structs/struct-dump.c b/structs/struct-dump.c
index 0ee7fc8..49bfe2d 100644
--- a/structs/struct-dump.c
+++ b/structs/struct-dump.c
@@ -43,7 +43,9 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
 	int16_t  s16;
 	uint8_t  u8;
 	int8_t   s8;
-	int al = sizeof(long)-1; /* struct + union + 64bit alignment */
+	struct al64_t { char c; uint64_t t; } al64_t;
+	int al = sizeof(long)-1; /* struct + union */
+	int al64 = (unsigned long)&al64_t.t - (unsigned long)&al64_t.c - 1; /* 64 bit alignement */
 	void *p;
 	unsigned int i,j,first;
 
@@ -149,7 +151,7 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
 			ptr += 4;
 			break;
 		case BITS64:
-			ptr = (void*)(((intptr_t)ptr + al) & ~al);
+			ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
 			u64 = *((uint64_t*)ptr);
 			first = 1;
 			fprintf(fp,"0x%" PRIx64 " [",u64);
@@ -166,13 +168,13 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
 			break;
 
 		case UINT64:
-			ptr = (void*)(((intptr_t)ptr + al) & ~al);
+			ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
 			u64 = *((uint64_t*)ptr);
 			fprintf(fp,"%" PRIu64,u64);
 			ptr += 8;
 			break;
 		case SINT64:
-			ptr = (void*)(((intptr_t)ptr + al) & ~al);
+			ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
 			s64 = *((int64_t*)ptr);
 			fprintf(fp,"%" PRId64,s64);
 			ptr += 8;


[PATCH] Read MAC for TeVii S470 PCI-e DVB-S2 card

2010-04-26 Thread pierre.gronlier
This patch retrieve the correct mac address from the eeprom for TeVii
S470 card.


Signed-off-by: Pierre Gronlier 


diff --git a/linux/drivers/media/video/cx23885/cx23885-dvb.c
b/linux/drivers/media/video/cx23885/cx23885-dvb.c
--- a/linux/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/linux/drivers/media/video/cx23885/cx23885-dvb.c
@@ -929,6 +929,22 @@
netup_ci_init(port);
break;
}
+   case CX23885_BOARD_TEVII_S470: {
+   u8 eeprom[256]; /* 24C02 i2c eeprom */
+
+   if (port->nr != 1)
+   break;
+
+   /* Read entire EEPROM */
+   dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
+   tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
sizeof(eeprom));
+   printk(KERN_INFO "TeVii S470 MAC= "
+   "%02X:%02X:%02X:%02X:%02X:%02X\n",
+   eeprom[0xa0], eeprom[0xa1], eeprom[0xa2],
+   eeprom[0xa3], eeprom[0xa4], eeprom[0xa5]);
+   memcpy(port->frontends.adapter.proposed_mac, eeprom +
0xa0, 6);
+   break;
+   }
}

return ret;


-- 
pierre gronlier
Read MAC for TeVii S470 PCI-e DVB-S2 card.
Signed-off-by: Pierre Gronlier 

diff --git a/linux/drivers/media/video/cx23885/cx23885-dvb.c b/linux/drivers/media/video/cx23885/cx23885-dvb.c
--- a/linux/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/linux/drivers/media/video/cx23885/cx23885-dvb.c
@@ -929,6 +929,22 @@
 		netup_ci_init(port);
 		break;
 		}
+	case CX23885_BOARD_TEVII_S470: {
+		u8 eeprom[256]; /* 24C02 i2c eeprom */
+
+		if (port->nr != 1)
+			break;
+
+		/* Read entire EEPROM */
+		dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
+		tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
+		printk(KERN_INFO "TeVii S470 MAC= "
+"%02X:%02X:%02X:%02X:%02X:%02X\n",
+eeprom[0xa0], eeprom[0xa1], eeprom[0xa2],
+eeprom[0xa3], eeprom[0xa4], eeprom[0xa5]);
+		memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
+		break;
+		}
 	}
 
 	return ret;


Re: [PATCH 06/15] [RFC] msp3400: convert to the new control framework

2010-04-26 Thread David Ellingsworth
On Mon, Apr 26, 2010 at 3:33 AM, Hans Verkuil  wrote:
> Signed-off-by: Hans Verkuil 
> ---
>  drivers/media/video/msp3400-driver.c   |  248 +++
>  drivers/media/video/msp3400-driver.h   |   16 ++-
>  drivers/media/video/msp3400-kthreads.c |   16 +-
>  3 files changed, 108 insertions(+), 172 deletions(-)
>
> diff --git a/drivers/media/video/msp3400-driver.c 
> b/drivers/media/video/msp3400-driver.c
> index e9df3cb..de0da40 100644
> --- a/drivers/media/video/msp3400-driver.c
> +++ b/drivers/media/video/msp3400-driver.c
> @@ -283,51 +283,6 @@ void msp_set_scart(struct i2c_client *client, int in, 
> int out)
>                msp_write_dem(client, 0x40, state->i2s_mode);
>  }
>
> -void msp_set_audio(struct i2c_client *client)
> -{
> -       struct msp_state *state = to_state(i2c_get_clientdata(client));
> -       int bal = 0, bass, treble, loudness;
> -       int val = 0;
> -       int reallymuted = state->muted | state->scan_in_progress;
> -
> -       if (!reallymuted)
> -               val = (state->volume * 0x7f / 65535) << 8;
> -
> -       v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n",
> -               state->muted ? "on" : "off",
> -               state->scan_in_progress ? "yes" : "no",
> -               state->volume);
> -
> -       msp_write_dsp(client, 0x, val);
> -       msp_write_dsp(client, 0x0007, reallymuted ? 0x1 : (val | 0x1));
> -       if (state->has_scart2_out_volume)
> -               msp_write_dsp(client, 0x0040, reallymuted ? 0x1 : (val | 
> 0x1));
> -       if (state->has_headphones)
> -               msp_write_dsp(client, 0x0006, val);
> -       if (!state->has_sound_processing)
> -               return;
> -
> -       if (val)
> -               bal = (u8)((state->balance / 256) - 128);
> -       bass = ((state->bass - 32768) * 0x60 / 65535) << 8;
> -       treble = ((state->treble - 32768) * 0x60 / 65535) << 8;
> -       loudness = state->loudness ? ((5 * 4) << 8) : 0;
> -
> -       v4l_dbg(1, msp_debug, client, "balance=%d bass=%d treble=%d 
> loudness=%d\n",
> -               state->balance, state->bass, state->treble, state->loudness);
> -
> -       msp_write_dsp(client, 0x0001, bal << 8);
> -       msp_write_dsp(client, 0x0002, bass);
> -       msp_write_dsp(client, 0x0003, treble);
> -       msp_write_dsp(client, 0x0004, loudness);
> -       if (!state->has_headphones)
> -               return;
> -       msp_write_dsp(client, 0x0030, bal << 8);
> -       msp_write_dsp(client, 0x0031, bass);
> -       msp_write_dsp(client, 0x0032, treble);
> -       msp_write_dsp(client, 0x0033, loudness);
> -}
> -
>  /*  
> */
>
>  static void msp_wake_thread(struct i2c_client *client)
> @@ -363,98 +318,73 @@ int msp_sleep(struct msp_state *state, int timeout)
>
>  /*  
> */
>
> -static int msp_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
> +static int msp_s_ctrl(struct v4l2_ctrl *ctrl)
>  {
> -       struct msp_state *state = to_state(sd);
> +       struct msp_state *state = ctrl_to_state(ctrl);
> +       struct i2c_client *client = v4l2_get_subdevdata(&state->sd);
> +       int val = ctrl->val;
>
>        switch (ctrl->id) {
> -       case V4L2_CID_AUDIO_VOLUME:
> -               ctrl->value = state->volume;
> -               break;
> -
> -       case V4L2_CID_AUDIO_MUTE:
> -               ctrl->value = state->muted;
> -               break;
> -
> -       case V4L2_CID_AUDIO_BALANCE:
> -               if (!state->has_sound_processing)
> -                       return -EINVAL;
> -               ctrl->value = state->balance;
> -               break;
> -
> -       case V4L2_CID_AUDIO_BASS:
> -               if (!state->has_sound_processing)
> -                       return -EINVAL;
> -               ctrl->value = state->bass;
> +       case V4L2_CID_AUDIO_VOLUME: {
> +               /* audio volume cluster */
> +               int reallymuted = state->muted->val | state->scan_in_progress;
> +
> +               if (!reallymuted)
> +                       val = (val * 0x7f / 65535) << 8;
> +
> +               v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s 
> volume=%d\n",
> +                               state->muted->val ? "on" : "off",
> +                               state->scan_in_progress ? "yes" : "no",
> +                               state->volume->val);
> +
> +               msp_write_dsp(client, 0x, val);
> +               msp_write_dsp(client, 0x0007, reallymuted ? 0x1 : (val | 
> 0x1));
> +               if (state->has_scart2_out_volume)
> +                       msp_write_dsp(client, 0x0040, reallymuted ? 0x1 : 
> (val | 0x1));
> +               if (state->has_headphones)
> +                       msp_write_dsp(client, 0x0006, val);
>                break;
> -
> -       case V4L2_CID_AUDIO_TREBLE:
> -               if (!state->has_sound_processing)
> -                       r

Re: [PATCH 05/15] [RFC] saa7115: convert to the new control framework

2010-04-26 Thread David Ellingsworth
On Mon, Apr 26, 2010 at 3:33 AM, Hans Verkuil  wrote:
> Signed-off-by: Hans Verkuil 
> ---
>  drivers/media/video/saa7115.c |  180 
> ++---
>  1 files changed, 80 insertions(+), 100 deletions(-)
>
> diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
> index 72eaa66..8db056f 100644
> --- a/drivers/media/video/saa7115.c
> +++ b/drivers/media/video/saa7115.c
> @@ -45,6 +45,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -65,16 +66,17 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
>
>  struct saa711x_state {
>        struct v4l2_subdev sd;
> +       struct v4l2_ctrl_handler hdl;
> +
> +       /* chroma gain control cluster */
> +       struct v4l2_ctrl *agc;
> +       struct v4l2_ctrl *gain;
> +
>        v4l2_std_id std;
>        int input;
>        int output;
>        int enable;
>        int radio;
> -       int bright;
> -       int contrast;
> -       int hue;
> -       int sat;
> -       int chroma_agc;
>        int width;
>        int height;
>        u32 ident;
> @@ -90,6 +92,11 @@ static inline struct saa711x_state *to_state(struct 
> v4l2_subdev *sd)
>        return container_of(sd, struct saa711x_state, sd);
>  }
>
> +static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
> +{
> +       return &container_of(ctrl->handler, struct saa711x_state, hdl)->sd;
> +}
> +
>  /* --- */
>
>  static inline int saa711x_write(struct v4l2_subdev *sd, u8 reg, u8 value)
> @@ -741,96 +748,53 @@ static int saa711x_s_clock_freq(struct v4l2_subdev *sd, 
> u32 freq)
>        return 0;
>  }
>
> -static int saa711x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
> +static int saa711x_g_ctrl(struct v4l2_ctrl *ctrl)
>  {
> +       struct v4l2_subdev *sd = to_sd(ctrl);
>        struct saa711x_state *state = to_state(sd);
> -       u8 val;
>
>        switch (ctrl->id) {
> -       case V4L2_CID_BRIGHTNESS:
> -               if (ctrl->value < 0 || ctrl->value > 255) {
> -                       v4l2_err(sd, "invalid brightness setting %d\n", 
> ctrl->value);
> -                       return -ERANGE;
> -               }
> -
> -               state->bright = ctrl->value;
> -               saa711x_write(sd, R_0A_LUMA_BRIGHT_CNTL, state->bright);
> -               break;
> -
> -       case V4L2_CID_CONTRAST:
> -               if (ctrl->value < 0 || ctrl->value > 127) {
> -                       v4l2_err(sd, "invalid contrast setting %d\n", 
> ctrl->value);
> -                       return -ERANGE;
> -               }
> -
> -               state->contrast = ctrl->value;
> -               saa711x_write(sd, R_0B_LUMA_CONTRAST_CNTL, state->contrast);
> -               break;
> -
> -       case V4L2_CID_SATURATION:
> -               if (ctrl->value < 0 || ctrl->value > 127) {
> -                       v4l2_err(sd, "invalid saturation setting %d\n", 
> ctrl->value);
> -                       return -ERANGE;
> -               }
> -
> -               state->sat = ctrl->value;
> -               saa711x_write(sd, R_0C_CHROMA_SAT_CNTL, state->sat);
> -               break;
> -
> -       case V4L2_CID_HUE:
> -               if (ctrl->value < -128 || ctrl->value > 127) {
> -                       v4l2_err(sd, "invalid hue setting %d\n", ctrl->value);
> -                       return -ERANGE;
> -               }
> -
> -               state->hue = ctrl->value;
> -               saa711x_write(sd, R_0D_CHROMA_HUE_CNTL, state->hue);
> -               break;
>        case V4L2_CID_CHROMA_AGC:
> -               val = saa711x_read(sd, R_0F_CHROMA_GAIN_CNTL);
> -               state->chroma_agc = ctrl->value;
> -               if (ctrl->value)
> -                       val &= 0x7f;
> -               else
> -                       val |= 0x80;
> -               saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, val);
> +               /* chroma gain cluster */
> +               if (state->agc->cur.val)
> +                       state->gain->cur.val =
> +                               saa711x_read(sd, R_0F_CHROMA_GAIN_CNTL) & 
> 0x7f;
>                break;
> -       case V4L2_CID_CHROMA_GAIN:
> -               /* Chroma gain cannot be set when AGC is enabled */
> -               if (state->chroma_agc == 1)
> -                       return -EINVAL;
> -               saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, ctrl->value | 0x80);
> -               break;
> -       default:
> -               return -EINVAL;
>        }
> -
>        return 0;
>  }
>
> -static int saa711x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
> +static int saa711x_s_ctrl(struct v4l2_ctrl *ctrl)
>  {
> +       struct v4l2_subdev *sd = to_sd(ctrl);
>        struct saa711x_state *state = to_state(sd);
>
>        switch (ctrl->id) {
>        case V4L2_CID_BRIGHTNESS:
> -               ctrl->value = state->bright;
> +               saa711x_write(sd, R_0A_LUMA_BRIGHT_CNTL, ctrl->val);
>         

Re: [PATCH] tm6000: Properly set alternate when preparing to stream

2010-04-26 Thread Stefan Ringel
Am 26.04.2010 16:24, schrieb Mauro Carvalho Chehab:
> Although the code is getting the better alternates, it is not really using
> it. Get the interface/alternate numbers and use it where needed.
>
> This patch implements also one small fix at the last_line set, as 
> proposed by Bee Hock Goh .
>
> Signed-off-by: Mauro Carvalho Chehab 
>   
Hi Mauro,

dvb doesn't build.

  CC [M]  /usr/src/src/tm6010/v4l-dvb/v4l/tm6000-dvb.o
/usr/src/src/tm6010/v4l-dvb/v4l/tm6000-dvb.c: In function
'tm6000_start_stream':
/usr/src/src/tm6010/v4l-dvb/v4l/tm6000-dvb.c:119:9: error: invalid type
argument of '->' (have 'struct tm6000_endpoint')
make[5]: *** [/usr/src/src/tm6010/v4l-dvb/v4l/tm6000-dvb.o] Fehler 1
make[4]: *** [_module_/usr/src/src/tm6010/v4l-dvb/v4l] Fehler 2
make[3]: *** [sub-make] Error 2
make[2]: *** [all] Error 2
make[2]: Leaving directory `/usr/src/linux-2.6.34-rc4-16-obj/x86_64/desktop'
make[1]: *** [default] Fehler 2
make[1]: Leaving directory `/usr/src/src/tm6010/v4l-dvb/v4l'
make: *** [all] Fehler 2


-- 
Stefan Ringel 

--
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: Ticket #5744: Initial tuning to an analogue station fault

2010-04-26 Thread Michael PARKER
All,

I could really do with someone able to interpret the following descriptions 
into a bugfix picking this issue up.

Attached to bug:

> CloseChannel here is called with with the only file descriptor open on the 
> video device. On certain tv cards at least, > closing that single connection 
> will initiate a sleep state of the analogue frontend with loss of all 
> previous 
> tuning detail. In order to fix this, the CloseChannel call is moved to a 
> later point where it is known that the video 
> device has been opened for reading elsewhere.

Contributed by Daniel Kristjansson, MythTv dev:

> It looks like the problem is that the driver is not allowing multiple
> open calls to it's file handle. It should be allowing opens for ioctl's 
> even if it only allows one open for reading.

As I've said previously, I believe the problem relates to the cx8800 
driver/module. It affects users of the Hauppauge HVR-4000 card trying to view 
any of the analogue outputs (RF/S-Video/Composite) through MythTV's "Watch TV" 
function.

A valid patch (to the MythTV source) is attached to the ticket, but the MythTV 
devs are reluctant to apply what's seen as a workaround for an upstream V4L 
issue.

Daniel: If you can provide any additional information, I'd be most grateful if 
you could step in right around now.

Many thanks in advance,

Mike

> -Original Message-
> From: Mike Parker [mailto:michael.par...@st.com] 
> Sent: Friday, April 23, 2010 12:29 PM
> To: 'linux-media@vger.kernel.org'
> Subject: Ticket #5744: Initial tuning to an analogue station fault
> 
> Hi,
> 
> Apologies for the nube ignorance/vagueness but
> 
> I'm seeking a bugfix to (I believe) the cx8800 module, 
> related to an issue I experienced in MythTV 
> (http://svn.mythtv.orgs/trac/ticket/5744). The MythTV devs are 
> reluctant to incorporate the patch attached to the bug since 
> they believe it is a workaround for an upstream V4L issue. 
> Hence my mail to this list.
> 
> The following is a mail written to Gerd Knorr (who I believe 
> to be the the author of the cx8800 driver/module), seeking 
> assistance with this bugfix. At the foot of the email trail 
> is a brief description of what is believed to be the issue 
> (written by Daniel Kristjansson). Having found various 
> statements suggesting Gerd is no longer involved with V4L, I 
> though I'd repost here.
> 
> NB. I've yet to receive confirmation that it is actually the 
> cx8800 module (and not some dependency of the cx8800 module) 
> that requires fixing. All I know is that MythTV reports that 
> it is using the cx8800 driver.
> 
> FYI, I'm picking up the V4L modules from kernel 
> v2.6.32.11-99. My system is running x86_64 Fedora 12. My 
> video capture card is a Hauppague HVR-4000
> 
> Any help anyone can give would be greatly appreciated.
> 
> Mike
> 
> ---
> 
> Gerd,
> 
> Apologies for the direct email, but I'm trying to track down 
> the person responsible for, I believe, the V4L cx8800 driver/module.
> 
> I'm attempting to find a resolution for 
> http://svn.mythtv.org/trac/ticket/5744, an issue which has 
> wasted several hours of my time recently as I've struggled to 
> get live TV in Myth working on my HVR-4000 card.
> 
> As the ticket describes, the MythTV devs are unwilling to 
> integrate this patch as they see it as a workaround for a V4L 
> driver bug (briefly described below by Daniel Kristjansson).
> 
> Are you the correct person to implement a fix for the cx8800 driver?
> 
> NB. As you can doubtless tell from this and previous mails, 
> I'm operating well out of my depth here. I'm just trying to 
> get an issue solved that has cost me time and will probably 
> cost others time in the months/years to come. If you can help 
> in any way to move this issue closer to resolution, I'd be 
> very grateful.
> 
> If you need any information, logs etc. from me, just let me 
> know what I need to do and I'll do my best to provide you 
> with the information you need.
> 
> Obviously, if you're not the correct recipient of this mail, 
> I'd appreciate you passing it onto to whoever you believe to 
> be the correct recipient.
> 
> Best regards,
> 
> Mike
> 
> -Original Message-
> From: Mike Parker [mailto:michael.par...@st.com] 
> Sent: Thursday, April 22, 2010 1:35 PM
> To: 'Daniel Kristjansson'
> Cc: 'Janne'
> Subject: RE: Ticket #5744: Initial tuning to an analogue station fault
> 
> 
> 
> > It looks like the problem is that the driver is not 
> allowing multiple
> > open calls to it's file handle. It should be allowing opens 
> for ioctl's 
> > even if it only allows one open for reading. The driver probably has
> > the name of the person who maintains the driver in it's 
> source files in
> > the copyright notice. Try e-mailing that person. We work with many
> > drivers so we don't want to add special code to interface with each
> > one's quirks unless it's on a limited time basis. When we add a
> > workaround we need the driver name and the version the problem

[PATCH] tm6000: Properly set alternate when preparing to stream

2010-04-26 Thread Mauro Carvalho Chehab
Although the code is getting the better alternates, it is not really using
it. Get the interface/alternate numbers and use it where needed.

This patch implements also one small fix at the last_line set, as 
proposed by Bee Hock Goh .

Signed-off-by: Mauro Carvalho Chehab 
-- 

Cheers,
Mauro
diff --git a/drivers/staging/tm6000/tm6000-cards.c 
b/drivers/staging/tm6000/tm6000-cards.c
index f795a3e..a7e9556 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -634,21 +634,24 @@ err:
 /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
 #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
 
-static void get_max_endpoint (  struct usb_device *usbdev,
-   char *msgtype,
-   struct usb_host_endpoint *curr_e,
-   unsigned int *maxsize,
-   struct usb_host_endpoint **ep  )
+static void get_max_endpoint(struct usb_device *udev,
+struct usb_host_interface *alt,
+char *msgtype,
+struct usb_host_endpoint *curr_e,
+struct tm6000_endpoint *tm_ep)
 {
u16 tmp = le16_to_cpu(curr_e->desc.wMaxPacketSize);
unsigned int size = tmp & 0x7ff;
 
-   if (usbdev->speed == USB_SPEED_HIGH)
+   if (udev->speed == USB_SPEED_HIGH)
size = size * hb_mult (tmp);
 
-   if (size>*maxsize) {
-   *ep = curr_e;
-   *maxsize = size;
+   if (size > tm_ep->maxsize) {
+   tm_ep->endp = curr_e;
+   tm_ep->maxsize = size;
+   tm_ep->bInterfaceNumber = alt->desc.bInterfaceNumber;
+   tm_ep->bAlternateSetting = alt->desc.bAlternateSetting;
+
printk("tm6000: %s endpoint: 0x%02x (max size=%u bytes)\n",
msgtype, curr_e->desc.bEndpointAddress,
size);
@@ -743,24 +746,28 @@ static int tm6000_usb_probe(struct usb_interface 
*interface,
switch (e->desc.bmAttributes) {
case USB_ENDPOINT_XFER_BULK:
if (!dir_out) {
-   get_max_endpoint (usbdev, "Bulk IN", e,
-   &dev->max_bulk_in,
-   &dev->bulk_in);
+   get_max_endpoint(usbdev,
+
&interface->altsetting[i],
+"Bulk IN", e,
+&dev->bulk_in);
} else {
-   get_max_endpoint (usbdev, "Bulk OUT", e,
-   &dev->max_bulk_out,
-   &dev->bulk_out);
+   get_max_endpoint(usbdev,
+
&interface->altsetting[i],
+"Bulk OUT", e,
+&dev->bulk_out);
}
break;
case USB_ENDPOINT_XFER_ISOC:
if (!dir_out) {
-   get_max_endpoint (usbdev, "ISOC IN", e,
-   &dev->max_isoc_in,
-   &dev->isoc_in);
+   get_max_endpoint(usbdev,
+
&interface->altsetting[i],
+"ISOC IN", e,
+&dev->isoc_in);
} else {
-   get_max_endpoint (usbdev, "ISOC OUT", e,
-   &dev->max_isoc_out,
-   &dev->isoc_out);
+   get_max_endpoint(usbdev,
+
&interface->altsetting[i],
+"ISOC OUT", e,
+&dev->isoc_out);
}
break;
}
@@ -775,7 +782,7 @@ static int tm6000_usb_probe(struct usb_interface *interface,
interface->altsetting->desc.bInterfaceNumber);
 
 /* check if the the device has the iso in endpoint at the correct place */
-   if (!dev->isoc_in) {
+   

Re: av7110 and budget_av are broken!

2010-04-26 Thread Mauro Carvalho Chehab
VDR User wrote:
> On Wed, Apr 21, 2010 at 2:44 AM, Oliver Endriss  wrote:
>>> It's merged in Mauro's fixes tree, but I don't think those pending patches
>>> have been pushed upstream yet. Mauro, can you verify this? They should be
>>> pushed to 2.6.34!
>> What about the HG driver?
>> The v4l-dvb HG repository is broken for 7 weeks...
> 
> It doesn't make any sense why someone would break a driver and then
> leave it that way for such a long period of time.  Yes, please fix the
> HG repository. 

You need to ask Douglas about -hg issues. He is the actual maintainer of that 
tree.
It is probably a good idea to merge also from fixes.git tree, but this may make
his sync process more complicated, so, it is up to him to decide how to do it.

I still thinking on having a better way to have those fixes patches merged 
earlier
on -git, but I'll need to have some time to do some scripting and test some 
things.

> I don't actually know anyone who bothers with the git
> tree for obvious reasons

About half of the developers are submitting git requests, so it seems that
there are people using it.

-- 

Cheers,
Mauro
--
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] tm6000 fix i2c

2010-04-26 Thread Mauro Carvalho Chehab
Hi Dmitri,

Dmitri Belimov wrote:
> Hi 
> 
> Rework last I2C patch.
> Set correct limit for I2C packet.
> Use different method for the tm5600/tm6000 and tm6010 to read word.
> 
> Try this patch.
> 
> diff -r 7c0b887911cf linux/drivers/staging/tm6000/tm6000-i2c.c
> --- a/linux/drivers/staging/tm6000/tm6000-i2c.c   Mon Apr 05 22:56:43 
> 2010 -0400
> +++ b/linux/drivers/staging/tm6000/tm6000-i2c.c   Mon Apr 26 04:15:56 
> 2010 +1000
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include 

You probably don't need this.

>  
>  #include "compat.h"
>  #include "tm6000.h"
> @@ -45,11 +46,49 @@
>   printk(KERN_DEBUG "%s at %s: " fmt, \
>   dev->name, __FUNCTION__ , ##args); } while (0)
>  
> +static void tm6000_i2c_reset(struct tm6000_core *dev)
> +{
> + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_CLK, 0);
> + msleep(15);
> + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_CLK, 1);
> + msleep(15);
> +}
> +
>  static int tm6000_i2c_send_regs(struct tm6000_core *dev, unsigned char addr,
>   __u8 reg, char *buf, int len)
>  {
> - return tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR | 
> USB_RECIP_DEVICE,
> - REQ_16_SET_GET_I2C_WR1_RDN, addr | reg << 8, 0, buf, len);
> + int rc;
> + unsigned int tsleep;
> + unsigned int i2c_packet_limit = 16;
> +
> + if (dev->dev_type == TM6010)
> + i2c_packet_limit = 64;
> +
> + if (!buf)
> + return -1;
> +
> + if (len < 1 || len > i2c_packet_limit){
> + printk("Incorrect lenght of i2c packet = %d, limit set to %d\n",
> + len, i2c_packet_limit);
> + return -1;
> + }
> +
> + /* capture mutex */
> + rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
> + USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> + addr | reg << 8, 0, buf, len);
> +
> + if (rc < 0) {
> + /* release mutex */
> + return rc;
> + }
> +
> + /* Calculate delay time, 14000us for 64 bytes */
> + tsleep = ((len * 200) + 200 + 1000) / 1000;
> + msleep(tsleep);
> +
> + /* release mutex */
> + return rc;
>  }
>  
>  /* Generic read - doesn't work fine with 16bit registers */
> @@ -58,23 +97,41 @@
>  {
>   int rc;
>   u8 b[2];
> + unsigned int i2c_packet_limit = 16;
>  
> - if ((dev->caps.has_zl10353) && (dev->demod_addr << 1 == addr) && (reg % 
> 2 == 0)) {
> + if (dev->dev_type == TM6010)
> + i2c_packet_limit = 64;
> +
> + if (!buf)
> + return -1;
> +
> + if (len < 1 || len > i2c_packet_limit){
> + printk("Incorrect lenght of i2c packet = %d, limit set to %d\n",
> + len, i2c_packet_limit);
> + return -1;
> + }
> +
> + /* capture mutex */
> + if ((dev->caps.has_zl10353) && (dev->demod_addr << 1 == addr)
> + && (reg % 2 == 0)) {
>   /*
>* Workaround an I2C bug when reading from zl10353
>*/
>   reg -= 1;
>   len += 1;
>  
> - rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR | 
> USB_RECIP_DEVICE,
> - REQ_16_SET_GET_I2C_WR1_RDN, addr | reg << 8, 0, b, len);
> + rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR |
> + USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> + addr | reg << 8, 0, b, len);
>  
>   *buf = b[1];
>   } else {
> - rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR | 
> USB_RECIP_DEVICE,
> - REQ_16_SET_GET_I2C_WR1_RDN, addr | reg << 8, 0, buf, 
> len);
> + rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR |
> + USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> + addr | reg << 8, 0, buf, len);
>   }
>  
> + /* release mutex */
>   return rc;
>  }
>  
> @@ -85,8 +142,137 @@
>  static int tm6000_i2c_recv_regs16(struct tm6000_core *dev, unsigned char 
> addr,
> __u16 reg, char *buf, int len)
>  {
> - return tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR | 
> USB_RECIP_DEVICE,
> - REQ_14_SET_GET_I2C_WR2_RDN, addr, reg, buf, len);
> + int rc;
> + unsigned char ureg;
> +
> + if (!buf || len != 2)
> + return -1;
> +
> + /* capture mutex */
> + if (dev->dev_type == TM6010){
> + ureg = reg & 0xFF;
> + rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
> + USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> + addr | (reg & 0xFF00), 0, &ureg, 1);
> +
> + if (rc < 0) {
> + /* release mutex */
> + return rc;
> + }
> +
> + msleep(1400 / 1000);
> + rc = tm6000_rea

Re: [PATCH] tm6000 fix i2c

2010-04-26 Thread Bee Hock Goh
thanks. This is work fine on my tm5600.

btw, can you use the git tree? There is some codes update from Stefan
there for the tm6000-i2c that is still not sync with hg.

On Mon, Apr 26, 2010 at 8:25 AM, Dmitri Belimov  wrote:
> Hi
>
> Rework last I2C patch.
> Set correct limit for I2C packet.
> Use different method for the tm5600/tm6000 and tm6010 to read word.
>
> Try this patch.
>
> diff -r 7c0b887911cf linux/drivers/staging/tm6000/tm6000-i2c.c
> --- a/linux/drivers/staging/tm6000/tm6000-i2c.c Mon Apr 05 22:56:43 2010 -0400
> +++ b/linux/drivers/staging/tm6000/tm6000-i2c.c Mon Apr 26 04:15:56 2010 +1000
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include "compat.h"
>  #include "tm6000.h"
> @@ -45,11 +46,49 @@
>                        printk(KERN_DEBUG "%s at %s: " fmt, \
>                        dev->name, __FUNCTION__ , ##args); } while (0)
>
> +static void tm6000_i2c_reset(struct tm6000_core *dev)
> +{
> +       tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_CLK, 0);
> +       msleep(15);
> +       tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_CLK, 1);
> +       msleep(15);
> +}
> +
>  static int tm6000_i2c_send_regs(struct tm6000_core *dev, unsigned char addr,
>                                __u8 reg, char *buf, int len)
>  {
> -       return tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR | 
> USB_RECIP_DEVICE,
> -               REQ_16_SET_GET_I2C_WR1_RDN, addr | reg << 8, 0, buf, len);
> +       int rc;
> +       unsigned int tsleep;
> +       unsigned int i2c_packet_limit = 16;
> +
> +       if (dev->dev_type == TM6010)
> +               i2c_packet_limit = 64;
> +
> +       if (!buf)
> +               return -1;
> +
> +       if (len < 1 || len > i2c_packet_limit){
> +               printk("Incorrect lenght of i2c packet = %d, limit set to 
> %d\n",
> +                       len, i2c_packet_limit);
> +               return -1;
> +       }
> +
> +       /* capture mutex */
> +       rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
> +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> +               addr | reg << 8, 0, buf, len);
> +
> +       if (rc < 0) {
> +               /* release mutex */
> +               return rc;
> +       }
> +
> +       /* Calculate delay time, 14000us for 64 bytes */
> +       tsleep = ((len * 200) + 200 + 1000) / 1000;
> +       msleep(tsleep);
> +
> +       /* release mutex */
> +       return rc;
>  }
>
>  /* Generic read - doesn't work fine with 16bit registers */
> @@ -58,23 +97,41 @@
>  {
>        int rc;
>        u8 b[2];
> +       unsigned int i2c_packet_limit = 16;
>
> -       if ((dev->caps.has_zl10353) && (dev->demod_addr << 1 == addr) && (reg 
> % 2 == 0)) {
> +       if (dev->dev_type == TM6010)
> +               i2c_packet_limit = 64;
> +
> +       if (!buf)
> +               return -1;
> +
> +       if (len < 1 || len > i2c_packet_limit){
> +               printk("Incorrect lenght of i2c packet = %d, limit set to 
> %d\n",
> +                       len, i2c_packet_limit);
> +               return -1;
> +       }
> +
> +       /* capture mutex */
> +       if ((dev->caps.has_zl10353) && (dev->demod_addr << 1 == addr)
> +       && (reg % 2 == 0)) {
>                /*
>                 * Workaround an I2C bug when reading from zl10353
>                 */
>                reg -= 1;
>                len += 1;
>
> -               rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR 
> | USB_RECIP_DEVICE,
> -                       REQ_16_SET_GET_I2C_WR1_RDN, addr | reg << 8, 0, b, 
> len);
> +               rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR |
> +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> +               addr | reg << 8, 0, b, len);
>
>                *buf = b[1];
>        } else {
> -               rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR 
> | USB_RECIP_DEVICE,
> -                       REQ_16_SET_GET_I2C_WR1_RDN, addr | reg << 8, 0, buf, 
> len);
> +               rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR |
> +               USB_RECIP_DEVICE, REQ_16_SET_GET_I2C_WR1_RDN,
> +               addr | reg << 8, 0, buf, len);
>        }
>
> +       /* release mutex */
>        return rc;
>  }
>
> @@ -85,8 +142,137 @@
>  static int tm6000_i2c_recv_regs16(struct tm6000_core *dev, unsigned char 
> addr,
>                                  __u16 reg, char *buf, int len)
>  {
> -       return tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR | 
> USB_RECIP_DEVICE,
> -               REQ_14_SET_GET_I2C_WR2_RDN, addr, reg, buf, len);
> +       int rc;
> +       unsigned char ureg;
> +
> +       if (!buf || len != 2)
> +               return -1;
> +
> +       /* capture mutex */
> +       if (dev->dev_type == TM6010){
> +               ureg = reg & 0xFF;
> +               rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR 
> |
> +                       USB_RECIP_DEVICE, REQ_16_SET

Re: Kworld Plus TV Hybrid PCI (DVB-T 210SE)

2010-04-26 Thread 0123peter
on Fri, 16 Apr 2010 09:50 am
in the Usenet newsgroup gmane.linux.drivers.video-input-infrastructure
hermann pitton wrote:


> Hi Peter,
> 
> Am Donnerstag, den 15.04.2010, 23:30 +1000 schrieb 0123pe...@gmail.com:
>> on Thu, 15 Apr 2010 01:32 pm
>> in the Usenet newsgroup gmane.linux.drivers.video-input-infrastructure
>> hermann pitton wrote:
>> 
>> > Hi,
>> > 
>> > to be honest, there is a little too much delay on those reports.
>> 
>> I have been very slow, sorry.  
> 
> no problem, but it becomes also a little hard to me to recap the issues.
> 
> As said, Hartmut had the best pointers I guess.
> 
>> >> > did not even notice a problem with Trent's prior patch.
>> >> > The same is also at vivi.
>> >> > 
>> >> >> Should I have a file called /etc/modprobe.d/TVanywhereAD 
>> >> >> that contains the line, 
>> >> >> 
>> >> >> options saa7134 card=94 gpio_tracking i2c_debug=1
>> >> >> 
>> >> >> and then watch the command line output of "kaffeine"?  
>> >> 
>> >> I've found a GUI that allows tweaking lots of module parameters 
>> >> that I have never heard of.  Card=94 in the config file, 
>> >> gpio_tracking and i2c_debug are set to "1" in the GUI.  
>> >> 
>> >> Strange things are appearing in dmesg and syslog.  I assume that 
>> >> [snip]
>> >> saa7133[0]: i2c eeprom f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> >> i2c-adapter i2c-0: Invalid 7-bit address 0x7a
>> >> saa7133[0]: i2c xfer: < 8e ERROR: NO_DEVICE
>> >> [snip]
>> >> is significant.  
>> > 
>> > No, not at all for my knowledge.
>> 
>> Unsurprisingly, that just highlights my ignorance.  
>> 
>> >> > If you want to produce debug output for failing firmware loading from
>> >> > file after a cold boot, yes, you might eventually be able to see that
>> >> > failing tuner initialization brings down i2c.
>> >> > 
>> >> > If it is a additional new regression, then mercurial bisect can find the
>> >> > patch in question fairly quick.
>> >> 
>> >> That sounds like something that I should be able to do, if only 
>> >> I'd read the instructions.  
>> > 
>> > It is totally up to you and all others with that hardware.
>> 
>> Can you provide a like for where to start reading?
> 
> README.patches.  
> 
>  Part III - Best Practices
>   1. Community best practices
>   2. Mercurial specific procedures
>   3. Knowing about newer patches committed at the development repositories
>   4. Patch submission from the community
>   5. Identifying regressions with Mercurial

I have not found the file README.patches.  

>> > Since already in some multiple broken conditions, never working without
>> > flaws previously, I would suggest not to wait any longer, until some
>> > sort of hadron collider is available ...
>> 
>> Now I'm discouraged.  It might be a better use of my time to do 
>> something else - anything else.  Maybe I'll just put it in a box 
>> for a year and see what happens.  
> 
> I (un)fortunately ;) don't have such hardware and Hartmut did not have
> any at that time either.
> 
> Don't just wait, also no need to hurry on next day.
> 
> If the problem is described well, someone can take it as a challenge to
> work on it. We indeed had people from CERN fixing tuners.
> 
> Trying to recap.

I have allowed things to get confused.  

> You have been interested to add the card to auto detection, but firmware
> load was only successful in one of three cases only already that time
> and we have not been aware of that flaw in the beginning.

I am not the original poster.  

When a link was posted that mentioned one of my cards 
(an MSI t...@nywhere A/D) I said, "Aha".  

Because there was a different, working, card next to it, problems 
with the MSI were less obvious than they should have been.  

In retrospect, the MSI has not worked at all for a long time and 
might have always been a little bit unreliable.  

I have not noticed a one-in-three firmware load failure on the MSI.  
That would have been the original poster about his Kworld.  
Although I did post a bit of dmesg that I thought might be relevant.  

> Hartmut assumed later, on such a card is some locking protection needed
> during the firmware load, and my guess is the longish tuner
> initialization sequence gets corrupted, because of that missing locking,
> and all goes doom. (at least well known on all of such before any
> support for the tda8275a)
> 
> Now, improved, only one of ten tries loads the firmware and keeps the
> card in a responding state. That is of course also very unpleasant for
> using mercurial bisect, I really do admit.
> 
> Also, as reported too now, with two of such kind of cards in one
> machine, likely better don't try at all.

My MSI tuner is currently in a test computer with no other tuner cards.  

> OTOH, the m$ driver obviously does manage to load the firmware even for
> multiple such cards. (but maybe breaks all others ...)
> 
> Which doesn't help us, since rebooting after that only hides our
> problem.
> 
> Those cards following the Philips/NXP/Trid

Re: [PATCH v3 2/3] v4l: videobuf: Add support for V4L2_BUF_FLAG_ERROR

2010-04-26 Thread Laurent Pinchart
Hi Pavel,

On Thursday 22 April 2010 11:35:35 Pawel Osciak wrote:
> >Laurent Pinchart 
> >On Wednesday 21 April 2010 13:39:44 Pawel Osciak wrote:
> >> @@ -679,23 +682,20 @@ int videobuf_dqbuf(struct videobuf_queue *q,
> >> 
> >>switch (buf->state) {
> >>
> >>case VIDEOBUF_ERROR:
> >>dprintk(1, "dqbuf: state is error\n");
> >> 
> >> -  retval = -EIO;
> >> -  CALL(q, sync, q, buf);
> >> -  buf->state = VIDEOBUF_IDLE;
> >> 
> >>break;
> >>
> >>case VIDEOBUF_DONE:
> >>dprintk(1, "dqbuf: state is done\n");
> >> 
> >> -  CALL(q, sync, q, buf);
> >> -  buf->state = VIDEOBUF_IDLE;
> >> 
> >>break;
> >>
> >>default:
> >>dprintk(1, "dqbuf: state invalid\n");
> >>retval = -EINVAL;
> >>goto done;
> >>
> >>}
> >> 
> >> -  list_del(&buf->stream);
> >> -  memset(b, 0, sizeof(*b));
> >> +  CALL(q, sync, q, buf);
> >> 
> >>videobuf_status(q, b, buf, q->type);
> >> 
> >> +  list_del(&buf->stream);
> >> +  buf->state = VIDEOBUF_IDLE;
> >> +  b->flags &= ~V4L2_BUF_FLAG_DONE;
> >
> >We do you clear the done flag here ?
> 
> The DONE flag is supposed to be cleared when dequeuing, but should
> be set when querying:
> 
> "When this flag is set, the buffer is currently on the outgoing queue,
> ready to be dequeued from the driver. Drivers set or clear this flag
> when the VIDIOC_QUERYBUF  ioctl is called. After calling the VIDIOC_QBUF
> or VIDIOC_DQBUF it is always cleared."
> 
> videobuf_status() is used for both QUERYBUF and DQBUF and making both
> work properly is not very straightforward without losing
> VIDEOBUF_DONE/VIDEOBUF_ERROR distinction (it becomes more clear when you
> analyze both cases).
> 
> My previous patch was doing it the other way around, but Hans' version
> seemed shorter and cleaner.

Thanks for pointing this out.

I have no more objection then,

Acked-by: Laurent Pinchart 

-- 
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: Re: Fw: PROBLEM: linux server halts while restarting VLC

2010-04-26 Thread Alexander Kolesnik
Hello.

> The issue happens if VLC process hasn't been unloaded before executing
> another  instance.  In  this  case  killall  command  did  not work as
> supposed.

This  appears  not  to be true. Today the server halted while starting
VLC first time. Will try to reload bttv modules before starting VLC.

--
Best regards,
Alexander

--
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: Doing a stable v4l-utils release

2010-04-26 Thread Hans Verkuil
On Monday 26 April 2010 09:35:23 Hans de Goede wrote:
> Hi all,
> 
> Currently v4l-utils is at version 0.7.91, which as the version
> suggests is meant as a beta release.
> 
> As this release seems to be working well I would like to do
> a v4l-utils-0.8.0 release soon. This is a headsup, to give
> people a chance to notify me of any bugs they would like to
> see fixed first / any patches they would like to add first.

This is a good opportunity to mention that I would like to run checkpatch
over the libs and clean them up.

I also know that there is a bug in the control handling code w.r.t.
V4L2_CTRL_FLAG_NEXT_CTRL. I have a patch, but I'd like to do the clean up
first.

If no one else has major patch series that they need to apply, then I can
start working on this. The clean up is just purely whitespace changes to
improve readability, no functionality will be touched.

Regards,

Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG, part of Cisco
--
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: faulty pac3711

2010-04-26 Thread Hans de Goede

Hi,

make sure you're using the camera together with apps which are using
libv4l, such as cheese.

Regards,

Hans


On 04/25/2010 08:39 PM, skjel...@robin.no wrote:

Hi!
I'd have an Exibel snakescope TF2808 which dont make any picure on
Linux. It worked ok on windows, but I do not have windows installed any
longer. I do not think there have happened something to the camera
meanwhile, I'd think the camera is OK. The driver seems to be ok too:

(part of messages)
Apr 25 19:43:16 sigmund-laptop kernel: [ 20.967903] gspca: main v2.6.0
registered
Apr 25 19:43:16 sigmund-laptop kernel: [ 21.214190] gspca: probing
093a:2620
Apr 25 19:43:16 sigmund-laptop kernel: [ 21.287398] gspca: probe ok
Apr 25 19:43:16 sigmund-laptop kernel: [ 21.287416] gspca: probing
093a:2620
Apr 25 19:43:16 sigmund-laptop kernel: [ 21.287431] gspca: probing
093a:2620
Apr 25 19:43:16 sigmund-laptop kernel: [ 21.287457] usbcore: registered
new interface driver pac7311
Apr 25 19:43:16 sigmund-laptop kernel: [ 21.287462] pac7311: registered

I'd have tried tvtime and xawtv as viewing application, same result on
both; blank screen and various error messages.

tvtime comes up with an blue screen "no signal","Frames too short from
pac7311" and "cannot open capture device /dev/video0".

xawtv started from an terminal outputs this and hangs:
sigm...@sigmund-laptop:~$ xawtv -device /dev/video0
This is xawtv-3.95.dfsg.1, running on Linux/i686 (2.6.31-20-generic)
xinerama 0: 1400x1050+0+0
WARNING: No DGA direct video mode for this display.
/dev/video0 [v4l2]: no overlay support
v4l-conf had some trouble, trying to continue anyway
Warning: Missing charsets in String to FontSet conversion
Warning: Cannot convert string
"-*-lucidatypewriter-bold-r-normal-*-14-*-*-*-m-*-iso8859-*,
-*-courier-bold-r-normal-*-14-*-*-*-m-*-iso8859-*,
-gnu-unifont-bold-r-normal--16-*-*-*-c-*-*-*,
-efont-biwidth-bold-r-normal--16-*-*-*-*-*-*-*,
-*-*-bold-r-normal-*-16-*-*-*-m-*-*-*,
-*-*-bold-r-normal-*-16-*-*-*-c-*-*-*, -*-*-*-*-*-*-16-*-*-*-*-*-*-*,*"
to type FontSet
Warning: Cannot convert string
"-*-ledfixed-medium-r-*--39-*-*-*-c-*-*-*" to type FontStruct
Warning: Missing charsets in String to FontSet conversion
Warning: Cannot convert string
"-*-lucidatypewriter-bold-r-normal-*-14-*-*-*-m-*-iso8859-*,
-*-courier-bold-r-normal-*-14-*-*-*-m-*-iso8859-*,
-gnu-unifont-bold-r-normal--16-*-*-*-c-*-*-*,
-efont-biwidth-bold-r-normal--16-*-*-*-*-*-*-*,
-*-*-bold-r-normal-*-16-*-*-*-m-*-*-*,
-*-*-bold-r-normal-*-16-*-*-*-c-*-*-*, -*-*-*-*-*-*-16-*-*-*-*-*-*-*, *"
to type FontSet
ioctl: VIDIOC_G_STD(std=0xb789b1d000971326
[PAL_B1,PAL_G,PAL_D,PAL_M,PAL_N,NTSC_M,SECAM_B,SECAM_D,SECAM_G,SECAM_K,?ATSC_8_VSB,(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)]):

end of xawtv output
syslog also came up with two new lines:
Apr 25 20:30:22 sigmund-laptop kernel: [ 2848.327067] gspca:
usb_submit_urb [0] err -28
Apr 25 20:30:23 sigmund-laptop kernel: [ 2848.607073] gspca:
usb_submit_urb [0] err -28

Tried an Creative Live! cam on the same machine and it works ok.

sigm...@sigmund-laptop:~$ uname -a
Linux sigmund-laptop 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12
05:23:09 UTC 2010 i686 GNU/Linux

I do not have any idea nor what to do now, nor how the error could be
further traced down. Hopefully there's somebody on the list who can help
me.

Cincerely,
Sigmund Skjelnes


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

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


Re: Xawtv version 3.96

2010-04-26 Thread Hans de Goede

Hi,

On 04/23/2010 05:18 PM, Chicken Shack wrote:


It would make much more sense to complete (or at least try to complete)
xawtv 4.0 pre instead of fixing bugs in 3.96.

Reasons why?

1. 4.0 pre contains more innovation, new ideas.
2. 3.96 s analogue only, not DVB.
3. Both the analogue AND the DVB driver development section do need
reference applications for driver development: 4.0 pre contains BOTH:
reference apps for analogue AND DVB driver development.



We're currently mainly working on collecting distro patches for 3.xx so
as to have a 3.xx upstream with all known issues fixed, and to have a
source of xawtv-3.xx which will work out of the box on recent distro's

When setting up 3.xx git, we've also set up a 4.xx git, so that
interested parties can work on it. As you seem interested, feel free
to submit patches and / or apply for direct commit access to 4.xx git.

Regards,

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


[PATCH 15/15] [RFC] ivtv: convert to the new control framework

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/ivtv/ivtv-controls.c |  275 --
 drivers/media/video/ivtv/ivtv-controls.h |6 +-
 drivers/media/video/ivtv/ivtv-driver.c   |   18 ++-
 drivers/media/video/ivtv/ivtv-driver.h   |5 +-
 drivers/media/video/ivtv/ivtv-fileops.c  |   23 +--
 drivers/media/video/ivtv/ivtv-firmware.c |6 +-
 drivers/media/video/ivtv/ivtv-ioctl.c|   31 ++--
 drivers/media/video/ivtv/ivtv-streams.c  |   20 ++-
 8 files changed, 86 insertions(+), 298 deletions(-)

diff --git a/drivers/media/video/ivtv/ivtv-controls.c 
b/drivers/media/video/ivtv/ivtv-controls.c
index 4a9c8ce..57f74c2 100644
--- a/drivers/media/video/ivtv/ivtv-controls.c
+++ b/drivers/media/video/ivtv/ivtv-controls.c
@@ -17,162 +17,14 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#include 
 
 #include "ivtv-driver.h"
-#include "ivtv-cards.h"
 #include "ivtv-ioctl.h"
-#include "ivtv-routing.h"
-#include "ivtv-i2c.h"
-#include "ivtv-mailbox.h"
 #include "ivtv-controls.h"
 
-/* Must be sorted from low to high control ID! */
-static const u32 user_ctrls[] = {
-   V4L2_CID_USER_CLASS,
-   V4L2_CID_BRIGHTNESS,
-   V4L2_CID_CONTRAST,
-   V4L2_CID_SATURATION,
-   V4L2_CID_HUE,
-   V4L2_CID_AUDIO_VOLUME,
-   V4L2_CID_AUDIO_BALANCE,
-   V4L2_CID_AUDIO_BASS,
-   V4L2_CID_AUDIO_TREBLE,
-   V4L2_CID_AUDIO_MUTE,
-   V4L2_CID_AUDIO_LOUDNESS,
-   0
-};
-
-static const u32 *ctrl_classes[] = {
-   user_ctrls,
-   cx2341x_mpeg_ctrls,
-   NULL
-};
-
-
-int ivtv_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl)
-{
-   struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
-   const char *name;
-
-   qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
-   if (qctrl->id == 0)
-   return -EINVAL;
-
-   switch (qctrl->id) {
-   /* Standard V4L2 controls */
-   case V4L2_CID_USER_CLASS:
-   return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0);
-   case V4L2_CID_BRIGHTNESS:
-   case V4L2_CID_HUE:
-   case V4L2_CID_SATURATION:
-   case V4L2_CID_CONTRAST:
-   if (v4l2_subdev_call(itv->sd_video, core, queryctrl, qctrl))
-   qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
-   return 0;
-
-   case V4L2_CID_AUDIO_VOLUME:
-   case V4L2_CID_AUDIO_MUTE:
-   case V4L2_CID_AUDIO_BALANCE:
-   case V4L2_CID_AUDIO_BASS:
-   case V4L2_CID_AUDIO_TREBLE:
-   case V4L2_CID_AUDIO_LOUDNESS:
-   if (v4l2_subdev_call(itv->sd_audio, core, queryctrl, qctrl))
-   qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
-   return 0;
-
-   default:
-   if (cx2341x_ctrl_query(&itv->params, qctrl))
-   qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
-   return 0;
-   }
-   strncpy(qctrl->name, name, sizeof(qctrl->name) - 1);
-   qctrl->name[sizeof(qctrl->name) - 1] = 0;
-   return 0;
-}
-
-int ivtv_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qmenu)
-{
-   struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
-   struct v4l2_queryctrl qctrl;
-
-   qctrl.id = qmenu->id;
-   ivtv_queryctrl(file, fh, &qctrl);
-   return v4l2_ctrl_query_menu(qmenu, &qctrl,
-   cx2341x_ctrl_get_menu(&itv->params, qmenu->id));
-}
-
-static int ivtv_try_ctrl(struct file *file, void *fh,
-   struct v4l2_ext_control *vctrl)
-{
-   struct v4l2_queryctrl qctrl;
-   const char **menu_items = NULL;
-   int err;
-
-   qctrl.id = vctrl->id;
-   err = ivtv_queryctrl(file, fh, &qctrl);
-   if (err)
-   return err;
-   if (qctrl.type == V4L2_CTRL_TYPE_MENU)
-   menu_items = v4l2_ctrl_get_menu(qctrl.id);
-   return v4l2_ctrl_check(vctrl, &qctrl, menu_items);
-}
-
-static int ivtv_s_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
-{
-   switch (vctrl->id) {
-   /* Standard V4L2 controls */
-   case V4L2_CID_BRIGHTNESS:
-   case V4L2_CID_HUE:
-   case V4L2_CID_SATURATION:
-   case V4L2_CID_CONTRAST:
-   return v4l2_subdev_call(itv->sd_video, core, s_ctrl, vctrl);
-
-   case V4L2_CID_AUDIO_VOLUME:
-   case V4L2_CID_AUDIO_MUTE:
-   case V4L2_CID_AUDIO_BALANCE:
-   case V4L2_CID_AUDIO_BASS:
-   case V4L2_CID_AUDIO_TREBLE:
-   case V4L2_CID_AUDIO_LOUDNESS:
-   return v4l2_subdev_call(itv->sd_audio, core, s_ctrl, vctrl);
-
-   default:
-   IVTV_DEBUG_IOCTL("invalid control 0x%x\n", vctrl->id);
-   return -EINVAL;
-   }
-   return 0;
-}
-
-static int ivtv_g_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
+static int ivtv_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)
 {
-   switch (vctrl->id) {
- 

[PATCH 13/15] [RFC] wm8739: convert to the new control framework

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/wm8739.c |  176 ++
 1 files changed, 59 insertions(+), 117 deletions(-)

diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index b572ce2..fe77086 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -26,11 +26,11 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 MODULE_DESCRIPTION("wm8739 driver");
 MODULE_AUTHOR("T. Adachi, Hans Verkuil");
@@ -53,12 +53,11 @@ enum {
 
 struct wm8739_state {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+   struct v4l2_ctrl *volume;
+   struct v4l2_ctrl *mute;
+   struct v4l2_ctrl *balance;
u32 clock_freq;
-   u8 muted;
-   u16 volume;
-   u16 balance;
-   u8 vol_l;   /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
-   u8 vol_r;   /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
 };
 
 static inline struct wm8739_state *to_state(struct v4l2_subdev *sd)
@@ -66,6 +65,11 @@ static inline struct wm8739_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct wm8739_state, sd);
 }
 
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return &container_of(ctrl->handler, struct wm8739_state, hdl)->sd;
+}
+
 /*  */
 
 static int wm8739_write(struct v4l2_subdev *sd, int reg, u16 val)
@@ -88,58 +92,17 @@ static int wm8739_write(struct v4l2_subdev *sd, int reg, 
u16 val)
return -1;
 }
 
-/* write regs to set audio volume etc */
-static void wm8739_set_audio(struct v4l2_subdev *sd)
-{
-   struct wm8739_state *state = to_state(sd);
-   u16 mute = state->muted ? 0x80 : 0;
-
-   /* Volume setting: bits 0-4, 0x1f = 12 dB, 0x00 = -34.5 dB
-* Default setting: 0x17 = 0 dB
-*/
-   wm8739_write(sd, R0, (state->vol_l & 0x1f) | mute);
-   wm8739_write(sd, R1, (state->vol_r & 0x1f) | mute);
-}
-
-static int wm8739_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct wm8739_state *state = to_state(sd);
-
-   switch (ctrl->id) {
-   case V4L2_CID_AUDIO_MUTE:
-   ctrl->value = state->muted;
-   break;
-
-   case V4L2_CID_AUDIO_VOLUME:
-   ctrl->value = state->volume;
-   break;
-
-   case V4L2_CID_AUDIO_BALANCE:
-   ctrl->value = state->balance;
-   break;
-
-   default:
-   return -EINVAL;
-   }
-   return 0;
-}
-
-static int wm8739_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int wm8739_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct wm8739_state *state = to_state(sd);
unsigned int work_l, work_r;
+   u8 vol_l;   /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
+   u8 vol_r;   /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
+   u16 mute;
 
switch (ctrl->id) {
-   case V4L2_CID_AUDIO_MUTE:
-   state->muted = ctrl->value;
-   break;
-
case V4L2_CID_AUDIO_VOLUME:
-   state->volume = ctrl->value;
-   break;
-
-   case V4L2_CID_AUDIO_BALANCE:
-   state->balance = ctrl->value;
break;
 
default:
@@ -147,52 +110,25 @@ static int wm8739_s_ctrl(struct v4l2_subdev *sd, struct 
v4l2_control *ctrl)
}
 
/* normalize ( 65535 to 0 -> 31 to 0 (12dB to -34.5dB) ) */
-   work_l = (min(65536 - state->balance, 32768) * state->volume) / 32768;
-   work_r = (min(state->balance, (u16)32768) * state->volume) / 32768;
+   work_l = (min(65536 - state->balance->val, 32768) * state->volume->val) 
/ 32768;
+   work_r = (min(state->balance->val, 32768) * state->volume->val) / 32768;
 
-   state->vol_l = (long)work_l * 31 / 65535;
-   state->vol_r = (long)work_r * 31 / 65535;
+   vol_l = (long)work_l * 31 / 65535;
+   vol_r = (long)work_r * 31 / 65535;
 
/* set audio volume etc. */
-   wm8739_set_audio(sd);
+   mute = state->mute->val ? 0x80 : 0;
+
+   /* Volume setting: bits 0-4, 0x1f = 12 dB, 0x00 = -34.5 dB
+* Default setting: 0x17 = 0 dB
+*/
+   wm8739_write(sd, R0, (vol_l & 0x1f) | mute);
+   wm8739_write(sd, R1, (vol_r & 0x1f) | mute);
return 0;
 }
 
 /*  */
 
-static struct v4l2_queryctrl wm8739_qctrl[] = {
-   {
-   .id= V4L2_CID_AUDIO_VOLUME,
-   .name  = "Volume",
-   .minimum   = 0,
-   .maximum   = 65535,
-   .step  = 65535/100,
-   .default_value = 58880,
-   .flags = 0,
-   .type  = V4L2_CTRL_TYPE_INTEGER,
-   }, {
-  

[PATCH 14/15] [RFC] ivtv: convert gpio subdev to new control framework.

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/ivtv/ivtv-driver.c |1 +
 drivers/media/video/ivtv/ivtv-driver.h |1 +
 drivers/media/video/ivtv/ivtv-gpio.c   |   77 +++-
 3 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 85aab0e..1232d92 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -1370,6 +1370,7 @@ static void ivtv_remove(struct pci_dev *pdev)
printk(KERN_INFO "ivtv: Removed %s\n", itv->card_name);
 
v4l2_device_unregister(&itv->v4l2_dev);
+   v4l2_ctrl_handler_free(&itv->hdl_gpio);
kfree(itv);
 }
 
diff --git a/drivers/media/video/ivtv/ivtv-driver.h 
b/drivers/media/video/ivtv/ivtv-driver.h
index bf05c34..0a85705 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -622,6 +622,7 @@ struct ivtv {
 
struct v4l2_device v4l2_dev;
struct v4l2_subdev sd_gpio; /* GPIO sub-device */
+   struct v4l2_ctrl_handler hdl_gpio;
u16 instance;
 
/* High-level state info */
diff --git a/drivers/media/video/ivtv/ivtv-gpio.c 
b/drivers/media/video/ivtv/ivtv-gpio.c
index aede061..463d58f 100644
--- a/drivers/media/video/ivtv/ivtv-gpio.c
+++ b/drivers/media/video/ivtv/ivtv-gpio.c
@@ -24,6 +24,7 @@
 #include "ivtv-gpio.h"
 #include "tuner-xc2028.h"
 #include 
+#include 
 
 /*
  * GPIO assignment of Yuan MPG600/MPG160
@@ -149,16 +150,10 @@ static inline struct ivtv *sd_to_ivtv(struct v4l2_subdev 
*sd)
return container_of(sd, struct ivtv, sd_gpio);
 }
 
-static struct v4l2_queryctrl gpio_ctrl_mute = {
-   .id= V4L2_CID_AUDIO_MUTE,
-   .type  = V4L2_CTRL_TYPE_BOOLEAN,
-   .name  = "Mute",
-   .minimum   = 0,
-   .maximum   = 1,
-   .step  = 1,
-   .default_value = 1,
-   .flags = 0,
-};
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return &container_of(ctrl->handler, struct ivtv, hdl_gpio)->sd_gpio;
+}
 
 static int subdev_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
 {
@@ -262,40 +257,24 @@ static int subdev_s_audio_routing(struct v4l2_subdev *sd,
return 0;
 }
 
-static int subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int subdev_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct ivtv *itv = sd_to_ivtv(sd);
u16 mask, data;
 
-   if (ctrl->id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   mask = itv->card->gpio_audio_mute.mask;
-   data = itv->card->gpio_audio_mute.mute;
-   ctrl->value = (read_reg(IVTV_REG_GPIO_OUT) & mask) == data;
-   return 0;
-}
-
-static int subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct ivtv *itv = sd_to_ivtv(sd);
-   u16 mask, data;
-
-   if (ctrl->id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   mask = itv->card->gpio_audio_mute.mask;
-   data = ctrl->value ? itv->card->gpio_audio_mute.mute : 0;
-   if (mask)
-   write_reg((read_reg(IVTV_REG_GPIO_OUT) & ~mask) | (data & 
mask), IVTV_REG_GPIO_OUT);
-   return 0;
+   switch (ctrl->id) {
+   case V4L2_CID_AUDIO_MUTE:
+   mask = itv->card->gpio_audio_mute.mask;
+   data = ctrl->val ? itv->card->gpio_audio_mute.mute : 0;
+   if (mask)
+   write_reg((read_reg(IVTV_REG_GPIO_OUT) & ~mask) |
+   (data & mask), IVTV_REG_GPIO_OUT);
+   return 0;
+   }
+   return -EINVAL;
 }
 
-static int subdev_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
-{
-   if (qc->id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   *qc = gpio_ctrl_mute;
-   return 0;
-}
 
 static int subdev_log_status(struct v4l2_subdev *sd)
 {
@@ -304,6 +283,7 @@ static int subdev_log_status(struct v4l2_subdev *sd)
IVTV_INFO("GPIO status: DIR=0x%04x OUT=0x%04x IN=0x%04x\n",
read_reg(IVTV_REG_GPIO_DIR), 
read_reg(IVTV_REG_GPIO_OUT),
read_reg(IVTV_REG_GPIO_IN));
+   v4l2_ctrl_handler_log_status(&itv->hdl_gpio, sd->name);
return 0;
 }
 
@@ -327,11 +307,19 @@ static int subdev_s_video_routing(struct v4l2_subdev *sd,
return 0;
 }
 
+static const struct v4l2_ctrl_ops gpio_ctrl_ops = {
+   .s_ctrl = subdev_s_ctrl,
+};
+
 static const struct v4l2_subdev_core_ops subdev_core_ops = {
.log_status = subdev_log_status,
-   .g_ctrl = subdev_g_ctrl,
-   .s_ctrl = subdev_s_ctrl,
-   .queryctrl = subdev_queryctrl,
+   .g_ext_ctrls = v4l2_sd_g_ext_ctrls,
+   .try_ext_ctrls = v4l2_sd_try_ext_ctrls,
+   .s_ext_ctrls = v4l2_sd_s_ext_ctrls,
+   .g_ctrl = v4l2_sd_g_ctrl,
+   .s_ctrl = v4l2_sd_s_ctrl,
+   .queryctrl = v4l2

[PATCH 12/15] [RFC] cs53l32a: convert to new control framework.

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/cs53l32a.c |  107 +--
 1 files changed, 68 insertions(+), 39 deletions(-)

diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 80bca8d..c405d05 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -25,10 +25,10 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 MODULE_DESCRIPTION("i2c device driver for cs53l32a Audio ADC");
@@ -42,6 +42,21 @@ module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, "Debugging messages, 0=Off (default), 1=On");
 
 
+struct cs53l32a_state {
+   struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+};
+
+static inline struct cs53l32a_state *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct cs53l32a_state, sd);
+}
+
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return &container_of(ctrl->handler, struct cs53l32a_state, hdl)->sd;
+}
+
 /* --- */
 
 static int cs53l32a_write(struct v4l2_subdev *sd, u8 reg, u8 value)
@@ -73,31 +88,20 @@ static int cs53l32a_s_routing(struct v4l2_subdev *sd,
return 0;
 }
 
-static int cs53l32a_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int cs53l32a_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   if (ctrl->id == V4L2_CID_AUDIO_MUTE) {
-   ctrl->value = (cs53l32a_read(sd, 0x03) & 0xc0) != 0;
-   return 0;
-   }
-   if (ctrl->id != V4L2_CID_AUDIO_VOLUME)
-   return -EINVAL;
-   ctrl->value = (s8)cs53l32a_read(sd, 0x04);
-   return 0;
-}
+   struct v4l2_subdev *sd = to_sd(ctrl);
 
-static int cs53l32a_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   if (ctrl->id == V4L2_CID_AUDIO_MUTE) {
-   cs53l32a_write(sd, 0x03, ctrl->value ? 0xf0 : 0x30);
+   switch (ctrl->id) {
+   case V4L2_CID_AUDIO_MUTE:
+   cs53l32a_write(sd, 0x03, ctrl->val ? 0xf0 : 0x30);
+   return 0;
+   case V4L2_CID_AUDIO_VOLUME:
+   cs53l32a_write(sd, 0x04, (u8)ctrl->val);
+   cs53l32a_write(sd, 0x05, (u8)ctrl->val);
return 0;
}
-   if (ctrl->id != V4L2_CID_AUDIO_VOLUME)
-   return -EINVAL;
-   if (ctrl->value > 12 || ctrl->value < -96)
-   return -EINVAL;
-   cs53l32a_write(sd, 0x04, (u8) ctrl->value);
-   cs53l32a_write(sd, 0x05, (u8) ctrl->value);
-   return 0;
+   return -EINVAL;
 }
 
 static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct 
v4l2_dbg_chip_ident *chip)
@@ -110,23 +114,30 @@ static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, 
struct v4l2_dbg_chip_id
 
 static int cs53l32a_log_status(struct v4l2_subdev *sd)
 {
+   struct cs53l32a_state *state = to_state(sd);
u8 v = cs53l32a_read(sd, 0x01);
-   u8 m = cs53l32a_read(sd, 0x03);
-   s8 vol = cs53l32a_read(sd, 0x04);
 
-   v4l2_info(sd, "Input:  %d%s\n", (v >> 4) & 3,
-   (m & 0xC0) ? " (muted)" : "");
-   v4l2_info(sd, "Volume: %d dB\n", vol);
+   v4l2_info(sd, "Input:  %d\n", (v >> 4) & 3);
+   v4l2_ctrl_handler_log_status(&state->hdl, sd->name);
return 0;
 }
 
 /* --- */
 
+static const struct v4l2_ctrl_ops cs53l32a_ctrl_ops = {
+   .s_ctrl = cs53l32a_s_ctrl,
+};
+
 static const struct v4l2_subdev_core_ops cs53l32a_core_ops = {
.log_status = cs53l32a_log_status,
.g_chip_ident = cs53l32a_g_chip_ident,
-   .g_ctrl = cs53l32a_g_ctrl,
-   .s_ctrl = cs53l32a_s_ctrl,
+   .g_ext_ctrls = v4l2_sd_g_ext_ctrls,
+   .try_ext_ctrls = v4l2_sd_try_ext_ctrls,
+   .s_ext_ctrls = v4l2_sd_s_ext_ctrls,
+   .g_ctrl = v4l2_sd_g_ctrl,
+   .s_ctrl = v4l2_sd_s_ctrl,
+   .queryctrl = v4l2_sd_queryctrl,
+   .querymenu = v4l2_sd_querymenu,
 };
 
 static const struct v4l2_subdev_audio_ops cs53l32a_audio_ops = {
@@ -150,6 +161,7 @@ static const struct v4l2_subdev_ops cs53l32a_ops = {
 static int cs53l32a_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
+   struct cs53l32a_state *state;
struct v4l2_subdev *sd;
int i;
 
@@ -163,9 +175,10 @@ static int cs53l32a_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);
 
-   sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
-   if (sd == NULL)
+   state = kzalloc(sizeof(struct cs53l32a_state), GFP_KERNEL);
+   if (state == NULL)
return -ENOMEM;
+   sd = &state->sd;
v4l2_i2c_subdev_init(sd, client, &cs53l32a_ops);
 
for (i = 1; i <= 7; i++) {
@@ -174,15 +187,29 @@ static int cs53l32a_probe(struct i2c_client *client,
  

[PATCH 11/15] [RFC] wm8775: convert to the new control framework

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/wm8775.c |   79 ++---
 1 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index f1f261a..9a8e3ad 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 MODULE_DESCRIPTION("wm8775 driver");
@@ -52,8 +53,9 @@ enum {
 
 struct wm8775_state {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+   struct v4l2_ctrl *mute;
u8 input;   /* Last selected input (0-0xf) */
-   u8 muted;
 };
 
 static inline struct wm8775_state *to_state(struct v4l2_subdev *sd)
@@ -61,6 +63,11 @@ static inline struct wm8775_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct wm8775_state, sd);
 }
 
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return &container_of(ctrl->handler, struct wm8775_state, hdl)->sd;
+}
+
 static int wm8775_write(struct v4l2_subdev *sd, int reg, u16 val)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -94,7 +101,7 @@ static int wm8775_s_routing(struct v4l2_subdev *sd,
return -EINVAL;
}
state->input = input;
-   if (state->muted)
+   if (!v4l2_ctrl_g(state->mute))
return 0;
wm8775_write(sd, R21, 0x0c0);
wm8775_write(sd, R14, 0x1d4);
@@ -103,29 +110,21 @@ static int wm8775_s_routing(struct v4l2_subdev *sd,
return 0;
 }
 
-static int wm8775_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int wm8775_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct wm8775_state *state = to_state(sd);
 
-   if (ctrl->id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   ctrl->value = state->muted;
-   return 0;
-}
-
-static int wm8775_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct wm8775_state *state = to_state(sd);
-
-   if (ctrl->id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   state->muted = ctrl->value;
-   wm8775_write(sd, R21, 0x0c0);
-   wm8775_write(sd, R14, 0x1d4);
-   wm8775_write(sd, R15, 0x1d4);
-   if (!state->muted)
-   wm8775_write(sd, R21, 0x100 + state->input);
-   return 0;
+   switch (ctrl->id) {
+   case V4L2_CID_AUDIO_MUTE:
+   wm8775_write(sd, R21, 0x0c0);
+   wm8775_write(sd, R14, 0x1d4);
+   wm8775_write(sd, R15, 0x1d4);
+   if (!ctrl->val)
+   wm8775_write(sd, R21, 0x100 + state->input);
+   return 0;
+   }
+   return -EINVAL;
 }
 
 static int wm8775_g_chip_ident(struct v4l2_subdev *sd, struct 
v4l2_dbg_chip_ident *chip)
@@ -139,8 +138,8 @@ static int wm8775_log_status(struct v4l2_subdev *sd)
 {
struct wm8775_state *state = to_state(sd);
 
-   v4l2_info(sd, "Input: %d%s\n", state->input,
-   state->muted ? " (muted)" : "");
+   v4l2_info(sd, "Input: %d\n", state->input);
+   v4l2_ctrl_handler_log_status(&state->hdl, sd->name);
return 0;
 }
 
@@ -161,11 +160,20 @@ static int wm8775_s_frequency(struct v4l2_subdev *sd, 
struct v4l2_frequency *fre
 
 /* --- */
 
+static const struct v4l2_ctrl_ops wm8775_ctrl_ops = {
+   .s_ctrl = wm8775_s_ctrl,
+};
+
 static const struct v4l2_subdev_core_ops wm8775_core_ops = {
.log_status = wm8775_log_status,
.g_chip_ident = wm8775_g_chip_ident,
-   .g_ctrl = wm8775_g_ctrl,
-   .s_ctrl = wm8775_s_ctrl,
+   .g_ext_ctrls = v4l2_sd_g_ext_ctrls,
+   .try_ext_ctrls = v4l2_sd_try_ext_ctrls,
+   .s_ext_ctrls = v4l2_sd_s_ext_ctrls,
+   .g_ctrl = v4l2_sd_g_ctrl,
+   .s_ctrl = v4l2_sd_s_ctrl,
+   .queryctrl = v4l2_sd_queryctrl,
+   .querymenu = v4l2_sd_querymenu,
 };
 
 static const struct v4l2_subdev_tuner_ops wm8775_tuner_ops = {
@@ -204,13 +212,24 @@ static int wm8775_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%02x (%s)\n",
client->addr << 1, client->adapter->name);
 
-   state = kmalloc(sizeof(struct wm8775_state), GFP_KERNEL);
+   state = kzalloc(sizeof(struct wm8775_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
sd = &state->sd;
v4l2_i2c_subdev_init(sd, client, &wm8775_ops);
state->input = 2;
-   state->muted = 0;
+
+   v4l2_ctrl_handler_init(&state->hdl, 1);
+   state->mute = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops,
+   V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
+   sd->ctrl_handler = &state->hdl;
+   if (state->hdl.error) {
+   int err = state->hdl.error;
+
+   v4l2_ctrl_handler_free(&state->hdl);
+   kfr

[PATCH 10/15] [RFC] cx2341x: convert to the control framework

2010-04-26 Thread Hans Verkuil
Since this module is also used by drivers that are not yet converted, the old
and new code have to co-exist.

The source is split into three parts: a common part at the top, which is used
by both old and new code, then the old code followed by the new control
framework implementation. This new code is much more readable (and shorter!)
than the original code.

Once all bridge drivers that use this are converted the old code can be
deleted.

Signed-off-by: Hans Verkuil 
---
 drivers/media/video/cx2341x.c |  725 ++---
 include/media/cx2341x.h   |   81 +
 2 files changed, 694 insertions(+), 112 deletions(-)

diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index 022b480..9a585e0 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -38,6 +38,145 @@ static int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Debug level (0-1)");
 
+/** COMMON CODE */
+
+/* definitions for audio properties bits 29-28 */
+#define CX2341X_AUDIO_ENCODING_METHOD_MPEG 0
+#define CX2341X_AUDIO_ENCODING_METHOD_AC3  1
+#define CX2341X_AUDIO_ENCODING_METHOD_LPCM 2
+
+static const char *cx2341x_get_name(u32 id)
+{
+   switch (id) {
+   case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE:
+   return "Spatial Filter Mode";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER:
+   return "Spatial Filter";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE:
+   return "Spatial Luma Filter Type";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE:
+   return "Spatial Chroma Filter Type";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE:
+   return "Temporal Filter Mode";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER:
+   return "Temporal Filter";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE:
+   return "Median Filter Type";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP:
+   return "Median Luma Filter Maximum";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM:
+   return "Median Luma Filter Minimum";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP:
+   return "Median Chroma Filter Maximum";
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM:
+   return "Median Chroma Filter Minimum";
+   case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS:
+   return "Insert Navigation Packets";
+   }
+   return NULL;
+}
+
+static const char **cx2341x_get_menu(u32 id)
+{
+   static const char *cx2341x_video_spatial_filter_mode_menu[] = {
+   "Manual",
+   "Auto",
+   NULL
+   };
+
+   static const char *cx2341x_video_luma_spatial_filter_type_menu[] = {
+   "Off",
+   "1D Horizontal",
+   "1D Vertical",
+   "2D H/V Separable",
+   "2D Symmetric non-separable",
+   NULL
+   };
+
+   static const char *cx2341x_video_chroma_spatial_filter_type_menu[] = {
+   "Off",
+   "1D Horizontal",
+   NULL
+   };
+
+   static const char *cx2341x_video_temporal_filter_mode_menu[] = {
+   "Manual",
+   "Auto",
+   NULL
+   };
+
+   static const char *cx2341x_video_median_filter_type_menu[] = {
+   "Off",
+   "Horizontal",
+   "Vertical",
+   "Horizontal/Vertical",
+   "Diagonal",
+   NULL
+   };
+
+   switch (id) {
+   case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE:
+   return cx2341x_video_spatial_filter_mode_menu;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE:
+   return cx2341x_video_luma_spatial_filter_type_menu;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE:
+   return cx2341x_video_chroma_spatial_filter_type_menu;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE:
+   return cx2341x_video_temporal_filter_mode_menu;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE:
+   return cx2341x_video_median_filter_type_menu;
+   }
+   return NULL;
+}
+
+static void cx2341x_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type 
*type,
+   s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags)
+{
+   *name = cx2341x_get_name(id);
+   *flags = 0;
+
+   switch (id) {
+   case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE:
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE:
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE:
+   case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE:
+   case V4L2_CID_MPEG_CX2341X_VI

[PATCH 09/15] [RFC] cx25840: convert to the new control framework

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/cx25840/cx25840-audio.c |  144 +++---
 drivers/media/video/cx25840/cx25840-core.c  |  178 ++-
 drivers/media/video/cx25840/cx25840-core.h  |   15 ++-
 3 files changed, 91 insertions(+), 246 deletions(-)

diff --git a/drivers/media/video/cx25840/cx25840-audio.c 
b/drivers/media/video/cx25840/cx25840-audio.c
index 45608d5..6faad34 100644
--- a/drivers/media/video/cx25840/cx25840-audio.c
+++ b/drivers/media/video/cx25840/cx25840-audio.c
@@ -474,33 +474,10 @@ void cx25840_audio_set_path(struct i2c_client *client)
cx25840_and_or(client, 0x803, ~0x10, 0x10);
 }
 
-static int get_volume(struct i2c_client *client)
-{
-   struct cx25840_state *state = to_state(i2c_get_clientdata(client));
-   int vol;
-
-   if (state->unmute_volume >= 0)
-   return state->unmute_volume;
-
-   /* Volume runs +18dB to -96dB in 1/2dB steps
-* change to fit the msp3400 -114dB to +12dB range */
-
-   /* check PATH1_VOLUME */
-   vol = 228 - cx25840_read(client, 0x8d4);
-   vol = (vol / 2) + 23;
-   return vol << 9;
-}
-
 static void set_volume(struct i2c_client *client, int volume)
 {
-   struct cx25840_state *state = to_state(i2c_get_clientdata(client));
int vol;
 
-   if (state->unmute_volume >= 0) {
-   state->unmute_volume = volume;
-   return;
-   }
-
/* Convert the volume to msp3400 values (0-127) */
vol = volume >> 9;
 
@@ -517,52 +494,6 @@ static void set_volume(struct i2c_client *client, int 
volume)
cx25840_write(client, 0x8d4, 228 - (vol * 2));
 }
 
-static int get_bass(struct i2c_client *client)
-{
-   /* bass is 49 steps +12dB to -12dB */
-
-   /* check PATH1_EQ_BASS_VOL */
-   int bass = cx25840_read(client, 0x8d9) & 0x3f;
-   bass = (((48 - bass) * 0x) + 47) / 48;
-   return bass;
-}
-
-static void set_bass(struct i2c_client *client, int bass)
-{
-   /* PATH1_EQ_BASS_VOL */
-   cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0x));
-}
-
-static int get_treble(struct i2c_client *client)
-{
-   /* treble is 49 steps +12dB to -12dB */
-
-   /* check PATH1_EQ_TREBLE_VOL */
-   int treble = cx25840_read(client, 0x8db) & 0x3f;
-   treble = (((48 - treble) * 0x) + 47) / 48;
-   return treble;
-}
-
-static void set_treble(struct i2c_client *client, int treble)
-{
-   /* PATH1_EQ_TREBLE_VOL */
-   cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0x));
-}
-
-static int get_balance(struct i2c_client *client)
-{
-   /* balance is 7 bit, 0 to -96dB */
-
-   /* check PATH1_BAL_LEVEL */
-   int balance = cx25840_read(client, 0x8d5) & 0x7f;
-   /* check PATH1_BAL_LEFT */
-   if ((cx25840_read(client, 0x8d5) & 0x80) == 0)
-   balance = 0x80 - balance;
-   else
-   balance = 0x80 + balance;
-   return balance << 8;
-}
-
 static void set_balance(struct i2c_client *client, int balance)
 {
int bal = balance >> 8;
@@ -579,31 +510,6 @@ static void set_balance(struct i2c_client *client, int 
balance)
}
 }
 
-static int get_mute(struct i2c_client *client)
-{
-   struct cx25840_state *state = to_state(i2c_get_clientdata(client));
-
-   return state->unmute_volume >= 0;
-}
-
-static void set_mute(struct i2c_client *client, int mute)
-{
-   struct cx25840_state *state = to_state(i2c_get_clientdata(client));
-
-   if (mute && state->unmute_volume == -1) {
-   int vol = get_volume(client);
-
-   set_volume(client, 0);
-   state->unmute_volume = vol;
-   }
-   else if (!mute && state->unmute_volume != -1) {
-   int vol = state->unmute_volume;
-
-   state->unmute_volume = -1;
-   set_volume(client, vol);
-   }
-}
-
 int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -624,25 +530,31 @@ int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
return retval;
 }
 
-int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int cx25840_audio_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
+   struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
-   ctrl->value = get_volume(client);
+   if (state->mute->val)
+   set_volume(client, 0);
+   else
+   set_volume(client, state->volume->val);
break;
case V4L2_CID_AUDIO_BASS:
-   ctrl->value = get_bass(client);
+   /* PATH1_EQ_BASS_VOL */
+   cx25840_and_or(client, 0x8d9, ~0x3f,
+   48 - (ctrl->val * 48 / 0x))

[PATCH 07/15] [RFC] saa717x: convert to the new control framework

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/saa717x.c |  323 ++--
 1 files changed, 81 insertions(+), 242 deletions(-)

diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c
index 6818df5..79c8957 100644
--- a/drivers/media/video/saa717x.c
+++ b/drivers/media/video/saa717x.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 MODULE_DESCRIPTION("Philips SAA717x audio/video decoder driver");
@@ -54,14 +55,11 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
 
 struct saa717x_state {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
v4l2_std_id std;
int input;
int enable;
int radio;
-   int bright;
-   int contrast;
-   int hue;
-   int sat;
int playback;
int audio;
int tuner_audio_mode;
@@ -80,6 +78,11 @@ static inline struct saa717x_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct saa717x_state, sd);
 }
 
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return &container_of(ctrl->handler, struct saa717x_state, hdl)->sd;
+}
+
 /* --- */
 
 /* for audio mode */
@@ -773,29 +776,6 @@ static void set_audio_mode(struct v4l2_subdev *sd, int 
audio_mode)
saa717x_write(sd, 0x470, reg_set_audio_template[audio_mode][1]);
 }
 
-/* write regs to video output level (bright,contrast,hue,sat) */
-static void set_video_output_level_regs(struct v4l2_subdev *sd,
-   struct saa717x_state *decoder)
-{
-   /* brightness ffh (bright) - 80h (ITU level) - 00h (dark) */
-   saa717x_write(sd, 0x10a, decoder->bright);
-
-   /* contrast 7fh (max: 1.984) - 44h (ITU) - 40h (1.0) -
-  0h (luminance off) 40: i2c dump
-  c0h (-1.0 inverse chrominance)
-  80h (-2.0 inverse chrominance) */
-   saa717x_write(sd, 0x10b, decoder->contrast);
-
-   /* saturation? 7fh(max)-40h(ITU)-0h(color off)
-  c0h (-1.0 inverse chrominance)
-  80h (-2.0 inverse chrominance) */
-   saa717x_write(sd, 0x10c, decoder->sat);
-
-   /* color hue (phase) control
-  7fh (+178.6) - 0h (0 normal) - 80h (-180.0) */
-   saa717x_write(sd, 0x10d, decoder->hue);
-}
-
 /* write regs to set audio volume, bass and treble */
 static int set_audio_regs(struct v4l2_subdev *sd,
struct saa717x_state *decoder)
@@ -828,9 +808,9 @@ static int set_audio_regs(struct v4l2_subdev *sd,
 
saa717x_write(sd, 0x480, val);
 
-   /* bass and treble; go to another function */
/* set bass and treble */
-   val = decoder->audio_main_bass | (decoder->audio_main_treble << 8);
+   val = decoder->audio_main_bass & 0x1f;
+   val |= (decoder->audio_main_treble & 0x1f) << 5;
saa717x_write(sd, 0x488, val);
return 0;
 }
@@ -892,218 +872,55 @@ static void set_v_scale(struct v4l2_subdev *sd, int 
task, int yscale)
saa717x_write(sd, 0x71 + task_shift, yscale >> 8);
 }
 
-static int saa717x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct saa717x_state *state = to_state(sd);
-
-   switch (ctrl->id) {
-   case V4L2_CID_BRIGHTNESS:
-   if (ctrl->value < 0 || ctrl->value > 255) {
-   v4l2_err(sd, "invalid brightness setting %d\n", 
ctrl->value);
-   return -ERANGE;
-   }
-
-   state->bright = ctrl->value;
-   v4l2_dbg(1, debug, sd, "bright:%d\n", state->bright);
-   saa717x_write(sd, 0x10a, state->bright);
-   break;
-
-   case V4L2_CID_CONTRAST:
-   if (ctrl->value < 0 || ctrl->value > 127) {
-   v4l2_err(sd, "invalid contrast setting %d\n", 
ctrl->value);
-   return -ERANGE;
-   }
-
-   state->contrast = ctrl->value;
-   v4l2_dbg(1, debug, sd, "contrast:%d\n", state->contrast);
-   saa717x_write(sd, 0x10b, state->contrast);
-   break;
-
-   case V4L2_CID_SATURATION:
-   if (ctrl->value < 0 || ctrl->value > 127) {
-   v4l2_err(sd, "invalid saturation setting %d\n", 
ctrl->value);
-   return -ERANGE;
-   }
-
-   state->sat = ctrl->value;
-   v4l2_dbg(1, debug, sd, "sat:%d\n", state->sat);
-   saa717x_write(sd, 0x10c, state->sat);
-   break;
-
-   case V4L2_CID_HUE:
-   if (ctrl->value < -128 || ctrl->value > 127) {
-   v4l2_err(sd, "invalid hue setting %d\n", ctrl->value);
-   return -ERANGE;
-   }
-
-   state->hue = ctrl->value;
-   v4l2_dbg(1, debug, sd, "hue:%d\n", state->hue);
-   saa717x_write(sd, 0x10d, state->hue);
-   break;
-
-   case V4L2_CID_AUD

[PATCH 08/15] [RFC] cx25840/ivtv: replace ugly priv control with s_config

2010-04-26 Thread Hans Verkuil
The cx25840 used a private control CX25840_CID_ENABLE_PVR150_WORKAROUND
to be told whether to enable a workaround for certain pvr150 cards.

This is really config data that it needs to get at load time.

Implemented this in cx25840 and ivtv.

Signed-off-by: Hans Verkuil 
---
 drivers/media/video/cx25840/cx25840-core.c |   23 +++
 drivers/media/video/cx25840/cx25840-core.h |8 
 drivers/media/video/ivtv/ivtv-driver.c |9 +
 drivers/media/video/ivtv/ivtv-i2c.c|7 +++
 include/media/cx25840.h|   11 +++
 5 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/drivers/media/video/cx25840/cx25840-core.c 
b/drivers/media/video/cx25840/cx25840-core.c
index f2461cd..b8aa5d2 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -915,11 +915,6 @@ static int cx25840_s_ctrl(struct v4l2_subdev *sd, struct 
v4l2_control *ctrl)
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
switch (ctrl->id) {
-   case CX25840_CID_ENABLE_PVR150_WORKAROUND:
-   state->pvr150_workaround = ctrl->value;
-   set_input(client, state->vid_input, state->aud_input);
-   break;
-
case V4L2_CID_BRIGHTNESS:
if (ctrl->value < 0 || ctrl->value > 255) {
v4l_err(client, "invalid brightness setting %d\n",
@@ -982,9 +977,6 @@ static int cx25840_g_ctrl(struct v4l2_subdev *sd, struct 
v4l2_control *ctrl)
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
switch (ctrl->id) {
-   case CX25840_CID_ENABLE_PVR150_WORKAROUND:
-   ctrl->value = state->pvr150_workaround;
-   break;
case V4L2_CID_BRIGHTNESS:
ctrl->value = (s8)cx25840_read(client, 0x414) + 128;
break;
@@ -1601,10 +1593,25 @@ static int cx25840_log_status(struct v4l2_subdev *sd)
return 0;
 }
 
+static int cx25840_s_config(struct v4l2_subdev *sd, int irq, void 
*platform_data)
+{
+   struct cx25840_state *state = to_state(sd);
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+   if (platform_data) {
+   struct cx25840_platform_data *pdata = platform_data;
+
+   state->pvr150_workaround = pdata->pvr150_workaround;
+   set_input(client, state->vid_input, state->aud_input);
+   }
+   return 0;
+}
+
 /* --- */
 
 static const struct v4l2_subdev_core_ops cx25840_core_ops = {
.log_status = cx25840_log_status,
+   .s_config = cx25840_s_config,
.g_chip_ident = cx25840_g_chip_ident,
.g_ctrl = cx25840_g_ctrl,
.s_ctrl = cx25840_s_ctrl,
diff --git a/drivers/media/video/cx25840/cx25840-core.h 
b/drivers/media/video/cx25840/cx25840-core.h
index 5534544..50b7887 100644
--- a/drivers/media/video/cx25840/cx25840-core.h
+++ b/drivers/media/video/cx25840/cx25840-core.h
@@ -26,14 +26,6 @@
 #include 
 #include 
 
-/* ENABLE_PVR150_WORKAROUND activates a workaround for a hardware bug that is
-   present in Hauppauge PVR-150 (and possibly PVR-500) cards that have
-   certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The
-   audio autodetect fails on some channels for these models and the workaround
-   is to select the audio standard explicitly. Many thanks to Hauppauge for
-   providing this information. */
-#define CX25840_CID_ENABLE_PVR150_WORKAROUND (V4L2_CID_PRIVATE_BASE+0)
-
 struct cx25840_state {
struct i2c_client *c;
struct v4l2_subdev sd;
diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 1b79475..85aab0e 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -1253,15 +1253,8 @@ int ivtv_init_on_first_open(struct ivtv *itv)
IVTV_DEBUG_INFO("Getting firmware version..\n");
ivtv_firmware_versions(itv);
 
-   if (itv->card->hw_all & IVTV_HW_CX25840) {
-   struct v4l2_control ctrl;
-
+   if (itv->card->hw_all & IVTV_HW_CX25840)
v4l2_subdev_call(itv->sd_video, core, load_fw);
-   /* CX25840_CID_ENABLE_PVR150_WORKAROUND */
-   ctrl.id = V4L2_CID_PRIVATE_BASE;
-   ctrl.value = itv->pvr150_workaround;
-   v4l2_subdev_call(itv->sd_video, core, s_ctrl, &ctrl);
-   }
 
vf.tuner = 0;
vf.type = V4L2_TUNER_ANALOG_TV;
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c 
b/drivers/media/video/ivtv/ivtv-i2c.c
index a5b92d1..d391bbd 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -63,6 +63,7 @@
 #include "ivtv-cards.h"
 #include "ivtv-gpio.h"
 #include "ivtv-i2c.h"
+#include 
 
 /* i2c implementation for cx23415/6 chip, ivtv project.
  * Author: Kevin Thayer (nufan_wfk at yahoo.com)
@@ -292,6 +293,12 @@ int ivtv_i2c_register(stru

[PATCH 06/15] [RFC] msp3400: convert to the new control framework

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/msp3400-driver.c   |  248 +++
 drivers/media/video/msp3400-driver.h   |   16 ++-
 drivers/media/video/msp3400-kthreads.c |   16 +-
 3 files changed, 108 insertions(+), 172 deletions(-)

diff --git a/drivers/media/video/msp3400-driver.c 
b/drivers/media/video/msp3400-driver.c
index e9df3cb..de0da40 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -283,51 +283,6 @@ void msp_set_scart(struct i2c_client *client, int in, int 
out)
msp_write_dem(client, 0x40, state->i2s_mode);
 }
 
-void msp_set_audio(struct i2c_client *client)
-{
-   struct msp_state *state = to_state(i2c_get_clientdata(client));
-   int bal = 0, bass, treble, loudness;
-   int val = 0;
-   int reallymuted = state->muted | state->scan_in_progress;
-
-   if (!reallymuted)
-   val = (state->volume * 0x7f / 65535) << 8;
-
-   v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n",
-   state->muted ? "on" : "off",
-   state->scan_in_progress ? "yes" : "no",
-   state->volume);
-
-   msp_write_dsp(client, 0x, val);
-   msp_write_dsp(client, 0x0007, reallymuted ? 0x1 : (val | 0x1));
-   if (state->has_scart2_out_volume)
-   msp_write_dsp(client, 0x0040, reallymuted ? 0x1 : (val | 0x1));
-   if (state->has_headphones)
-   msp_write_dsp(client, 0x0006, val);
-   if (!state->has_sound_processing)
-   return;
-
-   if (val)
-   bal = (u8)((state->balance / 256) - 128);
-   bass = ((state->bass - 32768) * 0x60 / 65535) << 8;
-   treble = ((state->treble - 32768) * 0x60 / 65535) << 8;
-   loudness = state->loudness ? ((5 * 4) << 8) : 0;
-
-   v4l_dbg(1, msp_debug, client, "balance=%d bass=%d treble=%d 
loudness=%d\n",
-   state->balance, state->bass, state->treble, state->loudness);
-
-   msp_write_dsp(client, 0x0001, bal << 8);
-   msp_write_dsp(client, 0x0002, bass);
-   msp_write_dsp(client, 0x0003, treble);
-   msp_write_dsp(client, 0x0004, loudness);
-   if (!state->has_headphones)
-   return;
-   msp_write_dsp(client, 0x0030, bal << 8);
-   msp_write_dsp(client, 0x0031, bass);
-   msp_write_dsp(client, 0x0032, treble);
-   msp_write_dsp(client, 0x0033, loudness);
-}
-
 /*  */
 
 static void msp_wake_thread(struct i2c_client *client)
@@ -363,98 +318,73 @@ int msp_sleep(struct msp_state *state, int timeout)
 
 /*  */
 
-static int msp_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int msp_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   struct msp_state *state = to_state(sd);
+   struct msp_state *state = ctrl_to_state(ctrl);
+   struct i2c_client *client = v4l2_get_subdevdata(&state->sd);
+   int val = ctrl->val;
 
switch (ctrl->id) {
-   case V4L2_CID_AUDIO_VOLUME:
-   ctrl->value = state->volume;
-   break;
-
-   case V4L2_CID_AUDIO_MUTE:
-   ctrl->value = state->muted;
-   break;
-
-   case V4L2_CID_AUDIO_BALANCE:
-   if (!state->has_sound_processing)
-   return -EINVAL;
-   ctrl->value = state->balance;
-   break;
-
-   case V4L2_CID_AUDIO_BASS:
-   if (!state->has_sound_processing)
-   return -EINVAL;
-   ctrl->value = state->bass;
+   case V4L2_CID_AUDIO_VOLUME: {
+   /* audio volume cluster */
+   int reallymuted = state->muted->val | state->scan_in_progress;
+
+   if (!reallymuted)
+   val = (val * 0x7f / 65535) << 8;
+
+   v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n",
+   state->muted->val ? "on" : "off",
+   state->scan_in_progress ? "yes" : "no",
+   state->volume->val);
+
+   msp_write_dsp(client, 0x, val);
+   msp_write_dsp(client, 0x0007, reallymuted ? 0x1 : (val | 0x1));
+   if (state->has_scart2_out_volume)
+   msp_write_dsp(client, 0x0040, reallymuted ? 0x1 : (val 
| 0x1));
+   if (state->has_headphones)
+   msp_write_dsp(client, 0x0006, val);
break;
-
-   case V4L2_CID_AUDIO_TREBLE:
-   if (!state->has_sound_processing)
-   return -EINVAL;
-   ctrl->value = state->treble;
-   break;
-
-   case V4L2_CID_AUDIO_LOUDNESS:
-   if (!state->has_sound_processing)
-   return -EINVAL;
-   ctrl->value = state->loudness;
-   break;
-
-   defa

[PATCH 05/15] [RFC] saa7115: convert to the new control framework

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 drivers/media/video/saa7115.c |  180 ++---
 1 files changed, 80 insertions(+), 100 deletions(-)

diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 72eaa66..8db056f 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -65,16 +66,17 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
 
 struct saa711x_state {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+
+   /* chroma gain control cluster */
+   struct v4l2_ctrl *agc;
+   struct v4l2_ctrl *gain;
+
v4l2_std_id std;
int input;
int output;
int enable;
int radio;
-   int bright;
-   int contrast;
-   int hue;
-   int sat;
-   int chroma_agc;
int width;
int height;
u32 ident;
@@ -90,6 +92,11 @@ static inline struct saa711x_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct saa711x_state, sd);
 }
 
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return &container_of(ctrl->handler, struct saa711x_state, hdl)->sd;
+}
+
 /* --- */
 
 static inline int saa711x_write(struct v4l2_subdev *sd, u8 reg, u8 value)
@@ -741,96 +748,53 @@ static int saa711x_s_clock_freq(struct v4l2_subdev *sd, 
u32 freq)
return 0;
 }
 
-static int saa711x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int saa711x_g_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct saa711x_state *state = to_state(sd);
-   u8 val;
 
switch (ctrl->id) {
-   case V4L2_CID_BRIGHTNESS:
-   if (ctrl->value < 0 || ctrl->value > 255) {
-   v4l2_err(sd, "invalid brightness setting %d\n", 
ctrl->value);
-   return -ERANGE;
-   }
-
-   state->bright = ctrl->value;
-   saa711x_write(sd, R_0A_LUMA_BRIGHT_CNTL, state->bright);
-   break;
-
-   case V4L2_CID_CONTRAST:
-   if (ctrl->value < 0 || ctrl->value > 127) {
-   v4l2_err(sd, "invalid contrast setting %d\n", 
ctrl->value);
-   return -ERANGE;
-   }
-
-   state->contrast = ctrl->value;
-   saa711x_write(sd, R_0B_LUMA_CONTRAST_CNTL, state->contrast);
-   break;
-
-   case V4L2_CID_SATURATION:
-   if (ctrl->value < 0 || ctrl->value > 127) {
-   v4l2_err(sd, "invalid saturation setting %d\n", 
ctrl->value);
-   return -ERANGE;
-   }
-
-   state->sat = ctrl->value;
-   saa711x_write(sd, R_0C_CHROMA_SAT_CNTL, state->sat);
-   break;
-
-   case V4L2_CID_HUE:
-   if (ctrl->value < -128 || ctrl->value > 127) {
-   v4l2_err(sd, "invalid hue setting %d\n", ctrl->value);
-   return -ERANGE;
-   }
-
-   state->hue = ctrl->value;
-   saa711x_write(sd, R_0D_CHROMA_HUE_CNTL, state->hue);
-   break;
case V4L2_CID_CHROMA_AGC:
-   val = saa711x_read(sd, R_0F_CHROMA_GAIN_CNTL);
-   state->chroma_agc = ctrl->value;
-   if (ctrl->value)
-   val &= 0x7f;
-   else
-   val |= 0x80;
-   saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, val);
+   /* chroma gain cluster */
+   if (state->agc->cur.val)
+   state->gain->cur.val =
+   saa711x_read(sd, R_0F_CHROMA_GAIN_CNTL) & 0x7f;
break;
-   case V4L2_CID_CHROMA_GAIN:
-   /* Chroma gain cannot be set when AGC is enabled */
-   if (state->chroma_agc == 1)
-   return -EINVAL;
-   saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, ctrl->value | 0x80);
-   break;
-   default:
-   return -EINVAL;
}
-
return 0;
 }
 
-static int saa711x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int saa711x_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct saa711x_state *state = to_state(sd);
 
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
-   ctrl->value = state->bright;
+   saa711x_write(sd, R_0A_LUMA_BRIGHT_CNTL, ctrl->val);
break;
+
case V4L2_CID_CONTRAST:
-   ctrl->value = state->contrast;
+   saa711x_write(sd, R_0B_LUMA_CONTRAST_CNTL, ctrl->val);
break;
+
case V4L2_CID_SATURATION:
-   ctrl->value = state->sat;
+   saa711x_write(sd, R_0C_CHROMA_S

[PATCH 04/15] [RFC] v4l: hook up the new control framework into the core framework

2010-04-26 Thread Hans Verkuil
Add the calls needed to automatically merge subdev controls into a bridge
control handler.

Hook up the control framework in __video_ioctl2.

Signed-off-by: Hans Verkuil 
---
 drivers/media/video/v4l2-device.c |7 +
 drivers/media/video/v4l2-ioctl.c  |   46 ++--
 2 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/drivers/media/video/v4l2-device.c 
b/drivers/media/video/v4l2-device.c
index 5a7dc4a..0b08f96 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -26,6 +26,7 @@
 #endif
 #include 
 #include 
+#include 
 
 int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
 {
@@ -115,6 +116,8 @@ EXPORT_SYMBOL_GPL(v4l2_device_unregister);
 int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
struct v4l2_subdev *sd)
 {
+   int err;
+
/* Check for valid input */
if (v4l2_dev == NULL || sd == NULL || !sd->name[0])
return -EINVAL;
@@ -122,6 +125,10 @@ int v4l2_device_register_subdev(struct v4l2_device 
*v4l2_dev,
WARN_ON(sd->v4l2_dev != NULL);
if (!try_module_get(sd->owner))
return -ENODEV;
+   /* This just returns 0 if either of the two args is NULL */
+   err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler);
+   if (err)
+   return err;
sd->v4l2_dev = v4l2_dev;
spin_lock(&v4l2_dev->lock);
list_add_tail(&sd->list, &v4l2_dev->subdevs);
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index e138918..daa9d0c 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -25,6 +25,7 @@
 #endif
 #include 
 #include 
+#include 
 #include 
 
 #define dbgarg(cmd, fmt, arg...) \
@@ -1253,9 +1254,12 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_queryctrl *p = arg;
 
-   if (!ops->vidioc_queryctrl)
+   if (vfd->ctrl_handler)
+   ret = v4l2_queryctrl(vfd->ctrl_handler, p);
+   else if (ops->vidioc_queryctrl)
+   ret = ops->vidioc_queryctrl(file, fh, p);
+   else
break;
-   ret = ops->vidioc_queryctrl(file, fh, p);
if (!ret)
dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, "
"step=%d, default=%d, flags=0x%08x\n",
@@ -1270,7 +1274,9 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_control *p = arg;
 
-   if (ops->vidioc_g_ctrl)
+   if (vfd->ctrl_handler)
+   ret = v4l2_g_ctrl(vfd->ctrl_handler, p);
+   else if (ops->vidioc_g_ctrl)
ret = ops->vidioc_g_ctrl(file, fh, p);
else if (ops->vidioc_g_ext_ctrls) {
struct v4l2_ext_controls ctrls;
@@ -1300,11 +1306,16 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls ctrls;
struct v4l2_ext_control ctrl;
 
-   if (!ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls)
+   if (!vfd->ctrl_handler &&
+   !ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls)
break;
 
dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
 
+   if (vfd->ctrl_handler) {
+   ret = v4l2_s_ctrl(vfd->ctrl_handler, p);
+   break;
+   }
if (ops->vidioc_s_ctrl) {
ret = ops->vidioc_s_ctrl(file, fh, p);
break;
@@ -1326,10 +1337,12 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls *p = arg;
 
p->error_idx = p->count;
-   if (!ops->vidioc_g_ext_ctrls)
-   break;
-   if (check_ext_ctrls(p, 0))
+   if (vfd->ctrl_handler)
+   ret = v4l2_g_ext_ctrls(vfd->ctrl_handler, p);
+   else if (ops->vidioc_g_ext_ctrls && check_ext_ctrls(p, 0))
ret = ops->vidioc_g_ext_ctrls(file, fh, p);
+   else
+   break;
v4l_print_ext_ctrls(cmd, vfd, p, !ret);
break;
}
@@ -1338,10 +1351,12 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls *p = arg;
 
p->error_idx = p->count;
-   if (!ops->vidioc_s_ext_ctrls)
+   if (!vfd->ctrl_handler && !ops->vidioc_s_ext_ctrls)
break;
v4l_print_ext_ctrls(cmd, vfd, p, 1);
-   if (check_ext_ctrls(p, 0))
+   if (vfd->ctrl_handler)
+   ret = v4l2_s_ext_ctrls(vfd->ctrl_handler, p);
+   else if (check_ex

Doing a stable v4l-utils release

2010-04-26 Thread Hans de Goede

Hi all,

Currently v4l-utils is at version 0.7.91, which as the version
suggests is meant as a beta release.

As this release seems to be working well I would like to do
a v4l-utils-0.8.0 release soon. This is a headsup, to give
people a chance to notify me of any bugs they would like to
see fixed first / any patches they would like to add first.

Regards,

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


[PATCH 03/15] [RFC] Documentation: add v4l2-controls.txt documenting the new controls API.

2010-04-26 Thread Hans Verkuil
Signed-off-by: Hans Verkuil 
---
 Documentation/video4linux/v4l2-controls.txt |  543 +++
 1 files changed, 543 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/video4linux/v4l2-controls.txt

diff --git a/Documentation/video4linux/v4l2-controls.txt 
b/Documentation/video4linux/v4l2-controls.txt
new file mode 100644
index 000..29a92b4
--- /dev/null
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -0,0 +1,543 @@
+Introduction
+
+
+The V4L2 control API seems simple enough, but quickly becomes very hard to
+implement correctly in drivers. But much of the code needed to handle controls
+is actually not driver specific and can be moved to the V4L core framework.
+
+After all, the only part that a driver developer is interested in is:
+
+1) How do I add a control?
+2) How do I set the control? (i.e. s_ctrl)
+
+And occasionally:
+
+3) How do I update the control's value? (i.e. g_ctrl)
+4) How do I validate the user's proposed control value? (i.e. try_ctrl)
+
+All the rest is something that can be done centrally.
+
+The control framework was created in order to implement all the rules of the
+V4L2 specification with respect to controls in a central place. And to make
+life as easy as possible for the driver developer.
+
+
+Objects in the framework
+
+
+There are two main objects:
+
+The v4l2_ctrl object describes the control properties and keeps track of the
+control's value (both the current value and the proposed new value).
+
+v4l2_ctrl_handler is the object that keeps track of controls. It maintains a
+list of v4l2_ctrl objects that it owns and another list of references to
+controls, possibly to controls owned by other handlers.
+
+
+Basic usage
+===
+
+1) Prepare the driver:
+
+- Add the handler to your main bridge driver or sub-device driver top-level
+  struct:
+
+   struct foo_dev {
+   ...
+   struct v4l2_ctrl_handler hdl;
+   ...
+   };
+
+   struct foo_dev *foo;
+
+- Initialize handler:
+
+   v4l2_ctrl_handler_init(&foo->hdl, nr_of_controls);
+
+  The second argument is a hint telling the function how many controls this
+  handled is expected to handle. It will allocate a hashtable based on this
+  information. It is a hint only.
+
+- Hooking the control handler into a driver:
+
+  When a subdevice is being registered with a bridge driver and the
+  ctrl_handler fields of both v4l2_subdev and v4l2_device are set, then the
+  controls of the subdev will become automatically available in the bridge
+  driver as well. If the subdev driver contains controls that already exist in
+  the bridge driver, then those will be skipped (so a bridge driver can always
+  override a subdev control).
+
+  How to hook the handler into a bridge driver:
+
+   foo->v4l2_dev.ctrl_handler = &foo->hdl;
+
+  And whenever you call video_register_device() you must set the
+  ctrl_handler field of struct video_device as well:
+
+   vdev->ctrl_handler = &foo->hdl;
+
+  Finally, remove all control functions from your v4l2_ioctl_ops:
+  vidioc_queryctrl, vidioc_querymenu, vidioc_g_ctrl, vidioc_s_ctrl,
+  vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and vidioc_s_ext_ctrls.
+  Those are now no longer needed.
+
+  How to hook the control handler into a subdev driver:
+
+   foo->sd.ctrl_handler = &foo->hdl;
+
+  And set all core control ops in your struct v4l2_subdev_core_ops to these
+  helpers:
+
+   .queryctrl = v4l2_sd_queryctrl,
+   .querymenu = v4l2_sd_querymenu,
+   .g_ctrl = v4l2_sd_g_ctrl,
+   .s_ctrl = v4l2_sd_s_ctrl,
+   .g_ext_ctrls = v4l2_sd_g_ext_ctrls,
+   .try_ext_ctrls = v4l2_sd_try_ext_ctrls,
+   .s_ext_ctrls = v4l2_sd_s_ext_ctrls,
+
+  This is for backwards compatibility. Once all bridge drivers are converted
+  these control ops can be removed just as they are already for bridge drivers.
+
+- Clean up the handler at the end:
+
+   v4l2_ctrl_handler_free(&foo->hdl);
+
+
+2) Add controls:
+
+Typically done right after the handler_init:
+
+   v4l2_ctrl_handler_init(&foo->hdl, nr_of_controls);
+   v4l2_ctrl_new_std(&foo->hdl, &foo_ctrl_ops,
+   V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
+   v4l2_ctrl_new_std(&foo->hdl, &foo_ctrl_ops,
+   V4L2_CID_CONTRAST, 0, 255, 1, 128);
+   ...
+   if (foo->hdl.error) {
+   int err = foo->hdl.error;
+
+   v4l2_ctrl_handler_free(&foo->hdl);
+   return err;
+   }
+
+The v4l2_ctrl_new_std function returns the v4l2_ctrl pointer to the new
+control, but if you do not need to access the pointer outside the control ops,
+then there is no need to store it.
+
+Note that if something fails, the function will return NULL or an error and
+set hdl->error to the error code. If hdl->error was already set, then it
+will just return and do nothing. This is also true for v4l2_ctrl_handler_init
+if it cannot allocate the internal da

[PATCH 02/15] [RFC] v4l2-ctrls: reorder 'case' statements to match order in header.

2010-04-26 Thread Hans Verkuil
To make it easier to determine whether all controls are added in v4l2-ctrls.c
the case statements inside the switch are re-ordered to match the header.

Signed-off-by: Hans Verkuil 
---
 drivers/media/video/v4l2-ctrls.c |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 442f0c5..0193b2d 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -259,6 +259,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 {
switch (id) {
/* USER controls */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
case V4L2_CID_USER_CLASS:   return "User Controls";
case V4L2_CID_BRIGHTNESS:   return "Brightness";
case V4L2_CID_CONTRAST: return "Contrast";
@@ -289,28 +290,37 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_SHARPNESS:return "Sharpness";
case V4L2_CID_BACKLIGHT_COMPENSATION:   return "Backlight Compensation";
case V4L2_CID_CHROMA_AGC:   return "Chroma AGC";
-   case V4L2_CID_CHROMA_GAIN:  return "Chroma Gain";
case V4L2_CID_COLOR_KILLER: return "Color Killer";
case V4L2_CID_COLORFX:  return "Color Effects";
case V4L2_CID_AUTOBRIGHTNESS:   return "Brightness, Automatic";
case V4L2_CID_BAND_STOP_FILTER: return "Band-Stop Filter";
case V4L2_CID_ROTATE:   return "Rotate";
case V4L2_CID_BG_COLOR: return "Background Color";
+   case V4L2_CID_CHROMA_GAIN:  return "Chroma Gain";
 
/* MPEG controls */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
case V4L2_CID_MPEG_CLASS:   return "MPEG Encoder Controls";
+   case V4L2_CID_MPEG_STREAM_TYPE: return "Stream Type";
+   case V4L2_CID_MPEG_STREAM_PID_PMT:  return "Stream PMT Program ID";
+   case V4L2_CID_MPEG_STREAM_PID_AUDIO:return "Stream Audio Program 
ID";
+   case V4L2_CID_MPEG_STREAM_PID_VIDEO:return "Stream Video Program 
ID";
+   case V4L2_CID_MPEG_STREAM_PID_PCR:  return "Stream PCR Program ID";
+   case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: return "Stream PES Audio ID";
+   case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: return "Stream PES Video ID";
+   case V4L2_CID_MPEG_STREAM_VBI_FMT:  return "Stream VBI Format";
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: return "Audio Sampling 
Frequency";
case V4L2_CID_MPEG_AUDIO_ENCODING:  return "Audio Encoding";
case V4L2_CID_MPEG_AUDIO_L1_BITRATE:return "Audio Layer I Bitrate";
case V4L2_CID_MPEG_AUDIO_L2_BITRATE:return "Audio Layer II Bitrate";
case V4L2_CID_MPEG_AUDIO_L3_BITRATE:return "Audio Layer III 
Bitrate";
-   case V4L2_CID_MPEG_AUDIO_AAC_BITRATE:   return "Audio AAC Bitrate";
-   case V4L2_CID_MPEG_AUDIO_AC3_BITRATE:   return "Audio AC-3 Bitrate";
case V4L2_CID_MPEG_AUDIO_MODE:  return "Audio Stereo Mode";
case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: return "Audio Stereo Mode 
Extension";
case V4L2_CID_MPEG_AUDIO_EMPHASIS:  return "Audio Emphasis";
case V4L2_CID_MPEG_AUDIO_CRC:   return "Audio CRC";
case V4L2_CID_MPEG_AUDIO_MUTE:  return "Audio Mute";
+   case V4L2_CID_MPEG_AUDIO_AAC_BITRATE:   return "Audio AAC Bitrate";
+   case V4L2_CID_MPEG_AUDIO_AC3_BITRATE:   return "Audio AC-3 Bitrate";
case V4L2_CID_MPEG_VIDEO_ENCODING:  return "Video Encoding";
case V4L2_CID_MPEG_VIDEO_ASPECT:return "Video Aspect";
case V4L2_CID_MPEG_VIDEO_B_FRAMES:  return "Video B Frames";
@@ -323,16 +333,9 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: return "Video Temporal 
Decimation";
case V4L2_CID_MPEG_VIDEO_MUTE:  return "Video Mute";
case V4L2_CID_MPEG_VIDEO_MUTE_YUV:  return "Video Mute YUV";
-   case V4L2_CID_MPEG_STREAM_TYPE: return "Stream Type";
-   case V4L2_CID_MPEG_STREAM_PID_PMT:  return "Stream PMT Program ID";
-   case V4L2_CID_MPEG_STREAM_PID_AUDIO:return "Stream Audio Program 
ID";
-   case V4L2_CID_MPEG_STREAM_PID_VIDEO:return "Stream Video Program 
ID";
-   case V4L2_CID_MPEG_STREAM_PID_PCR:  return "Stream PCR Program ID";
-   case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: return "Stream PES Audio ID";
-   case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: return "Stream PES Video ID";
-   case V4L2_CID_MPEG_STREAM_VBI_FMT:  return "Stream VBI Format";
 
/* CAMERA controls */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
case V4L2_CID_CAMERA_CLASS: return "Camera Controls";
case V4L2_CID_EXPOSURE_AUTO:   

[PATCH 00/15] [RFC] New control handling framework

2010-04-26 Thread Hans Verkuil
This RFC patch series adds the control handling framework and implements
it in ivtv and all subdev drivers used by ivtv.

It is a bare-bones implementation, so no sysfs or debugfs enhancements.

Any comments are welcome.

Once this is in then we can start migrating all subdev drivers to this
framework, followed by all bridge drivers. Converted subdev drivers can
still be used by unconverted bridge drivers. Once all bridge drivers are
converted the subdev backwards compatibility code can be removed.

The same is true for the cx2341x module: both converted and unconverted
bridge drivers are supported. Once all bridge drivers that use this module
are converted the compat code can be removed from cx2341x (and that will
save about 1060 lines of hard to understand code).

Before this can be merged Laurent Pinchart will have to verify that this
new framework can be used with UVC. Note to Laurent: v4l2_ctrl_new_custom()
allows you to pass a 'void *priv' pointer when creating the control. I'm
pretty sure you need this to associate a V4L control with a UVC data struct.
Should you need it, then it will be trivial to add a flag that will cause
the driver to kfree the priv pointer when the control is freed.

Regards,

Hans

Hans Verkuil (15):
  v4l: Add new control handling framework
  v4l2-ctrls: reorder 'case' statements to match order in header.
  Documentation: add v4l2-controls.txt documenting the new controls
API.
  v4l: hook up the new control framework into the core framework
  saa7115: convert to the new control framework
  msp3400: convert to the new control framework
  saa717x: convert to the new control framework
  cx25840/ivtv: replace ugly priv control with s_config
  cx25840: convert to the new control framework
  cx2341x: convert to the control framework
  wm8775: convert to the new control framework
  cs53l32a: convert to new control framework.
  wm8739: convert to the new control framework
  ivtv: convert gpio subdev to new control framework.
  ivtv: convert to the new control framework

 Documentation/video4linux/v4l2-controls.txt |  543 
 drivers/media/video/Makefile|2 +-
 drivers/media/video/cs53l32a.c  |  107 +-
 drivers/media/video/cx2341x.c   |  725 +--
 drivers/media/video/cx25840/cx25840-audio.c |  144 +--
 drivers/media/video/cx25840/cx25840-core.c  |  201 ++--
 drivers/media/video/cx25840/cx25840-core.h  |   23 +-
 drivers/media/video/ivtv/ivtv-controls.c|  275 +
 drivers/media/video/ivtv/ivtv-controls.h|6 +-
 drivers/media/video/ivtv/ivtv-driver.c  |   26 +-
 drivers/media/video/ivtv/ivtv-driver.h  |4 +-
 drivers/media/video/ivtv/ivtv-fileops.c |   23 +-
 drivers/media/video/ivtv/ivtv-firmware.c|6 +-
 drivers/media/video/ivtv/ivtv-gpio.c|   77 +-
 drivers/media/video/ivtv/ivtv-i2c.c |7 +
 drivers/media/video/ivtv/ivtv-ioctl.c   |   31 +-
 drivers/media/video/ivtv/ivtv-streams.c |   20 +-
 drivers/media/video/msp3400-driver.c|  248 ++---
 drivers/media/video/msp3400-driver.h|   16 +-
 drivers/media/video/msp3400-kthreads.c  |   16 +-
 drivers/media/video/saa7115.c   |  180 ++--
 drivers/media/video/saa717x.c   |  323 ++
 drivers/media/video/v4l2-common.c   |  472 +---
 drivers/media/video/v4l2-ctrls.c| 1793 +++
 drivers/media/video/v4l2-device.c   |7 +
 drivers/media/video/v4l2-ioctl.c|   46 +-
 drivers/media/video/wm8739.c|  176 +--
 drivers/media/video/wm8775.c|   79 +-
 include/media/cx2341x.h |   81 ++
 include/media/cx25840.h |   11 +
 include/media/v4l2-ctrls.h  |  271 
 include/media/v4l2-dev.h|4 +
 include/media/v4l2-device.h |4 +
 include/media/v4l2-subdev.h |3 +
 34 files changed, 4051 insertions(+), 1899 deletions(-)
 create mode 100644 Documentation/video4linux/v4l2-controls.txt
 create mode 100644 drivers/media/video/v4l2-ctrls.c
 create mode 100644 include/media/v4l2-ctrls.h

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


[GIT PATCHES FOR 2.6.35] gspca for_2.6.35

2010-04-26 Thread Jean-Francois Moine
Hi Mauro,

The following changes since commit 1fa9d4c07f3ddee1c054a751cd78e53e8b9050b4:
  Mauro Carvalho Chehab (1):
V4L/DVB: videobuf-dma-sg: Avoid using a wrong size

are available in the git repository at:

  git://linuxtv.org/jfrancois/gspca.git for_2.6.35

Jean-François Moine (9):
  gspca - sonixj: Split the init sequence of sensor ov7630.
  gspca - sonixj: Adjust debug output. - fix bad function name - 
add debug info for i2c buffer write
  gspca - sonixj: Set the colors at startup time.
  gspca - sonixj: Adjust minor values of sensor ov7630. - set the color 
gains to null at init time - change value of register 0x9a
  gspca - sonixj: Reset the bridge after sensor probe.
  gspca - sonixj: Add sensor soi768.
  gspca - zc3xx: Fix the light frequency values for pas202b and pb0330.
  gspca - zc3xx.c: Remove the brightness control.
  gspca - zc3xx: Fix the gamma calculation from the contrast.

 drivers/media/video/gspca/sonixj.c |  145 ++--
 drivers/media/video/gspca/zc3xx.c  |   95 +++
 2 files changed, 133 insertions(+), 107 deletions(-)


Thanks.

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/
--
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