os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/inc/soundsc_plat.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/inc/soundsc_plat.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,204 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// template\template_variant\inc\soundsc_plat.h
    1.18 +// Definitions for the Template shared chunk sound physical device driver (PDD).
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @internalTechnology
    1.25 + @prototype
    1.26 +*/
    1.27 +
    1.28 +#ifndef __SOUNDSC_PLAT_H__
    1.29 +#define __SOUNDSC_PLAT_H__
    1.30 +
    1.31 +#include <drivers/dma.h>
    1.32 +#include <drivers/soundsc.h>
    1.33 +
    1.34 +//#define __KTRACE_SND(s) s;
    1.35 +#define __KTRACE_SND(s)
    1.36 +
    1.37 +// TO DO: (mandatory)
    1.38 +// Fill in the maximum number of requests that may be outstanding on the playback and record DMA channels for this device.
    1.39 +const TInt KTemplateMaxTxDmaRequests=2;
    1.40 +const TInt KTemplateMaxRxDmaRequests=2;
    1.41 +
    1.42 +// TO DO: (mandatory)
    1.43 +// Fill in the maximum transfer length supported  on the playback and record DMA channels for this device.
    1.44 +const TInt KTemplateMaxTxDmaTransferLen=0;
    1.45 +const TInt KTemplateMaxRxDmaTransferLen=0;
    1.46 +
    1.47 +// Forward declarations
    1.48 +class DTemplateSoundScTxDmaRequest;
    1.49 +class DTemplateSoundScRxDmaRequest;
    1.50 +
    1.51 +/**
    1.52 +Factory class instantiated from ordinal 0.
    1.53 +The Template physical device for the shared chunk sound driver used to create the DSoundScPdd-derived channel objects.
    1.54 +*/
    1.55 +class DTemplateSoundScPddFactory : public DPhysicalDevice
    1.56 +	{
    1.57 +public:
    1.58 +	DTemplateSoundScPddFactory();
    1.59 +	~DTemplateSoundScPddFactory();
    1.60 +	virtual TInt Install();
    1.61 +	virtual void GetCaps(TDes8& aDes) const;
    1.62 +	virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
    1.63 +	virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
    1.64 +private:
    1.65 +	/** The DFC queue (used also by the LDD). */ 
    1.66 +	TDynamicDfcQue* iDfcQ;
    1.67 +	friend class DTemplateSoundScTxPdd;
    1.68 +	friend class DTemplateSoundScRxPdd;	
    1.69 +	};
    1.70 +
    1.71 +/**
    1.72 +The Template physical device driver (PDD) for the playback shared chunk sound driver.
    1.73 +*/
    1.74 +//
    1.75 +// TO DO: (optional)
    1.76 +//
    1.77 +// Add any private functions and data you require
    1.78 +//
    1.79 +class DTemplateSoundScTxPdd : public DSoundScPdd
    1.80 +	{
    1.81 +public:
    1.82 +	DTemplateSoundScTxPdd();
    1.83 +	~DTemplateSoundScTxPdd();
    1.84 +	TInt DoCreate();
    1.85 +
    1.86 +	// Implementations of the pure virtual functions inherited from DSoundScPdd (called by LDD).
    1.87 +	virtual TDfcQue* DfcQ(TInt aUnit);
    1.88 +	virtual void GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo);
    1.89 +	virtual void Caps(TDes8& aCapsBuf) const;
    1.90 +	virtual TInt MaxTransferLen() const;
    1.91 +	virtual TInt SetConfig(const TDesC8& aConfigBuf);
    1.92 +	virtual TInt SetVolume(TInt aVolume);
    1.93 +	virtual TInt StartTransfer();
    1.94 +	virtual TInt TransferData(TUint aTransferID,TLinAddr aLinAddr,TPhysAddr aPhysAddr,TInt aNumBytes);
    1.95 +	virtual void StopTransfer();
    1.96 +	virtual TInt PauseTransfer();
    1.97 +	virtual TInt ResumeTransfer();
    1.98 +	virtual TInt PowerUp();
    1.99 +	virtual void PowerDown();
   1.100 +	virtual TInt CustomConfig(TInt aFunction,TAny* aParam);
   1.101 +	virtual TInt TimeTransferred(TInt64& aTimeTransferred, TInt aStatus);
   1.102 +	void PlayCallback(TUint aTransferID,TInt aTransferResult,TInt aBytesTransferred);
   1.103 +private:
   1.104 +	void SetCaps();
   1.105 +	
   1.106 +private:
   1.107 +	/** A pointer to the PDD factory. */
   1.108 +	DTemplateSoundScPddFactory* iPhysicalDevice;
   1.109 +	/** The capabilities of this device. */
   1.110 +	TSoundFormatsSupportedV02 iCaps;
   1.111 +	/** The playback DMA channel. */
   1.112 +	TDmaChannel* iDmaChannel;
   1.113 +	/** The DMA request structures used for transfers. */ 				
   1.114 +	DTemplateSoundScTxDmaRequest* iDmaRequest[KTemplateMaxTxDmaRequests];
   1.115 +	/** The number of outstanding DMA play requests on the DMA channel. */	
   1.116 +	TInt iPendingPlay;
   1.117 +	/** A flag selecting the next DMA request for transfer. */
   1.118 +	TInt iFlag;
   1.119 +	friend class DTemplateSoundScPddFactory;
   1.120 +	};
   1.121 +	
   1.122 +/**
   1.123 +The Template physical device driver (PDD) for the record shared chunk sound driver.
   1.124 +*/
   1.125 +//
   1.126 +// TO DO: (optional)
   1.127 +//
   1.128 +// Add any private functions and data you require
   1.129 +//
   1.130 +class DTemplateSoundScRxPdd : public DSoundScPdd
   1.131 +	{
   1.132 +public:
   1.133 +	DTemplateSoundScRxPdd();
   1.134 +	~DTemplateSoundScRxPdd();
   1.135 +	TInt DoCreate();
   1.136 +
   1.137 +	// Implementations of the pure virtual functions inherited from DSoundScPdd (called by LDD).
   1.138 +	virtual TDfcQue* DfcQ(TInt aUnit);
   1.139 +	virtual void GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo);
   1.140 +	virtual void Caps(TDes8& aCapsBuf) const;
   1.141 +	virtual TInt MaxTransferLen() const;
   1.142 +	virtual TInt SetConfig(const TDesC8& aConfigBuf);
   1.143 +	virtual TInt SetVolume(TInt aVolume);
   1.144 +	virtual TInt StartTransfer();
   1.145 +	virtual TInt TransferData(TUint aTransferID,TLinAddr aLinAddr,TPhysAddr aPhysAddr,TInt aNumBytes);
   1.146 +	virtual void StopTransfer();
   1.147 +	virtual TInt PauseTransfer();
   1.148 +	virtual TInt ResumeTransfer();
   1.149 +	virtual TInt PowerUp();
   1.150 +	virtual void PowerDown();
   1.151 +	virtual TInt CustomConfig(TInt aFunction,TAny* aParam);
   1.152 +	virtual TInt TimeTransferred(TInt64& aTimeTransferred, TInt aStatus);
   1.153 +	void RecordCallback(TUint aTransferID,TInt aTransferResult,TInt aBytesTransferred);	
   1.154 +private:
   1.155 +	void SetCaps();	
   1.156 +
   1.157 +private:
   1.158 +	/** A pointer to the PDD factory. */
   1.159 +	DTemplateSoundScPddFactory* iPhysicalDevice;
   1.160 +	/** The capabilities of this device. */
   1.161 +	TSoundFormatsSupportedV02 iCaps;
   1.162 +	/** The record DMA channel. */
   1.163 +	TDmaChannel* iDmaChannel;
   1.164 +	/** The DMA request structures used for transfers. */ 				
   1.165 +	DTemplateSoundScRxDmaRequest* iDmaRequest[KTemplateMaxRxDmaRequests];
   1.166 +	/** The number of outstanding DMA record requests on the DMA channel. */	
   1.167 +	TInt iPendingRecord;
   1.168 +	/** A flag selecting the next DMA request for transfer. */
   1.169 +	TInt iFlag;
   1.170 +	friend class DTemplateSoundScPddFactory;
   1.171 +	};	
   1.172 +
   1.173 +/**
   1.174 +Wrapper function for a shared chunk sound driver playback DMA request.
   1.175 +*/
   1.176 +class DTemplateSoundScTxDmaRequest : public DDmaRequest
   1.177 +	{
   1.178 +public:	
   1.179 +	DTemplateSoundScTxDmaRequest(TDmaChannel& aChannel,DTemplateSoundScTxPdd* aPdd,TInt aMaxTransferSize=0);
   1.180 +	static void DmaService(TResult aResult, TAny* aArg);
   1.181 +public:
   1.182 +	/** Pointer back to the PDD. */
   1.183 +	DTemplateSoundScTxPdd* iPdd;
   1.184 +	/** The transfer ID for this DMA request - supplied by the LDD. */
   1.185 +	TUint iTransferID;
   1.186 +	/** The transfer sizes in progress. */
   1.187 +	TUint iTransferSize;
   1.188 +	};
   1.189 +
   1.190 +/**
   1.191 +Wrapper function for a shared chunk sound driver record DMA request.
   1.192 +*/
   1.193 +class DTemplateSoundScRxDmaRequest : public DDmaRequest
   1.194 +	{
   1.195 +public:	
   1.196 +	DTemplateSoundScRxDmaRequest(TDmaChannel& aChannel,DTemplateSoundScRxPdd* aPdd,TInt aMaxTransferSize=0);
   1.197 +	static void DmaService(TResult aResult, TAny* aArg);
   1.198 +public:
   1.199 +	/** Pointer back to the PDD. */
   1.200 +	DTemplateSoundScRxPdd* iPdd;
   1.201 +	/** The transfer ID for this DMA request - supplied by the LDD. */
   1.202 +	TUint iTransferID;
   1.203 +	/** The transfer sizes in progress. */
   1.204 +	TUint iTransferSize;
   1.205 +	};
   1.206 +
   1.207 +#endif /* __SOUNDSC_PLAT_H__ */