aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-04-26 10:24:18 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:58:18 -0400
commit6ae635c4f36d7a0b931feb4bb6dad6e5f18187cf (patch)
treec25817f7f8111fa9f0b82acf39f681b3e0673037 /drivers/staging
parent1ebf2c7f78bbf3501c13c6b442dc8e52beb77be6 (diff)
V4L/DVB: tm6000: Properly set alternate when preparing to stream
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 <behock@gmail.com>. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/tm6000/tm6000-cards.c51
-rw-r--r--drivers/staging/tm6000/tm6000-dvb.c2
-rw-r--r--drivers/staging/tm6000/tm6000-video.c21
-rw-r--r--drivers/staging/tm6000/tm6000.h11
4 files changed, 51 insertions, 34 deletions
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 3c652f26ebc..1aa6bc1a87e 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -650,21 +650,24 @@ err:
650/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */ 650/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
651#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03)) 651#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
652 652
653static void get_max_endpoint ( struct usb_device *usbdev, 653static void get_max_endpoint(struct usb_device *udev,
654 char *msgtype, 654 struct usb_host_interface *alt,
655 struct usb_host_endpoint *curr_e, 655 char *msgtype,
656 unsigned int *maxsize, 656 struct usb_host_endpoint *curr_e,
657 struct usb_host_endpoint **ep ) 657 struct tm6000_endpoint *tm_ep)
658{ 658{
659 u16 tmp = le16_to_cpu(curr_e->desc.wMaxPacketSize); 659 u16 tmp = le16_to_cpu(curr_e->desc.wMaxPacketSize);
660 unsigned int size = tmp & 0x7ff; 660 unsigned int size = tmp & 0x7ff;
661 661
662 if (usbdev->speed == USB_SPEED_HIGH) 662 if (udev->speed == USB_SPEED_HIGH)
663 size = size * hb_mult (tmp); 663 size = size * hb_mult (tmp);
664 664
665 if (size>*maxsize) { 665 if (size > tm_ep->maxsize) {
666 *ep = curr_e; 666 tm_ep->endp = curr_e;
667 *maxsize = size; 667 tm_ep->maxsize = size;
668 tm_ep->bInterfaceNumber = alt->desc.bInterfaceNumber;
669 tm_ep->bAlternateSetting = alt->desc.bAlternateSetting;
670
668 printk("tm6000: %s endpoint: 0x%02x (max size=%u bytes)\n", 671 printk("tm6000: %s endpoint: 0x%02x (max size=%u bytes)\n",
669 msgtype, curr_e->desc.bEndpointAddress, 672 msgtype, curr_e->desc.bEndpointAddress,
670 size); 673 size);
@@ -760,24 +763,28 @@ static int tm6000_usb_probe(struct usb_interface *interface,
760 switch (e->desc.bmAttributes) { 763 switch (e->desc.bmAttributes) {
761 case USB_ENDPOINT_XFER_BULK: 764 case USB_ENDPOINT_XFER_BULK:
762 if (!dir_out) { 765 if (!dir_out) {
763 get_max_endpoint (usbdev, "Bulk IN", e, 766 get_max_endpoint(usbdev,
764 &dev->max_bulk_in, 767 &interface->altsetting[i],
765 &dev->bulk_in); 768 "Bulk IN", e,
769 &dev->bulk_in);
766 } else { 770 } else {
767 get_max_endpoint (usbdev, "Bulk OUT", e, 771 get_max_endpoint(usbdev,
768 &dev->max_bulk_out, 772 &interface->altsetting[i],
769 &dev->bulk_out); 773 "Bulk OUT", e,
774 &dev->bulk_out);
770 } 775 }
771 break; 776 break;
772 case USB_ENDPOINT_XFER_ISOC: 777 case USB_ENDPOINT_XFER_ISOC:
773 if (!dir_out) { 778 if (!dir_out) {
774 get_max_endpoint (usbdev, "ISOC IN", e, 779 get_max_endpoint(usbdev,
775 &dev->max_isoc_in, 780 &interface->altsetting[i],
776 &dev->isoc_in); 781 "ISOC IN", e,
782 &dev->isoc_in);
777 } else { 783 } else {
778 get_max_endpoint (usbdev, "ISOC OUT", e, 784 get_max_endpoint(usbdev,
779 &dev->max_isoc_out, 785 &interface->altsetting[i],
780 &dev->isoc_out); 786 "ISOC OUT", e,
787 &dev->isoc_out);
781 } 788 }
782 break; 789 break;
783 } 790 }
@@ -792,7 +799,7 @@ static int tm6000_usb_probe(struct usb_interface *interface,
792 interface->altsetting->desc.bInterfaceNumber); 799 interface->altsetting->desc.bInterfaceNumber);
793 800
794/* check if the the device has the iso in endpoint at the correct place */ 801/* check if the the device has the iso in endpoint at the correct place */
795 if (!dev->isoc_in) { 802 if (!dev->isoc_in.endp) {
796 printk("tm6000: probing error: no IN ISOC endpoint!\n"); 803 printk("tm6000: probing error: no IN ISOC endpoint!\n");
797 rc= -ENODEV; 804 rc= -ENODEV;
798 805
diff --git a/drivers/staging/tm6000/tm6000-dvb.c b/drivers/staging/tm6000/tm6000-dvb.c
index 1072206f2a7..eafc89c22b6 100644
--- a/drivers/staging/tm6000/tm6000-dvb.c
+++ b/drivers/staging/tm6000/tm6000-dvb.c
@@ -108,7 +108,7 @@ int tm6000_start_stream(struct tm6000_core *dev)
108 return -ENOMEM; 108 return -ENOMEM;
109 } 109 }
110 110
111 pipe = usb_rcvbulkpipe(dev->udev, dev->bulk_in->desc.bEndpointAddress 111 pipe = usb_rcvbulkpipe(dev->udev, dev->bulk_in.endp->desc.bEndpointAddress
112 & USB_ENDPOINT_NUMBER_MASK); 112 & USB_ENDPOINT_NUMBER_MASK);
113 113
114 size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe)); 114 size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index be6fcb79ef0..92edb418586 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -151,7 +151,8 @@ static inline void get_next_buf(struct tm6000_dmaqueue *dma_q,
151 151
152 /* Cleans up buffer - Usefull for testing for frame/URB loss */ 152 /* Cleans up buffer - Usefull for testing for frame/URB loss */
153 outp = videobuf_to_vmalloc(&(*buf)->vb); 153 outp = videobuf_to_vmalloc(&(*buf)->vb);
154 memset(outp, 0, (*buf)->vb.size); 154 if (outp)
155 memset(outp, 0, (*buf)->vb.size);
155 156
156 return; 157 return;
157} 158}
@@ -284,7 +285,8 @@ static int copy_packet(struct urb *urb, u32 header, u8 **ptr, u8 *endp,
284 start_line=line; 285 start_line=line;
285 last_field=field; 286 last_field=field;
286 } 287 }
287 last_line=line; 288 if (cmd == TM6000_URB_MSG_VIDEO)
289 last_line = line;
288 290
289 pktsize = TM6000_URB_MSG_LEN; 291 pktsize = TM6000_URB_MSG_LEN;
290 } else { 292 } else {
@@ -616,14 +618,18 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
616 /* De-allocates all pending stuff */ 618 /* De-allocates all pending stuff */
617 tm6000_uninit_isoc(dev); 619 tm6000_uninit_isoc(dev);
618 620
621 usb_set_interface(dev->udev,
622 dev->isoc_in.bInterfaceNumber,
623 dev->isoc_in.bAlternateSetting);
624
619 pipe = usb_rcvisocpipe(dev->udev, 625 pipe = usb_rcvisocpipe(dev->udev,
620 dev->isoc_in->desc.bEndpointAddress & 626 dev->isoc_in.endp->desc.bEndpointAddress &
621 USB_ENDPOINT_NUMBER_MASK); 627 USB_ENDPOINT_NUMBER_MASK);
622 628
623 size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe)); 629 size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
624 630
625 if (size > dev->max_isoc_in) 631 if (size > dev->isoc_in.maxsize)
626 size = dev->max_isoc_in; 632 size = dev->isoc_in.maxsize;
627 633
628 dev->isoc_ctl.max_pkt_size = size; 634 dev->isoc_ctl.max_pkt_size = size;
629 635
@@ -653,8 +659,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
653 dprintk(dev, V4L2_DEBUG_QUEUE, "Allocating %d x %d packets" 659 dprintk(dev, V4L2_DEBUG_QUEUE, "Allocating %d x %d packets"
654 " (%d bytes) of %d bytes each to handle %u size\n", 660 " (%d bytes) of %d bytes each to handle %u size\n",
655 max_packets, num_bufs, sb_size, 661 max_packets, num_bufs, sb_size,
656 dev->max_isoc_in, size); 662 dev->isoc_in.maxsize, size);
657
658 663
659 /* allocate urbs and transfer buffers */ 664 /* allocate urbs and transfer buffers */
660 for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { 665 for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
@@ -682,7 +687,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
682 usb_fill_bulk_urb(urb, dev->udev, pipe, 687 usb_fill_bulk_urb(urb, dev->udev, pipe,
683 dev->isoc_ctl.transfer_buffer[i], sb_size, 688 dev->isoc_ctl.transfer_buffer[i], sb_size,
684 tm6000_irq_callback, dma_q); 689 tm6000_irq_callback, dma_q);
685 urb->interval = dev->isoc_in->desc.bInterval; 690 urb->interval = dev->isoc_in.endp->desc.bInterval;
686 urb->number_of_packets = max_packets; 691 urb->number_of_packets = max_packets;
687 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; 692 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
688 693
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index f402040907a..5a587f7de6a 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -132,6 +132,13 @@ struct tm6000_dvb {
132 struct mutex mutex; 132 struct mutex mutex;
133}; 133};
134 134
135struct tm6000_endpoint {
136 struct usb_host_endpoint *endp;
137 __u8 bInterfaceNumber;
138 __u8 bAlternateSetting;
139 unsigned maxsize;
140};
141
135struct tm6000_core { 142struct tm6000_core {
136 /* generic device properties */ 143 /* generic device properties */
137 char name[30]; /* name (including minor) of the device */ 144 char name[30]; /* name (including minor) of the device */
@@ -186,9 +193,7 @@ struct tm6000_core {
186 /* usb transfer */ 193 /* usb transfer */
187 struct usb_device *udev; /* the usb device */ 194 struct usb_device *udev; /* the usb device */
188 195
189 struct usb_host_endpoint *bulk_in, *bulk_out, *isoc_in, *isoc_out; 196 struct tm6000_endpoint bulk_in, bulk_out, isoc_in, isoc_out;
190 unsigned int max_bulk_in, max_bulk_out;
191 unsigned int max_isoc_in, max_isoc_out;
192 197
193 /* scaler!=0 if scaler is active*/ 198 /* scaler!=0 if scaler is active*/
194 int scaler; 199 int scaler;