Re: [PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-23 Thread Programmingkid


> On Feb 23, 2020, at 12:00 PM, qemu-ppc-requ...@nongnu.org wrote:
> 
> Message: 2
> Date: Sun, 23 Feb 2020 12:43:37 +0300
> From: Andrew Randrianasulu 
> To: hsp.c...@gmail.com, qemu-devel@nongnu.org, "qemu-...@nongnu.org"
>   
> Subject: Re: [PATCH v4] Implement the Screamer sound chip for the
>   mac99 machine type
> Message-ID: <202002231243.37654.randrianas...@gmail.com>
> Content-Type: text/plain;  charset="us-ascii"
> 
> Just thought I must share my uneducated guess on issue reported at
> 
> https://www.emaculation.com/forum/viewtopic.php?f=34=9820
>> Please note that running with 1024Mb of memory will make sound stop working 
>> in Mac OS 9.x. So run with less memory.
>> As will running without virtual memory.
> 
> My guess this has something to do with device memory regions, may be because 
> Linux  always uses Virtual memory
> (MMU, address translation), as well as Mac OS X 10.x - this little issue was 
> unnoticed until recently ?

Interesting theory. We may have to consult the 'Inside Macintosh' series under 
Memory management to find out how Mac OS 9 works with non-virtual memory. 


Re: [PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-23 Thread Programmingkid


> On Feb 23, 2020, at 9:17 AM, Howard Spoelstra  wrote:
> 
> 
> 
> On Fri, Feb 21, 2020 at 1:09 PM Howard Spoelstra  wrote:
> 
> 
> The current screamer-enabled builds for OSX and Windows are on 
> www.emaculation.com ;-)
> As you see from testing, there are reasons why the patches from Mark's 
> screamer branch are not in master yet, and these have not all been addressed. 
> There still needs to be testing on Linux and certainly on Windows builds, and 
> from what I mentioned above that might not be plain sailing. 
> I guess I'll wait with providing new builds when the patches for both 
> openbios and qemu are reviewed and in some repo from which I can build easily.
> 
> Best,
> Howard
> 
> Hi,
> 
> There is indeed an issue when building your code for Windows.
> Whereas the current screamer from Mark just plays sound, a build with your 
> patches will not.
> I need to Ctrl-Alt-G to exit grab, click on the command (cmd.exe) window in 
> which the Qemu textual output is showing and then grab the mouse again to get 
> sound. A simple grab exit/grab cycle is not enough, a click somewhere outside 
> the Qemu window will also not do. Only a click to activate the command window 
> and then grab again. Happens with both GTK and SDL GUIs.
> 
> Command line is:
> qemu-system-ppc-master-screamer-john-v4.exe -L pc-bios -boot c -m 256 -M 
> mac99,via=pmu ^
> -drive file=C:\mac-disks\9.2.img ^
> -sdl -serial stdio ^
> -bios openbios-qemu-screamer-john-v2.elf
> 
> Took me ages to find this regularity ;-)
> 
> Best,
> Howard

Thank you very much for catching this problem. Could you send me your Windows 
binary of QEMU that uses my patch. I would like to see if I can reproduce the 
problem on my computer. 


Re: [PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-23 Thread Howard Spoelstra
On Fri, Feb 21, 2020 at 1:09 PM Howard Spoelstra  wrote:

>
>
> The current screamer-enabled builds for OSX and Windows are on
> www.emaculation.com ;-)
> As you see from testing, there are reasons why the patches from Mark's
> screamer branch are not in master yet, and these have not all been
> addressed. There still needs to be testing on Linux and certainly on
> Windows builds, and from what I mentioned above that might not be plain
> sailing.
> I guess I'll wait with providing new builds when the patches for both
> openbios and qemu are reviewed and in some repo from which I can build
> easily.
>
> Best,
> Howard
>

Hi,

There is indeed an issue when building your code for Windows.
Whereas the current screamer from Mark just plays sound, a build with your
patches will not.
I need to Ctrl-Alt-G to exit grab, click on the command (cmd.exe) window in
which the Qemu textual output is showing and then grab the mouse again to
get sound. A simple grab exit/grab cycle is not enough, a click somewhere
outside the Qemu window will also not do. Only a click to activate the
command window and then grab again. Happens with both GTK and SDL GUIs.

