audiop16x.c revision d9cbf529b0d117a7aa5d5184c898dd1dc234366a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Purpose: Driver for the Creative P16X AC97 audio controller
*/
/*
*
* Copyright (C) 4Front Technologies 1996-2009.
*
* This software is released under CDDL 1.0 source license.
* See the COPYING file included in the main directory of this source
* distribution for the license terms and conditions.
*/
#include "audiop16x.h"
/*
* These boards use an AC'97 codec, but don't have all of the
* various outputs that the AC'97 codec can offer. We just
* suppress them for now.
*/
static char *p16x_remove_ac97[] = {
};
static struct ddi_device_acc_attr dev_attr = {
};
static struct ddi_device_acc_attr buf_attr = {
};
static ddi_dma_attr_t dma_attr_buf = {
DMA_ATTR_V0, /* version number */
0x00000000, /* low DMA address range */
0xffffffff, /* high DMA address range */
0xfffffffe, /* DMA counter register */
4, /* DMA address alignment */
0x3c, /* DMA burstsizes */
4, /* min effective DMA size */
0xffffffff, /* max DMA xfer size */
0xffffffff, /* segment boundary */
1, /* s/g length */
4, /* granularity of device */
0 /* Bus specific DMA flags */
};
static int p16x_attach(dev_info_t *);
static int p16x_resume(dev_info_t *);
static int p16x_detach(p16x_dev_t *);
static int p16x_suspend(p16x_dev_t *);
static void p16x_close(void *);
static int p16x_start(void *);
static void p16x_stop(void *);
static int p16x_format(void *);
static int p16x_channels(void *);
static int p16x_rate(void *);
static uint64_t p16x_count(void *);
static void p16x_sync(void *, unsigned);
static void p16x_chinfo(void *, int, unsigned *, unsigned *);
static int p16x_alloc_port(p16x_dev_t *, int);
static void p16x_update_port(p16x_port_t *);
static void p16x_start_port(p16x_port_t *);
static void p16x_stop_port(p16x_port_t *);
static void p16x_destroy(p16x_dev_t *);
static int p16x_setup_intrs(p16x_dev_t *);
static void p16x_hwinit(p16x_dev_t *);
static audio_engine_ops_t p16x_engine_ops = {
};
static unsigned int
{
unsigned int val;
return (val);
}
static void
{
}
static uint16_t
{
int i;
for (i = 0; i < 10000; i++)
break;
return (value);
}
static void
{
unsigned int i;
for (i = 0; i < 10000; i++)
break;
}
static uint_t
{
unsigned int status;
return (DDI_INTR_UNCLAIMED);
}
/* Read the interrupt status */
return (DDI_INTR_UNCLAIMED);
}
}
}
}
if (consume) {
}
if (produce) {
}
return (DDI_INTR_CLAIMED);
}
/*
* Audio routines
*/
static void
{
return;
} else {
for (int i = 0; i < 3; i++) {
}
}
}
static int
{
return (0);
}
void
p16x_close(void *arg)
{
}
int
p16x_start(void *arg)
{
}
return (0);
}
void
{
}
}
int
p16x_format(void *arg)
{
return (AUDIO_FORMAT_S16_LE);
}
int
p16x_channels(void *arg)
{
}
int
{
return (48000);
}
void
{
}
{
return (0);
}
p16x_count(void *arg)
{
return (val);
}
static void
{
unsigned mult;
switch (chan) {
case 0: /* left front */
case 1: /* right front */
mult = 0;
break;
case 2: /* center */
case 3: /* lfe */
mult = 2;
break;
case 4: /* left surround */
case 5: /* right surround */
mult = 1;
break;
}
*incr = 2;
} else {
*incr = 2;
}
}
/* private implementation bits */
void
{
return;
} else {
}
/* get the offset, and switch to frames */
} else {
}
}
void
{
unsigned int tmp;
return;
/* Enable Rec Channel */
tmp |= 0x100;
} else {
/* Enable play channel and go */
tmp |= 7;
}
}
void
{
unsigned int tmp;
return;
/* Disable rec channel */
tmp &= ~0x100;
} else {
/* Disable Play channel */
tmp &= ~7;
}
}
int
{
int dir;
char *prop;
unsigned caps;
switch (num) {
case P16X_REC:
prop = "record-interrupts";
dir = DDI_DMA_READ;
break;
case P16X_PLAY:
prop = "play-interrupts";
dir = DDI_DMA_WRITE;
break;
default:
return (DDI_FAILURE);
}
/* figure out fragment configuration */
/* make sure the values are good */
}
/*
* We choose 6 fragments for a specific reason. Since the
* device only has full and half interrupts, and since the
* framework will try to queue up 4 frags automatically, this
* ensures that we will be able to queue all 4 fragments, and
* it avoids a potential underrun that you would get with 8
* fragments. (More than 8 fragments is guaranteed to cause
* underruns in Boomer.)
*
* Boomer needs to get smarter about dealing with devices with
* fewer fragment counts. This device, for instance, should
* really be represented with just two fragments. That wll
* cause an infinite loop in Boomer, when Boomer tries to
* queue up 4 fragments.
*/
/*
* The device operates in pairs of dwords at a time, for
* performance reasons. So make sure that our buffer is
* arranged as a whole number of these. We could probably
* fine tune by just ensuring that the overall buffer was 128
* (64 for half and 64 for full), but this is simpler.
*/
/* now allocate buffers */
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
&count) != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
void
{
}
}
for (int i = 0; i < P16X_NUM_PORT; i++) {
if (!port)
continue;
}
}
}
}
}
}
}
}
}
}
void
{
int i;
for (i = 0; i < 3; i++) {
}
/* Set physical address of the DMA buffer */
/* Set physical address of the DMA buffer */
/* Clear any pending interrupts */
}
int
{
int actual;
int rv;
"Can't alloc interrupt handle (rv %d actual %d)",
return (DDI_FAILURE);
}
(void) ddi_intr_free(ih[0]);
return (DDI_FAILURE);
}
DDI_SUCCESS) {
(void) ddi_intr_free(ih[0]);
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
int
{
/* we don't support high level interrupts in the driver */
if (ddi_intr_hilevel(dip, 0) != 0) {
"!%s%d: unsupported high level interrupt",
return (DDI_FAILURE);
}
"!%s%d: cannot get iblock cookie",
return (DDI_FAILURE);
}
goto error;
}
goto error;
}
if (vendor != CREATIVE_VENDOR_ID ||
device != SB_P16X_ID) {
goto error;
}
/* set PCI command register */
goto error;
}
goto error;
}
/* set up the interrupt handler */
goto error;
}
/* Enable PCI interrupts */
goto error;
}
/* remove the AC'97 controls we don't want to expose */
for (int i = 0; p16x_remove_ac97[i]; i++) {
}
}
/* set up kernel statistics */
KSTAT_FLAG_PERSISTENT)) != NULL) {
}
goto error;
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
int
{
/* allow ac97 operations again */
for (int i = 0; i < P16X_NUM_PORT; i++) {
/* reset the port */
} else {
}
}
return (DDI_SUCCESS);
}
int
{
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
int
{
for (int i = 0; i < P16X_NUM_PORT; i++) {
}
return (DDI_SUCCESS);
}
static int p16x_ddi_quiesce(dev_info_t *);
static struct dev_ops p16x_dev_ops = {
DEVO_REV, /* rev */
0, /* refcnt */
NULL, /* getinfo */
nulldev, /* identify */
nulldev, /* probe */
p16x_ddi_attach, /* attach */
p16x_ddi_detach, /* detach */
nodev, /* reset */
NULL, /* cb_ops */
NULL, /* bus_ops */
NULL, /* power */
p16x_ddi_quiesce, /* quiesce */
};
static struct modldrv p16x_modldrv = {
&mod_driverops, /* drv_modops */
"Creative P16X Audio", /* linkinfo */
&p16x_dev_ops, /* dev_ops */
};
static struct modlinkage modlinkage = {
{ &p16x_modldrv, NULL }
};
int
_init(void)
{
int rv;
}
return (rv);
}
int
_fini(void)
{
int rv;
}
return (rv);
}
int
{
}
int
{
switch (cmd) {
case DDI_ATTACH:
return (p16x_attach(dip));
case DDI_RESUME:
return (p16x_resume(dip));
default:
return (DDI_FAILURE);
}
}
int
{
switch (cmd) {
case DDI_DETACH:
return (p16x_detach(dev));
case DDI_SUSPEND:
return (p16x_suspend(dev));
default:
return (DDI_FAILURE);
}
}
int
{
for (int i = 0; i < P16X_NUM_PORT; i++) {
}
return (DDI_SUCCESS);
}