0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32\include\d32camerasc.inl
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
inline TVersion RDevCameraSc::VersionRequired()
|
|
19 |
{
|
|
20 |
const TInt KCameraMajorVersionNumber=1;
|
|
21 |
const TInt KCameraMinorVersionNumber=0;
|
|
22 |
const TInt KCameraBuildVersionNumber=KE32BuildVersionNumber;
|
|
23 |
return TVersion(KCameraMajorVersionNumber,KCameraMinorVersionNumber,KCameraBuildVersionNumber);
|
|
24 |
}
|
|
25 |
|
|
26 |
#ifndef __KERNEL_MODE__
|
|
27 |
|
|
28 |
|
|
29 |
inline RDevCameraSc::RDevCameraSc()
|
|
30 |
: RBusLogicalChannel()
|
|
31 |
{
|
|
32 |
iCameraCaps = NULL;
|
|
33 |
iCapsSize = 0;
|
|
34 |
}
|
|
35 |
|
|
36 |
inline TInt RDevCameraSc::Open(TInt aUnit)
|
|
37 |
{
|
|
38 |
TInt r=DoCreate(KDevCameraScName,VersionRequired(),aUnit,NULL,NULL,EOwnerThread);
|
|
39 |
if (KErrNone == r)
|
|
40 |
{
|
|
41 |
// Obtain the Capability structure size then allocate memory for it on client side
|
|
42 |
r=iCapsSize=DoControl(EControlCapsSize);
|
|
43 |
if (KErrNone > r)
|
|
44 |
{
|
|
45 |
iCapsSize = 0;
|
|
46 |
return r;
|
|
47 |
}
|
|
48 |
|
|
49 |
TAny* capsBufPtr = User::Alloc(iCapsSize);
|
|
50 |
if(NULL == capsBufPtr)
|
|
51 |
{
|
|
52 |
iCapsSize = 0;
|
|
53 |
return KErrNoMemory;
|
|
54 |
}
|
|
55 |
|
|
56 |
TPtr8 capsPtr((TUint8*)capsBufPtr, iCapsSize, iCapsSize);
|
|
57 |
// Fill the Capability structure
|
|
58 |
r = DoControl(EControlCaps,(TAny*)&capsPtr);
|
|
59 |
if (KErrNone > r)
|
|
60 |
{
|
|
61 |
iCapsSize = 0;
|
|
62 |
return r;
|
|
63 |
}
|
|
64 |
iCameraCaps = (TCameraCapsV02*) capsPtr.Ptr();
|
|
65 |
}
|
|
66 |
|
|
67 |
return r;
|
|
68 |
}
|
|
69 |
|
|
70 |
inline void RDevCameraSc::Close()
|
|
71 |
{
|
|
72 |
if (iCameraCaps != NULL)
|
|
73 |
{
|
|
74 |
User::Free(iCameraCaps);
|
|
75 |
iCameraCaps = NULL;
|
|
76 |
}
|
|
77 |
iCapsSize = 0;
|
|
78 |
RBusLogicalChannel::Close();
|
|
79 |
}
|
|
80 |
|
|
81 |
inline TInt RDevCameraSc::Caps(TDes8& aCapsBuf)
|
|
82 |
{
|
|
83 |
if (aCapsBuf.MaxLength() < iCapsSize)
|
|
84 |
{
|
|
85 |
return KErrArgument;
|
|
86 |
}
|
|
87 |
|
|
88 |
TPtrC8 ptr ((TUint8*)iCameraCaps, iCapsSize);
|
|
89 |
aCapsBuf = ptr;
|
|
90 |
return KErrNone;
|
|
91 |
}
|
|
92 |
|
|
93 |
inline TPtrC8 RDevCameraSc::Caps()
|
|
94 |
{
|
|
95 |
TPtrC8 ptr((TUint8*)iCameraCaps, iCapsSize);
|
|
96 |
return ptr;
|
|
97 |
}
|
|
98 |
|
|
99 |
inline TInt RDevCameraSc::SetBufConfigChunkCreate(TDevCamCaptureMode aCaptureMode, TInt aNumBuffers, RChunk& aChunk)
|
|
100 |
{return(aChunk.SetReturnedHandle(DoControl(EControlSetBufConfigChunkCreate,(TAny*)aCaptureMode,(TAny*)aNumBuffers)));}
|
|
101 |
|
|
102 |
inline TInt RDevCameraSc::SetBufConfigChunkOpen(TDevCamCaptureMode aCaptureMode, const TDesC8& aBufferConfigBuf, RChunk& aChunk)
|
|
103 |
{
|
|
104 |
SSetBufConfigChunkOpenInfo info = {&aBufferConfigBuf, aChunk.Handle()};
|
|
105 |
return(DoControl(EControlSetBufConfigChunkOpen,(TAny*)aCaptureMode,&info));
|
|
106 |
}
|
|
107 |
|
|
108 |
inline TInt RDevCameraSc::ChunkClose(TDevCamCaptureMode aCaptureMode)
|
|
109 |
{return(DoControl(EControlChunkClose,(TAny*)aCaptureMode));}
|
|
110 |
|
|
111 |
inline TInt RDevCameraSc::SetCamConfig(TDevCamCaptureMode aCaptureMode,const TDesC8& aConfigBuf)
|
|
112 |
{return(DoControl(EControlSetCamConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf));}
|
|
113 |
|
|
114 |
inline void RDevCameraSc::GetCamConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf)
|
|
115 |
{DoControl(EControlGetCamConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf);}
|
|
116 |
|
|
117 |
inline void RDevCameraSc::GetBufferConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf)
|
|
118 |
{DoControl(EControlGetBufferConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf);}
|
|
119 |
|
|
120 |
inline TInt RDevCameraSc::SetCaptureMode(TDevCamCaptureMode aCaptureMode)
|
|
121 |
{return(DoControl(EControlSetCaptureMode,(TAny*)aCaptureMode));}
|
|
122 |
|
|
123 |
inline TInt RDevCameraSc::Start()
|
|
124 |
{return(DoControl(EControlStart));}
|
|
125 |
|
|
126 |
inline TInt RDevCameraSc::Stop()
|
|
127 |
{return(DoControl(EControlStop));}
|
|
128 |
|
|
129 |
inline void RDevCameraSc::NotifyNewImage(TRequestStatus& aStatus)
|
|
130 |
{DoRequest(ERequestNotifyNewImage,aStatus);}
|
|
131 |
|
|
132 |
inline void RDevCameraSc::NotifyNewImageCancel()
|
|
133 |
{DoCancel(1<<ERequestNotifyNewImage);}
|
|
134 |
|
|
135 |
inline void RDevCameraSc::NotifyNewImageCancel(const TRequestStatus& aStatus)
|
|
136 |
{DoControl(EControlNotifyNewImageSpecificCancel,(TAny*)&aStatus);}
|
|
137 |
|
|
138 |
inline TInt RDevCameraSc::ReleaseBuffer(TInt aBufferId)
|
|
139 |
{return(DoControl(EControlReleaseBuffer,(TAny*)aBufferId));}
|
|
140 |
|
|
141 |
inline TInt RDevCameraSc::BufferIdToOffset(TDevCamCaptureMode aCaptureMode, TInt aId, TInt& aOffset)
|
|
142 |
{
|
|
143 |
// search criteria
|
|
144 |
TDevCamBufferModeAndIdBuf databuf;
|
|
145 |
TDevCamBufferModeAndId &data = databuf();
|
|
146 |
data.iCaptureMode = aCaptureMode;
|
|
147 |
data.iId = aId;
|
|
148 |
|
|
149 |
return (DoControl(EControlBufferIdToOffset,(TAny*)&databuf,(TAny*)&aOffset));
|
|
150 |
}
|
|
151 |
|
|
152 |
inline TInt RDevCameraSc::CapsSize()
|
|
153 |
{return(iCapsSize);}
|
|
154 |
|
|
155 |
inline TInt RDevCameraSc::FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf)
|
|
156 |
{
|
|
157 |
SFrameSizeCapsInfo info = {aUidPixelFormat, aCaptureMode};
|
|
158 |
return(DoControl(EControlFrameSizeCaps, (TAny*)&aFrameSizeCapsBuf, &info));
|
|
159 |
}
|
|
160 |
|
|
161 |
inline TInt RDevCameraSc::SetDynamicAttribute(TDevCamDynamicAttributes aAttribute, TUint aValue)
|
|
162 |
{
|
|
163 |
TInt r = KErrNone;
|
|
164 |
|
|
165 |
// Are we not supported?
|
|
166 |
TInt misc = 0;
|
|
167 |
switch (aAttribute)
|
|
168 |
{
|
|
169 |
case ECamAttributeBrightness:
|
|
170 |
{
|
|
171 |
misc = KCamMiscBrightness;
|
|
172 |
break;
|
|
173 |
}
|
|
174 |
case ECamAttributeContrast:
|
|
175 |
{
|
|
176 |
misc = KCamMiscContrast;
|
|
177 |
break;
|
|
178 |
}
|
|
179 |
case ECamAttributeColorEffect:
|
|
180 |
{
|
|
181 |
misc = KCamMiscColorEffect;
|
|
182 |
break;
|
|
183 |
}
|
|
184 |
default:
|
|
185 |
{
|
|
186 |
r = KErrBadName;
|
|
187 |
}
|
|
188 |
}
|
|
189 |
|
|
190 |
if (KErrNone != r)
|
|
191 |
{
|
|
192 |
return r;
|
|
193 |
}
|
|
194 |
|
|
195 |
if (!(iCameraCaps->iCapsMisc & misc))
|
|
196 |
{
|
|
197 |
r = KErrNotSupported;
|
|
198 |
}
|
|
199 |
|
|
200 |
else
|
|
201 |
{
|
|
202 |
TDynamicRange &range = iCameraCaps->iDynamicRange[aAttribute];
|
|
203 |
// Not within range?
|
|
204 |
if (aValue < range.iMin || aValue > range.iMax)
|
|
205 |
{
|
|
206 |
r = KErrArgument;
|
|
207 |
}
|
|
208 |
else
|
|
209 |
{
|
|
210 |
r = DoControl(EControlSetDynamicAttribute,(TAny*)aAttribute, (TAny*)aValue);
|
|
211 |
}
|
|
212 |
}
|
|
213 |
|
|
214 |
return r;
|
|
215 |
}
|
|
216 |
|
|
217 |
#endif // __KERNEL_MODE__
|