aoa.c revision 1.1
1/* $OpenBSD: aoa.c,v 1.1 2005/10/31 00:04:54 joris Exp $ */ 2/* $Id: aoa.c,v 1.1 2005/10/31 00:04:54 joris Exp $ */ 3 4/*- 5 * Copyright (c) 2005 Tsubai Masanari. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30/* 31 * WORK-IN-PROGRESS AOAKeylargo audio driver. 32 */ 33 34#include <sys/param.h> 35#include <sys/audioio.h> 36#include <sys/device.h> 37#include <sys/systm.h> 38 39#include <dev/audio_if.h> 40#include <dev/ofw/openfirm.h> 41 42#include <machine/autoconf.h> 43#include <macppc/dev/dbdma.h> 44 45#include <macppc/dev/i2svar.h> 46 47#ifdef AOA_DEBUG 48# define DPRINTF printf 49#else 50# define DPRINTF while (0) printf 51#endif 52 53#define aoa_softc i2s_softc /* XXX */ 54 55int aoa_match(struct device *, void *, void *); 56void aoa_attach(struct device *, struct device *, void *); 57 58/* XXX */ 59int aoa_getdev(void *, struct audio_device *); 60 61void aoa_set_volume(struct aoa_softc *, int, int); 62 63struct cfattach aoa_ca = { 64 sizeof(struct aoa_softc), aoa_match, aoa_attach 65}; 66 67struct cfdriver aoa_cd = { 68 NULL, "aoa", DV_DULL 69}; 70 71struct audio_hw_if aoa_hw_if = { 72 i2s_open, 73 i2s_close, 74 NULL, 75 i2s_query_encoding, 76 i2s_set_params, 77 i2s_round_blocksize, 78 NULL, 79 NULL, 80 NULL, 81 NULL, 82 NULL, 83 i2s_halt_output, 84 i2s_halt_input, 85 NULL, 86 aoa_getdev, 87 NULL, 88 i2s_set_port, 89 i2s_get_port, 90 i2s_query_devinfo, 91 i2s_allocm, 92 NULL, 93 i2s_round_buffersize, 94 i2s_mappage, 95 i2s_get_props, 96 i2s_trigger_output, 97 i2s_trigger_input, 98}; 99 100struct audio_device aoa_device = { 101 "AOA", 102 "", 103 "aoa" 104}; 105 106int 107aoa_match(parent, match, aux) 108 struct device *parent; 109 void *match; 110 void *aux; 111{ 112 struct confargs *ca = aux; 113 int soundbus, soundchip; 114 char compat[32]; 115 116 if (strcmp(ca->ca_name, "i2s") != 0) 117 return 0; 118 119 if ((soundbus = OF_child(ca->ca_node)) == 0 || 120 (soundchip = OF_child(soundbus)) == 0) 121 return 0; 122 123 bzero(compat, sizeof compat); 124 OF_getprop(soundchip, "compatible", compat, sizeof compat); 125 126 if (strcmp(compat, "AOAKeylargo") == 0) 127 return 1; 128 if (strcmp(compat, "AOAK2") == 0) 129 return 1; 130 if (strcmp(compat, "AOAbase") == 0) 131 return 1; 132 133 return 0; 134} 135 136void 137aoa_attach(parent, self, aux) 138 struct device *parent, *self; 139 void *aux; 140{ 141 struct aoa_softc *sc = (struct aoa_softc *)self; 142 143 /* "set volume" callback */ 144 sc->sc_setvolume = aoa_set_volume; 145 146 i2s_attach(parent, sc, aux); 147 audio_attach_mi(&aoa_hw_if, sc, &sc->sc_dev); 148} 149 150int 151aoa_getdev(h, retp) 152 void *h; 153 struct audio_device *retp; 154{ 155 *retp = aoa_device; 156 return 0; 157} 158 159void 160aoa_set_volume(sc, left, right) 161 struct aoa_softc *sc; 162 int left, right; 163{ 164 printf("aoa_set_volume() not supported yet\n"); 165} 166