1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*****************************************************************************\
musb.h - USB support for multi-point transport driver
(c) 2010 Copyright Hewlett-Packard Development Company, LP
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Author: Naga Samrat Chowdary Narla
\*****************************************************************************/
#ifndef _MUSB_H
#define _MUSB_H
#include <usb.h>
#include "hpmud.h"
#include "hpmudi.h"
#define LIBUSB_TIMEOUT 30000 /* milliseconds */
#define LIBUSB_CONTROL_REQ_TIMEOUT 5000
enum FD_ID
{
FD_NA=0,
FD_7_1_2, /* bi-di interface */
FD_7_1_3, /* 1284.4 interface */
FD_ff_1_1, /* HP EWS interface */
FD_ff_2_1, /* HP Soap Scan interface */
FD_ff_3_1, /* HP Soap Fax interface */
FD_ff_ff_ff, /* HP dot4 interface */
FD_ff_d4_0, /* HP dot4 interface */
FD_ff_4_1, /* orblite scan / rest scan interface */
FD_ff_1_0, /* Marvell fax support*/
FD_ff_cc_0,
FD_ff_2_10,
MAX_FD
};
enum BRIGE_REG_ID
{
ECRR=2,
CCTR=3,
ATAA=8
};
/* USB file descriptor, one for each USB protocol. */
typedef struct
{
usb_dev_handle *hd;
enum FD_ID fd;
int config;
int interface;
int alt_setting;
/* Write thread definitions. */
int write_active; /* 0=no, 1=yes */
const void *write_buf;
int write_size;
int write_return; /* return value, normally number bytes written */
pthread_t tid;
pthread_mutex_t mutex;
pthread_cond_t write_done_cond;
unsigned char ubuf[HPMUD_BUFFER_SIZE]; /* usb read packet buffer */
int uindex;
int ucnt;
} file_descriptor;
struct _mud_device;
struct _mud_channel;
extern struct _mud_device_vf __attribute__ ((visibility ("hidden"))) musb_mud_device_vf;
int __attribute__ ((visibility ("hidden"))) musb_write(int fd, const void *buf, int size, int usec_timout);
int __attribute__ ((visibility ("hidden"))) musb_read(int fd, void *buf, int size, int usec_timout);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_open(struct _mud_device *pd);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_close(struct _mud_device *pd);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_get_device_id(struct _mud_device *pd, char *buf, int size, int *len);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_get_device_status(struct _mud_device *pd, unsigned int *status);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_channel_open(struct _mud_device *pd, const char *sn, HPMUD_CHANNEL *cd);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_channel_close(struct _mud_device *pd, struct _mud_channel *pc);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_channel_write(struct _mud_device *pd, struct _mud_channel *pc, const void *buf, int length, int timeout, int *bytes_wrote);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_channel_read(struct _mud_device *pd, struct _mud_channel *pc, void *buf, int length, int timeout, int *bytes_read);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_raw_channel_open(struct _mud_channel *pc);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_raw_channel_close(struct _mud_channel *pc);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_raw_channel_write(struct _mud_channel *pc, const void *buf, int length, int timeout, int *bytes_wrote);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_raw_channel_read(struct _mud_channel *pc, void *buf, int length, int timeout, int *bytes_wrote);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_comp_channel_open(struct _mud_channel *pc);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_mlc_channel_open(struct _mud_channel *pc);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_mlc_channel_close(struct _mud_channel *pc);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_mlc_channel_write(struct _mud_channel *pc, const void *buf, int length, int timeout, int *bytes_wrote);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_mlc_channel_read(struct _mud_channel *pc, void *buf, int length, int timeout, int *bytes_wrote);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_dot4_channel_open(struct _mud_channel *pc);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_dot4_channel_close(struct _mud_channel *pc);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_dot4_channel_write(struct _mud_channel *pc, const void *buf, int length, int sec_timeout, int *bytes_wrote);
enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) musb_dot4_channel_read(struct _mud_channel *pc, void *buf, int length, int sec_timeout, int *bytes_read);
int __attribute__ ((visibility ("hidden"))) musb_probe_devices(char *lst, int lst_size, int *cnt);
int __attribute__ ((visibility ("hidden"))) power_up(struct _mud_device *pd, int fd);
#endif // _MUSB_H
|