2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2003-09-07 16:28:03 +00:00
|
|
|
* Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
|
1999-09-01 04:08:39 +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, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1999-11-20 16:50:33 +00:00
|
|
|
#include <dev/sound/pcm/sound.h>
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2001-08-23 11:30:52 +00:00
|
|
|
SND_DECLARE_FILE("$FreeBSD$");
|
|
|
|
|
2000-08-20 22:18:56 +00:00
|
|
|
static u_int32_t fk_fmt[] = {
|
|
|
|
AFMT_U8,
|
|
|
|
AFMT_STEREO | AFMT_U8,
|
|
|
|
AFMT_S8,
|
|
|
|
AFMT_STEREO | AFMT_S8,
|
|
|
|
AFMT_S16_LE,
|
|
|
|
AFMT_STEREO | AFMT_S16_LE,
|
|
|
|
AFMT_U16_LE,
|
|
|
|
AFMT_STEREO | AFMT_U16_LE,
|
|
|
|
AFMT_S16_BE,
|
|
|
|
AFMT_STEREO | AFMT_S16_BE,
|
|
|
|
AFMT_U16_BE,
|
|
|
|
AFMT_STEREO | AFMT_U16_BE,
|
|
|
|
0
|
1999-09-01 04:08:39 +00:00
|
|
|
};
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps fk_caps = {0, 1000000, fk_fmt, 0};
|
|
|
|
|
|
|
|
#define FKBUFSZ 4096
|
|
|
|
static char fakebuf[FKBUFSZ];
|
1999-09-01 04:08:39 +00:00
|
|
|
|
|
|
|
/* channel interface */
|
|
|
|
static void *
|
2001-03-24 23:10:29 +00:00
|
|
|
fkchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_setup(b, fakebuf, FKBUFSZ);
|
1999-09-01 04:08:39 +00:00
|
|
|
return (void *)0xbabef00d;
|
|
|
|
}
|
|
|
|
|
2001-03-16 20:58:44 +00:00
|
|
|
static int
|
|
|
|
fkchan_free(kobj_t obj, void *data)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
fkchan_setformat(kobj_t obj, void *data, u_int32_t format)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
fkchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
return speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
fkchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
return blocksize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
fkchan_trigger(kobj_t obj, void *data, int go)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
fkchan_getptr(kobj_t obj, void *data)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps *
|
2000-12-18 01:36:41 +00:00
|
|
|
fkchan_getcaps(kobj_t obj, void *data)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
return &fk_caps;
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static kobj_method_t fkchan_methods[] = {
|
|
|
|
KOBJMETHOD(channel_init, fkchan_init),
|
2001-03-16 20:58:44 +00:00
|
|
|
KOBJMETHOD(channel_free, fkchan_free),
|
2000-12-18 01:36:41 +00:00
|
|
|
KOBJMETHOD(channel_setformat, fkchan_setformat),
|
|
|
|
KOBJMETHOD(channel_setspeed, fkchan_setspeed),
|
|
|
|
KOBJMETHOD(channel_setblocksize, fkchan_setblocksize),
|
|
|
|
KOBJMETHOD(channel_trigger, fkchan_trigger),
|
|
|
|
KOBJMETHOD(channel_getptr, fkchan_getptr),
|
|
|
|
KOBJMETHOD(channel_getcaps, fkchan_getcaps),
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
CHANNEL_DECLARE(fkchan);
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
struct pcm_channel *
|
|
|
|
fkchan_setup(device_t dev)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2001-03-24 23:10:29 +00:00
|
|
|
struct snddev_info *d = device_get_softc(dev);
|
|
|
|
struct pcm_channel *c;
|
|
|
|
|
2003-02-19 05:47:46 +00:00
|
|
|
c = malloc(sizeof(*c), M_DEVBUF, M_WAITOK);
|
|
|
|
c->methods = kobj_create(&fkchan_class, M_DEVBUF, M_WAITOK);
|
2001-05-27 17:22:00 +00:00
|
|
|
c->parentsnddev = d;
|
2001-03-24 23:10:29 +00:00
|
|
|
snprintf(c->name, CHN_NAMELEN, "%s:fake", device_get_nameunit(dev));
|
|
|
|
|
|
|
|
return c;
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
2000-12-18 01:36:41 +00:00
|
|
|
|
|
|
|
int
|
2001-03-24 23:10:29 +00:00
|
|
|
fkchan_kill(struct pcm_channel *c)
|
2000-12-18 01:36:41 +00:00
|
|
|
{
|
|
|
|
kobj_delete(c->methods, M_DEVBUF);
|
|
|
|
c->methods = NULL;
|
2001-03-24 23:10:29 +00:00
|
|
|
free(c, M_DEVBUF);
|
2000-12-18 01:36:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|