audio_impl.h revision 260256302ac564fcfed9ebfa5a6c98a2e6ef3808
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (C) 4Front Technologies 1996-2008.
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _AUDIO_IMPL_H
#define _AUDIO_IMPL_H
#include "audio_client.h"
#define AUDIO_MAX_OPENS 256
#define AUDIO_MAX_CHANNELS 16
#define AUDIO_UNIT_EXPAND 1024
#define AUDIO_VOL_SCALE 256
#define AUDIO_DB_SIZE 50
struct audio_parms {
int p_format;
int p_rate;
int p_nchan;
};
typedef int (*audio_cnv_func_t)(audio_stream_t *, int);
struct audio_buffer {
unsigned b_hidx; /* head % nframes */
unsigned b_tidx; /* tail % nframes */
unsigned b_fragfr; /* frames per frag */
unsigned b_fragbytes; /* bytes per frag */
unsigned b_nframes; /* total frames */
unsigned b_nbytes; /* total bytes */
unsigned b_nfrags; /* total frags */
unsigned b_framesz; /* bytes per frame */
};
/*
* struct audio_stream: This structure represents a virtual stream exposed
* to a single client. Each client will have at most two of these (one for
* record, one for playback.)
*/
struct audio_stream {
/*
* Various counters.
*/
/*
* Sample rate conversion (SRC) and format conversion details.
*/
unsigned s_src_quality;
int s_cnv_max;
void *s_cnv_src;
void *s_cnv_dst;
/*
* Volume.
*/
/*
* Callbacks.
*/
/*
* Other per stream details, e.g. channel offset, etc.
*/
int s_choffs;
/*
* Other bits.
*/
unsigned s_engcap; /* ENGINE_xxx_CAP */
};
/*
* struct audio_client: This structure represents a logical port,
* associated with an open file, etc. These are the entities that are
* mixed.
*/
struct audio_client {
void *c_private;
/*
* DDI support.
*/
/*
* Linkage for per-device list of clients.
*/
int c_refcnt;
/*
* Client wide settings... e.g. ops vector, etc.
*/
unsigned c_omode; /* open mode */
struct pollhead c_pollhead;
};
struct audio_infostr {
char i_line[100];
};
struct audio_stats {
};
/*
* An audio engine corresponds to a single DMA transfer channel. It can
* represent either record or playback, but not both at the same time.
* A device that supports simultaneous record and playback will register
* separate channels.
*/
struct audio_engine {
void *e_private;
unsigned e_flags;
/*
* Mixing related fields.
*/
unsigned e_limiter_state;
unsigned e_choffs[AUDIO_MAX_CHANNELS];
unsigned e_chincr[AUDIO_MAX_CHANNELS];
void (*e_export)(audio_engine_t *);
/*
* Underlying physical buffer shared with device driver.
*/
int e_intrs;
int e_errors;
int e_overruns;
int e_underruns;
int e_stream_overruns;
int e_stream_underruns;
/*
* Statistics.
*/
struct audio_stats e_stats;
/*
* Synchronization.
*/
/*
* Linkage for per-device list.
*/
int e_num; /* arbitrary engine number */
/*
* List of of streams attached to this engine.
*/
int e_nrunning;
};
struct audio_dev {
int d_instance;
#define DEV_OUTPUT_CAP (1U << 0)
int d_index; /* master device index */
int d_engno; /* engine counter */
/*
* Synchronization.
*/
unsigned d_refcnt;
/*
* Lists of virtual clients, controls and engines. Protected by
* the d_lock field above.
*/
/*
* Linkage onto global list of devices.
*/
/*
* Personality specific data.
*/
};
/*
* Each audio_dev optionally can have controls attached to it.
* Controls are separate from audio engines. They are methods of
* adjusting pharameters or reading metrics that usually relate to
* hardware on devices engine by the driver. They can be things like
* master volume for example.
*
* If the driver does not support controls then it must insure
* that any hardware controls are initialized to a usable state.
*
* the driver must create, enable and configure controls with
* control API's.
*
* There are a number of common controls (well-known) that most
* hardware supports. These have known names and known ctrl numbers.
* In addition a driver can have any number of extention
* controls (device-private). These can have any name and any ctrl
* number other then the ones, defined as well-knonw ones.
*
* Only controls created through control API's will be available,
* well-known or device-private.
*/
struct audio_ctrl {
void *ctrl_arg;
};
/*
* Prototypes.
*/
/* audio_format.c */
int auimpl_format_alloc(audio_stream_t *);
void auimpl_format_free(audio_stream_t *);
/* audio_output.c */
void auimpl_export_16ne(audio_engine_t *);
void auimpl_export_16oe(audio_engine_t *);
void auimpl_export_24ne(audio_engine_t *);
void auimpl_export_24oe(audio_engine_t *);
void auimpl_export_32ne(audio_engine_t *);
void auimpl_export_32oe(audio_engine_t *);
void auimpl_output_callback(audio_engine_t *);
/* audio_input.c */
void auimpl_input_callback(audio_engine_t *);
int auimpl_input_drain(audio_stream_t *);
/* audio_client.c */
void auimpl_client_init(void);
void auimpl_client_fini(void);
void auimpl_client_destroy(audio_client_t *);
int auimpl_create_minors(audio_dev_t *);
void auimpl_remove_minors(audio_dev_t *);
/* audio_engine.c */
void auimpl_dev_init(void);
void auimpl_dev_fini(void);
void auimpl_dev_hold(audio_dev_t *);
void auimpl_dev_release(audio_dev_t *);
int auimpl_choose_format(int);
void auimpl_engine_close(audio_stream_t *);
void auimpl_dev_walk_engines(audio_dev_t *,
int (*)(audio_engine_t *, void *), void *);
/* engine operations */
/* audio_sun.c */
void auimpl_sun_init(void);
/* audio_oss.c */
void auimpl_oss_init(void);
#endif /* _AUDIO_IMPL_H */