14 // e32\drivers\pbus\pbusmedia.cpp |
14 // e32\drivers\pbus\pbusmedia.cpp |
15 // |
15 // |
16 // |
16 // |
17 |
17 |
18 #include <drivers/pbusmedia.h> |
18 #include <drivers/pbusmedia.h> |
|
19 #include "OstTraceDefinitions.h" |
|
20 #ifdef OST_TRACE_COMPILER_IN_USE |
|
21 #include "locmedia_ost.h" |
|
22 #ifdef __VC32__ |
|
23 #pragma warning(disable: 4127) // disabling warning "conditional expression is constant" |
|
24 #endif |
|
25 #include "pbusmediaTraces.h" |
|
26 #endif |
19 |
27 |
20 void mediaCallBack(TAny* aPtr, TInt aReason, TAny* a1, TAny* a2) |
28 void mediaCallBack(TAny* aPtr, TInt aReason, TAny* a1, TAny* a2) |
21 { |
29 { |
|
30 OstTraceFunctionEntry0( MEDIACALLBACK_ENTRY ); |
22 DPBusPrimaryMedia* pM=(DPBusPrimaryMedia*)aPtr; |
31 DPBusPrimaryMedia* pM=(DPBusPrimaryMedia*)aPtr; |
23 __KTRACE_OPT(KLOCDRV,Kern::Printf("mediaCallBack media %d, reason %d, a1=0x%x, a2=0x%x",pM->iMediaId,aReason,a1,a2)); |
32 __KTRACE_OPT(KLOCDRV,Kern::Printf("mediaCallBack media %d, reason %d, a1=0x%x, a2=0x%x",pM->iMediaId,aReason,a1,a2)); |
|
33 OstTraceExt4( TRACE_INTERNALS, MEDIACALLBACK, "aPtr=0x%x; aReason=%d; a1=0x%x; a2=0x%x", ( TUint )( aPtr ), aReason, ( TUint )( a1 ), ( TUint )( a2 ) ); |
|
34 |
24 switch (aReason) |
35 switch (aReason) |
25 { |
36 { |
26 case TPBusCallBack::EPBusStateChange: |
37 case TPBusCallBack::EPBusStateChange: |
27 pM->PBusStateChange((TInt)a1,(TInt)a2); |
38 pM->PBusStateChange((TInt)a1,(TInt)a2); |
28 break; |
39 break; |
29 } |
40 } |
|
41 OstTraceFunctionExit0( MEDIACALLBACK_EXIT ); |
30 } |
42 } |
31 |
43 |
32 /** |
44 /** |
33 Constructor for DPBusPrimaryMedia. Initializes the iSocket with aSocket. |
45 Constructor for DPBusPrimaryMedia. Initializes the iSocket with aSocket. |
34 @param aSocket Pointer to DPBusSocket object |
46 @param aSocket Pointer to DPBusSocket object |
120 otherwise one of the other system wide error codes. |
142 otherwise one of the other system wide error codes. |
121 @see DPBusSocket::PowerUp() |
143 @see DPBusSocket::PowerUp() |
122 */ |
144 */ |
123 TInt DPBusPrimaryMedia::InitiatePowerUp() |
145 TInt DPBusPrimaryMedia::InitiatePowerUp() |
124 { |
146 { |
125 return iSocket->PowerUp(); |
147 OstTraceFunctionEntry1( DPBUSPRIMARYMEDIA_INITIATEPOWERUP_ENTRY, this ); |
|
148 TInt r = iSocket->PowerUp(); |
|
149 OstTraceFunctionExitExt( DPBUSPRIMARYMEDIA_INITIATEPOWERUP_EXIT, this, r ); |
|
150 return r; |
126 } |
151 } |
127 |
152 |
128 /** |
153 /** |
129 Flags the media driver as entering a critical part of its processing. |
154 Flags the media driver as entering a critical part of its processing. |
130 @return KErrNone if successful, |
155 @return KErrNone if successful, |
131 otherwise one of the other system wide error codes. |
156 otherwise one of the other system wide error codes. |
132 @see DPBusSocket::InCritical() |
157 @see DPBusSocket::InCritical() |
133 */ |
158 */ |
134 TInt DPBusPrimaryMedia::DoInCritical() |
159 TInt DPBusPrimaryMedia::DoInCritical() |
135 { |
160 { |
136 return iSocket->InCritical(); |
161 OstTraceFunctionEntry1( DPBUSPRIMARYMEDIA_DOINCRITICAL_ENTRY, this ); |
|
162 TInt r = iSocket->InCritical(); |
|
163 OstTraceFunctionExitExt( DPBUSPRIMARYMEDIA_DOINCRITICAL_EXIT, this, r ); |
|
164 return r; |
137 } |
165 } |
138 |
166 |
139 /** |
167 /** |
140 Flags the media driver as leaving a critical part of its processing. |
168 Flags the media driver as leaving a critical part of its processing. |
141 @return KErrNone if successful, |
169 @return KErrNone if successful, |
142 otherwise one of the other system wide error codes. |
170 otherwise one of the other system wide error codes. |
143 @see DPBusSocket::EndInCritical() |
171 @see DPBusSocket::EndInCritical() |
144 */ |
172 */ |
145 void DPBusPrimaryMedia::DoEndInCritical() |
173 void DPBusPrimaryMedia::DoEndInCritical() |
146 { |
174 { |
|
175 OstTraceFunctionEntry1( DPBUSPRIMARYMEDIA_DOENDINCRITICAL_ENTRY, this ); |
147 iSocket->EndInCritical(); |
176 iSocket->EndInCritical(); |
|
177 OstTraceFunctionExit1( DPBUSPRIMARYMEDIA_DOENDINCRITICAL_EXIT, this ); |
148 } |
178 } |
149 |
179 |
150 /** |
180 /** |
151 Sets the incremental value of current consumption to aCurrent. |
181 Sets the incremental value of current consumption to aCurrent. |
152 @param aCurrent Delta Current in Milliamps. |
182 @param aCurrent Delta Current in Milliamps. |
153 @see DPBusSocket::DeltaCurrentConsumption() |
183 @see DPBusSocket::DeltaCurrentConsumption() |
154 */ |
184 */ |
155 void DPBusPrimaryMedia::DeltaCurrentConsumption(TInt aCurrent) |
185 void DPBusPrimaryMedia::DeltaCurrentConsumption(TInt aCurrent) |
156 { |
186 { |
|
187 OstTraceFunctionEntryExt( DPBUSPRIMARYMEDIA_DELTACURRENTCONSUMPTION_ENTRY, this ); |
157 iSocket->DeltaCurrentConsumption(aCurrent); |
188 iSocket->DeltaCurrentConsumption(aCurrent); |
|
189 OstTraceFunctionExit1( DPBUSPRIMARYMEDIA_DELTACURRENTCONSUMPTION_EXIT, this ); |
158 } |
190 } |
159 |
191 |
160 /** |
192 /** |
161 Gets the default drive capability/attributes. |
193 Gets the default drive capability/attributes. |
162 @param aCaps A reference to a client-supplied TLocalDriveCapsV2 class to be filled by this function. |
194 @param aCaps A reference to a client-supplied TLocalDriveCapsV2 class to be filled by this function. |
163 @see TLocalDriveCapsV2 |
195 @see TLocalDriveCapsV2 |
164 @see TMediaType |
196 @see TMediaType |
165 */ |
197 */ |
166 void DPBusPrimaryMedia::DefaultDriveCaps(TLocalDriveCapsV2& aCaps) |
198 void DPBusPrimaryMedia::DefaultDriveCaps(TLocalDriveCapsV2& aCaps) |
167 { |
199 { |
|
200 OstTraceFunctionEntry1( DPBUSPRIMARYMEDIA_DEFAULTDRIVECAPS_ENTRY, this ); |
168 // aCaps is zeroed beforehand |
201 // aCaps is zeroed beforehand |
169 aCaps.iType = EMediaNotPresent; |
202 aCaps.iType = EMediaNotPresent; |
170 aCaps.iDriveAtt = KDriveAttLocal|KDriveAttRemovable; |
203 aCaps.iDriveAtt = KDriveAttLocal|KDriveAttRemovable; |
|
204 OstTraceFunctionExit1( DPBUSPRIMARYMEDIA_DEFAULTDRIVECAPS_EXIT, this ); |
171 } |
205 } |
172 |
206 |
173 /** |
207 /** |
174 Checks whether it is a removable media device or not. |
208 Checks whether it is a removable media device or not. |
175 @param aSocketNum This will be updated with socket number |
209 @param aSocketNum This will be updated with socket number |
176 @return ETrue if Removable Device, EFalse if the device is Non-Removable. |
210 @return ETrue if Removable Device, EFalse if the device is Non-Removable. |
177 */ |
211 */ |
178 TBool DPBusPrimaryMedia::IsRemovableDevice(TInt& aSocketNum) |
212 TBool DPBusPrimaryMedia::IsRemovableDevice(TInt& aSocketNum) |
179 { |
213 { |
|
214 OstTraceFunctionEntryExt( DPBUSPRIMARYMEDIA_ISREMOVABLEDEVICE_ENTRY, this ); |
180 aSocketNum=iSocket->iSocketNumber; |
215 aSocketNum=iSocket->iSocketNumber; |
|
216 OstTraceFunctionExit1( DPBUSPRIMARYMEDIA_ISREMOVABLEDEVICE_EXIT, this ); |
181 return(ETrue); |
217 return(ETrue); |
182 } |
218 } |
183 |
219 |
184 void DPBusPrimaryMedia::PBusStateChange(TInt aState, TInt anError) |
220 void DPBusPrimaryMedia::PBusStateChange(TInt aState, TInt anError) |
185 { |
221 { |
|
222 OstTraceFunctionEntryExt( DPBUSPRIMARYMEDIA_PBUSSTATECHANGE_ENTRY, this ); |
186 // receive power down and media change notifications |
223 // receive power down and media change notifications |
187 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPBusPrimaryMedia(%d)::PBusStateChange state %d, err %d",iMediaId,aState,anError)); |
224 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPBusPrimaryMedia(%d)::PBusStateChange state %d, err %d",iMediaId,aState,anError)); |
|
225 OstTraceExt3(TRACE_INTERNALS, DPBUSPRIMARYMEDIA_PBUSSTATECHANGE, "iMediaId=%d; aState=%d; anError=%d", iMediaId,aState,anError); |
188 if (aState!=iPBusState) |
226 if (aState!=iPBusState) |
189 { |
227 { |
190 TInt oldState = iPBusState; |
228 TInt oldState = iPBusState; |
191 iPBusState=aState; |
229 iPBusState=aState; |
192 switch (aState) |
230 switch (aState) |