|
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 Close(); |
|
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 // |
|
162 // |
|
163 // |
|
164 inline TInt RDevCameraSc::CheckAttributeSupported(TDevCamDynamicAttribute aAttribute) |
|
165 { |
|
166 TUint mask = 0; |
|
167 |
|
168 switch (aAttribute) |
|
169 { |
|
170 case ECamAttributeBrightness: |
|
171 mask = KCamMiscBrightness; |
|
172 break; |
|
173 |
|
174 case ECamAttributeContrast: |
|
175 mask = KCamMiscContrast; |
|
176 break; |
|
177 |
|
178 case ECamAttributeColorEffect: |
|
179 mask = KCamMiscColorEffect; |
|
180 break; |
|
181 |
|
182 default: |
|
183 return KErrNotSupported; |
|
184 } |
|
185 |
|
186 // Check that the attribute is supported by the hardware. |
|
187 return (iCameraCaps->iCapsMisc & mask ? KErrNone : KErrNotSupported); |
|
188 } |
|
189 |
|
190 // |
|
191 // |
|
192 // |
|
193 inline TInt RDevCameraSc::SetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint aValue) |
|
194 { |
|
195 TInt err = CheckAttributeSupported(aAttribute); |
|
196 if (err == KErrNone) |
|
197 { |
|
198 err = KErrArgument; |
|
199 TDynamicRange &range = iCameraCaps->iDynamicRange[aAttribute]; |
|
200 if ((aValue >= range.iMin) && (aValue <= range.iMax)) |
|
201 { |
|
202 err = DoControl(EControlSetDynamicAttribute, (TAny*)aAttribute, (TAny*)aValue); |
|
203 } |
|
204 } |
|
205 |
|
206 return err; |
|
207 } |
|
208 |
|
209 // |
|
210 // |
|
211 // |
|
212 inline TInt RDevCameraSc::GetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint& aValue) |
|
213 { |
|
214 TInt err = CheckAttributeSupported(aAttribute); |
|
215 if (err == KErrNone) |
|
216 { |
|
217 err = DoControl(EControlGetDynamicAttribute, (TAny*)aAttribute, (TAny*)&aValue); |
|
218 } |
|
219 |
|
220 return err; |
|
221 } |
|
222 #endif // __KERNEL_MODE__ |