Adds the davbus and sound nodes like this: mac-io/davbus/sound This enables audio playback for a Mac OS 9 and a Mac OS X guest.
Signed-off-by: John Arbuckle programmingkidx@gmail.com --- config/examples/ppc_config.xml | 1 + drivers/build.xml | 1 + drivers/macio.c | 2 + drivers/pci.c | 4 ++ drivers/screamer.c | 112 +++++++++++++++++++++++++++++++++++++++++ drivers/screamer.h | 9 ++++ 6 files changed, 129 insertions(+) create mode 100644 drivers/screamer.c create mode 100644 drivers/screamer.h
diff --git a/config/examples/ppc_config.xml b/config/examples/ppc_config.xml index 19dc043..908d497 100644 --- a/config/examples/ppc_config.xml +++ b/config/examples/ppc_config.xml @@ -84,5 +84,6 @@ <option name="CONFIG_DRIVER_USB" type="boolean" value="true"/> <option name="CONFIG_DEBUG_USB" type="boolean" value="false"/> <option name="CONFIG_USB_HID" type="boolean" value="true"/> + <option name="CONFIG_DRIVER_SCREAMER" type="boolean" value="true"/> <option name="CONFIG_DRIVER_LSI_53C810" type="boolean" value="true"/> <option name="CONFIG_DRIVER_VIRTIO_BLK" type="boolean" value="true"/> diff --git a/drivers/build.xml b/drivers/build.xml index 5a28bc2..575ac6a 100644 --- a/drivers/build.xml +++ b/drivers/build.xml @@ -22,6 +22,7 @@ <object source="pc_kbd.c" condition="DRIVER_PC_KBD"/> <object source="pc_serial.c" condition="DRIVER_PC_SERIAL"/> <object source="escc.c" condition="DRIVER_ESCC"/> + <object source="screamer.c" condition="DRIVER_SCREAMER"/> <object source="fw_cfg.c" condition="DRIVER_FW_CFG"/> <object source="usb.c" condition="DRIVER_USB"/> <object source="usbhid.c" condition="USB_HID"/> diff --git a/drivers/macio.c b/drivers/macio.c index 496bab1..15c74ac 100644 --- a/drivers/macio.c +++ b/drivers/macio.c @@ -21,6 +21,7 @@ #include "pmu.h" #include "escc.h" #include "drivers/pci.h" +#include "screamer.h"
#define OW_IO_NVRAM_SIZE 0x00020000 #define OW_IO_NVRAM_OFFSET 0x00060000 @@ -391,6 +392,7 @@ ob_macio_keylargo_init(const char *path, phys_addr_t addr) escc_init(path, addr); macio_ide_init(path, addr, 2); openpic_init(path, addr); + screamer_init();
aliases = find_dev("/aliases"); set_property(aliases, "mac-io", path, strlen(path) + 1); diff --git a/drivers/pci.c b/drivers/pci.c index 9d501d3..b607fa5 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -1978,6 +1978,10 @@ static phandle_t ob_pci_host_set_interrupt_map(phandle_t host) target_node = find_dev(path); set_int_property(target_node, "interrupt-parent", dnode);
+ snprintf(buf, sizeof(buf), "%s/mac-io/davbus", path); + target_node = find_dev(buf); + set_int_property(target_node, "interrupt-parent", dnode); + return dnode; }
diff --git a/drivers/screamer.c b/drivers/screamer.c new file mode 100644 index 0000000..e494caa --- /dev/null +++ b/drivers/screamer.c @@ -0,0 +1,112 @@ +// File: screamer.c +// Description: Implements the davbus and sound nodes for sound support. + +#include "screamer.h" +#include "asm/types.h" +#include "kernel/stack.h" +#include "libopenbios/bindings.h" + + +/* Add the sound node for the screamer sound chip */ +static void setup_screamer_node() +{ + phandle_t node; + + fword("new-device"); + push_str("sound"); + fword("device-name"); + + push_str("screamer"); + fword("encode-string"); + push_str("awacs"); + fword("encode-string"); + fword("encode+"); + push_str("compatible"); + fword("property"); + + push_str("343S0184"); + fword("encode-string"); + push_str("model"); + fword("property"); + + node = get_cur_dev(); + + set_int_property(node, "#-outputs", 1); + set_int_property(node, "#-detects", 3); + set_int_property(node, "#-features", 3); + set_int_property(node, "object-model-version", 1); + set_int_property(node, "device-id", 5); + + char *value = "init operation 2 param 00000001 param-size 4\0" + "feature index 0 model Proj7PowerControl\0" + "feature index 1 model USBSubwoofer\0" + "feature index 2 model NotifySSprockets\0" + "detect bit-mask 2 bit-match 2 device 2 index 0 model InSenseBitsDetect\0" + "detect bit-mask 4 bit-match 4 device 16 index 1 model InSenseBitsDetect\0" + "detect bit-mask 1 bit-match 0 device 32 index 2 model InSenseBitsDetect\0" + "input icon-id -16526 index 0 name-id -20520 port-connection 2 " + "port-type 0x656D6963 zero-gain 0 model ExternalMic\0" + "input icon-id -16526 index 1 name-id -20528 port-connection 2 " + "port-type 0x73696E6A zero-gain 0 model InputPort\0" + "input icon-id -20184 index 2 name-id -20540 port-connection 3 " + "port-type 0x6d6f646d zero-gain 0 model InputPort\0" + "input index 3 model NoInput\0" + "output device-mask 2 device-match 0 icon-id -16563 index 0 name-id -20525" + " port-connection 2 port-type 0x6973706B model OutputPort\0" + "output device-mask 2 device-match 2 icon-id -16563 index 1 name-id -20524" + " port-connection 1 port-type 0x6864706E model OutputPort\0"; + + set_property(node, "sound-objects", value, 996); + + fword("finish-device"); +} + +/* Add the davbus node */ +static void setup_davbus_node() +{ + phandle_t node; + fword("new-device"); + + push_str("davbus"); + fword("device-name"); + + push_str("soundbus"); + fword("encode-string"); + push_str("device_type"); + fword("property"); + + push_str("davbus"); + fword("encode-string"); + push_str("compatible"); + fword("property"); + + node = get_cur_dev(); + int properties[6]; + + /* reg property */ + properties[0] = 0x14000; + properties[1] = 0x1000; + properties[2] = 0x8800; + properties[3] = 0x100; + properties[4] = 0x8900; + properties[5] = 0x100; + set_property(node, "reg", (char *)properties, sizeof(int) * 6); + + /* interrupt property */ + properties[0] = 0x18; + properties[1] = 1; + properties[2] = 9; + properties[3] = 0; + properties[4] = 0xa; + properties[5] = 0; + set_property(node, "interrupts", (char *)properties, sizeof(int) * 6); + + setup_screamer_node(); + + fword("finish-device"); +} + +void screamer_init() +{ + setup_davbus_node(); +} diff --git a/drivers/screamer.h b/drivers/screamer.h new file mode 100644 index 0000000..76624c0 --- /dev/null +++ b/drivers/screamer.h @@ -0,0 +1,9 @@ +// File: screamer.h +// Description: header file for screamer.c + +#ifndef screamer_h +#define screamer_h + +void screamer_init(); + +#endif /* screamer_h */