nrelease - fix/improve livecd
[dragonfly.git] / sys / dev / sound / pcm / channel_if.m
CommitLineData
558a398b 1#-
984263bc
MD
2# KOBJ
3#
2a1ad637
FT
4# Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org>
5# Portions Copyright (c) Ryan Beasley <ryan.beasley@gmail.com> - GSoC 2006
6# Copyright (c) 2000 Cameron Grant <cg@FreeBSD.org>
984263bc
MD
7# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28# SUCH DAMAGE.
29#
2a1ad637 30# $FreeBSD: head/sys/dev/sound/pcm/channel_if.m 193640 2009-06-07 19:12:08Z ariff $
984263bc
MD
31#
32
33#include <dev/sound/pcm/sound.h>
34
35INTERFACE channel;
36
37CODE {
38
984263bc
MD
39 static int
40 channel_noreset(kobj_t obj, void *data)
41 {
42 return 0;
43 }
44
45 static int
46 channel_noresetdone(kobj_t obj, void *data)
47 {
48 return 0;
49 }
50
51 static int
52 channel_nofree(kobj_t obj, void *data)
53 {
54 return 1;
55 }
56
57 static u_int32_t
58 channel_nogetptr(kobj_t obj, void *data)
59 {
60 return 0;
61 }
62
63 static int
64 channel_nonotify(kobj_t obj, void *data, u_int32_t changed)
65 {
66 return 0;
67 }
68
2a1ad637
FT
69 static int
70 channel_nogetpeaks(kobj_t obj, void *data, int *lpeak, int *rpeak)
71 {
72 return -1;
73 }
74
75 static int
76 channel_nogetrates(kobj_t obj, void *data, int **rates)
77 {
78 *rates = NULL;
79 return 0;
80 }
81
82 static int
83 channel_nosetfragments(kobj_t obj, void *data, u_int32_t blocksize, u_int32_t blockcount)
84 {
85 return ENOTSUP;
86 }
87
88 static struct pcmchan_matrix *
89 channel_nogetmatrix(kobj_t obj, void *data, u_int32_t format)
90 {
91 format = feeder_matrix_default_format(format);
92 return (feeder_matrix_format_map(format));
93 }
94
95 static int
96 channel_nosetmatrix(kobj_t obj, void *data, struct pcmchan_matrix *m)
97 {
98 return ENOTSUP;
99 }
984263bc
MD
100};
101
102METHOD void* init {
103 kobj_t obj;
104 void *devinfo;
105 struct snd_dbuf *b;
106 struct pcm_channel *c;
107 int dir;
108};
109
110METHOD int free {
111 kobj_t obj;
112 void *data;
113} DEFAULT channel_nofree;
114
115METHOD int reset {
116 kobj_t obj;
117 void *data;
118} DEFAULT channel_noreset;
119
120METHOD int resetdone {
121 kobj_t obj;
122 void *data;
123} DEFAULT channel_noresetdone;
124
2a1ad637 125METHOD int setformat {
984263bc
MD
126 kobj_t obj;
127 void *data;
128 u_int32_t format;
129};
130
131METHOD u_int32_t setspeed {
132 kobj_t obj;
133 void *data;
134 u_int32_t speed;
135};
136
137METHOD u_int32_t setblocksize {
138 kobj_t obj;
139 void *data;
140 u_int32_t blocksize;
141};
142
2a1ad637
FT
143METHOD int setfragments {
144 kobj_t obj;
145 void *data;
146 u_int32_t blocksize;
147 u_int32_t blockcount;
148} DEFAULT channel_nosetfragments;
149
984263bc
MD
150METHOD int trigger {
151 kobj_t obj;
152 void *data;
153 int go;
154};
155
156METHOD u_int32_t getptr {
157 kobj_t obj;
158 void *data;
159} DEFAULT channel_nogetptr;
160
161METHOD struct pcmchan_caps* getcaps {
162 kobj_t obj;
163 void *data;
164};
165
166METHOD int notify {
167 kobj_t obj;
168 void *data;
169 u_int32_t changed;
170} DEFAULT channel_nonotify;
2a1ad637
FT
171
172/**
173 * @brief Retrieve channel peak values
174 *
175 * This function is intended to obtain peak volume values for samples
176 * played/recorded on a channel. Values are on a linear scale from 0 to
177 * 32767. If the channel is monaural, a single value should be recorded
178 * in @c lpeak.
179 *
180 * If hardware support isn't available, the SNDCTL_DSP_GET[IO]PEAKS
181 * operation should return EINVAL. However, we may opt to provide
182 * software support that the user may toggle via sysctl/mixext.
183 *
184 * @param obj standard kobj object (usually @c channel->methods)
185 * @param data driver-specific data (usually @c channel->devinfo)
186 * @param lpeak pointer to store left peak level
187 * @param rpeak pointer to store right peak level
188 *
189 * @retval -1 Error; usually operation isn't supported.
190 * @retval 0 success
191 */
192METHOD int getpeaks {
193 kobj_t obj;
194 void *data;
195 int *lpeak;
196 int *rpeak;
197} DEFAULT channel_nogetpeaks;
198
199/**
200 * @brief Retrieve discrete supported sample rates
201 *
202 * Some cards operate at fixed rates, and this call is intended to retrieve
203 * those rates primarily for when in-kernel rate adjustment is undesirable
204 * (e.g., application wants direct DMA access after setting a channel to run
205 * "uncooked").
206 *
207 * The parameter @c rates is a double pointer which will be reset to
208 * point to an array of supported sample rates. The number of elements
209 * in the array is returned to the caller.
210 *
211 * @param obj standard kobj object (usually @c channel->methods)
212 * @param data driver-specific data (usually @c channel->devinfo)
213 * @param rates rate array pointer
214 *
215 * @return Number of rates in the array
216 */
217METHOD int getrates {
218 kobj_t obj;
219 void *data;
220 int **rates;
221} DEFAULT channel_nogetrates;
222
223METHOD struct pcmchan_matrix * getmatrix {
224 kobj_t obj;
225 void *data;
226 u_int32_t format;
227} DEFAULT channel_nogetmatrix;
228
229METHOD int setmatrix {
230 kobj_t obj;
231 void *data;
232 struct pcmchan_matrix *m;
233} DEFAULT channel_nosetmatrix;