summaryrefslogtreecommitdiffstats
path: root/api/usb2impl.c
blob: 30e626510ded6d85d1b5e0e8bbc11e5bea0513db (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// all for Linux
#include <linux/autoconf.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/kref.h>
#include <linux/smp_lock.h>
#include <linux/usb.h>
#include <asm/uaccess.h>
#include <linux/device.h>
#include <linux/string.h>
#include <linux/firmware.h>
#include <linux/delay.h>
#include <linux/vmalloc.h>

#include "usb2impl.h"
#include "af903x.h"

#ifdef UNDER_CE

Handle Usb2_handle = NULL;


Dword Usb2_getDriver (
	IN  Demodulator*	demodulator,
	OUT Handle*			handle
) {
	return (Error_NO_ERROR);
}


Dword Usb2_writeControlBus (
	IN  Demodulator*	demodulator,
	IN  Dword			bufferLength,
	IN  Byte*			buffer
) {
	return (Error_NO_ERROR);
}


Dword Usb2_readControlBus (
	IN  Demodulator*	demodulator,
	IN  Dword			bufferLength,
	OUT Byte*			buffer
) {
	return (Error_NO_ERROR);
}


Dword Usb2_readDataBus (
	IN  Demodulator*	demodulator,
	IN  Dword			bufferLength,
	OUT Byte*			buffer
) {
	return (Error_NO_ERROR);
}

#else

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif

Handle Usb2_handle = 0;
/*
bool (__cdecl *Usb2_initialize) (
);
void (__cdecl *Usb2_finalize) (
);
bool (__cdecl *Usb2_writeControl) (
	Byte*		poutBuf,
	unsigned long		WriteLen,
	unsigned long*		pnBytesWrite
); 
bool (__cdecl *Usb2_readControl) (
	Byte*		pinBuf,
	unsigned long		ReadLen,
	unsigned long*		pnBytesRead
);
bool (__cdecl *Usb2_readData) (
	BYTE*		pinBuf,
	ULONG		ReadLen
);
*/

Dword Usb2_getDriver (
	IN  Demodulator*	demodulator,
	OUT Handle*			handle
) {
	Dword error = Error_NO_ERROR;
/*
	HINSTANCE instance = NULL;

    instance = LoadLibrary ("AF15BDAEX.dll");
    Usb2_initialize = (bool (__cdecl *) (
			)) GetProcAddress (instance, "af15_init");
    Usb2_finalize = (void (__cdecl *) (
			)) GetProcAddress (instance, "af15_exit");
	Usb2_writeControl = (bool (__cdecl *) (
					BYTE*		poutBuf,
					ULONG		WriteLen,
					ULONG*		pnBytesWrite
			)) GetProcAddress (instance, "af15_WriteBulkData");
    Usb2_readControl = (bool (__cdecl *) (
					BYTE*		pinBuf,
					ULONG		ReadLen,
					ULONG*		pnBytesRead
			)) GetProcAddress (instance, "af15_ReadBulkData");
    Usb2_readData = (bool (__cdecl *) (
					BYTE*		pinBuf,
					ULONG		ReadLen
			)) GetProcAddress (instance, "af15_GetTsData");

	if (!Usb2_initialize ())
		error = Error_DRIVER_INVALID;
			
	*handle = (Handle) instance;
*/
	return (error);
}


Dword Usb2_writeControlBus (
	IN  Demodulator*	demodulator,
	IN  Dword			bufferLength,
	IN  Byte*			buffer
) {

//    Ganymede *pGanymede = (Ganymede *)demodulator;
    Dword     ret,act_len;
	ret = 0;
	    		ret = usb_bulk_msg(usb_get_dev(udevs),
			usb_sndbulkpipe(usb_get_dev(udevs), 0x02),
			buffer,
			bufferLength,
			&act_len,
			100000);
   
	if (ret) deb_data(" Usb2_writeControlBus fail : %d!\n", ret);

	return (Error_NO_ERROR);
}


Dword Usb2_readControlBus (
	IN  Demodulator*	demodulator,
	IN  Dword			bufferLength,
	OUT Byte*			buffer
) {

//    Ganymede *pGanymede = (Ganymede *)demodulator;
	Dword     ret, nBytesRead;
	ret = 0;
   ret = usb_bulk_msg(usb_get_dev(udevs),
				usb_rcvbulkpipe(usb_get_dev(udevs),129),
				buffer,
				125,
				&nBytesRead,
				100000);
   
	 
	if (ret) 	deb_data(" Usb2_readControlBus fail : %d!\n", ret);

	return (Error_NO_ERROR);
}


Dword Usb2_readDataBus (
	IN  Demodulator*	demodulator,
	IN  Dword			bufferLength,
	OUT Byte*			buffer
) {
	return (Error_NO_ERROR);
}
#endif