[haiku-commits] r41541 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons/uvc

  • From: korli@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 16 May 2011 19:31:38 +0200 (CEST)

Author: korli
Date: 2011-05-16 19:31:38 +0200 (Mon, 16 May 2011)
New Revision: 41541
Changeset: https://dev.haiku-os.org/changeset/41541

Modified:
   haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp
   
haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.cpp
   
haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h
Log:
* select idle alternate when stopping the UVC device.
* set up a dumb deframer.
* received isochronous buffers can be zero length: loop instead of breaking.


Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp
===================================================================
--- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp        
2011-05-16 16:35:26 UTC (rev 41540)
+++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp        
2011-05-16 17:31:38 UTC (rev 41541)
@@ -589,7 +589,7 @@
 
                        if (len <= 0) {
                                PRINT((CH ": IsoIn: %s" CT, strerror(len)));
-                               break;
+                               continue;
                        }
 
 #ifndef DEBUG_DISCARD_DATA

Modified: 
haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.cpp
  2011-05-16 16:35:26 UTC (rev 41540)
+++ 
haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.cpp
  2011-05-16 17:31:38 UTC (rev 41541)
@@ -9,7 +9,9 @@
 
 #include <stdio.h>
 
+#include "CamStreamingDeframer.h"
 
+
 usb_webcam_support_descriptor kSupportedDevices[] = {
        // ofcourse we support a generic UVC device...
        {{ CC_VIDEO, SC_VIDEOCONTROL, 0, 0, 0 }, "USB", "Video Class", "??" },
@@ -58,9 +60,29 @@
 }
 
 
+// TODO dumb sof_marks and eof_marks
+static const uint8 sof_mark_1[] = { 0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96, 0x00 };
+static const uint8 sof_mark_2[] = { 0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96, 0x01 };
+static const uint8 *sof_marks[] = { sof_mark_1, sof_mark_2 };
+
+static const uint8 eof_mark_1[] = { 0x00, 0x00, 0x00, 0x00 };
+static const uint8 eof_mark_2[] = { 0x40, 0x00, 0x00, 0x00 };
+static const uint8 eof_mark_3[] = { 0x80, 0x00, 0x00, 0x00 };
+static const uint8 eof_mark_4[] = { 0xc0, 0x00, 0x00, 0x00 };
+static const uint8 *eof_marks[] = { eof_mark_1, eof_mark_2, eof_mark_3, 
eof_mark_4 };
+
+
+
 UVCCamDevice::UVCCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device)
-       : CamDevice(_addon, _device)
+       : CamDevice(_addon, _device),
+       fHeaderDescriptor(NULL),
+       fInterruptIn(NULL)
 {
+       fDeframer = new CamStreamingDeframer(this);
+       fDeframer->RegisterSOFTags(sof_marks, 2, sizeof(sof_mark_1), 12);
+       fDeframer->RegisterEOFTags(eof_marks, 4, sizeof(eof_mark_1), 
sizeof(eof_mark_1));
+       SetDataInput(fDeframer);
+       
        const BUSBConfiguration* config;
        const BUSBInterface* interface;
        usb_descriptor* generic;
@@ -519,6 +541,7 @@
 status_t
 UVCCamDevice::StopTransfer()
 {
+       _SelectIdleAlternate();
        return CamDevice::StopTransfer();
 }
 
@@ -649,6 +672,23 @@
 }
 
 
+status_t
+UVCCamDevice::_SelectIdleAlternate()
+{
+       const BUSBConfiguration *config = fDevice->ActiveConfiguration();
+       const BUSBInterface *streaming = config->InterfaceAt(fStreamingIndex);
+       if (((BUSBInterface *)streaming)->SetAlternate(0) != B_OK) {
+               fprintf(stderr, "UVCCamDevice::_SelectIdleAlternate()"
+                       " selecting alternate failed\n");
+               return B_ERROR;
+       }
+       
+       fIsoIn = NULL;
+       
+       return B_OK;
+}
+
+
 UVCCamDeviceAddon::UVCCamDeviceAddon(WebCamMediaAddOn* webcam)
        : CamDeviceAddon(webcam)
 {

Modified: 
haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h
===================================================================
--- 
haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h
    2011-05-16 16:35:26 UTC (rev 41540)
+++ 
haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h
    2011-05-16 17:31:38 UTC (rev 41541)
@@ -34,6 +34,7 @@
                                                                        size_t 
len);
                        status_t                        _ProbeCommitFormat();
                        status_t                        _SelectBestAlternate();
+                       status_t                        _SelectIdleAlternate();
 
                        usbvc_interface_header_descriptor *fHeaderDescriptor;
                        


Other related posts:

  • » [haiku-commits] r41541 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons/uvc - korli