Fw: tm6000 driver questions

2012-04-25 Thread matthieu castet


- Message Transféré -

Date: Wed, 25 Apr 2012 10:16:57 -0700
De: Vladimir Kerkez vker...@gmail.com
À: castet.matth...@free.fr
Sujet: tm6000 driver questions

 Hello,
 
 I would like to thank you for your outstanding work on the tm6000
 chipset. Because of you (and many other people) I now have a pal tv
 tuner I can use.
 
 I just recently bought a mac book pro, how ever most of the drivers
 were not supported under the 3.2 kernel. I pulled down the latestest
 drivers for my Hauppauge 900H from linux tv (tm6000 edition).
 
 I read the your patch changes that you have made here:
 http://patchwork.linuxtv.org/patch/8968/
 
 One of the first things I noticed is that the firmware for the tm6000
 loads about 10-12 seconds faster, my tvtime starting at a normal
 speed ( it used to take up to 20 seconds to load ). Im assuming this
 is something you may have patched? If you did thanks so much!
 
 However I am now running into a issue I never saw before with my
 tm6000 tuner. I noticed that in this new version of the driver the
 channel switching is a lot faster, but it seems to be causing  kernel
 panics. I believe the issues is that the channel switches so fast
 before the tuner gets a signal causing the kernel panic (the usb gets
 bad data and throws and emi).  This always happens when the channel
 is changed.
 
 Here is a snippet of the kernel panic:
 
 [ 4760.587553] xc2028 14-0061: xc2028_get_reg 0004 called
 [ 4760.591160] xc2028 14-0061: xc2028_get_reg 0008 called
 *[ 4760.633815] hub 2-0:1.0: port 4 disabled by hub (EMI?),
 re-enabling...* [ 4760.633827] usb 2-4: USB disconnect, device number
 3 [ 4760.637748] xc2028 14-0061: Device is Xceive 0 version 2.0,
 firmware version 3.6
 [ 4760.637756] xc2028 14-0061: Read invalid device hardware
 information - tuner hung?
 [ 4760.650641] tm6000: IR URB failure: status: -71, length 0
 
 Have you seen this issue? I would love to fix this and commit it to
 linux tv but, im still uncertain as to what changes need to be made.
 The drivers that do come with the 3.2 kernel work fine but however
 the firmware loading is taking forever (stable though when it is
 running).
 
 Any information you may have to help me out here would be much
 appreciated. I am not working this weekend and was looking forward to
 take a peak at the driver. I'll let you know where I stand with this
 next week.
 
 thank you so much for your hard work,
 
 -Vladimir
--
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] tm6000 : improve loading speed on hauppauge 900H

2011-12-22 Thread Matthieu CASTET
- enable fast usb quirk
- use usleep_range instead on msleep for short sleep
- merge i2c out and usb delay
- do like the windows driver that upload the tuner firmware with 80 bytes
packets

Signed-off-by: Matthieu CASTET castet.matth...@free.fr
CC: Thierry Reding thierry.red...@avionic-design.de
---
 drivers/media/video/tm6000/tm6000-cards.c |2 ++
 drivers/media/video/tm6000/tm6000-core.c  |   16 ++--
 drivers/media/video/tm6000/tm6000-i2c.c   |8 +---
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/media/video/tm6000/tm6000-cards.c 
b/drivers/media/video/tm6000/tm6000-cards.c
index 6b74259..3678918 100644
--- a/drivers/media/video/tm6000/tm6000-cards.c
+++ b/drivers/media/video/tm6000/tm6000-cards.c
@@ -943,6 +943,7 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
case TM6010_BOARD_HAUPPAUGE_900H:
case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
case TM6010_BOARD_TWINHAN_TU501:
+   ctl.max_len = 80;
ctl.fname = xc3028L-v36.fw;
break;
default:
@@ -1004,6 +1005,7 @@ static int fill_board_specific_data(struct tm6000_core 
*dev)
/* setup per-model quirks */
switch (dev-model) {
case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
+   case TM6010_BOARD_HAUPPAUGE_900H:
dev-quirks |= TM6000_QUIRK_NO_USB_DELAY;
break;
 
diff --git a/drivers/media/video/tm6000/tm6000-core.c 
b/drivers/media/video/tm6000/tm6000-core.c
index 979c85b..22cc011 100644
--- a/drivers/media/video/tm6000/tm6000-core.c
+++ b/drivers/media/video/tm6000/tm6000-core.c
@@ -38,6 +38,7 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 
req_type, u8 req,
int  ret, i;
unsigned int pipe;
u8   *data = NULL;
+   int delay = 5000;
 
mutex_lock(dev-usb_lock);
 
@@ -89,8 +90,19 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 
req_type, u8 req,
 
kfree(data);
 
-   if ((dev-quirks  TM6000_QUIRK_NO_USB_DELAY) == 0)
-   msleep(5);
+   if (dev-quirks  TM6000_QUIRK_NO_USB_DELAY)
+   delay = 0;
+
+   if (req == REQ_16_SET_GET_I2C_WR1_RDN  !(req_type  USB_DIR_IN)) {
+   unsigned int tsleep;
+   /* Calculate delay time, 14000us for 64 bytes */
+   tsleep = (len * 200) + 200;
+   if (tsleep  delay)
+   tsleep = delay;
+   usleep_range(tsleep, tsleep + 1000);
+   }
+   else if (delay)
+   usleep_range(delay, delay + 1000);
 
mutex_unlock(dev-usb_lock);
return ret;
diff --git a/drivers/media/video/tm6000/tm6000-i2c.c 
b/drivers/media/video/tm6000/tm6000-i2c.c
index 0290bbf..c7e23e3 100644
--- a/drivers/media/video/tm6000/tm6000-i2c.c
+++ b/drivers/media/video/tm6000/tm6000-i2c.c
@@ -46,11 +46,10 @@ static int tm6000_i2c_send_regs(struct tm6000_core *dev, 
unsigned char addr,
__u8 reg, char *buf, int len)
 {
int rc;
-   unsigned int tsleep;
unsigned int i2c_packet_limit = 16;
 
if (dev-dev_type == TM6010)
-   i2c_packet_limit = 64;
+   i2c_packet_limit = 80;
 
if (!buf)
return -1;
@@ -71,10 +70,6 @@ static int tm6000_i2c_send_regs(struct tm6000_core *dev, 
unsigned char addr,
return rc;
}
 
-   /* Calculate delay time, 14000us for 64 bytes */
-   tsleep = ((len * 200) + 200 + 1000) / 1000;
-   msleep(tsleep);
-
/* release mutex */
return rc;
 }
@@ -145,7 +140,6 @@ static int tm6000_i2c_recv_regs16(struct tm6000_core *dev, 
unsigned char addr,
return rc;
}
 
-   msleep(1400 / 1000);
rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR |
USB_RECIP_DEVICE, REQ_35_AFTEK_TUNER_READ,
reg, 0, buf, len);
-- 
1.7.5.4

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