Command line is:
qemu-system-ppc-master-screamer-john-v4.exe -L pc-bios -boot c -m 256 -M
mac99,via=pmu ^
-drive file=C:\mac-disks\9.2.img ^
-sdl -serial stdio ^
-bios openbios-qemu-screamer-john-v2.elf

Took me ages to find this regularity ;-)

Best,
Howard


Re: [PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-23 Thread Andrew Randrianasulu
Just thought I must share my uneducated guess on issue reported at

https://www.emaculation.com/forum/viewtopic.php?f=34=9820
> Please note that running with 1024Mb of memory will make sound stop working 
> in Mac OS 9.x. So run with less memory.
> As will running without virtual memory.

My guess this has something to do with device memory regions, may be because 
Linux  always uses Virtual memory
(MMU, address translation), as well as Mac OS X 10.x - this little issue was 
unnoticed until recently ?



Re: [PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-21 Thread Howard Spoelstra
On Fri, Feb 21, 2020 at 12:30 PM Programmingkid 
wrote:

>
> > On Feb 21, 2020, at 4:13 AM, Howard Spoelstra 
> wrote:
> >
> > Hi,
> >
> > It might be worth mentioning that any testing of your screamer
> implementation with MacOS/OSX guests on the mac99 machine needs a
> custom-built openbios.
> >
> > Where possible I'll compare your screamer with the current screamer
> implementation built from:
> > git clone -b screamer https://github.com/mcayland/qemu
> >
> > All tests on OSX Sierra host with system sounds and MP3 playback through
> latest QuickTime and iTunes available for the guest. Host is Intel i7-4770K
> at 3.50Ghz. 32Gb memory. Audio device is an USB headset.
> > Overall very subjective impression is that sound problems seem to arise
> quicker with strong changes in volume in the stream. Silence is produced
> perfectly...
> > I should note that I also tested earlier with a windows build and that I
> had to re-install Mac OS on three occasions to get sound going with your
> screamer. Whether that was caused by a faulty installation or your screamer
> is unclear to me.
> >
> > There we go:
> >
> > Mac OS 9.0.4: mac99,via=cuda
> > Apple audio extension often fails to load. (Not restricted to your
> screamer. This is a longstanding issue.) See at bottom for OSX crash report.
> > Your screamer: shows only CD in Sound CP Input panel. Play sound through
> output device is selected.
> > Current screamer: shows CD + External Mic. Play sound through output
> device is selected.
> >
> > Mac OS 9.1: mac99,via=cuda
> > Your screamer: No Input selection in the Sound CP.
> > Current screamer: Has External Mic (but no CD) in Sound CP. Play sound
> through output device is not selected.
> >
> > Mac OS 9.2: mac99,via=pmu
> > Your screamer: mp3 through iTunes and QuickTime OK. System sounds OK.
> > Current screamer: Has considerably more problems playing two streams
> simultaneously. (mp3 through both QuickTime and iTunes.)
> >
> > Mac OS X 10.0: mac99,via=cuda
> > Your screamer: setting the sound balance from middle position to the
> left seems to control volume.
> > Current screamer: Serious number of drop-outs when playing MP3 through
> QuickTime. Not when using iTunes. Has issues when moving the sound balance.
> >
> > Mac OS X 10.1: mac99,via=cuda
> > Off-topic: Interestingly, when booting with via=pmu, the same error
> occurs as reported above.
> > Your screamer: QuickTime: drop-outs. iTunes OK, even with playing system
> sounds through the stream. Balance has same problem as above.
> > Current screamer: Serious drop-outs through both QuickTime and iTunes
> when playing MP3. Balance sync gets completely lost after moving slider.
> More lag in response to clicking system sounds.
> >
> > Mac OSX 10.2: no test due to longstanding video issue with opening
> folders.
> >
> > Mac OSX 10.3: mac99,via=pmu
> > Your screamer: drop-outs with QuickTime and iTunes. But not the clicks
> heard as mentioned below. Opening the Sound preferences when playing MP3 is
> OK. System sounds playing through the stream produce crackling sound.
> systems sounds stop playing after several clicks on different ones. I hear
> parts of earlier clicked sound when new one clicked.
> > Current screamer: intermittent clicks (0.5 seconds) when playing MP3
> with QuickTime and iTunes. But QuickTime much better compared to 10.1.
> Currently playing mp3 gets completely distorted (doubled?) when opening
> Sound preferences.
> >
> > Mac OSX 10.4: mac99,via=pmu
> > Off-topic: From 10.4 onward, Internet radio works in iTunes. Channel
> update is very slow in 10.4...
> > Your screamer: drop-outs with QuickTime. Sounds comparable to current
> screamer. Opening Sound preferences is OK, but can make stream spiral out
> of control with an echo. Seems to happen quicker when playing sound with
> strong stereo effects. But always quickly recovers, unlike current
> screamer. iTunes also produces drop-outs. Also with internet stream, but is
> almost listenable.
> > Current screamer: drop-outs with QuickTime. Sounds like stream is not
> always in correct order. Sound crackles. iTunes almost OK. I can hear one
> or two clicks after stopping audio. Opening Sound preferences makes stream
> spiral out of control with an echo.
> >
> > Mac OSX 10.5: mac99,via=pmu
> > Your screamer: Drop-outs with QuickTime. A bit less-so with iTunes.
> Opening Sound preferences provides same experience as with 10.4. Internet
> stream almost listenable.
> > Current screamer: QuickTime produces drop-outs. Sound control panel
> spirals out of control. Small audio parts still played when stopping
> QuickTime. iTunes almost OK with MP3 playback, only small drop-outs. Same
> with Internet radio.
> >
> > For good measure I also tested 10.5 with your screamer and the recent
> hardfloat patches which improve fpu performance from 9% to 11% of a real G4
> 1Ghz ;-)
> > I did not experience a considerable improvement in sound quality.
> >
> > Best,
> > Howard
> >
> > OSX host Crash report when audio 

Re: [PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-21 Thread Programmingkid


> On Feb 21, 2020, at 4:13 AM, Howard Spoelstra  wrote:
> 
> Hi,
> 
> It might be worth mentioning that any testing of your screamer implementation 
> with MacOS/OSX guests on the mac99 machine needs a custom-built openbios.
> 
> Where possible I'll compare your screamer with the current screamer 
> implementation built from:
> git clone -b screamer https://github.com/mcayland/qemu 
> 
> All tests on OSX Sierra host with system sounds and MP3 playback through 
> latest QuickTime and iTunes available for the guest. Host is Intel i7-4770K 
> at 3.50Ghz. 32Gb memory. Audio device is an USB headset.
> Overall very subjective impression is that sound problems seem to arise 
> quicker with strong changes in volume in the stream. Silence is produced 
> perfectly...
> I should note that I also tested earlier with a windows build and that I had 
> to re-install Mac OS on three occasions to get sound going with your 
> screamer. Whether that was caused by a faulty installation or your screamer 
> is unclear to me.
> 
> There we go:
> 
> Mac OS 9.0.4: mac99,via=cuda
> Apple audio extension often fails to load. (Not restricted to your screamer. 
> This is a longstanding issue.) See at bottom for OSX crash report.
> Your screamer: shows only CD in Sound CP Input panel. Play sound through 
> output device is selected.
> Current screamer: shows CD + External Mic. Play sound through output device 
> is selected.
> 
> Mac OS 9.1: mac99,via=cuda
> Your screamer: No Input selection in the Sound CP. 
> Current screamer: Has External Mic (but no CD) in Sound CP. Play sound 
> through output device is not selected.
> 
> Mac OS 9.2: mac99,via=pmu
> Your screamer: mp3 through iTunes and QuickTime OK. System sounds OK.
> Current screamer: Has considerably more problems playing two streams 
> simultaneously. (mp3 through both QuickTime and iTunes.)
> 
> Mac OS X 10.0: mac99,via=cuda
> Your screamer: setting the sound balance from middle position to the left 
> seems to control volume.
> Current screamer: Serious number of drop-outs when playing MP3 through 
> QuickTime. Not when using iTunes. Has issues when moving the sound balance. 
> 
> Mac OS X 10.1: mac99,via=cuda
> Off-topic: Interestingly, when booting with via=pmu, the same error occurs as 
> reported above.
> Your screamer: QuickTime: drop-outs. iTunes OK, even with playing system 
> sounds through the stream. Balance has same problem as above.
> Current screamer: Serious drop-outs through both QuickTime and iTunes when 
> playing MP3. Balance sync gets completely lost after moving slider. More lag 
> in response to clicking system sounds.
> 
> Mac OSX 10.2: no test due to longstanding video issue with opening folders.
> 
> Mac OSX 10.3: mac99,via=pmu
> Your screamer: drop-outs with QuickTime and iTunes. But not the clicks heard 
> as mentioned below. Opening the Sound preferences when playing MP3 is OK. 
> System sounds playing through the stream produce crackling sound. systems 
> sounds stop playing after several clicks on different ones. I hear parts of 
> earlier clicked sound when new one clicked.
> Current screamer: intermittent clicks (0.5 seconds) when playing MP3 with 
> QuickTime and iTunes. But QuickTime much better compared to 10.1. Currently 
> playing mp3 gets completely distorted (doubled?) when opening Sound 
> preferences.
> 
> Mac OSX 10.4: mac99,via=pmu
> Off-topic: From 10.4 onward, Internet radio works in iTunes. Channel update 
> is very slow in 10.4...
> Your screamer: drop-outs with QuickTime. Sounds comparable to current 
> screamer. Opening Sound preferences is OK, but can make stream spiral out of 
> control with an echo. Seems to happen quicker when playing sound with strong 
> stereo effects. But always quickly recovers, unlike current screamer. iTunes 
> also produces drop-outs. Also with internet stream, but is almost listenable.
> Current screamer: drop-outs with QuickTime. Sounds like stream is not always 
> in correct order. Sound crackles. iTunes almost OK. I can hear one or two 
> clicks after stopping audio. Opening Sound preferences makes stream spiral 
> out of control with an echo.
> 
> Mac OSX 10.5: mac99,via=pmu
> Your screamer: Drop-outs with QuickTime. A bit less-so with iTunes. Opening 
> Sound preferences provides same experience as with 10.4. Internet stream 
> almost listenable.
> Current screamer: QuickTime produces drop-outs. Sound control panel spirals 
> out of control. Small audio parts still played when stopping QuickTime. 
> iTunes almost OK with MP3 playback, only small drop-outs. Same with Internet 
> radio. 
> 
> For good measure I also tested 10.5 with your screamer and the recent 
> hardfloat patches which improve fpu performance from 9% to 11% of a real G4 
> 1Ghz ;-)
> I did not experience a considerable improvement in sound quality.
> 
> Best,
> Howard
> 
> OSX host Crash report when audio extension fails:
> 
> Crashed Thread:2
> 
> Exception Type:EXC_BAD_ACCESS (SIGSEGV)
> Exception Codes:  

Re: [PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-21 Thread Howard Spoelstra
Hi,

It might be worth mentioning that any testing of your screamer
implementation with MacOS/OSX guests on the mac99 machine needs a
custom-built openbios.

Where possible I'll compare your screamer with the current screamer
implementation built from:
git clone -b screamer https://github.com/mcayland/qemu

All tests on OSX Sierra host with system sounds and MP3 playback through
latest QuickTime and iTunes available for the guest. Host is Intel i7-4770K
at 3.50Ghz. 32Gb memory. Audio device is an USB headset.
Overall very subjective impression is that sound problems seem to arise
quicker with strong changes in volume in the stream. Silence is produced
perfectly...
I should note that I also tested earlier with a windows build and that I
had to re-install Mac OS on three occasions to get sound going with your
screamer. Whether that was caused by a faulty installation or your screamer
is unclear to me.

There we go:

Mac OS 9.0.4: mac99,via=cuda
Apple audio extension often fails to load. (Not restricted to your
screamer. This is a longstanding issue.) See at bottom for OSX crash report.
Your screamer: shows only CD in Sound CP Input panel. Play sound through
output device is selected.
Current screamer: shows CD + External Mic. Play sound through output device
is selected.

Mac OS 9.1: mac99,via=cuda
Your screamer: No Input selection in the Sound CP.
Current screamer: Has External Mic (but no CD) in Sound CP. Play sound
through output device is not selected.

Mac OS 9.2: mac99,via=pmu
Your screamer: mp3 through iTunes and QuickTime OK. System sounds OK.
Current screamer: Has considerably more problems playing two streams
simultaneously. (mp3 through both QuickTime and iTunes.)

Mac OS X 10.0: mac99,via=cuda
Your screamer: setting the sound balance from middle position to the left
seems to control volume.
Current screamer: Serious number of drop-outs when playing MP3 through
QuickTime. Not when using iTunes. Has issues when moving the sound balance.

Mac OS X 10.1: mac99,via=cuda
Off-topic: Interestingly, when booting with via=pmu, the same error occurs
as reported above.
Your screamer: QuickTime: drop-outs. iTunes OK, even with playing system
sounds through the stream. Balance has same problem as above.
Current screamer: Serious drop-outs through both QuickTime and iTunes when
playing MP3. Balance sync gets completely lost after moving slider. More
lag in response to clicking system sounds.

Mac OSX 10.2: no test due to longstanding video issue with opening folders.

Mac OSX 10.3: mac99,via=pmu
Your screamer: drop-outs with QuickTime and iTunes. But not the clicks
heard as mentioned below. Opening the Sound preferences when playing MP3 is
OK. System sounds playing through the stream produce crackling sound.
systems sounds stop playing after several clicks on different ones. I hear
parts of earlier clicked sound when new one clicked.
Current screamer: intermittent clicks (0.5 seconds) when playing MP3 with
QuickTime and iTunes. But QuickTime much better compared to 10.1. Currently
playing mp3 gets completely distorted (doubled?) when opening Sound
preferences.

Mac OSX 10.4: mac99,via=pmu
Off-topic: From 10.4 onward, Internet radio works in iTunes. Channel update
is very slow in 10.4...
Your screamer: drop-outs with QuickTime. Sounds comparable to current
screamer. Opening Sound preferences is OK, but can make stream spiral out
of control with an echo. Seems to happen quicker when playing sound with
strong stereo effects. But always quickly recovers, unlike current
screamer. iTunes also produces drop-outs. Also with internet stream, but is
almost listenable.
Current screamer: drop-outs with QuickTime. Sounds like stream is not
always in correct order. Sound crackles. iTunes almost OK. I can hear one
or two clicks after stopping audio. Opening Sound preferences makes stream
spiral out of control with an echo.

Mac OSX 10.5: mac99,via=pmu
Your screamer: Drop-outs with QuickTime. A bit less-so with iTunes. Opening
Sound preferences provides same experience as with 10.4. Internet stream
almost listenable.
Current screamer: QuickTime produces drop-outs. Sound control panel spirals
out of control. Small audio parts still played when stopping QuickTime.
iTunes almost OK with MP3 playback, only small drop-outs. Same with
Internet radio.

For good measure I also tested 10.5 with your screamer and the recent
hardfloat patches which improve fpu performance from 9% to 11% of a real G4
1Ghz ;-)
I did not experience a considerable improvement in sound quality.

Best,
Howard

OSX host Crash report when audio extension fails:

Crashed Thread:2

Exception Type:EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:   KERN_INVALID_ADDRESS at 0x0008
Exception Note:EXC_CORPSE_NOTIFY

Termination Signal:Segmentation fault: 11
Termination Reason:Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x8:
-->
__TEXT 0001087b-000108f7f000 [ 

[PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-17 Thread John Arbuckle
This patch enables the playback of audio on a Mac OS 9 or Mac OS X guest.

Signed-off-by: John Arbuckle 
---
v4 changes:
- Switched to using HWADDR_PRIx in several debug statements.

v3 changes:
- Updated the location of patched code in hw/ppc/kconfig.
- Removed setting the props variable in screamer.c.
- Removed the screamer_properties variable in screamer.c.

v2 changes:
- Fixed a bug that prevented the sampling rate from being changed.

 hw/audio/Kconfig  |   3 +
 hw/audio/Makefile.objs|   2 +
 hw/audio/screamer.c   | 985 ++
 hw/misc/macio/macio.c |  35 +-
 hw/ppc/Kconfig|   1 +
 hw/ppc/mac.h  |   5 +
 include/hw/audio/screamer.h   |  42 ++
 include/hw/misc/macio/macio.h |   2 +
 8 files changed, 1074 insertions(+), 1 deletion(-)
 create mode 100644 hw/audio/screamer.c
 create mode 100644 include/hw/audio/screamer.h

diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
index e9c6fed826..196da6c3fe 100644
--- a/hw/audio/Kconfig
+++ b/hw/audio/Kconfig
@@ -50,3 +50,6 @@ config CS4231
 
 config MARVELL_88W8618
 bool
+
+config SCREAMER
+bool
diff --git a/hw/audio/Makefile.objs b/hw/audio/Makefile.objs
index 63db383709..55906886bc 100644
--- a/hw/audio/Makefile.objs
+++ b/hw/audio/Makefile.objs
@@ -15,4 +15,6 @@ common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
 
+common-obj-$(CONFIG_SCREAMER) += screamer.o
+
 common-obj-y += soundhw.o
diff --git a/hw/audio/screamer.c b/hw/audio/screamer.c
new file mode 100644
index 00..7de17fe8a6
--- /dev/null
+++ b/hw/audio/screamer.c
@@ -0,0 +1,985 @@
+/*
+ * File: Screamer.c
+ * Description: Implement the Screamer sound chip used in Apple Macintoshes.
+ * It works by filling a buffer, then playing the buffer.
+ */
+
+#include "qemu/osdep.h"
+#include "audio/audio.h"
+#include "hw/hw.h"
+#include "hw/irq.h"
+#include 
+#include "hw/ppc/mac.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
+#include "include/hw/audio/screamer.h"
+
+#define DEBUG_SCREAMER 0
+#define DPRINTF(fmt, ...) \
+do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
+
+#define SOUND_CONTROL_REG  0
+#define CODEC_CONTROL_REG  1
+#define CODEC_STATUS_REG   2
+#define CLIP_COUNT_REG 3
+#define BYTE_SWAP_REG  4
+#define FRAME_COUNT_REG5
+
+#define AWACS_BUSY 0x0100
+
+/* Used with AWACS register 1 */
+#define RECALIBRATE 0x004
+#define LOOPTHRU0x040
+#define SPEAKER_MUTE0x080
+#define HEADPHONE_MUTE  0x200
+#define OUTPUT_ZERO 0x400
+#define OUTPUT_ONE  0x800
+#define PARALLEL_OUTPUT 0xc00
+
+/* Function prototypes */
+static uint32_t set_busy_bit(uint32_t value, int bit);
+static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
+static uint32_t set_revision(uint32_t input_value);
+static uint32_t set_manufacturer(uint32_t input_value);
+static int get_sampling_rate(ScreamerState *s);
+static uint32_t get_frame_count_reg(ScreamerState *s);
+static void add_to_speaker_buffer(DBDMA_io *io);
+static void dma_request(DBDMA_io *io);
+
+
+/ Getters */
+
+/* Returns the codec control register's encoded AWACS address */
+static uint8_t get_codec_control_address(uint32_t value)
+{
+uint8_t return_value;
+return_value = (value >> 12) & 0x0fff;
+return return_value;
+}
+
+
+static uint32_t get_sound_control_reg(ScreamerState *s)
+{
+DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
+return s->sound_control;
+}
+
+/* The AWACS registers are accessed thru this register */
+static uint32_t get_codec_control_reg(ScreamerState *s)
+{
+int awacs_register = get_codec_control_address(s->codec_control);
+uint32_t return_value = s->awacs[awacs_register];
+return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
+DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
+return_value, awacs_register);
+return return_value;
+}
+
+/*
+ * Determines if the readback bit is set.
+ * It is used by the Codec Control register.
+ */
+static bool readback_enabled(ScreamerState *s)
+{
+/* Note: bit zero is the readback enabled bit */
+if (s->awacs[7] & 1) {
+return true;
+} else {
+return false;
+}
+}
+
+static uint32_t get_codec_status_reg(ScreamerState *s)
+{
+uint32_t return_value;
+
+/* if in readback mode - return AWACS register value */
+if (readback_enabled(s)) {
+int awacs_register = (s->awacs[7] & 0xe) >> 1;
+s->awacs[7] = s->awacs[7] & 0xfffe; /* turn off readback mode */
+return_value = s->awacs[awacs_register] << 4;
+DPRINTF("readback enable bit is set, returning AWACS register %d\t"
+"value:0x%x\n", awacs_register, return_value);
+
+