188447a05SGarrett D'Amore /* 288447a05SGarrett D'Amore * CDDL HEADER START 388447a05SGarrett D'Amore * 488447a05SGarrett D'Amore * The contents of this file are subject to the terms of the 588447a05SGarrett D'Amore * Common Development and Distribution License (the "License"). 688447a05SGarrett D'Amore * You may not use this file except in compliance with the License. 788447a05SGarrett D'Amore * 888447a05SGarrett D'Amore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 988447a05SGarrett D'Amore * or http://www.opensolaris.org/os/licensing. 1088447a05SGarrett D'Amore * See the License for the specific language governing permissions 1188447a05SGarrett D'Amore * and limitations under the License. 1288447a05SGarrett D'Amore * 1388447a05SGarrett D'Amore * When distributing Covered Code, include this CDDL HEADER in each 1488447a05SGarrett D'Amore * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1588447a05SGarrett D'Amore * If applicable, add the following below this CDDL HEADER, with the 1688447a05SGarrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying 1788447a05SGarrett D'Amore * information: Portions Copyright [yyyy] [name of copyright owner] 1888447a05SGarrett D'Amore * 1988447a05SGarrett D'Amore * CDDL HEADER END 2088447a05SGarrett D'Amore */ 2188447a05SGarrett D'Amore 2288447a05SGarrett D'Amore /* 23*2c30fa45SGarrett D'Amore * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 2488447a05SGarrett D'Amore */ 2588447a05SGarrett D'Amore 2688447a05SGarrett D'Amore #ifndef _AUDIO_CLIENT_H 2788447a05SGarrett D'Amore #define _AUDIO_CLIENT_H 2888447a05SGarrett D'Amore 2988447a05SGarrett D'Amore /* 3088447a05SGarrett D'Amore * Structure implementation in audio_impl.h 3188447a05SGarrett D'Amore */ 3288447a05SGarrett D'Amore #include <sys/audio/audio_common.h> 3388447a05SGarrett D'Amore 3488447a05SGarrett D'Amore typedef struct audio_client_ops { 3588447a05SGarrett D'Amore const char *aco_minor_prefix; 3688447a05SGarrett D'Amore void *(*aco_dev_init)(audio_dev_t *); 3788447a05SGarrett D'Amore void (*aco_dev_fini)(void *); 3888447a05SGarrett D'Amore int (*aco_open)(audio_client_t *, int); 3988447a05SGarrett D'Amore void (*aco_close)(audio_client_t *); 4088447a05SGarrett D'Amore int (*aco_read)(audio_client_t *, struct uio *, cred_t *); 4188447a05SGarrett D'Amore int (*aco_write)(audio_client_t *, struct uio *, cred_t *); 4288447a05SGarrett D'Amore int (*aco_ioctl)(audio_client_t *, int, intptr_t, int, 4388447a05SGarrett D'Amore cred_t *, int *); 4488447a05SGarrett D'Amore int (*aco_chpoll)(audio_client_t *, short, int, short *, 4588447a05SGarrett D'Amore struct pollhead **); 4688447a05SGarrett D'Amore int (*aco_mmap)(audio_client_t *, ...); 4788447a05SGarrett D'Amore void (*aco_input)(audio_client_t *); 4888447a05SGarrett D'Amore void (*aco_output)(audio_client_t *); 4988447a05SGarrett D'Amore void (*aco_drain)(audio_client_t *); 50a19bb1faSGarrett D'Amore 51a19bb1faSGarrett D'Amore void (*aco_wput)(audio_client_t *, mblk_t *); 52a19bb1faSGarrett D'Amore void (*aco_wsrv)(audio_client_t *); 53682cb104SGarrett D'Amore void (*aco_rsrv)(audio_client_t *); 5488447a05SGarrett D'Amore } audio_client_ops_t; 5588447a05SGarrett D'Amore 5688447a05SGarrett D'Amore void *auclnt_get_private(audio_client_t *); 5788447a05SGarrett D'Amore void auclnt_set_private(audio_client_t *, void *); 5888447a05SGarrett D'Amore 5988447a05SGarrett D'Amore int auclnt_drain(audio_client_t *); 6088447a05SGarrett D'Amore int auclnt_start_drain(audio_client_t *); 6188447a05SGarrett D'Amore 6288447a05SGarrett D'Amore int auclnt_set_rate(audio_stream_t *, int); 6388447a05SGarrett D'Amore int auclnt_get_rate(audio_stream_t *); 6488447a05SGarrett D'Amore 6588447a05SGarrett D'Amore int auclnt_set_format(audio_stream_t *, int); 6688447a05SGarrett D'Amore int auclnt_get_format(audio_stream_t *); 6788447a05SGarrett D'Amore 6888447a05SGarrett D'Amore int auclnt_set_channels(audio_stream_t *, int); 6988447a05SGarrett D'Amore int auclnt_get_channels(audio_stream_t *); 7088447a05SGarrett D'Amore 7188447a05SGarrett D'Amore void auclnt_set_gain(audio_stream_t *, uint8_t); 7288447a05SGarrett D'Amore uint8_t auclnt_get_gain(audio_stream_t *); 7388447a05SGarrett D'Amore 7488447a05SGarrett D'Amore void auclnt_set_muted(audio_stream_t *, boolean_t); 7588447a05SGarrett D'Amore boolean_t auclnt_get_muted(audio_stream_t *); 7688447a05SGarrett D'Amore 7788447a05SGarrett D'Amore uint64_t auclnt_get_samples(audio_stream_t *); 7888447a05SGarrett D'Amore void auclnt_set_samples(audio_stream_t *, uint64_t); 7988447a05SGarrett D'Amore 8088447a05SGarrett D'Amore uint64_t auclnt_get_errors(audio_stream_t *); 8188447a05SGarrett D'Amore void auclnt_set_errors(audio_stream_t *, uint64_t); 8288447a05SGarrett D'Amore 8388447a05SGarrett D'Amore uint64_t auclnt_get_eof(audio_stream_t *); 8488447a05SGarrett D'Amore void auclnt_set_eof(audio_stream_t *, uint64_t); 8588447a05SGarrett D'Amore 86622a30bfSGarrett D'Amore boolean_t auclnt_is_running(audio_stream_t *); 8788447a05SGarrett D'Amore void auclnt_start(audio_stream_t *); 8888447a05SGarrett D'Amore void auclnt_stop(audio_stream_t *); 8988447a05SGarrett D'Amore 9088447a05SGarrett D'Amore void auclnt_set_paused(audio_stream_t *); 9188447a05SGarrett D'Amore void auclnt_clear_paused(audio_stream_t *); 9288447a05SGarrett D'Amore boolean_t auclnt_is_paused(audio_stream_t *); 9388447a05SGarrett D'Amore 9488447a05SGarrett D'Amore void auclnt_flush(audio_stream_t *); 9588447a05SGarrett D'Amore 9668c47f65SGarrett D'Amore void auclnt_get_output_qlen(audio_client_t *, uint_t *, uint_t *); 9788447a05SGarrett D'Amore 9868c47f65SGarrett D'Amore uint_t auclnt_get_fragsz(audio_stream_t *); 9968c47f65SGarrett D'Amore uint_t auclnt_get_framesz(audio_stream_t *); 10068c47f65SGarrett D'Amore uint_t auclnt_get_nfrags(audio_stream_t *); 10168c47f65SGarrett D'Amore uint_t auclnt_get_nframes(audio_stream_t *); 10268c47f65SGarrett D'Amore uint_t auclnt_get_count(audio_stream_t *); 10388447a05SGarrett D'Amore uint64_t auclnt_get_head(audio_stream_t *); 10488447a05SGarrett D'Amore uint64_t auclnt_get_tail(audio_stream_t *); 10568c47f65SGarrett D'Amore uint_t auclnt_get_hidx(audio_stream_t *); 10668c47f65SGarrett D'Amore uint_t auclnt_get_tidx(audio_stream_t *); 10788447a05SGarrett D'Amore 10868c47f65SGarrett D'Amore void auclnt_set_latency(audio_stream_t *, uint_t, uint_t); 109a702341cSGarrett D'Amore 11088447a05SGarrett D'Amore audio_stream_t *auclnt_input_stream(audio_client_t *); 11188447a05SGarrett D'Amore audio_stream_t *auclnt_output_stream(audio_client_t *); 11288447a05SGarrett D'Amore 11388447a05SGarrett D'Amore int auclnt_get_oflag(audio_client_t *); 11488447a05SGarrett D'Amore 115*2c30fa45SGarrett D'Amore int auclnt_open(audio_client_t *, int); 11688447a05SGarrett D'Amore void auclnt_close(audio_client_t *); 11788447a05SGarrett D'Amore 11888447a05SGarrett D'Amore void auclnt_register_ops(minor_t, audio_client_ops_t *); 11988447a05SGarrett D'Amore 12088447a05SGarrett D'Amore minor_t auclnt_get_minor(audio_client_t *); 12188447a05SGarrett D'Amore minor_t auclnt_get_original_minor(audio_client_t *); 12288447a05SGarrett D'Amore minor_t auclnt_get_minor_type(audio_client_t *); 123a19bb1faSGarrett D'Amore queue_t *auclnt_get_rq(audio_client_t *); 124a19bb1faSGarrett D'Amore queue_t *auclnt_get_wq(audio_client_t *); 12588447a05SGarrett D'Amore 12668c47f65SGarrett D'Amore uint_t auclnt_produce(audio_stream_t *, uint_t); 12768c47f65SGarrett D'Amore uint_t auclnt_produce_data(audio_stream_t *, caddr_t, uint_t); 12868c47f65SGarrett D'Amore uint_t auclnt_consume(audio_stream_t *, uint_t); 12968c47f65SGarrett D'Amore uint_t auclnt_consume_data(audio_stream_t *, caddr_t, uint_t); 13088447a05SGarrett D'Amore int auclnt_read(audio_client_t *, struct uio *); 13188447a05SGarrett D'Amore int auclnt_write(audio_client_t *, struct uio *); 13288447a05SGarrett D'Amore int auclnt_chpoll(audio_client_t *, short, int, short *, struct pollhead **); 13388447a05SGarrett D'Amore void auclnt_pollwakeup(audio_client_t *, short); 13488447a05SGarrett D'Amore 13588447a05SGarrett D'Amore /* 13688447a05SGarrett D'Amore * Return the process id that performed the original open() of the client. 13788447a05SGarrett D'Amore */ 13888447a05SGarrett D'Amore pid_t auclnt_get_pid(audio_client_t *); 13988447a05SGarrett D'Amore 14088447a05SGarrett D'Amore /* 14188447a05SGarrett D'Amore * Return the credentials of the process that opened the client. 14288447a05SGarrett D'Amore */ 14388447a05SGarrett D'Amore cred_t *auclnt_get_cred(audio_client_t *); 14488447a05SGarrett D'Amore 14588447a05SGarrett D'Amore /* 14688447a05SGarrett D'Amore * Get an opaque handle the underlying device for an audio client. 14788447a05SGarrett D'Amore */ 14888447a05SGarrett D'Amore audio_dev_t *auclnt_get_dev(audio_client_t *); 14988447a05SGarrett D'Amore audio_dev_t *auclnt_hold_dev_by_index(int); 15088447a05SGarrett D'Amore void auclnt_release_dev(audio_dev_t *); 15188447a05SGarrett D'Amore int auclnt_get_dev_index(audio_dev_t *); 15288447a05SGarrett D'Amore int auclnt_get_dev_number(audio_dev_t *); 15388447a05SGarrett D'Amore void auclnt_set_dev_number(audio_dev_t *, int); 15488447a05SGarrett D'Amore const char *auclnt_get_dev_name(audio_dev_t *); 15588447a05SGarrett D'Amore const char *auclnt_get_dev_driver(audio_dev_t *); 15688447a05SGarrett D'Amore dev_info_t *auclnt_get_dev_devinfo(audio_dev_t *); 15788447a05SGarrett D'Amore int auclnt_get_dev_instance(audio_dev_t *); 15888447a05SGarrett D'Amore const char *auclnt_get_dev_description(audio_dev_t *); 15988447a05SGarrett D'Amore const char *auclnt_get_dev_version(audio_dev_t *); 16088447a05SGarrett D'Amore const char *auclnt_get_dev_hw_info(audio_dev_t *, void **); 16168c47f65SGarrett D'Amore uint_t auclnt_get_dev_capab(audio_dev_t *); 16288447a05SGarrett D'Amore #define AUDIO_CLIENT_CAP_PLAY (1U << 0) 16388447a05SGarrett D'Amore #define AUDIO_CLIENT_CAP_RECORD (1U << 1) 16488447a05SGarrett D'Amore #define AUDIO_CLIENT_CAP_DUPLEX (1U << 2) 16588447a05SGarrett D'Amore #define AUDIO_CLIENT_CAP_SNDSTAT (1U << 3) 16626025630SGarrett D'Amore #define AUDIO_CLIENT_CAP_OPAQUE (1U << 4) 16788447a05SGarrett D'Amore 16888447a05SGarrett D'Amore /* 16988447a05SGarrett D'Amore * Walk all the open client structures for a named audio device. 17088447a05SGarrett D'Amore * Clients can use this to find "peer" clients accessing the same 17188447a05SGarrett D'Amore * audio device. (This is useful for implementing special linkages, 17288447a05SGarrett D'Amore * e.g. between /dev/audio and /dev/audioctl.) 17388447a05SGarrett D'Amore */ 17488447a05SGarrett D'Amore void auclnt_dev_walk_clients(audio_dev_t *, 17588447a05SGarrett D'Amore int (*)(audio_client_t *, void *), void *); 17688447a05SGarrett D'Amore 177682cb104SGarrett D'Amore /* 178682cb104SGarrett D'Amore * This is used to check for updates to volume and control status. 179682cb104SGarrett D'Amore * Its a polling-based interface because that's what our clients (OSS) 180682cb104SGarrett D'Amore * need, and its far lighter weight than forcing an asynchronous 181682cb104SGarrett D'Amore * callback on everything. 182682cb104SGarrett D'Amore */ 18368c47f65SGarrett D'Amore uint_t auclnt_dev_get_serial(audio_dev_t *); 184682cb104SGarrett D'Amore 18588447a05SGarrett D'Amore /* 18688447a05SGarrett D'Amore * Audio control functions for use by clients. 18788447a05SGarrett D'Amore */ 18888447a05SGarrett D'Amore 18988447a05SGarrett D'Amore /* 19088447a05SGarrett D'Amore * This will walk all controls registered to my device and callback 19188447a05SGarrett D'Amore * to walker for each one with its audio_ctrl_desc_t.. 19288447a05SGarrett D'Amore * 19388447a05SGarrett D'Amore * Note that walk_func may return values to continue (AUDIO_WALK_CONTINUE) 19488447a05SGarrett D'Amore * or stop walk (AUDIO_WALK_STOP). 19588447a05SGarrett D'Amore * 19688447a05SGarrett D'Amore */ 19788447a05SGarrett D'Amore void auclnt_walk_controls(audio_dev_t *, 19888447a05SGarrett D'Amore int (*)(audio_ctrl_t *, void *), void *); 19988447a05SGarrett D'Amore 20088447a05SGarrett D'Amore /* 20188447a05SGarrett D'Amore * This will search all controls attached to a clients 20288447a05SGarrett D'Amore * audio device for a control with the desired name. 20388447a05SGarrett D'Amore * 20488447a05SGarrett D'Amore * On successful return a ctrl handle will be returned. On 20588447a05SGarrett D'Amore * failure NULL is returned. 20688447a05SGarrett D'Amore */ 20788447a05SGarrett D'Amore audio_ctrl_t *auclnt_find_control(audio_dev_t *, const char *); 20888447a05SGarrett D'Amore 20988447a05SGarrett D'Amore /* 21088447a05SGarrett D'Amore * Given a known control, get its attributes. 21188447a05SGarrett D'Amore * 21288447a05SGarrett D'Amore * The caller must supply a audio_ctrl_desc_t structure. Also the 21388447a05SGarrett D'Amore * values in the structure are ignored when making the call and filled 21488447a05SGarrett D'Amore * in by this function. 21588447a05SGarrett D'Amore * 21688447a05SGarrett D'Amore * If an error occurs then a non-zero is returned. 21788447a05SGarrett D'Amore */ 21888447a05SGarrett D'Amore int auclnt_control_describe(audio_ctrl_t *, audio_ctrl_desc_t *); 21988447a05SGarrett D'Amore 22088447a05SGarrett D'Amore 22188447a05SGarrett D'Amore /* 22288447a05SGarrett D'Amore * This is used to read the current value of a control. 22388447a05SGarrett D'Amore * Note, this will cause a callback into the driver to get the value. 22488447a05SGarrett D'Amore * 22588447a05SGarrett D'Amore * On return zero is returned on success else errno is returned. 22688447a05SGarrett D'Amore */ 22788447a05SGarrett D'Amore int auclnt_control_read(audio_ctrl_t *, uint64_t *); 22888447a05SGarrett D'Amore 22988447a05SGarrett D'Amore /* 23088447a05SGarrett D'Amore * This is used to write a value to a control. 23188447a05SGarrett D'Amore * Note, this will cause a callback into the driver to write the value. 23288447a05SGarrett D'Amore * 23388447a05SGarrett D'Amore * On return zero is returned on success else errno is returned. 23488447a05SGarrett D'Amore * 23588447a05SGarrett D'Amore */ 23688447a05SGarrett D'Amore int auclnt_control_write(audio_ctrl_t *, uint64_t); 23788447a05SGarrett D'Amore 23888447a05SGarrett D'Amore /* 23988447a05SGarrett D'Amore * Walk all the audio devices on the system. Useful for clients 24088447a05SGarrett D'Amore * like sndstat, which may need to inquire about every audio device 24188447a05SGarrett D'Amore * on the system. 24288447a05SGarrett D'Amore */ 24388447a05SGarrett D'Amore void auclnt_walk_devs(int (*walker)(audio_dev_t *, void *), void *); 24488447a05SGarrett D'Amore void auclnt_walk_devs_by_number(int (*walker)(audio_dev_t *, void *), void *); 24588447a05SGarrett D'Amore 24688447a05SGarrett D'Amore audio_client_t *auclnt_hold_by_devt(dev_t); 24788447a05SGarrett D'Amore void auclnt_release(audio_client_t *); 24868c47f65SGarrett D'Amore void auclnt_hold(audio_client_t *); 24968c47f65SGarrett D'Amore int auclnt_serialize(audio_client_t *); 25068c47f65SGarrett D'Amore void auclnt_unserialize(audio_client_t *); 25188447a05SGarrett D'Amore 25288447a05SGarrett D'Amore /* 25388447a05SGarrett D'Amore * Engine rlated accesses. Note that normally clients don't need this level 25488447a05SGarrett D'Amore * of information. 25588447a05SGarrett D'Amore */ 25688447a05SGarrett D'Amore void auclnt_dev_walk_engines(audio_dev_t *, 25788447a05SGarrett D'Amore int (*)(audio_engine_t *, void *), void *); 25888447a05SGarrett D'Amore int auclnt_engine_get_format(audio_engine_t *); 25988447a05SGarrett D'Amore int auclnt_engine_get_rate(audio_engine_t *); 26088447a05SGarrett D'Amore int auclnt_engine_get_channels(audio_engine_t *); 26168c47f65SGarrett D'Amore uint_t auclnt_engine_get_capab(audio_engine_t *); 26288447a05SGarrett D'Amore 26388447a05SGarrett D'Amore /* 26488447a05SGarrett D'Amore * Retrieve minor-specific data for the instance. This allows for 26588447a05SGarrett D'Amore * personality modules to store persistent state data on a physical 26688447a05SGarrett D'Amore * device (e.g. to store persistent settings.) Synchronization of 26788447a05SGarrett D'Amore * stored settings between personality modules is up to the 26888447a05SGarrett D'Amore * personality modules themselves. 26988447a05SGarrett D'Amore */ 27088447a05SGarrett D'Amore void *auclnt_get_minor_data(audio_client_t *, minor_t); 27188447a05SGarrett D'Amore void *auclnt_get_dev_minor_data(audio_dev_t *, minor_t); 27288447a05SGarrett D'Amore 27388447a05SGarrett D'Amore /* 27488447a05SGarrett D'Amore * Simpler warning message, alternative to cmn_err. 27588447a05SGarrett D'Amore */ 27688447a05SGarrett D'Amore void auclnt_warn(audio_client_t *, const char *fmt, ...); 27788447a05SGarrett D'Amore 27888447a05SGarrett D'Amore #endif /* _AUDIO_CLIENT_H */ 279