[PATCH] tm6000 : improve loading speed on hauppauge 900H

2011-12-16 Thread Matthieu CASTET
- enable fast usb quirk
- use usleep_range instead on msleep for short sleep
- merge i2c out and usb delay
- do like the windows driver that upload the tuner firmware with 80 bytes
packets

Signed-off-by: Matthieu CASTET castet.matth...@free.fr
CC: Thierry Reding thierry.red...@avionic-design.de
---
 drivers/staging/tm6000/tm6000-cards.c |2 ++
 drivers/staging/tm6000/tm6000-core.c  |   16 +++-
 drivers/staging/tm6000/tm6000-i2c.c   |8 +---
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/tm6000/tm6000-cards.c 
b/drivers/staging/tm6000/tm6000-cards.c
index ec2578a..2136fa9 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -941,6 +941,7 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
case TM6010_BOARD_HAUPPAUGE_900H:
case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
case TM6010_BOARD_TWINHAN_TU501:
+   ctl.max_len = 80;
ctl.fname = xc3028L-v36.fw;
break;
default:
@@ -1002,6 +1003,7 @@ static int fill_board_specific_data(struct tm6000_core 
*dev)
/* setup per-model quirks */
switch (dev-model) {
case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
+   case TM6010_BOARD_HAUPPAUGE_900H:
dev-quirks |= TM6000_QUIRK_NO_USB_DELAY;
break;
 
diff --git a/drivers/staging/tm6000/tm6000-core.c 
b/drivers/staging/tm6000/tm6000-core.c
index 6d0803c..c559f9f 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -38,6 +38,7 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 
req_type, u8 req,
int  ret, i;
unsigned int pipe;
u8   *data = NULL;
+   int delay = 5000;
 
mutex_lock(dev-usb_lock);
 
@@ -88,7 +89,20 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 
req_type, u8 req,
}
 
kfree(data);
-   msleep(5);
+
+   if (dev-quirks  TM6000_QUIRK_NO_USB_DELAY)
+   delay = 0;
+
+   if (req == REQ_16_SET_GET_I2C_WR1_RDN  !(req_type  USB_DIR_IN)) {
+   unsigned int tsleep;
+   /* Calculate delay time, 14000us for 64 bytes */
+   tsleep = (len * 200) + 200;
+   if (tsleep  delay)
+   tsleep = delay;
+   usleep_range(tsleep, tsleep + 1000);
+   }
+   else if (delay)
+   usleep_range(delay, delay + 1000);
 
mutex_unlock(dev-usb_lock);
return ret;
diff --git a/drivers/staging/tm6000/tm6000-i2c.c 
b/drivers/staging/tm6000/tm6000-i2c.c
index 76a8e3a..8809ed1 100644
--- a/drivers/staging/tm6000/tm6000-i2c.c
+++ b/drivers/staging/tm6000/tm6000-i2c.c
@@ -46,11 +46,10 @@ static int tm6000_i2c_send_regs(struct tm6000_core *dev, 
unsigned char addr,
__u8 reg, char *buf, int len)
 {
int rc;
-   unsigned int tsleep;
unsigned int i2c_packet_limit = 16;
 
if (dev-dev_type == TM6010)
-   i2c_packet_limit = 64;
+   i2c_packet_limit = 80;
 
if (!buf)
return -1;
@@ -71,10 +70,6 @@ static int tm6000_i2c_send_regs(struct tm6000_core *dev, 
unsigned char addr,
return rc;
}
 
-   /* Calculate delay time, 14000us for 64 bytes */
-   tsleep = ((len * 200) + 200 + 1000) / 1000;
-   msleep(tsleep);
-
/* release mutex */
return rc;
 }
@@ -145,7 +140,6 @@ static int tm6000_i2c_recv_regs16(struct tm6000_core *dev, 
unsigned char addr,
return rc;
}
 
-   msleep(1400 / 1000);
rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR |
USB_RECIP_DEVICE, REQ_35_AFTEK_TUNER_READ,
reg, 0, buf, len);
-- 
1.7.5.4

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


[PATCH] tm6000 : dvb doesn't work on usb1.1

2011-12-16 Thread Matthieu CASTET
Signed-off-by: Matthieu CASTET castet.matth...@free.fr
---
 drivers/staging/tm6000/tm6000-dvb.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/tm6000/tm6000-dvb.c 
b/drivers/staging/tm6000/tm6000-dvb.c
index 8f2a50b..cbecb7d 100644
--- a/drivers/staging/tm6000/tm6000-dvb.c
+++ b/drivers/staging/tm6000/tm6000-dvb.c
@@ -396,6 +396,11 @@ static int dvb_init(struct tm6000_core *dev)
if (!dev-caps.has_dvb)
return 0;
 
