blob: 1e4840d9c3db18e402d1e6619f4d61dd7a5d04ff [file] [log] [blame]
Michael Sevakis15b73212007-10-02 07:48:50 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Dave Chapman
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Michael Sevakis15b73212007-10-02 07:48:50 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _WM8731_H
23#define _WM8731_H
24
25/* volume/balance/treble/bass interdependency */
26#define VOLUME_MIN -730
27#define VOLUME_MAX 60
28
29extern int tenthdb2master(int db);
30extern int tenthdb2mixer(int db);
31
Michael Sevakis15b73212007-10-02 07:48:50 +000032extern void audiohw_preinit(void);
Christian Gmeiner06971be2008-02-13 11:19:23 +000033extern void audiohw_set_master_vol(int vol_l, int vol_r);
Michael Sevakis15b73212007-10-02 07:48:50 +000034extern void audiohw_set_nsorder(int order);
35extern void audiohw_set_sample_rate(int sampling_control);
36
Michael Sevakis15b73212007-10-02 07:48:50 +000037/* Register addresses and bits */
38#define LINVOL 0x00
39#define LINVOL_MASK 0x1f
40#define LINVOL_LRINBOTH (1 << 8)
41#define LINVOL_LINMUTE (1 << 7)
42
43#define RINVOL 0x01
44#define RINVOL_MASK 0x1f
45#define RINVOL_RINMUTE (1 << 7)
46#define RINVOL_RLINBOTH (1 << 8)
47
48#define LOUTVOL 0x02
49#define LOUTVOL_LHPVOL_MASK 0x7f
50#define LOUTVOL_LZCEN (1 << 7)
51#define LOUTVOL_LRHP_BOTH (1 << 8)
52
53#define ROUTVOL 0x03
54#define ROUTVOL_RHPVOL_MASK 0x7f
55#define ROUTVOL_RZCEN (1 << 7)
56#define ROUTVOL_RLHP_BOTH (1 << 8)
57
58#define AAPCTRL 0x04 /* Analog audio path control */
59#define AAPCTRL_MIC_BOOST (1 << 0)
60#define AAPCTRL_MUTEMIC (1 << 1)
61#define AAPCTRL_INSEL (1 << 2)
62#define AAPCTRL_BYPASS (1 << 3)
63#define AAPCTRL_DACSEL (1 << 4)
64#define AAPCTRL_SIDETONE (1 << 5)
65#define AAPCTRL_SIDEATT_6dB (3 << 6)
66#define AAPCTRL_SIDEATT_9dB (1 << 6)
67#define AAPCTRL_SIDEATT_12dB (2 << 6)
68#define AAPCTRL_SIDEATT_15dB (3 << 6)
69
70#define DAPCTRL 0x05 /* Digital audio path control */
71#define DAPCTRL_ADCHPD (1 << 0)
72#define DAPCTRL_DEEMP_DISABLE (0 << 2)
73#define DAPCTRL_DEEMP_32KHz (1 << 2)
74#define DAPCTRL_DEEMP_44KHz (2 << 2)
75#define DAPCTRL_DEEMP_48KHz (3 << 2)
76#define DAPCTRL_DEEMP_MASK (3 << 2)
77#define DAPCTRL_DACMU (1 << 3)
78#define DAPCTRL_HPOR (1 << 4)
79
80#define PDCTRL 0x06
81#define PDCTRL_LINEINPD (1 << 0)
82#define PDCTRL_MICPD (1 << 1)
83#define PDCTRL_ADCPD (1 << 2)
84#define PDCTRL_DACPD (1 << 3)
85#define PDCTRL_OUTPD (1 << 4)
86#define PDCTRL_OSCPD (1 << 5)
87#define PDCTRL_CLKOUTPD (1 << 6)
88#define PDCTRL_POWEROFF (1 << 7)
89
90#define AINTFCE 0x07
91#define AINTFCE_FORMAT_MSB_RJUST (0 << 0)
92#define AINTFCE_FORMAT_MSB_LJUST (1 << 0)
93#define AINTFCE_FORMAT_I2S (2 << 0)
94#define AINTFCE_FORMAT_DSP (3 << 0)
95#define AINTFCE_FORMAT_MASK (3 << 0)
96#define AINTFCE_IWL_16BIT (0 << 2)
97#define AINTFCE_IWL_20BIT (1 << 2)
98#define AINTFCE_IWL_24BIT (2 << 2)
99#define AINTFCE_IWL_32BIT (3 << 2)
100#define AINTFCE_IWL_MASK (3 << 2)
101#define AINTFCE_LRP_I2S_RLO (0 << 4)
102#define AINTFCE_LRP_I2S_RHI (1 << 4)
Michael Sevakisfc8bc5c2007-10-07 05:59:38 +0000103#define AINTFCE_DSP_MODE_B (0 << 4)
104#define AINTFCE_DSP_MODE_A (1 << 4)
Michael Sevakis15b73212007-10-02 07:48:50 +0000105#define AINTFCE_LRSWAP (1 << 5)
106#define AINTFCE_MS (1 << 6)
107#define AINTFCE_BCLKINV (1 << 7)
108
109#define SAMPCTRL 0x08
110#define SAMPCTRL_USB (1 << 0)
111#define SAMPCTRL_BOSR_NOR_256fs (0 << 1)
112#define SAMPCTRL_BOSR_NOR_384fs (1 << 1)
113#define SAMPCTRL_BOSR_USB_250fs (0 << 1)
114#define SAMPCTRL_BOSR_USB_272fs (1 << 1)
115/* Bits 2-5:
116 * Sample rate setting are device-specific. See WM8731(L) datasheet
117 * for proper settings for the device's clocking */
118#define SAMPCTRL_SR_MASK (0xf << 2)
119#define SAMPCTRL_CLKIDIV2 (1 << 6)
120#define SAMPCTRL_CLKODIV2 (1 << 7)
121
122#define ACTIVECTRL 0x09
123#define ACTIVECTRL_ACTIVE (1 << 0)
124
125#define RESET 0x0f
126#define RESET_RESET 0x0
127
128/* SAMPCTRL values for the supported samplerates (24MHz MCLK/USB): */
129#define WM8731_USB24_8000HZ 0x4d
130#define WM8731_USB24_32000HZ 0x59
131#define WM8731_USB24_44100HZ 0x63
132#define WM8731_USB24_48000HZ 0x41
133#define WM8731_USB24_88200HZ 0x7f
134#define WM8731_USB24_96000HZ 0x5d
135
136#endif /* _WM8731_H */