Commit bd23dd44 authored by Eduardo Valentin's avatar Eduardo Valentin Committed by Tony Lindgren

Code clean-up for sound/arm/omap/omap-alsa-dma.c

Removed lots of whitespaces and a few errors and
warnings reported by checkpatch.pl.
Signed-off-by: default avatarEduardo Valentin <eduardo.valentin@indt.org.br>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent fb107c0f
...@@ -21,24 +21,30 @@ ...@@ -21,24 +21,30 @@
* *
* History: * History:
* *
* 2004-06-07 Sriram Kannan - Created new file from omap_audio_dma_intfc.c. This file * 2004-06-07 Sriram Kannan - Created new file from omap_audio_dma_intfc.c.
* will contain only the DMA interface and buffer handling of OMAP * This file will contain only the DMA interface
* audio driver. * and buffer handling of OMAP audio driver.
* *
* 2004-06-22 Sriram Kannan - removed legacy code (auto-init). Self-linking of DMA logical channel. * 2004-06-22 Sriram Kannan - removed legacy code (auto-init). Self-linking
* of DMA logical channel.
* *
* 2004-08-12 Nishanth Menon - Modified to integrate Audio requirements on 1610,1710 platforms * 2004-08-12 Nishanth Menon - Modified to integrate Audio requirements on
* 1610, 1710 platforms
* *
* 2004-11-01 Nishanth Menon - 16xx platform code base modified to support multi channel chaining. * 2004-11-01 Nishanth Menon - 16xx platform code base modified to support
* multi channel chaining.
* *
* 2004-12-15 Nishanth Menon - Improved 16xx platform channel logic introduced - tasklets, queue handling updated * 2004-12-15 Nishanth Menon - Improved 16xx platform channel logic
* introduced - tasklets, queue handling updated
* *
* 2005-07-19 INdT Kernel Team - Alsa port. Creation of new file omap-alsa-dma.c based in * 2005-07-19 INdT Kernel Team - Alsa port. Creation of new file
* omap-audio-dma-intfc.c oss file. Support for aic23 codec. * omap-alsa-dma.c based in omap-audio-dma-intfc.c
* Removal of buffer handling (Alsa does that), modifications * oss file. Support for aic23 codec. Removal of
* buffer handling (Alsa does that), modifications
* in dma handling and port to alsa structures. * in dma handling and port to alsa structures.
* *
* 2005-12-18 Dirk Behme - Added L/R Channel Interchange fix as proposed by Ajaya Babu * 2005-12-18 Dirk Behme - Added L/R Channel Interchange fix as proposed
* by Ajaya Babu
*/ */
#include <linux/module.h> #include <linux/module.h>
...@@ -56,24 +62,21 @@ ...@@ -56,24 +62,21 @@
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/uaccess.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/hardware.h> #include <asm/hardware.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/arch/dma.h> #include <asm/arch/dma.h>
#include "omap-alsa-dma.h"
#include <asm/arch/mcbsp.h> #include <asm/arch/mcbsp.h>
#include <asm/arch/omap-alsa.h> #include <asm/arch/omap-alsa.h>
#undef DEBUG #include "omap-alsa-dma.h"
#define ERR(ARGS...) printk(KERN_ERR "{%s}-ERROR: ", __FUNCTION__);printk(ARGS); #undef DEBUG
/* Channel Queue Handling macros /*
* Channel Queue Handling macros
* tail always points to the current free entry * tail always points to the current free entry
* Head always points to the current entry being used * Head always points to the current entry being used
* end is either head or tail * end is either head or tail
...@@ -83,13 +86,21 @@ ...@@ -83,13 +86,21 @@
#define AUDIO_QUEUE_FULL(s) (nr_linked_channels == s->dma_q_count) #define AUDIO_QUEUE_FULL(s) (nr_linked_channels == s->dma_q_count)
#define AUDIO_QUEUE_LAST(s) (1 == s->dma_q_count) #define AUDIO_QUEUE_LAST(s) (1 == s->dma_q_count)
#define AUDIO_QUEUE_EMPTY(s) (0 == s->dma_q_count) #define AUDIO_QUEUE_EMPTY(s) (0 == s->dma_q_count)
#define __AUDIO_INCREMENT_QUEUE(end) ((end)=((end)+1) % nr_linked_channels) #define __AUDIO_INCREMENT_QUEUE(end) ((end) = ((end)+1) % nr_linked_channels)
#define AUDIO_INCREMENT_HEAD(s) __AUDIO_INCREMENT_QUEUE(s->dma_q_head); s->dma_q_count--; #define AUDIO_INCREMENT_HEAD(s) \
#define AUDIO_INCREMENT_TAIL(s) __AUDIO_INCREMENT_QUEUE(s->dma_q_tail); s->dma_q_count++; do { \
__AUDIO_INCREMENT_QUEUE(s->dma_q_head); \
s->dma_q_count--; \
} while (0)
#define AUDIO_INCREMENT_TAIL(s) \
do { \
__AUDIO_INCREMENT_QUEUE(s->dma_q_tail); \
s->dma_q_count++; \
} while (0)
/* DMA buffer fragmentation sizes */ /* DMA buffer fragmentation sizes */
#define MAX_DMA_SIZE 0x1000000 /* todo: sync with alsa */ #define MAX_DMA_SIZE 0x1000000 /* todo: sync with alsa */
//#define CUT_DMA_SIZE 0x1000 /* #define CUT_DMA_SIZE 0x1000 */
/* TODO: To be moved to more appropriate location */ /* TODO: To be moved to more appropriate location */
#define DCSR_ERROR 0x3 #define DCSR_ERROR 0x3
#define DCSR_END_BLOCK (1 << 5) #define DCSR_END_BLOCK (1 << 5)
...@@ -100,7 +111,7 @@ ...@@ -100,7 +111,7 @@
#define DCCR_EN (1 << 7) #define DCCR_EN (1 << 7)
#define DCCR_AI (1 << 8) #define DCCR_AI (1 << 8)
#define DCCR_REPEAT (1 << 9) #define DCCR_REPEAT (1 << 9)
/* if 0 the channel works in 3.1 compatible mode*/ /* if 0 the channel works in 3.1 compatible mode */
#define DCCR_N31COMP (1 << 10) #define DCCR_N31COMP (1 << 10)
#define DCCR_EP (1 << 11) #define DCCR_EP (1 << 11)
#define DCCR_SRC_AMODE_BIT 12 #define DCCR_SRC_AMODE_BIT 12
...@@ -112,26 +123,22 @@ ...@@ -112,26 +123,22 @@
#define AMODE_SINGLE_INDEX 0x2 #define AMODE_SINGLE_INDEX 0x2
#define AMODE_DOUBLE_INDEX 0x3 #define AMODE_DOUBLE_INDEX 0x3
/**************************** DATA STRUCTURES *****************************************/ /* Data structures */
DEFINE_SPINLOCK(dma_list_lock);
static spinlock_t dma_list_lock = SPIN_LOCK_UNLOCKED;
static char nr_linked_channels = 1; static char nr_linked_channels = 1;
/*********************************** MODULE SPECIFIC FUNCTIONS ***********************/ /* Module specific functions */
static void sound_dma_irq_handler(int lch, u16 ch_status, void *data); static void sound_dma_irq_handler(int lch, u16 ch_status, void *data);
static int audio_set_dma_params_play(int channel, dma_addr_t dma_ptr, static int audio_set_dma_params_play(int channel, dma_addr_t dma_ptr,
u_int dma_size); u_int dma_size);
static int audio_set_dma_params_capture(int channel, dma_addr_t dma_ptr, static int audio_set_dma_params_capture(int channel, dma_addr_t dma_ptr,
u_int dma_size); u_int dma_size);
static int audio_start_dma_chain(struct audio_stream * s); static int audio_start_dma_chain(struct audio_stream *s);
/*************************************************************************************** /*
*
* DMA channel requests * DMA channel requests
* */
**************************************************************************************/
static void omap_sound_dma_link_lch(void *data) static void omap_sound_dma_link_lch(void *data)
{ {
...@@ -166,8 +173,7 @@ int omap_request_alsa_sound_dma(int device_id, const char *device_name, ...@@ -166,8 +173,7 @@ int omap_request_alsa_sound_dma(int device_id, const char *device_name,
return -EPERM; return -EPERM;
} }
/* Try allocate memory for the num channels */ /* Try allocate memory for the num channels */
*channels = *channels = kmalloc(sizeof(int) * nr_linked_channels, GFP_KERNEL);
(int *) kmalloc(sizeof(int) * nr_linked_channels, GFP_KERNEL);
chan = *channels; chan = *channels;
if (NULL == chan) { if (NULL == chan) {
ERR("No Memory for channel allocs!\n"); ERR("No Memory for channel allocs!\n");
...@@ -185,9 +191,10 @@ int omap_request_alsa_sound_dma(int device_id, const char *device_name, ...@@ -185,9 +191,10 @@ int omap_request_alsa_sound_dma(int device_id, const char *device_name,
/* Handle Failure condition here */ /* Handle Failure condition here */
if (err < 0) { if (err < 0) {
int j; int j;
for (j = 0; j < i; j++) {
for (j = 0; j < i; j++)
omap_free_dma(chan[j]); omap_free_dma(chan[j]);
}
spin_unlock(&dma_list_lock); spin_unlock(&dma_list_lock);
kfree(chan); kfree(chan);
*channels = NULL; *channels = NULL;
...@@ -206,12 +213,11 @@ int omap_request_alsa_sound_dma(int device_id, const char *device_name, ...@@ -206,12 +213,11 @@ int omap_request_alsa_sound_dma(int device_id, const char *device_name,
FN_OUT(0); FN_OUT(0);
return 0; return 0;
} }
EXPORT_SYMBOL(omap_request_alsa_sound_dma);
/*************************************************************************************** /*
*
* DMA channel requests Freeing * DMA channel requests Freeing
* */
**************************************************************************************/
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;
...@@ -262,12 +268,11 @@ int omap_free_alsa_sound_dma(void *data, int **channels) ...@@ -262,12 +268,11 @@ int omap_free_alsa_sound_dma(void *data, int **channels)
FN_OUT(0); FN_OUT(0);
return 0; return 0;
} }
EXPORT_SYMBOL(omap_free_alsa_sound_dma);
/*************************************************************************************** /*
*
* Stop all the DMA channels of the stream * Stop all the DMA channels of the stream
* */
**************************************************************************************/
void omap_stop_alsa_sound_dma(struct audio_stream *s) void omap_stop_alsa_sound_dma(struct audio_stream *s)
{ {
int *chan = s->lch; int *chan = s->lch;
...@@ -286,24 +291,23 @@ void omap_stop_alsa_sound_dma(struct audio_stream *s) ...@@ -286,24 +291,23 @@ void omap_stop_alsa_sound_dma(struct audio_stream *s)
FN_OUT(0); FN_OUT(0);
return; return;
} }
/*************************************************************************************** EXPORT_SYMBOL(omap_stop_alsa_sound_dma);
*
/*
* Clear any pending transfers * Clear any pending transfers
* */
**************************************************************************************/ void omap_clear_alsa_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]);
FN_OUT(0); FN_OUT(0);
return; return;
} }
EXPORT_SYMBOL(omap_clear_alsa_sound_dma);
/*************************************************************************************** /*
*
* DMA related functions * DMA related functions
* */
**************************************************************************************/
static int audio_set_dma_params_play(int channel, dma_addr_t dma_ptr, static int audio_set_dma_params_play(int channel, dma_addr_t dma_ptr,
u_int dma_size) u_int dma_size)
{ {
...@@ -355,7 +359,8 @@ static int audio_start_dma_chain(struct audio_stream *s) ...@@ -355,7 +359,8 @@ static int audio_start_dma_chain(struct audio_stream *s)
return 0; return 0;
} }
/* Start DMA - /*
* Start DMA -
* 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
*/ */
...@@ -372,13 +377,9 @@ int omap_start_alsa_sound_dma(struct audio_stream *s, ...@@ -372,13 +377,9 @@ int omap_start_alsa_sound_dma(struct audio_stream *s,
MAX_DMA_SIZE); MAX_DMA_SIZE);
return -EOVERFLOW; return -EOVERFLOW;
} }
//if (AUDIO_QUEUE_FULL(s)) {
// ret = -2;
// goto sound_out;
//}
if (s->stream_id == SNDRV_PCM_STREAM_PLAYBACK) { if (s->stream_id == SNDRV_PCM_STREAM_PLAYBACK) {
/*playback */ /* playback */
ret = ret =
audio_set_dma_params_play(s->lch[s->dma_q_tail], audio_set_dma_params_play(s->lch[s->dma_q_tail],
dma_ptr, dma_size); dma_ptr, dma_size);
...@@ -393,14 +394,15 @@ int omap_start_alsa_sound_dma(struct audio_stream *s, ...@@ -393,14 +394,15 @@ int omap_start_alsa_sound_dma(struct audio_stream *s,
} }
AUDIO_INCREMENT_TAIL(s); AUDIO_INCREMENT_TAIL(s);
ret = audio_start_dma_chain(s); ret = audio_start_dma_chain(s);
if (ret) { if (ret)
ERR("dma start failed"); ERR("dma start failed");
}
sound_out: sound_out:
FN_OUT(ret); FN_OUT(ret);
return ret; return ret;
} }
EXPORT_SYMBOL(omap_start_alsa_sound_dma);
/* /*
* ISRs have to be short and smart.. * ISRs have to be short and smart..
...@@ -413,9 +415,7 @@ static void sound_dma_irq_handler(int sound_curr_lch, u16 ch_status, ...@@ -413,9 +415,7 @@ static void sound_dma_irq_handler(int sound_curr_lch, u16 ch_status,
struct audio_stream *s = (struct audio_stream *) data; struct audio_stream *s = (struct audio_stream *) data;
FN_IN; FN_IN;
/* /* some register checking */
* some register checkings
*/
DPRINTK("lch=%d,status=0x%x, dma_status=%d, data=%p\n", DPRINTK("lch=%d,status=0x%x, dma_status=%d, data=%p\n",
sound_curr_lch, ch_status, dma_status, data); sound_curr_lch, ch_status, dma_status, data);
...@@ -436,8 +436,3 @@ MODULE_AUTHOR("Texas Instruments"); ...@@ -436,8 +436,3 @@ MODULE_AUTHOR("Texas Instruments");
MODULE_DESCRIPTION("Common DMA handling for Audio driver on OMAP processors"); MODULE_DESCRIPTION("Common DMA handling for Audio driver on OMAP processors");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
EXPORT_SYMBOL(omap_start_alsa_sound_dma);
EXPORT_SYMBOL(omap_clear_alsa_sound_dma);
EXPORT_SYMBOL(omap_request_alsa_sound_dma);
EXPORT_SYMBOL(omap_free_alsa_sound_dma);
EXPORT_SYMBOL(omap_stop_alsa_sound_dma);
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