> Date: Thu, 4 Jun 2020 17:34:44 -0400
> From: George Koehler <[email protected]>
>
> This diff is for macppc "model PowerBook5,4". It adds the missing
> audio volume control by changing the driver from aoa(4) to snapper(4).
>
> Before the diff, I needed to put my ear near the speaker to check if
> audio was playing. After the diff, the speaker was so loud (about
> output.level=0.75) that I used sndioctl to turn it down. The diff
> uses strcmp(hw_prod, "PowerBook5,4") to attach the other driver.
>
> In OpenBSD,
> aoa(4) is i2s with no volume control.
> snapper(4) is i2s with TAS3004 volume control.
> In Mac OS X, system profiler shows TAS3004 audio on my PowerBook5,4.
>
> NetBSD doesn't check the "PowerBook5,4" model string. NetBSD's
> sys/arch/macppc/dev/snapper.c snapper_defer() looks for a "deq" in
> the device tree. No "deq" means no hardware volume control.
>
> OpenBSD defines a DEQaddr and doesn't check "deq". We do look for
> the kiic(4) on macobio(4) -- this device has "deq" -- but this
> happens late in snapper_defer(), after kiic(4) attaches, which is
> after aoa(4) or snapper(4) attaches. By checking "PowerBook5,4", I
> can pick aoa(4) or snapper(4) without knowing kiic(4). See part of
> my dmesg and eeprom -p, below the diff.
>
> OK to commit?
While it isn't "right", this is probably the least invasive way to
handle this. Apple just made too big a mess of their OFW device tree :(.
ok kettenis@
> Index: share/man/man4/man4.macppc/aoa.4
> ===================================================================
> RCS file: /cvs/src/share/man/man4/man4.macppc/aoa.4,v
> retrieving revision 1.9
> diff -u -p -r1.9 aoa.4
> --- share/man/man4/man4.macppc/aoa.4 2 Jul 2016 16:28:50 -0000 1.9
> +++ share/man/man4/man4.macppc/aoa.4 4 Jun 2020 20:39:33 -0000
> @@ -46,8 +46,6 @@ driver include:
> .Pp
> .Bl -dash -offset indent -compact
> .It
> -PowerBook5,4
> -.It
> PowerMac7,3
> .It
> PowerMac9,1
> Index: share/man/man4/man4.macppc/snapper.4
> ===================================================================
> RCS file: /cvs/src/share/man/man4/man4.macppc/snapper.4,v
> retrieving revision 1.16
> diff -u -p -r1.16 snapper.4
> --- share/man/man4/man4.macppc/snapper.4 15 Jan 2015 20:37:36 -0000
> 1.16
> +++ share/man/man4/man4.macppc/snapper.4 4 Jun 2020 20:39:33 -0000
> @@ -57,6 +57,8 @@ PowerBook5,2
> .It
> PowerBook5,3
> .It
> +PowerBook5,4
> +.It
> PowerBook5,5
> .It
> PowerBook5,6
> Index: sys/arch/macppc/dev/aoa.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/macppc/dev/aoa.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 aoa.c
> --- sys/arch/macppc/dev/aoa.c 19 Sep 2016 06:46:43 -0000 1.9
> +++ sys/arch/macppc/dev/aoa.c 4 Jun 2020 20:39:33 -0000
> @@ -57,6 +57,8 @@ void aoa_attach(struct device *, struct
> void aoa_defer(struct device *);
> void aoa_set_volume(struct aoa_softc *, int, int);
>
> +extern char *hw_prod;
> +
> struct cfattach aoa_ca = {
> sizeof(struct aoa_softc), aoa_match, aoa_attach
> };
> @@ -107,7 +109,8 @@ aoa_match(struct device *parent, void *m
> bzero(compat, sizeof compat);
> OF_getprop(soundchip, "compatible", compat, sizeof compat);
>
> - if (strcmp(compat, "AOAKeylargo") == 0)
> + if (strcmp(compat, "AOAKeylargo") == 0 &&
> + strcmp(hw_prod, "PowerBook5,4") != 0)
> return (1);
> if (strcmp(compat, "AOAK2") == 0)
> return (1);
> Index: sys/arch/macppc/dev/snapper.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/macppc/dev/snapper.c,v
> retrieving revision 1.37
> diff -u -p -r1.37 snapper.c
> --- sys/arch/macppc/dev/snapper.c 19 Sep 2016 06:46:43 -0000 1.37
> +++ sys/arch/macppc/dev/snapper.c 4 Jun 2020 20:39:34 -0000
> @@ -70,6 +70,8 @@ void snapper_set_input(struct snapper_so
> int tas3004_write(struct snapper_softc *, u_int, const void *);
> int tas3004_init(struct snapper_softc *);
>
> +extern char *hw_prod;
> +
> struct cfattach snapper_ca = {
> sizeof(struct snapper_softc), snapper_match, snapper_attach
> };
> @@ -442,6 +444,9 @@ snapper_match(struct device *parent, voi
> bzero(compat, sizeof compat);
> OF_getprop(soundchip, "compatible", compat, sizeof compat);
>
> + if (strcmp(compat, "AOAKeylargo") == 0 &&
> + strcmp(hw_prod, "PowerBook5,4") == 0)
> + return (1);
> if (strcmp(compat, "snapper") == 0)
> return (1);
>
>
> Part of dmesg:
> [ using 1155980 bytes of bsd ELF symbol table ]
> console out [ATY,Jasper_A] console in [keyboard]USB and ADB found, using ADB
> using parent ATY,JasperParent:: memaddr b8000000, size 8000000 : consaddr
> b8008000 : ioaddr b0020000, size 20000: width 1280 linebytes 1280 height 854
> depth 8
> Copyright (c) 1982, 1986, 1989, 1991, 1993
> The Regents of the University of California. All rights reserved.
> Copyright (c) 1995-2020 OpenBSD. All rights reserved. https://www.OpenBSD.org
>
> OpenBSD 6.7-current (GENERIC) #1: Thu Jun 4 16:12:14 EDT 2020
> [email protected]:/usr/src/sys57/arch/macppc/compile/GENERIC
> real mem = 1073741824 (1024MB)
> avail mem = 1026486272 (978MB)
> random: good seed from bootblocks
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root: model PowerBook5,4
> cpu0 at mainbus0: 7447A (Revision 0x101): 1499 MHz: 512KB L2 cache
> mem0 at mainbus0
> spdmem0 at mem0: 1GB DDR SDRAM non-parity PC2700CL2.5
> spdmem1 at mem0: 1GB DDR SDRAM non-parity PC2700CL2.5
> memc0 at mainbus0: uni-n rev 0xd2
> "hw-clock" at memc0 not configured
> kiic0 at memc0 offset 0xf8001000
> iic0 at kiic0
> adt0 at iic0 addr 0xae: adt7460 rev 0x62
> "lmu-controller" at iic0 addr 0x42 not configured
> mpcpcibr0 at mainbus0 pci: uni-north
> pci0 at mpcpcibr0 bus 0
> pchb0 at pci0 dev 11 function 0 "Apple UniNorth AGP" rev 0x00
> agp at pchb0 not configured
> radeondrm0 at pci0 dev 16 function 0 "ATI Radeon Mobility M10" rev 0x00
> drm0 at radeondrm0
> radeondrm0: irq 48
> mpcpcibr1 at mainbus0 pci: uni-north
> pci1 at mpcpcibr1 bus 0
> macobio0 at pci1 dev 23 function 0 "Apple Intrepid" rev 0x00
> openpic0 at macobio0 offset 0x40000: version 0x4614 feature 3f0302 LE
> macgpio0 at macobio0 offset 0x50
> "modem-reset" at macgpio0 offset 0x1d not configured
> "modem-power" at macgpio0 offset 0x1c not configured
> macgpio1 at macgpio0 offset 0x9: irq 47
> "programmer-switch" at macgpio0 offset 0x11 not configured
> dfs0 at macgpio0 offset 0x6b: speeds: 1499, 749 MHz
> "gpio4" at macgpio0 offset 0x1e not configured
> "gpio5" at macgpio0 offset 0x6f not configured
> "gpio6" at macgpio0 offset 0x70 not configured
> "extint-gpio4" at macgpio0 offset 0x5c not configured
> "gpio11" at macgpio0 offset 0x75 not configured
> "extint-gpio15" at macgpio0 offset 0x67 not configured
> "escc-legacy" at macobio0 offset 0x12000 not configured
> zs0 at macobio0 offset 0x13000: irq 22,23
> zstty0 at zs0 channel 0
> zstty1 at zs0 channel 1
> snapper0 at macobio0 offset 0x10000: irq 30,1,2
> "timer" at macobio0 offset 0x15000 not configured
> adb0 at macobio0 offset 0x16000: irq 25, via-pmu, 3 targets
> apm0 at adb0: battery flags 0x5, 98% charged
> piic0 at adb0
> iic1 at piic0
> akbd0 at adb0 addr 2: PowerBook G4 keyboard (Inverted T)
> wskbd0 at akbd0: console keyboard
> ams0 at adb0 addr 3: EMP trackpad <tpad> 4-button, 400 dpi
> wsmouse0 at ams0 mux 0
> abtn0 at adb0 addr 7: brightness/volume/eject buttons
> "battery" at macobio0 offset 0x0 not configured
> "backlight" at macobio0 offset 0xf300 not configured
> kiic1 at macobio0 offset 0x18000
> iic2 at kiic1
> wdc0 at macobio0 offset 0x20000 irq 24: DMA
> atapiscsi0 at wdc0 channel 0 drive 0
> scsibus1 at atapiscsi0: 2 targets
> cd0 at scsibus1 targ 0 lun 0: <MATSHITA, DVD-R UJ-825, DAM5> removable
> cd0(wdc0:0:0): using BIOS timings, DMA mode 2
> audio0 at snapper0
> bwi0 at pci1 dev 18 function 0 "Broadcom BCM4306" rev 0x03: irq 52, address
> 00:0d:93:ef:83:58
> cbb0 at pci1 dev 19 function 0 "TI PCI1510 CardBus" rev 0x00: irq 53
> ohci0 at pci1 dev 26 function 0 "Apple Intrepid USB" rev 0x00: irq 29,
> version 1.0, legacy support
> ohci1 at pci1 dev 27 function 0 "NEC USB" rev 0x43: irq 63, version 1.0
> ohci2 at pci1 dev 27 function 1 "NEC USB" rev 0x43: irq 63, version 1.0
> ehci0 at pci1 dev 27 function 2 "NEC USB" rev 0x04: irq 63
> usb0 at ehci0: USB revision 2.0
> uhub0 at usb0 configuration 1 interface 0 "NEC EHCI root hub" rev 2.00/1.00
> addr 1
> cardslot0 at cbb0 slot 0 flags 0
> cardbus0 at cardslot0: bus 1 device 0 cacheline 0x8, lattimer 0x20
> pcmcia0 at cardslot0
> usb1 at ohci0: USB revision 1.0
> uhub1 at usb1 configuration 1 interface 0 "Apple OHCI root hub" rev 1.00/1.00
> addr 1
> usb2 at ohci1: USB revision 1.0
> uhub2 at usb2 configuration 1 interface 0 "NEC OHCI root hub" rev 1.00/1.00
> addr 1
> usb3 at ohci2: USB revision 1.0
> uhub3 at usb3 configuration 1 interface 0 "NEC OHCI root hub" rev 1.00/1.00
> addr 1
> mpcpcibr2 at mainbus0 pci: uni-north
> pci2 at mpcpcibr2 bus 0
> kauaiata0 at pci2 dev 13 function 0 "Apple Intrepid ATA" rev 0x00
> wdc1 at kauaiata0 irq 39: DMA
> wd0 at wdc1 channel 0 drive 0: <WDC WD2500BEVE-00WZT0>
> wd0: 16-sector PIO, LBA48, 238475MB, 488397168 sectors
> wd0(wdc1:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 5
> "Apple UniNorth Firewire" rev 0x81 at pci2 dev 14 function 0 not configured
> gem0 at pci2 dev 15 function 0 "Apple Uni-N2 GMAC" rev 0x80: irq 41, address
> 00:0d:93:b4:cc:d4
> eephy0 at gem0 phy 0: 88E1111 Gigabit PHY, rev. 1
> rum0 at uhub0 port 1 configuration 1 interface 0 "Belkin Belkin 54g USB
> Network Adapter" rev 2.00/0.01 addr 2
> rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528, address 00:17:3f:85:5f:81
> uhidev0 at uhub1 port 1 configuration 1 interface 0 "Apple Computer
> HID-proxy" rev 1.10/12.41 addr 2
> uhidev0: iclass 3/1
> ukbd0 at uhidev0: 8 variable keys, 6 key codes
> wskbd1 at ukbd0 mux 1
> uhidev1 at uhub1 port 1 configuration 1 interface 1 "Apple Computer
> HID-proxy" rev 1.10/12.41 addr 2
> uhidev1: iclass 3/1
> ums0 at uhidev1: 5 buttons
> wsmouse1 at ums0 mux 0
> uhidev2 at uhub3 port 1 configuration 1 interface 0 "CHESEN USB Keyboard" rev
> 1.10/1.10 addr 2
> uhidev2: iclass 3/1
> ukbd1 at uhidev2: 8 variable keys, 6 key codes, country code 33
> wskbd2 at ukbd1 mux 1
> uhidev3 at uhub3 port 1 configuration 1 interface 1 "CHESEN USB Keyboard" rev
> 1.10/1.10 addr 2
> uhidev3: iclass 3/0, 3 report ids
> uhid0 at uhidev3 reportid 2: input=1, output=0, feature=0
> uhid1 at uhidev3 reportid 3: input=3, output=0, feature=0
> vscsi0 at root
> scsibus2 at vscsi0: 256 targets
> softraid0 at root
> scsibus3 at softraid0: 256 targets
> bootpath: /pci@f4000000/ata-6@d/disk@0:/bsd
> root on wd0a (f9af1cad957793db.a) swap on wd0b dump on wd0b
> initializing kernel modesetting (RV350 0x1002:0x4E50 0x1002:0x4E50 0x00).
> ...
>
> Part of eeprom -p:
> ...
> Node 0xff9740e0
> name: 'i2s'
> device_type: 'i2s'
> built-in:
> reg:
> 00010000.00001000.00008000.00000100.00008100.00000100.00008200.00000100.00008300.00000100
> #address-cells: 00000001
> ranges:
>
> Node 0xff9742f8
> name: 'i2s-a'
> device_type: 'soundbus'
> compatible: 'i2sbus'
> built-in:
> reg: 00010000.00001000.00008000.00000100.00008100.00000100
> interrupts:
> 0000001e.00000001.00000001.00000000.00000002.00000000
> interrupt-parent: ff9700a0
> AAPL,requested-priorities: 00000002.00000004.00000004
> AAPL,clock-id: 'i2s0i045i049i018'
> AAPL,clock-data:
> 02b11000.0000003c.00003400.00000044.00004000.00000044.00000400.00000044.00000004.69303439.6e756c6c.00000000.02ee0000.0000003c.00003400.00000044.00004000.00000044.00000200.00000044.00000002.69303435.6e756c6c.00000000.01194000.0000003c.00003000.0000003c.00000400.00000044.00004000.00000000.00000000.6e756c6c.6e756c6c.00000000
>
> Node 0xff974610
> name: 'sound'
> device_type: 'soundchip'
> compatible: 'AOAKeylargo'
> vendor-id: 0000106b
> layout-id: 00000033
> object-model-version: 00000002
>
> Node 0xff9d8148
> name: 'i2s-b'
> device_type: 'i2s-b'
> compatible: 'i2s-modem'
> built-in:
> reg: 00011000.00001000.00008200.00000100.00008300.00000100
> interrupts:
> 0000001f.00000001.00000003.00000000.00000004.00000000
> interrupt-parent: ff9700a0
> sw-reset-enable: 00000000
> ...
> Node 0xff97c0a8
> name: 'i2c'
> device_type: 'i2c'
> reg: 00018000.00001000
> compatible: 'keywest-i2c'
> #size-cells: 00000000
> #address-cells: 00000001
> built-in:
> interrupts: 0000001a.00000001
> interrupt-parent: ff9700a0
> AAPL,address: 80018000
> AAPL,address-step: 00000010
> AAPL,i2c-rate: 00000064
> AAPL,driver-name: '.i2c-mac-io'
>
> Node 0xff97cc90
> reg: 000001c0
> name: 'cereal'
> device_type: 'serial'
>
> Node 0xff97d3c0
> name: 'deq'
> device_type: 'deq'
> reg: 0000006a
> i2c-address: 0000006a
> ...
>
>