[PATCH] em28xx: Reworked probe code to get rid of some hacks (was: Re: em28xx_isoc_dvb_max_packetsize for EM2884 (Terratec Cinergy HTC Stick))

2011-12-28 Thread Holger Nelson
Reworked device probing to get rid of hacks to guess the maximum size of 
dvb iso transfer packets. The new code also selects the first alternate 
config which supports the largest possible iso transfers for dvb. 

Signed-off-by: Holger Nelson 

diff --git a/drivers/media/video/em28xx/em28xx-audio.c 
b/drivers/media/video/em28xx/em28xx-audio.c
index cff0768..e2a7b77 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -193,7 +193,7 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
 
urb->dev = dev->udev;
urb->context = dev;
-   urb->pipe = usb_rcvisocpipe(dev->udev, 0x83);
+   urb->pipe = usb_rcvisocpipe(dev->udev, EM28XX_EP_AUDIO);
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = dev->adev.transfer_buffer[i];
urb->interval = 1;
diff --git a/drivers/media/video/em28xx/em28xx-cards.c 
b/drivers/media/video/em28xx/em28xx-cards.c
index a7cfded..027f769 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -3087,12 +3087,11 @@ unregister_dev:
 static int em28xx_usb_probe(struct usb_interface *interface,
const struct usb_device_id *id)
 {
-   const struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev;
struct em28xx *dev = NULL;
int retval;
-   bool is_audio_only = false, has_audio = false;
-   int i, nr, isoc_pipe;
+   bool has_audio = false, has_video = false, has_dvb = false;
+   int i, nr;
const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
char *speed;
char descr[255] = "";
@@ -3124,54 +3123,63 @@ static int em28xx_usb_probe(struct usb_interface 
*interface,
goto err;
}
 
+   /* allocate memory for our device state and initialize it */
+   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+   if (dev == NULL) {
+   em28xx_err(DRIVER_NAME ": out of memory!\n");
+   retval = -ENOMEM;
+   goto err;
+   }
+
+   /* compute alternate max packet sizes */
+   dev->alt_max_pkt_size = kmalloc(sizeof(dev->alt_max_pkt_size[0]) * 
interface->num_altsetting, GFP_KERNEL);
+   if (dev->alt_max_pkt_size == NULL) {
+   em28xx_errdev("out of memory!\n");
+   kfree(dev);
+   retval = -ENOMEM;
+   goto err;
+   }
+
/* Get endpoints */
for (i = 0; i < interface->num_altsetting; i++) {
int ep;
 
for (ep = 0; ep < interface->altsetting[i].desc.bNumEndpoints; 
ep++) {
-   struct usb_host_endpoint*e;
-   e = &interface->altsetting[i].endpoint[ep];
-
-   if (e->desc.bEndpointAddress == 0x83)
-   has_audio = true;
+   const struct usb_endpoint_descriptor *e;
+   int sizedescr, size;
+
+   e = &interface->altsetting[i].endpoint[ep].desc;
+
+   sizedescr = le16_to_cpu(e->wMaxPacketSize);
+   size = sizedescr & 0x7ff;
+
+   if (udev->speed == USB_SPEED_HIGH)
+   size = size * hb_mult(sizedescr);
+
+   if (usb_endpoint_xfer_isoc(e) && 
usb_endpoint_dir_in(e)) {
+   switch (e->bEndpointAddress) {
+   case EM28XX_EP_AUDIO:
+   has_audio = true;
+   break;
+   case EM28XX_EP_ANALOG:
+   has_video = true;
+   dev->alt_max_pkt_size[i] = size;
+   break;
+   case EM28XX_EP_DIGITAL:
+   has_dvb = true;
+   if (size > dev->dvb_max_pkt_size) {
+   dev->dvb_max_pkt_size = size;
+   dev->dvb_alt = i;
+   }
+   break;
+   }
+   }
}
}
 
-   endpoint = &interface->cur_altsetting->endpoint[0].desc;
-
-   /* check if the device has the iso in endpoint at the correct place */
-   if (usb_endpoint_xfer_isoc(endpoint)
-   &&
-   (interface->altsetting[1].endpoint[0].desc.wMaxPacketSize == 940)) {
-   /* It's a newer em2874/em2875 device */
-   isoc_pipe = 0;
-   } e

Re: em28xx_isoc_dvb_max_packetsize for EM2884 (Terratec Cinergy HTC Stick)

2011-12-27 Thread Holger Nelson

On Mon, 26 Dec 2011, Mauro Carvalho Chehab wrote:


I'm currently without time right now to work on a patch, but I think that 
several hacks
inside the em28xx probe should be removed, including the one that detects the 
endpoint
based on the packet size.

As it is easier to code than to explain in words, the code below could be
a start (ok, it doesn't compile, doesn't remove all hacks, doesn't free memory, 
etc...)
Feel free to use it as a start for a real patch, if you wish.


I think, I filled the missing parts and removed most of the hacks in the 
probe code. The code works with my Cinergy HTC USB XS.


Holger

diff --git a/drivers/media/video/em28xx/em28xx-audio.c 
b/drivers/media/video/em28xx/em28xx-audio.c
index cff0768..e2a7b77 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -193,7 +193,7 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)

