1fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#ifndef _HIDRAW_H
2fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define _HIDRAW_H
3fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
4fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly/*
5fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly *  Copyright (c) 2007 Jiri Kosina
6fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly */
7fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
8fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly/*
9fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly * This program is free software; you can redistribute it and/or modify it
10fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly * under the terms and conditions of the GNU General Public License,
11fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly * version 2, as published by the Free Software Foundation.
12fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly *
13fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly * You should have received a copy of the GNU General Public License along with
14fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly * this program; if not, write to the Free Software Foundation, Inc.,
15fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly */
17fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
18fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#include <linux/hid.h>
19fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#include <linux/types.h>
20fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
21fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystruct hidraw_report_descriptor {
22fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	__u32 size;
23fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	__u8 value[HID_MAX_DESCRIPTOR_SIZE];
24fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly};
25fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
26fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystruct hidraw_devinfo {
27fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	__u32 bustype;
28fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	__s16 vendor;
29fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	__s16 product;
30fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly};
31fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
32fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly/* ioctl interface */
33fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define HIDIOCGRDESCSIZE	_IOR('H', 0x01, int)
34fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define HIDIOCGRDESC		_IOR('H', 0x02, struct hidraw_report_descriptor)
35fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define HIDIOCGRAWINFO		_IOR('H', 0x03, struct hidraw_devinfo)
36fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define HIDIOCGRAWNAME(len)     _IOC(_IOC_READ, 'H', 0x04, len)
37fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define HIDIOCGRAWPHYS(len)     _IOC(_IOC_READ, 'H', 0x05, len)
38fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
39fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define HIDRAW_FIRST_MINOR 0
40fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define HIDRAW_MAX_DEVICES 64
41fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly/* number of reports to buffer */
42fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#define HIDRAW_BUFFER_SIZE 64
43fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
44fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
45fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly/* kernel-only API declarations */
46fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#ifdef __KERNEL__
47fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
48fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystruct hidraw {
49fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	unsigned int minor;
50fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	int exist;
51fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	int open;
52fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	wait_queue_head_t wait;
53fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	struct hid_device *hid;
54fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	struct device *dev;
55fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	struct list_head list;
56fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly};
57fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
58fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystruct hidraw_report {
59fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	__u8 *value;
60fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	int len;
61fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly};
62fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
63fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystruct hidraw_list {
64fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	struct hidraw_report buffer[HIDRAW_BUFFER_SIZE];
65fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	int head;
66fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	int tail;
67fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	struct fasync_struct *fasync;
68fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	struct hidraw *hidraw;
69fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	struct list_head node;
70fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly	struct mutex read_mutex;
71fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly};
72fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
73fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#ifdef CONFIG_HIDRAW
74fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellyint hidraw_init(void);
75fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellyvoid hidraw_exit(void);
76fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellyvoid hidraw_report_event(struct hid_device *, u8 *, int);
77fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellyint hidraw_connect(struct hid_device *);
78fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellyvoid hidraw_disconnect(struct hid_device *);
79fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#else
80fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystatic inline int hidraw_init(void) { return 0; }
81fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystatic inline void hidraw_exit(void) { }
82fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystatic inline void hidraw_report_event(struct hid_device *hid, u8 *data, int len) { }
83fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystatic inline int hidraw_connect(struct hid_device *hid) { return -1; }
84fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pellystatic inline void hidraw_disconnect(struct hid_device *hid) { }
85fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#endif
86fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
87fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#endif
88fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly
89fae8ba518da5796231b7be04e28829ae195fc0a9Nick Pelly#endif
90