vserver 2.0 rc7
[linux-2.6.git] / sound / pci / cs46xx / dsp_spos.c
index 95fc96f..b66304f 100644 (file)
@@ -37,6 +37,8 @@
 #include "cs46xx_lib.h"
 #include "dsp_spos.h"
 
+static int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entry);
+
 static wide_opcode_t wide_opcodes[] = { 
        WIDE_FOR_BEGIN_LOOP,
        WIDE_FOR_BEGIN_LOOP2,
@@ -74,7 +76,7 @@ static int shadow_and_reallocate_code (cs46xx_t * chip,u32 * data,u32 size, u32
                            (mop_operands & WIDE_LADD_INSTR_MASK) == 0 &&
                            (mop_operands & WIDE_INSTR_MASK) != 0) {
                                wide_op = loval & 0x7f;
-                               for (j = 0;j < sizeof(wide_opcodes) / sizeof(wide_opcode_t); ++j) {
+                               for (j = 0;j < ARRAY_SIZE(wide_opcodes); ++j) {
                                        if (wide_opcodes[j] == wide_op) {
                                                /* need to reallocate instruction */
                                                address  = (hival & 0x00FFF) << 5;
@@ -289,15 +291,9 @@ void  cs46xx_dsp_spos_destroy (cs46xx_t * chip)
                cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) );
        }
 
-       if (ins->code.data)
-               kfree(ins->code.data);
-
-       if (ins->symbol_table.symbols)
-               vfree(ins->symbol_table.symbols);
-
-       if (ins->modules)
-               kfree(ins->modules);
-       
+       kfree(ins->code.data);
+       vfree(ins->symbol_table.symbols);
+       kfree(ins->modules);
        kfree(ins);
        up(&chip->spos_mutex);
 }
@@ -439,7 +435,7 @@ symbol_entry_t * cs46xx_dsp_lookup_symbol (cs46xx_t * chip, char * symbol_name,
 }
 
 
-symbol_entry_t * cs46xx_dsp_lookup_symbol_addr (cs46xx_t * chip, u32 address, int symbol_type)
+static symbol_entry_t * cs46xx_dsp_lookup_symbol_addr (cs46xx_t * chip, u32 address, int symbol_type)
 {
        int i;
        dsp_spos_instance_t * ins = chip->dsp_spos_instance;
@@ -462,7 +458,7 @@ symbol_entry_t * cs46xx_dsp_lookup_symbol_addr (cs46xx_t * chip, u32 address, in
 
 static void cs46xx_dsp_proc_symbol_table_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer)
 {
-       cs46xx_t *chip = snd_magic_cast(cs46xx_t, entry->private_data, return);
+       cs46xx_t *chip = entry->private_data;
        dsp_spos_instance_t * ins = chip->dsp_spos_instance;
        int i;
 
@@ -489,7 +485,7 @@ static void cs46xx_dsp_proc_symbol_table_read (snd_info_entry_t *entry, snd_info
 
 static void cs46xx_dsp_proc_modules_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer)
 {
-       cs46xx_t *chip = snd_magic_cast(cs46xx_t, entry->private_data, return);
+       cs46xx_t *chip = entry->private_data;
        dsp_spos_instance_t * ins = chip->dsp_spos_instance;
        int i,j;
 
@@ -511,10 +507,10 @@ static void cs46xx_dsp_proc_modules_read (snd_info_entry_t *entry, snd_info_buff
 
 static void cs46xx_dsp_proc_task_tree_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer)
 {
-       cs46xx_t *chip = snd_magic_cast(cs46xx_t, entry->private_data, return);
+       cs46xx_t *chip = entry->private_data;
        dsp_spos_instance_t * ins = chip->dsp_spos_instance;
        int i,j,col;
-       unsigned long dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
+       void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
 
        down(&chip->spos_mutex);
        snd_iprintf(buffer, "TASK TREES:\n");
@@ -538,7 +534,7 @@ static void cs46xx_dsp_proc_task_tree_read (snd_info_entry_t *entry, snd_info_bu
 
 static void cs46xx_dsp_proc_scb_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer)
 {
-       cs46xx_t *chip = snd_magic_cast(cs46xx_t, entry->private_data, return);
+       cs46xx_t *chip = entry->private_data;
        dsp_spos_instance_t * ins = chip->dsp_spos_instance;
        int i;
 
@@ -570,10 +566,10 @@ static void cs46xx_dsp_proc_scb_read (snd_info_entry_t *entry, snd_info_buffer_t
 
 static void cs46xx_dsp_proc_parameter_dump_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer)
 {
-       cs46xx_t *chip = snd_magic_cast(cs46xx_t, entry->private_data, return);
+       cs46xx_t *chip = entry->private_data;
        /*dsp_spos_instance_t * ins = chip->dsp_spos_instance; */
        unsigned int i,col = 0;
-       unsigned long dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
+       void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
        symbol_entry_t * symbol; 
 
        for (i = 0;i < DSP_PARAMETER_BYTE_SIZE; i += sizeof(u32),col ++) {
@@ -597,9 +593,9 @@ static void cs46xx_dsp_proc_parameter_dump_read (snd_info_entry_t *entry, snd_in
 
 static void cs46xx_dsp_proc_sample_dump_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer)
 {
-       cs46xx_t *chip = snd_magic_cast(cs46xx_t, entry->private_data, return);
+       cs46xx_t *chip = entry->private_data;
        int i,col = 0;
-       unsigned long dst = chip->region.idx[2].remap_addr;
+       void __iomem *dst = chip->region.idx[2].remap_addr;
 
        snd_iprintf(buffer,"PCMREADER:\n");
        for (i = PCM_READER_BUF1;i < PCM_READER_BUF1 + 0x30; i += sizeof(u32),col ++) {
@@ -909,12 +905,12 @@ int cs46xx_dsp_proc_done (cs46xx_t *chip)
 static int debug_tree;
 static void _dsp_create_task_tree (cs46xx_t *chip,u32 * task_data, u32  dest, int size)
 {
-       unsigned long spdst = chip->region.idx[1].remap_addr + 
+       void __iomem *spdst = chip->region.idx[1].remap_addr + 
                DSP_PARAMETER_BYTE_OFFSET + dest * sizeof(u32);
        int i;
 
        for (i = 0; i < size; ++i) {
-               if (debug_tree) printk ("addr %08x, val %08x\n",(int)spdst,task_data[i]);
+               if (debug_tree) printk ("addr %p, val %08x\n",spdst,task_data[i]);
                writel(task_data[i],spdst);
                spdst += sizeof(u32);
        }
@@ -923,12 +919,12 @@ static void _dsp_create_task_tree (cs46xx_t *chip,u32 * task_data, u32  dest, in
 static int debug_scb;
 static void _dsp_create_scb (cs46xx_t *chip,u32 * scb_data, u32  dest)
 {
-       unsigned long spdst = chip->region.idx[1].remap_addr + 
+       void __iomem *spdst = chip->region.idx[1].remap_addr + 
                DSP_PARAMETER_BYTE_OFFSET + dest * sizeof(u32);
        int i;
 
        for (i = 0; i < 0x10; ++i) {
-               if (debug_scb) printk ("addr %08x, val %08x\n",(int)spdst,scb_data[i]);
+               if (debug_scb) printk ("addr %p, val %08x\n",spdst,scb_data[i]);
                writel(scb_data[i],spdst);
                spdst += sizeof(u32);
        }
@@ -1019,7 +1015,7 @@ dsp_scb_descriptor_t * cs46xx_dsp_create_scb (cs46xx_t *chip,char * name, u32 *
 }
 
 
-dsp_task_descriptor_t *  cs46xx_dsp_create_task_tree (cs46xx_t *chip,char * name, u32 * task_data,u32 dest,int size)
+static dsp_task_descriptor_t *  cs46xx_dsp_create_task_tree (cs46xx_t *chip,char * name, u32 * task_data,u32 dest,int size)
 {
        dsp_task_descriptor_t * desc;
 
@@ -1057,7 +1053,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
        
        int fifo_addr,fifo_span,valid_slots;
 
-       spos_control_block_t sposcb = {
+       static spos_control_block_t sposcb = {
                /* 0 */ HFG_TREE_SCB,HFG_STACK,
                /* 1 */ SPOSCB_ADDR,BG_TREE_SCB_ADDR,
                /* 2 */ DSP_SPOS_DC,0,
@@ -1110,18 +1106,18 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
   
        {
                /* create the null SCB */
-               generic_scb_t null_scb = {
+               static generic_scb_t null_scb = {
                        { 0, 0, 0, 0 },
                        { 0, 0, 0, 0, 0 },
                        NULL_SCB_ADDR, NULL_SCB_ADDR,
-                       null_algorithm->address, 0,
-                       0,0,0,
+                       0, 0, 0, 0, 0,
                        {
                                0,0,
                                0,0,
                        }
                };
 
+               null_scb.entry_point = null_algorithm->address;
                ins->the_null_scb = cs46xx_dsp_create_scb(chip, "nullSCB", (u32 *)&null_scb, NULL_SCB_ADDR);
                ins->the_null_scb->task_entry = null_algorithm;
                ins->the_null_scb->sub_list_ptr = ins->the_null_scb;
@@ -1132,7 +1128,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
 
        {
                /* setup foreground task tree */
-               task_tree_control_block_t fg_task_tree_hdr =  {
+               static task_tree_control_block_t fg_task_tree_hdr =  {
                        { FG_TASK_HEADER_ADDR | (DSP_SPOS_DC << 0x10),
                          DSP_SPOS_DC_DC,
                          DSP_SPOS_DC_DC,
@@ -1145,7 +1141,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
     
                        {
                                BG_TREE_SCB_ADDR,TIMINGMASTER_SCB_ADDR, 
-                               fg_task_tree_header_code->address,
+                               0,
                                FG_TASK_HEADER_ADDR + TCBData,                  
                        },
 
@@ -1158,7 +1154,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
                        },
 
                        {
-                               DSP_SPOS_DC,task_tree_thread->address,
+                               DSP_SPOS_DC,0,
                                DSP_SPOS_DC,DSP_SPOS_DC,
                                DSP_SPOS_DC,DSP_SPOS_DC,
                                DSP_SPOS_DC,DSP_SPOS_DC,
@@ -1200,13 +1196,15 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
                        }
                };
 
+               fg_task_tree_hdr.links.entry_point = fg_task_tree_header_code->address;
+               fg_task_tree_hdr.context_blk.stack0 = task_tree_thread->address;
                cs46xx_dsp_create_task_tree(chip,"FGtaskTreeHdr",(u32 *)&fg_task_tree_hdr,FG_TASK_HEADER_ADDR,0x35);
        }
 
 
        {
                /* setup foreground task tree */
-               task_tree_control_block_t bg_task_tree_hdr =  {
+               static task_tree_control_block_t bg_task_tree_hdr =  {
                        { DSP_SPOS_DC_DC,
                          DSP_SPOS_DC_DC,
                          DSP_SPOS_DC_DC,
@@ -1219,7 +1217,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
     
                        {
                                NULL_SCB_ADDR,NULL_SCB_ADDR,  /* Set up the background to do nothing */
-                               task_tree_header_code->address,
+                               0,
                                BG_TREE_SCB_ADDR + TCBData,
                        },
 
@@ -1232,7 +1230,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
                        },
 
                        {
-                               DSP_SPOS_DC,task_tree_thread->address,
+                               DSP_SPOS_DC,0,
                                DSP_SPOS_DC,DSP_SPOS_DC,
                                DSP_SPOS_DC,DSP_SPOS_DC,
                                DSP_SPOS_DC,DSP_SPOS_DC,
@@ -1273,6 +1271,9 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
                                0,0
                        }
                };
+
+               bg_task_tree_hdr.links.entry_point = task_tree_header_code->address;
+               bg_task_tree_hdr.context_blk.stack0 = task_tree_thread->address;
                cs46xx_dsp_create_task_tree(chip,"BGtaskTreeHdr",(u32 *)&bg_task_tree_hdr,BG_TREE_SCB_ADDR,0x35);
        }
 
@@ -1312,7 +1313,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
        if (!write_back_scb) goto _fail_end;
 
        {
-               mix2_ostream_spb_t mix2_ostream_spb = {
+               static mix2_ostream_spb_t mix2_ostream_spb = {
                        0x00020000,
                        0x0000ffff
                };
@@ -1447,7 +1448,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip)
        return -EINVAL;
 }
 
-int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entry)
+static int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entry)
 {
        dsp_spos_instance_t * ins = chip->dsp_spos_instance;
        symbol_entry_t * s16_async_codec_input_task;