28
|
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 |
* header file for NCM communication interface class
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
@internalComponent
|
|
22 |
*/
|
|
23 |
|
|
24 |
#ifndef NCMCOMMUNICATIONINTERFACE_H
|
|
25 |
#define NCMCOMMUNICATIONINTERFACE_H
|
|
26 |
|
|
27 |
#include <e32base.h>
|
|
28 |
|
|
29 |
#ifndef __OVER_DUMMYUSBSCLDD__
|
|
30 |
#include <d32usbcsc.h>
|
|
31 |
#else //!__OVER_DUMMYUSBSCLDD__
|
|
32 |
#include <dummyusbsclddapi.h>
|
|
33 |
#endif// __OVER_DUMMYUSBSCLDD__
|
|
34 |
|
|
35 |
#include "ncmcomminterfacesenderandreceiver.h"
|
|
36 |
#include "ncmpktdrvcommon.h"
|
|
37 |
|
|
38 |
const TUint KSetupPacketLength = 8;
|
|
39 |
const TUint KNtbParamStructLength = 28;
|
|
40 |
const TUint KNtbInputSizeStructLength = 4;
|
|
41 |
|
|
42 |
_LIT(KNcmCommInterface, "NcmCommunicationInterface");
|
|
43 |
|
|
44 |
enum TNcmCommErrorCode
|
|
45 |
{
|
|
46 |
EInternalError,
|
|
47 |
EInvalidSetupPacketLength,
|
|
48 |
EInvalidOutSetupPacket,
|
|
49 |
EInvalidInSetupPacket,
|
|
50 |
EInvalidLengthToRead,
|
|
51 |
EInvalidDataPacketLength,
|
|
52 |
EInvalidFilterOffset
|
|
53 |
};
|
|
54 |
|
|
55 |
/**
|
|
56 |
* The interface to Ncm engine
|
|
57 |
*/
|
|
58 |
|
|
59 |
NONSHARABLE_CLASS(MNcmControlObserver)
|
|
60 |
{
|
|
61 |
public:
|
|
62 |
virtual TInt HandleSetNtbInputSize(TDes8& aBuf) = 0;
|
|
63 |
virtual TInt HandleGetNtbParam(TDes8& aBuf) = 0;
|
|
64 |
virtual TInt HandleGetNtbInputSize(TDes8& aBuf) = 0;
|
|
65 |
virtual void ControlError(TInt aError) = 0;
|
|
66 |
};
|
|
67 |
|
|
68 |
/**
|
|
69 |
* implement NCM control interface
|
|
70 |
*/
|
|
71 |
|
|
72 |
NONSHARABLE_CLASS(CNcmCommunicationInterface) : public CActive
|
|
73 |
{
|
|
74 |
public:
|
|
75 |
static CNcmCommunicationInterface* NewL(MNcmControlObserver& aEngine, RDevUsbcScClient& aLdd);
|
|
76 |
~CNcmCommunicationInterface();
|
|
77 |
TInt Start();
|
|
78 |
void Stop();
|
|
79 |
void ControlMsgError(TNcmCommErrorCode aCode);
|
|
80 |
TInt SendConnectionNotification(TBool aConnected);
|
|
81 |
TInt SendSpeedNotification(TInt aUSBitRate, TInt aDSBitRate);
|
|
82 |
|
|
83 |
public:
|
|
84 |
inline RDevUsbcScClient& Ldd();
|
|
85 |
inline TBool IsStarted();
|
|
86 |
|
|
87 |
private:
|
|
88 |
enum TNcmCommRWState
|
|
89 |
{
|
|
90 |
EStateInitial = 0,
|
|
91 |
EStateReadSetup,
|
|
92 |
EStateReadDataout,
|
|
93 |
EStateWriteDatain
|
|
94 |
};
|
|
95 |
|
|
96 |
enum TUsbRequestType
|
|
97 |
{
|
|
98 |
EGetNtbParameters = 0x80,
|
|
99 |
EGetNtbInputSize = 0x85,
|
|
100 |
ESetNtbInputSize = 0x86
|
|
101 |
};
|
|
102 |
|
|
103 |
private:
|
|
104 |
CNcmCommunicationInterface(MNcmControlObserver& aEngine, RDevUsbcScClient& aLdd);
|
|
105 |
void ConstructL();
|
|
106 |
void RunL();
|
|
107 |
void DoCancel();
|
|
108 |
void ReadSetup();
|
|
109 |
void DecodeSetup();
|
|
110 |
void ReadDataOut();
|
|
111 |
void WriteDataIn();
|
|
112 |
void ParseDataOut();
|
|
113 |
TInt WriteInterruptData(TInt aEndPoint, TDesC8& aDes, TInt aLength);
|
|
114 |
TInt GetInterfaceNumber();
|
|
115 |
|
|
116 |
|
|
117 |
private:
|
|
118 |
|
|
119 |
MNcmControlObserver& iEngine;
|
|
120 |
/**
|
|
121 |
* USB request type
|
|
122 |
*/
|
|
123 |
TUint8 iRequestType;
|
|
124 |
/**
|
|
125 |
* data stage data length
|
|
126 |
*/
|
|
127 |
TUint16 iDataStageLength;
|
|
128 |
/**
|
|
129 |
* usb setup packet
|
|
130 |
*/
|
|
131 |
TBuf8<KSetupPacketLength> iSetupPacket;
|
|
132 |
/**
|
|
133 |
* control transfer data
|
|
134 |
*/
|
|
135 |
TBuf8<KNtbParamStructLength> iDataBuffer;
|
|
136 |
TNcmCommRWState iRWState;
|
|
137 |
TBool iStarted;
|
|
138 |
RDevUsbcScClient& iPort;
|
|
139 |
/**
|
|
140 |
* instance to CNcmCommInterfaceSenderAndReceiver
|
|
141 |
*/
|
|
142 |
CNcmCommInterfaceSenderAndReceiver* iSenderAndReceiver;
|
|
143 |
/**
|
|
144 |
* communication interface number
|
|
145 |
*/
|
|
146 |
TUint8 iInterfaceNumber;
|
|
147 |
|
|
148 |
};
|
|
149 |
|
|
150 |
// Inline functions
|
|
151 |
#include "ncmcommunicationinterface.inl"
|
|
152 |
|
|
153 |
#endif //NCMCOMMUNICATIONINTERFACE_H
|