On Wed, Aug 10, 2022 at 11:08:43AM +0000, [email protected] wrote:
> Hello everyone. The following diff adds support for
> switching the record.source with the macppc onyx
> driver. I'm still unsure how to get mixerctl or
> sndctl to set the volume, any hints appreciated.
>
> Drew some inspiration from
> https://git.sipsolutions.net/snd-aoa.git
Nice! This does fix the built-in mic on my PowerBook G4.
ok anyone?
>
> Index: arch/macppc/dev/onyx.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/macppc/dev/onyx.c,v
> retrieving revision 1.15
> diff -u -p -u -p -r1.15 onyx.c
> --- arch/macppc/dev/onyx.c 21 Mar 2022 19:22:39 -0000 1.15
> +++ arch/macppc/dev/onyx.c 10 Aug 2022 11:07:14 -0000
> @@ -59,6 +59,7 @@
> /* PCM3052 registers */
> #define PCM3052_REG_LEFT_VOLUME 0x41
> #define PCM3052_REG_RIGHT_VOLUME 0x42
> +#define PCM3052_REG_ADC_CONTROL 0x48
>
> /* XXX */
> #define onyx_softc i2s_softc
> @@ -71,6 +72,7 @@ int onyx_match(struct device *, void *,
> void onyx_attach(struct device *, struct device *, void *);
> void onyx_defer(struct device *);
> void onyx_set_volume(struct onyx_softc *, int, int);
> +void onyx_set_input(struct onyx_softc *, int);
>
> const struct cfattach onyx_ca = {
> sizeof(struct onyx_softc), onyx_match, onyx_attach
> @@ -143,6 +145,7 @@ onyx_attach(struct device *parent, struc
> struct onyx_softc *sc = (struct onyx_softc *)self;
>
> sc->sc_setvolume = onyx_set_volume;
> + sc->sc_setinput = onyx_set_input;
>
> i2s_attach(parent, sc, aux);
> config_defer(self, onyx_defer);
> @@ -169,6 +172,7 @@ onyx_defer(struct device *dev)
>
> deq_reset(sc);
> onyx_set_volume(sc, 192, 192);
> + onyx_set_input(sc, 1);
> }
>
> void
> @@ -186,4 +190,25 @@ onyx_set_volume(struct onyx_softc *sc, i
> data = 128 + (right >> 1);
> kiic_write(sc->sc_i2c, PCM3052_I2C_ADDR,
> PCM3052_REG_RIGHT_VOLUME, &data, 1);
> +}
> +
> +void
> +onyx_set_input(struct onyx_softc *sc, int mask)
> +{
> + uint8_t data = 0;
> +
> + sc->sc_record_source = mask;
> +
> + switch (mask) {
> + case 1 << 0: /* microphone */
> + data = 0x20;
> + break;
> + case 1 << 1: /* line in */
> + data = 0;
> + break;
> + }
> + data |= 12; /* bump volume */
> +
> + kiic_write(sc->sc_i2c, PCM3052_I2C_ADDR,
> + PCM3052_REG_ADC_CONTROL, &data, 1);
> }
>