14 #include <linux/module.h>
17 #include <linux/wait.h>
19 #include <linux/slab.h>
47 size_t count,
unsigned int chan_mask)
51 if (chan_mask &
SP_FL) {
55 if (chan_mask &
SP_FR) {
60 #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT)
61 if (chan_mask &
SP_SR) {
62 dst->ac97_sl = *src++;
65 if (chan_mask &
SP_SL) {
66 dst->ac97_sr = *src++;
70 dst->ac97_lfe = *src++;
73 if (chan_mask &
SP_FC) {
74 dst->ac97_center = *src++;
94 static unsigned int sport_tx_curr_frag(
struct sport_device *sport)
104 int nextfrag = sport_tx_curr_frag(sport);
111 pr_debug(
"sport->tx_buf:%p, nextfrag:0x%x nextwrite:%p, cmd_count:%d\n",
112 sport->
tx_buf, nextfrag, nextwrite, cmd_count[nextfrag]);
116 ++cmd_count[nextfrag];
117 pr_debug(
"ac97_sport: Inserting %02x/%04x into fragment %d\n",
118 addr >> 8, data, nextfrag);
121 static unsigned short bf5xx_ac97_read(
struct snd_ac97 *ac97,
127 pr_debug(
"%s enter 0x%x\n", __func__, reg);
132 "to report this?\n");
139 out_frame[0].ac97_addr = ((reg << 8) | 0x8000);
141 (
unsigned char *)&in_frame,
143 return in_frame[1].ac97_data;
151 pr_debug(
"%s enter 0x%x:0x%04x\n", __func__, reg, val);
153 if (sport_handle->
tx_run) {
154 enqueue_cmd(ac97, (reg << 8), val);
155 enqueue_cmd(ac97, (reg << 8) | 0x8000, 0);
167 static void bf5xx_ac97_warm_reset(
struct snd_ac97 *ac97)
184 static void bf5xx_ac97_cold_reset(
struct snd_ac97 *ac97)
186 #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
197 pr_info(
"%s: Not implemented\n", __func__);
202 .read = bf5xx_ac97_read,
204 .warm_reset = bf5xx_ac97_warm_reset,
205 .reset = bf5xx_ac97_cold_reset,
212 struct sport_device *sport = snd_soc_dai_get_drvdata(dai);
214 pr_debug(
"%s : sport %d\n", __func__, dai->
id);
227 struct sport_device *sport = snd_soc_dai_get_drvdata(dai);
229 pr_debug(
"%s : sport %d\n", __func__, dai->
id);
233 #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT)
239 pr_err(
"SPORT is busy!\n");
245 pr_err(
"SPORT is busy!\n");
251 pr_err(
"SPORT is busy!\n");
259 #define bf5xx_ac97_suspend NULL
260 #define bf5xx_ac97_resume NULL
268 .stream_name =
"AC97 Playback",
270 #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT)
278 .stream_name =
"AC97 Capture",
290 #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
292 if (
gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM,
"SND_AD198x RESET")) {
293 pr_err(
"Failed to request GPIO_%d for reset\n",
294 CONFIG_SND_BF5XX_RESET_GPIO_NUM);
309 #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT)
315 pr_err(
"SPORT is busy!\n");
317 goto sport_config_err;
322 pr_err(
"SPORT is busy!\n");
324 goto sport_config_err;
329 pr_err(
"SPORT is busy!\n");
331 goto sport_config_err;
336 pr_err(
"Failed to register DAI: %d\n", ret);
337 goto sport_config_err;
340 ac97_sport_handle = sport_handle;
347 #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
348 gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM);
357 struct sport_device *sport_handle = platform_get_drvdata(pdev);
361 #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
362 gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM);
374 .probe = asoc_bfin_ac97_probe,