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