Remove some duplicate FreeBSD CVS IDs, move some IDs to better places.
[dragonfly.git] / sys / dev / sound / pcm / fake.c
CommitLineData
984263bc
MD
1/*
2 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
1de703da
MD
25 *
26 * $FreeBSD: src/sys/dev/sound/pcm/fake.c,v 1.4.2.5 2002/04/22 15:49:36 cg Exp $
27 * $DragonFly: src/sys/dev/sound/pcm/fake.c,v 1.2 2003/06/17 04:28:31 dillon Exp $
984263bc
MD
28 */
29
30#include <dev/sound/pcm/sound.h>
31
1de703da 32SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/fake.c,v 1.2 2003/06/17 04:28:31 dillon Exp $");
984263bc
MD
33
34static u_int32_t fk_fmt[] = {
35 AFMT_U8,
36 AFMT_STEREO | AFMT_U8,
37 AFMT_S8,
38 AFMT_STEREO | AFMT_S8,
39 AFMT_S16_LE,
40 AFMT_STEREO | AFMT_S16_LE,
41 AFMT_U16_LE,
42 AFMT_STEREO | AFMT_U16_LE,
43 AFMT_S16_BE,
44 AFMT_STEREO | AFMT_S16_BE,
45 AFMT_U16_BE,
46 AFMT_STEREO | AFMT_U16_BE,
47 0
48};
49static struct pcmchan_caps fk_caps = {0, 1000000, fk_fmt, 0};
50
51#define FKBUFSZ 4096
52static char fakebuf[FKBUFSZ];
53
54/* channel interface */
55static void *
56fkchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
57{
58 sndbuf_setup(b, fakebuf, FKBUFSZ);
59 return (void *)0xbabef00d;
60}
61
62static int
63fkchan_free(kobj_t obj, void *data)
64{
65 return 0;
66}
67
68static int
69fkchan_setformat(kobj_t obj, void *data, u_int32_t format)
70{
71 return 0;
72}
73
74static int
75fkchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
76{
77 return speed;
78}
79
80static int
81fkchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
82{
83 return blocksize;
84}
85
86static int
87fkchan_trigger(kobj_t obj, void *data, int go)
88{
89 return 0;
90}
91
92static int
93fkchan_getptr(kobj_t obj, void *data)
94{
95 return 0;
96}
97
98static struct pcmchan_caps *
99fkchan_getcaps(kobj_t obj, void *data)
100{
101 return &fk_caps;
102}
103
104static kobj_method_t fkchan_methods[] = {
105 KOBJMETHOD(channel_init, fkchan_init),
106 KOBJMETHOD(channel_free, fkchan_free),
107 KOBJMETHOD(channel_setformat, fkchan_setformat),
108 KOBJMETHOD(channel_setspeed, fkchan_setspeed),
109 KOBJMETHOD(channel_setblocksize, fkchan_setblocksize),
110 KOBJMETHOD(channel_trigger, fkchan_trigger),
111 KOBJMETHOD(channel_getptr, fkchan_getptr),
112 KOBJMETHOD(channel_getcaps, fkchan_getcaps),
113 { 0, 0 }
114};
115CHANNEL_DECLARE(fkchan);
116
117struct pcm_channel *
118fkchan_setup(device_t dev)
119{
120 struct snddev_info *d = device_get_softc(dev);
121 struct pcm_channel *c;
122
123 c = malloc(sizeof(*c), M_DEVBUF, M_WAITOK);
124 c->methods = kobj_create(&fkchan_class, M_DEVBUF, M_WAITOK);
125 c->parentsnddev = d;
126 snprintf(c->name, CHN_NAMELEN, "%s:fake", device_get_nameunit(dev));
127
128 return c;
129}
130
131int
132fkchan_kill(struct pcm_channel *c)
133{
134 kobj_delete(c->methods, M_DEVBUF);
135 c->methods = NULL;
136 free(c, M_DEVBUF);
137 return 0;
138}
139
140