Update contrib.
1 // Copyright (c) 2005-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 // its implementation.
19 @file Kernel side interfaces to example camera device driver which uses Shared Chunks in
24 #ifndef __CAMERA1_DEV_H__
25 #define __CAMERA1_DEV_H__
28 Logical Device (factory class) for 'Camera1'
30 class DCamera1Factory : public DLogicalDevice
35 // Inherited from DLogicalDevice
36 virtual TInt Install();
37 virtual void GetCaps(TDes8& aDes) const;
38 virtual TInt Create(DLogicalChannelBase*& aChannel);
42 Class representing a single image buffer
49 TInt Create(DChunk* aChunk, TInt aOffset, TInt aSize);
51 TInt iChunkOffset; /**< Offset, in bytes, of buffer start within the chunk */
52 TInt iSize; /**< Size of buffer n bytes */
53 TPhysAddr iPhysicalAddress; /**< Physical address of buffer. KPhysAddrInvalid if buffer not physically contiguous */
54 TPhysAddr* iPhysicalPages; /**< List of physical addresses for buffer pages. 0 if buffer is physically contiguous */
58 Class representing all of the image buffers
60 class DCaptureBuffers : public DBase
63 static DCaptureBuffers* New(TInt aNumBuffers,TInt aBufferSize);
67 void Purge(DImageBuffer* aBuffer);
68 DImageBuffer* ImageForClient();
69 DImageBuffer* ImageCaptured();
70 DImageBuffer* ImageRelease(TInt aChunkOffset);
71 DImageBuffer* InUseImage(TInt aChunkOffset);
75 TInt Create(TInt aNumBuffers,TInt aBufferSize);
76 static DImageBuffer* Remove(DImageBuffer** aList);
77 static DImageBuffer* Add(DImageBuffer** aList,DImageBuffer* aBuffer);
79 DChunk* iChunk; /**< The chunk which contains the buffers */
80 TLinAddr iChunkBase; /**< Linear address in kernel process for the start of the chunk */
81 TUint32 iChunkMapAttr; /**< MMU mapping attributes for chunk */
82 TInt iNumBuffers; /**< Number of buffers */
83 DImageBuffer* iImageBuffer; /**< Array of iNumBuffers buffer objects */
85 DImageBuffer* iCurrentBuffer; /**< The buffer currently being filled by image capture */
86 DImageBuffer* iNextBuffer; /**< The buffer to use for next image capture */
87 DImageBuffer** iFreeBuffers; /**< NULL terminated list of free buffers */
88 DImageBuffer** iCompletedBuffers; /**< NULL terminated list of buffers containing captured images */
89 DImageBuffer** iInUseBuffers; /**< NULL terminated list of buffers currently being used by client */
91 TInt iAccessCount; /**< Access count for this object */
92 TAny* iBufferLists; /**< Memory holding lists iFreeBuffers, iCompletedBuffers and iInUseBuffers */
96 Logical Channel class for 'Camera1'
98 class DCamera1Channel : public DLogicalChannelBase
102 virtual ~DCamera1Channel();
103 // Inherited from DLogicalChannelBase
104 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
105 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
107 // Implementation for the differnt kinds of messages sent through RBusLogicalChannel
108 TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
109 TInt DoRequest(TInt aNotReqNo, TAny* a1, TAny* a2);
110 TInt DoCancel(TUint aMask);
111 // Methods for configuration
112 TInt GetConfig(TDes8* aConfigBuf);
113 TInt SetConfig(const TDesC8* aConfigBuf);
114 // Methods for capturing images
117 void CaptureImage(TRequestStatus* aRequestStatus,TInt aReleaseImage);
118 void CaptureImageCancel();
119 TInt ImageRelease(TInt aChunkOffset);
120 static void CaptureDfcTrampoline(TAny* aSelf);
122 void StateChange(TBool aNewState);
123 static void StateChangeDfcTrampoline(TAny* aSelf);
124 void StateChangeDfc();
125 // Methods which program the camera hardware
126 void DoStartCapture();
128 void DoNextCapture();
130 NFastMutex iCaptureMutex; /**< Mutex to protect access to driver state */
132 DCaptureBuffers* iCaptureBuffers; /**< The image buffers */
134 TRequestStatus* iCaptureRequestStatus; /**< The request status for client CaptureImage request */
135 DThread* iCaptureRequestThread; /**< The client thread which issued a CaptureImage request */
137 TDfcQue* iDfcQ; /**< The DFC queue used for driver functions */
138 TDfc iStateChangeDfc; /**< DFC queued when Start/EndCapture requests are performed */
139 TBool iNewState; /**< True if state change DFC should start image capture, false to stop capture */
140 DMutex* iStateChangeMutex; /**< Mutex which protect Start/EndCapture requests from reenty */
141 NFastSemaphore iStateChangeSemaphore; /**< Semaphore signaled when state change DFC completes */
143 RCamera1::TConfig iConfig; /**< The driver configuration information */
144 TBool iCapturing; /**< Flag which is True when image capture is in progress */
146 TInt iCaptureCounter; /**< Frame counter incremented on each image captured */
147 NTimer iCaptureTimer; /**< Timer used to emulate image capture hardware */
148 TInt iCaptureRateTicks; /**< Number of timer ticks for iCaptureTimer */