summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/include/mach/audio_switch.h
blob: cedc86d3eb39749cd7e40e7dd8c3617a9446e512 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
 /*
 *
 * arch/arm/mach-tegra/include/mach/audio_switch.h
 *
 * Header and functions for audio switch and apbif module
 *
 * Copyright (c) 2010-2011, NVIDIA Corporation.
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef __ARCH_ARM_MACH_AUDIO_SWITCH_H
#define __ARCH_ARM_MACH_AUDIO_SWITCH_H

#include <linux/kernel.h>
#include <linux/types.h>

#define AUDIOCIF_EXPAND_ZERO	0
#define AUDIOCIF_EXPAND_ONE	1
#define AUDIOCIF_EXPAND_LFSR	2

/* generic macro to set modes */
#define set_reg_mode(r,m,v) {	\
	((r) &= (~(m)));	\
	((r) |= (v)?(m):(0));	\
}

typedef enum ahubtx_
{
	ahubtx0_apbif = 0,
	ahubtx1_apbif,
	ahubtx2_apbif,
	ahubtx3_apbif,
	ahubtx_i2s0,
	ahubtx_i2s1,
	ahubtx_i2s2,
	ahubtx_i2s3,
	ahubtx_i2s4,
	ahubtx_dam0,
	ahubtx_dam1,
	ahubtx_dam2,
	ahubtx0_spdif,
	ahubtx1_spdif,
	ahubtx_maxnum
} ahubtx;

typedef enum ahubrx_
{
	ahubrx0_apbif = 0x0,
	ahubrx1_apbif,
	ahubrx2_apbif,
	ahubrx3_apbif,
	ahubrx_i2s0,
	ahubrx_i2s1,
	ahubrx_i2s2,
	ahubrx_i2s3,
	ahubrx_i2s4,
	ahubrx0_dam0,
	ahubrx1_dam0,
	ahubrx0_dam1,
	ahubrx1_dam1,
	ahubrx0_dam2,
	ahubrx1_dam2,
	ahubrx0_spdif,
	ahubrx1_spdif,
	ahubrx_maxnum
} ahubrx;

typedef enum dam_chtype_
{
	dam_ch_in0 = 0x0,
	dam_ch_in1,
	dam_ch_out,
	dam_ch_maxnum
}dam_chtype;

struct audio_cif
{
	int threshold;
	int audio_channels;
	int client_channels;
	int audio_bits;
	int client_bits;
	int expand;
	int stereo_conv;
	int replicate;
	int direction;
	int truncate;
	int mono_conv;
};

/*
 * API
 */

void apbif_dump_registers(int ifc);
void audio_switch_dump_registers(int ifc);
int  apbif_get_fifo_mode(int ifc, int tx);
int  apbif_get_fifo_freecount(int ifc, int tx);
phys_addr_t apbif_get_fifo_phy_base(int ifc, int tx);
int  apbif_fifo_set_attention_level(int ifc, int tx, unsigned level);
void apbif_set_pack_mode(int ifc, int tx, int pack_mode);
void apbif_channel_set_loopback(int ifc, int on);
void apbif_channel_enable(int ifc, int tx, int enable);
int  apbif_get_channel(int regindex, int fifo_mode);

void apbif_soft_reset(int ifc, int fifo_mode, int enable);
void apbif_fifo_write(int ifc, int fifo_mode, u32 data);
u32 apbif_fifo_read(int ifc, int fifo_mode);
void audio_switch_set_acif(int addr, struct audio_cif *cifInfo);
int  audio_switch_get_rx_port(int rxport);
void audio_switch_set_rx_port(int rxport, int txport);
void audio_switch_clear_rx_port(int rxport);

int audio_apbif_free_channel(int ifc, int fifo_mode);
int audio_apbif_set_acif(int ifc, int fifo_mode, struct audio_cif *cifInfo);
int audio_switch_close(void);
int audio_switch_open(void);
int audio_switch_suspend(void);
int audio_switch_resume(void);
int audio_switch_enable_clock(void);
void audio_switch_disable_clock(void);

void dam_enable(int ifc, int on, int chtype);
void dam_set_samplerate(int ifc, int chtype, int samplerate);

/* FIXME: move to dam.h if needed */
int dam_open(void);
int dam_close(void);
int dam_set_acif(int ifc, int chtype, struct audio_cif *cifInfo);
int dam_get_controller(int chtype);
int dam_free_controller(int ifc, int chtype);
int dam_suspend(int ifc);
int dam_resume(int ifc);
int dam_set_clock_rate(int rate);
int dam_set_clock_parent(int ifc, int parent);
int dam_enable_clock(int ifc);
void dam_disable_clock(int ifc);
int dam_free_dma_requestor(int ifc, int chtype, int fifo_mode);
int dam_get_dma_requestor(int ifc, int chtype, int fifo_mode);
int dam_set_gain(int ifc, int chtype, int gain);

#endif /* __ARCH_ARM_MACH_AUDIO_SWITCH_H */