|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // its implementation. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file Kernel side interfaces to example camera device driver which uses Shared Chunks in |
|
20 @publishedPartner |
|
21 @prototype 9.1 |
|
22 */ |
|
23 |
|
24 #ifndef __CAMERA1_DEV_H__ |
|
25 #define __CAMERA1_DEV_H__ |
|
26 |
|
27 /** |
|
28 Logical Device (factory class) for 'Camera1' |
|
29 */ |
|
30 class DCamera1Factory : public DLogicalDevice |
|
31 { |
|
32 public: |
|
33 DCamera1Factory(); |
|
34 ~DCamera1Factory(); |
|
35 // Inherited from DLogicalDevice |
|
36 virtual TInt Install(); |
|
37 virtual void GetCaps(TDes8& aDes) const; |
|
38 virtual TInt Create(DLogicalChannelBase*& aChannel); |
|
39 }; |
|
40 |
|
41 /** |
|
42 Class representing a single image buffer |
|
43 */ |
|
44 class DImageBuffer |
|
45 { |
|
46 public: |
|
47 DImageBuffer(); |
|
48 ~DImageBuffer(); |
|
49 TInt Create(DChunk* aChunk, TInt aOffset, TInt aSize); |
|
50 public: |
|
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 */ |
|
55 }; |
|
56 |
|
57 /** |
|
58 Class representing all of the image buffers |
|
59 */ |
|
60 class DCaptureBuffers : public DBase |
|
61 { |
|
62 public: |
|
63 static DCaptureBuffers* New(TInt aNumBuffers,TInt aBufferSize); |
|
64 void Open(); |
|
65 void Close(); |
|
66 void Reset(); |
|
67 void Purge(DImageBuffer* aBuffer); |
|
68 DImageBuffer* ImageForClient(); |
|
69 DImageBuffer* ImageCaptured(); |
|
70 DImageBuffer* ImageRelease(TInt aChunkOffset); |
|
71 DImageBuffer* InUseImage(TInt aChunkOffset); |
|
72 private: |
|
73 DCaptureBuffers(); |
|
74 ~DCaptureBuffers(); |
|
75 TInt Create(TInt aNumBuffers,TInt aBufferSize); |
|
76 static DImageBuffer* Remove(DImageBuffer** aList); |
|
77 static DImageBuffer* Add(DImageBuffer** aList,DImageBuffer* aBuffer); |
|
78 public: |
|
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 */ |
|
84 // |
|
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 */ |
|
90 private: |
|
91 TInt iAccessCount; /**< Access count for this object */ |
|
92 TAny* iBufferLists; /**< Memory holding lists iFreeBuffers, iCompletedBuffers and iInUseBuffers */ |
|
93 }; |
|
94 |
|
95 /** |
|
96 Logical Channel class for 'Camera1' |
|
97 */ |
|
98 class DCamera1Channel : public DLogicalChannelBase |
|
99 { |
|
100 public: |
|
101 DCamera1Channel(); |
|
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); |
|
106 private: |
|
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 |
|
115 TInt StartCapture(); |
|
116 TInt EndCapture(); |
|
117 void CaptureImage(TRequestStatus* aRequestStatus,TInt aReleaseImage); |
|
118 void CaptureImageCancel(); |
|
119 TInt ImageRelease(TInt aChunkOffset); |
|
120 static void CaptureDfcTrampoline(TAny* aSelf); |
|
121 void CaptureDfc(); |
|
122 void StateChange(TBool aNewState); |
|
123 static void StateChangeDfcTrampoline(TAny* aSelf); |
|
124 void StateChangeDfc(); |
|
125 // Methods which program the camera hardware |
|
126 void DoStartCapture(); |
|
127 void DoEndCapture(); |
|
128 void DoNextCapture(); |
|
129 private: |
|
130 NFastMutex iCaptureMutex; /**< Mutex to protect access to driver state */ |
|
131 |
|
132 DCaptureBuffers* iCaptureBuffers; /**< The image buffers */ |
|
133 |
|
134 TRequestStatus* iCaptureRequestStatus; /**< The request status for client CaptureImage request */ |
|
135 DThread* iCaptureRequestThread; /**< The client thread which issued a CaptureImage request */ |
|
136 |
|
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 */ |
|
142 |
|
143 RCamera1::TConfig iConfig; /**< The driver configuration information */ |
|
144 TBool iCapturing; /**< Flag which is True when image capture is in progress */ |
|
145 |
|
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 */ |
|
149 }; |
|
150 |
|
151 #endif |
|
152 |