author | William Roberts <williamr@symbian.org> |
Tue, 15 Jun 2010 12:57:21 +0100 | |
branch | GCC_SURGE |
changeset 79 | 80387fbc46c5 |
parent 71 | d00bf4f57250 |
permissions | -rw-r--r-- |
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 |
#include "virtio_audio.h" |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
17 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
18 |
namespace VirtIo |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
19 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
20 |
namespace Audio |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
21 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
22 |
|
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
|
23 |
static TBool CheckProcessing( TAny* aSelf ) |
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
|
24 |
{ |
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
|
25 |
MQueue* queue = reinterpret_cast<MQueue*>( aSelf ); |
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
|
26 |
return queue->Processing() == 0; |
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
|
27 |
} |
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
|
28 |
|
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
|
29 |
static void WaitForCompletion( MQueue& aQueue ) |
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
|
30 |
{ |
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
|
31 |
SYBORG_VIRTIO_DEBUG("AddBufferHelperWaitForCompletion : {"); |
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
|
32 |
|
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
|
33 |
TInt st = Kern::PollingWait( &CheckProcessing, &aQueue, 50, 100 ); |
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
|
34 |
ASSERT ( (st == KErrNone) && "Polling problem" ) |
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
|
35 |
|
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
|
36 |
SYBORG_VIRTIO_DEBUG("AddBufferHelperWaitForCompletion : }"); |
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
|
37 |
} |
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
|
38 |
|
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 |
static void AddBufferHelper( MQueue& aQueue, TAddrLen aList[], TUint aBufInCount, TUint aBufOutCount, Token aToken) |
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
|
40 |
{ |
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
|
41 |
TInt st = aQueue.AddBuf(aList, aBufInCount, aBufOutCount, aToken ); |
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 |
if ( st == KErrNotReady ) |
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
|
43 |
{ |
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
|
44 |
SYBORG_VIRTIO_DEBUG("AddBufferHelper - no free descriptors at Control Queue, forcing wait"); |
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
|
45 |
TUint transferred; |
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
|
46 |
Token t; |
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
|
47 |
while ( ( t = aQueue.GetBuf(transferred), t ) != 0 ) |
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
|
48 |
{ |
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
|
49 |
SYBORG_VIRTIO_DEBUG("flushing Q%x, T%x, L%x\n", 0, t, transferred ); |
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
|
50 |
} |
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
|
51 |
|
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
|
52 |
st = aQueue.AddBuf(aList, aBufInCount, aBufOutCount, aToken ); |
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
|
53 |
} |
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
|
54 |
ASSERT( st == KErrNone ); |
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
|
55 |
} |
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
|
56 |
|
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
57 |
DControl::~DControl() |
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 |
if (iCmdMem) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
60 |
{ Kern::Free( iCmdMem ); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
61 |
} |
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 |
TInt DControl::Construct() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
64 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
65 |
TUint cmdSize = sizeof(iCmd[0])*KCmdMaxBufCount; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
66 |
TUint size = cmdSize + sizeof(*iBufferInfo); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
67 |
// as we are going to align the allocated memory |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
68 |
// we add extra alignment size minus 1 |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
69 |
iCmdMem = reinterpret_cast<TUint8*>( Kern::Alloc( size + sizeof(iCmd[0])-1 ) ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
70 |
if (!iCmdMem) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
71 |
{ return KErrNoMemory; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
72 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
73 |
// let us align the memory address |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
74 |
// note: sizeof(iCmd[0]) is a power of 2 |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
75 |
ASSERT( sizeof(iCmd[0]) == POW2ALIGN(sizeof(iCmd[0])) ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
76 |
TUint8* alignedMem = iCmdMem |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
77 |
+ ( (-(TUint32)iCmdMem)&(sizeof(iCmd[0])-1) ); // adding missing amount of bytes |
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 |
iCmd = reinterpret_cast<TCommandPadded*>( alignedMem ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
80 |
iBufferInfo = reinterpret_cast<TBufferInfo*>( alignedMem + cmdSize ); |
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 |
for (TUint i = 0; i< KCmdMaxBufCount; ++i) |
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 |
iCmd[i].iStream = iDataQueueId - 1; |
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 |
iCmd[0].iCommand = Audio::ECmdSetEndian; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
87 |
iCmd[1].iCommand = Audio::ECmdSetChannels; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
88 |
iCmd[2].iCommand = Audio::ECmdSetFormat; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
89 |
iCmd[3].iCommand = Audio::ECmdSetFrequency; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
90 |
iCmd[4].iCommand = Audio::ECmdInit; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
91 |
iCmd[5].iCommand = Audio::ECmdRun; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
92 |
iCmd[5].iArg = Audio::EDoRun; //start stream |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
93 |
iCmd[6].iCommand = Audio::ECmdRun; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
94 |
iCmd[6].iArg = Audio::EDoStop; //stop stream |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
95 |
iCmd[7].iCommand = Audio::ECmdRun; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
96 |
iCmd[7].iArg = Audio::EDoStop; //kind of pause |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
97 |
iCmd[8].iCommand = Audio::ECmdRun; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
98 |
iCmd[8].iArg = Audio::EDoRun; //kind of resume |
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
|
99 |
iCmd[9].iCommand = Audio::ECmdInit; // kind of shutdown |
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
|
100 |
iCmd[9].iArg = EDirectionNone; |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
101 |
return KErrNone; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
102 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
103 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
104 |
TInt DControl::Setup( StreamDirection aDirection, TInt aChannelNum, |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
105 |
FormatId aFormat, TInt aFreq) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
106 |
{ |
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
|
107 |
if (iIsRunning |
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
|
108 |
&& (( aDirection != iDirection ) |
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
|
109 |
|| (aFormat != iCmd[2].iArg ) |
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
|
110 |
|| (aFreq != iCmd[3].iArg ) |
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
|
111 |
|| (aChannelNum != iCmd[1].iArg ) |
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
|
112 |
)) |
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
|
113 |
{ return KErrInUse; } |
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
|
114 |
|
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
115 |
iCmd[1].iArg = aChannelNum; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
116 |
iCmd[2].iArg = aFormat; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
117 |
iCmd[3].iArg = aFreq; |
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
|
118 |
iCmd[4].iArg = iDirection = aDirection; |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
119 |
AddCommand(&iCmd[1],(Token)1); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
120 |
AddCommand(&iCmd[2],(Token)2); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
121 |
AddCommand(&iCmd[3],(Token)3); |
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
|
122 |
if (!iIsRunning) { |
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
|
123 |
AddCommand(&iCmd[4],(Token)4, iBufferInfo, sizeof(*iBufferInfo) ); |
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
|
124 |
AddCommand(&iCmd[6],(Token)6); |
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
|
125 |
} |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
126 |
ControlQueue().Sync(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
127 |
return KErrNone; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
128 |
} |
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
|
129 |
|
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
130 |
void DControl::AddCommand( TCommandPadded* aCmd, Token aToken ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
131 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
132 |
TAddrLen list; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
133 |
list.iLen = sizeof(TCommand); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
134 |
list.iAddr = Epoc::LinearToPhysical((TUint32)aCmd); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
135 |
SYBORG_VIRTIO_DEBUG("AddCommand %x %x %x", aCmd->iCommand, aCmd->iStream, aCmd->iArg); |
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
|
136 |
AddBufferHelper( ControlQueue(), &list, 1, 0, aToken ); |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
137 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
138 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
139 |
void DControl::AddCommand( TCommandPadded* aCmd, Token aToken, |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
140 |
TAny* aMem, TUint aSize ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
141 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
142 |
TAddrLen list[2]; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
143 |
list[0].iLen = sizeof(TCommand); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
144 |
list[0].iAddr = Epoc::LinearToPhysical((TUint32)aCmd); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
145 |
list[1].iLen = aSize; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
146 |
list[1].iAddr = Epoc::LinearToPhysical((TUint32)aMem); |
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
|
147 |
AddBufferHelper( ControlQueue(),list, 1, 1, aToken ); |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
148 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
149 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
150 |
void DControl::AddCommand( Command aCmd ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
151 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
152 |
TUint idx = aCmd; |
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
|
153 |
if ( (aCmd == EStop) || (aCmd == EShutDown) ) |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
154 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
155 |
// due to bug on qemu's side we need to stop sending buffers |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
156 |
// and wait for all pending buffers to get filled... |
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
|
157 |
WaitForCompletion(DataQueue()); |
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
|
158 |
WaitForCompletion(ControlQueue()); |
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
|
159 |
iIsRunning = 0; |
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
|
160 |
} |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
161 |
AddCommand(&iCmd[idx], (Token)idx ); |
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
|
162 |
if (aCmd == ERun ) |
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
|
163 |
{ |
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
|
164 |
iIsRunning = 1; |
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
|
165 |
} |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
166 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
167 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
168 |
TInt DControl::SendDataBuffer( TAny* virtaulAddr, TUint aSize, Token aToken ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
169 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
170 |
TAddrLen sgl[KMaxSGLItemCountPerAudioBuffer]; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
171 |
TUint sglCount = KMaxSGLItemCountPerAudioBuffer; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
172 |
TInt st = LinearToSGL(virtaulAddr, aSize, sgl, sglCount ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
173 |
ASSERT( st != KErrNoMemory ); // failure means our fixed lenght sgl table is too small |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
174 |
if (st!=KErrNone) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
175 |
{ return st; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
176 |
st = DataQueue().AddBuf( sgl, |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
177 |
iDirection == EDirectionPlayback ? sglCount : 0, |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
178 |
iDirection == EDirectionRecord ? sglCount : 0, |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
179 |
aToken ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
180 |
if (st!=KErrNone) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
181 |
{ return st; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
182 |
DataQueue().Sync(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
183 |
return KErrNone; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
184 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
185 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
186 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
187 |
} // namespace Audio |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
188 |
} // namespace VirtIo |