[ALSA] dbri: more cleanups
This patch: - removes redundant constant suffices - removes redundant parentheses - removes redundant curly brackets - removes check if a spinlock is locked inside method which is only called with the spinlock locked - moves few functions to the __init section - removes line which appears twice after the previous patch - minor comments improvements Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
This commit is contained in:
parent
c6c2d57b8c
commit
cf68d212d5
|
@ -233,12 +233,12 @@ static struct {
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* DBRI main registers */
|
/* DBRI main registers */
|
||||||
#define REG0 0x00UL /* Status and Control */
|
#define REG0 0x00 /* Status and Control */
|
||||||
#define REG1 0x04UL /* Mode and Interrupt */
|
#define REG1 0x04 /* Mode and Interrupt */
|
||||||
#define REG2 0x08UL /* Parallel IO */
|
#define REG2 0x08 /* Parallel IO */
|
||||||
#define REG3 0x0cUL /* Test */
|
#define REG3 0x0c /* Test */
|
||||||
#define REG8 0x20UL /* Command Queue Pointer */
|
#define REG8 0x20 /* Command Queue Pointer */
|
||||||
#define REG9 0x24UL /* Interrupt Queue Pointer */
|
#define REG9 0x24 /* Interrupt Queue Pointer */
|
||||||
|
|
||||||
#define DBRI_NO_CMDS 64
|
#define DBRI_NO_CMDS 64
|
||||||
#define DBRI_INT_BLK 64
|
#define DBRI_INT_BLK 64
|
||||||
|
@ -565,7 +565,7 @@ struct snd_dbri {
|
||||||
/* Translate the ALSA direction into the array index */
|
/* Translate the ALSA direction into the array index */
|
||||||
#define DBRI_STREAMNO(substream) \
|
#define DBRI_STREAMNO(substream) \
|
||||||
(substream->stream == \
|
(substream->stream == \
|
||||||
SNDRV_PCM_STREAM_PLAYBACK? DBRI_PLAY: DBRI_REC)
|
SNDRV_PCM_STREAM_PLAYBACK ? DBRI_PLAY: DBRI_REC)
|
||||||
|
|
||||||
/* Return a pointer to dbri_streaminfo */
|
/* Return a pointer to dbri_streaminfo */
|
||||||
#define DBRI_STREAM(dbri, substream) \
|
#define DBRI_STREAM(dbri, substream) \
|
||||||
|
@ -611,8 +611,8 @@ The list is terminated with a WAIT command, which generates a
|
||||||
CPU interrupt to signal completion.
|
CPU interrupt to signal completion.
|
||||||
|
|
||||||
Since the DBRI can run in parallel with the CPU, several means of
|
Since the DBRI can run in parallel with the CPU, several means of
|
||||||
synchronization present themselves. The method implemented here is only
|
synchronization present themselves. The method implemented here uses
|
||||||
use of the dbri_cmdwait() to wait for execution of batch of sent commands.
|
the dbri_cmdwait() to wait for execution of batch of sent commands.
|
||||||
|
|
||||||
A circular command buffer is used here. A new command is being added
|
A circular command buffer is used here. A new command is being added
|
||||||
while another can be executed. The scheme works by adding two WAIT commands
|
while another can be executed. The scheme works by adding two WAIT commands
|
||||||
|
@ -648,15 +648,14 @@ static void dbri_cmdwait(struct snd_dbri *dbri)
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&dbri->lock, flags);
|
spin_unlock_irqrestore(&dbri->lock, flags);
|
||||||
|
|
||||||
if (maxloops == 0) {
|
if (maxloops == 0)
|
||||||
printk(KERN_ERR "DBRI: Chip never completed command buffer\n");
|
printk(KERN_ERR "DBRI: Chip never completed command buffer\n");
|
||||||
} else {
|
else
|
||||||
dprintk(D_CMD, "Chip completed command buffer (%d)\n",
|
dprintk(D_CMD, "Chip completed command buffer (%d)\n",
|
||||||
MAXLOOPS - maxloops - 1);
|
MAXLOOPS - maxloops - 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Lock the command queue and returns pointer to a space for len cmd words
|
* Lock the command queue and return pointer to space for len cmd words
|
||||||
* It locks the cmdlock spinlock.
|
* It locks the cmdlock spinlock.
|
||||||
*/
|
*/
|
||||||
static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len)
|
static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len)
|
||||||
|
@ -749,7 +748,7 @@ static void dbri_reset(struct snd_dbri *dbri)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lock must not be held before calling this */
|
/* Lock must not be held before calling this */
|
||||||
static void dbri_initialize(struct snd_dbri *dbri)
|
static void __init dbri_initialize(struct snd_dbri *dbri)
|
||||||
{
|
{
|
||||||
s32 *cmd;
|
s32 *cmd;
|
||||||
u32 dma_addr;
|
u32 dma_addr;
|
||||||
|
@ -804,7 +803,7 @@ list ordering, among other things. The transmit and receive functions
|
||||||
here interface closely with the transmit and receive interrupt code.
|
here interface closely with the transmit and receive interrupt code.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static int pipe_active(struct snd_dbri *dbri, int pipe)
|
static inline int pipe_active(struct snd_dbri *dbri, int pipe)
|
||||||
{
|
{
|
||||||
return ((pipe >= 0) && (dbri->pipes[pipe].desc != -1));
|
return ((pipe >= 0) && (dbri->pipes[pipe].desc != -1));
|
||||||
}
|
}
|
||||||
|
@ -1148,6 +1147,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period)
|
||||||
if (!dbri->dma->desc[desc].ba)
|
if (!dbri->dma->desc[desc].ba)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc == DBRI_NO_DESCS) {
|
if (desc == DBRI_NO_DESCS) {
|
||||||
printk(KERN_ERR "DBRI: setup_descs: No descriptors\n");
|
printk(KERN_ERR "DBRI: setup_descs: No descriptors\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1308,7 +1308,7 @@ to the DBRI via the CHI interface and few of the DBRI's PIO pins.
|
||||||
* Lock must not be held before calling it.
|
* Lock must not be held before calling it.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static void cs4215_setup_pipes(struct snd_dbri *dbri)
|
static __init void cs4215_setup_pipes(struct snd_dbri *dbri)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
|
@ -1341,7 +1341,7 @@ static void cs4215_setup_pipes(struct snd_dbri *dbri)
|
||||||
dbri_cmdwait(dbri);
|
dbri_cmdwait(dbri);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cs4215_init_data(struct cs4215 *mm)
|
static __init int cs4215_init_data(struct cs4215 *mm)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* No action, memory resetting only.
|
* No action, memory resetting only.
|
||||||
|
@ -1633,7 +1633,7 @@ static int cs4215_prepare(struct snd_dbri *dbri, unsigned int rate,
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int cs4215_init(struct snd_dbri *dbri)
|
static __init int cs4215_init(struct snd_dbri *dbri)
|
||||||
{
|
{
|
||||||
u32 reg2 = sbus_readl(dbri->regs + REG2);
|
u32 reg2 = sbus_readl(dbri->regs + REG2);
|
||||||
dprintk(D_MM, "cs4215_init: reg2=0x%x\n", reg2);
|
dprintk(D_MM, "cs4215_init: reg2=0x%x\n", reg2);
|
||||||
|
@ -1771,13 +1771,10 @@ static void xmit_descs(struct snd_dbri *dbri)
|
||||||
|
|
||||||
static void transmission_complete_intr(struct snd_dbri *dbri, int pipe)
|
static void transmission_complete_intr(struct snd_dbri *dbri, int pipe)
|
||||||
{
|
{
|
||||||
struct dbri_streaminfo *info;
|
struct dbri_streaminfo *info = &dbri->stream_info[DBRI_PLAY];
|
||||||
int td;
|
int td = dbri->pipes[pipe].desc;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
info = &dbri->stream_info[DBRI_PLAY];
|
|
||||||
|
|
||||||
td = dbri->pipes[pipe].desc;
|
|
||||||
while (td >= 0) {
|
while (td >= 0) {
|
||||||
if (td >= DBRI_NO_DESCS) {
|
if (td >= DBRI_NO_DESCS) {
|
||||||
printk(KERN_ERR "DBRI: invalid td on pipe %d\n", pipe);
|
printk(KERN_ERR "DBRI: invalid td on pipe %d\n", pipe);
|
||||||
|
@ -1798,12 +1795,9 @@ static void transmission_complete_intr(struct snd_dbri *dbri, int pipe)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify ALSA */
|
/* Notify ALSA */
|
||||||
if (spin_is_locked(&dbri->lock)) {
|
|
||||||
spin_unlock(&dbri->lock);
|
spin_unlock(&dbri->lock);
|
||||||
snd_pcm_period_elapsed(info->substream);
|
snd_pcm_period_elapsed(info->substream);
|
||||||
spin_lock(&dbri->lock);
|
spin_lock(&dbri->lock);
|
||||||
} else
|
|
||||||
snd_pcm_period_elapsed(info->substream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reception_complete_intr(struct snd_dbri *dbri, int pipe)
|
static void reception_complete_intr(struct snd_dbri *dbri, int pipe)
|
||||||
|
@ -1830,12 +1824,9 @@ static void reception_complete_intr(struct snd_dbri *dbri, int pipe)
|
||||||
rd, DBRI_RD_STATUS(status), DBRI_RD_CNT(status));
|
rd, DBRI_RD_STATUS(status), DBRI_RD_CNT(status));
|
||||||
|
|
||||||
/* Notify ALSA */
|
/* Notify ALSA */
|
||||||
if (spin_is_locked(&dbri->lock)) {
|
|
||||||
spin_unlock(&dbri->lock);
|
spin_unlock(&dbri->lock);
|
||||||
snd_pcm_period_elapsed(info->substream);
|
snd_pcm_period_elapsed(info->substream);
|
||||||
spin_lock(&dbri->lock);
|
spin_lock(&dbri->lock);
|
||||||
} else
|
|
||||||
snd_pcm_period_elapsed(info->substream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dbri_process_one_interrupt(struct snd_dbri *dbri, int x)
|
static void dbri_process_one_interrupt(struct snd_dbri *dbri, int x)
|
||||||
|
@ -1986,10 +1977,10 @@ static irqreturn_t snd_dbri_interrupt(int irq, void *dev_id)
|
||||||
PCM Interface
|
PCM Interface
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static struct snd_pcm_hardware snd_dbri_pcm_hw = {
|
static struct snd_pcm_hardware snd_dbri_pcm_hw = {
|
||||||
.info = (SNDRV_PCM_INFO_MMAP |
|
.info = SNDRV_PCM_INFO_MMAP |
|
||||||
SNDRV_PCM_INFO_INTERLEAVED |
|
SNDRV_PCM_INFO_INTERLEAVED |
|
||||||
SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
||||||
SNDRV_PCM_INFO_MMAP_VALID),
|
SNDRV_PCM_INFO_MMAP_VALID,
|
||||||
.formats = SNDRV_PCM_FMTBIT_MU_LAW |
|
.formats = SNDRV_PCM_FMTBIT_MU_LAW |
|
||||||
SNDRV_PCM_FMTBIT_A_LAW |
|
SNDRV_PCM_FMTBIT_A_LAW |
|
||||||
SNDRV_PCM_FMTBIT_U8 |
|
SNDRV_PCM_FMTBIT_U8 |
|
||||||
|
@ -1999,7 +1990,7 @@ static struct snd_pcm_hardware snd_dbri_pcm_hw = {
|
||||||
.rate_max = 48000,
|
.rate_max = 48000,
|
||||||
.channels_min = 1,
|
.channels_min = 1,
|
||||||
.channels_max = 2,
|
.channels_max = 2,
|
||||||
.buffer_bytes_max = (64 * 1024),
|
.buffer_bytes_max = 64 * 1024,
|
||||||
.period_bytes_min = 1,
|
.period_bytes_min = 1,
|
||||||
.period_bytes_max = DBRI_TD_MAXCNT,
|
.period_bytes_max = DBRI_TD_MAXCNT,
|
||||||
.periods_min = 1,
|
.periods_min = 1,
|
||||||
|
@ -2266,11 +2257,10 @@ static int snd_cs4215_info_volume(struct snd_kcontrol *kcontrol,
|
||||||
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
||||||
uinfo->count = 2;
|
uinfo->count = 2;
|
||||||
uinfo->value.integer.min = 0;
|
uinfo->value.integer.min = 0;
|
||||||
if (kcontrol->private_value == DBRI_PLAY) {
|
if (kcontrol->private_value == DBRI_PLAY)
|
||||||
uinfo->value.integer.max = DBRI_MAX_VOLUME;
|
uinfo->value.integer.max = DBRI_MAX_VOLUME;
|
||||||
} else {
|
else
|
||||||
uinfo->value.integer.max = DBRI_MAX_GAIN;
|
uinfo->value.integer.max = DBRI_MAX_GAIN;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2304,7 +2294,7 @@ static int snd_cs4215_put_volume(struct snd_kcontrol *kcontrol,
|
||||||
info->right_gain = ucontrol->value.integer.value[1];
|
info->right_gain = ucontrol->value.integer.value[1];
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
if (changed == 1) {
|
if (changed) {
|
||||||
/* First mute outputs, and wait 1/8000 sec (125 us)
|
/* First mute outputs, and wait 1/8000 sec (125 us)
|
||||||
* to make sure this takes. This avoids clicking noises.
|
* to make sure this takes. This avoids clicking noises.
|
||||||
*/
|
*/
|
||||||
|
@ -2443,8 +2433,9 @@ static int __init snd_dbri_mixer(struct snd_dbri *dbri)
|
||||||
strcpy(card->mixername, card->shortname);
|
strcpy(card->mixername, card->shortname);
|
||||||
|
|
||||||
for (idx = 0; idx < ARRAY_SIZE(dbri_controls); idx++) {
|
for (idx = 0; idx < ARRAY_SIZE(dbri_controls); idx++) {
|
||||||
if ((err = snd_ctl_add(card,
|
err = snd_ctl_add(card,
|
||||||
snd_ctl_new1(&dbri_controls[idx], dbri))) < 0)
|
snd_ctl_new1(&dbri_controls[idx], dbri));
|
||||||
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2485,8 +2476,8 @@ static void dbri_debug_read(struct snd_info_entry *entry,
|
||||||
"Pipe %d: %s SDP=0x%x desc=%d, "
|
"Pipe %d: %s SDP=0x%x desc=%d, "
|
||||||
"len=%d next %d\n",
|
"len=%d next %d\n",
|
||||||
pipe,
|
pipe,
|
||||||
((pptr->sdp & D_SDP_TO_SER) ? "output" :
|
(pptr->sdp & D_SDP_TO_SER) ? "output" :
|
||||||
"input"),
|
"input",
|
||||||
pptr->sdp, pptr->desc,
|
pptr->sdp, pptr->desc,
|
||||||
pptr->length, pptr->nextpipe);
|
pptr->length, pptr->nextpipe);
|
||||||
}
|
}
|
||||||
|
@ -2502,7 +2493,7 @@ void snd_dbri_proc(struct snd_dbri *dbri)
|
||||||
snd_info_set_text_ops(entry, dbri, dbri_regs_read);
|
snd_info_set_text_ops(entry, dbri, dbri_regs_read);
|
||||||
|
|
||||||
#ifdef DBRI_DEBUG
|
#ifdef DBRI_DEBUG
|
||||||
if (! snd_card_proc_new(dbri->card, "debug", &entry)) {
|
if (!snd_card_proc_new(dbri->card, "debug", &entry)) {
|
||||||
snd_info_set_text_ops(entry, dbri, dbri_debug_read);
|
snd_info_set_text_ops(entry, dbri, dbri_debug_read);
|
||||||
entry->mode = S_IFREG | S_IRUGO; /* Readable only. */
|
entry->mode = S_IFREG | S_IRUGO; /* Readable only. */
|
||||||
}
|
}
|
||||||
|
@ -2633,11 +2624,12 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
dbri = card->private_data;
|
dbri = card->private_data;
|
||||||
if ((err = snd_dbri_pcm(dbri)) < 0)
|
err = snd_dbri_pcm(dbri);
|
||||||
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
||||||
if ((err = snd_dbri_mixer(dbri)) < 0)
|
err = snd_dbri_mixer(dbri);
|
||||||
if ((err = snd_dbri_mixer(dbri)) < 0)
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
||||||
/* /proc file handling */
|
/* /proc file handling */
|
||||||
|
|
Loading…
Reference in New Issue