author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 16 Apr 2010 16:24:37 +0300 | |
changeset 90 | 947f0dc9f7a8 |
parent 31 | 56f325a607ea |
child 297 | b2826f67641f |
permissions | -rw-r--r-- |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1 |
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// |
|
15 |
||
16 |
/** |
|
17 |
@file |
|
18 |
@internalTechnology |
|
19 |
*/ |
|
20 |
||
21 |
#include <e32base.h> |
|
22 |
#include <d32usbdi_hubdriver.h> |
|
23 |
#include <d32usbdi.h> |
|
24 |
#include <d32otgdi.h> |
|
25 |
#include <d32usbdescriptors.h> |
|
26 |
#include <d32usbtransfers.h> |
|
27 |
#include "botmsctypes.h" |
|
28 |
#include "msctypes.h" |
|
29 |
#include "mtransport.h" |
|
30 |
#include "mprotocol.h" |
|
31 |
#include "cusbifacehandler.h" |
|
32 |
#include "cbulkonlytransport.h" |
|
33 |
#include "debug.h" |
|
34 |
#include "msdebug.h" |
|
35 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
36 |
CUsbInterfaceHandler* CUsbInterfaceHandler::NewL(RUsbInterface &aInterface, RUsbPipe& aBulkPipeIn) |
0 | 37 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
38 |
return new (ELeave) CUsbInterfaceHandler(aInterface, aBulkPipeIn); |
0 | 39 |
} |
40 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
41 |
CUsbInterfaceHandler::CUsbInterfaceHandler(RUsbInterface &aInterface, RUsbPipe& aBulkPipeIn) |
0 | 42 |
: CActive(EPriorityStandard), |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
43 |
iInterface(aInterface), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
44 |
iBulkPipeIn(aBulkPipeIn) |
0 | 45 |
{ |
46 |
__MSFNLOG |
|
47 |
CActiveScheduler::Add(this); |
|
48 |
} |
|
49 |
||
50 |
CUsbInterfaceHandler::~CUsbInterfaceHandler() |
|
51 |
{ |
|
52 |
__MSFNLOG |
|
53 |
if (iState != ENone) |
|
54 |
{ |
|
55 |
iState = ENone; |
|
56 |
iBotGetMaxLun.Complete(KErrCancel); |
|
57 |
Cancel(); |
|
58 |
} |
|
59 |
} |
|
60 |
||
61 |
/** |
|
62 |
Cancellation of outstanding request |
|
63 |
*/ |
|
64 |
void CUsbInterfaceHandler::DoCancel() |
|
65 |
{ |
|
66 |
__MSFNLOG |
|
67 |
} |
|
68 |
||
69 |
/** |
|
70 |
Completion of USB transport request. |
|
71 |
*/ |
|
72 |
void CUsbInterfaceHandler::RunL() |
|
73 |
{ |
|
74 |
__MSFNLOG |
|
75 |
TInt error = iStatus.Int(); |
|
76 |
||
77 |
if (error == KErrUsbStalled && iState == EGetMaxLun) |
|
78 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
79 |
// Devices that do not support multiple LUNs may STALL this command |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
80 |
__BOTPRINT(_L("...KErrUsbStalled")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
81 |
iBulkPipeIn.ClearRemoteStall(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
82 |
error = KErrNone; |
0 | 83 |
} |
84 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
85 |
else if (error == KErrNone) |
0 | 86 |
{ |
87 |
__BOTPRINT(_L("...KErrNone")); |
|
88 |
if (iState == EGetMaxLun) |
|
89 |
{ |
|
90 |
__BOTPRINT(_L("...sending GetMaxLun response")); |
|
91 |
*ipGetMaxLun = iBuffer[0]; |
|
92 |
} |
|
93 |
} |
|
94 |
else |
|
95 |
{ |
|
96 |
__BOTPRINT(_L("...completeing with KErrGeneral")); |
|
97 |
error = KErrGeneral; |
|
98 |
} |
|
99 |
||
100 |
iState = ENone; |
|
101 |
iBotGetMaxLun.Complete(error); |
|
102 |
} |
|
103 |
||
104 |
||
105 |
void CUsbInterfaceHandler::GetMaxLun(TLun* aMaxLun, const RMessage2& aMessage) |
|
106 |
{ |
|
107 |
__MSFNLOG |
|
108 |
||
109 |
/* Send the Get max lun command in the ep0 */ |
|
110 |
RUsbInterface::TUsbTransferRequestDetails reqDetails; |
|
111 |
_LIT8(KNullDesC8,""); |
|
112 |
iBotGetMaxLun = aMessage; |
|
113 |
iState = EGetMaxLun; |
|
114 |
ipGetMaxLun = aMaxLun; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
115 |
*ipGetMaxLun = 0; // default response is MaxLUN=0 |
0 | 116 |
|
117 |
reqDetails.iRequestType = 0xA1; |
|
118 |
reqDetails.iRequest = 0xFE; |
|
119 |
reqDetails.iValue = 0x0000; |
|
120 |
reqDetails.iIndex = 0x0000; |
|
121 |
reqDetails.iFlags = 0x04; // Short transfer OK |
|
122 |
||
123 |
iBuffer.SetLength(1); |
|
124 |
iInterface.Ep0Transfer(reqDetails, KNullDesC8, iBuffer, iStatus); |
|
125 |
SetActive(); |
|
126 |
} |
|
127 |