/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Purpose: Driver for the VIA VT82C686A AC97 audio controller
*/
/*
*
* Copyright (C) 4Front Technologies 1996-2009.
*/
#include "audiovia97.h"
};
};
DMA_ATTR_V0, /* version number */
0x00000000, /* low DMA address range */
0xffffffff, /* high DMA address range */
0x0000ffff, /* DMA counter register */
8, /* DMA address alignment */
0x3c, /* DMA burstsizes */
8, /* min effective DMA size */
0xffffffff, /* max DMA xfer size */
0x00000fff, /* segment boundary */
1, /* s/g length */
8, /* granularity of device */
0 /* Bus specific DMA flags */
};
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 via97_attach(dev_info_t *);
static int via97_resume(dev_info_t *);
static int via97_detach(via97_devc_t *);
static int via97_suspend(via97_devc_t *);
static int via97_open(void *, int, unsigned *, caddr_t *);
static void via97_close(void *);
static int via97_start(void *);
static void via97_stop(void *);
static int via97_format(void *);
static int via97_channels(void *);
static int via97_rate(void *);
static uint64_t via97_count(void *);
static void via97_sync(void *, unsigned);
static uint_t via97_playahead(void *);
static int via97_alloc_port(via97_devc_t *, int);
static void via97_destroy(via97_devc_t *);
static void via97_hwinit(via97_devc_t *);
NULL,
NULL,
};
static uint16_t
{
/* Index has only 7 bits */
if (index > 0x7F)
return (0xffff);
drv_usecwait(100);
/* Check AC CODEC access time out */
for (i = 0; i < CODEC_TIMEOUT_COUNT; i++) {
/* if send command over, break */
break;
drv_usecwait(50);
}
if (i == CODEC_TIMEOUT_COUNT) {
return (0xffff);
}
/* Check if Index still ours? If yes, return data, else return FAIL */
return ((int)tmp & CODEC_DATA);
}
return (0xffff);
}
static void
{
int value = 0;
unsigned int i = 0;
drv_usecwait(100);
/* Check AC CODEC access time out */
for (i = 0; i < CODEC_TIMEOUT_COUNT; i++) {
/* if send command over, break */
break;
drv_usecwait(50);
}
}
/*
* Audio routines
*/
int
{
return (0);
}
void
{
}
int
{
/* Set autostart at EOL, stereo, 16 bits */
0x80 | /* Set autostart at EOL */
0x20 | /* 16 bits */
0x10); /* Stereo */
return (0);
}
void
{
}
int
{
return (AUDIO_FORMAT_S16_LE);
}
int
{
return (2);
}
int
{
return (48000);
}
void
{
}
{
/*
* We see some situations where the default 1.5 fragments from
* the framework is not enough. 800-900 frame jitter is not
* uncommon. Especially at startup.
*/
return (1024);
}
{
uint32_t n;
/* convert from bytes to 16-bit stereo frames */
} else {
}
}
/* private implementation bits */
int
{
int dir;
unsigned caps;
switch (num) {
case VIA97_REC_SGD_NUM:
dir = DDI_DMA_READ;
break;
case VIA97_PLAY_SGD_NUM:
dir = DDI_DMA_WRITE;
break;
default:
return (DDI_FAILURE);
}
/* Simplicity -- a single contiguous looping buffer */
/* first allocate up space for SGD list */
return (DDI_FAILURE);
}
/* a single SGD entry is only 8 bytes long */
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
/* now buffers */
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
&count) != DDI_SUCCESS) {
return (DDI_FAILURE);
}
/* now wire descriptor up -- we only use one (which has EOL set)! */
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
void
{
for (int i = 0; i < VIA97_NUM_PORTC; i++) {
if (!portc)
continue;
}
}
}
}
}
}
}
}
}
}
}
}
}
void
{
/* Enable codec, etc */
drv_usecwait(10);
drv_usecwait(10);
/* disable FM io */
/* Enable interrupt on FLAG and on EOL */
}
int
{
goto error;
}
goto error;
}
if (vendor != VIA_VENDOR_ID ||
device != VIA_82C686) {
goto error;
}
goto error;
}
goto error;
}
goto error;
}
goto error;
}
goto error;
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
int
{
return (DDI_SUCCESS);
}
int
{
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
int
{
return (DDI_SUCCESS);
}
static int via97_ddi_quiesce(dev_info_t *);
DEVO_REV, /* rev */
0, /* refcnt */
NULL, /* getinfo */
nulldev, /* identify */
nulldev, /* probe */
via97_ddi_attach, /* attach */
via97_ddi_detach, /* detach */
nodev, /* reset */
NULL, /* cb_ops */
NULL, /* bus_ops */
NULL, /* power */
via97_ddi_quiesce, /* quiesce */
};
&mod_driverops, /* drv_modops */
"Via 82C686 Audio", /* linkinfo */
&via97_dev_ops, /* dev_ops */
};
{ &via97_modldrv, NULL }
};
int
_init(void)
{
int rv;
}
return (rv);
}
int
_fini(void)
{
int rv;
}
return (rv);
}
int
{
}
int
{
switch (cmd) {
case DDI_ATTACH:
return (via97_attach(dip));
case DDI_RESUME:
return (via97_resume(dip));
default:
return (DDI_FAILURE);
}
}
int
{
switch (cmd) {
case DDI_DETACH:
return (via97_detach(devc));
case DDI_SUSPEND:
return (via97_suspend(devc));
default:
return (DDI_FAILURE);
}
}
int
{
/*
* Turn off the hardware
*/
return (DDI_SUCCESS);
}