ASoC: SSM2602: add SND control for mic boost2 and default it to off
[deliverable/linux.git] / sound / soc / blackfin / bf5xx-sport.h
CommitLineData
8c9c1983
CC
1/*
2 * File: bf5xx_ac97_sport.h
3 * Based on:
4 * Author: Roy Huang <roy.huang@analog.com>
5 *
6 * Created:
7 * Description:
8 *
9 * Copyright 2004-2007 Analog Devices Inc.
10 *
11 * Bugs: Enter bugs at http://blackfin.uclinux.org/
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see the file COPYING, or write
25 * to the Free Software Foundation, Inc.,
26 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 */
28
29
30#ifndef __BF5XX_SPORT_H__
31#define __BF5XX_SPORT_H__
32
33#include <linux/types.h>
34#include <linux/wait.h>
35#include <linux/workqueue.h>
36#include <asm/dma.h>
37
38struct sport_register {
39 u16 tcr1; u16 reserved0;
40 u16 tcr2; u16 reserved1;
41 u16 tclkdiv; u16 reserved2;
42 u16 tfsdiv; u16 reserved3;
43 u32 tx;
44 u32 reserved_l0;
45 u32 rx;
46 u32 reserved_l1;
47 u16 rcr1; u16 reserved4;
48 u16 rcr2; u16 reserved5;
49 u16 rclkdiv; u16 reserved6;
50 u16 rfsdiv; u16 reserved7;
51 u16 stat; u16 reserved8;
52 u16 chnl; u16 reserved9;
53 u16 mcmc1; u16 reserved10;
54 u16 mcmc2; u16 reserved11;
55 u32 mtcs0;
56 u32 mtcs1;
57 u32 mtcs2;
58 u32 mtcs3;
59 u32 mrcs0;
60 u32 mrcs1;
61 u32 mrcs2;
62 u32 mrcs3;
63};
64
65#define DESC_ELEMENT_COUNT 9
66
67struct sport_device {
68 int dma_rx_chan;
69 int dma_tx_chan;
70 int err_irq;
71 struct sport_register *regs;
72
73 unsigned char *rx_buf;
74 unsigned char *tx_buf;
75 unsigned int rx_fragsize;
76 unsigned int tx_fragsize;
77 unsigned int rx_frags;
78 unsigned int tx_frags;
79 unsigned int wdsize;
80
81 /* for dummy dma transfer */
82 void *dummy_buf;
83 unsigned int dummy_count;
84
85 /* DMA descriptor ring head of current audio stream*/
86 struct dmasg *dma_rx_desc;
87 struct dmasg *dma_tx_desc;
88 unsigned int rx_desc_bytes;
89 unsigned int tx_desc_bytes;
90
91 unsigned int rx_run:1; /* rx is running */
92 unsigned int tx_run:1; /* tx is running */
93
94 struct dmasg *dummy_rx_desc;
95 struct dmasg *dummy_tx_desc;
96
97 struct dmasg *curr_rx_desc;
98 struct dmasg *curr_tx_desc;
99
100 int rx_curr_frag;
101 int tx_curr_frag;
102
103 unsigned int rcr1;
104 unsigned int rcr2;
105 int rx_tdm_count;
106
107 unsigned int tcr1;
108 unsigned int tcr2;
109 int tx_tdm_count;
110
111 void (*rx_callback)(void *data);
112 void *rx_data;
113 void (*tx_callback)(void *data);
114 void *tx_data;
115 void (*err_callback)(void *data);
116 void *err_data;
117 unsigned char *tx_dma_buf;
118 unsigned char *rx_dma_buf;
67f854b9 119#ifdef CONFIG_SND_BF5XX_MMAP_SUPPORT
8c9c1983
CC
120 dma_addr_t tx_dma_phy;
121 dma_addr_t rx_dma_phy;
122 int tx_pos;/*pcm sample count*/
123 int rx_pos;
124 unsigned int tx_buffer_size;
125 unsigned int rx_buffer_size;
6b58a821
CC
126 int tx_delay_pos;
127 int once;
8c9c1983
CC
128#endif
129 void *private_data;
130};
131
132extern struct sport_device *sport_handle;
133
134struct sport_param {
135 int dma_rx_chan;
136 int dma_tx_chan;
137 int err_irq;
138 struct sport_register *regs;
139};
140
141struct sport_device *sport_init(struct sport_param *param, unsigned wdsize,
142 unsigned dummy_count, void *private_data);
143
144void sport_done(struct sport_device *sport);
145
146/* first use these ...*/
147
148/* note: multichannel is in units of 8 channels, tdm_count is number of channels
149 * NOT / 8 ! all channels are enabled by default */
150int sport_set_multichannel(struct sport_device *sport, int tdm_count,
151 u32 mask, int packed);
152
153int sport_config_rx(struct sport_device *sport,
154 unsigned int rcr1, unsigned int rcr2,
155 unsigned int clkdiv, unsigned int fsdiv);
156
157int sport_config_tx(struct sport_device *sport,
158 unsigned int tcr1, unsigned int tcr2,
159 unsigned int clkdiv, unsigned int fsdiv);
160
161/* ... then these: */
162
163/* buffer size (in bytes) == fragcount * fragsize_bytes */
164
165/* this is not a very general api, it sets the dma to 2d autobuffer mode */
166
167int sport_config_rx_dma(struct sport_device *sport, void *buf,
168 int fragcount, size_t fragsize_bytes);
169
170int sport_config_tx_dma(struct sport_device *sport, void *buf,
171 int fragcount, size_t fragsize_bytes);
172
173int sport_tx_start(struct sport_device *sport);
174int sport_tx_stop(struct sport_device *sport);
175int sport_rx_start(struct sport_device *sport);
176int sport_rx_stop(struct sport_device *sport);
177
178/* for use in interrupt handler */
179unsigned long sport_curr_offset_rx(struct sport_device *sport);
180unsigned long sport_curr_offset_tx(struct sport_device *sport);
181
182void sport_incfrag(struct sport_device *sport, int *frag, int tx);
183void sport_decfrag(struct sport_device *sport, int *frag, int tx);
184
185int sport_set_rx_callback(struct sport_device *sport,
186 void (*rx_callback)(void *), void *rx_data);
187int sport_set_tx_callback(struct sport_device *sport,
188 void (*tx_callback)(void *), void *tx_data);
189int sport_set_err_callback(struct sport_device *sport,
190 void (*err_callback)(void *), void *err_data);
191
192int sport_send_and_recv(struct sport_device *sport, u8 *out_data, \
193 u8 *in_data, int len);
194#endif /* BF53X_SPORT_H */
This page took 0.073124 seconds and 5 git commands to generate.