1139749Simp#- 273765Scg# KOBJ 370134Scg# 4193640Sariff# Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org> 5193640Sariff# Portions Copyright (c) Ryan Beasley <ryan.beasley@gmail.com> - GSoC 2006 6193640Sariff# Copyright (c) 2000 Cameron Grant <cg@FreeBSD.org> 770134Scg# All rights reserved. 870134Scg# 970134Scg# Redistribution and use in source and binary forms, with or without 1070134Scg# modification, are permitted provided that the following conditions 1170134Scg# are met: 1270134Scg# 1. Redistributions of source code must retain the above copyright 1370134Scg# notice, this list of conditions and the following disclaimer. 1470134Scg# 2. Redistributions in binary form must reproduce the above copyright 1570134Scg# notice, this list of conditions and the following disclaimer in the 1670134Scg# documentation and/or other materials provided with the distribution. 1770134Scg# 1870134Scg# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1970134Scg# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2070134Scg# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2170134Scg# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2270134Scg# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2370134Scg# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2470134Scg# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2570134Scg# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2670134Scg# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2770134Scg# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2870134Scg# SUCH DAMAGE. 2970134Scg# 3070134Scg# $FreeBSD: releng/10.2/sys/dev/sound/pcm/channel_if.m 193640 2009-06-07 19:12:08Z ariff $ 3170134Scg# 3270134Scg 3370134Scg#include <dev/sound/pcm/sound.h> 3470134Scg 3570134ScgINTERFACE channel; 3670134Scg 3770134ScgCODE { 3870134Scg 3970134Scg static int 4070134Scg channel_noreset(kobj_t obj, void *data) 4170134Scg { 4270134Scg return 0; 4370134Scg } 4470134Scg 4570134Scg static int 4670134Scg channel_noresetdone(kobj_t obj, void *data) 4770134Scg { 4870134Scg return 0; 4970134Scg } 5070134Scg 5170134Scg static int 5270134Scg channel_nofree(kobj_t obj, void *data) 5370134Scg { 5470134Scg return 1; 5570134Scg } 5670134Scg 5777269Scg static u_int32_t 5877269Scg channel_nogetptr(kobj_t obj, void *data) 5977269Scg { 6077269Scg return 0; 6177269Scg } 6277269Scg 6377269Scg static int 6477269Scg channel_nonotify(kobj_t obj, void *data, u_int32_t changed) 6577269Scg { 6677269Scg return 0; 6777269Scg } 6877269Scg 69162588Snetchild static int 70162588Snetchild channel_nogetpeaks(kobj_t obj, void *data, int *lpeak, int *rpeak) 71162588Snetchild { 72162588Snetchild return -1; 73162588Snetchild } 74162588Snetchild 75162588Snetchild static int 76162588Snetchild channel_nogetrates(kobj_t obj, void *data, int **rates) 77162588Snetchild { 78162588Snetchild *rates = NULL; 79162588Snetchild return 0; 80162588Snetchild } 81162588Snetchild 82167645Sariff static int 83167645Sariff channel_nosetfragments(kobj_t obj, void *data, u_int32_t blocksize, u_int32_t blockcount) 84167645Sariff { 85193640Sariff return ENOTSUP; 86167645Sariff } 87167645Sariff 88193640Sariff static struct pcmchan_matrix * 89193640Sariff channel_nogetmatrix(kobj_t obj, void *data, u_int32_t format) 90193640Sariff { 91193640Sariff format = feeder_matrix_default_format(format); 92193640Sariff return (feeder_matrix_format_map(format)); 93193640Sariff } 94193640Sariff 95193640Sariff static int 96193640Sariff channel_nosetmatrix(kobj_t obj, void *data, struct pcmchan_matrix *m) 97193640Sariff { 98193640Sariff return ENOTSUP; 99193640Sariff } 10070134Scg}; 10170134Scg 10270134ScgMETHOD void* init { 10370134Scg kobj_t obj; 10470134Scg void *devinfo; 10574763Scg struct snd_dbuf *b; 10674763Scg struct pcm_channel *c; 10770134Scg int dir; 10870134Scg}; 10970134Scg 11070134ScgMETHOD int free { 11170134Scg kobj_t obj; 11270134Scg void *data; 11370134Scg} DEFAULT channel_nofree; 11470134Scg 11570134ScgMETHOD int reset { 11670134Scg kobj_t obj; 11770134Scg void *data; 11870134Scg} DEFAULT channel_noreset; 11970134Scg 12070134ScgMETHOD int resetdone { 12170134Scg kobj_t obj; 12270134Scg void *data; 12370134Scg} DEFAULT channel_noresetdone; 12470134Scg 125193640SariffMETHOD int setformat { 12670134Scg kobj_t obj; 12770134Scg void *data; 12870134Scg u_int32_t format; 12970134Scg}; 13070134Scg 13170134ScgMETHOD u_int32_t setspeed { 13270134Scg kobj_t obj; 13370134Scg void *data; 13470134Scg u_int32_t speed; 13570134Scg}; 13670134Scg 13770134ScgMETHOD u_int32_t setblocksize { 13870134Scg kobj_t obj; 13970134Scg void *data; 14070134Scg u_int32_t blocksize; 14170134Scg}; 14270134Scg 143167645SariffMETHOD int setfragments { 144167645Sariff kobj_t obj; 145167645Sariff void *data; 146167645Sariff u_int32_t blocksize; 147167645Sariff u_int32_t blockcount; 148167645Sariff} DEFAULT channel_nosetfragments; 149167645Sariff 15070134ScgMETHOD int trigger { 15170134Scg kobj_t obj; 15270134Scg void *data; 15370134Scg int go; 15470134Scg}; 15570134Scg 15670134ScgMETHOD u_int32_t getptr { 15770134Scg kobj_t obj; 15870134Scg void *data; 15977269Scg} DEFAULT channel_nogetptr; 16070134Scg 16174763ScgMETHOD struct pcmchan_caps* getcaps { 16270134Scg kobj_t obj; 16370134Scg void *data; 16470134Scg}; 16570134Scg 16677269ScgMETHOD int notify { 16777269Scg kobj_t obj; 16877269Scg void *data; 16977269Scg u_int32_t changed; 17077269Scg} DEFAULT channel_nonotify; 171162588Snetchild 172162588Snetchild/** 173162588Snetchild * @brief Retrieve channel peak values 174162588Snetchild * 175162588Snetchild * This function is intended to obtain peak volume values for samples 176162588Snetchild * played/recorded on a channel. Values are on a linear scale from 0 to 177162588Snetchild * 32767. If the channel is monaural, a single value should be recorded 178162588Snetchild * in @c lpeak. 179162588Snetchild * 180162588Snetchild * If hardware support isn't available, the SNDCTL_DSP_GET[IO]PEAKS 181162588Snetchild * operation should return EINVAL. However, we may opt to provide 182162588Snetchild * software support that the user may toggle via sysctl/mixext. 183162588Snetchild * 184162588Snetchild * @param obj standard kobj object (usually @c channel->methods) 185162588Snetchild * @param data driver-specific data (usually @c channel->devinfo) 186162588Snetchild * @param lpeak pointer to store left peak level 187162588Snetchild * @param rpeak pointer to store right peak level 188162588Snetchild * 189162588Snetchild * @retval -1 Error; usually operation isn't supported. 190162588Snetchild * @retval 0 success 191162588Snetchild */ 192162588SnetchildMETHOD int getpeaks { 193162588Snetchild kobj_t obj; 194162588Snetchild void *data; 195162588Snetchild int *lpeak; 196162588Snetchild int *rpeak; 197162588Snetchild} DEFAULT channel_nogetpeaks; 198162588Snetchild 199162588Snetchild/** 200162588Snetchild * @brief Retrieve discrete supported sample rates 201162588Snetchild * 202162588Snetchild * Some cards operate at fixed rates, and this call is intended to retrieve 203162588Snetchild * those rates primarily for when in-kernel rate adjustment is undesirable 204162588Snetchild * (e.g., application wants direct DMA access after setting a channel to run 205162588Snetchild * "uncooked"). 206162588Snetchild * 207162588Snetchild * The parameter @c rates is a double pointer which will be reset to 208162588Snetchild * point to an array of supported sample rates. The number of elements 209162588Snetchild * in the array is returned to the caller. 210162588Snetchild * 211162588Snetchild * @param obj standard kobj object (usually @c channel->methods) 212162588Snetchild * @param data driver-specific data (usually @c channel->devinfo) 213162588Snetchild * @param rates rate array pointer 214162588Snetchild * 215162588Snetchild * @return Number of rates in the array 216162588Snetchild */ 217162588SnetchildMETHOD int getrates { 218162588Snetchild kobj_t obj; 219162588Snetchild void *data; 220162588Snetchild int **rates; 221162588Snetchild} DEFAULT channel_nogetrates; 222193640Sariff 223193640SariffMETHOD struct pcmchan_matrix * getmatrix { 224193640Sariff kobj_t obj; 225193640Sariff void *data; 226193640Sariff u_int32_t format; 227193640Sariff} DEFAULT channel_nogetmatrix; 228193640Sariff 229193640SariffMETHOD int setmatrix { 230193640Sariff kobj_t obj; 231193640Sariff void *data; 232193640Sariff struct pcmchan_matrix *m; 233193640Sariff} DEFAULT channel_nosetmatrix; 234