author | Maciej Jablonski <maciej.jablonski@sosco.com> |
Wed, 12 May 2010 23:13:16 +0100 | |
changeset 72 | d00bf4f57250 |
parent 45 | 01c1ffcc4fca |
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_queue.h" |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
17 |
|
72
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
|
18 |
// #define ENABLE_QEMU_AUDIO_MODEL_BUG_WORKAROUND |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
19 |
#define ENABLE_QEMU_VIRTIO_CLEANUP_BUG_WORKAROUND |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
20 |
#define PHYS_ADDR(x) Epoc::LinearToPhysical( reinterpret_cast<TUint32>(x)) |
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 |
namespace VirtIo |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
23 |
{ |
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 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
26 |
DQueue::DQueue( MIo& aVirtIo, TUint aId, TUint aCount ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
27 |
: iVirtIo( aVirtIo ), iId( aId ), iCount( aCount ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
28 |
{ |
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 |
TInt DQueue::Construct() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
32 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
33 |
TInt r = AllocQueue(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
34 |
if (r!=KErrNone) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
35 |
{ return r; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
36 |
PreInitQueue(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
37 |
iVirtIo.SetQueueBase( iId, iDesc ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
38 |
PostInitQueue(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
39 |
return KErrNone; |
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 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
42 |
void DQueue::Wipe() |
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 |
if ( iChunk ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
45 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
46 |
iChunk->Close( NULL ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
47 |
iChunk = NULL; |
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 |
#ifndef ENABLE_QEMU_VIRTIO_CLEANUP_BUG_WORKAROUND |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
50 |
if ( iPhysAddr ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
51 |
{ Epoc::FreePhysicalRam( iPhysAddr ); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
52 |
#endif |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
53 |
iPhysAddr = 0; |
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 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
56 |
DQueue::~DQueue() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
57 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
58 |
Wipe(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
59 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
60 |
|
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 |
// Implementation here is that descs are allocated from the one starting with lowest index, |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
63 |
TInt DQueue::AddBuf( const TAddrLen aScatterList[], TUint32 aOutNum, TUint32 aInNum, Token aToken) |
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 |
SYBORG_VIRTIO_DEBUG("AddBuf Q%x %x l%x %x,%x %x", |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
66 |
iId, aScatterList[0].iAddr, aScatterList[0].iLen, aOutNum, aInNum, aToken ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
67 |
TUint outLeft = aOutNum; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
68 |
TUint inLeft = aInNum; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
69 |
TInt first = -1; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
70 |
TInt last = -1; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
71 |
TUint totalLen = 0; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
72 |
// @TODO maintain freedescs counter to know if the below is going to success from the outset. |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
73 |
// alloc and initialise descs |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
74 |
for ( TUint i = 0, j = 0; (i < iCount) && (outLeft+inLeft); ++i ) |
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 |
if (iDesc[i].iFlags == KFreeDescriptorMarker) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
77 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
78 |
if (first<0) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
79 |
{ first = i; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
80 |
iDesc[i].iFlags = ((outLeft)? 0 : TRingDesc::EFlagWrite); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
81 |
iDesc[i].iNext = KFreeDescriptorMarker; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
82 |
iDesc[i].iAddr = aScatterList[j].iAddr; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
83 |
iDesc[i].iLen = aScatterList[j].iLen; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
84 |
totalLen += aScatterList[j].iLen; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
85 |
iToken[i].iToken = aToken; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
86 |
iToken[i].iTotalLen = 0; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
87 |
if ( last >=0 ) |
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 |
iDesc[last].iNext = i; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
90 |
iDesc[last].iFlags |= TRingDesc::EFlagNext; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
91 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
92 |
last = i; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
93 |
if (outLeft) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
94 |
{ --outLeft; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
95 |
else |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
96 |
{ --inLeft; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
97 |
j++; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
98 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
99 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
100 |
if (outLeft+inLeft) // rollback descs if not all could have been claimed |
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 |
if (first>=0) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
103 |
{ FreeDescs(first); } |
72
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
|
104 |
SYBORG_VIRTIO_DEBUG("AddBuf Q%x - not ready", iId ); |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
105 |
return KErrNotReady; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
106 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
107 |
iToken[first].iTotalLen = totalLen; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
108 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
109 |
// fill a slot in avail ring |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
110 |
iAvail->iRing[Slot(iAvail->iIdx)] = first; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
111 |
++iAvail->iIdx; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
112 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
113 |
return KErrNone; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
114 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
115 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
116 |
// bases on the assumption that the lowest desc index with given aToken value is used (see addBuf) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
117 |
// @todo make sure the buffer is not yet posted |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
118 |
TInt DQueue::DetachBuf( Token aToken ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
119 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
120 |
TUint myDescId = KFreeDescriptorMarker; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
121 |
for ( TIdx i = iNextAvailToSync; i != iAvail->iIdx ; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
122 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
123 |
TUint availSlot = Slot( i ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
124 |
TUint descId = iAvail->iRing[availSlot]; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
125 |
if ( descId < iCount ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
126 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
127 |
if (iToken[descId].iToken == aToken) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
128 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
129 |
myDescId = descId; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
130 |
break; |
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 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
133 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
134 |
if ( myDescId != KFreeDescriptorMarker ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
135 |
{ return KErrNotFound; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
136 |
FreeDescs( myDescId ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
137 |
return KErrNone; |
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 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
140 |
Token DQueue::GetBuf( TUint& aLen ) |
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 |
TIdx usedIdx = iUsed->iIdx; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
143 |
ASSERT( ((TIdx)iNextUsedToRead) <= usedIdx ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
144 |
if (usedIdx == ((TIdx)iNextUsedToRead)) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
145 |
{ return 0; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
146 |
TUint nextUsedSlot = Slot(iNextUsedToRead); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
147 |
TUint len = iUsed->iRing[nextUsedSlot].iLen; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
148 |
TUint descId = iUsed->iRing[nextUsedSlot].iId; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
149 |
ASSERT(descId<iCount); |
72
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
|
150 |
Token token = iToken[descId].iToken; |
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
|
151 |
SYBORG_VIRTIO_DEBUG( "GetBuf Q%x %x ..%x t%x D%x L%x OL%x", iId, iNextUsedToRead, usedIdx, token, descId, len, iToken[descId].iTotalLen ); |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
152 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
153 |
++iNextUsedToRead; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
154 |
FreeDescs( descId ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
155 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
156 |
#ifdef ENABLE_QEMU_AUDIO_MODEL_BUG_WORKAROUND |
72
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 |
aLen = len?len:iToken[descId].iTotalLen; // @TODO kind of a hack to solve virtio-audio's failure to report len by syborg on the side of qemu |
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 |
#else |
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 |
aLen = len; |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
160 |
#endif |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
161 |
return token; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
162 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
163 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
164 |
TInt DQueue::Processing() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
165 |
{ return ((TIdx)(iAvail->iIdx - iFirstEverToSync)) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
166 |
- ((TIdx)(iUsed->iIdx - iFirstEverToRead)); } |
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 DQueue::Completed() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
169 |
{ return ((TIdx)(iUsed->iIdx - iNextUsedToRead)); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
170 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
171 |
void DQueue::Sync() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
172 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
173 |
SYBORG_VIRTIO_DEBUG("Sync Q%d, %x..%x", |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
174 |
iId, iNextAvailToSync, iAvail->iIdx ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
175 |
if ( ((TIdx)iNextAvailToSync) == iAvail->iIdx) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
176 |
{ return; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
177 |
DumpAvailPending(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
178 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
179 |
iNextAvailToSync = iAvail->iIdx; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
180 |
iVirtIo.PostQueue( iId ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
181 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
182 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
183 |
void DQueue::DumpUsedPending() |
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 |
for (TIdx i = iNextUsedToRead; i != iUsed->iIdx; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
186 |
{ DumpUsed( Slot(i) ); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
187 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
188 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
189 |
void DQueue::DumpUsed(TUint usedSlot) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
190 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
191 |
SYBORG_VIRTIO_DEBUG("Usedslot = %x, aLen = %x, descId=%x", usedSlot, (TUint32) iUsed->iRing[usedSlot].iLen, iUsed->iRing[usedSlot].iId); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
192 |
TUint descId = iUsed->iRing[usedSlot].iId; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
193 |
DumpDescs( descId ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
194 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
195 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
196 |
void DQueue::DumpAvailPending() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
197 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
198 |
for (TIdx i = iNextAvailToSync; i != iAvail->iIdx; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
199 |
{ DumpAvail( Slot(i) ); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
200 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
201 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
202 |
void DQueue::DumpAvail(TUint availSlot) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
203 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
204 |
SYBORG_VIRTIO_DEBUG("Q%d, availslot = %x", iId, availSlot); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
205 |
TUint descId = iAvail->iRing[availSlot]; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
206 |
DumpDescs( descId ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
207 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
208 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
209 |
void DQueue::DumpDescs(TUint descId ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
210 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
211 |
do { |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
212 |
TRingDesc& d = iDesc[descId]; |
72
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
|
213 |
if ( (-1) == ((signed)d.iAddr) ) |
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
|
214 |
break; |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
215 |
SYBORG_VIRTIO_DEBUG(" Desc %x,addr %x, len %x, flags %x, next %x", |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
216 |
(TUint32)descId, (TUint32)d.iAddr, (TUint32)d.iLen, (TUint32)d.iFlags, (TUint32)d.iNext ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
217 |
if ((d.iFlags&TRingDesc::EFlagNext)==0) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
218 |
{ break; } |
72
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
|
219 |
if ( KFreeDescriptorMarker == d.iNext ) |
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
|
220 |
break; |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
221 |
descId = d.iNext; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
222 |
} while (ETrue); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
223 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
224 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
225 |
void DQueue::DumpAll() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
226 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
227 |
DumpAvailPending(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
228 |
DumpUsedPending(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
229 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
230 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
231 |
void DQueue::FreeDescs( TUint firstDescIdx ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
232 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
233 |
TInt i = firstDescIdx; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
234 |
Token token = iToken[firstDescIdx].iToken; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
235 |
while (i>=0) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
236 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
237 |
ASSERT( ( ((TUint)i) < iCount ) ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
238 |
TUint flags = iDesc[i].iFlags; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
239 |
ASSERT( flags != KFreeDescriptorMarker ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
240 |
iDesc[i].iFlags = KFreeDescriptorMarker; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
241 |
ASSERT( iToken[i].iToken == token ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
242 |
iToken[i].iToken = 0; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
243 |
iToken[i].iTotalLen = 0; |
72
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
|
244 |
if ((flags&TRingDesc::EFlagNext)==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
|
245 |
break; |
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
|
246 |
i = iDesc[i].iNext; |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
247 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
248 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
249 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
250 |
TUint8* DQueue::AllocMem( TUint aSize ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
251 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
252 |
TInt r = KErrNone; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
253 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
254 |
#ifdef ENABLE_QEMU_VIRTIO_CLEANUP_BUG_WORKAROUND |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
255 |
// note this is second part of workaround that deals |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
256 |
// with the issue that memory once assigned to queuebase cannot be |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
257 |
// changed, |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
258 |
// if queuebase != 0 this is because it was set when the driver |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
259 |
// was loaded previous time |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
260 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
261 |
iPhysAddr = (TUint32) iVirtIo.GetQueueBase( iId ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
262 |
iPhysMemReallyAllocated = (iPhysAddr == 0); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
263 |
if (iPhysMemReallyAllocated) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
264 |
{ r = Epoc::AllocPhysicalRam(aSize, iPhysAddr, 0 ); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
265 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
266 |
#endif |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
267 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
268 |
if (r!=KErrNone ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
269 |
{ return NULL; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
270 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
271 |
r = DPlatChunkHw::New( iChunk, iPhysAddr, aSize, |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
272 |
EMapAttrSupRw | EMapAttrL2Uncached | EMapAttrL1Uncached ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
273 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
274 |
if (r!=KErrNone ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
275 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
276 |
if ( iPhysMemReallyAllocated ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
277 |
{ Epoc::FreePhysicalRam( iPhysAddr, aSize ); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
278 |
iChunk->Close( NULL ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
279 |
return NULL; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
280 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
281 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
282 |
ASSERT( r == KErrNone ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
283 |
return reinterpret_cast<TUint8*>( iChunk->LinearAddress() ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
284 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
285 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
286 |
TInt DQueue::AllocQueue() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
287 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
288 |
iDescSize = iCount * sizeof(TRingDesc); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
289 |
iAvailSize = sizeof(TRingAvail) + (iCount-1) * sizeof(((TRingAvail*)0)->iRing[0]); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
290 |
iTokenSize = iCount * sizeof(TTransactionInfo); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
291 |
TUint usedOffset = Align( iDescSize + iAvailSize, KVirtIoAlignment ); |
72
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
|
292 |
iUsedSize = sizeof(TRingUsed) + (iCount-1) * sizeof(((TRingUsed*)0)->iRing[0]); |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
293 |
TUint size = usedOffset + iUsedSize; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
294 |
TUint8* iMemAligned; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
295 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
296 |
iMemAligned = AllocMem( size ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
297 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
298 |
if (!iMemAligned) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
299 |
{ return KErrNoMemory; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
300 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
301 |
iDesc = reinterpret_cast<TRingDesc*>( iMemAligned ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
302 |
iAvail = reinterpret_cast<TRingAvail*>( iMemAligned + iDescSize ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
303 |
iUsed = reinterpret_cast<TRingUsed*>( iMemAligned + usedOffset ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
304 |
iToken = reinterpret_cast<TTransactionInfo*>( Kern::Alloc( iTokenSize ) ); |
72
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
|
305 |
SYBORG_VIRTIO_DEBUG("DQueue %d, Virt iDesc=%x/%x,iAvail=%x/%x,iToken=%x,iUsed=%x/%x", |
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
|
306 |
iId, iDesc, iDescSize, iAvail, iAvailSize, iToken, iUsed, iUsedSize ); |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
307 |
SYBORG_VIRTIO_DEBUG("DQueue %d, Phys iDesc=%x, iUsed=%x", |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
308 |
iId, PHYS_ADDR(iDesc), PHYS_ADDR(iUsed) ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
309 |
ASSERT( ((PHYS_ADDR(iUsed)-PHYS_ADDR(iDesc))) == ((TUint32)((TUint8*)iUsed-(TUint8*)iDesc)) ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
310 |
return KErrNone; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
311 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
312 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
313 |
void DQueue::PreInitQueue() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
314 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
315 |
memset(iDesc, -1, iDescSize ); |
72
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
|
316 |
memset( ((TUint8*) iAvail) + 4, -1, iAvailSize - 4 ); |
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
|
317 |
memset( ((TUint8*) iUsed) + 4, -1, iUsedSize - 4 ); |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
318 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
319 |
iAvail->iFlags = 0; // no notifications from control queue |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
320 |
iUsed->iFlags = 0; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
321 |
if ( iPhysMemReallyAllocated ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
322 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
323 |
iAvail->iIdx = 0; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
324 |
iUsed->iIdx = 0; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
325 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
326 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
327 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
328 |
void DQueue::PostInitQueue() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
329 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
330 |
iFirstEverToSync = iNextAvailToSync = iAvail->iIdx; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
331 |
iFirstEverToRead = iNextUsedToRead = iUsed->iIdx; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
332 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
333 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
334 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
335 |
} // namespace VirtIo |