os/kernelhwsrv/kerneltest/e32test/examples/convert1/convert1_dev.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-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
// Shared Chunks in its implementation.
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file Kernel side interfaces to example data converter device driver which uses
sl@0
    20
 @publishedPartner
sl@0
    21
 @prototype 9.1
sl@0
    22
*/
sl@0
    23
sl@0
    24
#ifndef __CONVERT1_DEV_H__
sl@0
    25
#define __CONVERT1_DEV_H__
sl@0
    26
sl@0
    27
/**
sl@0
    28
  Logical Device (factory class) for 'Convert1'
sl@0
    29
*/
sl@0
    30
class DConvert1Factory : public DLogicalDevice
sl@0
    31
	{
sl@0
    32
public:
sl@0
    33
	DConvert1Factory();
sl@0
    34
	~DConvert1Factory();
sl@0
    35
	//	Inherited from DLogicalDevice
sl@0
    36
	virtual TInt Install();
sl@0
    37
	virtual void GetCaps(TDes8& aDes) const;
sl@0
    38
	virtual TInt Create(DLogicalChannelBase*& aChannel);
sl@0
    39
	// Resource handling methods
sl@0
    40
	TInt ClaimResource(TInt& aResourceId);
sl@0
    41
	void ReleaseResource(TInt aResourceId);
sl@0
    42
private:
sl@0
    43
	NFastMutex iResourceMutex;	/**< Mutex to protect access to iResourceFlags */
sl@0
    44
	TUint iResourceFlags;		/**< Bitfield of flags representing device resources available for use.
sl@0
    45
								     I.e. iResourceFlags&(1<<resourceId) is true if resource 'resourceId' is free. */
sl@0
    46
	};
sl@0
    47
sl@0
    48
/**
sl@0
    49
  Class representing a buffer of data
sl@0
    50
*/
sl@0
    51
class DChunkBuffer
sl@0
    52
	{
sl@0
    53
public:
sl@0
    54
	DChunkBuffer();
sl@0
    55
	~DChunkBuffer();
sl@0
    56
	TInt Create(TInt aSize);
sl@0
    57
	void Destroy();
sl@0
    58
	TInt SetMaxSize(TInt aMaxSize);
sl@0
    59
	TInt Open(TAny* aAddress, TInt aSize, TBool aWrite=EFalse);
sl@0
    60
	TInt Open(TInt aChunkHandle, TInt aOffset, TInt aSize, TBool aWrite=EFalse);
sl@0
    61
	void Close();
sl@0
    62
	TInt Copy(TAny* aAddress, TInt aSize);
sl@0
    63
private:
sl@0
    64
	TInt SetPhysicalAddresses(TInt aSize);
sl@0
    65
public:
sl@0
    66
	DChunk* iChunk;				/**< The chunk which contains the buffer */
sl@0
    67
	TInt iChunkOffset;			/**< Offset, in bytes, of buffer start within the chunk */
sl@0
    68
	TInt iMaxSize;				/**< Maximum size of buffer n bytes */
sl@0
    69
	TLinAddr iChunkBase;		/**< Linear address in kernel process for the start of the chunk  */
sl@0
    70
	TUint32 iChunkMapAttr;		/**< MMU mapping attributes for chunk */
sl@0
    71
	TPhysAddr iPhysicalAddress;	/**< Physical address of buffer. KPhysAddrInvalid if buffer not physically contiguous */
sl@0
    72
	TPhysAddr* iPhysicalPages;	/**< List of physical addresses for buffer pages. 0 if buffer is physically contiguous */
sl@0
    73
	};
sl@0
    74
sl@0
    75
/**
sl@0
    76
  Logical Channel class for 'Convert1'
sl@0
    77
*/
sl@0
    78
class DConvert1Channel : public DLogicalChannelBase
sl@0
    79
	{
sl@0
    80
public:
sl@0
    81
	DConvert1Channel(DConvert1Factory* aFactory);
sl@0
    82
	virtual ~DConvert1Channel();
sl@0
    83
	//	Inherited from DObject
sl@0
    84
	virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
sl@0
    85
	// Inherited from DLogicalChannelBase
sl@0
    86
	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
sl@0
    87
	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
sl@0
    88
private:
sl@0
    89
	// Panic reasons
sl@0
    90
	enum TPanic
sl@0
    91
		{
sl@0
    92
		ERequestFromWrongThread=1,
sl@0
    93
		ERequestAlreadyPending
sl@0
    94
		};
sl@0
    95
	// Implementation for the differnt kinds of messages sent through RBusLogicalChannel
sl@0
    96
	TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
sl@0
    97
	TInt DoRequest(TInt aNotReqNo, TAny* a1, TAny* a2);
sl@0
    98
	TInt DoCancel(TUint aMask);
sl@0
    99
	// Methods for configuration
sl@0
   100
	TInt GetConfig(TDes8* aConfigBuf);
sl@0
   101
	TInt SetConfig(const TDesC8* aConfigBuf,RConvert1::TBufferInfo* aBufferInfo);
sl@0
   102
	// Methods for capturing images
sl@0
   103
	void ConvertDes(const TDesC8* aSrc,TRequestStatus* aRequestStatus);
sl@0
   104
	void ConvertChunk(const RConvert1::TConvertArgs* aSrcArgs,TRequestStatus* aRequestStatus);
sl@0
   105
	void ConvertInChunk(TInt aSize,TRequestStatus* aRequestStatus);
sl@0
   106
	void ConvertCancel();
sl@0
   107
	void ConvertComplete(TInt aResult);
sl@0
   108
	static void ConvertDfcTrampoline(TAny* aSelf);
sl@0
   109
	void ConvertDfc();
sl@0
   110
	// Methods which program the convert hardware
sl@0
   111
	void DoConvertStart(TInt aOffset,TInt aSize);
sl@0
   112
	void DoConvertCancel();
sl@0
   113
private:
sl@0
   114
	DConvert1Factory* iFactory;	/**< Pointer to device driver factory object */
sl@0
   115
	TInt iResourceId;			/**< The id of the device hardware resource owned by this channel */
sl@0
   116
sl@0
   117
	NFastMutex iConvertMutex;	/**< Mutex to protect access to driver state */
sl@0
   118
sl@0
   119
	DChunkBuffer* iSource;		/**< Buffer containing the converter's input data */
sl@0
   120
	DChunkBuffer iInBuffer;		/**< Buffer into which client supplied data can be copied */
sl@0
   121
	DChunkBuffer iOutBuffer;	/**< Buffer containing the converter's output data */
sl@0
   122
	DChunkBuffer iClientBuffer;	/**< Buffer representing client supplied chunk data */
sl@0
   123
sl@0
   124
	DThread* iClient;			/**< The single client thread for this channel */
sl@0
   125
	TRequestStatus* iConvertRequestStatus;	/**< The request status for client ConvertImage request */
sl@0
   126
sl@0
   127
	RConvert1::TConfig iConfig;	/**< The driver configuration information */
sl@0
   128
sl@0
   129
	NTimer iConvertTimer;		/**< Timer used to emulate image capture hardware */
sl@0
   130
	};
sl@0
   131
sl@0
   132
#endif
sl@0
   133