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 // Shared Chunks in its implementation.
19 @file Kernel side interfaces to example data converter device driver which uses
24 #ifndef __CONVERT1_DEV_H__
25 #define __CONVERT1_DEV_H__
28 Logical Device (factory class) for 'Convert1'
30 class DConvert1Factory : public DLogicalDevice
35 // Inherited from DLogicalDevice
36 virtual TInt Install();
37 virtual void GetCaps(TDes8& aDes) const;
38 virtual TInt Create(DLogicalChannelBase*& aChannel);
39 // Resource handling methods
40 TInt ClaimResource(TInt& aResourceId);
41 void ReleaseResource(TInt aResourceId);
43 NFastMutex iResourceMutex; /**< Mutex to protect access to iResourceFlags */
44 TUint iResourceFlags; /**< Bitfield of flags representing device resources available for use.
45 I.e. iResourceFlags&(1<<resourceId) is true if resource 'resourceId' is free. */
49 Class representing a buffer of data
56 TInt Create(TInt aSize);
58 TInt SetMaxSize(TInt aMaxSize);
59 TInt Open(TAny* aAddress, TInt aSize, TBool aWrite=EFalse);
60 TInt Open(TInt aChunkHandle, TInt aOffset, TInt aSize, TBool aWrite=EFalse);
62 TInt Copy(TAny* aAddress, TInt aSize);
64 TInt SetPhysicalAddresses(TInt aSize);
66 DChunk* iChunk; /**< The chunk which contains the buffer */
67 TInt iChunkOffset; /**< Offset, in bytes, of buffer start within the chunk */
68 TInt iMaxSize; /**< Maximum size of buffer n bytes */
69 TLinAddr iChunkBase; /**< Linear address in kernel process for the start of the chunk */
70 TUint32 iChunkMapAttr; /**< MMU mapping attributes for chunk */
71 TPhysAddr iPhysicalAddress; /**< Physical address of buffer. KPhysAddrInvalid if buffer not physically contiguous */
72 TPhysAddr* iPhysicalPages; /**< List of physical addresses for buffer pages. 0 if buffer is physically contiguous */
76 Logical Channel class for 'Convert1'
78 class DConvert1Channel : public DLogicalChannelBase
81 DConvert1Channel(DConvert1Factory* aFactory);
82 virtual ~DConvert1Channel();
83 // Inherited from DObject
84 virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
85 // Inherited from DLogicalChannelBase
86 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
87 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
92 ERequestFromWrongThread=1,
93 ERequestAlreadyPending
95 // Implementation for the differnt kinds of messages sent through RBusLogicalChannel
96 TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
97 TInt DoRequest(TInt aNotReqNo, TAny* a1, TAny* a2);
98 TInt DoCancel(TUint aMask);
99 // Methods for configuration
100 TInt GetConfig(TDes8* aConfigBuf);
101 TInt SetConfig(const TDesC8* aConfigBuf,RConvert1::TBufferInfo* aBufferInfo);
102 // Methods for capturing images
103 void ConvertDes(const TDesC8* aSrc,TRequestStatus* aRequestStatus);
104 void ConvertChunk(const RConvert1::TConvertArgs* aSrcArgs,TRequestStatus* aRequestStatus);
105 void ConvertInChunk(TInt aSize,TRequestStatus* aRequestStatus);
106 void ConvertCancel();
107 void ConvertComplete(TInt aResult);
108 static void ConvertDfcTrampoline(TAny* aSelf);
110 // Methods which program the convert hardware
111 void DoConvertStart(TInt aOffset,TInt aSize);
112 void DoConvertCancel();
114 DConvert1Factory* iFactory; /**< Pointer to device driver factory object */
115 TInt iResourceId; /**< The id of the device hardware resource owned by this channel */
117 NFastMutex iConvertMutex; /**< Mutex to protect access to driver state */
119 DChunkBuffer* iSource; /**< Buffer containing the converter's input data */
120 DChunkBuffer iInBuffer; /**< Buffer into which client supplied data can be copied */
121 DChunkBuffer iOutBuffer; /**< Buffer containing the converter's output data */
122 DChunkBuffer iClientBuffer; /**< Buffer representing client supplied chunk data */
124 DThread* iClient; /**< The single client thread for this channel */
125 TRequestStatus* iConvertRequestStatus; /**< The request status for client ConvertImage request */
127 RConvert1::TConfig iConfig; /**< The driver configuration information */
129 NTimer iConvertTimer; /**< Timer used to emulate image capture hardware */