sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// template\template_variant\camerasc\camerasc.cpp
|
sl@0
|
15 |
// Implementation of the template shared chunk camera physical device driver (PDD).
|
sl@0
|
16 |
// This file is part of the Template Base port
|
sl@0
|
17 |
//
|
sl@0
|
18 |
//
|
sl@0
|
19 |
#include "camerasc_plat.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
_LIT(KCameraScPddName, "CameraSc.TE");
|
sl@0
|
22 |
_LIT(KCameraScDfcQueueName, "CameraSc.TE.DfcQ");
|
sl@0
|
23 |
|
sl@0
|
24 |
/**
|
sl@0
|
25 |
Standard export function for PDD factories. This creates a DPhysicalDevice derived object, in this case,
|
sl@0
|
26 |
DTemplateCameraScPddFactory.
|
sl@0
|
27 |
*/
|
sl@0
|
28 |
DECLARE_STANDARD_PDD()
|
sl@0
|
29 |
{
|
sl@0
|
30 |
return new DTemplateCameraScPddFactory;
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
Constructor for the shared chunk camera PDD factory class.
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
DTemplateCameraScPddFactory::DTemplateCameraScPddFactory()
|
sl@0
|
37 |
{
|
sl@0
|
38 |
// We currently support only unit 0
|
sl@0
|
39 |
iUnitsMask = 0x01;
|
sl@0
|
40 |
|
sl@0
|
41 |
// Set the version number for this device. This is used to allow code to specify that it requires a
|
sl@0
|
42 |
// minimum version of the device in order to operate. If the version requested is less than this then
|
sl@0
|
43 |
// the device is safe to be used
|
sl@0
|
44 |
iVersion = RDevCameraSc::VersionRequired();
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
/**
|
sl@0
|
48 |
Destructor for the shared chunk camera PDD factory class.
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
DTemplateCameraScPddFactory::~DTemplateCameraScPddFactory()
|
sl@0
|
51 |
{
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
/**
|
sl@0
|
55 |
Second stage constructor for the shared chunk camera PDD factory class. This must at least set a name for
|
sl@0
|
56 |
the driver object.
|
sl@0
|
57 |
@return KErrNone if successful, otherwise one of the system wide error codes.
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
TInt DTemplateCameraScPddFactory::Install()
|
sl@0
|
60 |
{
|
sl@0
|
61 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPddFactory::Install()"));
|
sl@0
|
62 |
|
sl@0
|
63 |
TInt r;
|
sl@0
|
64 |
|
sl@0
|
65 |
// Create a DFC queue so that handling of both camera hardware callbacks and requests made to the LDD from
|
sl@0
|
66 |
// user mode can be processed in the same thread, to avoid the use of semaphores
|
sl@0
|
67 |
if ((r = Kern::DynamicDfcQCreate(iDfcQ, 26, KCameraScDfcQueueName)) == KErrNone)
|
sl@0
|
68 |
{
|
sl@0
|
69 |
// All PDD factories must have a unique name
|
sl@0
|
70 |
r = SetName(&KCameraScPddName);
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPddFactory::Install() => Returning %d", r));
|
sl@0
|
74 |
|
sl@0
|
75 |
return r;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
/**
|
sl@0
|
79 |
Returns the PDD's capabilities. This is not used by the Symbian OS device driver framework
|
sl@0
|
80 |
or by the LDD but is here as some LDDs will make use of it.
|
sl@0
|
81 |
@param aDes A descriptor into which to write capability information.
|
sl@0
|
82 |
*/
|
sl@0
|
83 |
void DTemplateCameraScPddFactory::GetCaps(TDes8& /*aDes*/) const
|
sl@0
|
84 |
{
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
/**
|
sl@0
|
88 |
Called by the kernel's device driver framework to check if this PDD is suitable for use
|
sl@0
|
89 |
with a logical channel. This is called in the context of the client thread which requested
|
sl@0
|
90 |
the creation of a logical channel, through a call to RBusLogicalChannel::DoCreate(). The
|
sl@0
|
91 |
thread is in a critical section.
|
sl@0
|
92 |
@param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate()
|
sl@0
|
93 |
This is used to determine which sensor to use.
|
sl@0
|
94 |
@param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate().
|
sl@0
|
95 |
@param aVer The version number of the logical channel which will use this physical channel.
|
sl@0
|
96 |
@return KErrNone if successful, otherwise one of the system wide error codes.
|
sl@0
|
97 |
*/
|
sl@0
|
98 |
TInt DTemplateCameraScPddFactory::Validate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
// Check that the version requested is less than or equal to the version of this PDD
|
sl@0
|
101 |
if (!Kern::QueryVersionSupported(RDevCameraSc::VersionRequired(), aVer))
|
sl@0
|
102 |
{
|
sl@0
|
103 |
return KErrNotSupported;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
// Check that the unit number specifies the available sensor
|
sl@0
|
107 |
if ((aUnit < 0) || (aUnit > 0))
|
sl@0
|
108 |
{
|
sl@0
|
109 |
return KErrNotSupported;
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
return KErrNone;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
Called by the kernel's device driver framework to create a physical channel object. This
|
sl@0
|
117 |
is called in the context of the client thread which requested the creation of a logical
|
sl@0
|
118 |
channel, through a call to RBusLogicalChannel::DoCreate(). The thread is in a critical section.
|
sl@0
|
119 |
@param aChannel Set by this function to point to the created physical channel object.
|
sl@0
|
120 |
@param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate().
|
sl@0
|
121 |
@param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate().
|
sl@0
|
122 |
@param aVer The version number of the logical channel which will use this physical channel.
|
sl@0
|
123 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
TInt DTemplateCameraScPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPddFactory::Create()"));
|
sl@0
|
128 |
|
sl@0
|
129 |
// Create an instance of the PDD channel object that will work with the Template sensor
|
sl@0
|
130 |
DTemplateCameraScPdd* pD = new DTemplateCameraScPdd;
|
sl@0
|
131 |
|
sl@0
|
132 |
aChannel = pD;
|
sl@0
|
133 |
TInt r = KErrNoMemory;
|
sl@0
|
134 |
|
sl@0
|
135 |
if (pD)
|
sl@0
|
136 |
{
|
sl@0
|
137 |
r = pD->DoCreate(this, aUnit);
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPddFactory::Create() => Returning %d", r));
|
sl@0
|
141 |
|
sl@0
|
142 |
return r;
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
/**
|
sl@0
|
146 |
Called by SetUnitOpen() to see if a particular unit is open. When called, the
|
sl@0
|
147 |
iUnitInfoMutex fast mutex will be taken, ensuring safe access to iUnitsOpenMask.
|
sl@0
|
148 |
@param aUnit The unit number to be checked for being open.
|
sl@0
|
149 |
@return ETrue if the unit specified by aUnit is already open, otherwise EFalse.
|
sl@0
|
150 |
*/
|
sl@0
|
151 |
TBool DTemplateCameraScPddFactory::IsUnitOpen(TInt aUnit)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
return (iUnitsOpenMask & (1 << aUnit));
|
sl@0
|
154 |
}
|
sl@0
|
155 |
|
sl@0
|
156 |
/**
|
sl@0
|
157 |
Attempt to change the state of the unit open state for a particular unit.
|
sl@0
|
158 |
@param aUnit The unit number to be set to open or closed state.
|
sl@0
|
159 |
@param aIsOpen The required new state for the unit; either ETrue to set the state
|
sl@0
|
160 |
to open or EFalse to set the state to closed.
|
sl@0
|
161 |
@return KErrNone if the state was updated successfully, otherwise KErrInUse if an attempt
|
sl@0
|
162 |
was made to set the unit status to open while it is already open.
|
sl@0
|
163 |
*/
|
sl@0
|
164 |
TInt DTemplateCameraScPddFactory::SetUnitOpen(TInt aUnit, TBool aIsOpen)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
// Wait until it is safe to access the unit state mask
|
sl@0
|
167 |
NKern::FMWait(&iUnitInfoMutex);
|
sl@0
|
168 |
|
sl@0
|
169 |
// Fail a request to open a unit that is already open
|
sl@0
|
170 |
if (aIsOpen && IsUnitOpen(aUnit))
|
sl@0
|
171 |
{
|
sl@0
|
172 |
__KTRACE_CAM(Kern::Printf("+ DTemplateCameraScPddFactory::SetUnitOpen() => Unit %d is already in use", aUnit));
|
sl@0
|
173 |
|
sl@0
|
174 |
// Release the unit state mask mutex
|
sl@0
|
175 |
NKern::FMSignal(&iUnitInfoMutex);
|
sl@0
|
176 |
|
sl@0
|
177 |
return KErrInUse;
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
// Set or clear the unit's open status bit as required
|
sl@0
|
181 |
if (aIsOpen)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
iUnitsOpenMask |= (1 << aUnit);
|
sl@0
|
184 |
}
|
sl@0
|
185 |
else
|
sl@0
|
186 |
{
|
sl@0
|
187 |
iUnitsOpenMask &= ~(1 << aUnit);
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
// Release the unit state mask mutex
|
sl@0
|
191 |
NKern::FMSignal(&iUnitInfoMutex);
|
sl@0
|
192 |
|
sl@0
|
193 |
return KErrNone;
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
/**
|
sl@0
|
197 |
Constructor for the shared chunk camera PDD class.
|
sl@0
|
198 |
*/
|
sl@0
|
199 |
DTemplateCameraScPdd::DTemplateCameraScPdd()
|
sl@0
|
200 |
{
|
sl@0
|
201 |
// Set the unit number to -1 to indicate that this channel has never been registered
|
sl@0
|
202 |
// with the PDD factory
|
sl@0
|
203 |
iUnit = -1;
|
sl@0
|
204 |
|
sl@0
|
205 |
// The channel has been created but not yet configured */
|
sl@0
|
206 |
iState = EUnconfigured;
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
/**
|
sl@0
|
210 |
Destructor for the shared chunk camera PDD class. This is called in the context of the client thread
|
sl@0
|
211 |
once an 'ECloseMsg' message has been sent to the device driver DFC thread.
|
sl@0
|
212 |
*/
|
sl@0
|
213 |
DTemplateCameraScPdd::~DTemplateCameraScPdd()
|
sl@0
|
214 |
{
|
sl@0
|
215 |
delete [] iCapsBuffer;
|
sl@0
|
216 |
delete iSensor;
|
sl@0
|
217 |
|
sl@0
|
218 |
// Indicate that a physical channel is no longer open on this unit
|
sl@0
|
219 |
if (iUnit >= 0)
|
sl@0
|
220 |
{
|
sl@0
|
221 |
iPhysicalDevice->SetUnitOpen(iUnit, EFalse);
|
sl@0
|
222 |
}
|
sl@0
|
223 |
}
|
sl@0
|
224 |
|
sl@0
|
225 |
/**
|
sl@0
|
226 |
Second stage constructor for the H4 camera PDD.
|
sl@0
|
227 |
@param aPhysicalDevice A pointer to the factory class that is creating this PDD
|
sl@0
|
228 |
@param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate().
|
sl@0
|
229 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
230 |
*/
|
sl@0
|
231 |
TInt DTemplateCameraScPdd::DoCreate(DTemplateCameraScPddFactory* aPhysicalDevice, TInt aUnit)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::DoCreate()"));
|
sl@0
|
234 |
|
sl@0
|
235 |
TInt r;
|
sl@0
|
236 |
|
sl@0
|
237 |
iPhysicalDevice = aPhysicalDevice;
|
sl@0
|
238 |
|
sl@0
|
239 |
// Check that a physical channel hasn't already been opened on this unit
|
sl@0
|
240 |
if ((r = iPhysicalDevice->SetUnitOpen(aUnit, ETrue)) == KErrNone)
|
sl@0
|
241 |
{
|
sl@0
|
242 |
iUnit = aUnit;
|
sl@0
|
243 |
|
sl@0
|
244 |
// Create an abstracted sensor interface
|
sl@0
|
245 |
if ((iSensor = new DTemplateSensorIf(*this, DfcQ(aUnit))) != NULL)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
if ((r = iSensor->DoCreate()) == KErrNone)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
// Setup the capabilities of this device for later reference
|
sl@0
|
250 |
if ((r = iSensor->GetCaps(iCaps)) > 0)
|
sl@0
|
251 |
{
|
sl@0
|
252 |
// And save the size as returned from the sensor
|
sl@0
|
253 |
iCapsSize = r;
|
sl@0
|
254 |
|
sl@0
|
255 |
// Although iCaps now points to a TCameraCapsV02 structure, it is actually a variable
|
sl@0
|
256 |
// sized structure that was allocated as an array of TUint8 so save it to a TUint8
|
sl@0
|
257 |
// ptr so that it can be deleted properly
|
sl@0
|
258 |
iCapsBuffer = (TUint8*) iCaps;
|
sl@0
|
259 |
|
sl@0
|
260 |
// Enable the clocks needed by the camera subsystem and power up the sensor
|
sl@0
|
261 |
r = iSensor->RequestPower();
|
sl@0
|
262 |
|
sl@0
|
263 |
// Some sensors power themselves up automatically in their DoCreate() function,
|
sl@0
|
264 |
// so take this into account here
|
sl@0
|
265 |
if (r == KErrAlreadyExists)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
r = KErrNone;
|
sl@0
|
268 |
}
|
sl@0
|
269 |
}
|
sl@0
|
270 |
}
|
sl@0
|
271 |
}
|
sl@0
|
272 |
else
|
sl@0
|
273 |
{
|
sl@0
|
274 |
r = KErrNoMemory;
|
sl@0
|
275 |
}
|
sl@0
|
276 |
}
|
sl@0
|
277 |
|
sl@0
|
278 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::DoCreate() => Returning %d", r));
|
sl@0
|
279 |
|
sl@0
|
280 |
return r;
|
sl@0
|
281 |
}
|
sl@0
|
282 |
|
sl@0
|
283 |
/**
|
sl@0
|
284 |
An appropriate DFC queue to use for processing client requests (that is, those that won't be processed
|
sl@0
|
285 |
in the context of the client thread), and also for processing image completion requests from the sensor
|
sl@0
|
286 |
will have been setup by the PDD factory. Anything needing to run in this same DFC thread can access the
|
sl@0
|
287 |
queue via this function.
|
sl@0
|
288 |
@param aUnit The unit number for which to get the DFC queue.
|
sl@0
|
289 |
@return The DFC queue to be used.
|
sl@0
|
290 |
*/
|
sl@0
|
291 |
TDfcQue* DTemplateCameraScPdd::DfcQ(TInt /*aUnit*/)
|
sl@0
|
292 |
{
|
sl@0
|
293 |
return iPhysicalDevice->iDfcQ;
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
/**
|
sl@0
|
297 |
Called by the LDD in order to query the capabilities of the PDD.
|
sl@0
|
298 |
@param aCapsBuf A reference to a descriptor owned by the LDD, containing a TCameraCapsV02 structure
|
sl@0
|
299 |
for the capabilities.
|
sl@0
|
300 |
*/
|
sl@0
|
301 |
void DTemplateCameraScPdd::Caps(TDes8& aCapsBuf) const
|
sl@0
|
302 |
{
|
sl@0
|
303 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::Caps()"));
|
sl@0
|
304 |
|
sl@0
|
305 |
// The iCaps structure will already have been created by a call to iSensor->SetCaps() in DoCreate().
|
sl@0
|
306 |
// Simply copy it into the supplied TPckgBuf, taking into account the fact that the TCameraCapsV02
|
sl@0
|
307 |
// buffer is of a variable size *and* may be smaller or larger than the iCaps structure
|
sl@0
|
308 |
TPtrC8 ptr((const TUint8*) iCaps, iCapsSize);
|
sl@0
|
309 |
aCapsBuf.FillZ(aCapsBuf.MaxLength());
|
sl@0
|
310 |
aCapsBuf = ptr.Left(Min(ptr.Length(), aCapsBuf.MaxLength()));
|
sl@0
|
311 |
|
sl@0
|
312 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::Caps()"));
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
/**
|
sl@0
|
316 |
Called by the LDD to setup a new image configuration, including such things as image size, framerate
|
sl@0
|
317 |
and pixel format.
|
sl@0
|
318 |
@param aConfigBuf A reference to a TPckgBuf containing a TCameraConfigV02 configuration structure.
|
sl@0
|
319 |
@return KErrNone if successful, otherwise one of the system wide error codes.
|
sl@0
|
320 |
*/
|
sl@0
|
321 |
TInt DTemplateCameraScPdd::SetConfig(const TDesC8& aConfigBuf)
|
sl@0
|
322 |
{
|
sl@0
|
323 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::SetConfig()"));
|
sl@0
|
324 |
|
sl@0
|
325 |
TInt r;
|
sl@0
|
326 |
|
sl@0
|
327 |
// It is only legal to call this if image capture is not already underway, so check for this
|
sl@0
|
328 |
// before doing anything
|
sl@0
|
329 |
if (iState <= EConfigured)
|
sl@0
|
330 |
{
|
sl@0
|
331 |
// Read the new configuration from the LDD into a local copy of the configuration structure,
|
sl@0
|
332 |
// taking into account for compatibility that the TPckgBuf may be smaller or larger than the
|
sl@0
|
333 |
// TCameraConfigV02 structure
|
sl@0
|
334 |
TCameraConfigV02 config;
|
sl@0
|
335 |
TPtr8 ptr((TUint8*) &config, sizeof(config));
|
sl@0
|
336 |
Kern::InfoCopy(ptr, aConfigBuf);
|
sl@0
|
337 |
|
sl@0
|
338 |
// Save the new configuration for later and let the sensor also know about it
|
sl@0
|
339 |
iConfig = config;
|
sl@0
|
340 |
iSensor->SetConfig(config);
|
sl@0
|
341 |
|
sl@0
|
342 |
// Signal success and set the channel to the configured state
|
sl@0
|
343 |
r = KErrNone;
|
sl@0
|
344 |
iState = EConfigured;
|
sl@0
|
345 |
}
|
sl@0
|
346 |
else
|
sl@0
|
347 |
{
|
sl@0
|
348 |
r = KErrInUse;
|
sl@0
|
349 |
}
|
sl@0
|
350 |
|
sl@0
|
351 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::SetConfig() => Returning %d", r));
|
sl@0
|
352 |
|
sl@0
|
353 |
return r;
|
sl@0
|
354 |
}
|
sl@0
|
355 |
|
sl@0
|
356 |
/**
|
sl@0
|
357 |
Begins capture into the address pointed to by aLinAddr and aPhysAddr. Both of these addresses point to
|
sl@0
|
358 |
the same buffer; The address used by the sensor is hardware dependent.
|
sl@0
|
359 |
@param aCaptureMode Whether to capture in video, viewfinder or single image mode.
|
sl@0
|
360 |
@param aLinAddr The virtual address of the buffer into which to capture the image.
|
sl@0
|
361 |
@param aPhysAddr The physical address of the buffer into which to capture the image.
|
sl@0
|
362 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
363 |
@pre SetConfig() must first have been called.
|
sl@0
|
364 |
*/
|
sl@0
|
365 |
TInt DTemplateCameraScPdd::Start(TDevCamCaptureMode aCaptureMode, TLinAddr aLinAddr, TPhysAddr aPhysAddr)
|
sl@0
|
366 |
{
|
sl@0
|
367 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::Start() => Configuring sensor for %d x %d capture", iConfig.iFrameSize.iWidth, iConfig.iFrameSize.iHeight));
|
sl@0
|
368 |
|
sl@0
|
369 |
// Ensure the precondition is met
|
sl@0
|
370 |
__ASSERT_DEBUG((iState == EConfigured), Kern::Fault("camerasc", ENotConfigured));
|
sl@0
|
371 |
|
sl@0
|
372 |
// Save the capture mode for use when we call back into the LDD with the captured image
|
sl@0
|
373 |
iCaptureMode = aCaptureMode;
|
sl@0
|
374 |
|
sl@0
|
375 |
// And start the sensor running
|
sl@0
|
376 |
TInt r = iSensor->Start(aCaptureMode, aLinAddr, aPhysAddr);
|
sl@0
|
377 |
|
sl@0
|
378 |
// If everything was ok, set the channel to the capturing state
|
sl@0
|
379 |
if (r == KErrNone)
|
sl@0
|
380 |
{
|
sl@0
|
381 |
iState = ECapturing;
|
sl@0
|
382 |
}
|
sl@0
|
383 |
|
sl@0
|
384 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::Start() => Returning %d", r));
|
sl@0
|
385 |
|
sl@0
|
386 |
return r;
|
sl@0
|
387 |
}
|
sl@0
|
388 |
|
sl@0
|
389 |
/**
|
sl@0
|
390 |
Sets the address of the buffer info which the next image will be captured. Called by the LDD for successive
|
sl@0
|
391 |
images that are requested after the initial call to Start().
|
sl@0
|
392 |
@param aLinAddr The virtual address of the buffer into which to capture the image.
|
sl@0
|
393 |
@param aPhysAddr The physical address of the buffer into which to capture the image.
|
sl@0
|
394 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
395 |
*/
|
sl@0
|
396 |
TInt DTemplateCameraScPdd::CaptureNextImage(TLinAddr aLinAddr, TPhysAddr aPhysAddr)
|
sl@0
|
397 |
{
|
sl@0
|
398 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::CaptureNextImage()"));
|
sl@0
|
399 |
|
sl@0
|
400 |
// Pass the call directly to the sensor abstraction
|
sl@0
|
401 |
TInt r = iSensor->CaptureNextImage(aLinAddr, aPhysAddr);
|
sl@0
|
402 |
|
sl@0
|
403 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::CaptureNextImage()=> Returning %d", r));
|
sl@0
|
404 |
|
sl@0
|
405 |
return(r);
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
/**
|
sl@0
|
409 |
Stops any image capturing that is currently underway. It is safe to call this without having called Start().
|
sl@0
|
410 |
@return KErrNone if successful, otherwise one of the other system wide error codes.
|
sl@0
|
411 |
*/
|
sl@0
|
412 |
TInt DTemplateCameraScPdd::Stop()
|
sl@0
|
413 |
{
|
sl@0
|
414 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::Stop()"));
|
sl@0
|
415 |
|
sl@0
|
416 |
// Pass the call directly to the sensor abstraction
|
sl@0
|
417 |
iSensor->Stop();
|
sl@0
|
418 |
|
sl@0
|
419 |
// Det the channel back to the configured state as it is now safe to call Start() again
|
sl@0
|
420 |
iState = EConfigured;
|
sl@0
|
421 |
|
sl@0
|
422 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::Stop()"));
|
sl@0
|
423 |
|
sl@0
|
424 |
return KErrNone;
|
sl@0
|
425 |
}
|
sl@0
|
426 |
|
sl@0
|
427 |
/**
|
sl@0
|
428 |
Power down the camera device. This is called by the LDD when the driver channel is being closed or
|
sl@0
|
429 |
when the system is being powered down. This is always called in the context of the DFC thread.
|
sl@0
|
430 |
*/
|
sl@0
|
431 |
void DTemplateCameraScPdd::PowerDown()
|
sl@0
|
432 |
{
|
sl@0
|
433 |
|
sl@0
|
434 |
#ifdef _DEBUG
|
sl@0
|
435 |
|
sl@0
|
436 |
// Power off the camera
|
sl@0
|
437 |
TInt r = iSensor->RelinquishPower();
|
sl@0
|
438 |
|
sl@0
|
439 |
// Not being able to power down indicates a serious programming error
|
sl@0
|
440 |
__ASSERT_DEBUG((r == KErrNone), Kern::Fault("camerasc", ECannotPowerDown));
|
sl@0
|
441 |
|
sl@0
|
442 |
#else // ! _DEBUG
|
sl@0
|
443 |
|
sl@0
|
444 |
// Power off the camera
|
sl@0
|
445 |
iSensor->RelinquishPower();
|
sl@0
|
446 |
|
sl@0
|
447 |
#endif // ! _DEBUG
|
sl@0
|
448 |
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
/**
|
sl@0
|
452 |
Return the shared chunk creation information to be used by this device.
|
sl@0
|
453 |
@param aChunkCreateInfo A structure to be filled with the settings required for this device.
|
sl@0
|
454 |
*/
|
sl@0
|
455 |
void DTemplateCameraScPdd::GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo)
|
sl@0
|
456 |
{
|
sl@0
|
457 |
// Can be opened by any number of user side processes
|
sl@0
|
458 |
aChunkCreateInfo.iType = TChunkCreateInfo::ESharedKernelMultiple;
|
sl@0
|
459 |
// Use both L1 and L2 cache if available. LDD will take care of pre and post DMA cache handling
|
sl@0
|
460 |
#ifdef __WINS__
|
sl@0
|
461 |
aChunkCreateInfo.iMapAttr = 0xFF000;
|
sl@0
|
462 |
#else
|
sl@0
|
463 |
aChunkCreateInfo.iMapAttr = EMapAttrCachedMax;
|
sl@0
|
464 |
#endif
|
sl@0
|
465 |
// Chunk owns the memory which will be freed when the chunk is destroyed
|
sl@0
|
466 |
aChunkCreateInfo.iOwnsMemory = ETrue;
|
sl@0
|
467 |
// Don't queue the chunk's destruction on an DFC
|
sl@0
|
468 |
aChunkCreateInfo.iDestroyedDfc = NULL;
|
sl@0
|
469 |
}
|
sl@0
|
470 |
|
sl@0
|
471 |
/**
|
sl@0
|
472 |
Returns the size of the variable sized capabilities structure in bytes. The buffer passed into
|
sl@0
|
473 |
DTemplateCameraScPdd::GetCaps() must be at least this large to hold the fixed portion of the TCameraCapsV02
|
sl@0
|
474 |
structure, as well as the array of SDevCamPixelFormat structures that follows it.
|
sl@0
|
475 |
@return The size in bytes of the variable sized capabilities structure.
|
sl@0
|
476 |
*/
|
sl@0
|
477 |
TInt DTemplateCameraScPdd::CapsSize()
|
sl@0
|
478 |
{
|
sl@0
|
479 |
return iCapsSize;
|
sl@0
|
480 |
}
|
sl@0
|
481 |
|
sl@0
|
482 |
/**
|
sl@0
|
483 |
Obtains information regarding the frame sizes and frame rates supported for a given combination of capture mode
|
sl@0
|
484 |
and pixel format.
|
sl@0
|
485 |
@param aCaptureMode The capture mode for which to obtain the information.
|
sl@0
|
486 |
@param aUidPixelFormat The pixel format for which to obtain the information.
|
sl@0
|
487 |
@param aFrameSizeCapsBuf A reference to an array of packaged SDevCamFrameSize structures, owned by the LDD, into
|
sl@0
|
488 |
which to place the information.
|
sl@0
|
489 |
@@return KErrNone if successful, else one of the other system wide error codes.
|
sl@0
|
490 |
*/
|
sl@0
|
491 |
TInt DTemplateCameraScPdd::FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf)
|
sl@0
|
492 |
{
|
sl@0
|
493 |
return iSensor->FrameSizeCaps(aCaptureMode, aUidPixelFormat, aFrameSizeCapsBuf);
|
sl@0
|
494 |
}
|
sl@0
|
495 |
|
sl@0
|
496 |
/**
|
sl@0
|
497 |
Called by the sensor abstraction when an image is available.
|
sl@0
|
498 |
@param aResult KErrNone if successful, otherwise one of the system wide error codes.
|
sl@0
|
499 |
@param aLinAddr The virtual address of the buffer into which to capture the image.
|
sl@0
|
500 |
@param aPhysAddr The physical address of the buffer into which to capture the image.
|
sl@0
|
501 |
*/
|
sl@0
|
502 |
TInt DTemplateCameraScPdd::NotifyImageCaptureEvent(TInt aResult, TLinAddr& aLinAddr, TPhysAddr& aPhysAddr)
|
sl@0
|
503 |
{
|
sl@0
|
504 |
__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::NotifyImageCaptureEvent() => aResult = %d", aResult));
|
sl@0
|
505 |
|
sl@0
|
506 |
// Inform the LDD that a new image has been received
|
sl@0
|
507 |
TInt r = iLdd->ImageCaptureCallback(iCaptureMode, aResult, &aLinAddr, &aPhysAddr);
|
sl@0
|
508 |
|
sl@0
|
509 |
// If the LDD has returned KErrAbort then something has gone wrong, and if it has returned KErrNotReady
|
sl@0
|
510 |
// then it has no more frames available, so call Stop()
|
sl@0
|
511 |
if (r != KErrNone)
|
sl@0
|
512 |
{
|
sl@0
|
513 |
Stop();
|
sl@0
|
514 |
}
|
sl@0
|
515 |
|
sl@0
|
516 |
__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::NotifyImageCaptureEvent() => Returning %d", r));
|
sl@0
|
517 |
|
sl@0
|
518 |
return r;
|
sl@0
|
519 |
}
|
sl@0
|
520 |
|
sl@0
|
521 |
TInt DTemplateCameraScPdd::SetBrightness(TUint /*aBrightness*/)
|
sl@0
|
522 |
{
|
sl@0
|
523 |
return KErrNone;
|
sl@0
|
524 |
}
|
sl@0
|
525 |
|
sl@0
|
526 |
TInt DTemplateCameraScPdd::SetContrast(TUint /*aContrast*/)
|
sl@0
|
527 |
{
|
sl@0
|
528 |
return KErrNone;
|
sl@0
|
529 |
}
|
sl@0
|
530 |
|
sl@0
|
531 |
TInt DTemplateCameraScPdd::SetColorEffect(TUint /*aColorEffect*/)
|
sl@0
|
532 |
{
|
sl@0
|
533 |
return KErrNone;
|
sl@0
|
534 |
}
|
sl@0
|
535 |
|