From: ratchov Date: Wed, 21 Jul 2010 07:11:55 +0000 (+0000) Subject: make ENVY_GPIO_XXX macros card specific, add stub for audiophile 192k X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e70152709728c3e498f455289a9accc69a6051a3;p=openbsd make ENVY_GPIO_XXX macros card specific, add stub for audiophile 192k --- diff --git a/sys/dev/pci/envy.c b/sys/dev/pci/envy.c index d328ba6d8d1..b504784d21b 100644 --- a/sys/dev/pci/envy.c +++ b/sys/dev/pci/envy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: envy.c,v 1.37 2010/07/15 03:43:11 jakemsr Exp $ */ +/* $OpenBSD: envy.c,v 1.38 2010/07/21 07:11:55 ratchov Exp $ */ /* * Copyright (c) 2007 Alexandre Ratchov * @@ -116,6 +116,9 @@ enum ac97_host_flags envy_ac97_flags_codec(void *); void delta_init(struct envy_softc *); void delta_codec_write(struct envy_softc *, int, int, int); +void ap192k_init(struct envy_softc *); +void ap192k_codec_write(struct envy_softc *, int, int, int); + void revo51_init(struct envy_softc *); void revo51_codec_write(struct envy_softc *, int, int, int); @@ -280,6 +283,12 @@ struct envy_card envy_cards[] = { julia_init, julia_codec_write, julia_eeprom + }, { + PCI_ID_CODE(0x1412, 0x3632), + "M-Audio Audiophile 192k", + 2, &unkenvy_codec, 2, &ak4358_dac, + ap192k_init, + ap192k_codec_write }, { PCI_ID_CODE(0x1412, 0x3631), "M-Audio Revolution 5.1", @@ -306,6 +315,14 @@ struct envy_card envy_cards[] = { * M-Audio Delta specific code */ +/* + * GPIO pin numbers + */ +#define DELTA_GPIO_CLK 0x2 +#define DELTA_GPIO_DOUT 0x8 +#define DELTA_GPIO_CSMASK 0x70 +#define DELTA_GPIO_CS(dev) ((dev) << 4) + void delta_init(struct envy_softc *sc) { @@ -332,25 +349,84 @@ delta_codec_write(struct envy_softc *sc, int dev, int addr, int data) int bits, i, reg; reg = envy_gpio_getstate(sc); - reg &= ~ENVY_GPIO_CSMASK; - reg |= ENVY_GPIO_CS(dev); + reg &= ~DELTA_GPIO_CSMASK; + reg |= DELTA_GPIO_CS(dev); + envy_gpio_setstate(sc, reg); + delay(1); + + bits = 0xa000 | (addr << 8) | data; + for (i = 0; i < 16; i++) { + reg &= ~(DELTA_GPIO_CLK | DELTA_GPIO_DOUT); + reg |= (bits & 0x8000) ? DELTA_GPIO_DOUT : 0; + envy_gpio_setstate(sc, reg); + delay(1); + + reg |= DELTA_GPIO_CLK; + envy_gpio_setstate(sc, reg); + delay(1); + bits <<= 1; + } + + reg |= DELTA_GPIO_CSMASK; + envy_gpio_setstate(sc, reg); + delay(1); +} + +/* + * M-Audio Audiophile 192 specific code + */ + +/* + * GPIO pin numbers + */ +#define AP192K_GPIO_CLK 0x2 +#define AP192K_GPIO_DOUT 0x8 +#define AP192K_GPIO_CSMASK 0x70 +#define AP192K_GPIO_CS(dev) ((dev) << 4) + +#define AP192K_GPIO_CLK 0x2 +#define AP192K_GPIO_DOUT 0x8 +#define AP192K_GPIO_CSMASK 0x70 +#define AP192K_GPIO_CS(dev) ((dev) << 4) + +void +ap192k_init(struct envy_softc *sc) +{ + int i; + + envy_codec_write(sc, 0, 0, 0); /* reset */ + delay(300); + envy_codec_write(sc, 0, 0, 0x87); /* i2s mode */ + for (i = 0; i < sc->card->noch; i++) { + sc->shadow[0][AK4358_ATT(i)] = 0xff; + } +} + +void +ap192k_codec_write(struct envy_softc *sc, int dev, int addr, int data) +{ + int bits, i, reg; + + reg = envy_gpio_getstate(sc); + reg &= ~AP192K_GPIO_CSMASK; + reg |= AP192K_GPIO_CS(dev); envy_gpio_setstate(sc, reg); delay(1); bits = 0xa000 | (addr << 8) | data; for (i = 0; i < 16; i++) { - reg &= ~(ENVY_GPIO_CLK | ENVY_GPIO_DOUT); - reg |= (bits & 0x8000) ? ENVY_GPIO_DOUT : 0; + reg &= ~(AP192K_GPIO_CLK | AP192K_GPIO_DOUT); + reg |= (bits & 0x8000) ? AP192K_GPIO_DOUT : 0; envy_gpio_setstate(sc, reg); delay(1); - reg |= ENVY_GPIO_CLK; + reg |= AP192K_GPIO_CLK; envy_gpio_setstate(sc, reg); delay(1); bits <<= 1; } - reg |= ENVY_GPIO_CSMASK; + reg |= AP192K_GPIO_CSMASK; envy_gpio_setstate(sc, reg); delay(1); } @@ -359,6 +435,8 @@ delta_codec_write(struct envy_softc *sc, int dev, int addr, int data) * M-Audio Revolution 5.1 specific code */ +#define REVO51_GPIO_CLK 0x2 +#define REVO51_GPIO_DOUT 0x8 #define REVO51_GPIO_CSMASK 0x30 #define REVO51_GPIO_CS(dev) ((dev) ? 0x10 : 0x20) #define REVO51_MUTE 0x400000 @@ -413,12 +491,12 @@ revo51_codec_write(struct envy_softc *sc, int dev, int addr, int data) bits = 0xa000 | (addr << 8) | data; for (mask = 0x8000; mask != 0; mask >>= 1) { - reg &= ~(ENVY_GPIO_CLK | ENVY_GPIO_DOUT); - reg |= (bits & mask) ? ENVY_GPIO_DOUT : 0; + reg &= ~(REVO51_GPIO_CLK | REVO51_GPIO_DOUT); + reg |= (bits & mask) ? REVO51_GPIO_DOUT : 0; envy_gpio_setstate(sc, reg); delay(1); - reg |= ENVY_GPIO_CLK; + reg |= REVO51_GPIO_CLK; envy_gpio_setstate(sc, reg); delay(1); } diff --git a/sys/dev/pci/envyreg.h b/sys/dev/pci/envyreg.h index 1368a3cef87..8fe99b2aba0 100644 --- a/sys/dev/pci/envyreg.h +++ b/sys/dev/pci/envyreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: envyreg.h,v 1.14 2010/03/07 18:55:45 ratchov Exp $ */ +/* $OpenBSD: envyreg.h,v 1.15 2010/07/21 07:11:55 ratchov Exp $ */ /* * Copyright (c) 2007 Alexandre Ratchov * @@ -75,14 +75,6 @@ #define ENVY_CCI_GPIOMASK 0x21 #define ENVY_CCI_GPIODIR 0x22 -/* - * GPIO pin numbers - */ -#define ENVY_GPIO_CLK 0x2 -#define ENVY_GPIO_DOUT 0x8 -#define ENVY_GPIO_CSMASK 0x70 -#define ENVY_GPIO_CS(dev) ((dev) << 4) - /* * EEPROM bytes signification */