[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-ppc
Subject:    Onyx driver set_input support
From:       jon () elytron ! openbsd ! amsterdam
Date:       2022-08-23 17:55:27
Message-ID: bd364c25e5483ff7 () pg4
[Download RAW message or body]

Reposting from tech, might be more relevant here.

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

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);
 }

	break;
+	}
+	data |= 12; /* bump volume */
+
+	kiic_write(sc->sc_i2c, PCM3052_I2C_ADDR,
+	    PCM3052_REG_ADC_CONTROL, &data, 1);
 }

From jon Wed Aug 10 21:27:59 2022
From: jon@elytron.openbsd.amsterdam
To: tech@openbsd.org
Subject: Onyx driver set_input support
Status: RO

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

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);
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic