Home | History | Annotate | Line # | Download | only in broadcom
bcm2835_vcaudio.c revision 1.7
      1  1.7     skrll /* $NetBSD: bcm2835_vcaudio.c,v 1.7 2014/10/06 06:59:20 skrll Exp $ */
      2  1.1  jmcneill 
      3  1.1  jmcneill /*-
      4  1.1  jmcneill  * Copyright (c) 2013 Jared D. McNeill <jmcneill (at) invisible.ca>
      5  1.1  jmcneill  * All rights reserved.
      6  1.1  jmcneill  *
      7  1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      8  1.1  jmcneill  * modification, are permitted provided that the following conditions
      9  1.1  jmcneill  * are met:
     10  1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     11  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     12  1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15  1.1  jmcneill  *
     16  1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.1  jmcneill  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.1  jmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.1  jmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.1  jmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.1  jmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.1  jmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.1  jmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.1  jmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.1  jmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1  jmcneill  * POSSIBILITY OF SUCH DAMAGE.
     27  1.1  jmcneill  */
     28  1.1  jmcneill 
     29  1.1  jmcneill /*
     30  1.1  jmcneill  * VideoCore audio interface
     31  1.1  jmcneill  */
     32  1.1  jmcneill 
     33  1.1  jmcneill #include <sys/cdefs.h>
     34  1.7     skrll __KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.7 2014/10/06 06:59:20 skrll Exp $");
     35  1.1  jmcneill 
     36  1.1  jmcneill #include <sys/param.h>
     37  1.1  jmcneill #include <sys/types.h>
     38  1.1  jmcneill #include <sys/systm.h>
     39  1.1  jmcneill #include <sys/device.h>
     40  1.1  jmcneill #include <sys/conf.h>
     41  1.1  jmcneill #include <sys/bus.h>
     42  1.1  jmcneill #include <sys/kmem.h>
     43  1.1  jmcneill 
     44  1.1  jmcneill #include <sys/audioio.h>
     45  1.1  jmcneill #include <dev/audio_if.h>
     46  1.1  jmcneill #include <dev/auconv.h>
     47  1.1  jmcneill 
     48  1.1  jmcneill #include <interface/compat/vchi_bsd.h>
     49  1.1  jmcneill #include <interface/vchiq_arm/vchiq_netbsd.h>
     50  1.1  jmcneill #include <interface/vchi/vchi.h>
     51  1.1  jmcneill 
     52  1.1  jmcneill #include "bcm2835_vcaudioreg.h"
     53  1.1  jmcneill 
     54  1.1  jmcneill #define vol2pct(vol)	(((vol) * 100) / 255)
     55  1.1  jmcneill 
     56  1.1  jmcneill enum {
     57  1.1  jmcneill 	VCAUDIO_OUTPUT_CLASS,
     58  1.1  jmcneill 	VCAUDIO_INPUT_CLASS,
     59  1.1  jmcneill 	VCAUDIO_OUTPUT_MASTER_VOLUME,
     60  1.1  jmcneill 	VCAUDIO_INPUT_DAC_VOLUME,
     61  1.1  jmcneill 	VCAUDIO_ENUM_LAST,
     62  1.1  jmcneill };
     63  1.1  jmcneill 
     64  1.1  jmcneill enum vcaudio_dest {
     65  1.1  jmcneill 	VCAUDIO_DEST_AUTO = 0,
     66  1.1  jmcneill 	VCAUDIO_DEST_HP = 1,
     67  1.1  jmcneill 	VCAUDIO_DEST_HDMI = 2,
     68  1.1  jmcneill };
     69  1.1  jmcneill 
     70  1.7     skrll 
     71  1.7     skrll /*
     72  1.7     skrll  * Standard message size is 4000 bytes and VCHIQ can accept 16 messages.
     73  1.7     skrll  *
     74  1.7     skrll  * 4000 bytes of 16bit 48kHz stereo is approximately 21ms.
     75  1.7     skrll  *
     76  1.7     skrll  * We get complete messages at ~10ms intervals.
     77  1.7     skrll  *
     78  1.7     skrll  * Setting blocksize to 2 x 4000 means that we send approx 42ms of audio. We
     79  1.7     skrll  * prefill by two blocks before starting audio meaning we have 83ms of latency.
     80  1.7     skrll  */
     81  1.7     skrll 
     82  1.7     skrll #define VCAUDIO_MSGSIZE		4000
     83  1.7     skrll #define VCAUDIO_NUMMSGS		2
     84  1.7     skrll #define VCAUDIO_BLOCKSIZE	(VCAUDIO_MSGSIZE * VCAUDIO_NUMMSGS)
     85  1.7     skrll #define VCAUDIO_BUFFERSIZE	128000
     86  1.7     skrll #define VCAUDIO_PREFILLCOUNT	2
     87  1.1  jmcneill 
     88  1.1  jmcneill struct vcaudio_softc {
     89  1.1  jmcneill 	device_t			sc_dev;
     90  1.1  jmcneill 	device_t			sc_audiodev;
     91  1.1  jmcneill 
     92  1.7     skrll 	lwp_t				*sc_lwp;
     93  1.7     skrll 
     94  1.1  jmcneill 	kmutex_t			sc_lock;
     95  1.1  jmcneill 	kmutex_t			sc_intr_lock;
     96  1.7     skrll 	kcondvar_t			sc_datacv;
     97  1.3     skrll 
     98  1.3     skrll 	kmutex_t			sc_msglock;
     99  1.3     skrll 	kcondvar_t			sc_msgcv;
    100  1.1  jmcneill 
    101  1.1  jmcneill 	struct audio_format		sc_format;
    102  1.1  jmcneill 	struct audio_encoding_set	*sc_encodings;
    103  1.1  jmcneill 
    104  1.1  jmcneill 	void				(*sc_pint)(void *);
    105  1.1  jmcneill 	void				*sc_pintarg;
    106  1.1  jmcneill 	audio_params_t			sc_pparam;
    107  1.1  jmcneill 	bool				sc_started;
    108  1.7     skrll 	int				sc_pblkcnt;	// prefill block count
    109  1.7     skrll 	int				sc_abytes;	// available bytes
    110  1.7     skrll 	int				sc_pbytes;	// played bytes
    111  1.1  jmcneill 	off_t				sc_ppos;
    112  1.1  jmcneill 	void				*sc_pstart;
    113  1.1  jmcneill 	void				*sc_pend;
    114  1.1  jmcneill 	int				sc_pblksize;
    115  1.1  jmcneill 
    116  1.3     skrll 	bool				sc_msgdone;
    117  1.1  jmcneill 	int				sc_success;
    118  1.1  jmcneill 
    119  1.1  jmcneill 	VCHI_INSTANCE_T			sc_instance;
    120  1.1  jmcneill 	VCHI_CONNECTION_T		sc_connection;
    121  1.1  jmcneill 	VCHI_SERVICE_HANDLE_T		sc_service;
    122  1.1  jmcneill 
    123  1.6  jmcneill 	short				sc_peer_version;
    124  1.6  jmcneill 
    125  1.1  jmcneill 	int				sc_volume;
    126  1.1  jmcneill 	enum vcaudio_dest		sc_dest;
    127  1.1  jmcneill };
    128  1.1  jmcneill 
    129  1.1  jmcneill static int	vcaudio_match(device_t, cfdata_t, void *);
    130  1.1  jmcneill static void	vcaudio_attach(device_t, device_t, void *);
    131  1.1  jmcneill static int	vcaudio_rescan(device_t, const char *, const int *);
    132  1.1  jmcneill static void	vcaudio_childdet(device_t, device_t);
    133  1.1  jmcneill 
    134  1.1  jmcneill static int	vcaudio_init(struct vcaudio_softc *);
    135  1.1  jmcneill static void	vcaudio_service_callback(void *,
    136  1.7     skrll     const VCHI_CALLBACK_REASON_T, void *);
    137  1.7     skrll static int	vcaudio_msg_sync(struct vcaudio_softc *, VC_AUDIO_MSG_T *,
    138  1.7     skrll     size_t);
    139  1.7     skrll static void	vcaudio_worker(void *);
    140  1.1  jmcneill 
    141  1.1  jmcneill static int	vcaudio_open(void *, int);
    142  1.1  jmcneill static void	vcaudio_close(void *);
    143  1.1  jmcneill static int	vcaudio_query_encoding(void *, struct audio_encoding *);
    144  1.1  jmcneill static int	vcaudio_set_params(void *, int, int,
    145  1.7     skrll     audio_params_t *, audio_params_t *,
    146  1.7     skrll     stream_filter_list_t *, stream_filter_list_t *);
    147  1.1  jmcneill static int	vcaudio_halt_output(void *);
    148  1.1  jmcneill static int	vcaudio_halt_input(void *);
    149  1.1  jmcneill static int	vcaudio_set_port(void *, mixer_ctrl_t *);
    150  1.1  jmcneill static int	vcaudio_get_port(void *, mixer_ctrl_t *);
    151  1.1  jmcneill static int	vcaudio_query_devinfo(void *, mixer_devinfo_t *);
    152  1.1  jmcneill static int	vcaudio_getdev(void *, struct audio_device *);
    153  1.1  jmcneill static int	vcaudio_get_props(void *);
    154  1.7     skrll 
    155  1.7     skrll static int	vcaudio_round_blocksize(void *, int, int,
    156  1.7     skrll     const audio_params_t *);
    157  1.1  jmcneill static size_t	vcaudio_round_buffersize(void *, int, size_t);
    158  1.7     skrll 
    159  1.1  jmcneill static int	vcaudio_trigger_output(void *, void *, void *, int,
    160  1.7     skrll     void (*)(void *), void *, const audio_params_t *);
    161  1.1  jmcneill static int	vcaudio_trigger_input(void *, void *, void *, int,
    162  1.7     skrll     void (*)(void *), void *, const audio_params_t *);
    163  1.7     skrll 
    164  1.1  jmcneill static void	vcaudio_get_locks(void *, kmutex_t **, kmutex_t **);
    165  1.1  jmcneill 
    166  1.1  jmcneill static const struct audio_hw_if vcaudio_hw_if = {
    167  1.1  jmcneill 	.open = vcaudio_open,
    168  1.1  jmcneill 	.close = vcaudio_close,
    169  1.1  jmcneill 	.query_encoding = vcaudio_query_encoding,
    170  1.1  jmcneill 	.set_params = vcaudio_set_params,
    171  1.1  jmcneill 	.halt_output = vcaudio_halt_output,
    172  1.1  jmcneill 	.halt_input = vcaudio_halt_input,
    173  1.1  jmcneill 	.getdev = vcaudio_getdev,
    174  1.1  jmcneill 	.set_port = vcaudio_set_port,
    175  1.1  jmcneill 	.get_port = vcaudio_get_port,
    176  1.1  jmcneill 	.query_devinfo = vcaudio_query_devinfo,
    177  1.1  jmcneill 	.get_props = vcaudio_get_props,
    178  1.1  jmcneill 	.round_blocksize = vcaudio_round_blocksize,
    179  1.1  jmcneill 	.round_buffersize = vcaudio_round_buffersize,
    180  1.1  jmcneill 	.trigger_output = vcaudio_trigger_output,
    181  1.1  jmcneill 	.trigger_input = vcaudio_trigger_input,
    182  1.1  jmcneill 	.get_locks = vcaudio_get_locks,
    183  1.1  jmcneill };
    184  1.1  jmcneill 
    185  1.1  jmcneill CFATTACH_DECL2_NEW(vcaudio, sizeof(struct vcaudio_softc),
    186  1.7     skrll     vcaudio_match, vcaudio_attach, NULL, NULL, vcaudio_rescan,
    187  1.7     skrll     vcaudio_childdet);
    188  1.1  jmcneill 
    189  1.1  jmcneill static int
    190  1.1  jmcneill vcaudio_match(device_t parent, cfdata_t match, void *aux)
    191  1.1  jmcneill {
    192  1.1  jmcneill 	struct vchiq_attach_args *vaa = aux;
    193  1.1  jmcneill 
    194  1.1  jmcneill 	return !strcmp(vaa->vaa_name, "AUDS");
    195  1.1  jmcneill }
    196  1.1  jmcneill 
    197  1.1  jmcneill static void
    198  1.1  jmcneill vcaudio_attach(device_t parent, device_t self, void *aux)
    199  1.1  jmcneill {
    200  1.1  jmcneill 	struct vcaudio_softc *sc = device_private(self);
    201  1.1  jmcneill 	int error;
    202  1.1  jmcneill 
    203  1.1  jmcneill 	sc->sc_dev = self;
    204  1.1  jmcneill 	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
    205  1.3     skrll 	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_NONE);
    206  1.3     skrll 	mutex_init(&sc->sc_msglock, MUTEX_DEFAULT, IPL_NONE);
    207  1.7     skrll 	cv_init(&sc->sc_msgcv, "msg");
    208  1.7     skrll 	cv_init(&sc->sc_datacv, "data");
    209  1.3     skrll 	sc->sc_success = -1;
    210  1.7     skrll 
    211  1.7     skrll 	error = kthread_create(PRI_BIO, KTHREAD_MPSAFE, NULL, vcaudio_worker,
    212  1.7     skrll 	    sc, &sc->sc_lwp, "vcaudio");
    213  1.1  jmcneill 	if (error) {
    214  1.7     skrll 		aprint_error(": couldn't create thread (%d)\n", error);
    215  1.1  jmcneill 		return;
    216  1.1  jmcneill 	}
    217  1.1  jmcneill 
    218  1.1  jmcneill 	aprint_naive("\n");
    219  1.7     skrll 	aprint_normal(": auds\n");
    220  1.7     skrll 
    221  1.7     skrll 	error = vcaudio_rescan(self, NULL, NULL);
    222  1.7     skrll 	if (error)
    223  1.7     skrll 		aprint_error_dev(self, "not configured\n");
    224  1.1  jmcneill 
    225  1.1  jmcneill }
    226  1.1  jmcneill 
    227  1.1  jmcneill static int
    228  1.1  jmcneill vcaudio_rescan(device_t self, const char *ifattr, const int *locs)
    229  1.1  jmcneill {
    230  1.1  jmcneill 	struct vcaudio_softc *sc = device_private(self);
    231  1.6  jmcneill 	int error;
    232  1.1  jmcneill 
    233  1.1  jmcneill 	if (ifattr_match(ifattr, "audiobus") && sc->sc_audiodev == NULL) {
    234  1.6  jmcneill 		error = vcaudio_init(sc);
    235  1.7     skrll 		if (error) {
    236  1.6  jmcneill 			return error;
    237  1.7     skrll 		}
    238  1.6  jmcneill 
    239  1.1  jmcneill 		sc->sc_audiodev = audio_attach_mi(&vcaudio_hw_if,
    240  1.1  jmcneill 		    sc, sc->sc_dev);
    241  1.1  jmcneill 	}
    242  1.1  jmcneill 	return 0;
    243  1.1  jmcneill }
    244  1.1  jmcneill 
    245  1.1  jmcneill static void
    246  1.1  jmcneill vcaudio_childdet(device_t self, device_t child)
    247  1.1  jmcneill {
    248  1.1  jmcneill 	struct vcaudio_softc *sc = device_private(self);
    249  1.1  jmcneill 
    250  1.1  jmcneill 	if (sc->sc_audiodev == child)
    251  1.1  jmcneill 		sc->sc_audiodev = NULL;
    252  1.1  jmcneill }
    253  1.1  jmcneill 
    254  1.1  jmcneill static int
    255  1.1  jmcneill vcaudio_init(struct vcaudio_softc *sc)
    256  1.1  jmcneill {
    257  1.1  jmcneill 	VC_AUDIO_MSG_T msg;
    258  1.1  jmcneill 	int error;
    259  1.1  jmcneill 
    260  1.1  jmcneill 	sc->sc_volume = 128;
    261  1.1  jmcneill 	sc->sc_dest = VCAUDIO_DEST_AUTO;
    262  1.1  jmcneill 
    263  1.1  jmcneill 	sc->sc_format.mode = AUMODE_PLAY|AUMODE_RECORD;
    264  1.1  jmcneill 	sc->sc_format.encoding = AUDIO_ENCODING_SLINEAR_LE;
    265  1.1  jmcneill 	sc->sc_format.validbits = 16;
    266  1.1  jmcneill 	sc->sc_format.precision = 16;
    267  1.1  jmcneill 	sc->sc_format.channels = 2;
    268  1.1  jmcneill 	sc->sc_format.channel_mask = AUFMT_STEREO;
    269  1.1  jmcneill 	sc->sc_format.frequency_type = 0;
    270  1.4  jmcneill 	sc->sc_format.frequency[0] = 48000;
    271  1.1  jmcneill 	sc->sc_format.frequency[1] = 48000;
    272  1.2     skrll 
    273  1.1  jmcneill 	error = auconv_create_encodings(&sc->sc_format, 1, &sc->sc_encodings);
    274  1.1  jmcneill 	if (error) {
    275  1.1  jmcneill 		aprint_error_dev(sc->sc_dev,
    276  1.1  jmcneill 		    "couldn't create encodings (error=%d)\n", error);
    277  1.1  jmcneill 		return error;
    278  1.1  jmcneill 	}
    279  1.1  jmcneill 
    280  1.1  jmcneill 	error = vchi_initialise(&sc->sc_instance);
    281  1.1  jmcneill 	if (error) {
    282  1.7     skrll 		aprint_error_dev(sc->sc_dev,
    283  1.7     skrll 		    "couldn't init vchi instance (%d)\n", error);
    284  1.1  jmcneill 		return EIO;
    285  1.1  jmcneill 	}
    286  1.1  jmcneill 
    287  1.1  jmcneill 	error = vchi_connect(NULL, 0, sc->sc_instance);
    288  1.1  jmcneill 	if (error) {
    289  1.7     skrll 		aprint_error_dev(sc->sc_dev,
    290  1.7     skrll 		    "couldn't connect vchi (%d)\n", error);
    291  1.1  jmcneill 		return EIO;
    292  1.1  jmcneill 	}
    293  1.1  jmcneill 
    294  1.1  jmcneill 	SERVICE_CREATION_T setup = {
    295  1.1  jmcneill 		.version = VCHI_VERSION(VC_AUDIOSERV_VER),
    296  1.1  jmcneill 		.service_id = VC_AUDIO_SERVER_NAME,
    297  1.1  jmcneill 		.connection = &sc->sc_connection,
    298  1.1  jmcneill 		.rx_fifo_size = 0,
    299  1.1  jmcneill 		.tx_fifo_size = 0,
    300  1.1  jmcneill 		.callback = vcaudio_service_callback,
    301  1.1  jmcneill 		.callback_param = sc,
    302  1.1  jmcneill 		.want_unaligned_bulk_rx = 1,
    303  1.1  jmcneill 		.want_unaligned_bulk_tx = 1,
    304  1.1  jmcneill 		.want_crc = 0,
    305  1.1  jmcneill 	};
    306  1.1  jmcneill 
    307  1.1  jmcneill 	error = vchi_service_open(sc->sc_instance, &setup, &sc->sc_service);
    308  1.1  jmcneill 	if (error) {
    309  1.7     skrll 		aprint_error_dev(sc->sc_dev, "couldn't open service (%d)\n",
    310  1.1  jmcneill 		    error);
    311  1.1  jmcneill 		return EIO;
    312  1.1  jmcneill 	}
    313  1.1  jmcneill 
    314  1.6  jmcneill 	vchi_get_peer_version(sc->sc_service, &sc->sc_peer_version);
    315  1.6  jmcneill 
    316  1.6  jmcneill 	if (sc->sc_peer_version < 2) {
    317  1.6  jmcneill 		aprint_error_dev(sc->sc_dev,
    318  1.6  jmcneill 		    "peer version (%d) is less than the required version (2)\n",
    319  1.6  jmcneill 		    sc->sc_peer_version);
    320  1.6  jmcneill 		return EINVAL;
    321  1.6  jmcneill 	}
    322  1.6  jmcneill 
    323  1.1  jmcneill 	memset(&msg, 0, sizeof(msg));
    324  1.1  jmcneill 	msg.type = VC_AUDIO_MSG_TYPE_OPEN;
    325  1.1  jmcneill 	error = vchi_msg_queue(sc->sc_service, &msg, sizeof(msg),
    326  1.1  jmcneill 	    VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
    327  1.1  jmcneill 	if (error) {
    328  1.7     skrll 		aprint_error_dev(sc->sc_dev,
    329  1.7     skrll 		    "couldn't send OPEN message (%d)\n", error);
    330  1.1  jmcneill 	}
    331  1.1  jmcneill 
    332  1.1  jmcneill 	memset(&msg, 0, sizeof(msg));
    333  1.4  jmcneill 	msg.type = VC_AUDIO_MSG_TYPE_CONFIG;
    334  1.4  jmcneill 	msg.u.config.channels = 2;
    335  1.4  jmcneill 	msg.u.config.samplerate = 48000;
    336  1.4  jmcneill 	msg.u.config.bps = 16;
    337  1.4  jmcneill 	error = vcaudio_msg_sync(sc, &msg, sizeof(msg));
    338  1.4  jmcneill 	if (error) {
    339  1.7     skrll 		aprint_error_dev(sc->sc_dev,
    340  1.7     skrll 		    "couldn't send CONFIG message (%d)\n", error);
    341  1.4  jmcneill 	}
    342  1.4  jmcneill 
    343  1.4  jmcneill 	memset(&msg, 0, sizeof(msg));
    344  1.1  jmcneill 	msg.type = VC_AUDIO_MSG_TYPE_CONTROL;
    345  1.1  jmcneill 	msg.u.control.volume = vol2pct(sc->sc_volume);
    346  1.1  jmcneill 	msg.u.control.dest = VCAUDIO_DEST_AUTO;
    347  1.1  jmcneill 	error = vcaudio_msg_sync(sc, &msg, sizeof(msg));
    348  1.1  jmcneill 	if (error) {
    349  1.7     skrll 		aprint_error_dev(sc->sc_dev,
    350  1.7     skrll 		    "couldn't send CONTROL message (%d)\n", error);
    351  1.1  jmcneill 	}
    352  1.7     skrll 
    353  1.1  jmcneill 	vchi_service_release(sc->sc_service);
    354  1.1  jmcneill 
    355  1.1  jmcneill 	return 0;
    356  1.1  jmcneill }
    357  1.1  jmcneill 
    358  1.1  jmcneill static void
    359  1.1  jmcneill vcaudio_service_callback(void *priv, const VCHI_CALLBACK_REASON_T reason,
    360  1.1  jmcneill     void *msg_handle)
    361  1.1  jmcneill {
    362  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    363  1.1  jmcneill 	VC_AUDIO_MSG_T msg;
    364  1.1  jmcneill 	int32_t msglen = 0;
    365  1.1  jmcneill 	int error;
    366  1.1  jmcneill 	void (*intr)(void *) = NULL;
    367  1.1  jmcneill 	void *intrarg = NULL;
    368  1.1  jmcneill 
    369  1.1  jmcneill 	if (sc == NULL || reason != VCHI_CALLBACK_MSG_AVAILABLE)
    370  1.1  jmcneill 		return;
    371  1.1  jmcneill 
    372  1.1  jmcneill 	memset(&msg, 0, sizeof(msg));
    373  1.1  jmcneill 	error = vchi_msg_dequeue(sc->sc_service, &msg, sizeof(msg), &msglen,
    374  1.1  jmcneill 	    VCHI_FLAGS_NONE);
    375  1.1  jmcneill 	if (error) {
    376  1.1  jmcneill 		device_printf(sc->sc_dev, "couldn't dequeue msg (%d)\n",
    377  1.1  jmcneill 		    error);
    378  1.1  jmcneill 		return;
    379  1.1  jmcneill 	}
    380  1.1  jmcneill 
    381  1.1  jmcneill 	switch (msg.type) {
    382  1.1  jmcneill 	case VC_AUDIO_MSG_TYPE_RESULT:
    383  1.3     skrll 		mutex_enter(&sc->sc_msglock);
    384  1.1  jmcneill 		sc->sc_success = msg.u.result.success;
    385  1.3     skrll 		sc->sc_msgdone = true;
    386  1.3     skrll 		cv_broadcast(&sc->sc_msgcv);
    387  1.3     skrll 		mutex_exit(&sc->sc_msglock);
    388  1.1  jmcneill 		break;
    389  1.7     skrll 
    390  1.1  jmcneill 	case VC_AUDIO_MSG_TYPE_COMPLETE:
    391  1.1  jmcneill 		intr = msg.u.complete.callback;
    392  1.1  jmcneill 		intrarg = msg.u.complete.cookie;
    393  1.1  jmcneill 		if (intr && intrarg) {
    394  1.5  jmcneill 			int count = msg.u.complete.count & 0xffff;
    395  1.7     skrll 			int perr = (msg.u.complete.count & __BIT(30)) != 0;
    396  1.5  jmcneill 			bool sched = false;
    397  1.7     skrll 
    398  1.3     skrll 			mutex_enter(&sc->sc_intr_lock);
    399  1.7     skrll 
    400  1.5  jmcneill 			if (count > 0) {
    401  1.5  jmcneill 				sc->sc_pbytes += count;
    402  1.5  jmcneill 			}
    403  1.5  jmcneill 			if (perr && sc->sc_started) {
    404  1.5  jmcneill #ifdef VCAUDIO_DEBUG
    405  1.5  jmcneill 				device_printf(sc->sc_dev, "underrun\n");
    406  1.5  jmcneill #endif
    407  1.5  jmcneill 				sched = true;
    408  1.1  jmcneill 			}
    409  1.1  jmcneill 			if (sc->sc_pbytes >= sc->sc_pblksize) {
    410  1.1  jmcneill 				sc->sc_pbytes -= sc->sc_pblksize;
    411  1.5  jmcneill 				sched = true;
    412  1.5  jmcneill 			}
    413  1.5  jmcneill 
    414  1.5  jmcneill 			if (sched) {
    415  1.1  jmcneill 				intr(intrarg);
    416  1.7     skrll 				sc->sc_abytes += sc->sc_pblksize;
    417  1.7     skrll 				cv_signal(&sc->sc_datacv);
    418  1.1  jmcneill 			}
    419  1.3     skrll 			mutex_exit(&sc->sc_intr_lock);
    420  1.1  jmcneill 		}
    421  1.1  jmcneill 		break;
    422  1.1  jmcneill 	default:
    423  1.1  jmcneill 		break;
    424  1.1  jmcneill 	}
    425  1.1  jmcneill }
    426  1.1  jmcneill 
    427  1.1  jmcneill static void
    428  1.7     skrll vcaudio_worker(void *priv)
    429  1.1  jmcneill {
    430  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    431  1.1  jmcneill 	VC_AUDIO_MSG_T msg;
    432  1.1  jmcneill 	void (*intr)(void *);
    433  1.1  jmcneill 	void *intrarg;
    434  1.1  jmcneill 	void *block;
    435  1.1  jmcneill 	int error, resid, off, nb, count;
    436  1.1  jmcneill 
    437  1.1  jmcneill 	mutex_enter(&sc->sc_intr_lock);
    438  1.1  jmcneill 
    439  1.7     skrll 	while (true) {
    440  1.7     skrll 		intr = sc->sc_pint;
    441  1.7     skrll 		intrarg = sc->sc_pintarg;
    442  1.7     skrll 
    443  1.7     skrll 		if (intr == NULL || intrarg == NULL) {
    444  1.7     skrll 			cv_wait_sig(&sc->sc_datacv, &sc->sc_intr_lock);
    445  1.7     skrll 			continue;
    446  1.7     skrll 		}
    447  1.1  jmcneill 
    448  1.7     skrll 		KASSERT(sc->sc_pblksize != 0);
    449  1.1  jmcneill 
    450  1.7     skrll 		if (sc->sc_abytes < sc->sc_pblksize) {
    451  1.7     skrll 			cv_wait_sig(&sc->sc_datacv, &sc->sc_intr_lock);
    452  1.7     skrll 			continue;
    453  1.7     skrll 		}
    454  1.7     skrll 		count = sc->sc_pblksize;
    455  1.1  jmcneill 
    456  1.1  jmcneill 		memset(&msg, 0, sizeof(msg));
    457  1.7     skrll 		msg.type = VC_AUDIO_MSG_TYPE_WRITE;
    458  1.7     skrll 		msg.u.write.max_packet = VCAUDIO_MSGSIZE;
    459  1.7     skrll 		msg.u.write.count = count;
    460  1.7     skrll 		msg.u.write.callback = intr;
    461  1.7     skrll 		msg.u.write.cookie = intrarg;
    462  1.7     skrll 		msg.u.write.silence = 0;
    463  1.7     skrll 
    464  1.7     skrll 	    	block = (uint8_t *)sc->sc_pstart + sc->sc_ppos;
    465  1.7     skrll 		resid = count;
    466  1.7     skrll 		off = 0;
    467  1.7     skrll 
    468  1.7     skrll 		vchi_service_use(sc->sc_service);
    469  1.7     skrll 
    470  1.1  jmcneill 		error = vchi_msg_queue(sc->sc_service, &msg, sizeof(msg),
    471  1.1  jmcneill 		    VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
    472  1.1  jmcneill 		if (error) {
    473  1.7     skrll 			printf("%s: failed to write (%d)\n", __func__, error);
    474  1.1  jmcneill 			goto done;
    475  1.1  jmcneill 		}
    476  1.1  jmcneill 
    477  1.7     skrll 		while (resid > 0) {
    478  1.7     skrll 			nb = min(resid, msg.u.write.max_packet);
    479  1.7     skrll 			error = vchi_msg_queue(sc->sc_service,
    480  1.7     skrll 			    (char *)block + off, nb,
    481  1.7     skrll 			    VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
    482  1.7     skrll 			if (error) {
    483  1.7     skrll 				/* XXX What to do here? */
    484  1.7     skrll 				device_printf(sc->sc_dev,
    485  1.7     skrll 				    "failed to queue data (%d)\n", error);
    486  1.7     skrll 				goto done;
    487  1.7     skrll 			}
    488  1.7     skrll 			off += nb;
    489  1.7     skrll 			resid -= nb;
    490  1.7     skrll 		}
    491  1.1  jmcneill 
    492  1.7     skrll 		sc->sc_abytes -= count;
    493  1.7     skrll 		sc->sc_ppos += count;
    494  1.7     skrll 		if ((uint8_t *)sc->sc_pstart + sc->sc_ppos >=
    495  1.7     skrll 		    (uint8_t *)sc->sc_pend)
    496  1.7     skrll 			sc->sc_ppos = 0;
    497  1.7     skrll 
    498  1.7     skrll 		if (!sc->sc_started) {
    499  1.7     skrll         		++sc->sc_pblkcnt;
    500  1.7     skrll 
    501  1.7     skrll 			if (sc->sc_pblkcnt == VCAUDIO_PREFILLCOUNT) {
    502  1.7     skrll 
    503  1.7     skrll 				memset(&msg, 0, sizeof(msg));
    504  1.7     skrll 				msg.type = VC_AUDIO_MSG_TYPE_START;
    505  1.7     skrll 				error = vchi_msg_queue(sc->sc_service, &msg,
    506  1.7     skrll 				    sizeof(msg), VCHI_FLAGS_BLOCK_UNTIL_QUEUED,
    507  1.7     skrll 				    NULL);
    508  1.7     skrll 				if (error) {
    509  1.7     skrll 					device_printf(sc->sc_dev,
    510  1.7     skrll 					    "failed to start (%d)\n", error);
    511  1.7     skrll 					goto done;
    512  1.7     skrll 				}
    513  1.7     skrll 				sc->sc_started = true;
    514  1.7     skrll 				sc->sc_pbytes = 0;
    515  1.7     skrll 			} else {
    516  1.7     skrll 				intr(intrarg);
    517  1.7     skrll 				sc->sc_abytes += sc->sc_pblksize;
    518  1.7     skrll 			}
    519  1.1  jmcneill 		}
    520  1.1  jmcneill 
    521  1.1  jmcneill done:
    522  1.7     skrll 		vchi_service_release(sc->sc_service);
    523  1.7     skrll 	}
    524  1.1  jmcneill }
    525  1.1  jmcneill 
    526  1.1  jmcneill static int
    527  1.1  jmcneill vcaudio_msg_sync(struct vcaudio_softc *sc, VC_AUDIO_MSG_T *msg, size_t msglen)
    528  1.1  jmcneill {
    529  1.1  jmcneill 	int error = 0;
    530  1.1  jmcneill 
    531  1.3     skrll 	mutex_enter(&sc->sc_msglock);
    532  1.3     skrll 
    533  1.1  jmcneill 	sc->sc_success = -1;
    534  1.3     skrll 	sc->sc_msgdone = false;
    535  1.3     skrll 
    536  1.1  jmcneill 	error = vchi_msg_queue(sc->sc_service, msg, msglen,
    537  1.1  jmcneill 	    VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
    538  1.1  jmcneill 	if (error) {
    539  1.1  jmcneill 		printf("%s: failed to queue message (%d)\n", __func__, error);
    540  1.1  jmcneill 		goto done;
    541  1.1  jmcneill 	}
    542  1.3     skrll 
    543  1.3     skrll 	while (!sc->sc_msgdone) {
    544  1.3     skrll 		error = cv_wait_sig(&sc->sc_msgcv, &sc->sc_msglock);
    545  1.1  jmcneill 		if (error)
    546  1.1  jmcneill 			break;
    547  1.1  jmcneill 	}
    548  1.3     skrll 	if (sc->sc_success != 0)
    549  1.1  jmcneill 		error = EIO;
    550  1.1  jmcneill done:
    551  1.3     skrll 	mutex_exit(&sc->sc_msglock);
    552  1.1  jmcneill 
    553  1.1  jmcneill 	return error;
    554  1.1  jmcneill }
    555  1.1  jmcneill 
    556  1.1  jmcneill static int
    557  1.1  jmcneill vcaudio_open(void *priv, int flags)
    558  1.1  jmcneill {
    559  1.1  jmcneill 	return 0;
    560  1.1  jmcneill }
    561  1.1  jmcneill 
    562  1.1  jmcneill static void
    563  1.1  jmcneill vcaudio_close(void *priv)
    564  1.1  jmcneill {
    565  1.1  jmcneill }
    566  1.1  jmcneill 
    567  1.1  jmcneill static int
    568  1.1  jmcneill vcaudio_query_encoding(void *priv, struct audio_encoding *ae)
    569  1.1  jmcneill {
    570  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    571  1.1  jmcneill 
    572  1.1  jmcneill 	return auconv_query_encoding(sc->sc_encodings, ae);
    573  1.1  jmcneill }
    574  1.1  jmcneill 
    575  1.1  jmcneill static int
    576  1.1  jmcneill vcaudio_set_params(void *priv, int setmode, int usemode,
    577  1.1  jmcneill     audio_params_t *play, audio_params_t *rec,
    578  1.1  jmcneill     stream_filter_list_t *pfil, stream_filter_list_t *rfil)
    579  1.1  jmcneill {
    580  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    581  1.1  jmcneill 	int index;
    582  1.1  jmcneill 
    583  1.1  jmcneill 	if (play && (setmode & AUMODE_PLAY)) {
    584  1.1  jmcneill 		index = auconv_set_converter(&sc->sc_format, 1,
    585  1.1  jmcneill 		    AUMODE_PLAY, play, true, pfil);
    586  1.1  jmcneill 		if (index < 0)
    587  1.1  jmcneill 			return EINVAL;
    588  1.1  jmcneill 	}
    589  1.1  jmcneill 
    590  1.1  jmcneill 	return 0;
    591  1.1  jmcneill }
    592  1.1  jmcneill 
    593  1.1  jmcneill static int
    594  1.1  jmcneill vcaudio_halt_output(void *priv)
    595  1.1  jmcneill {
    596  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    597  1.1  jmcneill 	VC_AUDIO_MSG_T msg;
    598  1.1  jmcneill 	int error = 0;
    599  1.1  jmcneill 
    600  1.7     skrll 	KASSERT(mutex_owned(&sc->sc_intr_lock));
    601  1.7     skrll 
    602  1.1  jmcneill 	vchi_service_use(sc->sc_service);
    603  1.1  jmcneill 	memset(&msg, 0, sizeof(msg));
    604  1.1  jmcneill 	msg.type = VC_AUDIO_MSG_TYPE_STOP;
    605  1.7     skrll 	msg.u.stop.draining = 0;
    606  1.1  jmcneill 	error = vchi_msg_queue(sc->sc_service, &msg, sizeof(msg),
    607  1.1  jmcneill 	    VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
    608  1.1  jmcneill 	if (error) {
    609  1.1  jmcneill 		device_printf(sc->sc_dev, "couldn't send STOP message (%d)\n",
    610  1.1  jmcneill 		    error);
    611  1.1  jmcneill 	}
    612  1.1  jmcneill 	vchi_service_release(sc->sc_service);
    613  1.1  jmcneill 
    614  1.1  jmcneill 	sc->sc_pint = NULL;
    615  1.1  jmcneill 	sc->sc_pintarg = NULL;
    616  1.1  jmcneill 	sc->sc_started = false;
    617  1.1  jmcneill 
    618  1.1  jmcneill #ifdef VCAUDIO_DEBUG
    619  1.1  jmcneill 	device_printf(sc->sc_dev, "halting output\n");
    620  1.1  jmcneill #endif
    621  1.1  jmcneill 
    622  1.1  jmcneill 	return error;
    623  1.1  jmcneill }
    624  1.1  jmcneill 
    625  1.1  jmcneill static int
    626  1.1  jmcneill vcaudio_halt_input(void *priv)
    627  1.1  jmcneill {
    628  1.1  jmcneill 	return EINVAL;
    629  1.1  jmcneill }
    630  1.1  jmcneill 
    631  1.1  jmcneill static int
    632  1.1  jmcneill vcaudio_set_port(void *priv, mixer_ctrl_t *mc)
    633  1.1  jmcneill {
    634  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    635  1.1  jmcneill 	VC_AUDIO_MSG_T msg;
    636  1.1  jmcneill 	int error;
    637  1.1  jmcneill 
    638  1.1  jmcneill 	switch (mc->dev) {
    639  1.1  jmcneill 	case VCAUDIO_OUTPUT_MASTER_VOLUME:
    640  1.1  jmcneill 	case VCAUDIO_INPUT_DAC_VOLUME:
    641  1.1  jmcneill 		sc->sc_volume = mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT];
    642  1.7     skrll 
    643  1.7     skrll 		vchi_service_use(sc->sc_service);
    644  1.7     skrll 
    645  1.1  jmcneill 		memset(&msg, 0, sizeof(msg));
    646  1.1  jmcneill 		msg.type = VC_AUDIO_MSG_TYPE_CONTROL;
    647  1.1  jmcneill 		msg.u.control.volume = vol2pct(sc->sc_volume);
    648  1.1  jmcneill 		msg.u.control.dest = VCAUDIO_DEST_AUTO;
    649  1.7     skrll 
    650  1.1  jmcneill 		error = vcaudio_msg_sync(sc, &msg, sizeof(msg));
    651  1.1  jmcneill 		if (error) {
    652  1.7     skrll 			device_printf(sc->sc_dev,
    653  1.7     skrll 			    "couldn't send CONTROL message (%d)\n", error);
    654  1.1  jmcneill 		}
    655  1.7     skrll 
    656  1.1  jmcneill 		vchi_service_release(sc->sc_service);
    657  1.1  jmcneill 
    658  1.1  jmcneill 		return error;
    659  1.1  jmcneill 	}
    660  1.1  jmcneill 	return ENXIO;
    661  1.1  jmcneill }
    662  1.1  jmcneill 
    663  1.1  jmcneill static int
    664  1.1  jmcneill vcaudio_get_port(void *priv, mixer_ctrl_t *mc)
    665  1.1  jmcneill {
    666  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    667  1.1  jmcneill 
    668  1.1  jmcneill 	switch (mc->dev) {
    669  1.1  jmcneill 	case VCAUDIO_OUTPUT_MASTER_VOLUME:
    670  1.1  jmcneill 	case VCAUDIO_INPUT_DAC_VOLUME:
    671  1.1  jmcneill 		mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] =
    672  1.1  jmcneill 		    mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] =
    673  1.1  jmcneill 		    sc->sc_volume;
    674  1.1  jmcneill 		return 0;
    675  1.1  jmcneill 	}
    676  1.1  jmcneill 	return ENXIO;
    677  1.1  jmcneill }
    678  1.1  jmcneill 
    679  1.1  jmcneill static int
    680  1.1  jmcneill vcaudio_query_devinfo(void *priv, mixer_devinfo_t *di)
    681  1.1  jmcneill {
    682  1.1  jmcneill 	switch (di->index) {
    683  1.1  jmcneill 	case VCAUDIO_OUTPUT_CLASS:
    684  1.1  jmcneill 		di->mixer_class = VCAUDIO_OUTPUT_CLASS;
    685  1.1  jmcneill 		strcpy(di->label.name, AudioCoutputs);
    686  1.1  jmcneill 		di->type = AUDIO_MIXER_CLASS;
    687  1.1  jmcneill 		di->next = di->prev = AUDIO_MIXER_LAST;
    688  1.1  jmcneill 		return 0;
    689  1.1  jmcneill 	case VCAUDIO_INPUT_CLASS:
    690  1.1  jmcneill 		di->mixer_class = VCAUDIO_INPUT_CLASS;
    691  1.1  jmcneill 		strcpy(di->label.name, AudioCinputs);
    692  1.1  jmcneill 		di->type = AUDIO_MIXER_CLASS;
    693  1.1  jmcneill 		di->next = di->prev = AUDIO_MIXER_LAST;
    694  1.1  jmcneill 		return 0;
    695  1.1  jmcneill 	case VCAUDIO_OUTPUT_MASTER_VOLUME:
    696  1.1  jmcneill 		di->mixer_class = VCAUDIO_OUTPUT_CLASS;
    697  1.1  jmcneill 		strcpy(di->label.name, AudioNmaster);
    698  1.1  jmcneill 		di->type = AUDIO_MIXER_VALUE;
    699  1.1  jmcneill 		di->next = di->prev = AUDIO_MIXER_LAST;
    700  1.1  jmcneill 		di->un.v.num_channels = 2;
    701  1.1  jmcneill 		strcpy(di->un.v.units.name, AudioNvolume);
    702  1.1  jmcneill 		return 0;
    703  1.1  jmcneill 	case VCAUDIO_INPUT_DAC_VOLUME:
    704  1.1  jmcneill 		di->mixer_class = VCAUDIO_INPUT_CLASS;
    705  1.1  jmcneill 		strcpy(di->label.name, AudioNdac);
    706  1.1  jmcneill 		di->type = AUDIO_MIXER_VALUE;
    707  1.1  jmcneill 		di->next = di->prev = AUDIO_MIXER_LAST;
    708  1.1  jmcneill 		di->un.v.num_channels = 2;
    709  1.1  jmcneill 		strcpy(di->un.v.units.name, AudioNvolume);
    710  1.1  jmcneill 		return 0;
    711  1.1  jmcneill 	}
    712  1.1  jmcneill 
    713  1.1  jmcneill 	return ENXIO;
    714  1.1  jmcneill }
    715  1.1  jmcneill 
    716  1.1  jmcneill static int
    717  1.1  jmcneill vcaudio_getdev(void *priv, struct audio_device *audiodev)
    718  1.1  jmcneill {
    719  1.6  jmcneill 	struct vcaudio_softc *sc = priv;
    720  1.6  jmcneill 
    721  1.7     skrll 	snprintf(audiodev->name, sizeof(audiodev->name), "vchiq auds");
    722  1.6  jmcneill 	snprintf(audiodev->version, sizeof(audiodev->version),
    723  1.6  jmcneill 	    "%d", sc->sc_peer_version);
    724  1.1  jmcneill 	snprintf(audiodev->config, sizeof(audiodev->config), "vcaudio");
    725  1.6  jmcneill 
    726  1.1  jmcneill 	return 0;
    727  1.1  jmcneill }
    728  1.1  jmcneill 
    729  1.1  jmcneill static int
    730  1.1  jmcneill vcaudio_get_props(void *priv)
    731  1.1  jmcneill {
    732  1.1  jmcneill 	return AUDIO_PROP_PLAYBACK|AUDIO_PROP_CAPTURE|AUDIO_PROP_INDEPENDENT;
    733  1.1  jmcneill }
    734  1.1  jmcneill 
    735  1.1  jmcneill static int
    736  1.1  jmcneill vcaudio_round_blocksize(void *priv, int bs, int mode,
    737  1.1  jmcneill     const audio_params_t *params)
    738  1.1  jmcneill {
    739  1.7     skrll 	return VCAUDIO_BLOCKSIZE;
    740  1.1  jmcneill }
    741  1.1  jmcneill 
    742  1.1  jmcneill static size_t
    743  1.1  jmcneill vcaudio_round_buffersize(void *priv, int direction, size_t bufsize)
    744  1.1  jmcneill {
    745  1.1  jmcneill 
    746  1.7     skrll 	return VCAUDIO_BUFFERSIZE;
    747  1.1  jmcneill }
    748  1.1  jmcneill 
    749  1.1  jmcneill static int
    750  1.1  jmcneill vcaudio_trigger_output(void *priv, void *start, void *end, int blksize,
    751  1.1  jmcneill     void (*intr)(void *), void *intrarg, const audio_params_t *params)
    752  1.1  jmcneill {
    753  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    754  1.1  jmcneill 
    755  1.7     skrll 	ASSERT_SLEEPABLE();
    756  1.7     skrll 	KASSERT(mutex_owned(&sc->sc_intr_lock));
    757  1.7     skrll 
    758  1.1  jmcneill 	sc->sc_pparam = *params;
    759  1.1  jmcneill 	sc->sc_pint = intr;
    760  1.1  jmcneill 	sc->sc_pintarg = intrarg;
    761  1.1  jmcneill 	sc->sc_ppos = 0;
    762  1.1  jmcneill 	sc->sc_pstart = start;
    763  1.1  jmcneill 	sc->sc_pend = end;
    764  1.1  jmcneill 	sc->sc_pblksize = blksize;
    765  1.7     skrll 	sc->sc_pblkcnt = 0;
    766  1.7     skrll 	sc->sc_pbytes = 0;
    767  1.7     skrll 	sc->sc_abytes = blksize;
    768  1.7     skrll 
    769  1.7     skrll 	cv_signal(&sc->sc_datacv);
    770  1.1  jmcneill 
    771  1.1  jmcneill 	return 0;
    772  1.1  jmcneill }
    773  1.2     skrll 
    774  1.1  jmcneill static int
    775  1.1  jmcneill vcaudio_trigger_input(void *priv, void *start, void *end, int blksize,
    776  1.1  jmcneill     void (*intr)(void *), void *intrarg, const audio_params_t *params)
    777  1.1  jmcneill {
    778  1.1  jmcneill 	return EINVAL;
    779  1.1  jmcneill }
    780  1.1  jmcneill 
    781  1.1  jmcneill static void
    782  1.1  jmcneill vcaudio_get_locks(void *priv, kmutex_t **intr, kmutex_t **thread)
    783  1.1  jmcneill {
    784  1.1  jmcneill 	struct vcaudio_softc *sc = priv;
    785  1.1  jmcneill 
    786  1.1  jmcneill 	*intr = &sc->sc_intr_lock;
    787  1.1  jmcneill 	*thread = &sc->sc_lock;
    788  1.1  jmcneill }
    789