Untitled diff

Creato Il diff non scade mai
1 rimozione
401 linee
3 aggiunte
403 linee
// good
// bad
/*
/*
* 1394-Based Digital Camera Control Library
* 1394-Based Digital Camera Control Library
*
*
* IIDC-over-USB using libusb backend for dc1394
* IIDC-over-USB using libusb backend for dc1394
*
*
* Written by David Moore <dcm@acm.org>
* Written by David Moore <dcm@acm.org>
*
*
* This library is free software; you can redistribute it and/or
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*/
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <inttypes.h>
#include <inttypes.h>
#include "config.h"
#include "config.h"
#include "platform.h"
#include "platform.h"
#include "internal.h"
#include "internal.h"
#include "usb.h"
#include "usb.h"
static platform_t *
static platform_t *
dc1394_usb_new (void)
dc1394_usb_new (void)
{
{
libusb_context *context;
libusb_context *context;
if (libusb_init(&context) != 0)
if (libusb_init(&context) != 0)
return NULL;
return NULL;
platform_t * p = calloc (1, sizeof (platform_t));
platform_t * p = calloc (1, sizeof (platform_t));
p->context = context;
p->context = context;
return p;
return p;
}
}
static void
static void
dc1394_usb_free (platform_t * p)
dc1394_usb_free (platform_t * p)
{
{
if (p->context)
if (p->context)
libusb_exit(p->context);
libusb_exit(p->context);
p->context = NULL;
p->context = NULL;
free (p);
free (p);
}
}
struct _platform_device_t {
struct _platform_device_t {
libusb_device * dev;
libusb_device * dev;
};
};
typedef struct _usb_device_list_t {
typedef struct _usb_device_list_t {
platform_device_list_t list;
platform_device_list_t list;
libusb_device ** libusb_list;
libusb_device ** libusb_list;
} usb_device_list_t;
} usb_device_list_t;
/* This is the list of USB vendor/products that we know support
/* This is the list of USB vendor/products that we know support
* IIDC-over-USB. Currently, this is the only mechanism of detecting
* IIDC-over-USB. Currently, this is the only mechanism of detecting
* such cameras. */
* such cameras. */
static struct _vendor_product_t {
static struct _vendor_product_t {
uint16_t vendor;
uint16_t vendor;
uint16_t product;
uint16_t product;
} usb_products[] = {
} usb_products[] = {
{ 0x1e10, 0x2000 }, // Point Grey Firefly MV Color
{ 0x1e10, 0x2000 }, // Point Grey Firefly MV Color
{ 0x1e10, 0x2001 }, // Point Grey Firefly MV Mono
{ 0x1e10, 0x2001 }, // Point Grey Firefly MV Mono
{ 0x1e10, 0x2002 }, // Point Grey High Res Firefly MV Color
{ 0x1e10, 0x2002 }, // Point Grey High Res Firefly MV Color
{ 0x1e10, 0x2003 }, // Point Grey High Res Firefly MV Mono
{ 0x1e10, 0x2003 }, // Point Grey High Res Firefly MV Mono
{ 0x1e10, 0x2004 }, // Point Grey Chameleon Color
{ 0x1e10, 0x2004 }, // Point Grey Chameleon Color
{ 0x1e10, 0x2005 }, // Point Grey Chameleon Mono
{ 0x1e10, 0x2005 }, // Point Grey Chameleon Mono
{ 0x1e10, 0x3000 }, // Point Grey Flea 3
{ 0x1e10, 0x3000 }, // Point Grey Flea 3
{ 0x1e10, 0x3005 }, // Point Grey Flea 3 (FL3-U3-13Y3M)
{ 0x1e10, 0x3005 }, // Point Grey Flea 3 (FL3-U3-13Y3M)
{ 0x1e10, 0x3006 }, // Point Grey Flea 3 (FL3-U3-13S2C)
{ 0x1e10, 0x3006 }, // Point Grey Flea 3 (FL3-U3-13S2C)
{ 0x1e10, 0x3008 }, // Point Grey Flea 3 (FL3-U3-88S2C)
{ 0x1e10, 0x3008 }, // Point Grey Flea 3 (FL3-U3-88S2C)
{ 0x1e10, 0x300a }, // Point Grey Flea 3 (FL3-U3-13E4C)
{ 0x1e10, 0x300a }, // Point Grey Flea 3 (FL3-U3-13E4C)
{ 0x1e10, 0x300b }, // Point Grey Flea 3 (FL3-U3-13E4M with 1.43.3.2 FW)
{ 0x1e10, 0x3300 }, // Point Grey Flea 3 (FL3-U3-13E4M with 2.7.3.0 FW)
{ 0, 0 }
{ 0, 0 }
};
};
static int
static int
is_device_iidc (uint16_t vendor, uint16_t product)
is_device_iidc (uint16_t vendor, uint16_t product)
{
{
int j = 0;
int j = 0;
while (usb_products[j].vendor != 0 && usb_products[j].product != 0) {
while (usb_products[j].vendor != 0 && usb_products[j].product != 0) {
if (usb_products[j].vendor == vendor &&
if (usb_products[j].vendor == vendor &&
usb_products[j].product == product)
usb_products[j].product == product)
return 1;
return 1;
j++;
j++;
}
}
return 0;
return 0;
}
}
static platform_device_list_t *
static platform_device_list_t *