descr_compat.c revision 187994
1187994Salfred/*
2187994Salfred * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
3187994Salfred * All rights reserved.
4187994Salfred *
5187994Salfred * Redistribution and use in source and binary forms, with or without
6187994Salfred * modification, are permitted provided that the following conditions
7187994Salfred * are met:
8187994Salfred * 1. Redistributions of source code must retain the above copyright
9187994Salfred *    notice, this list of conditions and the following disclaimer.
10187994Salfred * 2. Redistributions in binary form must reproduce the above copyright
11187994Salfred *    notice, this list of conditions and the following disclaimer in the
12187994Salfred *    documentation and/or other materials provided with the distribution.
13187994Salfred *
14187994Salfred * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15187994Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16187994Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17187994Salfred * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18187994Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19187994Salfred * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20187994Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21187994Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22187994Salfred * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23187994Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24187994Salfred * SUCH DAMAGE.
25187994Salfred */
26187994Salfred
27187994Salfred/*
28187994Salfred * This file contains fallback-compatibility code for the old FreeBSD
29187994Salfred * USB stack.
30187994Salfred */
31187994Salfred
32187994Salfred#include <sys/cdefs.h>
33187994Salfred__FBSDID("$FreeBSD: head/lib/libusbhid/descr_compat.c 187994 2009-02-02 00:49:39Z alfred $");
34187994Salfred
35187994Salfred#include <sys/types.h>
36187994Salfred
37187994Salfred#include <assert.h>
38187994Salfred#include <errno.h>
39187994Salfred#include <stdlib.h>
40187994Salfred#include <string.h>
41187994Salfred#include <unistd.h>
42187994Salfred#include <sys/time.h>
43187994Salfred#include <sys/ioctl.h>
44187994Salfred
45187994Salfred#include <dev/usb/usb.h>
46187994Salfred
47187994Salfred#include "usbhid.h"
48187994Salfred#include "usbvar.h"
49187994Salfred
50187994Salfredint
51187994Salfredhid_set_immed_compat7(int fd, int enable)
52187994Salfred{
53187994Salfred	return (ioctl(fd, USB_SET_IMMED, &enable));
54187994Salfred}
55187994Salfred
56187994Salfredint
57187994Salfredhid_get_report_id_compat7(int fd)
58187994Salfred{
59187994Salfred	int temp = -1;
60187994Salfred
61187994Salfred	if (ioctl(fd, USB_GET_REPORT_ID, &temp) < 0)
62187994Salfred		return (-1);
63187994Salfred
64187994Salfred	return (temp);
65187994Salfred}
66187994Salfred
67187994Salfredreport_desc_t
68187994Salfredhid_get_report_desc_compat7(int fd)
69187994Salfred{
70187994Salfred	struct usb_ctl_report_desc rep;
71187994Salfred
72187994Salfred	rep.ucrd_size = 0;
73187994Salfred	if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0)
74187994Salfred		return (NULL);
75187994Salfred
76187994Salfred	return (hid_use_report_desc(rep.ucrd_data, (unsigned int)rep.ucrd_size));
77187994Salfred}
78