diff options
Diffstat (limited to 'sound/pci/cs46xx/dsp_spos_scb_lib.c')
-rw-r--r-- | sound/pci/cs46xx/dsp_spos_scb_lib.c | 115 |
1 files changed, 70 insertions, 45 deletions
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index 2873cfe48c3..dd7c41b037b 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c | |||
@@ -46,8 +46,11 @@ static void remove_symbol (struct snd_cs46xx * chip, struct dsp_symbol_entry * s | |||
46 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 46 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
47 | int symbol_index = (int)(symbol - ins->symbol_table.symbols); | 47 | int symbol_index = (int)(symbol - ins->symbol_table.symbols); |
48 | 48 | ||
49 | snd_assert(ins->symbol_table.nsymbols > 0,return); | 49 | if (snd_BUG_ON(ins->symbol_table.nsymbols <= 0)) |
50 | snd_assert(symbol_index >= 0 && symbol_index < ins->symbol_table.nsymbols, return); | 50 | return; |
51 | if (snd_BUG_ON(symbol_index < 0 || | ||
52 | symbol_index >= ins->symbol_table.nsymbols)) | ||
53 | return; | ||
51 | 54 | ||
52 | ins->symbol_table.symbols[symbol_index].deleted = 1; | 55 | ins->symbol_table.symbols[symbol_index].deleted = 1; |
53 | 56 | ||
@@ -116,8 +119,9 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor | |||
116 | 119 | ||
117 | if ( scb->parent_scb_ptr ) { | 120 | if ( scb->parent_scb_ptr ) { |
118 | /* unlink parent SCB */ | 121 | /* unlink parent SCB */ |
119 | snd_assert ((scb->parent_scb_ptr->sub_list_ptr == scb || | 122 | if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr != scb && |
120 | scb->parent_scb_ptr->next_scb_ptr == scb),return); | 123 | scb->parent_scb_ptr->next_scb_ptr != scb)) |
124 | return; | ||
121 | 125 | ||
122 | if (scb->parent_scb_ptr->sub_list_ptr == scb) { | 126 | if (scb->parent_scb_ptr->sub_list_ptr == scb) { |
123 | 127 | ||
@@ -140,7 +144,6 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor | |||
140 | scb->next_scb_ptr = ins->the_null_scb; | 144 | scb->next_scb_ptr = ins->the_null_scb; |
141 | } | 145 | } |
142 | } else { | 146 | } else { |
143 | /* snd_assert ( (scb->sub_list_ptr == ins->the_null_scb), return); */ | ||
144 | scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr; | 147 | scb->parent_scb_ptr->next_scb_ptr = scb->next_scb_ptr; |
145 | 148 | ||
146 | if (scb->next_scb_ptr != ins->the_null_scb) { | 149 | if (scb->next_scb_ptr != ins->the_null_scb) { |
@@ -181,16 +184,17 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * | |||
181 | unsigned long flags; | 184 | unsigned long flags; |
182 | 185 | ||
183 | /* check integrety */ | 186 | /* check integrety */ |
184 | snd_assert ( (scb->index >= 0 && | 187 | if (snd_BUG_ON(scb->index < 0 || |
185 | scb->index < ins->nscb && | 188 | scb->index >= ins->nscb || |
186 | (ins->scbs + scb->index) == scb), return ); | 189 | (ins->scbs + scb->index) != scb)) |
190 | return; | ||
187 | 191 | ||
188 | #if 0 | 192 | #if 0 |
189 | /* can't remove a SCB with childs before | 193 | /* can't remove a SCB with childs before |
190 | removing childs first */ | 194 | removing childs first */ |
191 | snd_assert ( (scb->sub_list_ptr == ins->the_null_scb && | 195 | if (snd_BUG_ON(scb->sub_list_ptr != ins->the_null_scb || |
192 | scb->next_scb_ptr == ins->the_null_scb), | 196 | scb->next_scb_ptr != ins->the_null_scb)) |
193 | goto _end); | 197 | goto _end; |
194 | #endif | 198 | #endif |
195 | 199 | ||
196 | spin_lock_irqsave(&scb->lock, flags); | 200 | spin_lock_irqsave(&scb->lock, flags); |
@@ -198,7 +202,8 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * | |||
198 | spin_unlock_irqrestore(&scb->lock, flags); | 202 | spin_unlock_irqrestore(&scb->lock, flags); |
199 | 203 | ||
200 | cs46xx_dsp_proc_free_scb_desc(scb); | 204 | cs46xx_dsp_proc_free_scb_desc(scb); |
201 | snd_assert (scb->scb_symbol != NULL, return ); | 205 | if (snd_BUG_ON(!scb->scb_symbol)) |
206 | return; | ||
202 | remove_symbol (chip,scb->scb_symbol); | 207 | remove_symbol (chip,scb->scb_symbol); |
203 | 208 | ||
204 | ins->scbs[scb->index].deleted = 1; | 209 | ins->scbs[scb->index].deleted = 1; |
@@ -234,7 +239,6 @@ void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb) | |||
234 | snd_info_free_entry(scb->proc_info); | 239 | snd_info_free_entry(scb->proc_info); |
235 | scb->proc_info = NULL; | 240 | scb->proc_info = NULL; |
236 | 241 | ||
237 | snd_assert (scb_info != NULL, return); | ||
238 | kfree (scb_info); | 242 | kfree (scb_info); |
239 | } | 243 | } |
240 | } | 244 | } |
@@ -291,7 +295,8 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u | |||
291 | 295 | ||
292 | unsigned long flags; | 296 | unsigned long flags; |
293 | 297 | ||
294 | snd_assert (ins->the_null_scb != NULL,return NULL); | 298 | if (snd_BUG_ON(!ins->the_null_scb)) |
299 | return NULL; | ||
295 | 300 | ||
296 | /* fill the data that will be wroten to DSP */ | 301 | /* fill the data that will be wroten to DSP */ |
297 | scb_data[SCBsubListPtr] = | 302 | scb_data[SCBsubListPtr] = |
@@ -321,18 +326,20 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u | |||
321 | #endif | 326 | #endif |
322 | /* link to parent SCB */ | 327 | /* link to parent SCB */ |
323 | if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) { | 328 | if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) { |
324 | snd_assert ( (scb->parent_scb_ptr->next_scb_ptr == ins->the_null_scb), | 329 | if (snd_BUG_ON(scb->parent_scb_ptr->next_scb_ptr != |
325 | return NULL); | 330 | ins->the_null_scb)) |
331 | return NULL; | ||
326 | 332 | ||
327 | scb->parent_scb_ptr->next_scb_ptr = scb; | 333 | scb->parent_scb_ptr->next_scb_ptr = scb; |
328 | 334 | ||
329 | } else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) { | 335 | } else if (scb_child_type == SCB_ON_PARENT_SUBLIST_SCB) { |
330 | snd_assert ( (scb->parent_scb_ptr->sub_list_ptr == ins->the_null_scb), | 336 | if (snd_BUG_ON(scb->parent_scb_ptr->sub_list_ptr != |
331 | return NULL); | 337 | ins->the_null_scb)) |
338 | return NULL; | ||
332 | 339 | ||
333 | scb->parent_scb_ptr->sub_list_ptr = scb; | 340 | scb->parent_scb_ptr->sub_list_ptr = scb; |
334 | } else { | 341 | } else { |
335 | snd_assert (0,return NULL); | 342 | snd_BUG(); |
336 | } | 343 | } |
337 | 344 | ||
338 | spin_lock_irqsave(&chip->reg_lock, flags); | 345 | spin_lock_irqsave(&chip->reg_lock, flags); |
@@ -675,7 +682,7 @@ cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name, | |||
675 | if (pass_through) { | 682 | if (pass_through) { |
676 | /* wont work with any other rate than | 683 | /* wont work with any other rate than |
677 | the native DSP rate */ | 684 | the native DSP rate */ |
678 | snd_assert (rate == 48000); | 685 | snd_BUG_ON(rate != 48000); |
679 | 686 | ||
680 | scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb, | 687 | scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb, |
681 | dest,"DMAREADER",parent_scb, | 688 | dest,"DMAREADER",parent_scb, |
@@ -1142,7 +1149,8 @@ find_next_free_scb (struct snd_cs46xx * chip, struct dsp_scb_descriptor * from) | |||
1142 | struct dsp_scb_descriptor * scb = from; | 1149 | struct dsp_scb_descriptor * scb = from; |
1143 | 1150 | ||
1144 | while (scb->next_scb_ptr != ins->the_null_scb) { | 1151 | while (scb->next_scb_ptr != ins->the_null_scb) { |
1145 | snd_assert (scb->next_scb_ptr != NULL, return NULL); | 1152 | if (snd_BUG_ON(!scb->next_scb_ptr)) |
1153 | return NULL; | ||
1146 | 1154 | ||
1147 | scb = scb->next_scb_ptr; | 1155 | scb = scb->next_scb_ptr; |
1148 | } | 1156 | } |
@@ -1246,10 +1254,11 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, | |||
1246 | break; | 1254 | break; |
1247 | case DSP_PCM_S71_CHANNEL: | 1255 | case DSP_PCM_S71_CHANNEL: |
1248 | /* TODO */ | 1256 | /* TODO */ |
1249 | snd_assert(0); | 1257 | snd_BUG(); |
1250 | break; | 1258 | break; |
1251 | case DSP_IEC958_CHANNEL: | 1259 | case DSP_IEC958_CHANNEL: |
1252 | snd_assert (ins->asynch_tx_scb != NULL, return NULL); | 1260 | if (snd_BUG_ON(!ins->asynch_tx_scb)) |
1261 | return NULL; | ||
1253 | mixer_scb = ins->asynch_tx_scb; | 1262 | mixer_scb = ins->asynch_tx_scb; |
1254 | 1263 | ||
1255 | /* if sample rate is set to 48khz we pass | 1264 | /* if sample rate is set to 48khz we pass |
@@ -1262,7 +1271,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, | |||
1262 | } | 1271 | } |
1263 | break; | 1272 | break; |
1264 | default: | 1273 | default: |
1265 | snd_assert (0); | 1274 | snd_BUG(); |
1266 | return NULL; | 1275 | return NULL; |
1267 | } | 1276 | } |
1268 | /* default sample rate is 44100 */ | 1277 | /* default sample rate is 44100 */ |
@@ -1308,7 +1317,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, | |||
1308 | break; | 1317 | break; |
1309 | } | 1318 | } |
1310 | } | 1319 | } |
1311 | snd_assert (src_index != -1,return NULL); | 1320 | if (snd_BUG_ON(src_index == -1)) |
1321 | return NULL; | ||
1312 | 1322 | ||
1313 | /* we need to create a new SRC SCB */ | 1323 | /* we need to create a new SRC SCB */ |
1314 | if (mixer_scb->sub_list_ptr == ins->the_null_scb) { | 1324 | if (mixer_scb->sub_list_ptr == ins->the_null_scb) { |
@@ -1462,9 +1472,10 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip, | |||
1462 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 1472 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
1463 | unsigned long flags; | 1473 | unsigned long flags; |
1464 | 1474 | ||
1465 | snd_assert(pcm_channel->active, return ); | 1475 | if (snd_BUG_ON(!pcm_channel->active || |
1466 | snd_assert(ins->npcm_channels > 0, return ); | 1476 | ins->npcm_channels <= 0 || |
1467 | snd_assert(pcm_channel->src_scb->ref_count > 0, return ); | 1477 | pcm_channel->src_scb->ref_count <= 0)) |
1478 | return; | ||
1468 | 1479 | ||
1469 | spin_lock_irqsave(&chip->reg_lock, flags); | 1480 | spin_lock_irqsave(&chip->reg_lock, flags); |
1470 | pcm_channel->unlinked = 1; | 1481 | pcm_channel->unlinked = 1; |
@@ -1479,8 +1490,9 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip, | |||
1479 | if (!pcm_channel->src_scb->ref_count) { | 1490 | if (!pcm_channel->src_scb->ref_count) { |
1480 | cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb); | 1491 | cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb); |
1481 | 1492 | ||
1482 | snd_assert (pcm_channel->src_slot >= 0 && pcm_channel->src_slot < DSP_MAX_SRC_NR, | 1493 | if (snd_BUG_ON(pcm_channel->src_slot < 0 || |
1483 | return ); | 1494 | pcm_channel->src_slot >= DSP_MAX_SRC_NR)) |
1495 | return; | ||
1484 | 1496 | ||
1485 | ins->src_scb_slots[pcm_channel->src_slot] = 0; | 1497 | ins->src_scb_slots[pcm_channel->src_slot] = 0; |
1486 | ins->nsrc_scb --; | 1498 | ins->nsrc_scb --; |
@@ -1490,11 +1502,11 @@ void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip, | |||
1490 | int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, | 1502 | int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, |
1491 | struct dsp_pcm_channel_descriptor * pcm_channel) | 1503 | struct dsp_pcm_channel_descriptor * pcm_channel) |
1492 | { | 1504 | { |
1493 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | ||
1494 | unsigned long flags; | 1505 | unsigned long flags; |
1495 | 1506 | ||
1496 | snd_assert(pcm_channel->active,return -EIO); | 1507 | if (snd_BUG_ON(!pcm_channel->active || |
1497 | snd_assert(ins->npcm_channels > 0,return -EIO); | 1508 | chip->dsp_spos_instance->npcm_channels <= 0)) |
1509 | return -EIO; | ||
1498 | 1510 | ||
1499 | spin_lock(&pcm_channel->src_scb->lock); | 1511 | spin_lock(&pcm_channel->src_scb->lock); |
1500 | 1512 | ||
@@ -1537,7 +1549,7 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, | |||
1537 | 1549 | ||
1538 | src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb; | 1550 | src_scb->sub_list_ptr = pcm_channel->pcm_reader_scb; |
1539 | 1551 | ||
1540 | snd_assert (pcm_channel->pcm_reader_scb->parent_scb_ptr == NULL, ; ); | 1552 | snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr); |
1541 | pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; | 1553 | pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; |
1542 | 1554 | ||
1543 | spin_lock_irqsave(&chip->reg_lock, flags); | 1555 | spin_lock_irqsave(&chip->reg_lock, flags); |
@@ -1564,7 +1576,8 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s | |||
1564 | struct dsp_scb_descriptor * pcm_input; | 1576 | struct dsp_scb_descriptor * pcm_input; |
1565 | int insert_point; | 1577 | int insert_point; |
1566 | 1578 | ||
1567 | snd_assert (ins->record_mixer_scb != NULL,return NULL); | 1579 | if (snd_BUG_ON(!ins->record_mixer_scb)) |
1580 | return NULL; | ||
1568 | 1581 | ||
1569 | if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) { | 1582 | if (ins->record_mixer_scb->sub_list_ptr != ins->the_null_scb) { |
1570 | parent = find_next_free_scb (chip,ins->record_mixer_scb->sub_list_ptr); | 1583 | parent = find_next_free_scb (chip,ins->record_mixer_scb->sub_list_ptr); |
@@ -1583,7 +1596,8 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s | |||
1583 | 1596 | ||
1584 | int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) | 1597 | int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) |
1585 | { | 1598 | { |
1586 | snd_assert (src->parent_scb_ptr != NULL, return -EINVAL ); | 1599 | if (snd_BUG_ON(!src->parent_scb_ptr)) |
1600 | return -EINVAL; | ||
1587 | 1601 | ||
1588 | /* mute SCB */ | 1602 | /* mute SCB */ |
1589 | cs46xx_dsp_scb_set_volume (chip,src,0,0); | 1603 | cs46xx_dsp_scb_set_volume (chip,src,0,0); |
@@ -1598,8 +1612,10 @@ int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) | |||
1598 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 1612 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
1599 | struct dsp_scb_descriptor * parent_scb; | 1613 | struct dsp_scb_descriptor * parent_scb; |
1600 | 1614 | ||
1601 | snd_assert (src->parent_scb_ptr == NULL, return -EINVAL ); | 1615 | if (snd_BUG_ON(src->parent_scb_ptr)) |
1602 | snd_assert(ins->master_mix_scb !=NULL, return -EINVAL ); | 1616 | return -EINVAL; |
1617 | if (snd_BUG_ON(!ins->master_mix_scb)) | ||
1618 | return -EINVAL; | ||
1603 | 1619 | ||
1604 | if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) { | 1620 | if (ins->master_mix_scb->sub_list_ptr != ins->the_null_scb) { |
1605 | parent_scb = find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr); | 1621 | parent_scb = find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr); |
@@ -1635,8 +1651,11 @@ int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip) | |||
1635 | return -EBUSY; | 1651 | return -EBUSY; |
1636 | } | 1652 | } |
1637 | 1653 | ||
1638 | snd_assert (ins->asynch_tx_scb == NULL, return -EINVAL); | 1654 | if (snd_BUG_ON(ins->asynch_tx_scb)) |
1639 | snd_assert (ins->master_mix_scb->next_scb_ptr == ins->the_null_scb, return -EINVAL); | 1655 | return -EINVAL; |
1656 | if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr != | ||
1657 | ins->the_null_scb)) | ||
1658 | return -EINVAL; | ||
1640 | 1659 | ||
1641 | /* reset output snooper sample buffer pointer */ | 1660 | /* reset output snooper sample buffer pointer */ |
1642 | snd_cs46xx_poke (chip, (ins->ref_snoop_scb->address + 2) << 2, | 1661 | snd_cs46xx_poke (chip, (ins->ref_snoop_scb->address + 2) << 2, |
@@ -1676,10 +1695,15 @@ int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip) | |||
1676 | } | 1695 | } |
1677 | 1696 | ||
1678 | /* check integrety */ | 1697 | /* check integrety */ |
1679 | snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); | 1698 | if (snd_BUG_ON(!ins->asynch_tx_scb)) |
1680 | snd_assert (ins->spdif_pcm_input_scb != NULL,return -EINVAL); | 1699 | return -EINVAL; |
1681 | snd_assert (ins->master_mix_scb->next_scb_ptr == ins->asynch_tx_scb, return -EINVAL); | 1700 | if (snd_BUG_ON(!ins->spdif_pcm_input_scb)) |
1682 | snd_assert (ins->asynch_tx_scb->parent_scb_ptr == ins->master_mix_scb, return -EINVAL); | 1701 | return -EINVAL; |
1702 | if (snd_BUG_ON(ins->master_mix_scb->next_scb_ptr != ins->asynch_tx_scb)) | ||
1703 | return -EINVAL; | ||
1704 | if (snd_BUG_ON(ins->asynch_tx_scb->parent_scb_ptr != | ||
1705 | ins->master_mix_scb)) | ||
1706 | return -EINVAL; | ||
1683 | 1707 | ||
1684 | cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb); | 1708 | cs46xx_dsp_remove_scb (chip,ins->spdif_pcm_input_scb); |
1685 | cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb); | 1709 | cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb); |
@@ -1734,7 +1758,8 @@ int cs46xx_iec958_post_close (struct snd_cs46xx *chip) | |||
1734 | { | 1758 | { |
1735 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 1759 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
1736 | 1760 | ||
1737 | snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); | 1761 | if (snd_BUG_ON(!ins->asynch_tx_scb)) |
1762 | return -EINVAL; | ||
1738 | 1763 | ||
1739 | ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN; | 1764 | ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN; |
1740 | 1765 | ||