2007-05-22 15:56:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Christian Gmeiner
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-05-22 15:56:05 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _AUDIOHW_H_
|
|
|
|
#define _AUDIOHW_H_
|
|
|
|
|
|
|
|
#include "config.h"
|
2007-06-13 06:33:40 +00:00
|
|
|
#include <stdbool.h>
|
2007-05-22 15:56:05 +00:00
|
|
|
|
2008-04-28 08:37:18 +00:00
|
|
|
/* define some audiohw caps */
|
2008-05-16 19:28:45 +00:00
|
|
|
#define TREBLE_CAP (1 << 0)
|
|
|
|
#define BASS_CAP (1 << 1)
|
|
|
|
#define BALANCE_CAP (1 << 2)
|
|
|
|
#define CLIPPING_CAP (1 << 3)
|
|
|
|
#define PRESCALER_CAP (1 << 4)
|
|
|
|
#define BASS_CUTOFF_CAP (1 << 5)
|
|
|
|
#define TREBLE_CUTOFF_CAP (1 << 6)
|
2008-04-28 08:37:18 +00:00
|
|
|
|
2007-05-22 20:17:35 +00:00
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
#include "uda1380.h"
|
2009-10-26 18:16:58 +00:00
|
|
|
#elif defined(HAVE_UDA1341)
|
|
|
|
#include "uda1341.h"
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif defined(HAVE_WM8750) || defined(HAVE_WM8751)
|
2007-05-22 20:17:35 +00:00
|
|
|
#include "wm8751.h"
|
2008-04-27 10:30:54 +00:00
|
|
|
#elif defined(HAVE_WM8978)
|
|
|
|
#include "wm8978.h"
|
|
|
|
#elif defined(HAVE_WM8975)
|
2007-05-22 20:17:35 +00:00
|
|
|
#include "wm8975.h"
|
2008-01-14 22:04:48 +00:00
|
|
|
#elif defined(HAVE_WM8985)
|
|
|
|
#include "wm8985.h"
|
2007-05-22 20:17:35 +00:00
|
|
|
#elif defined(HAVE_WM8758)
|
|
|
|
#include "wm8758.h"
|
2008-12-08 21:09:56 +00:00
|
|
|
#elif defined(HAVE_WM8711) || defined(HAVE_WM8721) || \
|
|
|
|
defined(HAVE_WM8731)
|
2007-10-02 07:48:50 +00:00
|
|
|
#include "wm8731.h"
|
2007-05-22 20:17:35 +00:00
|
|
|
#elif defined(HAVE_TLV320)
|
|
|
|
#include "tlv320.h"
|
|
|
|
#elif defined(HAVE_AS3514)
|
|
|
|
#include "as3514.h"
|
|
|
|
#elif defined(HAVE_MAS35XX)
|
|
|
|
#include "mas35xx.h"
|
2008-04-27 13:43:05 +00:00
|
|
|
#elif defined(HAVE_TSC2100)
|
|
|
|
#include "tsc2100.h"
|
2009-02-26 21:15:40 +00:00
|
|
|
#elif defined(HAVE_JZ4740_CODEC)
|
|
|
|
#include "jz4740-codec.h"
|
2009-05-25 21:10:45 +00:00
|
|
|
#elif defined(HAVE_AK4537)
|
|
|
|
#include "ak4537.h"
|
2007-05-22 20:17:35 +00:00
|
|
|
#endif
|
|
|
|
|
2010-04-25 22:54:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define ONE_DB 10
|
|
|
|
|
|
|
|
#if !defined(VOLUME_MIN) && !defined(VOLUME_MAX)
|
|
|
|
#warning define for VOLUME_MIN and VOLUME_MAX is missing
|
|
|
|
#define VOLUME_MIN -700
|
|
|
|
#define VOLUME_MAX 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* volume/balance/treble/bass interdependency main part */
|
|
|
|
#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
|
|
|
|
|
|
|
|
|
2008-04-28 08:37:18 +00:00
|
|
|
/* convert caps into defines */
|
|
|
|
#ifdef AUDIOHW_CAPS
|
|
|
|
#if (AUDIOHW_CAPS & TREBLE_CAP)
|
|
|
|
#define AUDIOHW_HAVE_TREBLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (AUDIOHW_CAPS & BASS_CAP)
|
|
|
|
#define AUDIOHW_HAVE_BASS
|
|
|
|
#endif
|
2008-05-13 06:19:16 +00:00
|
|
|
|
|
|
|
#if (AUDIOHW_CAPS & BALANCE_CAP)
|
|
|
|
#define AUDIOHW_HAVE_BALANCE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (AUDIOHW_CAPS & CLIPPING_CAP)
|
|
|
|
#define AUDIOHW_HAVE_CLIPPING
|
|
|
|
#endif
|
2008-05-14 21:35:19 +00:00
|
|
|
|
|
|
|
#if (AUDIOHW_CAPS & PRESCALER_CAP)
|
|
|
|
#define AUDIOHW_HAVE_PRESCALER
|
|
|
|
#endif
|
2008-05-16 19:28:45 +00:00
|
|
|
|
|
|
|
#if (AUDIOHW_CAPS & BASS_CUTOFF_CAP)
|
|
|
|
#define AUDIOHW_HAVE_BASS_CUTOFF
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (AUDIOHW_CAPS & TREBLE_CUTOFF_CAP)
|
|
|
|
#define AUDIOHW_HAVE_TREBLE_CUTOFF
|
|
|
|
#endif
|
2008-04-28 08:37:18 +00:00
|
|
|
#endif /* AUDIOHW_CAPS */
|
|
|
|
|
2007-05-22 15:56:05 +00:00
|
|
|
enum {
|
|
|
|
SOUND_VOLUME = 0,
|
|
|
|
SOUND_BASS,
|
|
|
|
SOUND_TREBLE,
|
|
|
|
SOUND_BALANCE,
|
|
|
|
SOUND_CHANNELS,
|
|
|
|
SOUND_STEREO_WIDTH,
|
|
|
|
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
|
|
|
SOUND_LOUDNESS,
|
|
|
|
SOUND_AVC,
|
|
|
|
SOUND_MDB_STRENGTH,
|
|
|
|
SOUND_MDB_HARMONICS,
|
|
|
|
SOUND_MDB_CENTER,
|
|
|
|
SOUND_MDB_SHAPE,
|
|
|
|
SOUND_MDB_ENABLE,
|
|
|
|
SOUND_SUPERBASS,
|
|
|
|
#endif
|
2008-05-16 20:26:20 +00:00
|
|
|
#if defined(HAVE_RECORDING)
|
2007-05-22 15:56:05 +00:00
|
|
|
SOUND_LEFT_GAIN,
|
|
|
|
SOUND_RIGHT_GAIN,
|
|
|
|
SOUND_MIC_GAIN,
|
|
|
|
#endif
|
2008-05-16 19:28:45 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
|
2007-11-24 07:51:00 +00:00
|
|
|
SOUND_BASS_CUTOFF,
|
2008-05-16 19:28:45 +00:00
|
|
|
#endif
|
|
|
|
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
|
2007-11-24 07:51:00 +00:00
|
|
|
SOUND_TREBLE_CUTOFF,
|
|
|
|
#endif
|
2009-01-02 11:21:58 +00:00
|
|
|
SOUND_LAST_SETTING, /* Keep this last */
|
2007-05-22 15:56:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Channel {
|
|
|
|
SOUND_CHAN_STEREO,
|
|
|
|
SOUND_CHAN_MONO,
|
|
|
|
SOUND_CHAN_CUSTOM,
|
|
|
|
SOUND_CHAN_MONO_LEFT,
|
|
|
|
SOUND_CHAN_MONO_RIGHT,
|
|
|
|
SOUND_CHAN_KARAOKE,
|
|
|
|
SOUND_CHAN_NUM_MODES,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sound_settings_info {
|
|
|
|
const char *unit;
|
2008-08-11 13:01:01 +00:00
|
|
|
char numdecimals;
|
|
|
|
char steps;
|
|
|
|
short minval;
|
|
|
|
short maxval;
|
|
|
|
short defaultval;
|
2007-05-22 15:56:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This struct is used by every driver to export its min/max/default values for
|
|
|
|
* its audio settings. Keep in mind that the order must be correct! */
|
|
|
|
extern const struct sound_settings_info audiohw_settings[];
|
|
|
|
|
2007-06-11 23:39:07 +00:00
|
|
|
/* All usable functions implemented by a audio codec drivers. Most of
|
|
|
|
* the function in sound settings are only called, when in audio codecs
|
|
|
|
* .h file suitable defines are added.
|
|
|
|
*/
|
|
|
|
|
2007-06-13 06:33:40 +00:00
|
|
|
/**
|
2008-11-26 14:25:45 +00:00
|
|
|
* Initialize audio codec to a well defined state. Includes SoC-specific
|
|
|
|
* setup.
|
2007-06-13 06:33:40 +00:00
|
|
|
*/
|
|
|
|
void audiohw_init(void);
|
|
|
|
|
2008-02-12 20:40:53 +00:00
|
|
|
/**
|
2008-11-26 14:25:45 +00:00
|
|
|
* Do initial audio codec setup. Usually called from audiohw_init.
|
2008-04-27 10:30:54 +00:00
|
|
|
*/
|
|
|
|
void audiohw_preinit(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do some stuff (codec related) after audiohw_init that needs to be
|
|
|
|
* delayed such as enabling outputs to prevent popping. This lets
|
|
|
|
* other inits in the system complete in the meantime.
|
2008-02-12 20:40:53 +00:00
|
|
|
*/
|
|
|
|
void audiohw_postinit(void);
|
|
|
|
|
2007-06-13 06:33:40 +00:00
|
|
|
/**
|
|
|
|
* Close audio codec.
|
|
|
|
*/
|
|
|
|
void audiohw_close(void);
|
|
|
|
|
2008-05-13 06:19:16 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_CLIPPING
|
|
|
|
/**
|
|
|
|
* Set new volume value
|
|
|
|
* @param val to set.
|
|
|
|
* NOTE: AUDIOHW_CAPS need to contain
|
|
|
|
* CLIPPING_CAP
|
|
|
|
*/
|
|
|
|
void audiohw_set_volume(int val);
|
|
|
|
#endif
|
|
|
|
|
2008-05-14 21:35:19 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_PRESCALER
|
|
|
|
/**
|
|
|
|
* Set new prescaler value.
|
|
|
|
* @param val to set.
|
|
|
|
* NOTE: AUDIOHW_CAPS need to contain
|
|
|
|
* PRESCALER_CAP
|
|
|
|
*/
|
|
|
|
void audiohw_set_prescaler(int val);
|
|
|
|
#endif
|
|
|
|
|
2008-05-13 06:19:16 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_BALANCE
|
|
|
|
/**
|
|
|
|
* Set new balance value
|
|
|
|
* @param val to set.
|
|
|
|
* NOTE: AUDIOHW_CAPS need to contain
|
|
|
|
* BALANCE_CAP
|
|
|
|
*/
|
|
|
|
void audiohw_set_balance(int val);
|
|
|
|
#endif
|
|
|
|
|
2008-04-28 08:37:18 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_TREBLE
|
|
|
|
/**
|
|
|
|
* Set new treble value.
|
|
|
|
* @param val to set.
|
|
|
|
* NOTE: AUDIOHW_CAPS need to contain
|
|
|
|
* TREBLE_CAP
|
|
|
|
*/
|
|
|
|
void audiohw_set_treble(int val);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIOHW_HAVE_BASS
|
|
|
|
/**
|
|
|
|
* Set new bass value.
|
|
|
|
* @param val to set.
|
|
|
|
* NOTE: AUDIOHW_CAPS need to contain
|
|
|
|
* BASS_CAP
|
|
|
|
*/
|
|
|
|
void audiohw_set_bass(int val);
|
|
|
|
#endif
|
|
|
|
|
2008-05-16 19:28:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_BASS_CUTOFF
|
|
|
|
/**
|
|
|
|
* Set new bass cut off value.
|
|
|
|
* @param val to set.
|
|
|
|
* NOTE: AUDIOHW_CAPS need to contain
|
|
|
|
* BASS_CUTOFF_CAP
|
|
|
|
*/
|
|
|
|
void audiohw_set_bass_cutoff(int val);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
|
|
|
|
/**
|
|
|
|
* Set new treble cut off value.
|
|
|
|
* @param val to set.
|
|
|
|
* NOTE: AUDIOHW_CAPS need to contain
|
|
|
|
* TREBLE_CUTOFF_CAP
|
|
|
|
*/
|
|
|
|
void audiohw_set_treble_cutoff(int val);
|
|
|
|
#endif
|
|
|
|
|
2009-01-20 22:55:10 +00:00
|
|
|
void audiohw_set_frequency(int fsel);
|
|
|
|
|
2007-11-19 15:50:52 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable recording.
|
|
|
|
* @param source_mic if this is true, we want to record from microphone,
|
|
|
|
* else we want to record FM/LineIn.
|
|
|
|
*/
|
|
|
|
void audiohw_enable_recording(bool source_mic);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable recording.
|
|
|
|
*/
|
|
|
|
void audiohw_disable_recording(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set gain of recording source.
|
|
|
|
* @param left gain value.
|
|
|
|
* @param right will not be used if recording from micophone (mono).
|
|
|
|
* @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN.
|
|
|
|
*/
|
|
|
|
void audiohw_set_recvol(int left, int right, int type);
|
|
|
|
|
2009-02-05 19:57:18 +00:00
|
|
|
#endif /*HAVE_RECORDING*/
|
|
|
|
|
|
|
|
#if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
|
|
|
|
|
2007-11-19 15:50:52 +00:00
|
|
|
/**
|
|
|
|
* Enable or disable recording monitor.
|
|
|
|
* @param enable ture or false.
|
|
|
|
*/
|
|
|
|
void audiohw_set_monitor(bool enable);
|
|
|
|
|
2009-02-05 19:57:18 +00:00
|
|
|
#endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */
|
2008-04-22 13:43:01 +00:00
|
|
|
|
|
|
|
#if CONFIG_CODEC != SWCODEC
|
|
|
|
|
|
|
|
/* functions which are only used by mas35xx codecs, but are also
|
|
|
|
aviable on SWCODECS through dsp */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set channel configuration.
|
|
|
|
* @param val new channel value (see enum Channel).
|
|
|
|
*/
|
|
|
|
void audiohw_set_channel(int val);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set stereo width.
|
|
|
|
* @param val new stereo width value.
|
|
|
|
*/
|
|
|
|
void audiohw_set_stereo_width(int val);
|
|
|
|
|
|
|
|
#endif /* CONFIG_CODEC != SWCODEC */
|
|
|
|
|
2009-03-02 18:18:24 +00:00
|
|
|
#ifdef HAVE_SPEAKER
|
|
|
|
|
|
|
|
void audiohw_enable_speaker(bool on);
|
|
|
|
|
|
|
|
#endif /* HAVE_SPEAKER */
|
|
|
|
|
2007-05-22 15:56:05 +00:00
|
|
|
#endif /* _AUDIOHW_H_ */
|