Update contrib.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\d32camerasc.inl
18 inline TVersion RDevCameraSc::VersionRequired()
20 const TInt KCameraMajorVersionNumber=1;
21 const TInt KCameraMinorVersionNumber=0;
22 const TInt KCameraBuildVersionNumber=KE32BuildVersionNumber;
23 return TVersion(KCameraMajorVersionNumber,KCameraMinorVersionNumber,KCameraBuildVersionNumber);
26 #ifndef __KERNEL_MODE__
29 inline RDevCameraSc::RDevCameraSc()
30 : RBusLogicalChannel()
36 inline TInt RDevCameraSc::Open(TInt aUnit)
38 TInt r=DoCreate(KDevCameraScName,VersionRequired(),aUnit,NULL,NULL,EOwnerThread);
41 // Obtain the Capability structure size then allocate memory for it on client side
42 r=iCapsSize=DoControl(EControlCapsSize);
49 TAny* capsBufPtr = User::Alloc(iCapsSize);
50 if(NULL == capsBufPtr)
56 TPtr8 capsPtr((TUint8*)capsBufPtr, iCapsSize, iCapsSize);
57 // Fill the Capability structure
58 r = DoControl(EControlCaps,(TAny*)&capsPtr);
64 iCameraCaps = (TCameraCapsV02*) capsPtr.Ptr();
70 inline void RDevCameraSc::Close()
72 if (iCameraCaps != NULL)
74 User::Free(iCameraCaps);
78 RBusLogicalChannel::Close();
81 inline TInt RDevCameraSc::Caps(TDes8& aCapsBuf)
83 if (aCapsBuf.MaxLength() < iCapsSize)
88 TPtrC8 ptr ((TUint8*)iCameraCaps, iCapsSize);
93 inline TPtrC8 RDevCameraSc::Caps()
95 TPtrC8 ptr((TUint8*)iCameraCaps, iCapsSize);
99 inline TInt RDevCameraSc::SetBufConfigChunkCreate(TDevCamCaptureMode aCaptureMode, TInt aNumBuffers, RChunk& aChunk)
100 {return(aChunk.SetReturnedHandle(DoControl(EControlSetBufConfigChunkCreate,(TAny*)aCaptureMode,(TAny*)aNumBuffers)));}
102 inline TInt RDevCameraSc::SetBufConfigChunkOpen(TDevCamCaptureMode aCaptureMode, const TDesC8& aBufferConfigBuf, RChunk& aChunk)
104 SSetBufConfigChunkOpenInfo info = {&aBufferConfigBuf, aChunk.Handle()};
105 return(DoControl(EControlSetBufConfigChunkOpen,(TAny*)aCaptureMode,&info));
108 inline TInt RDevCameraSc::ChunkClose(TDevCamCaptureMode aCaptureMode)
109 {return(DoControl(EControlChunkClose,(TAny*)aCaptureMode));}
111 inline TInt RDevCameraSc::SetCamConfig(TDevCamCaptureMode aCaptureMode,const TDesC8& aConfigBuf)
112 {return(DoControl(EControlSetCamConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf));}
114 inline void RDevCameraSc::GetCamConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf)
115 {DoControl(EControlGetCamConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf);}
117 inline void RDevCameraSc::GetBufferConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf)
118 {DoControl(EControlGetBufferConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf);}
120 inline TInt RDevCameraSc::SetCaptureMode(TDevCamCaptureMode aCaptureMode)
121 {return(DoControl(EControlSetCaptureMode,(TAny*)aCaptureMode));}
123 inline TInt RDevCameraSc::Start()
124 {return(DoControl(EControlStart));}
126 inline TInt RDevCameraSc::Stop()
127 {return(DoControl(EControlStop));}
129 inline void RDevCameraSc::NotifyNewImage(TRequestStatus& aStatus)
130 {DoRequest(ERequestNotifyNewImage,aStatus);}
132 inline void RDevCameraSc::NotifyNewImageCancel()
133 {DoCancel(1<<ERequestNotifyNewImage);}
135 inline void RDevCameraSc::NotifyNewImageCancel(const TRequestStatus& aStatus)
136 {DoControl(EControlNotifyNewImageSpecificCancel,(TAny*)&aStatus);}
138 inline TInt RDevCameraSc::ReleaseBuffer(TInt aBufferId)
139 {return(DoControl(EControlReleaseBuffer,(TAny*)aBufferId));}
141 inline TInt RDevCameraSc::BufferIdToOffset(TDevCamCaptureMode aCaptureMode, TInt aId, TInt& aOffset)
144 TDevCamBufferModeAndIdBuf databuf;
145 TDevCamBufferModeAndId &data = databuf();
146 data.iCaptureMode = aCaptureMode;
149 return (DoControl(EControlBufferIdToOffset,(TAny*)&databuf,(TAny*)&aOffset));
152 inline TInt RDevCameraSc::CapsSize()
155 inline TInt RDevCameraSc::FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf)
157 SFrameSizeCapsInfo info = {aUidPixelFormat, aCaptureMode};
158 return(DoControl(EControlFrameSizeCaps, (TAny*)&aFrameSizeCapsBuf, &info));
164 inline TInt RDevCameraSc::CheckAttributeSupported(TDevCamDynamicAttribute aAttribute)
170 case ECamAttributeBrightness:
171 mask = KCamMiscBrightness;
174 case ECamAttributeContrast:
175 mask = KCamMiscContrast;
178 case ECamAttributeColorEffect:
179 mask = KCamMiscColorEffect;
183 return KErrNotSupported;
186 // Check that the attribute is supported by the hardware.
187 return (iCameraCaps->iCapsMisc & mask ? KErrNone : KErrNotSupported);
193 inline TInt RDevCameraSc::SetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint aValue)
195 TInt err = CheckAttributeSupported(aAttribute);
199 TDynamicRange &range = iCameraCaps->iDynamicRange[aAttribute];
200 if ((aValue >= range.iMin) && (aValue <= range.iMax))
202 err = DoControl(EControlSetDynamicAttribute, (TAny*)aAttribute, (TAny*)aValue);
212 inline TInt RDevCameraSc::GetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint& aValue)
214 TInt err = CheckAttributeSupported(aAttribute);
217 err = DoControl(EControlGetDynamicAttribute, (TAny*)aAttribute, (TAny*)&aValue);
222 #endif // __KERNEL_MODE__