+   if (dev-udev-speed == USB_SPEED_FULL) {
+   printk(KERN_INFO This USB2.0 device cannot be run on a USB1.1 
port. (it lacks a hardware PID filter)\n);
+   return 0;
+   }
+
dvb = kzalloc(sizeof(struct tm6000_dvb), GFP_KERNEL);
if (!dvb) {
printk(KERN_INFO Cannot allocate memory\n);
-- 
1.7.5.4

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


Re: add dvb-t fr-All frequency

2011-03-17 Thread matthieu castet
Le Wed, 16 Mar 2011 16:46:38 +0100,
Christoph Pfister christophpfis...@gmail.com a écrit :

 2011/3/15 matthieu castet castet.matth...@free.fr:
  Hi,
 
  can this file be added to dvb-apps/util/scan/dvb-t
 
 No. Use auto-Normal [1] (or the +-167kHz file if needed).
 
Ok, thanks I wasn't aware of the auto files.

How does the offset version works ?
The scan tools is clever enough to not duplicate freq, freq-offset,
freq+offset and choose the one with best signal ?

BTW in theory in France, offset can be :  - 0,166 MHz /+ 0,166
MHz /+ 0,332 MHz /+ 0,498 MHz.

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


add dvb-t fr-All frequency

2011-03-15 Thread matthieu castet

Hi,

can this file be added to dvb-apps/util/scan/dvb-t

Thanks

Matthieu
#http://tvignaud.pagesperso-orange.fr/

T 47400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 48200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 49000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 49800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 50600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 51400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 52200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 53000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 53800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 54600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 55400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 56200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 57000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 57800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 58600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 59400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 60200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 61000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 61800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 62600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 63400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 64200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 65000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 65800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 66600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 67400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 68200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 69000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 69800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 70600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 71400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 72200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 73000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 73800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 74600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 75400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 76200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 77000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 77800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 78600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 79400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 80200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 81000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 81800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 82600 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 83400 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 84200 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 85000 8MHz AUTO AUTO QAM64 AUTO AUTO NONE
T 85800 8MHz AUTO AUTO QAM64 AUTO AUTO NONE


Re: [PATCH] fix dvb frontend lockup

2010-05-05 Thread matthieu castet

matthieu castet a écrit :

Hi,

With my current kernel (2.6.32), if my dvb device is removed while in use, I 
got [1].

After checking the source code, the problem seems to happen also in master :

If there are users (for example users == -2) :
- dvb_unregister_frontend :
- stop kernel thread with dvb_frontend_stop :
 - fepriv-exit = 1;
 - thread loop catch stop event and break while loop
 - fepriv-thread = NULL; and fepriv-exit = 0;
- dvb_unregister_frontend wait on fepriv-dvbdev-wait_queue that 
fepriv-dvbdev-users==-1.
The user finish :
- dvb_frontend_release - set users to -1
- don't wait wait_queue because fepriv-exit != 1

= dvb_unregister_frontend never exit the wait queue.


Matthieu


[ 4920.484047] khubd D c2008000 0   198  2 0x
[ 4920.484056]  f64c8000 0046  c2008000 0004 c13fa000 c13fa000 f
64c8000
[ 4920.484066]  f64c81bc c2008000  d9d9dce6 0452 0001 f64c8000 c
102daad
[ 4920.484075]  00100100 f64c81bc 0286 f0a7ccc0 f0913404 f0cba404 f644de58 f
092b0a8
[ 4920.484084] Call Trace:
[ 4920.484102]  [c102daad] ? default_wake_function+0x0/0x8
[ 4920.484147]  [f8cb09e1] ? dvb_unregister_frontend+0x95/0xcc [dvb_core]
[ 4920.484157]  [c1044412] ? autoremove_wake_function+0x0/0x2d
[ 4920.484168]  [f8dd1af2] ? dvb_usb_adapter_frontend_exit+0x12/0x21 [dvb_usb]
[ 4920.484176]  [f8dd12f1] ? dvb_usb_exit+0x26/0x88 [dvb_usb]
[ 4920.484184]  [f8dd138d] ? dvb_usb_device_exit+0x3a/0x4a [dvb_usb]
[ 4920.484217]  [f7fe1b08] ? usb_unbind_interface+0x3f/0xb4 [usbcore]
[ 4920.484227]  [c11a4178] ? __device_release_driver+0x74/0xb7
[ 4920.484233]  [c11a4247] ? device_release_driver+0x15/0x1e
[ 4920.484243]  [c11a3a33] ? bus_remove_device+0x6e/0x87
[ 4920.484249]  [c11a26d6] ? device_del+0xfa/0x152
[ 4920.484264]  [f7fdf609] ? usb_disable_device+0x59/0xb9 [usbcore]
[ 4920.484279]  [f7fdb9ee] ? usb_disconnect+0x70/0xdc [usbcore]
[ 4920.484294]  [f7fdc728] ? hub_thread+0x521/0xe1d [usbcore]
[ 4920.484301]  [c1044412] ? autoremove_wake_function+0x0/0x2d
[ 4920.484316]  [f7fdc207] ? hub_thread+0x0/0xe1d [usbcore]
[ 4920.484321]  [c10441e0] ? kthread+0x61/0x66
[ 4920.484327]  [c104417f] ? kthread+0x0/0x66
[ 4920.484336]  [c1003d47] ? kernel_thread_helper+0x7/0x10


Here a patch that fix the issue


Signed-off-by: Matthieu CASTET castet.matth...@free.fr


diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 55ea260..6932def 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -95,6 +95,10 @@ MODULE_PARM_DESC(dvb_mfe_wait_time, Wait up to mfe_wait_time seconds on open(
  * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
  */
 
+#define DVB_FE_NO_EXIT	0
+#define DVB_FE_NORMAL_EXIT	1
+#define DVB_FE_DEVICE_REMOVED	2
+
 static DEFINE_MUTEX(frontend_mutex);
 
 struct dvb_frontend_private {
@@ -497,7 +501,7 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
 {
 	struct dvb_frontend_private *fepriv = fe-frontend_priv;
 
-	if (fepriv-exit)
+	if (fepriv-exit != DVB_FE_NO_EXIT)
 		return 1;
 
 	if (fepriv-dvbdev-writers == 1)
@@ -559,7 +563,7 @@ restart:
 
 		if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) {
 			/* got signal or quitting */
-			fepriv-exit = 1;
+			fepriv-exit = DVB_FE_NORMAL_EXIT;
 			break;
 		}
 
@@ -673,7 +677,10 @@ restart:
 	}
 
 	fepriv-thread = NULL;
-	fepriv-exit = 0;
+	if (kthread_should_stop())
+		fepriv-exit = DVB_FE_DEVICE_REMOVED;
+	else
+		fepriv-exit = DVB_FE_NO_EXIT;
 	mb();
 
 	dvb_frontend_wakeup(fe);
@@ -686,7 +693,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
 
 	dprintk (%s\n, __func__);
 
-	fepriv-exit = 1;
+	fepriv-exit = DVB_FE_NORMAL_EXIT;
 	mb();
 
 	if (!fepriv-thread)
@@ -755,7 +762,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
 	dprintk (%s\n, __func__);
 
 	if (fepriv-thread) {
-		if (!fepriv-exit)
+		if (fepriv-exit == DVB_FE_NO_EXIT)
 			return 0;
 		else
 			dvb_frontend_stop (fe);
@@ -767,7 +774,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
 		return -EINTR;
 
 	fepriv-state = FESTATE_IDLE;
-	fepriv-exit = 0;
+	fepriv-exit = DVB_FE_NO_EXIT;
 	fepriv-thread = NULL;
 	mb();
 
@@ -1490,7 +1497,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
 
 	dprintk(%s (%d)\n, __func__, _IOC_NR(cmd));
 
-	if (fepriv-exit)
+	if (fepriv-exit != DVB_FE_NO_EXIT)
 		return -ENODEV;
 
 	if ((file-f_flags  O_ACCMODE) == O_RDONLY 
@@ -1916,6 +1923,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
 	int ret;
 
 	dprintk (%s\n, __func__);
+	if (fepriv-exit == DVB_FE_DEVICE_REMOVED)
+		return -ENODEV;
 
 	if (adapter-mfe_shared) {
 		mutex_lock (adapter-mfe_lock);
@@ -2008,7 +2017,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
 	ret = dvb_generic_release (inode, file);
 
 	if (dvbdev-users == -1) {
-		if (fepriv-exit == 1) {
+		if (fepriv-exit != DVB_FE_NO_EXIT) {
 			fops_put

Re: [PATCH] fix dvb frontend lockup

2010-04-03 Thread matthieu castet

matthieu castet a écrit :

matthieu castet a écrit :

Hi,

With my current kernel (2.6.32), if my dvb device is removed while in 
use, I got [1].


After checking the source code, the problem seems to happen also in 
master :


If there are users (for example users == -2) :
- dvb_unregister_frontend :
- stop kernel thread with dvb_frontend_stop :
 - fepriv-exit = 1;
 - thread loop catch stop event and break while loop
 - fepriv-thread = NULL; and fepriv-exit = 0;
- dvb_unregister_frontend wait on fepriv-dvbdev-wait_queue that 
fepriv-dvbdev-users==-1.

The user finish :
- dvb_frontend_release - set users to -1
- don't wait wait_queue because fepriv-exit != 1

= dvb_unregister_frontend never exit the wait queue.


Matthieu


[ 4920.484047] khubd D c2008000 0   198  2 0x
[ 4920.484056]  f64c8000 0046  c2008000 0004 c13fa000 
c13fa000 f

64c8000
[ 4920.484066]  f64c81bc c2008000  d9d9dce6 0452 0001 
f64c8000 c

102daad
[ 4920.484075]  00100100 f64c81bc 0286 f0a7ccc0 f0913404 f0cba404 
f644de58 f

092b0a8
[ 4920.484084] Call Trace:
[ 4920.484102]  [c102daad] ? default_wake_function+0x0/0x8
[ 4920.484147]  [f8cb09e1] ? dvb_unregister_frontend+0x95/0xcc 
[dvb_core]

[ 4920.484157]  [c1044412] ? autoremove_wake_function+0x0/0x2d
[ 4920.484168]  [f8dd1af2] ? dvb_usb_adapter_frontend_exit+0x12/0x21 
[dvb_usb]

[ 4920.484176]  [f8dd12f1] ? dvb_usb_exit+0x26/0x88 [dvb_usb]
[ 4920.484184]  [f8dd138d] ? dvb_usb_device_exit+0x3a/0x4a [dvb_usb]
[ 4920.484217]  [f7fe1b08] ? usb_unbind_interface+0x3f/0xb4 [usbcore]
[ 4920.484227]  [c11a4178] ? __device_release_driver+0x74/0xb7
[ 4920.484233]  [c11a4247] ? device_release_driver+0x15/0x1e
[ 4920.484243]  [c11a3a33] ? bus_remove_device+0x6e/0x87
[ 4920.484249]  [c11a26d6] ? device_del+0xfa/0x152
[ 4920.484264]  [f7fdf609] ? usb_disable_device+0x59/0xb9 [usbcore]
[ 4920.484279]  [f7fdb9ee] ? usb_disconnect+0x70/0xdc [usbcore]
[ 4920.484294]  [f7fdc728] ? hub_thread+0x521/0xe1d [usbcore]
[ 4920.484301]  [c1044412] ? autoremove_wake_function+0x0/0x2d
[ 4920.484316]  [f7fdc207] ? hub_thread+0x0/0xe1d [usbcore]
[ 4920.484321]  [c10441e0] ? kthread+0x61/0x66
[ 4920.484327]  [c104417f] ? kthread+0x0/0x66
[ 4920.484336]  [c1003d47] ? kernel_thread_helper+0x7/0x10


Here a patch that fix the issue


Signed-off-by: Matthieu CASTET castet.matth...@free.fr


Any news on that
--
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] fix dvb frontend lockup

2010-03-27 Thread matthieu castet

matthieu castet a écrit :

Hi,

With my current kernel (2.6.32), if my dvb device is removed while in 
use, I got [1].


After checking the source code, the problem seems to happen also in 
master :


If there are users (for example users == -2) :
- dvb_unregister_frontend :
- stop kernel thread with dvb_frontend_stop :
 - fepriv-exit = 1;
 - thread loop catch stop event and break while loop
 - fepriv-thread = NULL; and fepriv-exit = 0;
- dvb_unregister_frontend wait on fepriv-dvbdev-wait_queue that 
fepriv-dvbdev-users==-1.

The user finish :
- dvb_frontend_release - set users to -1
- don't wait wait_queue because fepriv-exit != 1

= dvb_unregister_frontend never exit the wait queue.


Matthieu


[ 4920.484047] khubd D c2008000 0   198  2 0x
[ 4920.484056]  f64c8000 0046  c2008000 0004 c13fa000 
c13fa000 f

64c8000
[ 4920.484066]  f64c81bc c2008000  d9d9dce6 0452 0001 
f64c8000 c

102daad
[ 4920.484075]  00100100 f64c81bc 0286 f0a7ccc0 f0913404 f0cba404 
f644de58 f

092b0a8
[ 4920.484084] Call Trace:
[ 4920.484102]  [c102daad] ? default_wake_function+0x0/0x8
[ 4920.484147]  [f8cb09e1] ? dvb_unregister_frontend+0x95/0xcc [dvb_core]
[ 4920.484157]  [c1044412] ? autoremove_wake_function+0x0/0x2d
[ 4920.484168]  [f8dd1af2] ? dvb_usb_adapter_frontend_exit+0x12/0x21 
[dvb_usb]

[ 4920.484176]  [f8dd12f1] ? dvb_usb_exit+0x26/0x88 [dvb_usb]
[ 4920.484184]  [f8dd138d] ? dvb_usb_device_exit+0x3a/0x4a [dvb_usb]
[ 4920.484217]  [f7fe1b08] ? usb_unbind_interface+0x3f/0xb4 [usbcore]
[ 4920.484227]  [c11a4178] ? __device_release_driver+0x74/0xb7
[ 4920.484233]  [c11a4247] ? device_release_driver+0x15/0x1e
[ 4920.484243]  [c11a3a33] ? bus_remove_device+0x6e/0x87
[ 4920.484249]  [c11a26d6] ? device_del+0xfa/0x152
[ 4920.484264]  [f7fdf609] ? usb_disable_device+0x59/0xb9 [usbcore]
[ 4920.484279]  [f7fdb9ee] ? usb_disconnect+0x70/0xdc [usbcore]
[ 4920.484294]  [f7fdc728] ? hub_thread+0x521/0xe1d [usbcore]
[ 4920.484301]  [c1044412] ? autoremove_wake_function+0x0/0x2d
[ 4920.484316]  [f7fdc207] ? hub_thread+0x0/0xe1d [usbcore]
[ 4920.484321]  [c10441e0] ? kthread+0x61/0x66
[ 4920.484327]  [c104417f] ? kthread+0x0/0x66
[ 4920.484336]  [c1003d47] ? kernel_thread_helper+0x7/0x10


Here a patch that fix the issue


Signed-off-by: Matthieu CASTET castet.matth...@free.fr
--- 1/linux/drivers/media/dvb/dvb-core/dvb_frontend.c	2010-03-27 22:59:50.0 +0100
+++ 2/linux/drivers/media/dvb/dvb-core/dvb_frontend.c	2010-03-27 23:01:34.0 +0100
@@ -686,7 +686,10 @@
 	}
 
 	fepriv-thread = NULL;
-	fepriv-exit = 0;
+	if (kthread_should_stop())
+		fepriv-exit = 2;
+	else
+		fepriv-exit = 0;
 	mb();
 
 	dvb_frontend_wakeup(fe);
@@ -1929,6 +1932,8 @@
 	int ret;
 
 	dprintk (%s\n, __func__);
+	if (fepriv-exit == 2)
+		return -ENODEV;
 
 	if (adapter-mfe_shared) {
 		mutex_lock (adapter-mfe_lock);
@@ -2021,7 +2026,7 @@
 	ret = dvb_generic_release (inode, file);
 
 	if (dvbdev-users == -1) {
-		if (fepriv-exit == 1) {
+		if (fepriv-exit) {
 			fops_put(file-f_op);
 			file-f_op = NULL;
 			wake_up(dvbdev-wait_queue);


[PATCH] af9015 : more robust eeprom parsing

2010-03-21 Thread matthieu castet

the af9015 eeprom parsing accept 0x38 as 2nd demodulator. But this is 
impossible because the
first one is already hardcoded to 0x38.
This remove a special case for AverMedia AVerTV Volar Black HD.

Also in af9015_copy_firmware don't hardcode the 2nd demodulator address to 0x3a.


Signed-off-by: Matthieu CASTET castet.matth...@free.fr 
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index d797538..f93767e 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -493,7 +493,7 @@ static int af9015_copy_firmware(struct dvb_usb_device *d)
 	/* wait 2nd demodulator ready */
 	msleep(100);
 
-	ret = af9015_read_reg_i2c(d, 0x3a, 0x98be, val);
+	ret = af9015_read_reg_i2c(d, af9015_af9013_config[1].demod_address, 0x98be, val);
 	if (ret)
 		goto error;
 	else
@@ -913,8 +913,13 @@ static int af9015_read_config(struct usb_device *udev)
 		ret = af9015_rw_udev(udev, req);
 		if (ret)
 			goto error;
-		af9015_af9013_config[1].demod_address = val;
+		if (val != AF9015_I2C_DEMOD)
+			af9015_af9013_config[1].demod_address = val;
+		else 
+			af9015_config.dual_mode = 0;
+	}
 
+	if (af9015_config.dual_mode) {
 		/* enable 2nd adapter */
 		for (i = 0; i  af9015_properties_count; i++)
 			af9015_properties[i].num_adapters = 2;
@@ -1023,11 +1028,6 @@ error:
 	if (le16_to_cpu(udev-descriptor.idVendor) == USB_VID_AVERMEDIA 
 	le16_to_cpu(udev-descriptor.idProduct) == USB_PID_AVERMEDIA_A850) {
 		deb_info(%s: AverMedia A850: overriding config\n, __func__);
-		/* disable dual mode */
-		af9015_config.dual_mode = 0;
-		 /* disable 2nd adapter */
-		for (i = 0; i  af9015_properties_count; i++)
-			af9015_properties[i].num_adapters = 1;
 
 		/* set correct IF */
 		af9015_af9013_config[0].tuner_if = 4570;


dvb frontend lockup

2010-03-21 Thread matthieu castet

Hi,

With my current kernel (2.6.32), if my dvb device is removed while in use, I 
got [1].

After checking the source code, the problem seems to happen also in master :

If there are users (for example users == -2) :
- dvb_unregister_frontend :
- stop kernel thread with dvb_frontend_stop :
 - fepriv-exit = 1;
 - thread loop catch stop event and break while loop
 - fepriv-thread = NULL; and fepriv-exit = 0;
- dvb_unregister_frontend wait on fepriv-dvbdev-wait_queue that 
fepriv-dvbdev-users==-1.
The user finish :
- dvb_frontend_release 
- set users to -1

- don't wait wait_queue because fepriv-exit != 1

= dvb_unregister_frontend never exit the wait queue.


Matthieu


[ 4920.484047] khubd D c2008000 0   198  2 0x
[ 4920.484056]  f64c8000 0046  c2008000 0004 c13fa000 c13fa000 f
64c8000
[ 4920.484066]  f64c81bc c2008000  d9d9dce6 0452 0001 f64c8000 c
102daad
[ 4920.484075]  00100100 f64c81bc 0286 f0a7ccc0 f0913404 f0cba404 f644de58 f
092b0a8
[ 4920.484084] Call Trace:
[ 4920.484102]  [c102daad] ? default_wake_function+0x0/0x8
[ 4920.484147]  [f8cb09e1] ? dvb_unregister_frontend+0x95/0xcc [dvb_core]
[ 4920.484157]  [c1044412] ? autoremove_wake_function+0x0/0x2d
[ 4920.484168]  [f8dd1af2] ? dvb_usb_adapter_frontend_exit+0x12/0x21 [dvb_usb]
[ 4920.484176]  [f8dd12f1] ? dvb_usb_exit+0x26/0x88 [dvb_usb]
[ 4920.484184]  [f8dd138d] ? dvb_usb_device_exit+0x3a/0x4a [dvb_usb]
[ 4920.484217]  [f7fe1b08] ? usb_unbind_interface+0x3f/0xb4 [usbcore]
[ 4920.484227]  [c11a4178] ? __device_release_driver+0x74/0xb7
[ 4920.484233]  [c11a4247] ? device_release_driver+0x15/0x1e
[ 4920.484243]  [c11a3a33] ? bus_remove_device+0x6e/0x87
[ 4920.484249]  [c11a26d6] ? device_del+0xfa/0x152
[ 4920.484264]  [f7fdf609] ? usb_disable_device+0x59/0xb9 [usbcore]
[ 4920.484279]  [f7fdb9ee] ? usb_disconnect+0x70/0xdc [usbcore]
[ 4920.484294]  [f7fdc728] ? hub_thread+0x521/0xe1d [usbcore]
[ 4920.484301]  [c1044412] ? autoremove_wake_function+0x0/0x2d
[ 4920.484316]  [f7fdc207] ? hub_thread+0x0/0xe1d [usbcore]
[ 4920.484321]  [c10441e0] ? kthread+0x61/0x66
[ 4920.484327]  [c104417f] ? kthread+0x0/0x66
[ 4920.484336]  [c1003d47] ? kernel_thread_helper+0x7/0x10
--
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


i2c interface bugs in dvb drivers

2010-03-21 Thread matthieu castet

Hi,

some dvb driver that export a i2c interface contains some mistakes because they 
mainly used by driver (frontend, tuner) wrote for them.
But the i2c interface is exposed to everybody.

One mistake is expect msg[i].addr with 8 bits address instead of 7 bits 
address. This make them use eeprom address at 0xa0 instead of 0x50. Also they 
shift tuner address (qt1010 tuner is likely to be at address 0x62, but some put 
it a 0xc4 (af9015, af9005, dtv5100)).

Other mistakes is in xfer callback. Often the controller support a limited i2c 
support (n bytes write then m bytes read). The driver try to convert the linux 
i2c msg to this pattern, but they often miss cases :
- msg[i].len can be null
- msg write are not always followed by msg read

And this can be dangerous if these interfaces are exported to userspace via 
i2c-dev :
- some scanning program avoid eeprom by filtering 0x5x range, but now it is at 
0xax range (well that should happen because scan limit should be 0x77)
- some read only command can be interpreted as write command.


What should be done ?
Fix the drivers.
Have a mode where i2c interface are not exported to everybody.
Don't care.

First why does the i2c stack doesn't check that the address is on 7 bits (like 
the attached patch) ?

Also I believe a program for testing i2c interface corner case should catch 
most of these bugs :
- null msg[i].len
- different transactions on a device :
- one write/read transaction
- one write transaction then one read transaction
[...]

Does a such program exist ?


Matthieu

PS : please keep me in CC

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 3202a86..91e63ea 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1150,6 +1150,17 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 (msgs[ret].flags  I2C_M_RECV_LEN) ? + : );
 		}
 #endif
+		for (ret = 0; ret  num; ret++) {
+			if (msgs[ret].flags  I2C_M_TEN) {
+/* XXX whats I2C_M_TEN range */
+if (msgs[ret].addr  0x03 || msgs[ret].addr  0x377)
+	return -EINVAL;
+			}
+			else {
+if (msgs[ret].addr  0x03 || msgs[ret].addr  0x77)
+	return -EINVAL;
+			}
+		}
 
 		if (in_atomic() || irqs_disabled()) {
 			ret = rt_mutex_trylock(adap-bus_lock);


videobuf cached user mapping

2010-01-15 Thread Matthieu CASTET
Hi,

Is that possible to have user mapping cached in Memory Mapping mode ?

This means buffer allocated by mmap in userspace, will have cache
support, and it will be faster to work on it.

But how the cache coherency can be done ?

For a camera we should :
- invalidate cache before dma operation (to have not old buffer data in
the cache)
- forbid the user to access the buffer during the dma operation (to not
pollute the cache)

Is it possible ?
How can we achieve that ?

I see sync method, that seems only called after frame capture ?


Or user User Pointers is the solution ?
But they should have the same problems. Is there some documentation of
how user pointer are synchronised with dma ?

Thanks,
Matthieu


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


videobuf-dma-contig.c cached user mapping

2009-12-23 Thread Matthieu CASTET
Hi,

I would like to add support for cached user mapping to
videobuf-dma-contig.c.

For enabling this, vma-vm_page_prot =
pgprot_noncached(vma-vm_page_prot); line should be removed.

But now we should ensure user mapping cache coherency.
For that, for a camera we should :
- invalidate cache before dma operation (to have not old buffer data in
the cache)
- forbid the user to access the buffer during the dma operation (to not
pollute the cache)

Is it possible ?
How can we achieve that ?

I see sync method, that seems only called after frame capture ?


Thanks,
Matthieu
--
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: tm6010 status

2009-10-05 Thread matthieu castet

Hi,

Dênis Goes wrote:

Hi Matthieu...
I made the same answer yesterday... I want to help in development for use my
PixelView 405 USB.

Do you have the correct tridvid.sys file to extract the firmware ?


No, I took the firmware (for the tuner) somewhere on internet.

Some time ago I have done some usb sniffing on Windows for my HVR900H, study 
the linux driver and start
some analysis [2].

I found some strange thing on i2c bus [1]. Then I figure out what should be 
done to make
work the digital part.
But because of lack of time and motivation (like everybody ;) ), I stopped 
working on this.

Matthieu

[1] 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg00987.html


[2]
== i2c ==
0x1f zl
0xa0 eeprom
0xa2 ??? (0xff)
0xa4
0xa6-0xac ??? (0xff)
0xae 
0xc2 (tuner)

== gpio ==
0 (WP eeprom ?? )
1 ZL RESET
2 tuner_reset_gpio
4 input sel ???
5 (led green)
7 (led blue)
== eeprom format ==
0x0-0x3 : magic ???
0x4-0x15 : GetDescriptor device
0xc VID
0xE PID
0x10 DID
0x12 iManufacturer
0x13 Product string
0x14 SerialNumber

0x40 string size (10 03) ???
0x42-0x4f (Product string @32)
0x94 string size (16 03)
0x96-0xa9 (SerialNumber @64)
0x16 string size (02 03)
0x18- (iManufacturer @16)

0x60 : iConfiguration index ???
0x6a string size (0a 03)
0x6c (iConfiguration @48)

where is mac address and rev ???
--
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


tm6010 status

2009-10-04 Thread matthieu castet

Hi,

what's the status of tm6010 support ?

http://www.mail-archive.com/linux-media@vger.kernel.org/msg04048.html announced 
some patches,
but nothing seems to have happened ?


Matthieu
--
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] DIBUSB_MC : fix i2c to not corrupt eeprom in case of strange read pattern

2009-05-16 Thread matthieu castet

Hi,


dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program
doing
file = open(/dev/i2c-x, O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

I attach a possible (untested) patch.


Matthieu

Signed-off-by: Matthieu CASTET castet.matth...@free.fr



Signed-off-by: Matthieu CASTET castet.matth...@free.fr
Index: linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c
===
--- linux-2.6.orig/drivers/media/dvb/dvb-usb/dibusb-common.c2009-02-09 
20:36:03.0 +0100
+++ linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c 2009-02-09 
20:38:21.0 +0100
@@ -133,14 +133,18 @@
 
for (i = 0; i  num; i++) {
/* write/read request */
-   if (i+1  num  (msg[i+1].flags  I2C_M_RD)) {
+   if (i+1  num  (msg[i].flags  I2C_M_RD) == 0
+  (msg[i+1].flags  I2C_M_RD)) {
if (dibusb_i2c_msg(d, msg[i].addr, 
msg[i].buf,msg[i].len,
msg[i+1].buf,msg[i+1].len)  0)
break;
i++;
-   } else
+   } else if ((msg[i].flags  I2C_M_RD) == 0) {
if (dibusb_i2c_msg(d, msg[i].addr, 
msg[i].buf,msg[i].len,NULL,0)  0)
break;
+   }
+   else
+   break;
}
 
mutex_unlock(d-i2c_mutex);



Re: [PATCH] Support faulty USB IDs on DIBUSB_MC

2009-02-09 Thread matthieu castet

Hi,

matthieu castet wrote:

matthieu castet wrote:

Hi Patrick,

Patrick Boettcher wrote:

Hi,

sorry for not answering ealier, recently I became the master of 
postponing things. :(


On Thu, 29 Jan 2009, Mauro Carvalho Chehab wrote:

+/* 14 */{ USB_DEVICE(USB_VID_CYPRESS,
USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },

+#endif


It doesn't sound a very good approach the need of recompiling the 
driver to
allow it to work with a broken card. The better would be to have 
some modprobe
option to force it to accept a certain USB ID as a valid ID for the 
card.


The most correct way would be to reprogram the eeprom, by simply 
writing to 0xa0 (0x50  1) I2C address... There was a thread on the 
linux-dvb some time ago.



BTW dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program 
doing

file = open(/dev/i2c-x, O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
 read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.


Patrick, any info about that.

I attach a possible (untested) patch.


Matthieu
Signed-off-by: Matthieu CASTET castet.matth...@free.fr
Index: linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c
===
--- linux-2.6.orig/drivers/media/dvb/dvb-usb/dibusb-common.c2009-02-09 
20:36:03.0 +0100
+++ linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c 2009-02-09 
20:38:21.0 +0100
@@ -133,14 +133,18 @@
 
for (i = 0; i  num; i++) {
/* write/read request */
-   if (i+1  num  (msg[i+1].flags  I2C_M_RD)) {
+   if (i+1  num  (msg[i].flags  I2C_M_RD) == 0
+  (msg[i+1].flags  I2C_M_RD)) {
if (dibusb_i2c_msg(d, msg[i].addr, 
msg[i].buf,msg[i].len,
msg[i+1].buf,msg[i+1].len)  0)
break;
i++;
-   } else
+   } else if ((msg[i].flags  I2C_M_RD) == 0) {
if (dibusb_i2c_msg(d, msg[i].addr, 
msg[i].buf,msg[i].len,NULL,0)  0)
break;
+   }
+   else
+   break;
}
 
mutex_unlock(d-i2c_mutex);


Re: [PATCH] Support faulty USB IDs on DIBUSB_MC

2009-01-29 Thread matthieu castet

Hi Patrick,

Patrick Boettcher wrote:

Hi,

sorry for not answering ealier, recently I became the master of 
postponing things. :(


On Thu, 29 Jan 2009, Mauro Carvalho Chehab wrote:

+/* 14 */{ USB_DEVICE(USB_VID_CYPRESS,
USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },

+#endif


It doesn't sound a very good approach the need of recompiling the 
driver to
allow it to work with a broken card. The better would be to have some 
modprobe

option to force it to accept a certain USB ID as a valid ID for the card.


The most correct way would be to reprogram the eeprom, by simply writing 
to 0xa0 (0x50  1) I2C address... There was a thread on the linux-dvb 
some time ago.



Why not, I only don't want to maintain a patch for my device.

I wonder why didn't they use WP pin of the eeprom to avoid write.

Do you know what should be written.
After a quick search, I found [1]. Is that ok ?


Matthieu

[1]
EEPROM AddressContents
  00xC0
  1Vendor ID (VID) L
  2Vendor ID (VID) H
  3Product ID (PID) L
  4Product ID (PID) H
  5Device ID (DID) L
  6Device ID (DID) H
  7Configuration byte

--
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] Support faulty USB IDs on DIBUSB_MC

2009-01-29 Thread matthieu castet

matthieu castet wrote:

Hi Patrick,

Patrick Boettcher wrote:

Hi,

sorry for not answering ealier, recently I became the master of 
postponing things. :(


On Thu, 29 Jan 2009, Mauro Carvalho Chehab wrote:

+/* 14 */{ USB_DEVICE(USB_VID_CYPRESS,
USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },

+#endif


It doesn't sound a very good approach the need of recompiling the 
driver to
allow it to work with a broken card. The better would be to have some 
modprobe
option to force it to accept a certain USB ID as a valid ID for the 
card.


The most correct way would be to reprogram the eeprom, by simply 
writing to 0xa0 (0x50  1) I2C address... There was a thread on the 
linux-dvb some time ago.



BTW dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program 
doing

file = open(/dev/i2c-x, O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
 read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

Now that I think of that, I run sensors-detect on this machine, may be 
this is what trash the eeprom ?



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


tm6010 : strange i2c

2009-01-29 Thread matthieu castet

Hi,

I am trying to make work my hauppauge HVR900H, and I start looking at 
http://linuxtv.org/hg/~mchehab/tm6010/ drivers and windows usb trace.



After some experiment I found that the i2c is very strange :
 * for the zl10353 demodulator, the register read only seems to work if 
the register address is odd and we read at least 2 bytes[1]. And the 
windows driver seems to really do that according usb trace (read always 
2 bytes at odd address).


 * the windows driver read the eeprom in the strange way : it use 
REQ_14_SET_GET_I2C_WR2_RDN, but setting the offset in the high byte of 
wIndex. And it does 16 bytes read, 1 bytes read for reading again the 
last 16th byte, and continue 16 bytes read, 1 byte read.


Did the people that worked on the tm6000 driver saw that weird i2c ?


Matthieu


[1]
Doing REQ_16_SET_GET_I2C_WR1_RDN on the demodulator with different 
register address and read size.


0051: 00
--
0051: 00
--
0052: 00
--
0050: 00
--
004f: 00
--
0050: 00
--
0051: 44 46
--
0051: 44 46
--
0052: 46 46
--
0050: 46 46
--
004f: 46 0c
--
0050: 0c 0c
--
0051: 44 46 15 0f
--
0051: 44 46 15 0f
--
0052: 0f 0f 00 00
--
0050: 00 00 00 00
--
004f: 00 0c 44 46
--
0050: 46 46 00 00
--
0051: 44 46 15 0f 00 00 00 00
--
0051: 44 46 15 0f 00 00 00 00
--
0052: 00 00 00 00 00 00 00 00
--
0050: 00 00 00 00 00 00 00 00
--
004f: 00 0c 44 46 15 0f 00 00
--
0050: 00 00 00 00 00 00 00 00
--
0051: 44 46 15 0f 00 00 00 00 00 48 00 75 0d 0d 0d 00
--
0051: 44 46 15 0f 00 00 00 00 00 48 00 75 0d 0d 0d 00
--
0052: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
--
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
--
004f: 00 0c 44 46 15 0f 00 00 00 00 00 48 00 75 0d 0d
--
0050: 0d 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00
--
0051: 44 46 15 0f 00 00 00 00 00 48 00 75 0d 0d 0d 00
0061: 4d 0a 0f 0f 0f 0f c2 00 00 80 00 00 00 00 00 00
--
0051: 44 46 15 0f 00 00 00 00 00 48 00 75 0d 0d 0d 00
0061: 4d 0a 0f 0f 0f 0f c2 00 00 80 00 00 00 00 00 00
--
0052: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0062: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
--
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
--
004f: 00 0c 44 46 15 0f 00 00 00 00 00 48 00 75 0d 0d
005f: 0d 00 4d 0a 0f 0f 0f 0f c2 00 00 80 00 00 00 00
--
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
--
--
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


haupauge remote keycode for av7110_loadkeys

2009-01-19 Thread matthieu castet

Hi,

I attached keycodes for 
http://www.hauppauge.eu/boutique_us/images_produits/111.jpg remote.


Can it be added to dvb-apps/util/av7110_loadkeys/ repo.

Matthieu

PS : this is more or less a duplicate of keycode in 
ir_codes_hauppauge_new (ir-kbd-i2c.c) and it could be useful to merge 
them. But I like better the av7110_loadkeys approch, because with 
ir-kbd-i2c you can't use other remote without modifying the source code.

0x3d KEY_POWER
0x3b KEY_GOTO

0x1c KEY_TV
0x18 KEY_VIDEO
0x19 KEY_AUDIO
0x1a KEY_MHP
0x1b KEY_EPG
0x0c KEY_RADIO

0x14 KEY_UP
0x16 KEY_LEFT
0x17 KEY_RIGHT
0x15 KEY_DOWN
0x25 KEY_ENTER

0x1f KEY_EXIT
0x0d KEY_MENU

0x10 KEY_VOLUMEUP
0x11 KEY_VOLUMEDOWN
0x20 KEY_CHANNELUP
0x21 KEY_CHANNELDOWN
0x12 KEY_PREVIOUS

0x0f KEY_MUTE
0x32 KEY_REWIND
0x35 KEY_PLAY
0x34 KEY_FASTFORWARD
0x37 KEY_RECORD
0x36 KEY_STOP
0x30 KEY_PAUSE
0x24 KEY_PREVIOUSSONG
0x1e KEY_NEXTSONG

0x00 KEY_0
0x01 KEY_1
0x02 KEY_2
0x03 KEY_3
0x04 KEY_4
0x05 KEY_5
0x06 KEY_6
0x07 KEY_7
0x08 KEY_8
0x09 KEY_9
0x0a KEY_TEXT
0x0e KEY_SUBTITLE

0x0b KEY_RED
0x2e KEY_GREEN
0x38 KEY_YELLOW
0x29 KEY_BLUE