urb->dev = dev->udev;
urb->context = dev;
-   urb->pipe = usb_rcvisocpipe(dev->udev, 0x83);
+   urb->pipe = usb_rcvisocpipe(dev->udev, EM28XX_EP_AUDIO);
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = dev->adev.transfer_buffer[i];
urb->interval = 1;
diff --git a/drivers/media/video/em28xx/em28xx-cards.c 
b/drivers/media/video/em28xx/em28xx-cards.c
index a7cfded..8082914 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -3087,12 +3087,11 @@ unregister_dev:
 static int em28xx_usb_probe(struct usb_interface *interface,
const struct usb_device_id *id)
 {
-   const struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev;
struct em28xx *dev = NULL;
int retval;
-   bool is_audio_only = false, has_audio = false;
-   int i, nr, isoc_pipe;
+   bool has_audio = false, has_video = false, has_dvb = false;
+   int i, nr, sizedescr, size;
const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
char *speed;
char descr[255] = "";
@@ -3124,56 +3123,69 @@ static int em28xx_usb_probe(struct usb_interface 
*interface,
goto err;
}

-   /* Get endpoints */
-   for (i = 0; i < interface->num_altsetting; i++) {
-   int ep;
+   /* allocate memory for our device state and initialize it */
+   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+   if (dev == NULL) {
+   em28xx_err(DRIVER_NAME ": out of memory!\n");
+   retval = -ENOMEM;
+   goto err;
+   }

-   for (ep = 0; ep < interface->altsetting[i].desc.bNumEndpoints; 
ep++) {
-   struct usb_host_endpoint*e;
-   e = &interface->altsetting[i].endpoint[ep];
+   /* compute alternate max packet sizes */
+   dev->alt_video_max_pkt_size = 
kmalloc(sizeof(dev->alt_video_max_pkt_size[0]) * interface->num_altsetting, 
GFP_KERNEL);
+   if (dev->alt_video_max_pkt_size == NULL) {
+   em28xx_errdev("out of memory!\n");
+   kfree(dev);
+   retval = -ENOMEM;
+   goto err;
+   }

-   if (e->desc.bEndpointAddress == 0x83)
-   has_audio = true;
-   }
+   dev->alt_dvb_max_pkt_size = kmalloc(sizeof(dev->alt_dvb_max_pkt_size[0]) * 
interface->num_altsetting, GFP_KERNEL);
+   if (dev->alt_dvb_max_pkt_size == NULL) {
+   em28xx_errdev("out of memory!\n");
+   kfree(dev->alt_video_max_pkt_size);
+   kfree(dev);
+   retval = -ENOMEM;
+   goto err;
}

-   endpoint = &interface->cur_altsetting->endpoint[0].desc;
+   /* Get endpoints */
+   for (i = 0; i < interface->num_altsetting; i++) {
+   int ep;

-   /* check if the device has the iso in endpoint at the correct place */
-   if (usb_endpoint_xfer_isoc(endpoint)
-   &&
-   (interface->altsetting[1].endpoint[0].desc.wMaxPacketSize == 940)) {
-   /* It's a newer em2874/em2875 device */
-   isoc_pipe = 0;
-   } else {
-   int check_interface = 1;
-   isoc_pipe = 1;
-   endpoint = &interface->cur_altsetting->endpoint[1].desc;
-   if (!usb_endpoint_xfer_isoc(endpoint))
-   check_interface = 0;
-
-   if (usb_endpoint_dir_out(endpoint))
-   check_interface = 0;
-
-   if (!check_interface) {
-   if (has_audio) {
-   is_audio_only = true;
-   } else {
-   em28xx_err(DRIVER_NAME " video device (%04x:%04x): 
"
-   "interface %i, class %i found.\n",
-   le16_to_cpu(udev->descriptor.idVend

Re: em28xx_isoc_dvb_max_packetsize for EM2884 (Terratec Cinergy HTC Stick)

2011-12-25 Thread Holger Nelson

Hi!

On Sun, 25 Dec 2011, Dennis Sperlich wrote:


I just tried, replacing
   max_dvb_packet_size = em28xx_isoc_dvb_max_packetsize(dev);
by
   max_dvb_packet_size = dev->alt_max_pkt_size[1];

but it did not work. Was this the correct replacement?

   printk(KERN_INFO "dev->alt_max_pkt_size[1] is 
%i\n",dev->alt_max_pkt_size[1]);


then said, dev->alt_max_pkt_size[1] is 0.

I also attachted  a lsusb -v output for the Terratec Cinergy HTC Stick. I 
don't know, which of these endpoints the dvb-c part is, but it may be anyway 
usefull.


Is it possible, that dev->alt_max_pkt_size gets the maximum packet sizes 
for the analog video input endpoint (0x82 in lsusb output)? The patch 
below worked during a small test, but I doubt that it is the best way to 
do it.


While still looking at it: Is there a reason to allocate 32 bytes per 
alternate interface configuration if we only store one unsigned int per 
configuration in it? - I just copied the allocation code from above.


Holger

diff --git a/drivers/media/video/em28xx/em28xx-cards.c 
b/drivers/media/video/em28xx/em28xx-cards.c
index 1704da0..70866c5 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -3269,6 +3273,30 @@ static int em28xx_usb_probe(struct usb_interface 
*interface,
dev->alt_max_pkt_size[i] = size;
}

+   dev->alt_dvb_max_pkt_size = kmalloc(32 * dev->num_alt, GFP_KERNEL);
+
+   if (dev->alt_dvb_max_pkt_size == NULL) {
+   em28xx_errdev("out of memory!\n");
+   kfree(dev);
+   retval = -ENOMEM;
+   goto err;
+   }
+
+   for (i = 0; i < dev->num_alt ; i++) {
+   int ep;
+   for (ep = 0; ep < interface->altsetting[i].desc.bNumEndpoints; 
ep++) {
+   struct usb_host_endpoint *e = 
&interface->altsetting[i].endpoint[ep];
+   if (e->desc.bEndpointAddress == 0x84) {
+   u16 tmp = le16_to_cpu(e->desc.wMaxPacketSize);
+   unsigned int size = tmp & 0x7ff;
+   if (udev->speed == USB_SPEED_HIGH)
+   size = size * hb_mult(tmp);
+
+   dev->alt_dvb_max_pkt_size[i] = size;
+   }
+   }
+   }
+
if ((card[nr] >= 0) && (card[nr] < em28xx_bcount))
dev->model = card[nr];

@@ -3281,6 +3309,7 @@ static int em28xx_usb_probe(struct usb_interface 
*interface,
retval = em28xx_init_dev(&dev, udev, interface, nr);
if (retval) {
mutex_unlock(&dev->lock);
+   kfree(dev->alt_dvb_max_pkt_size);
kfree(dev->alt_max_pkt_size);
kfree(dev);
goto err;
@@ -3365,6 +3394,7 @@ static void em28xx_usb_disconnect(struct usb_interface 
*interface)
em28xx_close_extension(dev);

if (!dev->users) {
+   kfree(dev->alt_dvb_max_pkt_size);
kfree(dev->alt_max_pkt_size);
kfree(dev);
}
diff --git a/drivers/media/video/em28xx/em28xx-core.c 
b/drivers/media/video/em28xx/em28xx-core.c
index 804a4ab..e7d3541 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -1157,7 +1157,7 @@ int em28xx_isoc_dvb_max_packetsize(struct em28xx *dev)
 * FIXME: same as em2874. 564 was enough for 22 Mbit DVB-T
 * but not enough for 44 Mbit DVB-C.
 */
-   packet_size = 752;
+   packet_size = dev->alt_dvb_max_pkt_size[1];
}

return packet_size;
diff --git a/drivers/media/video/em28xx/em28xx-video.c 
b/drivers/media/video/em28xx/em28xx-video.c
index 9b4557a..2491a2c 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -2254,6 +2254,7 @@ static int em28xx_v4l2_close(struct file *filp)
   free the remaining resources */
if (dev->state & DEV_DISCONNECTED) {
em28xx_release_resources(dev);
+   kfree(dev->alt_dvb_max_pkt_size);
kfree(dev->alt_max_pkt_size);
kfree(dev);
return 0;
diff --git a/drivers/media/video/em28xx/em28xx.h 
b/drivers/media/video/em28xx/em28xx.h
index b1199ef..793c85a 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -597,6 +597,7 @@ struct em28xx {
int max_pkt_size;   /* max packet size of isoc transaction */
int num_alt;/* Number of alternative settings */
unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
+   unsigned int *alt_dvb_max_pkt_size;
struct urb *urb[EM28XX_NUM_BUFS];   /* urb for isoc transfers */
char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc
 

[PATCH] em28xx: Add Terratec Cinergy HTC USB XS to em28xx-cards.c

2011-12-23 Thread Holger Nelson
This adds support for the Terratec Cinergy HTC USB XS which is similar to 
the Terratec H5 by adding the USB-ids to the table. According to 
http://linux.terratec.de it uses the same ICs and DVB-C works for me

using the firmware of the H5.

Signed-off-by: Holger Nelson 
---
diff --git a/drivers/media/video/em28xx/em28xx-cards.c 
b/drivers/media/video/em28xx/em28xx-cards.c
index 1704da0..a7cfded 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -1963,6 +1963,10 @@ struct usb_device_id em28xx_id_table[] = {
.driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
{ USB_DEVICE(0x0ccd, 0x0043),
.driver_info = EM2870_BOARD_TERRATEC_XS },
+   { USB_DEVICE(0x0ccd, 0x008e),   /* Cinergy HTC USB XS Rev. 1 */
+   .driver_info = EM2884_BOARD_TERRATEC_H5 },
+   { USB_DEVICE(0x0ccd, 0x00ac),   /* Cinergy HTC USB XS Rev. 2 */
+   .driver_info = EM2884_BOARD_TERRATEC_H5 },
{ USB_DEVICE(0x0ccd, 0x10a2),   /* H5 Rev. 1 */
.driver_info = EM2884_BOARD_TERRATEC_H5 },
{ USB_DEVICE(0x0ccd, 0x10ad),   /* H5 Rev. 2 */
--
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


Some success with Terratec Cinergy HTC USB XS

2011-08-28 Thread Holger Nelson

Hi,

I had some success with a Terratec Cinergy HTC USB XS:
I added the usb id as a Terratec H5 to em28xx-cards.c and downloaded
the firmware file for Terratec H5, because I saw on Terratecs linux-site 
that both devices use the same ICs. DVB-C works with this setup.
Watching analog tv didn't work: Xawtv timed out or hang trying to 
access /dev/video0.


Is there anything else I could test?


regards,
Holger

--- linux/drivers/media/video/em28xx/em28xx-cards.c~2011-07-18 
05:45:26.0 +0200
+++ linux/drivers/media/video/em28xx/em28xx-cards.c 2011-08-27 
21:15:26.564483966 +0200
@@ -1883,6 +1883,8 @@ struct usb_device_id em28xx_id_table[] =
.driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
{ USB_DEVICE(0x0ccd, 0x0042),
.driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
+   { USB_DEVICE(0x0ccd, 0x008e),
+   .driver_info = EM2884_BOARD_TERRATEC_H5 },
{ USB_DEVICE(0x0ccd, 0x0043),
.driver_info = EM2884_BOARD_TERRATEC_H5 },
{ USB_DEVICE(0x0ccd, 0x10a2),   /* Rev. 1 */
--
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: Add support for Terratec Grabster AV 150/250 MX

2011-02-02 Thread Holger Nelson
This patch adds support for Terratec Grabster AV 150/250 MX. For now it is 
only possible to use composite input as switching inputs does not work.


Signed-off-by: Holger Nelson 

---
 drivers/staging/tm6000/tm6000-cards.c |   17 +
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/tm6000/tm6000-cards.c 
b/drivers/staging/tm6000/tm6000-cards.c
index 455038b..078bba4 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -50,6 +50,7 @@
 #define TM6010_BOARD_BEHOLD_VOYAGER11
 #define TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE12
 #define TM6010_BOARD_TWINHAN_TU501 13
+#define TM5600_BOARD_TERRATEC_GRABSTER 14

 #define TM6000_MAXBOARDS16
 static unsigned int card[] = {[0 ... (TM6000_MAXBOARDS - 1)] = UNSET };
@@ -303,6 +304,19 @@ struct tm6000_board tm6000_boards[] = {
.dvb_led= TM6010_GPIO_5,
.ir = TM6010_GPIO_0,
},
+   },
+   [TM5600_BOARD_TERRATEC_GRABSTER] = {
+   .name = "Terratec Grabster AV 150/250 MX",
+   .type = TM5600,
+   .caps = {
+   .has_tuner  = 0,
+   .has_dvb= 0,
+   .has_zl10353= 0,
+   .has_eeprom = 0,
+   .has_remote = 0,
+   },
+   .gpio = {
+   },
}
 };

@@ -325,6 +339,7 @@ struct usb_device_id tm6000_id_table[] = {
{ USB_DEVICE(0x13d3, 0x3241), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
{ USB_DEVICE(0x13d3, 0x3243), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
{ USB_DEVICE(0x13d3, 0x3264), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
+   { USB_DEVICE(0x0ccd, 0x0079), .driver_info = 
TM5600_BOARD_TERRATEC_GRABSTER },
{ },
 };

@@ -488,6 +503,8 @@ int tm6000_cards_setup(struct tm6000_core *dev)
 * the board-specific session.
 */
switch (dev->model) {
+   case TM5600_BOARD_TERRATEC_GRABSTER:
+   return 0;
case TM6010_BOARD_HAUPPAUGE_900H:
case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
case TM6010_BOARD_TWINHAN_TU501:
--
1.7.1
--
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 Terratec Grabster support to tm6000

2011-01-05 Thread Holger Nelson

On Tue, 4 Jan 2011, Stefan Ringel wrote:


Am 04.01.2011 20:12, schrieb Holger Nelson:

Hi,
the following patch adds support for a Terratec Grabster AV MX150 (and 
maybe other devices in the Grabster series). This device is an analog 
frame grabber device using a tm5600. This device doesn't have a tuner, 
so I changed the code to skip the tuner reset if neither has_tuner nor 
has_dvb is set.
it skip, if you has no tuner gpio defined. You does'nt need more. Work 
the driver with input select (tv (conposite0), composite, s-vhs)?


Yes tuner reset is skipped, but in the else-branch, the code also 
complains that tuner reset is not configured and returns -1, which makes 
tm6000_init_dev exit before v4l2_device_register is called. Switching 
inputs does not work, but at least I can use the composite input, if I 
use the tv-input.


Below is a new version of the patch.

Holger

diff --git a/drivers/staging/tm6000/tm6000-cards.c 
b/drivers/staging/tm6000/tm6000-cards.c
index 5a7946c..0f4154f 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -50,6 +50,7 @@
 #define TM6010_BOARD_BEHOLD_VOYAGER11
 #define TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE12
 #define TM6010_BOARD_TWINHAN_TU501 13
+#define TM5600_BOARD_TERRATEC_GRABSTER 14

 #define TM6000_MAXBOARDS16
 static unsigned int card[] = {[0 ... (TM6000_MAXBOARDS - 1)] = UNSET };
@@ -303,6 +304,19 @@ struct tm6000_board tm6000_boards[] = {
.dvb_led= TM6010_GPIO_5,
.ir = TM6010_GPIO_0,
},
+   },
+   [TM5600_BOARD_TERRATEC_GRABSTER] = {
+   .name = "Terratec Grabster AV 150/250 MX",
+   .type = TM5600,
+   .caps = {
+   .has_tuner  = 0,
+   .has_dvb= 0,
+   .has_zl10353= 0,
+   .has_eeprom = 0,
+   .has_remote = 0,
+   },
+   .gpio = {
+   },
}
 };

@@ -325,6 +339,7 @@ struct usb_device_id tm6000_id_table[] = {
{ USB_DEVICE(0x13d3, 0x3241), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
{ USB_DEVICE(0x13d3, 0x3243), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
{ USB_DEVICE(0x13d3, 0x3264), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
+   { USB_DEVICE(0x0ccd, 0x0079), .driver_info = 
TM5600_BOARD_TERRATEC_GRABSTER },
{ },
 };

@@ -447,6 +462,8 @@ int tm6000_cards_setup(struct tm6000_core *dev)
 * the board-specific session.
 */
switch (dev->model) {
+   case TM5600_BOARD_TERRATEC_GRABSTER:
+   return 0;
case TM6010_BOARD_HAUPPAUGE_900H:
case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
case TM6010_BOARD_TWINHAN_TU501:
--
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 Terratec Grabster support to tm6000

2011-01-04 Thread Holger Nelson

Hi,

the following patch adds support for a Terratec Grabster AV MX150 (and 
maybe other devices in the Grabster series). This device is an analog 
frame grabber device using a tm5600. This device doesn't have a tuner, so 
I changed the code to skip the tuner reset if neither has_tuner nor 
has_dvb is set.


Holger

diff -urpN --exclude='*~' 
linux-2.6.37-rc8/drivers/staging/tm6000/tm6000-cards.c 
linux-lts-backport-natty-2.6.37/drivers/staging/tm6000/tm6000-cards.c
--- linux-2.6.37-rc8/drivers/staging/tm6000/tm6000-cards.c  2010-12-29 
02:05:48.0 +0100
+++ linux-lts-backport-natty-2.6.37/drivers/staging/tm6000/tm6000-cards.c   
2011-01-04 10:46:40.582497722 +0100
@@ -50,6 +50,7 @@
 #define TM6010_BOARD_BEHOLD_VOYAGER11
 #define TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE12
 #define TM6010_BOARD_TWINHAN_TU501 13
+#define TM5600_BOARD_TERRATEC_GRABSTER 14

 #define TM6000_MAXBOARDS16
 static unsigned int card[] = {[0 ... (TM6000_MAXBOARDS - 1)] = UNSET };
@@ -303,6 +304,19 @@ struct tm6000_board tm6000_boards[] = {
.dvb_led= TM6010_GPIO_5,
.ir = TM6010_GPIO_0,
},
+   },
+   [TM5600_BOARD_TERRATEC_GRABSTER] = {
+   .name = "Terratec Grabster Series",
+   .type = TM5600,
+   .caps = {
+   .has_tuner  = 0,
+   .has_dvb= 0,
+   .has_zl10353= 0,
+   .has_eeprom = 0,
+   .has_remote = 0,
+   },
+   .gpio = {
+   },
}
 };

@@ -325,6 +339,7 @@ struct usb_device_id tm6000_id_table[] =
{ USB_DEVICE(0x13d3, 0x3241), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
{ USB_DEVICE(0x13d3, 0x3243), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
{ USB_DEVICE(0x13d3, 0x3264), .driver_info = TM6010_BOARD_TWINHAN_TU501 
},
+   { USB_DEVICE(0x0ccd, 0x0079), .driver_info = 
TM5600_BOARD_TERRATEC_GRABSTER },
{ },
 };

@@ -505,33 +520,35 @@ int tm6000_cards_setup(struct tm6000_cor
 * reset, just add the code at the board-specific part
 */

-   if (dev->gpio.tuner_reset) {
-   for (i = 0; i < 2; i++) {
-   rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
-   dev->gpio.tuner_reset, 0x00);
-   if (rc < 0) {
-   printk(KERN_ERR "Error %i doing tuner reset\n", 
rc);
-   return rc;
-   }
+   if (dev->caps.has_tuner||dev->caps.has_dvb) {
+   if (dev->gpio.tuner_reset) {
+   for (i = 0; i < 2; i++) {
+   rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+   dev->gpio.tuner_reset, 
0x00);
+   if (rc < 0) {
+   printk(KERN_ERR "Error %i doing tuner 
reset\n", rc);
+   return rc;
+   }

-   msleep(10); /* Just to be conservative */
-   rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
-   dev->gpio.tuner_reset, 0x01);
-   if (rc < 0) {
-   printk(KERN_ERR "Error %i doing tuner reset\n", 
rc);
-   return rc;
-   }
-   msleep(10);
+   msleep(10); /* Just to be conservative */
+   rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+   dev->gpio.tuner_reset, 
0x01);
+   if (rc < 0) {
+   printk(KERN_ERR "Error %i doing tuner 
reset\n", rc);
+   return rc;
+   }
+   msleep(10);

-   if (!i) {
-   rc = tm6000_get_reg32(dev, REQ_40_GET_VERSION, 
0, 0);
-   if (rc >= 0)
-   printk(KERN_DEBUG "board=0x%08x\n", rc);
+   if (!i) {
+   rc = tm6000_get_reg32(dev, 
REQ_40_GET_VERSION, 0, 0);
+   if (rc >= 0)
+   printk(KERN_DEBUG 
"board=0x%08x\n", rc);
+   }
}
+   } else {
+   printk(KERN_ERR "Tuner reset is not configured\n");
+   return -1;
}
-   } else {
-   printk(KERN_ERR "Tuner reset