use pcm_getbuffersize()
This commit is contained in:
parent
7fc2570dc7
commit
14c953e80c
@ -50,6 +50,8 @@ SND_DECLARE_FILE("$FreeBSD$");
|
||||
#define DEB(x) /* x */
|
||||
#endif /* DEB */
|
||||
|
||||
#define ALS_DEFAULT_BUFSZ 16384
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Structures */
|
||||
|
||||
@ -73,6 +75,8 @@ struct sc_info {
|
||||
struct resource *reg, *irq;
|
||||
int regid, irqid;
|
||||
void *ih;
|
||||
|
||||
unsigned int bufsz;
|
||||
struct sc_chinfo pch, rch;
|
||||
};
|
||||
|
||||
@ -209,7 +213,7 @@ alschan_init(kobj_t obj, void *devinfo,
|
||||
ch->format = AFMT_U8;
|
||||
ch->speed = DSP_DEFAULT_SPEED;
|
||||
ch->buffer = b;
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, ALS_BUFFER_SIZE) != 0) {
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
return ch;
|
||||
@ -246,9 +250,10 @@ static int
|
||||
alschan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
||||
{
|
||||
struct sc_chinfo *ch = data;
|
||||
struct sc_info *sc = ch->parent;
|
||||
|
||||
if (blocksize > ALS_BUFFER_SIZE / 2) {
|
||||
blocksize = ALS_BUFFER_SIZE / 2;
|
||||
if (blocksize > sc->bufsz / 2) {
|
||||
blocksize = sc->bufsz / 2;
|
||||
}
|
||||
sndbuf_resize(ch->buffer, 2, blocksize);
|
||||
return blocksize;
|
||||
@ -731,12 +736,14 @@ als_resource_grab(device_t dev, struct sc_info *sc)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
sc->bufsz = pcm_getbuffersize(dev, 4096, ALS_DEFAULT_BUFSZ, 65536);
|
||||
|
||||
if (bus_dma_tag_create(/*parent*/NULL,
|
||||
/*alignment*/2, /*boundary*/0,
|
||||
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
|
||||
/*highaddr*/BUS_SPACE_MAXADDR,
|
||||
/*filter*/NULL, /*filterarg*/NULL,
|
||||
/*maxsize*/ALS_BUFFER_SIZE,
|
||||
/*maxsize*/sc->bufsz,
|
||||
/*nsegments*/1, /*maxsegz*/0x3ffff,
|
||||
/*flags*/0, &sc->parent_dmat) != 0) {
|
||||
device_printf(dev, "unable to create dma tag\n");
|
||||
|
@ -30,7 +30,6 @@
|
||||
#define ALS_PCI_POWERREG 0xe0
|
||||
|
||||
#define ALS_CONFIG_SPACE_BYTES 128
|
||||
#define ALS_BUFFER_SIZE 8192
|
||||
|
||||
#define ALS_GCR_DATA 0x08
|
||||
#define ALS_GCR_INDEX 0x0c
|
||||
|
@ -60,7 +60,7 @@ SND_DECLARE_FILE("$FreeBSD$");
|
||||
#define CMI8738B_PCI_ID 0x011213f6
|
||||
|
||||
/* Buffer size max is 64k for permitted DMA boundaries */
|
||||
#define CMI_BUFFER_SIZE 16384
|
||||
#define CMI_DEFAULT_BUFSZ 16384
|
||||
|
||||
/* Interrupts per length of buffer */
|
||||
#define CMI_INTR_PER_BUFFER 2
|
||||
@ -109,6 +109,7 @@ struct sc_info {
|
||||
void *ih;
|
||||
void *lock;
|
||||
|
||||
unsigned int bufsz;
|
||||
struct sc_chinfo pch, rch;
|
||||
};
|
||||
|
||||
@ -338,7 +339,7 @@ cmichan_init(kobj_t obj, void *devinfo,
|
||||
ch->spd = DSP_DEFAULT_SPEED;
|
||||
ch->buffer = b;
|
||||
ch->dma_active = 0;
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, CMI_BUFFER_SIZE) != 0) {
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
DEB(printf("cmichan_init failed\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -443,10 +444,11 @@ static int
|
||||
cmichan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
||||
{
|
||||
struct sc_chinfo *ch = data;
|
||||
struct sc_info *sc = ch->parent;
|
||||
|
||||
/* user has requested interrupts every blocksize bytes */
|
||||
if (blocksize > CMI_BUFFER_SIZE / CMI_INTR_PER_BUFFER) {
|
||||
blocksize = CMI_BUFFER_SIZE / CMI_INTR_PER_BUFFER;
|
||||
if (blocksize > sc->bufsz / CMI_INTR_PER_BUFFER) {
|
||||
blocksize = sc->bufsz / CMI_INTR_PER_BUFFER;
|
||||
}
|
||||
sndbuf_resize(ch->buffer, CMI_INTR_PER_BUFFER, blocksize);
|
||||
|
||||
@ -844,11 +846,13 @@ cmi_attach(device_t dev)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
sc->bufsz = pcm_getbuffersize(dev, 4096, CMI_DEFAULT_BUFSZ, 65536);
|
||||
|
||||
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
|
||||
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
|
||||
/*highaddr*/BUS_SPACE_MAXADDR,
|
||||
/*filter*/NULL, /*filterarg*/NULL,
|
||||
/*maxsize*/CMI_BUFFER_SIZE, /*nsegments*/1,
|
||||
/*maxsize*/sc->bufsz, /*nsegments*/1,
|
||||
/*maxsegz*/0x3ffff, /*flags*/0,
|
||||
&sc->parent_dmat) != 0) {
|
||||
device_printf(dev, "cmi_attach: Unable to create dma tag\n");
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
SND_DECLARE_FILE("$FreeBSD$");
|
||||
|
||||
#define CS4281_BUFFER_SIZE 16384
|
||||
#define CS4281_DEFAULT_BUFSZ 16384
|
||||
|
||||
/* Max fifo size for full duplex is 64 */
|
||||
#define CS4281_FIFO_SIZE 15
|
||||
@ -90,6 +90,7 @@ struct sc_info {
|
||||
void *ih;
|
||||
|
||||
int power;
|
||||
unsigned long bufsz;
|
||||
struct sc_chinfo pch;
|
||||
struct sc_chinfo rch;
|
||||
};
|
||||
@ -316,7 +317,7 @@ cs4281chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channe
|
||||
struct sc_chinfo *ch = (dir == PCMDIR_PLAY) ? &sc->pch : &sc->rch;
|
||||
|
||||
ch->buffer = b;
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, CS4281_BUFFER_SIZE) != 0) {
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
ch->parent = sc;
|
||||
@ -340,19 +341,20 @@ static int
|
||||
cs4281chan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
||||
{
|
||||
struct sc_chinfo *ch = data;
|
||||
struct sc_info *sc = ch->parent;
|
||||
u_int32_t go;
|
||||
|
||||
go = adcdac_go(ch, 0);
|
||||
|
||||
/* 2 interrupts are possible and used in buffer (half-empty,empty),
|
||||
* hence factor of 2. */
|
||||
ch->blksz = MIN(blocksize, CS4281_BUFFER_SIZE / 2);
|
||||
ch->blksz = MIN(blocksize, sc->bufsz / 2);
|
||||
sndbuf_resize(ch->buffer, 2, ch->blksz);
|
||||
ch->dma_setup = 0;
|
||||
adcdac_prog(ch);
|
||||
adcdac_go(ch, go);
|
||||
|
||||
DEB(printf("cs4281chan_setblocksize: bufsz %d Setting %d\n", blocksize, ch->blksz));
|
||||
DEB(printf("cs4281chan_setblocksize: blksz %d Setting %d\n", blocksize, ch->blksz));
|
||||
|
||||
return ch->blksz;
|
||||
}
|
||||
@ -823,11 +825,13 @@ cs4281_pci_attach(device_t dev)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
sc->bufsz = pcm_getbuffersize(dev, 4096, CS4281_DEFAULT_BUFSZ, 65536);
|
||||
|
||||
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
|
||||
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
|
||||
/*highaddr*/BUS_SPACE_MAXADDR,
|
||||
/*filter*/NULL, /*filterarg*/NULL,
|
||||
/*maxsize*/CS4281_BUFFER_SIZE, /*nsegments*/1,
|
||||
/*maxsize*/sc->bufsz, /*nsegments*/1,
|
||||
/*maxsegz*/0x3ffff,
|
||||
/*flags*/0, &sc->parent_dmat) != 0) {
|
||||
device_printf(dev, "unable to create dma tag\n");
|
||||
|
@ -42,8 +42,8 @@ SND_DECLARE_FILE("$FreeBSD$");
|
||||
/* Constants */
|
||||
|
||||
#define SV_PCI_ID 0xca005333
|
||||
#define SV_MAX_BUFFER 8192
|
||||
#define SV_MIN_BUFFER 128
|
||||
#define SV_DEFAULT_BUFSZ 16384
|
||||
#define SV_MIN_BLKSZ 128
|
||||
#define SV_INTR_PER_BUFFER 2
|
||||
|
||||
#ifndef DEB
|
||||
@ -89,6 +89,9 @@ struct sc_info {
|
||||
int irqid;
|
||||
void *ih;
|
||||
|
||||
/* User configurable buffer size */
|
||||
unsigned int bufsz;
|
||||
|
||||
struct sc_chinfo rch, pch;
|
||||
u_int8_t rev;
|
||||
};
|
||||
@ -189,7 +192,7 @@ svchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c
|
||||
ch->channel = c;
|
||||
ch->dir = dir;
|
||||
|
||||
if (sndbuf_alloc(b, sc->parent_dmat, SV_MAX_BUFFER) != 0) {
|
||||
if (sndbuf_alloc(b, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
DEB(printf("svchan_init failed\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -211,9 +214,10 @@ static int
|
||||
svchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
||||
{
|
||||
struct sc_chinfo *ch = data;
|
||||
struct sc_info *sc = ch->parent;
|
||||
|
||||
/* user has requested interrupts every blocksize bytes */
|
||||
RANGE(blocksize, SV_MIN_BUFFER, SV_MAX_BUFFER / SV_INTR_PER_BUFFER);
|
||||
RANGE(blocksize, SV_MIN_BLKSZ, sc->bufsz / SV_INTR_PER_BUFFER);
|
||||
sndbuf_resize(ch->buffer, SV_INTR_PER_BUFFER, blocksize);
|
||||
DEB(printf("svchan_setblocksize: %d\n", blocksize));
|
||||
return blocksize;
|
||||
@ -765,11 +769,12 @@ sv_attach(device_t dev) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sc->bufsz = pcm_getbuffersize(dev, 4096, SV_DEFAULT_BUFSZ, 65536);
|
||||
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
|
||||
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
|
||||
/*highaddr*/BUS_SPACE_MAXADDR,
|
||||
/*filter*/NULL, /*filterarg*/NULL,
|
||||
/*maxsize*/SV_MAX_BUFFER, /*nsegments*/1,
|
||||
/*maxsize*/sc->bufsz, /*nsegments*/1,
|
||||
/*maxsegz*/0x3ffff, /*flags*/0,
|
||||
&sc->parent_dmat) != 0) {
|
||||
device_printf(dev, "sv_attach: Unable to create dma tag\n");
|
||||
|
Loading…
Reference in New Issue
Block a user