diff options
Diffstat (limited to 'sound/pci/cs46xx/dsp_spos_scb_lib.c')
| -rw-r--r-- | sound/pci/cs46xx/dsp_spos_scb_lib.c | 118 |
1 files changed, 32 insertions, 86 deletions
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index 7488e1b7a770..32ed415bf427 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -1,19 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * */ /* @@ -73,14 +59,11 @@ static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, { struct proc_scb_info * scb_info = entry->private_data; struct dsp_scb_descriptor * scb = scb_info->scb_desc; - struct dsp_spos_instance * ins; struct snd_cs46xx *chip = scb_info->chip; int j,col; void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; - ins = chip->dsp_spos_instance; - - mutex_lock(&chip->spos_mutex); + guard(mutex)(&chip->spos_mutex); snd_iprintf(buffer,"%04x %s:\n",scb->address,scb->scb_name); for (col = 0,j = 0;j < 0x10; j++,col++) { @@ -108,7 +91,6 @@ static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, scb->task_entry->address); snd_iprintf(buffer,"index [%d] ref_count [%d]\n",scb->index,scb->ref_count); - mutex_unlock(&chip->spos_mutex); } #endif @@ -177,7 +159,6 @@ static void _dsp_clear_sample_buffer (struct snd_cs46xx *chip, u32 sample_buffer void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) { struct dsp_spos_instance * ins = chip->dsp_spos_instance; - unsigned long flags; /* check integrety */ if (snd_BUG_ON(scb->index < 0 || @@ -193,9 +174,9 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * goto _end; #endif - spin_lock_irqsave(&chip->reg_lock, flags); - _dsp_unlink_scb (chip,scb); - spin_unlock_irqrestore(&chip->reg_lock, flags); + scoped_guard(spinlock_irqsave, &chip->reg_lock) { + _dsp_unlink_scb(chip, scb); + } cs46xx_dsp_proc_free_scb_desc(scb); if (snd_BUG_ON(!scb->scb_symbol)) @@ -218,13 +199,6 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * if (ins->scb_highest_frag_index > ins->nscb) { ins->scb_highest_frag_index = ins->nscb; } - -#if 0 - /* !!!! THIS IS A PIECE OF SHIT MADE BY ME !!! */ - for(i = scb->index + 1;i < ins->nscb; ++i) { - ins->scbs[i - 1].index = i - 1; - } -#endif } @@ -257,8 +231,9 @@ void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip, if (ins->snd_card != NULL && ins->proc_dsp_dir != NULL && scb->proc_info == NULL) { - if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name, - ins->proc_dsp_dir)) != NULL) { + entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name, + ins->proc_dsp_dir); + if (entry) { scb_info = kmalloc(sizeof(struct proc_scb_info), GFP_KERNEL); if (!scb_info) { snd_info_free_entry(entry); @@ -268,18 +243,8 @@ void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip, scb_info->chip = chip; scb_info->scb_desc = scb; - - entry->content = SNDRV_INFO_CONTENT_TEXT; - entry->private_data = scb_info; - entry->mode = S_IFREG | S_IRUGO | S_IWUSR; - - entry->c.text.read = cs46xx_dsp_proc_scb_info_read; - - if (snd_info_register(entry) < 0) { - snd_info_free_entry(entry); - kfree (scb_info); - entry = NULL; - } + snd_info_set_text_ops(entry, scb_info, + cs46xx_dsp_proc_scb_info_read); } out: scb->proc_info = entry; @@ -296,8 +261,6 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u struct dsp_spos_instance * ins = chip->dsp_spos_instance; struct dsp_scb_descriptor * scb; - unsigned long flags; - if (snd_BUG_ON(!ins->the_null_scb)) return NULL; @@ -351,12 +314,10 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u snd_BUG(); } - spin_lock_irqsave(&chip->reg_lock, flags); - - /* update entry in DSP RAM */ - cs46xx_dsp_spos_update_scb(chip,scb->parent_scb_ptr); - - spin_unlock_irqrestore(&chip->reg_lock, flags); + scoped_guard(spinlock_irqsave, &chip->reg_lock) { + /* update entry in DSP RAM */ + cs46xx_dsp_spos_update_scb(chip, scb->parent_scb_ptr); + } } @@ -1171,7 +1132,7 @@ find_next_free_scb (struct snd_cs46xx * chip, struct dsp_scb_descriptor * from) return scb; } -static u32 pcm_reader_buffer_addr[DSP_MAX_PCM_CHANNELS] = { +static const u32 pcm_reader_buffer_addr[DSP_MAX_PCM_CHANNELS] = { 0x0600, /* 1 */ 0x1500, /* 2 */ 0x1580, /* 3 */ @@ -1206,7 +1167,7 @@ static u32 pcm_reader_buffer_addr[DSP_MAX_PCM_CHANNELS] = { 0x2400, /* 32 */ }; -static u32 src_output_buffer_addr[DSP_MAX_SRC_NR] = { +static const u32 src_output_buffer_addr[DSP_MAX_SRC_NR] = { 0x2B80, 0x2BA0, 0x2BC0, @@ -1223,7 +1184,7 @@ static u32 src_output_buffer_addr[DSP_MAX_SRC_NR] = { 0x2E20 }; -static u32 src_delay_buffer_addr[DSP_MAX_SRC_NR] = { +static const u32 src_delay_buffer_addr[DSP_MAX_SRC_NR] = { 0x2480, 0x2500, 0x2580, @@ -1253,7 +1214,6 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, /* struct dsp_scb_descriptor * pcm_parent_scb; */ char scb_name[DSP_MAX_SCB_NAME]; int i, pcm_index = -1, insert_point, src_index = -1, pass_through = 0; - unsigned long flags; switch (pcm_channel_id) { case DSP_PCM_MAIN_CHANNEL: @@ -1319,7 +1279,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, if (src_scb == NULL) { if (ins->nsrc_scb >= DSP_MAX_SRC_NR) { dev_err(chip->card->dev, - "dsp_spos: to many SRC instances\n!"); + "dsp_spos: too many SRC instances\n!"); return NULL; } @@ -1390,7 +1350,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, return NULL; } - spin_lock_irqsave(&chip->reg_lock, flags); + guard(spinlock_irqsave)(&chip->reg_lock); ins->pcm_channels[pcm_index].sample_rate = sample_rate; ins->pcm_channels[pcm_index].pcm_reader_scb = pcm_scb; ins->pcm_channels[pcm_index].src_scb = src_scb; @@ -1401,7 +1361,6 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, ins->pcm_channels[pcm_index].pcm_slot = pcm_index; ins->pcm_channels[pcm_index].mixer_scb = mixer_scb; ins->npcm_channels ++; - spin_unlock_irqrestore(&chip->reg_lock, flags); return (ins->pcm_channels + pcm_index); } @@ -1489,20 +1448,19 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip, struct dsp_pcm_channel_descriptor * pcm_channel) { struct dsp_spos_instance * ins = chip->dsp_spos_instance; - unsigned long flags; if (snd_BUG_ON(!pcm_channel->active || ins->npcm_channels <= 0 || pcm_channel->src_scb->ref_count <= 0)) return; - spin_lock_irqsave(&chip->reg_lock, flags); - pcm_channel->unlinked = 1; - pcm_channel->active = 0; - pcm_channel->private_data = NULL; - pcm_channel->src_scb->ref_count --; - ins->npcm_channels --; - spin_unlock_irqrestore(&chip->reg_lock, flags); + scoped_guard(spinlock_irqsave, &chip->reg_lock) { + pcm_channel->unlinked = 1; + pcm_channel->active = 0; + pcm_channel->private_data = NULL; + pcm_channel->src_scb->ref_count--; + ins->npcm_channels--; + } cs46xx_dsp_remove_scb(chip,pcm_channel->pcm_reader_scb); @@ -1521,22 +1479,17 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip, int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, struct dsp_pcm_channel_descriptor * pcm_channel) { - unsigned long flags; - if (snd_BUG_ON(!pcm_channel->active || chip->dsp_spos_instance->npcm_channels <= 0)) return -EIO; - spin_lock_irqsave(&chip->reg_lock, flags); - if (pcm_channel->unlinked) { - spin_unlock_irqrestore(&chip->reg_lock, flags); + guard(spinlock_irqsave)(&chip->reg_lock); + if (pcm_channel->unlinked) return -EIO; - } pcm_channel->unlinked = 1; _dsp_unlink_scb (chip,pcm_channel->pcm_reader_scb); - spin_unlock_irqrestore(&chip->reg_lock, flags); return 0; } @@ -1547,14 +1500,11 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, struct dsp_spos_instance * ins = chip->dsp_spos_instance; struct dsp_scb_descriptor * parent_scb; struct dsp_scb_descriptor * src_scb = pcm_channel->src_scb; - unsigned long flags; - spin_lock_irqsave(&chip->reg_lock, flags); + guard(spinlock_irqsave)(&chip->reg_lock); - if (pcm_channel->unlinked == 0) { - spin_unlock_irqrestore(&chip->reg_lock, flags); + if (pcm_channel->unlinked == 0) return -EIO; - } parent_scb = src_scb; @@ -1575,7 +1525,6 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, cs46xx_dsp_spos_update_scb(chip,parent_scb); pcm_channel->unlinked = 0; - spin_unlock_irqrestore(&chip->reg_lock, flags); return 0; } @@ -1608,17 +1557,14 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) { - unsigned long flags; - if (snd_BUG_ON(!src->parent_scb_ptr)) return -EINVAL; /* mute SCB */ cs46xx_dsp_scb_set_volume (chip,src,0,0); - spin_lock_irqsave(&chip->reg_lock, flags); + guard(spinlock_irqsave)(&chip->reg_lock); _dsp_unlink_scb (chip,src); - spin_unlock_irqrestore(&chip->reg_lock, flags); return 0; } @@ -1742,7 +1688,7 @@ int cs46xx_iec958_pre_open (struct snd_cs46xx *chip) struct dsp_spos_instance * ins = chip->dsp_spos_instance; if ( ins->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED ) { - /* remove AsynchFGTxSCB and and PCMSerialInput_II */ + /* remove AsynchFGTxSCB and PCMSerialInput_II */ cs46xx_dsp_disable_spdif_out (chip); /* save state */ |
