bsptemplate/asspandvariant/template_variant/inc/soundsc_plat.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2006-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 // template\template_variant\inc\soundsc_plat.h
       
    15 // Definitions for the Template shared chunk sound physical device driver (PDD).
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22  @prototype
       
    23 */
       
    24 
       
    25 #ifndef __SOUNDSC_PLAT_H__
       
    26 #define __SOUNDSC_PLAT_H__
       
    27 
       
    28 #include <drivers/dma.h>
       
    29 #include <drivers/soundsc.h>
       
    30 
       
    31 //#define __KTRACE_SND(s) s;
       
    32 #define __KTRACE_SND(s)
       
    33 
       
    34 // TO DO: (mandatory)
       
    35 // Fill in the maximum number of requests that may be outstanding on the playback and record DMA channels for this device.
       
    36 const TInt KTemplateMaxTxDmaRequests=2;
       
    37 const TInt KTemplateMaxRxDmaRequests=2;
       
    38 
       
    39 // TO DO: (mandatory)
       
    40 // Fill in the maximum transfer length supported  on the playback and record DMA channels for this device.
       
    41 const TInt KTemplateMaxTxDmaTransferLen=0;
       
    42 const TInt KTemplateMaxRxDmaTransferLen=0;
       
    43 
       
    44 // Forward declarations
       
    45 class DTemplateSoundScTxDmaRequest;
       
    46 class DTemplateSoundScRxDmaRequest;
       
    47 
       
    48 /**
       
    49 Factory class instantiated from ordinal 0.
       
    50 The Template physical device for the shared chunk sound driver used to create the DSoundScPdd-derived channel objects.
       
    51 */
       
    52 class DTemplateSoundScPddFactory : public DPhysicalDevice
       
    53 	{
       
    54 public:
       
    55 	DTemplateSoundScPddFactory();
       
    56 	~DTemplateSoundScPddFactory();
       
    57 	virtual TInt Install();
       
    58 	virtual void GetCaps(TDes8& aDes) const;
       
    59 	virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
       
    60 	virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
       
    61 private:
       
    62 	/** The DFC queue (used also by the LDD). */ 
       
    63 	TDynamicDfcQue* iDfcQ;
       
    64 	friend class DTemplateSoundScTxPdd;
       
    65 	friend class DTemplateSoundScRxPdd;	
       
    66 	};
       
    67 
       
    68 /**
       
    69 The Template physical device driver (PDD) for the playback shared chunk sound driver.
       
    70 */
       
    71 //
       
    72 // TO DO: (optional)
       
    73 //
       
    74 // Add any private functions and data you require
       
    75 //
       
    76 class DTemplateSoundScTxPdd : public DSoundScPdd
       
    77 	{
       
    78 public:
       
    79 	DTemplateSoundScTxPdd();
       
    80 	~DTemplateSoundScTxPdd();
       
    81 	TInt DoCreate();
       
    82 
       
    83 	// Implementations of the pure virtual functions inherited from DSoundScPdd (called by LDD).
       
    84 	virtual TDfcQue* DfcQ(TInt aUnit);
       
    85 	virtual void GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo);
       
    86 	virtual void Caps(TDes8& aCapsBuf) const;
       
    87 	virtual TInt MaxTransferLen() const;
       
    88 	virtual TInt SetConfig(const TDesC8& aConfigBuf);
       
    89 	virtual TInt SetVolume(TInt aVolume);
       
    90 	virtual TInt StartTransfer();
       
    91 	virtual TInt TransferData(TUint aTransferID,TLinAddr aLinAddr,TPhysAddr aPhysAddr,TInt aNumBytes);
       
    92 	virtual void StopTransfer();
       
    93 	virtual TInt PauseTransfer();
       
    94 	virtual TInt ResumeTransfer();
       
    95 	virtual TInt PowerUp();
       
    96 	virtual void PowerDown();
       
    97 	virtual TInt CustomConfig(TInt aFunction,TAny* aParam);
       
    98 	virtual TInt TimeTransferred(TInt64& aTimeTransferred, TInt aStatus);
       
    99 	void PlayCallback(TUint aTransferID,TInt aTransferResult,TInt aBytesTransferred);
       
   100 private:
       
   101 	void SetCaps();
       
   102 	
       
   103 private:
       
   104 	/** A pointer to the PDD factory. */
       
   105 	DTemplateSoundScPddFactory* iPhysicalDevice;
       
   106 	/** The capabilities of this device. */
       
   107 	TSoundFormatsSupportedV02 iCaps;
       
   108 	/** The playback DMA channel. */
       
   109 	TDmaChannel* iDmaChannel;
       
   110 	/** The DMA request structures used for transfers. */ 				
       
   111 	DTemplateSoundScTxDmaRequest* iDmaRequest[KTemplateMaxTxDmaRequests];
       
   112 	/** The number of outstanding DMA play requests on the DMA channel. */	
       
   113 	TInt iPendingPlay;
       
   114 	/** A flag selecting the next DMA request for transfer. */
       
   115 	TInt iFlag;
       
   116 	friend class DTemplateSoundScPddFactory;
       
   117 	};
       
   118 	
       
   119 /**
       
   120 The Template physical device driver (PDD) for the record shared chunk sound driver.
       
   121 */
       
   122 //
       
   123 // TO DO: (optional)
       
   124 //
       
   125 // Add any private functions and data you require
       
   126 //
       
   127 class DTemplateSoundScRxPdd : public DSoundScPdd
       
   128 	{
       
   129 public:
       
   130 	DTemplateSoundScRxPdd();
       
   131 	~DTemplateSoundScRxPdd();
       
   132 	TInt DoCreate();
       
   133 
       
   134 	// Implementations of the pure virtual functions inherited from DSoundScPdd (called by LDD).
       
   135 	virtual TDfcQue* DfcQ(TInt aUnit);
       
   136 	virtual void GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo);
       
   137 	virtual void Caps(TDes8& aCapsBuf) const;
       
   138 	virtual TInt MaxTransferLen() const;
       
   139 	virtual TInt SetConfig(const TDesC8& aConfigBuf);
       
   140 	virtual TInt SetVolume(TInt aVolume);
       
   141 	virtual TInt StartTransfer();
       
   142 	virtual TInt TransferData(TUint aTransferID,TLinAddr aLinAddr,TPhysAddr aPhysAddr,TInt aNumBytes);
       
   143 	virtual void StopTransfer();
       
   144 	virtual TInt PauseTransfer();
       
   145 	virtual TInt ResumeTransfer();
       
   146 	virtual TInt PowerUp();
       
   147 	virtual void PowerDown();
       
   148 	virtual TInt CustomConfig(TInt aFunction,TAny* aParam);
       
   149 	virtual TInt TimeTransferred(TInt64& aTimeTransferred, TInt aStatus);
       
   150 	void RecordCallback(TUint aTransferID,TInt aTransferResult,TInt aBytesTransferred);	
       
   151 private:
       
   152 	void SetCaps();	
       
   153 
       
   154 private:
       
   155 	/** A pointer to the PDD factory. */
       
   156 	DTemplateSoundScPddFactory* iPhysicalDevice;
       
   157 	/** The capabilities of this device. */
       
   158 	TSoundFormatsSupportedV02 iCaps;
       
   159 	/** The record DMA channel. */
       
   160 	TDmaChannel* iDmaChannel;
       
   161 	/** The DMA request structures used for transfers. */ 				
       
   162 	DTemplateSoundScRxDmaRequest* iDmaRequest[KTemplateMaxRxDmaRequests];
       
   163 	/** The number of outstanding DMA record requests on the DMA channel. */	
       
   164 	TInt iPendingRecord;
       
   165 	/** A flag selecting the next DMA request for transfer. */
       
   166 	TInt iFlag;
       
   167 	friend class DTemplateSoundScPddFactory;
       
   168 	};	
       
   169 
       
   170 /**
       
   171 Wrapper function for a shared chunk sound driver playback DMA request.
       
   172 */
       
   173 class DTemplateSoundScTxDmaRequest : public DDmaRequest
       
   174 	{
       
   175 public:	
       
   176 	DTemplateSoundScTxDmaRequest(TDmaChannel& aChannel,DTemplateSoundScTxPdd* aPdd,TInt aMaxTransferSize=0);
       
   177 	static void DmaService(TResult aResult, TAny* aArg);
       
   178 public:
       
   179 	/** Pointer back to the PDD. */
       
   180 	DTemplateSoundScTxPdd* iPdd;
       
   181 	/** The transfer ID for this DMA request - supplied by the LDD. */
       
   182 	TUint iTransferID;
       
   183 	/** The transfer sizes in progress. */
       
   184 	TUint iTransferSize;
       
   185 	};
       
   186 
       
   187 /**
       
   188 Wrapper function for a shared chunk sound driver record DMA request.
       
   189 */
       
   190 class DTemplateSoundScRxDmaRequest : public DDmaRequest
       
   191 	{
       
   192 public:	
       
   193 	DTemplateSoundScRxDmaRequest(TDmaChannel& aChannel,DTemplateSoundScRxPdd* aPdd,TInt aMaxTransferSize=0);
       
   194 	static void DmaService(TResult aResult, TAny* aArg);
       
   195 public:
       
   196 	/** Pointer back to the PDD. */
       
   197 	DTemplateSoundScRxPdd* iPdd;
       
   198 	/** The transfer ID for this DMA request - supplied by the LDD. */
       
   199 	TUint iTransferID;
       
   200 	/** The transfer sizes in progress. */
       
   201 	TUint iTransferSize;
       
   202 	};
       
   203 
       
   204 #endif /* __SOUNDSC_PLAT_H__ */