blob: c465764e778fc9ae8cb8f7a4d2b4a62d984a6d86 [file] [log] [blame]
Liam Girdwood529e46d2011-02-03 18:26:41 +00001/*
2
3 This file is provided under a dual BSD/GPLv2 license. When using or
4 redistributing this file, you may do so under either license.
5
6 GPL LICENSE SUMMARY
7
8 Copyright(c) 2010-2011 Texas Instruments Incorporated,
9 All rights reserved.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of version 2 of the GNU General Public License as
13 published by the Free Software Foundation.
14
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23 The full GNU General Public License is included in this distribution
24 in the file called LICENSE.GPL.
25
26 BSD LICENSE
27
28 Copyright(c) 2010-2011 Texas Instruments Incorporated,
29 All rights reserved.
30
31 Redistribution and use in source and binary forms, with or without
32 modification, are permitted provided that the following conditions
33 are met:
34
35 * Redistributions of source code must retain the above copyright
36 notice, this list of conditions and the following disclaimer.
37 * Redistributions in binary form must reproduce the above copyright
38 notice, this list of conditions and the following disclaimer in
39 the documentation and/or other materials provided with the
40 distribution.
41 * Neither the name of Texas Instruments Incorporated nor the names of
42 its contributors may be used to endorse or promote products derived
43 from this software without specific prior written permission.
44
45 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56
57*/
58
59#ifndef _ABE_H_
60#define _ABE_H_
61
62#include <linux/module.h>
63#include <linux/moduleparam.h>
64#include <linux/init.h>
65#include <linux/err.h>
66#include <linux/slab.h>
67#include <linux/io.h>
68
69#include "abe_def.h"
70#include "abe_define.h"
71#include "abe_fw.h"
72#include "abe_ext.h"
73#include "abe_dbg.h"
74
75/*
76 * BASIC TYPES
77 */
78#define MAX_UINT8 ((((1L << 7) - 1) << 1) + 1)
79#define MAX_UINT16 ((((1L << 15) - 1) << 1) + 1)
80#define MAX_UINT32 ((((1L << 31) - 1) << 1) + 1)
81
82#define s8 char
83#define u8 unsigned char
84#define s16 short
85#define u16 unsigned short
86#define s32 int
87#define u32 unsigned int
88
89struct omap_abe_equ {
90 /* type of filter */
91 u32 equ_type;
92 /* filter length */
93 u32 equ_length;
94 union {
95 /* parameters are the direct and recursive coefficients in */
96 /* Q6.26 integer fixed-point format. */
97 s32 type1[NBEQ1];
98 struct {
99 /* center frequency of the band [Hz] */
100 s32 freq[NBEQ2];
101 /* gain of each band. [dB] */
102 s32 gain[NBEQ2];
103 /* Q factor of this band [dB] */
104 s32 q[NBEQ2];
105 } type2;
106 } coef;
107 s32 equ_param3;
108};
109
110struct omap_abe {
111 void __iomem *io_base[5];
112 u32 firmware_version_number;
113 u16 MultiFrame[PROCESSING_SLOTS][TASKS_IN_SLOT];
114 u32 compensated_mixer_gain;
115 u8 muted_gains_indicator[MAX_NBGAIN_CMEM];
116 u32 desired_gains_decibel[MAX_NBGAIN_CMEM];
117 u32 muted_gains_decibel[MAX_NBGAIN_CMEM];
118 u32 desired_gains_linear[MAX_NBGAIN_CMEM];
119 u32 desired_ramp_delay_ms[MAX_NBGAIN_CMEM];
120 struct mutex mutex;
121 u32 warm_boot;
122
123 u32 irq_dbg_read_ptr;
124
125 struct omap_abe_dbg dbg;
126};
127
128extern struct omap_abe *abe;
129
130void omap_abe_dbg_log(struct omap_abe *abe, u32 x, u32 y, u32 z, u32 t);
131void omap_abe_dbg_error(struct omap_abe *abe, int level, int error);
132int omap_abe_set_opp_processing(struct omap_abe *abe, u32 opp);
133int omap_abe_connect_debug_trace(struct omap_abe *abe,
134 struct omap_abe_dma *dma2);
135
136int omap_abe_use_compensated_gain(struct omap_abe *abe, int on_off);
137int omap_abe_write_equalizer(struct omap_abe *abe,
138 u32 id, struct omap_abe_equ *param);
139
140int omap_abe_disable_gain(struct omap_abe *abe, u32 id, u32 p);
141int omap_abe_enable_gain(struct omap_abe *abe, u32 id, u32 p);
142int omap_abe_mute_gain(struct omap_abe *abe, u32 id, u32 p);
143int omap_abe_unmute_gain(struct omap_abe *abe, u32 id, u32 p);
144
145int omap_abe_write_gain(struct omap_abe *abe,
146 u32 id, s32 f_g, u32 ramp, u32 p);
147int omap_abe_write_mixer(struct omap_abe *abe,
148 u32 id, s32 f_g, u32 f_ramp, u32 p);
149int omap_abe_read_gain(struct omap_abe *abe,
150 u32 id, u32 *f_g, u32 p);
151int omap_abe_read_mixer(struct omap_abe *abe,
152 u32 id, u32 *f_g, u32 p);
153
154/*
155 * MACROS
156 */
157#define _log(x, y, z, t) { if (x & abe->dbg.mask) omap_abe_dbg_log(abe, x, y, z, t); }
158
159#endif/* _ABE_H_ */