From 8dfe61a7f3c717807a8c0e94561551c0869c82b7 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Sat, 3 May 2003 10:00:59 +0000 Subject: Update dec driver to work with 2.5 kernels --- linux/drivers/media/dvb/dvb-core/dvb_compat.h | 15 ++++ .../drivers/media/dvb/ttusb-dec/dec2000_frontend.c | 1 + linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c | 90 ++++++++++++++++++++-- 3 files changed, 101 insertions(+), 5 deletions(-) (limited to 'linux/drivers/media/dvb') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_compat.h b/linux/drivers/media/dvb/dvb-core/dvb_compat.h index a777e7bdb..87cbc5e86 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_compat.h +++ b/linux/drivers/media/dvb/dvb-core/dvb_compat.h @@ -122,6 +122,21 @@ extern struct page * vmalloc_to_page(void *addr); #define devfs_mk_dir(parent,name,info) devfs_mk_dir(name) #endif +/* USB compatibility */ + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + +typedef struct iso_packet_descriptor usb_iso_packet_descriptor; +#define URB_ISO_ASAP USB_ISO_ASAP +#define URB_MEM_FLAG + +#else + +#define URB_MEM_FLAG , GFP_KERNEL + +#endif #endif diff --git a/linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c b/linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c index 05adad0f3..4a8ae58ff 100644 --- a/linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c +++ b/linux/drivers/media/dvb/ttusb-dec/dec2000_frontend.c @@ -20,6 +20,7 @@ */ #include "dvb_frontend.h" +#include "dvb_compat.h" static int debug = 0; diff --git a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 1a2ae9999..086183e37 100644 --- a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -25,6 +25,7 @@ #include #include "ttusb_dec.h" +#include "dvb_compat.h" #include "dvb_frontend.h" static int debug = 0; @@ -431,9 +432,16 @@ ttusb_dec_process_urb_frame(ttusb_dec_t * dec, u8 * b, int length) } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) static void ttusb_dec_process_urb(struct urb *urb) { +#else +static void +ttusb_dec_process_urb(struct urb *urb, struct pt_regs *ptregs) +{ + (void)ptregs; +#endif ttusb_dec_t *dec = urb->context; @@ -443,7 +451,7 @@ ttusb_dec_process_urb(struct urb *urb) for (i = 0; i < FRAMES_PER_ISO_BUF; i++) { - struct iso_packet_descriptor *d; + struct usb_iso_packet_descriptor *d; u8 *b; int length; @@ -464,6 +472,10 @@ ttusb_dec_process_urb(struct urb *urb) } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) + usb_submit_urb(urb URB_MEM_FLAG); +#endif + } static void @@ -483,7 +495,10 @@ ttusb_dec_setup_urbs(ttusb_dec_t * dec) urb->context = dec; urb->complete = ttusb_dec_process_urb; urb->pipe = dec->stream_pipe; - urb->transfer_flags = USB_ISO_ASAP; + urb->transfer_flags = URB_ISO_ASAP; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) + urb->interval = 1; +#endif urb->number_of_packets = FRAMES_PER_ISO_BUF; urb->transfer_buffer_length = ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF; @@ -541,6 +556,18 @@ ttusb_dec_start_iso_xfer(ttusb_dec_t *dec) if (down_interruptible(&dec->iso_sem)) return -EAGAIN; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) + if (!dec->interface) { + + /* Can't do this at mod init time - weird. + * Seems to work up here for 2.5 + */ + usb_set_interface(dec->udev, 0, 8); + dec->interface = 8; + + } +#endif + if (!dec->iso_stream_count) { u8 b0[] = { 0x05 }; @@ -551,14 +578,14 @@ ttusb_dec_start_iso_xfer(ttusb_dec_t *dec) for (i = 0; i < ISO_BUF_COUNT; i++) { - if ((result = usb_submit_urb(dec->iso_urb[i]))) { + if ((result = usb_submit_urb(dec->iso_urb[i] URB_MEM_FLAG))) { printk("%s: failed urb submission %d: error %d\n", __FUNCTION__, i, result); while (i) { - usb_unlink_urb(dec->iso_urb[i]); + usb_unlink_urb(dec->iso_urb[i - 1]); i--; } @@ -579,6 +606,7 @@ ttusb_dec_start_iso_xfer(ttusb_dec_t *dec) up(&dec->iso_sem); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if (!dec->interface) { /* Can't do this at mod init time - weird. @@ -590,6 +618,7 @@ ttusb_dec_start_iso_xfer(ttusb_dec_t *dec) dec->interface = 8; } +#endif return 0; @@ -735,7 +764,7 @@ ttusb_dec_alloc_iso_urbs(ttusb_dec_t * dec) struct urb *urb; - if (!(urb = usb_alloc_urb(FRAMES_PER_ISO_BUF))) { + if (!(urb = usb_alloc_urb(FRAMES_PER_ISO_BUF URB_MEM_FLAG))) { ttusb_dec_free_iso_urbs(dec); return -ENOMEM; @@ -748,12 +777,14 @@ ttusb_dec_alloc_iso_urbs(ttusb_dec_t * dec) ttusb_dec_setup_urbs(dec); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) for (i = 0; i < ISO_BUF_COUNT; i++) { int next = (i + 1) % ISO_BUF_COUNT; dec->iso_urb[i]->next = dec->iso_urb[next]; } +#endif return 0; @@ -1018,6 +1049,7 @@ ttusb_dec_exit_usb(ttusb_dec_t * dec) } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) static void * ttusb_dec_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id) @@ -1052,11 +1084,59 @@ ttusb_dec_probe(struct usb_device *udev, unsigned int ifnum, return (void *) dec; } +#else +static int +ttusb_dec_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + + struct usb_device *udev; + ttusb_dec_t *dec; + + dprintk("%s\n", __FUNCTION__); + + udev = interface_to_usbdev(intf); + + if (!(dec = kmalloc(sizeof (ttusb_dec_t), GFP_KERNEL))) { + + printk("%s: couldn't allocate memory.\n", __FUNCTION__); + return -ENOMEM; + + } + + memset(dec, 0, sizeof (ttusb_dec_t)); + + dec->udev = udev; + + ttusb_dec_init_usb(dec); + + ttusb_dec_init_stb(dec); + + ttusb_dec_init_dvb(dec); + + ttusb_dec_init_v_pes(dec); + + usb_set_intfdata(intf, (void *)dec); + + return 0; + +} +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) static void ttusb_dec_disconnect(struct usb_device *udev, void *data) { + ttusb_dec_t *dec = data; +#else +static void +ttusb_dec_disconnect(struct usb_interface *intf) +{ + + ttusb_dec_t *dec = usb_get_intfdata(intf); + + usb_set_intfdata(intf, NULL); +#endif dprintk("%s\n", __FUNCTION__); -- cgit v1.2.3