author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 11 May 2010 17:28:22 +0300 | |
branch | RCL_3 |
changeset 110 | c734af59ce98 |
parent 31 | 56f325a607ea |
child 258 | 880ff05ad710 |
permissions | -rw-r--r-- |
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 |
{ |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
Close(); |
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 |
} |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
160 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
161 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
inline TInt RDevCameraSc::CheckAttributeSupported(TDevCamDynamicAttribute aAttribute) |
0 | 165 |
{ |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
166 |
TUint mask = 0; |
0 | 167 |
|
168 |
switch (aAttribute) |
|
169 |
{ |
|
170 |
case ECamAttributeBrightness: |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
mask = KCamMiscBrightness; |
0 | 172 |
break; |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
173 |
|
0 | 174 |
case ECamAttributeContrast: |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
mask = KCamMiscContrast; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
176 |
break; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
177 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
178 |
case ECamAttributeColorEffect: |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
mask = KCamMiscColorEffect; |
0 | 180 |
break; |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
182 |
default: |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
183 |
return KErrNotSupported; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
// Check that the attribute is supported by the hardware. |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
187 |
return (iCameraCaps->iCapsMisc & mask ? KErrNone : KErrNotSupported); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
190 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
inline TInt RDevCameraSc::SetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint aValue) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
TInt err = CheckAttributeSupported(aAttribute); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
if (err == KErrNone) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
198 |
err = KErrArgument; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
TDynamicRange &range = iCameraCaps->iDynamicRange[aAttribute]; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
if ((aValue >= range.iMin) && (aValue <= range.iMax)) |
0 | 201 |
{ |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
err = DoControl(EControlSetDynamicAttribute, (TAny*)aAttribute, (TAny*)aValue); |
0 | 203 |
} |
204 |
} |
|
205 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
return err; |
0 | 207 |
} |
208 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
// |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
inline TInt RDevCameraSc::GetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint& aValue) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
TInt err = CheckAttributeSupported(aAttribute); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
if (err == KErrNone) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
err = DoControl(EControlGetDynamicAttribute, (TAny*)aAttribute, (TAny*)&aValue); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
return err; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
} |
0 | 222 |
#endif // __KERNEL_MODE__ |