baseport/syborg/soundsc/virtio_audio.h
author Gareth Stockwell <gareth.stockwell@accenture.com>
Fri, 24 Sep 2010 13:44:00 +0100
branchgraphics-phase-3
changeset 117 b7d35cad610d
parent 71 d00bf4f57250
permissions -rw-r--r--
Modified path to qemu package source to /sf/adapt/qemu This is to conform with the convention that adaptation-level packages should be located in /sf/adapt rather than /sf/adaptation. This is an interim workaround for bug 3744.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     1
/*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     2
* This component and the accompanying materials are made available
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     3
* under the terms of the License "Eclipse Public License v1.0"
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     4
* which accompanies this distribution, and is available
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     5
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     6
*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     7
* Initial Contributors:
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     8
* Accenture Ltd
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     9
*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    10
* Contributors:
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    11
*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    12
* Description: This file is a part of sound driver for Syborg adaptation.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    13
*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    14
*/
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    15
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    16
#ifndef VIRTIO_AUDIO_H
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    17
#define VIRTIO_AUDIO_H
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    18
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    19
#include "virtio_audio_defs.h"
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    20
#include "virtio_defs.h"
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    21
#include "virtio.h"
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    22
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    23
#include <e32def.h>
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    24
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    25
namespace VirtIo
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    26
{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    27
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    28
namespace Audio
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    29
{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    30
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    31
/// Encapsulates routines that affect VirtIo Audio device's Stream.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    32
/// DControl object may share ioHandler with other DControl objects.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    33
/// especially Control Queue.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    34
class DControl : public DBase
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    35
	{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    36
	static const TUint KCmdMaxBufCount = 8;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    37
	static const TUint KControlQueueId = 0;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    38
public:
71
d00bf4f57250 Fix bug 873. Fixes to syborg virtio-audio code as well as to the audio driver
Maciej Jablonski <maciej.jablonski@sosco.com>
parents: 45
diff changeset
    39
	enum Command { ERun = 5, EStop, EPause, EResume, EShutDown };
45
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    40
	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    41
	DControl( VirtIo::MIoHandler& aIoHandler, TUint32 aDataQueueId )
71
d00bf4f57250 Fix bug 873. Fixes to syborg virtio-audio code as well as to the audio driver
Maciej Jablonski <maciej.jablonski@sosco.com>
parents: 45
diff changeset
    42
	: iIoHandler( aIoHandler ), iDataQueueId( aDataQueueId), iIsRunning( 0 )
45
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    43
		{}
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    44
		
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    45
	~DControl();
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    46
		
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    47
	TInt Construct();
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    48
	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    49
	/// sets up stream parameters.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    50
	TInt Setup( StreamDirection aDirection, TInt aChannelNum, 
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    51
		FormatId aFormat, TInt aFreq );
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    52
		
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    53
	/// @brief posts a data buffer. 
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    54
	///
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    55
	/// The virtaulAddr is going to be turned into 
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    56
	/// a physical address scatter gather list.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    57
	TInt SendDataBuffer( TAny* virtaulAddr, TUint aSize, Token aToken );
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    58
	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    59
	/// Sends a specific command
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    60
	void SendCommand( Command aCmd )
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    61
		{ AddCommand( aCmd ); ControlQueue().Sync(); }
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    62
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    63
	/// Return Data Queue of the stream.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    64
	MQueue& DataQueue()
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    65
		{ return iIoHandler.Queue(iDataQueueId); }
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    66
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    67
	/// Returns Control Queue of the associated device.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    68
	MQueue& ControlQueue()
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    69
		{ return iIoHandler.Queue(KControlQueueId); }	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    70
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    71
private:
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    72
	// size of this struct needs to be power2 aligned
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    73
	// we extend original TCommand with padding to ensure this
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    74
	struct TCommandPadded: public TCommand
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    75
		{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    76
		static const TUint KPaddingSize = POW2ALIGN(sizeof(TCommand))-sizeof(TCommand);
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    77
		TUint8 iPadding[KPaddingSize];
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    78
		};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    79
	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    80
	void AddCommand( TCommandPadded* aCmd, Token aToken );
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    81
	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    82
	void AddCommand( TCommandPadded* aCmd, Token aToken, TAny* mem, TUint size );
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    83
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    84
	void AddCommand( Command aCmd );
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    85
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    86
	VirtIo::MIoHandler& iIoHandler;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    87
	TUint iDataQueueId;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    88
	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    89
	TUint8* iCmdMem; // managed
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    90
	TCommandPadded* iCmd; // unmanaged
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    91
	TBufferInfo* iBufferInfo; // unmanaged
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    92
	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    93
	StreamDirection iDirection;
71
d00bf4f57250 Fix bug 873. Fixes to syborg virtio-audio code as well as to the audio driver
Maciej Jablonski <maciej.jablonski@sosco.com>
parents: 45
diff changeset
    94
    
d00bf4f57250 Fix bug 873. Fixes to syborg virtio-audio code as well as to the audio driver
Maciej Jablonski <maciej.jablonski@sosco.com>
parents: 45
diff changeset
    95
    TUint iIsRunning;
45
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    96
	};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    97
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    98
} // namespace Audio
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    99
} // namespace VirtIo
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   100
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   101
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   102
#endif