Blame libusb/hotplug.h

Packit Service b0a153
/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
Packit Service b0a153
/*
Packit Service b0a153
 * Hotplug support for libusb
Packit Service b0a153
 * Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.com>
Packit Service b0a153
 * Copyright © 2012-2013 Peter Stuge <peter@stuge.se>
Packit Service b0a153
 *
Packit Service b0a153
 * This library is free software; you can redistribute it and/or
Packit Service b0a153
 * modify it under the terms of the GNU Lesser General Public
Packit Service b0a153
 * License as published by the Free Software Foundation; either
Packit Service b0a153
 * version 2.1 of the License, or (at your option) any later version.
Packit Service b0a153
 *
Packit Service b0a153
 * This library is distributed in the hope that it will be useful,
Packit Service b0a153
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service b0a153
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service b0a153
 * Lesser General Public License for more details.
Packit Service b0a153
 *
Packit Service b0a153
 * You should have received a copy of the GNU Lesser General Public
Packit Service b0a153
 * License along with this library; if not, write to the Free Software
Packit Service b0a153
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit Service b0a153
 */
Packit Service b0a153
Packit Service b0a153
#ifndef USBI_HOTPLUG_H
Packit Service b0a153
#define USBI_HOTPLUG_H
Packit Service b0a153
Packit Service b0a153
#include "libusbi.h"
Packit Service b0a153
Packit Service b0a153
enum usbi_hotplug_flags {
Packit Service b0a153
	/* This callback is interested in device arrivals */
Packit Service b0a153
	USBI_HOTPLUG_DEVICE_ARRIVED = LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED,
Packit Service b0a153
Packit Service b0a153
	/* This callback is interested in device removals */
Packit Service b0a153
	USBI_HOTPLUG_DEVICE_LEFT = LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT,
Packit Service b0a153
Packit Service b0a153
	/* IMPORTANT: The values for the below entries must start *after*
Packit Service b0a153
	 * the highest value of the above entries!!!
Packit Service b0a153
	 */
Packit Service b0a153
Packit Service b0a153
	/* The vendor_id field is valid for matching */
Packit Service b0a153
	USBI_HOTPLUG_VENDOR_ID_VALID = (1U << 3),
Packit Service b0a153
Packit Service b0a153
	/* The product_id field is valid for matching */
Packit Service b0a153
	USBI_HOTPLUG_PRODUCT_ID_VALID = (1U << 4),
Packit Service b0a153
Packit Service b0a153
	/* The dev_class field is valid for matching */
Packit Service b0a153
	USBI_HOTPLUG_DEV_CLASS_VALID = (1U << 5),
Packit Service b0a153
Packit Service b0a153
	/* This callback has been unregistered and needs to be freed */
Packit Service b0a153
	USBI_HOTPLUG_NEEDS_FREE = (1U << 6),
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/** \ingroup hotplug
Packit Service b0a153
 * The hotplug callback structure. The user populates this structure with
Packit Service b0a153
 * libusb_hotplug_prepare_callback() and then calls libusb_hotplug_register_callback()
Packit Service b0a153
 * to receive notification of hotplug events.
Packit Service b0a153
 */
Packit Service b0a153
struct libusb_hotplug_callback {
Packit Service b0a153
	/** Flags that control how this callback behaves */
Packit Service b0a153
	uint8_t flags;
Packit Service b0a153
Packit Service b0a153
	/** Vendor ID to match (if flags says this is valid) */
Packit Service b0a153
	uint16_t vendor_id;
Packit Service b0a153
Packit Service b0a153
	/** Product ID to match (if flags says this is valid) */
Packit Service b0a153
	uint16_t product_id;
Packit Service b0a153
Packit Service b0a153
	/** Device class to match (if flags says this is valid) */
Packit Service b0a153
	uint8_t dev_class;
Packit Service b0a153
Packit Service b0a153
	/** Callback function to invoke for matching event/device */
Packit Service b0a153
	libusb_hotplug_callback_fn cb;
Packit Service b0a153
Packit Service b0a153
	/** Handle for this callback (used to match on deregister) */
Packit Service b0a153
	libusb_hotplug_callback_handle handle;
Packit Service b0a153
Packit Service b0a153
	/** User data that will be passed to the callback function */
Packit Service b0a153
	void *user_data;
Packit Service b0a153
Packit Service b0a153
	/** List this callback is registered in (ctx->hotplug_cbs) */
Packit Service b0a153
	struct list_head list;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
struct libusb_hotplug_message {
Packit Service b0a153
	/** The hotplug event that occurred */
Packit Service b0a153
	libusb_hotplug_event event;
Packit Service b0a153
Packit Service b0a153
	/** The device for which this hotplug event occurred */
Packit Service b0a153
	struct libusb_device *device;
Packit Service b0a153
Packit Service b0a153
	/** List this message is contained in (ctx->hotplug_msgs) */
Packit Service b0a153
	struct list_head list;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
void usbi_hotplug_deregister(struct libusb_context *ctx, int forced);
Packit Service b0a153
void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
Packit Service b0a153
			libusb_hotplug_event event);
Packit Service b0a153
void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device *dev,
Packit Service b0a153
			libusb_hotplug_event event);
Packit Service b0a153
Packit Service b0a153
#endif