source: mainline/uspace/app/vuhid/virthid.h@ c4a8e4a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c4a8e4a was 9a884ed, checked in by Vojtech Horky <vojtechhorky@…>, 14 years ago

Virtual HID terminates with last interface

Also it is not possible to turn on the same interface twice.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Copyright (c) 2011 Vojtech Horky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup usbvirthid
30 * @{
31 */
32/** @file
33 *
34 */
35#ifndef VUHID_VIRTHID_H_
36#define VUHID_VIRTHID_H_
37
38#include <usb/usb.h>
39#include <usbvirt/device.h>
40#include <fibril_synch.h>
41
42#define VUHID_ENDPOINT_MAX USB11_ENDPOINT_MAX
43#define VUHID_INTERFACE_MAX 8
44
45typedef struct vuhid_interface vuhid_interface_t;
46
47typedef struct {
48 vuhid_interface_t *in_endpoints_mapping[VUHID_ENDPOINT_MAX];
49 size_t in_endpoint_first_free;
50 vuhid_interface_t *out_endpoints_mapping[VUHID_ENDPOINT_MAX];
51 size_t out_endpoint_first_free;
52 vuhid_interface_t *interface_mapping[VUHID_INTERFACE_MAX];
53
54 fibril_mutex_t iface_count_mutex;
55 fibril_condvar_t iface_count_cv;
56 size_t iface_count;
57 size_t iface_died_count;
58} vuhid_data_t;
59
60struct vuhid_interface {
61 const char *name;
62 const char *id;
63 int usb_subclass;
64 int usb_protocol;
65
66 uint8_t *report_descriptor;
67 size_t report_descriptor_size;
68
69 size_t in_data_size;
70 size_t out_data_size;
71
72 int (*on_data_in)(vuhid_interface_t *, void *, size_t, size_t *);
73 int (*on_data_out)(vuhid_interface_t *, void *, size_t);
74 void (*live)(vuhid_interface_t *);
75
76 int set_protocol;
77
78 void *interface_data;
79
80 vuhid_data_t *vuhid_data;
81};
82
83typedef struct {
84 uint8_t length;
85 uint8_t type;
86 uint16_t hid_spec_release;
87 uint8_t country_code;
88 uint8_t descriptor_count;
89 uint8_t descriptor1_type;
90 uint16_t descriptor1_length;
91} __attribute__ ((packed)) hid_descriptor_t;
92
93int add_interface_by_id(vuhid_interface_t **, const char *, usbvirt_device_t *);
94void wait_for_interfaces_death(usbvirt_device_t *);
95
96#endif
97/**
98 * @}
99 */
Note: See TracBrowser for help on using the repository browser.