Commit 419edf1b authored by Daniel Petrini's avatar Daniel Petrini Committed by Tony Lindgren

[PATCH] ARM: OMAP: Alsa modularisations and support for tsc2101 1/3 (round 2)

This 1/3 patch prepares the addon of tsc2101 driver by renaming structures
that can be shared by aic23 and tsc2101 drivers to more specific names.
In addition this patch renames DMA function names so that they do not
conflict with the dma function names in the oss driver.
Signed-off-by: default avatarMika Laitio <lamikr@cc.jyu.fi>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 51c0cddf
...@@ -98,7 +98,7 @@ MODULE_ALIAS("omap_mcbsp.1"); ...@@ -98,7 +98,7 @@ MODULE_ALIAS("omap_mcbsp.1");
static char *id = NULL; static char *id = NULL;
MODULE_PARM_DESC(id, "OMAP OSK ALSA Driver for AIC23 chip."); MODULE_PARM_DESC(id, "OMAP OSK ALSA Driver for AIC23 chip.");
static struct snd_card_omap_aic23 *omap_aic23 = NULL; static struct snd_card_omap_codec *omap_aic23 = NULL;
static struct clk *aic23_mclk = 0; static struct clk *aic23_mclk = 0;
...@@ -182,7 +182,7 @@ static int audio_ifc_stop(void) ...@@ -182,7 +182,7 @@ static int audio_ifc_stop(void)
/* /*
* Sample rate changing * Sample rate changing
*/ */
static void omap_aic23_set_samplerate(struct snd_card_omap_aic23 static void omap_aic23_set_samplerate(struct snd_card_omap_codec
*omap_aic23, long rate) *omap_aic23, long rate)
{ {
u8 count = 0; u8 count = 0;
...@@ -252,7 +252,7 @@ static inline void aic23_configure(void) ...@@ -252,7 +252,7 @@ static inline void aic23_configure(void)
} }
static void omap_aic23_audio_init(struct snd_card_omap_aic23 *omap_aic23) static void omap_aic23_audio_init(struct snd_card_omap_codec *omap_aic23)
{ {
/* Setup DMA stuff */ /* Setup DMA stuff */
omap_aic23->s[SNDRV_PCM_STREAM_PLAYBACK].id = "Alsa AIC23 out"; omap_aic23->s[SNDRV_PCM_STREAM_PLAYBACK].id = "Alsa AIC23 out";
...@@ -298,7 +298,7 @@ static int audio_dma_request(struct audio_stream *s, ...@@ -298,7 +298,7 @@ static int audio_dma_request(struct audio_stream *s,
{ {
int err; int err;
err = omap_request_sound_dma(s->dma_dev, s->id, s, &s->lch); err = omap_request_alsa_sound_dma(s->dma_dev, s->id, s, &s->lch);
if (err < 0) if (err < 0)
printk(KERN_ERR "unable to grab audio dma 0x%x\n", printk(KERN_ERR "unable to grab audio dma 0x%x\n",
s->dma_dev); s->dma_dev);
...@@ -309,7 +309,7 @@ static int audio_dma_free(struct audio_stream *s) ...@@ -309,7 +309,7 @@ static int audio_dma_free(struct audio_stream *s)
{ {
int err = 0; int err = 0;
err = omap_free_sound_dma(s, &s->lch); err = omap_free_alsa_sound_dma(s, &s->lch);
if (err < 0) if (err < 0)
printk(KERN_ERR "Unable to free audio dma channels!\n"); printk(KERN_ERR "Unable to free audio dma channels!\n");
return err; return err;
...@@ -360,9 +360,10 @@ static void audio_stop_dma(struct audio_stream *s) ...@@ -360,9 +360,10 @@ static void audio_stop_dma(struct audio_stream *s)
s->periods = 0; s->periods = 0;
/* this stops the dma channel and clears the buffer ptrs */ /* this stops the dma channel and clears the buffer ptrs */
omap_audio_stop_dma(s); /* this stops the dma channel and clears the buffer ptrs */
omap_stop_alsa_sound_dma(s);
omap_clear_sound_dma(s); omap_clear_alsa_sound_dma(s);
spin_unlock_irqrestore(&s->dma_lock, flags); spin_unlock_irqrestore(&s->dma_lock, flags);
} }
...@@ -383,8 +384,7 @@ static void audio_process_dma(struct audio_stream *s) ...@@ -383,8 +384,7 @@ static void audio_process_dma(struct audio_stream *s)
dma_size = frames_to_bytes(runtime, runtime->period_size); dma_size = frames_to_bytes(runtime, runtime->period_size);
offset = dma_size * s->period; offset = dma_size * s->period;
snd_assert(dma_size <= DMA_BUF_SIZE,); snd_assert(dma_size <= DMA_BUF_SIZE,);
ret = ret = omap_start_alsa_sound_dma(s,
omap_start_sound_dma(s,
(dma_addr_t) runtime->dma_area + (dma_addr_t) runtime->dma_area +
offset, dma_size); offset, dma_size);
if (ret) { if (ret) {
...@@ -404,7 +404,7 @@ static void audio_process_dma(struct audio_stream *s) ...@@ -404,7 +404,7 @@ static void audio_process_dma(struct audio_stream *s)
/* /*
* This is called when dma IRQ occurs at the end of each transmited block * This is called when dma IRQ occurs at the end of each transmited block
*/ */
void audio_dma_callback(void *data) void callback_omap_alsa_sound_dma(void *data)
{ {
struct audio_stream *s = data; struct audio_stream *s = data;
...@@ -429,9 +429,9 @@ void audio_dma_callback(void *data) ...@@ -429,9 +429,9 @@ void audio_dma_callback(void *data)
* PCM settings and callbacks * PCM settings and callbacks
*/ */
static int snd_omap_aic23_trigger(snd_pcm_substream_t * substream, int cmd) static int snd_omap_alsa_trigger(snd_pcm_substream_t * substream, int cmd)
{ {
struct snd_card_omap_aic23 *chip = struct snd_card_omap_codec *chip =
snd_pcm_substream_chip(substream); snd_pcm_substream_chip(substream);
int stream_id = substream->pstr->stream; int stream_id = substream->pstr->stream;
struct audio_stream *s = &chip->s[stream_id]; struct audio_stream *s = &chip->s[stream_id];
...@@ -459,9 +459,9 @@ static int snd_omap_aic23_trigger(snd_pcm_substream_t * substream, int cmd) ...@@ -459,9 +459,9 @@ static int snd_omap_aic23_trigger(snd_pcm_substream_t * substream, int cmd)
return err; return err;
} }
static int snd_omap_aic23_prepare(snd_pcm_substream_t * substream) static int snd_omap_alsa_prepare(snd_pcm_substream_t * substream)
{ {
struct snd_card_omap_aic23 *chip = struct snd_card_omap_codec *chip =
snd_pcm_substream_chip(substream); snd_pcm_substream_chip(substream);
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
struct audio_stream *s = &chip->s[substream->pstr->stream]; struct audio_stream *s = &chip->s[substream->pstr->stream];
...@@ -475,10 +475,10 @@ static int snd_omap_aic23_prepare(snd_pcm_substream_t * substream) ...@@ -475,10 +475,10 @@ static int snd_omap_aic23_prepare(snd_pcm_substream_t * substream)
return 0; return 0;
} }
static snd_pcm_uframes_t snd_omap_aic23_pointer(snd_pcm_substream_t * static snd_pcm_uframes_t snd_omap_alsa_pointer(snd_pcm_substream_t *
substream) substream)
{ {
struct snd_card_omap_aic23 *chip = struct snd_card_omap_codec *chip =
snd_pcm_substream_chip(substream); snd_pcm_substream_chip(substream);
return audio_get_dma_pos(&chip->s[substream->pstr->stream]); return audio_get_dma_pos(&chip->s[substream->pstr->stream]);
...@@ -486,7 +486,7 @@ static snd_pcm_uframes_t snd_omap_aic23_pointer(snd_pcm_substream_t * ...@@ -486,7 +486,7 @@ static snd_pcm_uframes_t snd_omap_aic23_pointer(snd_pcm_substream_t *
/* Hardware capabilities */ /* Hardware capabilities */
static snd_pcm_hardware_t snd_omap_aic23_capture = { static snd_pcm_hardware_t snd_omap_alsa_capture = {
.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID), SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID),
.formats = (SNDRV_PCM_FMTBIT_S16_LE), .formats = (SNDRV_PCM_FMTBIT_S16_LE),
...@@ -507,7 +507,7 @@ static snd_pcm_hardware_t snd_omap_aic23_capture = { ...@@ -507,7 +507,7 @@ static snd_pcm_hardware_t snd_omap_aic23_capture = {
.fifo_size = 0, .fifo_size = 0,
}; };
static snd_pcm_hardware_t snd_omap_aic23_playback = { static snd_pcm_hardware_t snd_omap_alsa_playback = {
.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID), SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID),
.formats = (SNDRV_PCM_FMTBIT_S16_LE), .formats = (SNDRV_PCM_FMTBIT_S16_LE),
...@@ -528,9 +528,9 @@ static snd_pcm_hardware_t snd_omap_aic23_playback = { ...@@ -528,9 +528,9 @@ static snd_pcm_hardware_t snd_omap_aic23_playback = {
.fifo_size = 0, .fifo_size = 0,
}; };
static int snd_card_omap_aic23_open(snd_pcm_substream_t * substream) static int snd_card_omap_alsa_open(snd_pcm_substream_t * substream)
{ {
struct snd_card_omap_aic23 *chip = struct snd_card_omap_codec *chip =
snd_pcm_substream_chip(substream); snd_pcm_substream_chip(substream);
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
int stream_id = substream->pstr->stream; int stream_id = substream->pstr->stream;
...@@ -542,9 +542,9 @@ static int snd_card_omap_aic23_open(snd_pcm_substream_t * substream) ...@@ -542,9 +542,9 @@ static int snd_card_omap_aic23_open(snd_pcm_substream_t * substream)
omap_aic23_clock_on(); omap_aic23_clock_on();
if (stream_id == SNDRV_PCM_STREAM_PLAYBACK) if (stream_id == SNDRV_PCM_STREAM_PLAYBACK)
runtime->hw = snd_omap_aic23_playback; runtime->hw = snd_omap_alsa_playback;
else else
runtime->hw = snd_omap_aic23_capture; runtime->hw = snd_omap_alsa_capture;
if ((err = if ((err =
snd_pcm_hw_constraint_integer(runtime, snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS)) < SNDRV_PCM_HW_PARAM_PERIODS)) <
...@@ -559,9 +559,9 @@ static int snd_card_omap_aic23_open(snd_pcm_substream_t * substream) ...@@ -559,9 +559,9 @@ static int snd_card_omap_aic23_open(snd_pcm_substream_t * substream)
return 0; return 0;
} }
static int snd_card_omap_aic23_close(snd_pcm_substream_t * substream) static int snd_card_omap_alsa_close(snd_pcm_substream_t * substream)
{ {
struct snd_card_omap_aic23 *chip = struct snd_card_omap_codec *chip =
snd_pcm_substream_chip(substream); snd_pcm_substream_chip(substream);
ADEBUG(); ADEBUG();
...@@ -573,40 +573,39 @@ static int snd_card_omap_aic23_close(snd_pcm_substream_t * substream) ...@@ -573,40 +573,39 @@ static int snd_card_omap_aic23_close(snd_pcm_substream_t * substream)
/* HW params & free */ /* HW params & free */
static int snd_omap_aic23_hw_params(snd_pcm_substream_t * substream, static int snd_omap_alsa_hw_params(snd_pcm_substream_t * substream,
snd_pcm_hw_params_t * hw_params) snd_pcm_hw_params_t * hw_params)
{ {
return snd_pcm_lib_malloc_pages(substream, return snd_pcm_lib_malloc_pages(substream,
params_buffer_bytes(hw_params)); params_buffer_bytes(hw_params));
} }
static int snd_omap_aic23_hw_free(snd_pcm_substream_t * substream) static int snd_omap_alsa_hw_free(snd_pcm_substream_t * substream)
{ {
return snd_pcm_lib_free_pages(substream); return snd_pcm_lib_free_pages(substream);
} }
/* pcm operations */ /* pcm operations */
static snd_pcm_ops_t snd_card_omap_alsa_playback_ops = {
static snd_pcm_ops_t snd_card_omap_aic23_playback_ops = { .open = snd_card_omap_alsa_open,
.open = snd_card_omap_aic23_open, .close = snd_card_omap_alsa_close,
.close = snd_card_omap_aic23_close,
.ioctl = snd_pcm_lib_ioctl, .ioctl = snd_pcm_lib_ioctl,
.hw_params = snd_omap_aic23_hw_params, .hw_params = snd_omap_alsa_hw_params,
.hw_free = snd_omap_aic23_hw_free, .hw_free = snd_omap_alsa_hw_free,
.prepare = snd_omap_aic23_prepare, .prepare = snd_omap_alsa_prepare,
.trigger = snd_omap_aic23_trigger, .trigger = snd_omap_alsa_trigger,
.pointer = snd_omap_aic23_pointer, .pointer = snd_omap_alsa_pointer,
}; };
static snd_pcm_ops_t snd_card_omap_aic23_capture_ops = { static snd_pcm_ops_t snd_card_omap_alsa_capture_ops = {
.open = snd_card_omap_aic23_open, .open = snd_card_omap_alsa_open,
.close = snd_card_omap_aic23_close, .close = snd_card_omap_alsa_close,
.ioctl = snd_pcm_lib_ioctl, .ioctl = snd_pcm_lib_ioctl,
.hw_params = snd_omap_aic23_hw_params, .hw_params = snd_omap_alsa_hw_params,
.hw_free = snd_omap_aic23_hw_free, .hw_free = snd_omap_alsa_hw_free,
.prepare = snd_omap_aic23_prepare, .prepare = snd_omap_alsa_prepare,
.trigger = snd_omap_aic23_trigger, .trigger = snd_omap_alsa_trigger,
.pointer = snd_omap_aic23_pointer, .pointer = snd_omap_alsa_pointer,
}; };
/* /*
...@@ -614,8 +613,8 @@ static snd_pcm_ops_t snd_card_omap_aic23_capture_ops = { ...@@ -614,8 +613,8 @@ static snd_pcm_ops_t snd_card_omap_aic23_capture_ops = {
* *
* Inits pcm alsa structures, allocate the alsa buffer, suspend, resume * Inits pcm alsa structures, allocate the alsa buffer, suspend, resume
*/ */
static int __init snd_card_omap_aic23_pcm(struct snd_card_omap_aic23 static int __init snd_card_omap_alsa_pcm(struct snd_card_omap_codec *omap_alsa,
*omap_aic23, int device) int device)
{ {
snd_pcm_t *pcm; snd_pcm_t *pcm;
int err; int err;
...@@ -634,9 +633,9 @@ static int __init snd_card_omap_aic23_pcm(struct snd_card_omap_aic23 ...@@ -634,9 +633,9 @@ static int __init snd_card_omap_aic23_pcm(struct snd_card_omap_aic23
128 * 1024, 128 * 1024); 128 * 1024, 128 * 1024);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
&snd_card_omap_aic23_playback_ops); &snd_card_omap_alsa_playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
&snd_card_omap_aic23_capture_ops); &snd_card_omap_alsa_capture_ops);
pcm->private_data = omap_aic23; pcm->private_data = omap_aic23;
pcm->info_flags = 0; pcm->info_flags = 0;
strcpy(pcm->name, "omap aic23 pcm"); strcpy(pcm->name, "omap aic23 pcm");
...@@ -645,87 +644,63 @@ static int __init snd_card_omap_aic23_pcm(struct snd_card_omap_aic23 ...@@ -645,87 +644,63 @@ static int __init snd_card_omap_aic23_pcm(struct snd_card_omap_aic23
/* setup DMA controller */ /* setup DMA controller */
audio_dma_request(&omap_aic23->s[SNDRV_PCM_STREAM_PLAYBACK], audio_dma_request(&omap_aic23->s[SNDRV_PCM_STREAM_PLAYBACK],
audio_dma_callback); callback_omap_alsa_sound_dma);
audio_dma_request(&omap_aic23->s[SNDRV_PCM_STREAM_CAPTURE], audio_dma_request(&omap_aic23->s[SNDRV_PCM_STREAM_CAPTURE],
audio_dma_callback); callback_omap_alsa_sound_dma);
omap_aic23->pcm = pcm; omap_aic23->pcm = pcm;
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int snd_omap_aic23_suspend(snd_card_t * card, pm_message_t state)
{
struct snd_card_omap_aic23 *chip = card->private_data;
ADEBUG();
if (chip->card->power_state != SNDRV_CTL_POWER_D3hot) {
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
snd_pcm_suspend_all(chip->pcm);
/* Mutes and turn clock off */
omap_aic23_clock_off();
snd_omap_suspend_mixer();
}
return 0;
}
/*
* Prepare hardware for resume
*/
static int snd_omap_aic23_resume(snd_card_t * card)
{
struct snd_card_omap_aic23 *chip = card->private_data;
ADEBUG();
if (chip->card->power_state != SNDRV_CTL_POWER_D0) {
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
omap_aic23_clock_on();
snd_omap_resume_mixer();
}
return 0;
}
/* /*
* Driver suspend/resume - calls alsa functions. Some hints from aaci.c * Driver suspend/resume - calls alsa functions. Some hints from aaci.c
*/ */
static int omap_aic23_suspend(struct platform_device *pdev, pm_message_t state) int snd_omap_alsa_suspend(struct platform_device *pdev, pm_message_t state)
{ {
struct snd_card_omap_codec *chip;
snd_card_t *card = platform_get_drvdata(pdev); snd_card_t *card = platform_get_drvdata(pdev);
if (card->power_state != SNDRV_CTL_POWER_D3hot) { if (card->power_state != SNDRV_CTL_POWER_D3hot) {
snd_omap_aic23_suspend(card, PMSG_SUSPEND); chip = card->private_data;
if (chip->card->power_state != SNDRV_CTL_POWER_D3hot) {
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
snd_pcm_suspend_all(chip->pcm);
/* Mutes and turn clock off */
omap_aic23_clock_off();
snd_omap_suspend_mixer();
}
} }
return 0; return 0;
} }
static int omap_aic23_resume(struct platform_device *pdev) int snd_omap_alsa_resume(struct platform_device *pdev)
{ {
struct snd_card_omap_codec *chip;
snd_card_t *card = platform_get_drvdata(pdev); snd_card_t *card = platform_get_drvdata(pdev);
if (card->power_state != SNDRV_CTL_POWER_D0) { if (card->power_state != SNDRV_CTL_POWER_D0) {
snd_omap_aic23_resume(card); chip = card->private_data;
if (chip->card->power_state != SNDRV_CTL_POWER_D0) {
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
omap_aic23_clock_on();
snd_omap_resume_mixer();
}
} }
return 0; return 0;
} }
#else #else
#define snd_omap_aic23_suspend NULL #define snd_omap_alsa_suspend NULL
#define snd_omap_aic23_resume NULL #define snd_omap_alsa_resume NULL
#define omap_aic23_suspend NULL
#define omap_aic23_resume NULL
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
/* /*
*/ */
void snd_omap_aic23_free(snd_card_t * card) void snd_omap_alsa_free(snd_card_t * card)
{ {
struct snd_card_omap_aic23 *chip = card->private_data; struct snd_card_omap_codec *chip = card->private_data;
ADEBUG(); ADEBUG();
/* /*
...@@ -826,7 +801,7 @@ int omap_aic23_clock_off(void) ...@@ -826,7 +801,7 @@ int omap_aic23_clock_off(void)
/* /*
* Inits alsa soudcard structure * Inits alsa soudcard structure
*/ */
static int __init snd_omap_aic23_probe(struct platform_device *pdev) static int __init snd_omap_alsa_aic23_probe(struct platform_device *pdev)
{ {
int err = 0; int err = 0;
snd_card_t *card; snd_card_t *card;
...@@ -845,7 +820,7 @@ static int __init snd_omap_aic23_probe(struct platform_device *pdev) ...@@ -845,7 +820,7 @@ static int __init snd_omap_aic23_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
card->private_data = (void *) omap_aic23; card->private_data = (void *) omap_aic23;
card->private_free = snd_omap_aic23_free; card->private_free = snd_omap_alsa_free;
omap_aic23->card = card; omap_aic23->card = card;
omap_aic23->samplerate = AUDIO_RATE_DEFAULT; omap_aic23->samplerate = AUDIO_RATE_DEFAULT;
...@@ -858,7 +833,7 @@ static int __init snd_omap_aic23_probe(struct platform_device *pdev) ...@@ -858,7 +833,7 @@ static int __init snd_omap_aic23_probe(struct platform_device *pdev)
goto nodev; goto nodev;
/* PCM */ /* PCM */
if ((err = snd_card_omap_aic23_pcm(omap_aic23, 0)) < 0) if ((err = snd_card_omap_alsa_pcm(omap_aic23, 0)) < 0)
goto nodev; goto nodev;
strcpy(card->driver, "AIC23"); strcpy(card->driver, "AIC23");
...@@ -876,15 +851,15 @@ static int __init snd_omap_aic23_probe(struct platform_device *pdev) ...@@ -876,15 +851,15 @@ static int __init snd_omap_aic23_probe(struct platform_device *pdev)
} }
nodev: nodev:
snd_omap_aic23_free(card); snd_card_free(card);
return err; return err;
} }
static int snd_omap_aic23_remove(struct platform_device *pdev) static int snd_omap_alsa_remove(struct platform_device *pdev)
{ {
snd_card_t *card = platform_get_drvdata(pdev); snd_card_t *card = platform_get_drvdata(pdev);
struct snd_card_omap_aic23 *chip = card->private_data; struct snd_card_omap_codec *chip = card->private_data;
snd_card_free(card); snd_card_free(card);
...@@ -899,16 +874,16 @@ static int snd_omap_aic23_remove(struct platform_device *pdev) ...@@ -899,16 +874,16 @@ static int snd_omap_aic23_remove(struct platform_device *pdev)
} }
static struct platform_driver omap_alsa_driver = { static struct platform_driver omap_alsa_driver = {
.probe = snd_omap_aic23_probe, .probe = snd_omap_alsa_aic23_probe,
.remove = snd_omap_aic23_remove, .remove = snd_omap_alsa_remove,
.suspend = omap_aic23_suspend, .suspend = snd_omap_alsa_suspend,
.resume = omap_aic23_resume, .resume = snd_omap_alsa_resume,
.driver = { .driver = {
.name = "omap_mcbsp", .name = "omap_mcbsp",
}, },
}; };
static int __init omap_aic23_init(void) static int __init omap_alsa_aic23_init(void)
{ {
int err; int err;
ADEBUG(); ADEBUG();
...@@ -918,12 +893,12 @@ static int __init omap_aic23_init(void) ...@@ -918,12 +893,12 @@ static int __init omap_aic23_init(void)
return err; return err;
} }
static void __exit omap_aic23_exit(void) static void __exit omap_alsa_aic23_exit(void)
{ {
ADEBUG(); ADEBUG();
platform_driver_unregister(&omap_alsa_driver); platform_driver_unregister(&omap_alsa_driver);
} }
module_init(omap_aic23_init); module_init(omap_alsa_aic23_init);
module_exit(omap_aic23_exit); module_exit(omap_alsa_aic23_exit);
...@@ -93,17 +93,15 @@ struct audio_stream { ...@@ -93,17 +93,15 @@ struct audio_stream {
/* /*
* Alsa card structure for aic23 * Alsa card structure for aic23
*/ */
struct snd_card_omap_aic23 { struct snd_card_omap_codec {
snd_card_t *card; snd_card_t *card;
snd_pcm_t *pcm; snd_pcm_t *pcm;
long samplerate; long samplerate;
struct audio_stream s[2]; /* playback & capture */ struct audio_stream s[2]; /* playback & capture */
}; };
/*********** Function Prototypes *************************/ /*********** Mixer function prototypes *************************/
int snd_omap_mixer(struct snd_card_omap_codec *);
void audio_dma_callback(void *);
int snd_omap_mixer(struct snd_card_omap_aic23 *);
void snd_omap_init_mixer(void); void snd_omap_init_mixer(void);
/* Clock functions */ /* Clock functions */
int omap_aic23_clock_on(void); int omap_aic23_clock_on(void);
...@@ -114,6 +112,9 @@ void snd_omap_suspend_mixer(void); ...@@ -114,6 +112,9 @@ void snd_omap_suspend_mixer(void);
void snd_omap_resume_mixer(void); void snd_omap_resume_mixer(void);
#endif #endif
/*********** function prototype to function called from the dma interrupt handler ******/
void callback_omap_alsa_sound_dma(void *);
/* Codec AIC23 */ /* Codec AIC23 */
#if defined(CONFIG_SENSORS_TLV320AIC23) || defined (CONFIG_SENSORS_TLV320AIC23_MODULE) #if defined(CONFIG_SENSORS_TLV320AIC23) || defined (CONFIG_SENSORS_TLV320AIC23_MODULE)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
* *
* Common audio DMA handling for the OMAP processors * Common audio DMA handling for the OMAP processors
* *
* Copyright (C) 2006 Mika Laitio <lamikr@cc.jyu.fi>
*
* Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil * Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil
* *
* Copyright (C) 2004 Texas Instruments, Inc. * Copyright (C) 2004 Texas Instruments, Inc.
...@@ -66,10 +68,8 @@ ...@@ -66,10 +68,8 @@
#include <asm/arch/mcbsp.h> #include <asm/arch/mcbsp.h>
#include "omap-aic23.h"
#undef DEBUG #undef DEBUG
//#define DEBUG #define DEBUG
#ifdef DEBUG #ifdef DEBUG
#define DPRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) #define DPRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
#define FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) #define FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
...@@ -165,7 +165,7 @@ static void omap_sound_dma_link_lch(void *data) ...@@ -165,7 +165,7 @@ static void omap_sound_dma_link_lch(void *data)
FN_OUT(0); FN_OUT(0);
} }
int omap_request_sound_dma(int device_id, const char *device_name, int omap_request_alsa_sound_dma(int device_id, const char *device_name,
void *data, int **channels) void *data, int **channels)
{ {
int i, err = 0; int i, err = 0;
...@@ -186,10 +186,11 @@ int omap_request_sound_dma(int device_id, const char *device_name, ...@@ -186,10 +186,11 @@ int omap_request_sound_dma(int device_id, const char *device_name,
} }
spin_lock(&dma_list_lock); spin_lock(&dma_list_lock);
for (i = 0; i < nr_linked_channels; i++) { for (i = 0; i < nr_linked_channels; i++) {
err = err = omap_request_dma(device_id,
omap_request_dma(device_id, device_name, device_name,
sound_dma_irq_handler, data, sound_dma_irq_handler,
&chan[i]); data,
&chan[i]);
/* Handle Failure condition here */ /* Handle Failure condition here */
if (err < 0) { if (err < 0) {
...@@ -223,7 +224,7 @@ int omap_request_sound_dma(int device_id, const char *device_name, ...@@ -223,7 +224,7 @@ int omap_request_sound_dma(int device_id, const char *device_name,
**************************************************************************************/ **************************************************************************************/
static void omap_sound_dma_unlink_lch(void *data) static void omap_sound_dma_unlink_lch(void *data)
{ {
struct audio_stream *s = (struct audio_stream *) data; struct audio_stream *s = (struct audio_stream *)data;
int *chan = s->lch; int *chan = s->lch;
int i; int i;
...@@ -243,11 +244,11 @@ static void omap_sound_dma_unlink_lch(void *data) ...@@ -243,11 +244,11 @@ static void omap_sound_dma_unlink_lch(void *data)
FN_OUT(0); FN_OUT(0);
} }
int omap_free_sound_dma(void *data, int **channels) int omap_free_alsa_sound_dma(void *data, int **channels)
{ {
int i; int i;
int *chan = NULL; int *chan = NULL;
FN_IN; FN_IN;
if (unlikely(NULL == channels)) { if (unlikely(NULL == channels)) {
BUG(); BUG();
...@@ -277,10 +278,11 @@ int omap_free_sound_dma(void *data, int **channels) ...@@ -277,10 +278,11 @@ int omap_free_sound_dma(void *data, int **channels)
* Stop all the DMA channels of the stream * Stop all the DMA channels of the stream
* *
**************************************************************************************/ **************************************************************************************/
void omap_audio_stop_dma(struct audio_stream *s) void omap_stop_alsa_sound_dma(struct audio_stream *s)
{ {
int *chan = s->lch; int *chan = s->lch;
int i; int i;
FN_IN; FN_IN;
if (unlikely(NULL == chan)) { if (unlikely(NULL == chan)) {
BUG(); BUG();
...@@ -299,7 +301,7 @@ void omap_audio_stop_dma(struct audio_stream *s) ...@@ -299,7 +301,7 @@ void omap_audio_stop_dma(struct audio_stream *s)
* Clear any pending transfers * Clear any pending transfers
* *
**************************************************************************************/ **************************************************************************************/
void omap_clear_sound_dma(struct audio_stream * s) void omap_clear_alsa_sound_dma(struct audio_stream * s)
{ {
FN_IN; FN_IN;
omap_clear_dma(s->lch[s->dma_q_head]); omap_clear_dma(s->lch[s->dma_q_head]);
...@@ -307,13 +309,6 @@ void omap_clear_sound_dma(struct audio_stream * s) ...@@ -307,13 +309,6 @@ void omap_clear_sound_dma(struct audio_stream * s)
return; return;
} }
/*********************************** MODULE FUNCTIONS DEFINTIONS ***********************/
#ifdef OMAP1610_MCBSP1_BASE
#undef OMAP1610_MCBSP1_BASE
#endif
#define OMAP1610_MCBSP1_BASE 0xE1011000
/*************************************************************************************** /***************************************************************************************
* *
* DMA related functions * DMA related functions
...@@ -325,9 +320,10 @@ static int audio_set_dma_params_play(int channel, dma_addr_t dma_ptr, ...@@ -325,9 +320,10 @@ static int audio_set_dma_params_play(int channel, dma_addr_t dma_ptr,
int dt = 0x1; /* data type 16 */ int dt = 0x1; /* data type 16 */
int cen = 32; /* Stereo */ int cen = 32; /* Stereo */
int cfn = dma_size / (2 * cen); int cfn = dma_size / (2 * cen);
FN_IN; FN_IN;
omap_set_dma_dest_params(channel, 0x05, 0x00, omap_set_dma_dest_params(channel, 0x05, 0x00,
(OMAP1610_MCBSP1_BASE + 0x806), (OMAP1510_MCBSP1_BASE + 0x06),
0, 0); 0, 0);
omap_set_dma_src_params(channel, 0x00, 0x01, dma_ptr, omap_set_dma_src_params(channel, 0x00, 0x01, dma_ptr,
0, 0); 0, 0);
...@@ -341,11 +337,11 @@ static int audio_set_dma_params_capture(int channel, dma_addr_t dma_ptr, ...@@ -341,11 +337,11 @@ static int audio_set_dma_params_capture(int channel, dma_addr_t dma_ptr,
{ {
int dt = 0x1; /* data type 16 */ int dt = 0x1; /* data type 16 */
int cen = 32; /* stereo */ int cen = 32; /* stereo */
int cfn = dma_size / (2 * cen); int cfn = dma_size / (2 * cen);
FN_IN; FN_IN;
omap_set_dma_src_params(channel, 0x05, 0x00, omap_set_dma_src_params(channel, 0x05, 0x00,
(OMAP1610_MCBSP1_BASE + 0x802), (OMAP1510_MCBSP1_BASE + 0x02),
0, 0); 0, 0);
omap_set_dma_dest_params(channel, 0x00, 0x01, dma_ptr, 0, 0); omap_set_dma_dest_params(channel, 0x00, 0x01, dma_ptr, 0, 0);
omap_set_dma_transfer_params(channel, dt, cen, cfn, 0x00, 0, 0); omap_set_dma_transfer_params(channel, dt, cen, cfn, 0x00, 0, 0);
...@@ -358,7 +354,7 @@ static int audio_start_dma_chain(struct audio_stream *s) ...@@ -358,7 +354,7 @@ static int audio_start_dma_chain(struct audio_stream *s)
int channel = s->lch[s->dma_q_head]; int channel = s->lch[s->dma_q_head];
FN_IN; FN_IN;
if (!s->started) { if (!s->started) {
s->hw_stop(); /* stops McBSP Interface */ s->hw_stop(); /* stops McBSP Interface */
omap_start_dma(channel); omap_start_dma(channel);
s->started = 1; s->started = 1;
s->hw_start(); /* start McBSP interface */ s->hw_start(); /* start McBSP interface */
...@@ -372,8 +368,9 @@ static int audio_start_dma_chain(struct audio_stream *s) ...@@ -372,8 +368,9 @@ static int audio_start_dma_chain(struct audio_stream *s)
* Do the initial set of work to initialize all the channels as required. * Do the initial set of work to initialize all the channels as required.
* We shall then initate a transfer * We shall then initate a transfer
*/ */
int omap_start_sound_dma(struct audio_stream *s, dma_addr_t dma_ptr, int omap_start_alsa_sound_dma(struct audio_stream *s,
u_int dma_size) dma_addr_t dma_ptr,
u_int dma_size)
{ {
int ret = -EPERM; int ret = -EPERM;
...@@ -439,18 +436,17 @@ static void sound_dma_irq_handler(int sound_curr_lch, u16 ch_status, ...@@ -439,18 +436,17 @@ static void sound_dma_irq_handler(int sound_curr_lch, u16 ch_status,
} }
if (ch_status & DCSR_END_BLOCK) if (ch_status & DCSR_END_BLOCK)
audio_dma_callback(s); callback_omap_alsa_sound_dma(s);
FN_OUT(0); FN_OUT(0);
return; return;
} }
MODULE_AUTHOR("Texas Instruments"); MODULE_AUTHOR("Texas Instruments");
MODULE_DESCRIPTION MODULE_DESCRIPTION("Common DMA handling for Audio driver on OMAP processors");
("Common DMA handling for Audio driver on OMAP processors");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
EXPORT_SYMBOL(omap_start_sound_dma); EXPORT_SYMBOL(omap_start_alsa_sound_dma);
EXPORT_SYMBOL(omap_clear_sound_dma); EXPORT_SYMBOL(omap_clear_alsa_sound_dma);
EXPORT_SYMBOL(omap_request_sound_dma); EXPORT_SYMBOL(omap_request_alsa_sound_dma);
EXPORT_SYMBOL(omap_free_sound_dma); EXPORT_SYMBOL(omap_free_alsa_sound_dma);
EXPORT_SYMBOL(omap_audio_stop_dma); EXPORT_SYMBOL(omap_stop_alsa_sound_dma);
/* /*
* linux/sound/arm/omap-alsa-dma.h * sound/arm/omap-alsa-dma.h
* *
* Common audio DMA handling for the OMAP processors * Common audio DMA handling for the OMAP processors
* *
* Copyright (C) 2006 Mika Laitio <lamikr@cc.jyu.fi>
*
* Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil * Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil
* *
* Copyright (C) 2004 Texas Instruments, Inc. * Copyright (C) 2004 Texas Instruments, Inc.
...@@ -32,28 +34,20 @@ ...@@ -32,28 +34,20 @@
#include "omap-aic23.h" #include "omap-aic23.h"
/************************** GLOBAL MACROS *************************************/
/* Provide the Macro interfaces common across platforms */
#define DMA_REQUEST(e,s, cb) {e=omap_request_sound_dma(s->dma_dev, s->id, s, &s->lch);}
#define DMA_FREE(s) omap_free_sound_dma(s, &s->lch)
#define DMA_CLEAR(s) omap_clear_sound_dma(s)
/************************** GLOBAL DATA STRUCTURES *********************************/ /************************** GLOBAL DATA STRUCTURES *********************************/
typedef void (*dma_callback_t) (int lch, u16 ch_status, void *data); typedef void (*dma_callback_t) (int lch, u16 ch_status, void *data);
/**************** ARCH SPECIFIC FUNCIONS *******************************************/ /**************** ARCH SPECIFIC FUNCIONS *******************************************/
void omap_clear_sound_dma(struct audio_stream * s); void omap_clear_alsa_sound_dma(struct audio_stream * s);
int omap_request_sound_dma(int device_id, const char *device_name, int omap_request_alsa_sound_dma(int device_id, const char *device_name,
void *data, int **channels); void *data, int **channels);
int omap_free_sound_dma(void *data, int **channels); int omap_free_alsa_sound_dma(void *data, int **channels);
int omap_start_sound_dma(struct audio_stream *s, dma_addr_t dma_ptr, int omap_start_alsa_sound_dma(struct audio_stream *s, dma_addr_t dma_ptr, u_int dma_size);
u_int dma_size);
void omap_audio_stop_dma(struct audio_stream *s); void omap_stop_alsa_sound_dma(struct audio_stream *s);
#endif #endif
...@@ -474,7 +474,7 @@ void snd_omap_resume_mixer(void) ...@@ -474,7 +474,7 @@ void snd_omap_resume_mixer(void)
} }
#endif #endif
int snd_omap_mixer(struct snd_card_omap_aic23 *chip) int snd_omap_mixer(struct snd_card_omap_codec *chip)
{ {
snd_card_t *card; snd_card_t *card;
unsigned int idx; unsigned int idx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment