2001-07-01 19:38:58 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 Katsurajima Naoto <raven@katsurajima.seya.yokohama.jp>
|
2001-07-03 17:27:13 +00:00
|
|
|
* Copyright (c) 2001 Cameron Grant <cg@freebsd.org>
|
2001-07-01 19:38:58 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <dev/sound/pcm/sound.h>
|
|
|
|
#include <dev/sound/pcm/ac97.h>
|
2001-07-03 17:27:13 +00:00
|
|
|
#include <dev/sound/pci/ich.h>
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
#include <pci/pcireg.h>
|
|
|
|
#include <pci/pcivar.h>
|
|
|
|
|
2001-08-23 11:30:52 +00:00
|
|
|
SND_DECLARE_FILE("$FreeBSD$");
|
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define ICH_TIMEOUT 1000 /* semaphore timeout polling count */
|
2001-07-03 17:27:13 +00:00
|
|
|
#define ICH_DTBL_LENGTH 32
|
|
|
|
#define ICH_DEFAULT_BUFSZ 16384
|
2001-09-18 14:53:01 +00:00
|
|
|
#define ICH_MAX_BUFSZ 65536
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
/* buffer descriptor */
|
|
|
|
struct ich_desc {
|
|
|
|
volatile u_int32_t buffer;
|
|
|
|
volatile u_int32_t length;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sc_info;
|
|
|
|
|
|
|
|
/* channel registers */
|
|
|
|
struct sc_chinfo {
|
2001-12-21 19:20:28 +00:00
|
|
|
u_int32_t num:8, run:1, run_save:1;
|
|
|
|
u_int32_t blksz, blkcnt, spd;
|
2001-07-03 17:27:13 +00:00
|
|
|
u_int32_t regbase, spdreg;
|
2001-12-19 17:38:38 +00:00
|
|
|
u_int32_t imask;
|
2001-08-29 02:31:03 +00:00
|
|
|
u_int32_t civ;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
struct snd_dbuf *buffer;
|
|
|
|
struct pcm_channel *channel;
|
|
|
|
struct sc_info *parent;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
|
|
|
struct ich_desc *dtbl;
|
2001-07-01 19:38:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* device private data */
|
|
|
|
struct sc_info {
|
2001-07-03 17:27:13 +00:00
|
|
|
device_t dev;
|
2001-09-18 14:53:01 +00:00
|
|
|
int hasvra, hasvrm, hasmic;
|
|
|
|
unsigned int chnum, bufsz;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
struct resource *nambar, *nabmbar, *irq;
|
|
|
|
int nambarid, nabmbarid, irqid;
|
2001-07-01 19:38:58 +00:00
|
|
|
bus_space_tag_t nambart, nabmbart;
|
|
|
|
bus_space_handle_t nambarh, nabmbarh;
|
|
|
|
bus_dma_tag_t dmat;
|
2001-07-03 17:27:13 +00:00
|
|
|
bus_dmamap_t dtmap;
|
|
|
|
void *ih;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
struct ac97_info *codec;
|
2001-07-03 17:27:13 +00:00
|
|
|
struct sc_chinfo ch[3];
|
2001-12-17 01:57:42 +00:00
|
|
|
int ac97rate;
|
2001-07-03 17:27:13 +00:00
|
|
|
struct ich_desc *dtbl;
|
2001-07-01 19:38:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
static u_int32_t ich_fmt[] = {
|
2001-07-01 19:38:58 +00:00
|
|
|
AFMT_STEREO | AFMT_S16_LE,
|
|
|
|
0
|
|
|
|
};
|
2001-07-03 17:27:13 +00:00
|
|
|
static struct pcmchan_caps ich_vrcaps = {8000, 48000, ich_fmt, 0};
|
|
|
|
static struct pcmchan_caps ich_caps = {48000, 48000, ich_fmt, 0};
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* Hardware */
|
|
|
|
static u_int32_t
|
|
|
|
ich_rd(struct sc_info *sc, int regno, int size)
|
|
|
|
{
|
|
|
|
switch (size) {
|
|
|
|
case 1:
|
2001-07-03 17:27:13 +00:00
|
|
|
return bus_space_read_1(sc->nabmbart, sc->nabmbarh, regno);
|
2001-07-01 19:38:58 +00:00
|
|
|
case 2:
|
2001-07-03 17:27:13 +00:00
|
|
|
return bus_space_read_2(sc->nabmbart, sc->nabmbarh, regno);
|
2001-07-01 19:38:58 +00:00
|
|
|
case 4:
|
2001-07-03 17:27:13 +00:00
|
|
|
return bus_space_read_4(sc->nabmbart, sc->nabmbarh, regno);
|
2001-07-01 19:38:58 +00:00
|
|
|
default:
|
|
|
|
return 0xffffffff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ich_wr(struct sc_info *sc, int regno, u_int32_t data, int size)
|
|
|
|
{
|
|
|
|
switch (size) {
|
|
|
|
case 1:
|
2001-07-03 17:27:13 +00:00
|
|
|
bus_space_write_1(sc->nabmbart, sc->nabmbarh, regno, data);
|
2001-07-01 19:38:58 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2001-07-03 17:27:13 +00:00
|
|
|
bus_space_write_2(sc->nabmbart, sc->nabmbarh, regno, data);
|
2001-07-01 19:38:58 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2001-07-03 17:27:13 +00:00
|
|
|
bus_space_write_4(sc->nabmbart, sc->nabmbarh, regno, data);
|
2001-07-01 19:38:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ac97 codec */
|
|
|
|
static int
|
|
|
|
ich_waitcd(void *devinfo)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int32_t data;
|
|
|
|
struct sc_info *sc = (struct sc_info *)devinfo;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ICH_TIMEOUT; i++) {
|
|
|
|
data = ich_rd(sc, ICH_REG_ACC_SEMA, 1);
|
2001-07-01 19:38:58 +00:00
|
|
|
if ((data & 0x01) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
device_printf(sc->dev, "CODEC semaphore timeout\n");
|
|
|
|
return ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ich_rdcd(kobj_t obj, void *devinfo, int regno)
|
|
|
|
{
|
|
|
|
struct sc_info *sc = (struct sc_info *)devinfo;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
regno &= 0xff;
|
|
|
|
ich_waitcd(sc);
|
2001-07-03 17:27:13 +00:00
|
|
|
|
|
|
|
return bus_space_read_2(sc->nambart, sc->nambarh, regno);
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_wrcd(kobj_t obj, void *devinfo, int regno, u_int16_t data)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
|
|
|
struct sc_info *sc = (struct sc_info *)devinfo;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
regno &= 0xff;
|
|
|
|
ich_waitcd(sc);
|
2001-07-03 17:27:13 +00:00
|
|
|
bus_space_write_2(sc->nambart, sc->nambarh, regno, data);
|
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static kobj_method_t ich_ac97_methods[] = {
|
|
|
|
KOBJMETHOD(ac97_read, ich_rdcd),
|
|
|
|
KOBJMETHOD(ac97_write, ich_wrcd),
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
AC97_DECLARE(ich_ac97);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2001-07-03 17:27:13 +00:00
|
|
|
/* common routines */
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
static void
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_filldtbl(struct sc_chinfo *ch)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
2001-07-03 17:27:13 +00:00
|
|
|
u_int32_t base;
|
2001-08-29 02:31:03 +00:00
|
|
|
int i;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
base = vtophys(sndbuf_getbuf(ch->buffer));
|
|
|
|
ch->blkcnt = sndbuf_getsize(ch->buffer) / ch->blksz;
|
|
|
|
if (ch->blkcnt != 2 && ch->blkcnt != 4 && ch->blkcnt != 8 && ch->blkcnt != 16 && ch->blkcnt != 32) {
|
|
|
|
ch->blkcnt = 2;
|
|
|
|
ch->blksz = sndbuf_getsize(ch->buffer) / ch->blkcnt;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
for (i = 0; i < ICH_DTBL_LENGTH; i++) {
|
2001-08-29 02:31:03 +00:00
|
|
|
ch->dtbl[i].buffer = base + (ch->blksz * (i % ch->blkcnt));
|
|
|
|
ch->dtbl[i].length = ICH_BDC_IOC | (ch->blksz / 2);
|
2001-07-03 17:27:13 +00:00
|
|
|
}
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_resetchan(struct sc_info *sc, int num)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
2001-07-03 17:27:13 +00:00
|
|
|
int i, cr, regbase;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
if (num == 0)
|
|
|
|
regbase = ICH_REG_PO_BASE;
|
|
|
|
else if (num == 1)
|
|
|
|
regbase = ICH_REG_PI_BASE;
|
|
|
|
else if (num == 2)
|
|
|
|
regbase = ICH_REG_MC_BASE;
|
|
|
|
else
|
|
|
|
return ENXIO;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_wr(sc, regbase + ICH_REG_X_CR, 0, 1);
|
|
|
|
DELAY(100);
|
|
|
|
ich_wr(sc, regbase + ICH_REG_X_CR, ICH_X_CR_RR, 1);
|
|
|
|
for (i = 0; i < ICH_TIMEOUT; i++) {
|
|
|
|
cr = ich_rd(sc, regbase + ICH_REG_X_CR, 1);
|
|
|
|
if (cr == 0)
|
|
|
|
return 0;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
2001-07-03 17:27:13 +00:00
|
|
|
|
|
|
|
device_printf(sc->dev, "cannot reset channel %d\n", num);
|
|
|
|
return ENXIO;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* channel interface */
|
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
static void *
|
2001-07-03 17:27:13 +00:00
|
|
|
ichchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
|
|
|
struct sc_info *sc = devinfo;
|
|
|
|
struct sc_chinfo *ch;
|
2001-09-18 14:53:01 +00:00
|
|
|
unsigned int num;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
num = sc->chnum++;
|
|
|
|
ch = &sc->ch[num];
|
|
|
|
ch->num = num;
|
2001-07-01 19:38:58 +00:00
|
|
|
ch->buffer = b;
|
|
|
|
ch->channel = c;
|
|
|
|
ch->parent = sc;
|
|
|
|
ch->run = 0;
|
2001-07-03 17:27:13 +00:00
|
|
|
ch->dtbl = sc->dtbl + (ch->num * ICH_DTBL_LENGTH);
|
|
|
|
ch->blkcnt = 2;
|
2001-09-18 14:53:01 +00:00
|
|
|
ch->blksz = sc->bufsz / ch->blkcnt;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
|
|
|
switch(ch->num) {
|
|
|
|
case 0: /* play */
|
|
|
|
KASSERT(dir == PCMDIR_PLAY, ("wrong direction"));
|
|
|
|
ch->regbase = ICH_REG_PO_BASE;
|
|
|
|
ch->spdreg = sc->hasvra? AC97_REGEXT_FDACRATE : 0;
|
2001-12-19 17:38:38 +00:00
|
|
|
ch->imask = ICH_GLOB_STA_POINT;
|
2001-07-01 19:38:58 +00:00
|
|
|
break;
|
|
|
|
|
2001-08-29 02:31:03 +00:00
|
|
|
case 1: /* record */
|
2001-07-03 17:27:13 +00:00
|
|
|
KASSERT(dir == PCMDIR_REC, ("wrong direction"));
|
2001-08-29 02:31:03 +00:00
|
|
|
ch->regbase = ICH_REG_PI_BASE;
|
|
|
|
ch->spdreg = sc->hasvra? AC97_REGEXT_LADCRATE : 0;
|
2001-12-19 17:38:38 +00:00
|
|
|
ch->imask = ICH_GLOB_STA_PIINT;
|
2001-07-03 17:27:13 +00:00
|
|
|
break;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-08-29 02:31:03 +00:00
|
|
|
case 2: /* mic */
|
2001-07-03 17:27:13 +00:00
|
|
|
KASSERT(dir == PCMDIR_REC, ("wrong direction"));
|
2001-08-29 02:31:03 +00:00
|
|
|
ch->regbase = ICH_REG_MC_BASE;
|
|
|
|
ch->spdreg = sc->hasvrm? AC97_REGEXT_MADCRATE : 0;
|
2001-12-19 17:38:38 +00:00
|
|
|
ch->imask = ICH_GLOB_STA_MINT;
|
2001-07-03 17:27:13 +00:00
|
|
|
break;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
2001-09-18 14:53:01 +00:00
|
|
|
if (sndbuf_alloc(ch->buffer, sc->dmat, sc->bufsz))
|
2001-07-03 17:27:13 +00:00
|
|
|
return NULL;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_wr(sc, ch->regbase + ICH_REG_X_BDBAR, (u_int32_t)vtophys(ch->dtbl), 4);
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-03 17:27:13 +00:00
|
|
|
ichchan_setformat(kobj_t obj, void *data, u_int32_t format)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
2001-07-03 17:27:13 +00:00
|
|
|
return 0;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-03 17:27:13 +00:00
|
|
|
ichchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
|
|
|
struct sc_chinfo *ch = data;
|
2001-07-03 17:27:13 +00:00
|
|
|
struct sc_info *sc = ch->parent;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-12-17 01:57:42 +00:00
|
|
|
if (ch->spdreg) {
|
|
|
|
int r;
|
|
|
|
if (sc->ac97rate <= 32000 || sc->ac97rate >= 64000)
|
|
|
|
sc->ac97rate = 48000;
|
|
|
|
r = speed * 48000 / sc->ac97rate;
|
2001-12-21 19:20:28 +00:00
|
|
|
ch->spd = ac97_setrate(sc->codec, ch->spdreg, r) *
|
2001-12-17 01:57:42 +00:00
|
|
|
sc->ac97rate / 48000;
|
|
|
|
} else {
|
2001-12-21 19:20:28 +00:00
|
|
|
ch->spd = 48000;
|
2001-12-17 01:57:42 +00:00
|
|
|
}
|
2001-12-21 19:20:28 +00:00
|
|
|
return ch->spd;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-03 17:27:13 +00:00
|
|
|
ichchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
|
|
|
struct sc_chinfo *ch = data;
|
2001-07-03 17:27:13 +00:00
|
|
|
struct sc_info *sc = ch->parent;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
ch->blksz = blocksize;
|
|
|
|
ich_filldtbl(ch);
|
2001-08-29 02:31:03 +00:00
|
|
|
ich_wr(sc, ch->regbase + ICH_REG_X_LVI, ch->blkcnt - 1, 1);
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
return ch->blksz;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-03 17:27:13 +00:00
|
|
|
ichchan_trigger(kobj_t obj, void *data, int go)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
|
|
|
struct sc_chinfo *ch = data;
|
|
|
|
struct sc_info *sc = ch->parent;
|
|
|
|
|
|
|
|
switch (go) {
|
|
|
|
case PCMTRIG_START:
|
|
|
|
ch->run = 1;
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_wr(sc, ch->regbase + ICH_REG_X_BDBAR, (u_int32_t)vtophys(ch->dtbl), 4);
|
|
|
|
ich_wr(sc, ch->regbase + ICH_REG_X_CR, ICH_X_CR_RPBM | ICH_X_CR_LVBIE | ICH_X_CR_IOCE | ICH_X_CR_FEIE, 1);
|
2001-07-01 19:38:58 +00:00
|
|
|
break;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
case PCMTRIG_ABORT:
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_resetchan(sc, ch->num);
|
2001-07-01 19:38:58 +00:00
|
|
|
ch->run = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-03 17:27:13 +00:00
|
|
|
ichchan_getptr(kobj_t obj, void *data)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
|
|
|
struct sc_chinfo *ch = data;
|
|
|
|
struct sc_info *sc = ch->parent;
|
2001-08-29 02:31:03 +00:00
|
|
|
u_int32_t pos;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-08-29 02:31:03 +00:00
|
|
|
ch->civ = ich_rd(sc, ch->regbase + ICH_REG_X_CIV, 1) % ch->blkcnt;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-08-29 02:31:03 +00:00
|
|
|
pos = ch->civ * ch->blksz;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
|
|
|
return pos;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct pcmchan_caps *
|
2001-07-03 17:27:13 +00:00
|
|
|
ichchan_getcaps(kobj_t obj, void *data)
|
2001-07-01 19:38:58 +00:00
|
|
|
{
|
2001-07-03 17:27:13 +00:00
|
|
|
struct sc_chinfo *ch = data;
|
|
|
|
|
|
|
|
return ch->spdreg? &ich_vrcaps : &ich_caps;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
static kobj_method_t ichchan_methods[] = {
|
|
|
|
KOBJMETHOD(channel_init, ichchan_init),
|
|
|
|
KOBJMETHOD(channel_setformat, ichchan_setformat),
|
|
|
|
KOBJMETHOD(channel_setspeed, ichchan_setspeed),
|
|
|
|
KOBJMETHOD(channel_setblocksize, ichchan_setblocksize),
|
|
|
|
KOBJMETHOD(channel_trigger, ichchan_trigger),
|
|
|
|
KOBJMETHOD(channel_getptr, ichchan_getptr),
|
|
|
|
KOBJMETHOD(channel_getcaps, ichchan_getcaps),
|
2001-07-01 19:38:58 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
2001-07-03 17:27:13 +00:00
|
|
|
CHANNEL_DECLARE(ichchan);
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* The interrupt handler */
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
static void
|
|
|
|
ich_intr(void *p)
|
|
|
|
{
|
|
|
|
struct sc_info *sc = (struct sc_info *)p;
|
|
|
|
struct sc_chinfo *ch;
|
2001-12-19 17:38:38 +00:00
|
|
|
u_int32_t cbi, lbi, lvi, st, gs;
|
2001-07-03 17:27:13 +00:00
|
|
|
int i;
|
|
|
|
|
2001-12-19 18:26:53 +00:00
|
|
|
gs = ich_rd(sc, ICH_REG_GLOB_STA, 4) & ICH_GLOB_STA_IMASK;
|
2001-12-19 17:38:38 +00:00
|
|
|
if (gs & (ICH_GLOB_STA_PRES | ICH_GLOB_STA_SRES)) {
|
|
|
|
/* Clear resume interrupt(s) - nothing doing with them */
|
|
|
|
ich_wr(sc, ICH_REG_GLOB_STA, gs, 4);
|
|
|
|
}
|
|
|
|
gs &= ~(ICH_GLOB_STA_PRES | ICH_GLOB_STA_SRES);
|
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
ch = &sc->ch[i];
|
2001-12-19 17:38:38 +00:00
|
|
|
if ((ch->imask & gs) == 0)
|
|
|
|
continue;
|
|
|
|
gs &= ~ch->imask;
|
2001-07-03 17:27:13 +00:00
|
|
|
st = ich_rd(sc, ch->regbase + ICH_REG_X_SR, 2);
|
|
|
|
st &= ICH_X_SR_FIFOE | ICH_X_SR_BCIS | ICH_X_SR_LVBCI;
|
2001-12-19 17:38:38 +00:00
|
|
|
if (st & (ICH_X_SR_BCIS | ICH_X_SR_LVBCI)) {
|
2001-07-03 17:27:13 +00:00
|
|
|
/* block complete - update buffer */
|
2001-12-19 17:38:38 +00:00
|
|
|
if (ch->run)
|
|
|
|
chn_intr(ch->channel);
|
|
|
|
lvi = ich_rd(sc, ch->regbase + ICH_REG_X_LVI, 1);
|
|
|
|
cbi = ch->civ % ch->blkcnt;
|
|
|
|
if (cbi == 0)
|
|
|
|
cbi = ch->blkcnt - 1;
|
|
|
|
else
|
|
|
|
cbi--;
|
|
|
|
lbi = lvi % ch->blkcnt;
|
|
|
|
if (cbi >= lbi)
|
|
|
|
lvi += cbi - lbi;
|
|
|
|
else
|
|
|
|
lvi += cbi + ch->blkcnt - lbi;
|
|
|
|
lvi %= ICH_DTBL_LENGTH;
|
|
|
|
ich_wr(sc, ch->regbase + ICH_REG_X_LVI, lvi, 1);
|
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
2001-12-19 17:38:38 +00:00
|
|
|
/* clear status bit */
|
|
|
|
ich_wr(sc, ch->regbase + ICH_REG_X_SR, st, 2);
|
|
|
|
}
|
|
|
|
if (gs != 0) {
|
|
|
|
device_printf(sc->dev,
|
|
|
|
"Unhandled interrupt, gs_intr = %x\n", gs);
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-17 01:57:42 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Sysctl to control ac97 speed (some boards overclocked ac97). */
|
|
|
|
|
|
|
|
static int
|
|
|
|
ich_initsys(struct sc_info* sc)
|
|
|
|
{
|
|
|
|
#ifdef SND_DYNSYSCTL
|
|
|
|
SYSCTL_ADD_INT(snd_sysctl_tree(sc->dev),
|
|
|
|
SYSCTL_CHILDREN(snd_sysctl_tree_top(sc->dev)),
|
|
|
|
OID_AUTO, "ac97rate", CTLFLAG_RW,
|
|
|
|
&sc->ac97rate, 48000,
|
|
|
|
"AC97 link rate (default = 48000)");
|
|
|
|
#endif /* SND_DYNSYSCTL */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-12-18 03:29:31 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* Calibrate card (some boards are overclocked and need scaling) */
|
|
|
|
|
|
|
|
static
|
|
|
|
unsigned int ich_calibrate(struct sc_info *sc)
|
|
|
|
{
|
|
|
|
/* Grab audio from input for fixed interval and compare how
|
|
|
|
* much we actually get with what we expect. Interval needs
|
|
|
|
* to be sufficiently short that no interrupts are
|
|
|
|
* generated. */
|
|
|
|
struct sc_chinfo *ch = &sc->ch[1];
|
|
|
|
u_int16_t target_picb, actual_picb;
|
2001-12-19 18:04:04 +00:00
|
|
|
u_int32_t wait_us, actual_48k_rate;
|
2001-12-18 03:29:31 +00:00
|
|
|
|
|
|
|
KASSERT(ch->regbase == ICH_REG_PI_BASE, ("wrong direction"));
|
|
|
|
|
|
|
|
ichchan_setspeed(0, ch, 48000);
|
|
|
|
ichchan_setblocksize(0, ch, ICH_DEFAULT_BUFSZ);
|
|
|
|
|
|
|
|
target_picb = ch->dtbl[0].length / 2; /* half interrupt interval */
|
|
|
|
wait_us = target_picb * 1000 / (2 * 48); /* (2 == stereo -> mono) */
|
|
|
|
|
|
|
|
if (bootverbose)
|
|
|
|
device_printf(sc->dev, "Calibration interval %d us\n",
|
|
|
|
wait_us);
|
|
|
|
|
|
|
|
ichchan_trigger(0, ch, PCMTRIG_START);
|
|
|
|
DELAY(wait_us);
|
|
|
|
actual_picb = ich_rd(sc, ch->regbase + ICH_REG_X_PICB, 2);
|
|
|
|
ichchan_trigger(0, ch, PCMTRIG_ABORT);
|
|
|
|
|
|
|
|
actual_48k_rate = 48000 * (2 * target_picb - actual_picb) /
|
|
|
|
(target_picb);
|
|
|
|
|
2001-12-19 18:04:04 +00:00
|
|
|
if (actual_48k_rate > 48500 || actual_48k_rate < 47500) {
|
2001-12-18 03:29:31 +00:00
|
|
|
sc->ac97rate = actual_48k_rate;
|
|
|
|
} else {
|
|
|
|
sc->ac97rate = 48000;
|
|
|
|
}
|
2001-12-19 18:04:04 +00:00
|
|
|
|
|
|
|
if (bootverbose)
|
|
|
|
device_printf(sc->dev,
|
|
|
|
"Estimated AC97 link rate %d, using %d\n",
|
|
|
|
actual_48k_rate, sc->ac97rate);
|
|
|
|
|
2001-12-18 03:29:31 +00:00
|
|
|
return sc->ac97rate;
|
|
|
|
}
|
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
2001-07-03 17:27:13 +00:00
|
|
|
/* Probe and attach the card */
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
static void
|
|
|
|
ich_setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
ich_init(struct sc_info *sc)
|
|
|
|
{
|
|
|
|
u_int32_t stat;
|
2001-07-03 17:27:13 +00:00
|
|
|
int sz;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_wr(sc, ICH_REG_GLOB_CNT, ICH_GLOB_CTL_COLD, 4);
|
2001-07-01 19:38:58 +00:00
|
|
|
DELAY(600000);
|
2001-07-03 17:27:13 +00:00
|
|
|
stat = ich_rd(sc, ICH_REG_GLOB_STA, 4);
|
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
if ((stat & ICH_GLOB_STA_PCR) == 0)
|
2001-07-03 17:27:13 +00:00
|
|
|
return ENXIO;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
ich_wr(sc, ICH_REG_GLOB_CNT, ICH_GLOB_CTL_COLD | ICH_GLOB_CTL_PRES, 4);
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-09-18 14:53:01 +00:00
|
|
|
if (ich_resetchan(sc, 0) || ich_resetchan(sc, 1))
|
|
|
|
return ENXIO;
|
|
|
|
if (sc->hasmic && ich_resetchan(sc, 2))
|
2001-07-03 17:27:13 +00:00
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
if (bus_dmamem_alloc(sc->dmat, (void **)&sc->dtbl, BUS_DMA_NOWAIT, &sc->dtmap))
|
|
|
|
return ENOSPC;
|
|
|
|
|
|
|
|
sz = sizeof(struct ich_desc) * ICH_DTBL_LENGTH * 3;
|
|
|
|
if (bus_dmamap_load(sc->dmat, sc->dtmap, sc->dtbl, sz, ich_setmap, NULL, 0)) {
|
|
|
|
bus_dmamem_free(sc->dmat, (void **)&sc->dtbl, sc->dtmap);
|
|
|
|
return ENOSPC;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
2001-07-03 17:27:13 +00:00
|
|
|
|
|
|
|
return 0;
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ich_pci_probe(device_t dev)
|
|
|
|
{
|
2001-07-03 17:27:13 +00:00
|
|
|
switch(pci_get_devid(dev)) {
|
|
|
|
case 0x71958086:
|
|
|
|
device_set_desc(dev, "Intel 443MX");
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 0x24158086:
|
|
|
|
device_set_desc(dev, "Intel 82801AA (ICH)");
|
|
|
|
return 0;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
case 0x24258086:
|
2001-11-03 05:07:59 +00:00
|
|
|
device_set_desc(dev, "Intel 82801AB (ICH)");
|
2001-07-01 19:38:58 +00:00
|
|
|
return 0;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
|
|
|
case 0x24458086:
|
|
|
|
device_set_desc(dev, "Intel 82801BA (ICH2)");
|
|
|
|
return 0;
|
|
|
|
|
2001-11-03 05:07:59 +00:00
|
|
|
case 0x24858086:
|
|
|
|
device_set_desc(dev, "Intel 82801CA (ICH3)");
|
|
|
|
return 0;
|
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
default:
|
2001-07-01 19:38:58 +00:00
|
|
|
return ENXIO;
|
2001-07-03 17:27:13 +00:00
|
|
|
}
|
2001-07-01 19:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ich_pci_attach(device_t dev)
|
|
|
|
{
|
|
|
|
u_int32_t data;
|
2001-11-21 04:26:04 +00:00
|
|
|
u_int16_t extcaps;
|
2001-07-01 19:38:58 +00:00
|
|
|
struct sc_info *sc;
|
|
|
|
char status[SND_STATUSLEN];
|
|
|
|
|
|
|
|
if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT)) == NULL) {
|
|
|
|
device_printf(dev, "cannot allocate softc\n");
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
bzero(sc, sizeof(*sc));
|
|
|
|
sc->dev = dev;
|
|
|
|
|
|
|
|
data = pci_read_config(dev, PCIR_COMMAND, 2);
|
|
|
|
data |= (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
|
|
|
|
pci_write_config(dev, PCIR_COMMAND, data, 2);
|
|
|
|
data = pci_read_config(dev, PCIR_COMMAND, 2);
|
|
|
|
|
|
|
|
sc->nambarid = PCIR_NAMBAR;
|
|
|
|
sc->nabmbarid = PCIR_NABMBAR;
|
2001-07-03 17:27:13 +00:00
|
|
|
sc->nambar = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->nambarid, 0, ~0, 1, RF_ACTIVE);
|
|
|
|
sc->nabmbar = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->nabmbarid, 0, ~0, 1, RF_ACTIVE);
|
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
if (!sc->nambar || !sc->nabmbar) {
|
|
|
|
device_printf(dev, "unable to map IO port space\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
sc->nambart = rman_get_bustag(sc->nambar);
|
|
|
|
sc->nambarh = rman_get_bushandle(sc->nambar);
|
|
|
|
sc->nabmbart = rman_get_bustag(sc->nabmbar);
|
|
|
|
sc->nabmbarh = rman_get_bushandle(sc->nabmbar);
|
|
|
|
|
2001-09-18 14:53:01 +00:00
|
|
|
sc->bufsz = pcm_getbuffersize(dev, 4096, ICH_DEFAULT_BUFSZ, ICH_MAX_BUFSZ);
|
2001-08-29 02:31:03 +00:00
|
|
|
if (bus_dma_tag_create(NULL, 8, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
|
2001-09-18 14:53:01 +00:00
|
|
|
NULL, NULL, sc->bufsz, 1, 0x3ffff, 0, &sc->dmat) != 0) {
|
2001-07-01 19:38:58 +00:00
|
|
|
device_printf(dev, "unable to create dma tag\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
if (ich_init(sc)) {
|
2001-07-01 19:38:58 +00:00
|
|
|
device_printf(dev, "unable to initialize the card\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->codec = AC97_CREATE(dev, sc, ich_ac97);
|
|
|
|
if (sc->codec == NULL)
|
|
|
|
goto bad;
|
|
|
|
mixer_init(dev, ac97_getmixerclass(), sc->codec);
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
/* check and set VRA function */
|
2001-11-22 23:38:26 +00:00
|
|
|
extcaps = ac97_getextcaps(sc->codec);
|
2001-11-21 04:26:04 +00:00
|
|
|
sc->hasvra = extcaps & AC97_EXTCAP_VRA;
|
|
|
|
sc->hasvrm = extcaps & AC97_EXTCAP_VRM;
|
2001-11-22 23:38:26 +00:00
|
|
|
sc->hasmic = extcaps & AC97_CAP_MICCHANNEL;
|
|
|
|
ac97_setextmode(sc->codec, sc->hasvra | sc->hasvrm | sc->hasmic);
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
sc->irqid = 0;
|
2001-07-03 17:27:13 +00:00
|
|
|
sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid, 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
|
|
|
|
if (!sc->irq || snd_setup_intr(dev, sc->irq, INTR_MPSAFE, ich_intr, sc, &sc->ih)) {
|
2001-07-01 19:38:58 +00:00
|
|
|
device_printf(dev, "unable to map interrupt\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2001-10-07 23:31:52 +00:00
|
|
|
if (pcm_register(dev, sc, 1, sc->hasmic? 2 : 1))
|
2001-07-01 19:38:58 +00:00
|
|
|
goto bad;
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-09-18 14:53:01 +00:00
|
|
|
pcm_addchan(dev, PCMDIR_PLAY, &ichchan_class, sc); /* play */
|
|
|
|
pcm_addchan(dev, PCMDIR_REC, &ichchan_class, sc); /* record */
|
|
|
|
if (sc->hasmic)
|
|
|
|
pcm_addchan(dev, PCMDIR_REC, &ichchan_class, sc); /* record mic */
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-10-07 23:31:52 +00:00
|
|
|
snprintf(status, SND_STATUSLEN, "at io 0x%lx, 0x%lx irq %ld bufsz %u",
|
|
|
|
rman_get_start(sc->nambar), rman_get_start(sc->nabmbar), rman_get_start(sc->irq), sc->bufsz);
|
2001-07-03 17:27:13 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
pcm_setstatus(dev, status);
|
|
|
|
|
2001-12-17 01:57:42 +00:00
|
|
|
ich_initsys(sc);
|
2001-12-18 03:29:31 +00:00
|
|
|
ich_calibrate(sc);
|
2001-12-17 01:57:42 +00:00
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
bad:
|
|
|
|
if (sc->codec)
|
|
|
|
ac97_destroy(sc->codec);
|
|
|
|
if (sc->nambar)
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT,
|
|
|
|
sc->nambarid, sc->nambar);
|
|
|
|
if (sc->nabmbar)
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT,
|
|
|
|
sc->nabmbarid, sc->nabmbar);
|
|
|
|
if (sc->ih)
|
|
|
|
bus_teardown_intr(dev, sc->irq, sc->ih);
|
|
|
|
if (sc->irq)
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
|
|
|
|
free(sc, M_DEVBUF);
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ich_pci_detach(device_t dev)
|
|
|
|
{
|
|
|
|
struct sc_info *sc;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = pcm_unregister(dev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
sc = pcm_getdevinfo(dev);
|
|
|
|
|
2001-07-03 17:27:13 +00:00
|
|
|
bus_teardown_intr(dev, sc->irq, sc->ih);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
|
2001-07-01 19:38:58 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, sc->nambarid, sc->nambar);
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, sc->nabmbarid, sc->nabmbar);
|
|
|
|
bus_dma_tag_destroy(sc->dmat);
|
|
|
|
free(sc, M_DEVBUF);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-12-21 19:20:28 +00:00
|
|
|
static int
|
|
|
|
ich_pci_suspend(device_t dev)
|
|
|
|
{
|
|
|
|
struct sc_info *sc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
sc = pcm_getdevinfo(dev);
|
|
|
|
for (i = 0 ; i < 3; i++) {
|
|
|
|
sc->ch[i].run_save = sc->ch[i].run;
|
|
|
|
if (sc->ch[i].run) {
|
|
|
|
ichchan_trigger(0, &sc->ch[i], PCMTRIG_ABORT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ACLINK shut off */
|
|
|
|
ich_wr(sc,ICH_REG_GLOB_CNT, ICH_GLOB_CTL_SHUT, 4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-07-01 19:38:58 +00:00
|
|
|
static int
|
|
|
|
ich_pci_resume(device_t dev)
|
|
|
|
{
|
|
|
|
struct sc_info *sc;
|
2001-12-21 19:20:28 +00:00
|
|
|
int i;
|
2001-07-01 19:38:58 +00:00
|
|
|
|
|
|
|
sc = pcm_getdevinfo(dev);
|
|
|
|
|
|
|
|
/* Reinit audio device */
|
|
|
|
if (ich_init(sc) == -1) {
|
|
|
|
device_printf(dev, "unable to reinitialize the card\n");
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
/* Reinit mixer */
|
|
|
|
if (mixer_reinit(dev) == -1) {
|
|
|
|
device_printf(dev, "unable to reinitialize the mixer\n");
|
|
|
|
return ENXIO;
|
|
|
|
}
|
2001-12-21 19:20:28 +00:00
|
|
|
/* Re-start DMA engines */
|
|
|
|
for (i = 0 ; i < 3; i++) {
|
|
|
|
struct sc_chinfo *ch = &sc->ch[i];
|
|
|
|
if (sc->ch[i].run_save) {
|
|
|
|
ichchan_setblocksize(0, ch, ch->blksz);
|
|
|
|
ichchan_setspeed(0, ch, ch->spd);
|
|
|
|
ichchan_trigger(0, ch, PCMTRIG_START);
|
|
|
|
}
|
|
|
|
}
|
2001-07-01 19:38:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static device_method_t ich_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, ich_pci_probe),
|
|
|
|
DEVMETHOD(device_attach, ich_pci_attach),
|
|
|
|
DEVMETHOD(device_detach, ich_pci_detach),
|
2001-12-21 19:20:28 +00:00
|
|
|
DEVMETHOD(device_suspend, ich_pci_suspend),
|
2001-07-01 19:38:58 +00:00
|
|
|
DEVMETHOD(device_resume, ich_pci_resume),
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ich_driver = {
|
|
|
|
"pcm",
|
|
|
|
ich_methods,
|
2001-08-23 11:30:52 +00:00
|
|
|
PCM_SOFTC_SIZE,
|
2001-07-01 19:38:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DRIVER_MODULE(snd_ich, pci, ich_driver, pcm_devclass, 0, 0);
|
|
|
|
MODULE_DEPEND(snd_ich, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER);
|
|
|
|
MODULE_VERSION(snd_ich, 1);
|