2009-08-14 13:19:32 +00:00
|
|
|
/*
|
2012-12-12 17:04:51 +00:00
|
|
|
* virusb.h: helper APIs for managing host USB devices
|
|
|
|
*
|
2009-08-14 13:19:32 +00:00
|
|
|
* Copyright (C) 2009 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* 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,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2009-08-14 13:19:32 +00:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Daniel P. Berrange <berrange@redhat.com>
|
2011-12-21 17:58:29 +00:00
|
|
|
* Michal Privoznik <mprivozn@redhat.com>
|
2009-08-14 13:19:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_USB_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_USB_H__
|
2009-08-14 13:19:32 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
2013-01-16 11:49:54 +00:00
|
|
|
# include "virobject.h"
|
2009-08-14 13:19:32 +00:00
|
|
|
|
2012-12-17 19:37:11 +00:00
|
|
|
# define USB_DEVFS "/dev/bus/usb/"
|
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
typedef struct _virUSBDevice virUSBDevice;
|
|
|
|
typedef virUSBDevice *virUSBDevicePtr;
|
|
|
|
typedef struct _virUSBDeviceList virUSBDeviceList;
|
|
|
|
typedef virUSBDeviceList *virUSBDeviceListPtr;
|
2009-08-14 13:19:32 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
virUSBDevicePtr virUSBDeviceNew(unsigned int bus,
|
|
|
|
unsigned int devno,
|
|
|
|
const char *vroot);
|
2012-05-04 07:49:58 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virUSBDeviceFindByBus(unsigned int bus,
|
|
|
|
unsigned int devno,
|
2012-11-27 16:17:47 +00:00
|
|
|
const char *vroot,
|
2012-10-03 14:57:28 +00:00
|
|
|
bool mandatory,
|
2013-01-14 22:11:44 +00:00
|
|
|
virUSBDevicePtr *usb);
|
|
|
|
|
|
|
|
int virUSBDeviceFindByVendor(unsigned int vendor,
|
|
|
|
unsigned int product,
|
|
|
|
const char *vroot,
|
|
|
|
bool mandatory,
|
|
|
|
virUSBDeviceListPtr *devices);
|
2012-10-03 14:57:28 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virUSBDeviceFind(unsigned int vendor,
|
|
|
|
unsigned int product,
|
|
|
|
unsigned int bus,
|
|
|
|
unsigned int devno,
|
|
|
|
const char *vroot,
|
|
|
|
bool mandatory,
|
|
|
|
virUSBDevicePtr *usb);
|
2012-05-04 07:49:58 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
void virUSBDeviceFree(virUSBDevicePtr dev);
|
2014-03-01 06:28:56 +00:00
|
|
|
int virUSBDeviceSetUsedBy(virUSBDevicePtr dev,
|
|
|
|
const char *drv_name,
|
|
|
|
const char *dom_name);
|
|
|
|
void virUSBDeviceGetUsedBy(virUSBDevicePtr dev,
|
|
|
|
const char **drv_name,
|
|
|
|
const char **dom_name);
|
2013-01-14 22:11:44 +00:00
|
|
|
const char *virUSBDeviceGetName(virUSBDevicePtr dev);
|
2010-03-04 11:48:16 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
unsigned int virUSBDeviceGetBus(virUSBDevicePtr dev);
|
|
|
|
unsigned int virUSBDeviceGetDevno(virUSBDevicePtr dev);
|
2009-08-14 13:19:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback that will be invoked once for each file
|
|
|
|
* associated with / used for USB host device access.
|
|
|
|
*
|
|
|
|
* Should return 0 if successfully processed, or
|
|
|
|
* -1 to indicate error and abort iteration
|
|
|
|
*/
|
2013-01-14 22:11:44 +00:00
|
|
|
typedef int (*virUSBDeviceFileActor)(virUSBDevicePtr dev,
|
|
|
|
const char *path, void *opaque);
|
2009-08-14 13:19:32 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virUSBDeviceFileIterate(virUSBDevicePtr dev,
|
|
|
|
virUSBDeviceFileActor actor,
|
|
|
|
void *opaque);
|
2009-08-14 13:19:32 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
virUSBDeviceListPtr virUSBDeviceListNew(void);
|
|
|
|
int virUSBDeviceListAdd(virUSBDeviceListPtr list,
|
|
|
|
virUSBDevicePtr dev);
|
|
|
|
virUSBDevicePtr virUSBDeviceListGet(virUSBDeviceListPtr list,
|
|
|
|
int idx);
|
2014-01-07 14:44:27 +00:00
|
|
|
size_t virUSBDeviceListCount(virUSBDeviceListPtr list);
|
2013-01-14 22:11:44 +00:00
|
|
|
virUSBDevicePtr virUSBDeviceListSteal(virUSBDeviceListPtr list,
|
|
|
|
virUSBDevicePtr dev);
|
|
|
|
void virUSBDeviceListDel(virUSBDeviceListPtr list,
|
|
|
|
virUSBDevicePtr dev);
|
|
|
|
virUSBDevicePtr virUSBDeviceListFind(virUSBDeviceListPtr list,
|
|
|
|
virUSBDevicePtr dev);
|
2009-08-14 13:19:32 +00:00
|
|
|
|
|
|
|
#endif /* __VIR_USB_H__ */
|