59
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
33
|
17 |
|
|
18 |
#ifndef __D32USBTRANSFERS_H
|
|
19 |
#define __D32USBTRANSFERS_H
|
|
20 |
|
|
21 |
#ifdef __KERNEL_MODE__
|
|
22 |
#include <kernel/klib.h>
|
|
23 |
#else
|
|
24 |
#include <e32base.h>
|
|
25 |
#endif
|
|
26 |
#include <d32usbdi.h>
|
|
27 |
|
|
28 |
|
|
29 |
class RUsbTransferStrategy;
|
|
30 |
|
|
31 |
/**
|
|
32 |
Base class for all transfer descriptors.
|
|
33 |
|
|
34 |
@publishedPartner Intended to be available to 3rd parties later
|
|
35 |
@prototype
|
|
36 |
*/
|
|
37 |
NONSHARABLE_CLASS(RUsbTransferDescriptor)
|
|
38 |
{
|
|
39 |
public:
|
|
40 |
enum TTransferType
|
|
41 |
{
|
|
42 |
EBulk,
|
|
43 |
EIsochronous,
|
|
44 |
EInterrupt
|
|
45 |
};
|
|
46 |
|
|
47 |
enum TZlpStatus
|
|
48 |
{
|
|
49 |
ESuppressZlp,
|
|
50 |
ESendZlpIfRequired, // Default
|
|
51 |
EAlwaysSendZlp
|
|
52 |
};
|
|
53 |
|
|
54 |
#ifndef __KERNEL_MODE__
|
|
55 |
friend class RUsbPipe;
|
|
56 |
friend class RUsbTransferStrategy;
|
|
57 |
|
|
58 |
public:
|
|
59 |
virtual void Close();
|
|
60 |
|
|
61 |
protected:
|
|
62 |
RUsbTransferDescriptor(TTransferType aType, TInt aMaxSize, TInt aMaxNumPackets);
|
|
63 |
|
|
64 |
protected:
|
|
65 |
static const TInt KInvalidHandle = -1;
|
|
66 |
|
|
67 |
protected:
|
|
68 |
/**
|
|
69 |
A pointer to the transfer strategy the descriptor is registered in.
|
|
70 |
*/
|
|
71 |
RUsbTransferStrategy* iTransferStrategy;
|
|
72 |
|
|
73 |
/**
|
|
74 |
Handle into the transfer strategy for the descriptor.
|
|
75 |
*/
|
|
76 |
TInt iHandle;
|
|
77 |
|
|
78 |
public:
|
|
79 |
/**
|
|
80 |
The type of transfer descriptor this instance represents.
|
|
81 |
*/
|
|
82 |
const TTransferType iType;
|
|
83 |
|
|
84 |
/**
|
|
85 |
For isochronous transfers this refers to the maximum packet size packets
|
|
86 |
in this descriptor may be.
|
|
87 |
For other transfers this refers to the maximum size of the transfer.
|
|
88 |
*/
|
|
89 |
const TInt iMaxSize;
|
|
90 |
|
|
91 |
/**
|
|
92 |
Used to specify the maximum number of packets the descriptor will hold.
|
|
93 |
*/
|
|
94 |
const TInt iMaxNumPackets;
|
|
95 |
#endif // __KERNEL_MODE__
|
|
96 |
};
|
|
97 |
|
|
98 |
|
|
99 |
#ifndef __KERNEL_MODE__
|
|
100 |
|
|
101 |
/**
|
|
102 |
A class that refers to the list of packet lengths for a isochronous transfer
|
|
103 |
descriptor.
|
|
104 |
|
|
105 |
@publishedPartner
|
|
106 |
@prototype
|
|
107 |
*/
|
|
108 |
NONSHARABLE_CLASS(TPacketLengths)
|
|
109 |
{
|
|
110 |
public:
|
|
111 |
NONSHARABLE_CLASS(TLength)
|
|
112 |
{
|
|
113 |
public:
|
|
114 |
IMPORT_C TUint16 operator=(TUint16 aValue);
|
|
115 |
IMPORT_C operator TUint16() const;
|
|
116 |
public:
|
|
117 |
TLength(TUint16& aRecv, TUint16& aReq);
|
|
118 |
private:
|
|
119 |
TUint16& iRecv;
|
|
120 |
TUint16& iReq;
|
|
121 |
};
|
|
122 |
public:
|
|
123 |
IMPORT_C TLength At(TInt aIndex);
|
|
124 |
IMPORT_C const TLength At(TInt aIndex) const;
|
|
125 |
IMPORT_C TLength operator[](TInt aIndex);
|
|
126 |
IMPORT_C const TLength operator[](TInt aIndex) const;
|
|
127 |
IMPORT_C TInt MaxNumPackets();
|
|
128 |
|
|
129 |
public:
|
|
130 |
TPacketLengths(TUint16* aRecvPtr, TUint16* aReqPtr, TInt& aMaxNumPackets);
|
|
131 |
|
|
132 |
private:
|
|
133 |
TUint16* iRecvPtr;
|
|
134 |
TUint16* iReqPtr;
|
|
135 |
TInt& iMaxNumPackets;
|
|
136 |
};
|
|
137 |
|
|
138 |
/**
|
|
139 |
A class that refers to the list of packet results for a isochronous transfer
|
|
140 |
descriptor.
|
|
141 |
|
|
142 |
@publishedPartner
|
|
143 |
@prototype
|
|
144 |
*/
|
|
145 |
NONSHARABLE_CLASS(TPacketResults)
|
|
146 |
{
|
|
147 |
public:
|
|
148 |
IMPORT_C TInt At(TInt aIndex) const;
|
|
149 |
IMPORT_C TInt operator[](TInt aIndex) const;
|
|
150 |
IMPORT_C TInt MaxNumPackets();
|
|
151 |
|
|
152 |
public:
|
|
153 |
TPacketResults(TInt* aResPtr, TInt& aMaxNumPackets);
|
|
154 |
|
|
155 |
private:
|
|
156 |
TInt* iResPtr;
|
|
157 |
TInt& iMaxNumPackets;
|
|
158 |
};
|
|
159 |
|
|
160 |
|
|
161 |
/**
|
|
162 |
Provides *SEQUENTIAL* access to the packet slots in an isochronous transfer descriptor.
|
|
163 |
As some HCs may pack the buffer space tightly, with one packet starting immediately after the preceeding one,
|
|
164 |
random access is not possible -- in this implementation, even replacing the content of a slot with another packet
|
|
165 |
of the same size is not 'intentionally' possible.
|
|
166 |
Note that reading data is possible in a random access manner -- the sequential constraint only applies to writing.
|
|
167 |
@publishedPartner Intended to be available to 3rd parties later
|
|
168 |
@prototype
|
|
169 |
*/
|
|
170 |
NONSHARABLE_CLASS(RUsbIsocTransferDescriptor) : public RUsbTransferDescriptor
|
|
171 |
{
|
|
172 |
friend class RUsbTransferStrategy;
|
|
173 |
|
|
174 |
public:
|
|
175 |
IMPORT_C RUsbIsocTransferDescriptor(TInt aMaxPacketSize, TInt aMaxNumPackets);
|
|
176 |
|
|
177 |
public:
|
|
178 |
IMPORT_C void Reset();
|
|
179 |
IMPORT_C TPacketLengths Lengths();
|
|
180 |
IMPORT_C TPacketResults Results();
|
|
181 |
IMPORT_C TInt MaxPacketSize();
|
|
182 |
|
|
183 |
public: // Sending
|
|
184 |
IMPORT_C TPtr8 WritablePackets(TInt aNumPacketsRequested, TInt& aMaxNumOfPacketsAbleToWrite);
|
|
185 |
IMPORT_C void SaveMultiple(TInt aNumOfPackets);
|
|
186 |
|
|
187 |
public: // Receiving
|
|
188 |
IMPORT_C TPtrC8 Packets(TInt aFirstPacketIndex, TInt aNumPacketsRequested, TInt& aNumOfPacketsReturned) const;
|
|
189 |
IMPORT_C void ReceivePackets(TInt aNumOfPackets);
|
|
190 |
|
|
191 |
private:
|
|
192 |
/**
|
|
193 |
The handle to represent the current point in writing an isoc. transfer.
|
|
194 |
*/
|
|
195 |
TInt iWriteHandle;
|
|
196 |
};
|
|
197 |
|
|
198 |
|
|
199 |
/**
|
|
200 |
Provides buffer management for Bulk transfers
|
|
201 |
@publishedPartner Intended to be available to 3rd parties later
|
|
202 |
@prototype
|
|
203 |
*/
|
|
204 |
NONSHARABLE_CLASS(RUsbBulkTransferDescriptor) : public RUsbTransferDescriptor
|
|
205 |
{
|
|
206 |
public:
|
|
207 |
IMPORT_C RUsbBulkTransferDescriptor(TInt aMaxSize);
|
|
208 |
|
|
209 |
public: // Setters
|
|
210 |
IMPORT_C TPtr8 WritableBuffer();
|
|
211 |
IMPORT_C void SaveData(TInt aLength);
|
|
212 |
IMPORT_C void SetZlpStatus(TZlpStatus aZlpStatus);
|
|
213 |
|
|
214 |
public: // Getters
|
|
215 |
IMPORT_C TPtrC8 Buffer() const;
|
|
216 |
};
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
/**
|
|
221 |
Provides buffer management for Interrupt transfers
|
|
222 |
@publishedPartner Intended to be available to 3rd parties later
|
|
223 |
@prototype
|
|
224 |
*/
|
|
225 |
NONSHARABLE_CLASS(RUsbIntrTransferDescriptor) : public RUsbTransferDescriptor
|
|
226 |
{
|
|
227 |
public:
|
|
228 |
IMPORT_C RUsbIntrTransferDescriptor(TInt aMaxSize);
|
|
229 |
|
|
230 |
public: // Setters
|
|
231 |
IMPORT_C TPtr8 WritableBuffer();
|
|
232 |
IMPORT_C void SaveData(TInt aLength);
|
|
233 |
IMPORT_C void SetZlpStatus(TZlpStatus aZlpStatus);
|
|
234 |
|
|
235 |
public: // Getters
|
|
236 |
IMPORT_C TPtrC8 Buffer() const;
|
|
237 |
};
|
|
238 |
|
|
239 |
#endif // __KERNEL_MODE__
|
|
240 |
|
|
241 |
#endif // __D32USBTRANSFERS_H
|