2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * 2002-07 Benny Sjostrand benny@hostmobility.com
24 #include <linux/delay.h>
26 #include <linux/init.h>
27 #include <linux/slab.h>
28 #include <linux/vmalloc.h>
29 #include <linux/mutex.h>
31 #include <sound/core.h>
32 #include <sound/control.h>
33 #include <sound/info.h>
34 #include <sound/asoundef.h>
35 #include <sound/cs46xx.h>
37 #include "cs46xx_lib.h"
40 static int cs46xx_dsp_async_init (struct snd_cs46xx
*chip
,
41 struct dsp_scb_descriptor
* fg_entry
);
43 static enum wide_opcode wide_opcodes
[] = {
48 WIDE_TBEQ_COND_GOTO_ADDR
,
49 WIDE_TBEQ_COND_CALL_ADDR
,
50 WIDE_TBEQ_NCOND_GOTO_ADDR
,
51 WIDE_TBEQ_NCOND_CALL_ADDR
,
52 WIDE_TBEQ_COND_GOTO1_ADDR
,
53 WIDE_TBEQ_COND_CALL1_ADDR
,
54 WIDE_TBEQ_NCOND_GOTOI_ADDR
,
55 WIDE_TBEQ_NCOND_CALL1_ADDR
58 static int shadow_and_reallocate_code (struct snd_cs46xx
* chip
, u32
* data
, u32 size
,
59 u32 overlay_begin_address
)
61 unsigned int i
= 0, j
, nreallocated
= 0;
62 u32 hival
,loval
,address
;
63 u32 mop_operands
,mop_type
,wide_op
;
64 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
66 if (snd_BUG_ON(size
%2))
73 if (ins
->code
.offset
> 0) {
74 mop_operands
= (hival
>> 6) & 0x03fff;
75 mop_type
= mop_operands
>> 10;
77 /* check for wide type instruction */
79 (mop_operands
& WIDE_LADD_INSTR_MASK
) == 0 &&
80 (mop_operands
& WIDE_INSTR_MASK
) != 0) {
81 wide_op
= loval
& 0x7f;
82 for (j
= 0;j
< ARRAY_SIZE(wide_opcodes
); ++j
) {
83 if (wide_opcodes
[j
] == wide_op
) {
84 /* need to reallocate instruction */
85 address
= (hival
& 0x00FFF) << 5;
86 address
|= loval
>> 15;
88 snd_printdd("handle_wideop[1]: %05x:%05x addr %04x\n",hival
,loval
,address
);
90 if ( !(address
& 0x8000) ) {
91 address
+= (ins
->code
.offset
/ 2) - overlay_begin_address
;
93 snd_printdd("handle_wideop[1]: ROM symbol not reallocated\n");
99 hival
|= ( (address
>> 5) & 0x00FFF);
100 loval
|= ( (address
<< 15) & 0xF8000);
102 address
= (hival
& 0x00FFF) << 5;
103 address
|= loval
>> 15;
105 snd_printdd("handle_wideop:[2] %05x:%05x addr %04x\n",hival
,loval
,address
);
107 } /* wide_opcodes[j] == wide_op */
109 } /* mod_type == 0 ... */
110 } /* ins->code.offset > 0 */
112 ins
->code
.data
[ins
->code
.size
++] = loval
;
113 ins
->code
.data
[ins
->code
.size
++] = hival
;
116 snd_printdd("dsp_spos: %d instructions reallocated\n",nreallocated
);
120 static struct dsp_segment_desc
* get_segment_desc (struct dsp_module_desc
* module
, int seg_type
)
123 for (i
= 0;i
< module
->nsegments
; ++i
) {
124 if (module
->segments
[i
].segment_type
== seg_type
) {
125 return (module
->segments
+ i
);
132 static int find_free_symbol_index (struct dsp_spos_instance
* ins
)
134 int index
= ins
->symbol_table
.nsymbols
,i
;
136 for (i
= ins
->symbol_table
.highest_frag_index
; i
< ins
->symbol_table
.nsymbols
; ++i
) {
137 if (ins
->symbol_table
.symbols
[i
].deleted
) {
146 static int add_symbols (struct snd_cs46xx
* chip
, struct dsp_module_desc
* module
)
149 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
151 if (module
->symbol_table
.nsymbols
> 0) {
152 if (!strcmp(module
->symbol_table
.symbols
[0].symbol_name
, "OVERLAYBEGINADDRESS") &&
153 module
->symbol_table
.symbols
[0].symbol_type
== SYMBOL_CONSTANT
) {
154 module
->overlay_begin_address
= module
->symbol_table
.symbols
[0].address
;
158 for (i
= 0;i
< module
->symbol_table
.nsymbols
; ++i
) {
159 if (ins
->symbol_table
.nsymbols
== (DSP_MAX_SYMBOLS
- 1)) {
160 snd_printk(KERN_ERR
"dsp_spos: symbol table is full\n");
165 if (cs46xx_dsp_lookup_symbol(chip
,
166 module
->symbol_table
.symbols
[i
].symbol_name
,
167 module
->symbol_table
.symbols
[i
].symbol_type
) == NULL
) {
169 ins
->symbol_table
.symbols
[ins
->symbol_table
.nsymbols
] = module
->symbol_table
.symbols
[i
];
170 ins
->symbol_table
.symbols
[ins
->symbol_table
.nsymbols
].address
+= ((ins
->code
.offset
/ 2) - module
->overlay_begin_address
);
171 ins
->symbol_table
.symbols
[ins
->symbol_table
.nsymbols
].module
= module
;
172 ins
->symbol_table
.symbols
[ins
->symbol_table
.nsymbols
].deleted
= 0;
174 if (ins
->symbol_table
.nsymbols
> ins
->symbol_table
.highest_frag_index
)
175 ins
->symbol_table
.highest_frag_index
= ins
->symbol_table
.nsymbols
;
177 ins
->symbol_table
.nsymbols
++;
179 /* if (0) printk ("dsp_spos: symbol <%s> duplicated, probably nothing wrong with that (Cirrus?)\n",
180 module->symbol_table.symbols[i].symbol_name); */
187 static struct dsp_symbol_entry
*
188 add_symbol (struct snd_cs46xx
* chip
, char * symbol_name
, u32 address
, int type
)
190 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
191 struct dsp_symbol_entry
* symbol
= NULL
;
194 if (ins
->symbol_table
.nsymbols
== (DSP_MAX_SYMBOLS
- 1)) {
195 snd_printk(KERN_ERR
"dsp_spos: symbol table is full\n");
199 if (cs46xx_dsp_lookup_symbol(chip
,
202 snd_printk(KERN_ERR
"dsp_spos: symbol <%s> duplicated\n", symbol_name
);
206 index
= find_free_symbol_index (ins
);
208 strcpy (ins
->symbol_table
.symbols
[index
].symbol_name
, symbol_name
);
209 ins
->symbol_table
.symbols
[index
].address
= address
;
210 ins
->symbol_table
.symbols
[index
].symbol_type
= type
;
211 ins
->symbol_table
.symbols
[index
].module
= NULL
;
212 ins
->symbol_table
.symbols
[index
].deleted
= 0;
213 symbol
= (ins
->symbol_table
.symbols
+ index
);
215 if (index
> ins
->symbol_table
.highest_frag_index
)
216 ins
->symbol_table
.highest_frag_index
= index
;
218 if (index
== ins
->symbol_table
.nsymbols
)
219 ins
->symbol_table
.nsymbols
++; /* no frag. in list */
224 struct dsp_spos_instance
*cs46xx_dsp_spos_create (struct snd_cs46xx
* chip
)
226 struct dsp_spos_instance
* ins
= kzalloc(sizeof(struct dsp_spos_instance
), GFP_KERNEL
);
231 /* better to use vmalloc for this big table */
232 ins
->symbol_table
.symbols
= vmalloc(sizeof(struct dsp_symbol_entry
) *
234 ins
->code
.data
= kmalloc(DSP_CODE_BYTE_SIZE
, GFP_KERNEL
);
235 ins
->modules
= kmalloc(sizeof(struct dsp_module_desc
) * DSP_MAX_MODULES
, GFP_KERNEL
);
236 if (!ins
->symbol_table
.symbols
|| !ins
->code
.data
|| !ins
->modules
) {
237 cs46xx_dsp_spos_destroy(chip
);
240 ins
->symbol_table
.nsymbols
= 0;
241 ins
->symbol_table
.highest_frag_index
= 0;
242 ins
->code
.offset
= 0;
248 /* default SPDIF input sample rate
250 ins
->spdif_in_sample_rate
= 48000;
252 /* maximize volume */
253 ins
->dac_volume_right
= 0x8000;
254 ins
->dac_volume_left
= 0x8000;
255 ins
->spdif_input_volume_right
= 0x8000;
256 ins
->spdif_input_volume_left
= 0x8000;
258 /* set left and right validity bits and
259 default channel status */
260 ins
->spdif_csuv_default
=
261 ins
->spdif_csuv_stream
=
262 /* byte 0 */ ((unsigned int)_wrap_all_bits( (SNDRV_PCM_DEFAULT_CON_SPDIF
& 0xff)) << 24) |
263 /* byte 1 */ ((unsigned int)_wrap_all_bits( ((SNDRV_PCM_DEFAULT_CON_SPDIF
>> 8) & 0xff)) << 16) |
264 /* byte 3 */ (unsigned int)_wrap_all_bits( (SNDRV_PCM_DEFAULT_CON_SPDIF
>> 24) & 0xff) |
265 /* left and right validity bits */ (1 << 13) | (1 << 12);
271 kfree(ins
->code
.data
);
272 vfree(ins
->symbol_table
.symbols
);
277 void cs46xx_dsp_spos_destroy (struct snd_cs46xx
* chip
)
280 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
282 if (snd_BUG_ON(!ins
))
285 mutex_lock(&chip
->spos_mutex
);
286 for (i
= 0; i
< ins
->nscb
; ++i
) {
287 if (ins
->scbs
[i
].deleted
) continue;
289 cs46xx_dsp_proc_free_scb_desc ( (ins
->scbs
+ i
) );
291 kfree(ins
->scbs
[i
].data
);
295 kfree(ins
->code
.data
);
296 vfree(ins
->symbol_table
.symbols
);
299 mutex_unlock(&chip
->spos_mutex
);
302 static int dsp_load_parameter(struct snd_cs46xx
*chip
,
303 struct dsp_segment_desc
*parameter
)
308 snd_printdd("dsp_spos: module got no parameter segment\n");
312 doffset
= (parameter
->offset
* 4 + DSP_PARAMETER_BYTE_OFFSET
);
313 dsize
= parameter
->size
* 4;
315 snd_printdd("dsp_spos: "
316 "downloading parameter data to chip (%08x-%08x)\n",
317 doffset
,doffset
+ dsize
);
318 if (snd_cs46xx_download (chip
, parameter
->data
, doffset
, dsize
)) {
319 snd_printk(KERN_ERR
"dsp_spos: "
320 "failed to download parameter data to DSP\n");
326 static int dsp_load_sample(struct snd_cs46xx
*chip
,
327 struct dsp_segment_desc
*sample
)
332 snd_printdd("dsp_spos: module got no sample segment\n");
336 doffset
= (sample
->offset
* 4 + DSP_SAMPLE_BYTE_OFFSET
);
337 dsize
= sample
->size
* 4;
339 snd_printdd("dsp_spos: downloading sample data to chip (%08x-%08x)\n",
340 doffset
,doffset
+ dsize
);
342 if (snd_cs46xx_download (chip
,sample
->data
,doffset
,dsize
)) {
343 snd_printk(KERN_ERR
"dsp_spos: failed to sample data to DSP\n");
349 int cs46xx_dsp_load_module (struct snd_cs46xx
* chip
, struct dsp_module_desc
* module
)
351 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
352 struct dsp_segment_desc
* code
= get_segment_desc (module
,SEGTYPE_SP_PROGRAM
);
356 if (ins
->nmodules
== DSP_MAX_MODULES
- 1) {
357 snd_printk(KERN_ERR
"dsp_spos: to many modules loaded into DSP\n");
361 snd_printdd("dsp_spos: loading module %s into DSP\n", module
->module_name
);
363 if (ins
->nmodules
== 0) {
364 snd_printdd("dsp_spos: clearing parameter area\n");
365 snd_cs46xx_clear_BA1(chip
, DSP_PARAMETER_BYTE_OFFSET
, DSP_PARAMETER_BYTE_SIZE
);
368 err
= dsp_load_parameter(chip
, get_segment_desc(module
,
369 SEGTYPE_SP_PARAMETER
));
373 if (ins
->nmodules
== 0) {
374 snd_printdd("dsp_spos: clearing sample area\n");
375 snd_cs46xx_clear_BA1(chip
, DSP_SAMPLE_BYTE_OFFSET
, DSP_SAMPLE_BYTE_SIZE
);
378 err
= dsp_load_sample(chip
, get_segment_desc(module
,
383 if (ins
->nmodules
== 0) {
384 snd_printdd("dsp_spos: clearing code area\n");
385 snd_cs46xx_clear_BA1(chip
, DSP_CODE_BYTE_OFFSET
, DSP_CODE_BYTE_SIZE
);
389 snd_printdd("dsp_spos: module got no code segment\n");
391 if (ins
->code
.offset
+ code
->size
> DSP_CODE_BYTE_SIZE
) {
392 snd_printk(KERN_ERR
"dsp_spos: no space available in DSP\n");
396 module
->load_address
= ins
->code
.offset
;
397 module
->overlay_begin_address
= 0x000;
399 /* if module has a code segment it must have
401 if (snd_BUG_ON(!module
->symbol_table
.symbols
))
403 if (add_symbols(chip
,module
)) {
404 snd_printk(KERN_ERR
"dsp_spos: failed to load symbol table\n");
408 doffset
= (code
->offset
* 4 + ins
->code
.offset
* 4 + DSP_CODE_BYTE_OFFSET
);
409 dsize
= code
->size
* 4;
410 snd_printdd("dsp_spos: downloading code to chip (%08x-%08x)\n",
411 doffset
,doffset
+ dsize
);
413 module
->nfixups
= shadow_and_reallocate_code(chip
,code
->data
,code
->size
,module
->overlay_begin_address
);
415 if (snd_cs46xx_download (chip
,(ins
->code
.data
+ ins
->code
.offset
),doffset
,dsize
)) {
416 snd_printk(KERN_ERR
"dsp_spos: failed to download code to DSP\n");
420 ins
->code
.offset
+= code
->size
;
423 /* NOTE: module segments and symbol table must be
424 statically allocated. Case that module data is
425 not generated by the ospparser */
426 ins
->modules
[ins
->nmodules
] = *module
;
432 struct dsp_symbol_entry
*
433 cs46xx_dsp_lookup_symbol (struct snd_cs46xx
* chip
, char * symbol_name
, int symbol_type
)
436 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
438 for ( i
= 0; i
< ins
->symbol_table
.nsymbols
; ++i
) {
440 if (ins
->symbol_table
.symbols
[i
].deleted
)
443 if (!strcmp(ins
->symbol_table
.symbols
[i
].symbol_name
,symbol_name
) &&
444 ins
->symbol_table
.symbols
[i
].symbol_type
== symbol_type
) {
445 return (ins
->symbol_table
.symbols
+ i
);
450 printk ("dsp_spos: symbol <%s> type %02x not found\n",
451 symbol_name
,symbol_type
);
458 #ifdef CONFIG_PROC_FS
459 static struct dsp_symbol_entry
*
460 cs46xx_dsp_lookup_symbol_addr (struct snd_cs46xx
* chip
, u32 address
, int symbol_type
)
463 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
465 for ( i
= 0; i
< ins
->symbol_table
.nsymbols
; ++i
) {
467 if (ins
->symbol_table
.symbols
[i
].deleted
)
470 if (ins
->symbol_table
.symbols
[i
].address
== address
&&
471 ins
->symbol_table
.symbols
[i
].symbol_type
== symbol_type
) {
472 return (ins
->symbol_table
.symbols
+ i
);
481 static void cs46xx_dsp_proc_symbol_table_read (struct snd_info_entry
*entry
,
482 struct snd_info_buffer
*buffer
)
484 struct snd_cs46xx
*chip
= entry
->private_data
;
485 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
488 snd_iprintf(buffer
, "SYMBOLS:\n");
489 for ( i
= 0; i
< ins
->symbol_table
.nsymbols
; ++i
) {
490 char *module_str
= "system";
492 if (ins
->symbol_table
.symbols
[i
].deleted
)
495 if (ins
->symbol_table
.symbols
[i
].module
!= NULL
) {
496 module_str
= ins
->symbol_table
.symbols
[i
].module
->module_name
;
500 snd_iprintf(buffer
, "%04X <%02X> %s [%s]\n",
501 ins
->symbol_table
.symbols
[i
].address
,
502 ins
->symbol_table
.symbols
[i
].symbol_type
,
503 ins
->symbol_table
.symbols
[i
].symbol_name
,
509 static void cs46xx_dsp_proc_modules_read (struct snd_info_entry
*entry
,
510 struct snd_info_buffer
*buffer
)
512 struct snd_cs46xx
*chip
= entry
->private_data
;
513 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
516 mutex_lock(&chip
->spos_mutex
);
517 snd_iprintf(buffer
, "MODULES:\n");
518 for ( i
= 0; i
< ins
->nmodules
; ++i
) {
519 snd_iprintf(buffer
, "\n%s:\n", ins
->modules
[i
].module_name
);
520 snd_iprintf(buffer
, " %d symbols\n", ins
->modules
[i
].symbol_table
.nsymbols
);
521 snd_iprintf(buffer
, " %d fixups\n", ins
->modules
[i
].nfixups
);
523 for (j
= 0; j
< ins
->modules
[i
].nsegments
; ++ j
) {
524 struct dsp_segment_desc
* desc
= (ins
->modules
[i
].segments
+ j
);
525 snd_iprintf(buffer
, " segment %02x offset %08x size %08x\n",
526 desc
->segment_type
,desc
->offset
, desc
->size
);
529 mutex_unlock(&chip
->spos_mutex
);
532 static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry
*entry
,
533 struct snd_info_buffer
*buffer
)
535 struct snd_cs46xx
*chip
= entry
->private_data
;
536 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
538 void __iomem
*dst
= chip
->region
.idx
[1].remap_addr
+ DSP_PARAMETER_BYTE_OFFSET
;
540 mutex_lock(&chip
->spos_mutex
);
541 snd_iprintf(buffer
, "TASK TREES:\n");
542 for ( i
= 0; i
< ins
->ntask
; ++i
) {
543 snd_iprintf(buffer
,"\n%04x %s:\n",ins
->tasks
[i
].address
,ins
->tasks
[i
].task_name
);
545 for (col
= 0,j
= 0;j
< ins
->tasks
[i
].size
; j
++,col
++) {
548 snd_iprintf(buffer
,"\n");
551 val
= readl(dst
+ (ins
->tasks
[i
].address
+ j
) * sizeof(u32
));
552 snd_iprintf(buffer
,"%08x ",val
);
556 snd_iprintf(buffer
,"\n");
557 mutex_unlock(&chip
->spos_mutex
);
560 static void cs46xx_dsp_proc_scb_read (struct snd_info_entry
*entry
,
561 struct snd_info_buffer
*buffer
)
563 struct snd_cs46xx
*chip
= entry
->private_data
;
564 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
567 mutex_lock(&chip
->spos_mutex
);
568 snd_iprintf(buffer
, "SCB's:\n");
569 for ( i
= 0; i
< ins
->nscb
; ++i
) {
570 if (ins
->scbs
[i
].deleted
)
572 snd_iprintf(buffer
,"\n%04x %s:\n\n",ins
->scbs
[i
].address
,ins
->scbs
[i
].scb_name
);
574 if (ins
->scbs
[i
].parent_scb_ptr
!= NULL
) {
575 snd_iprintf(buffer
,"parent [%s:%04x] ",
576 ins
->scbs
[i
].parent_scb_ptr
->scb_name
,
577 ins
->scbs
[i
].parent_scb_ptr
->address
);
578 } else snd_iprintf(buffer
,"parent [none] ");
580 snd_iprintf(buffer
,"sub_list_ptr [%s:%04x]\nnext_scb_ptr [%s:%04x] task_entry [%s:%04x]\n",
581 ins
->scbs
[i
].sub_list_ptr
->scb_name
,
582 ins
->scbs
[i
].sub_list_ptr
->address
,
583 ins
->scbs
[i
].next_scb_ptr
->scb_name
,
584 ins
->scbs
[i
].next_scb_ptr
->address
,
585 ins
->scbs
[i
].task_entry
->symbol_name
,
586 ins
->scbs
[i
].task_entry
->address
);
589 snd_iprintf(buffer
,"\n");
590 mutex_unlock(&chip
->spos_mutex
);
593 static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry
*entry
,
594 struct snd_info_buffer
*buffer
)
596 struct snd_cs46xx
*chip
= entry
->private_data
;
597 /*struct dsp_spos_instance * ins = chip->dsp_spos_instance; */
598 unsigned int i
, col
= 0;
599 void __iomem
*dst
= chip
->region
.idx
[1].remap_addr
+ DSP_PARAMETER_BYTE_OFFSET
;
600 struct dsp_symbol_entry
* symbol
;
602 for (i
= 0;i
< DSP_PARAMETER_BYTE_SIZE
; i
+= sizeof(u32
),col
++) {
604 snd_iprintf(buffer
,"\n");
608 if ( (symbol
= cs46xx_dsp_lookup_symbol_addr (chip
,i
/ sizeof(u32
), SYMBOL_PARAMETER
)) != NULL
) {
610 snd_iprintf (buffer
,"\n%s:\n",symbol
->symbol_name
);
614 snd_iprintf(buffer
, "%04X ", i
/ (unsigned int)sizeof(u32
));
617 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
621 static void cs46xx_dsp_proc_sample_dump_read (struct snd_info_entry
*entry
,
622 struct snd_info_buffer
*buffer
)
624 struct snd_cs46xx
*chip
= entry
->private_data
;
626 void __iomem
*dst
= chip
->region
.idx
[2].remap_addr
;
628 snd_iprintf(buffer
,"PCMREADER:\n");
629 for (i
= PCM_READER_BUF1
;i
< PCM_READER_BUF1
+ 0x30; i
+= sizeof(u32
),col
++) {
631 snd_iprintf(buffer
,"\n");
636 snd_iprintf(buffer
, "%04X ",i
);
639 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
642 snd_iprintf(buffer
,"\nMIX_SAMPLE_BUF1:\n");
645 for (i
= MIX_SAMPLE_BUF1
;i
< MIX_SAMPLE_BUF1
+ 0x40; i
+= sizeof(u32
),col
++) {
647 snd_iprintf(buffer
,"\n");
652 snd_iprintf(buffer
, "%04X ",i
);
655 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
658 snd_iprintf(buffer
,"\nSRC_TASK_SCB1:\n");
660 for (i
= 0x2480 ; i
< 0x2480 + 0x40 ; i
+= sizeof(u32
),col
++) {
662 snd_iprintf(buffer
,"\n");
667 snd_iprintf(buffer
, "%04X ",i
);
670 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
674 snd_iprintf(buffer
,"\nSPDIFO_BUFFER:\n");
676 for (i
= SPDIFO_IP_OUTPUT_BUFFER1
;i
< SPDIFO_IP_OUTPUT_BUFFER1
+ 0x30; i
+= sizeof(u32
),col
++) {
678 snd_iprintf(buffer
,"\n");
683 snd_iprintf(buffer
, "%04X ",i
);
686 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
689 snd_iprintf(buffer
,"\n...\n");
692 for (i
= SPDIFO_IP_OUTPUT_BUFFER1
+0xD0;i
< SPDIFO_IP_OUTPUT_BUFFER1
+ 0x110; i
+= sizeof(u32
),col
++) {
694 snd_iprintf(buffer
,"\n");
699 snd_iprintf(buffer
, "%04X ",i
);
702 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
706 snd_iprintf(buffer
,"\nOUTPUT_SNOOP:\n");
708 for (i
= OUTPUT_SNOOP_BUFFER
;i
< OUTPUT_SNOOP_BUFFER
+ 0x40; i
+= sizeof(u32
),col
++) {
710 snd_iprintf(buffer
,"\n");
715 snd_iprintf(buffer
, "%04X ",i
);
718 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
721 snd_iprintf(buffer
,"\nCODEC_INPUT_BUF1: \n");
723 for (i
= CODEC_INPUT_BUF1
;i
< CODEC_INPUT_BUF1
+ 0x40; i
+= sizeof(u32
),col
++) {
725 snd_iprintf(buffer
,"\n");
730 snd_iprintf(buffer
, "%04X ",i
);
733 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
736 snd_iprintf(buffer
,"\nWRITE_BACK_BUF1: \n");
738 for (i
= WRITE_BACK_BUF1
;i
< WRITE_BACK_BUF1
+ 0x40; i
+= sizeof(u32
),col
++) {
740 snd_iprintf(buffer
,"\n");
745 snd_iprintf(buffer
, "%04X ",i
);
748 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
752 snd_iprintf(buffer
,"\nSPDIFI_IP_OUTPUT_BUFFER1: \n");
754 for (i
= SPDIFI_IP_OUTPUT_BUFFER1
;i
< SPDIFI_IP_OUTPUT_BUFFER1
+ 0x80; i
+= sizeof(u32
),col
++) {
756 snd_iprintf(buffer
,"\n");
761 snd_iprintf(buffer
, "%04X ",i
);
764 snd_iprintf(buffer
,"%08X ",readl(dst
+ i
));
766 snd_iprintf(buffer
,"\n");
769 int cs46xx_dsp_proc_init (struct snd_card
*card
, struct snd_cs46xx
*chip
)
771 struct snd_info_entry
*entry
;
772 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
775 ins
->snd_card
= card
;
777 if ((entry
= snd_info_create_card_entry(card
, "dsp", card
->proc_root
)) != NULL
) {
778 entry
->content
= SNDRV_INFO_CONTENT_TEXT
;
779 entry
->mode
= S_IFDIR
| S_IRUGO
| S_IXUGO
;
781 if (snd_info_register(entry
) < 0) {
782 snd_info_free_entry(entry
);
787 ins
->proc_dsp_dir
= entry
;
789 if (!ins
->proc_dsp_dir
)
792 if ((entry
= snd_info_create_card_entry(card
, "spos_symbols", ins
->proc_dsp_dir
)) != NULL
) {
793 entry
->content
= SNDRV_INFO_CONTENT_TEXT
;
794 entry
->private_data
= chip
;
795 entry
->mode
= S_IFREG
| S_IRUGO
| S_IWUSR
;
796 entry
->c
.text
.read
= cs46xx_dsp_proc_symbol_table_read
;
797 if (snd_info_register(entry
) < 0) {
798 snd_info_free_entry(entry
);
802 ins
->proc_sym_info_entry
= entry
;
804 if ((entry
= snd_info_create_card_entry(card
, "spos_modules", ins
->proc_dsp_dir
)) != NULL
) {
805 entry
->content
= SNDRV_INFO_CONTENT_TEXT
;
806 entry
->private_data
= chip
;
807 entry
->mode
= S_IFREG
| S_IRUGO
| S_IWUSR
;
808 entry
->c
.text
.read
= cs46xx_dsp_proc_modules_read
;
809 if (snd_info_register(entry
) < 0) {
810 snd_info_free_entry(entry
);
814 ins
->proc_modules_info_entry
= entry
;
816 if ((entry
= snd_info_create_card_entry(card
, "parameter", ins
->proc_dsp_dir
)) != NULL
) {
817 entry
->content
= SNDRV_INFO_CONTENT_TEXT
;
818 entry
->private_data
= chip
;
819 entry
->mode
= S_IFREG
| S_IRUGO
| S_IWUSR
;
820 entry
->c
.text
.read
= cs46xx_dsp_proc_parameter_dump_read
;
821 if (snd_info_register(entry
) < 0) {
822 snd_info_free_entry(entry
);
826 ins
->proc_parameter_dump_info_entry
= entry
;
828 if ((entry
= snd_info_create_card_entry(card
, "sample", ins
->proc_dsp_dir
)) != NULL
) {
829 entry
->content
= SNDRV_INFO_CONTENT_TEXT
;
830 entry
->private_data
= chip
;
831 entry
->mode
= S_IFREG
| S_IRUGO
| S_IWUSR
;
832 entry
->c
.text
.read
= cs46xx_dsp_proc_sample_dump_read
;
833 if (snd_info_register(entry
) < 0) {
834 snd_info_free_entry(entry
);
838 ins
->proc_sample_dump_info_entry
= entry
;
840 if ((entry
= snd_info_create_card_entry(card
, "task_tree", ins
->proc_dsp_dir
)) != NULL
) {
841 entry
->content
= SNDRV_INFO_CONTENT_TEXT
;
842 entry
->private_data
= chip
;
843 entry
->mode
= S_IFREG
| S_IRUGO
| S_IWUSR
;
844 entry
->c
.text
.read
= cs46xx_dsp_proc_task_tree_read
;
845 if (snd_info_register(entry
) < 0) {
846 snd_info_free_entry(entry
);
850 ins
->proc_task_info_entry
= entry
;
852 if ((entry
= snd_info_create_card_entry(card
, "scb_info", ins
->proc_dsp_dir
)) != NULL
) {
853 entry
->content
= SNDRV_INFO_CONTENT_TEXT
;
854 entry
->private_data
= chip
;
855 entry
->mode
= S_IFREG
| S_IRUGO
| S_IWUSR
;
856 entry
->c
.text
.read
= cs46xx_dsp_proc_scb_read
;
857 if (snd_info_register(entry
) < 0) {
858 snd_info_free_entry(entry
);
862 ins
->proc_scb_info_entry
= entry
;
864 mutex_lock(&chip
->spos_mutex
);
865 /* register/update SCB's entries on proc */
866 for (i
= 0; i
< ins
->nscb
; ++i
) {
867 if (ins
->scbs
[i
].deleted
) continue;
869 cs46xx_dsp_proc_register_scb_desc (chip
, (ins
->scbs
+ i
));
871 mutex_unlock(&chip
->spos_mutex
);
876 int cs46xx_dsp_proc_done (struct snd_cs46xx
*chip
)
878 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
881 snd_info_free_entry(ins
->proc_sym_info_entry
);
882 ins
->proc_sym_info_entry
= NULL
;
884 snd_info_free_entry(ins
->proc_modules_info_entry
);
885 ins
->proc_modules_info_entry
= NULL
;
887 snd_info_free_entry(ins
->proc_parameter_dump_info_entry
);
888 ins
->proc_parameter_dump_info_entry
= NULL
;
890 snd_info_free_entry(ins
->proc_sample_dump_info_entry
);
891 ins
->proc_sample_dump_info_entry
= NULL
;
893 snd_info_free_entry(ins
->proc_scb_info_entry
);
894 ins
->proc_scb_info_entry
= NULL
;
896 snd_info_free_entry(ins
->proc_task_info_entry
);
897 ins
->proc_task_info_entry
= NULL
;
899 mutex_lock(&chip
->spos_mutex
);
900 for (i
= 0; i
< ins
->nscb
; ++i
) {
901 if (ins
->scbs
[i
].deleted
) continue;
902 cs46xx_dsp_proc_free_scb_desc ( (ins
->scbs
+ i
) );
904 mutex_unlock(&chip
->spos_mutex
);
906 snd_info_free_entry(ins
->proc_dsp_dir
);
907 ins
->proc_dsp_dir
= NULL
;
911 #endif /* CONFIG_PROC_FS */
913 static int debug_tree
;
914 static void _dsp_create_task_tree (struct snd_cs46xx
*chip
, u32
* task_data
,
917 void __iomem
*spdst
= chip
->region
.idx
[1].remap_addr
+
918 DSP_PARAMETER_BYTE_OFFSET
+ dest
* sizeof(u32
);
921 for (i
= 0; i
< size
; ++i
) {
922 if (debug_tree
) printk ("addr %p, val %08x\n",spdst
,task_data
[i
]);
923 writel(task_data
[i
],spdst
);
924 spdst
+= sizeof(u32
);
928 static int debug_scb
;
929 static void _dsp_create_scb (struct snd_cs46xx
*chip
, u32
* scb_data
, u32 dest
)
931 void __iomem
*spdst
= chip
->region
.idx
[1].remap_addr
+
932 DSP_PARAMETER_BYTE_OFFSET
+ dest
* sizeof(u32
);
935 for (i
= 0; i
< 0x10; ++i
) {
936 if (debug_scb
) printk ("addr %p, val %08x\n",spdst
,scb_data
[i
]);
937 writel(scb_data
[i
],spdst
);
938 spdst
+= sizeof(u32
);
942 static int find_free_scb_index (struct dsp_spos_instance
* ins
)
944 int index
= ins
->nscb
, i
;
946 for (i
= ins
->scb_highest_frag_index
; i
< ins
->nscb
; ++i
) {
947 if (ins
->scbs
[i
].deleted
) {
956 static struct dsp_scb_descriptor
* _map_scb (struct snd_cs46xx
*chip
, char * name
, u32 dest
)
958 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
959 struct dsp_scb_descriptor
* desc
= NULL
;
962 if (ins
->nscb
== DSP_MAX_SCB_DESC
- 1) {
963 snd_printk(KERN_ERR
"dsp_spos: got no place for other SCB\n");
967 index
= find_free_scb_index (ins
);
969 memset(&ins
->scbs
[index
], 0, sizeof(ins
->scbs
[index
]));
970 strcpy(ins
->scbs
[index
].scb_name
, name
);
971 ins
->scbs
[index
].address
= dest
;
972 ins
->scbs
[index
].index
= index
;
973 ins
->scbs
[index
].ref_count
= 1;
975 desc
= (ins
->scbs
+ index
);
976 ins
->scbs
[index
].scb_symbol
= add_symbol (chip
, name
, dest
, SYMBOL_PARAMETER
);
978 if (index
> ins
->scb_highest_frag_index
)
979 ins
->scb_highest_frag_index
= index
;
981 if (index
== ins
->nscb
)
987 static struct dsp_task_descriptor
*
988 _map_task_tree (struct snd_cs46xx
*chip
, char * name
, u32 dest
, u32 size
)
990 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
991 struct dsp_task_descriptor
* desc
= NULL
;
993 if (ins
->ntask
== DSP_MAX_TASK_DESC
- 1) {
994 snd_printk(KERN_ERR
"dsp_spos: got no place for other TASK\n");
999 strcpy(ins
->tasks
[ins
->ntask
].task_name
, name
);
1001 strcpy(ins
->tasks
[ins
->ntask
].task_name
, "(NULL)");
1002 ins
->tasks
[ins
->ntask
].address
= dest
;
1003 ins
->tasks
[ins
->ntask
].size
= size
;
1005 /* quick find in list */
1006 ins
->tasks
[ins
->ntask
].index
= ins
->ntask
;
1007 desc
= (ins
->tasks
+ ins
->ntask
);
1011 add_symbol (chip
,name
,dest
,SYMBOL_PARAMETER
);
1015 #define SCB_BYTES (0x10 * 4)
1017 struct dsp_scb_descriptor
*
1018 cs46xx_dsp_create_scb (struct snd_cs46xx
*chip
, char * name
, u32
* scb_data
, u32 dest
)
1020 struct dsp_scb_descriptor
* desc
;
1023 /* copy the data for resume */
1024 scb_data
= kmemdup(scb_data
, SCB_BYTES
, GFP_KERNEL
);
1029 desc
= _map_scb (chip
,name
,dest
);
1031 desc
->data
= scb_data
;
1032 _dsp_create_scb(chip
,scb_data
,dest
);
1034 snd_printk(KERN_ERR
"dsp_spos: failed to map SCB\n");
1044 static struct dsp_task_descriptor
*
1045 cs46xx_dsp_create_task_tree (struct snd_cs46xx
*chip
, char * name
, u32
* task_data
,
1048 struct dsp_task_descriptor
* desc
;
1050 desc
= _map_task_tree (chip
,name
,dest
,size
);
1052 desc
->data
= task_data
;
1053 _dsp_create_task_tree(chip
,task_data
,dest
,size
);
1055 snd_printk(KERN_ERR
"dsp_spos: failed to map TASK\n");
1061 int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx
*chip
)
1063 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1064 struct dsp_symbol_entry
* fg_task_tree_header_code
;
1065 struct dsp_symbol_entry
* task_tree_header_code
;
1066 struct dsp_symbol_entry
* task_tree_thread
;
1067 struct dsp_symbol_entry
* null_algorithm
;
1068 struct dsp_symbol_entry
* magic_snoop_task
;
1070 struct dsp_scb_descriptor
* timing_master_scb
;
1071 struct dsp_scb_descriptor
* codec_out_scb
;
1072 struct dsp_scb_descriptor
* codec_in_scb
;
1073 struct dsp_scb_descriptor
* src_task_scb
;
1074 struct dsp_scb_descriptor
* master_mix_scb
;
1075 struct dsp_scb_descriptor
* rear_mix_scb
;
1076 struct dsp_scb_descriptor
* record_mix_scb
;
1077 struct dsp_scb_descriptor
* write_back_scb
;
1078 struct dsp_scb_descriptor
* vari_decimate_scb
;
1079 struct dsp_scb_descriptor
* rear_codec_out_scb
;
1080 struct dsp_scb_descriptor
* clfe_codec_out_scb
;
1081 struct dsp_scb_descriptor
* magic_snoop_scb
;
1083 int fifo_addr
, fifo_span
, valid_slots
;
1085 static struct dsp_spos_control_block sposcb
= {
1086 /* 0 */ HFG_TREE_SCB
,HFG_STACK
,
1087 /* 1 */ SPOSCB_ADDR
,BG_TREE_SCB_ADDR
,
1088 /* 2 */ DSP_SPOS_DC
,0,
1089 /* 3 */ DSP_SPOS_DC
,DSP_SPOS_DC
,
1091 /* 5 */ DSP_SPOS_UU
,0,
1092 /* 6 */ FG_TASK_HEADER_ADDR
,0,
1094 /* 8 */ DSP_SPOS_UU
,DSP_SPOS_DC
,
1096 /* A */ 0,HFG_FIRST_EXECUTE_MODE
,
1097 /* B */ DSP_SPOS_UU
,DSP_SPOS_UU
,
1098 /* C */ DSP_SPOS_DC_DC
,
1099 /* D */ DSP_SPOS_DC_DC
,
1100 /* E */ DSP_SPOS_DC_DC
,
1101 /* F */ DSP_SPOS_DC_DC
1104 cs46xx_dsp_create_task_tree(chip
, "sposCB", (u32
*)&sposcb
, SPOSCB_ADDR
, 0x10);
1106 null_algorithm
= cs46xx_dsp_lookup_symbol(chip
, "NULLALGORITHM", SYMBOL_CODE
);
1107 if (null_algorithm
== NULL
) {
1108 snd_printk(KERN_ERR
"dsp_spos: symbol NULLALGORITHM not found\n");
1112 fg_task_tree_header_code
= cs46xx_dsp_lookup_symbol(chip
, "FGTASKTREEHEADERCODE", SYMBOL_CODE
);
1113 if (fg_task_tree_header_code
== NULL
) {
1114 snd_printk(KERN_ERR
"dsp_spos: symbol FGTASKTREEHEADERCODE not found\n");
1118 task_tree_header_code
= cs46xx_dsp_lookup_symbol(chip
, "TASKTREEHEADERCODE", SYMBOL_CODE
);
1119 if (task_tree_header_code
== NULL
) {
1120 snd_printk(KERN_ERR
"dsp_spos: symbol TASKTREEHEADERCODE not found\n");
1124 task_tree_thread
= cs46xx_dsp_lookup_symbol(chip
, "TASKTREETHREAD", SYMBOL_CODE
);
1125 if (task_tree_thread
== NULL
) {
1126 snd_printk(KERN_ERR
"dsp_spos: symbol TASKTREETHREAD not found\n");
1130 magic_snoop_task
= cs46xx_dsp_lookup_symbol(chip
, "MAGICSNOOPTASK", SYMBOL_CODE
);
1131 if (magic_snoop_task
== NULL
) {
1132 snd_printk(KERN_ERR
"dsp_spos: symbol MAGICSNOOPTASK not found\n");
1137 /* create the null SCB */
1138 static struct dsp_generic_scb null_scb
= {
1141 NULL_SCB_ADDR
, NULL_SCB_ADDR
,
1149 null_scb
.entry_point
= null_algorithm
->address
;
1150 ins
->the_null_scb
= cs46xx_dsp_create_scb(chip
, "nullSCB", (u32
*)&null_scb
, NULL_SCB_ADDR
);
1151 ins
->the_null_scb
->task_entry
= null_algorithm
;
1152 ins
->the_null_scb
->sub_list_ptr
= ins
->the_null_scb
;
1153 ins
->the_null_scb
->next_scb_ptr
= ins
->the_null_scb
;
1154 ins
->the_null_scb
->parent_scb_ptr
= NULL
;
1155 cs46xx_dsp_proc_register_scb_desc (chip
,ins
->the_null_scb
);
1159 /* setup foreground task tree */
1160 static struct dsp_task_tree_control_block fg_task_tree_hdr
= {
1161 { FG_TASK_HEADER_ADDR
| (DSP_SPOS_DC
<< 0x10),
1165 DSP_SPOS_DC
, DSP_SPOS_DC
,
1169 DSP_SPOS_DC
,DSP_SPOS_DC
},
1172 BG_TREE_SCB_ADDR
,TIMINGMASTER_SCB_ADDR
,
1174 FG_TASK_HEADER_ADDR
+ TCBData
,
1180 2,SPOSCB_ADDR
+ HFGFlags
,
1182 FG_TASK_HEADER_ADDR
+ TCBContextBlk
,FG_STACK
1187 DSP_SPOS_DC
,DSP_SPOS_DC
,
1188 DSP_SPOS_DC
,DSP_SPOS_DC
,
1189 DSP_SPOS_DC
,DSP_SPOS_DC
,
1190 DSP_SPOS_DC
,DSP_SPOS_DC
,
1223 FG_INTERVAL_TIMER_PERIOD
,DSP_SPOS_UU
,
1228 fg_task_tree_hdr
.links
.entry_point
= fg_task_tree_header_code
->address
;
1229 fg_task_tree_hdr
.context_blk
.stack0
= task_tree_thread
->address
;
1230 cs46xx_dsp_create_task_tree(chip
,"FGtaskTreeHdr",(u32
*)&fg_task_tree_hdr
,FG_TASK_HEADER_ADDR
,0x35);
1235 /* setup foreground task tree */
1236 static struct dsp_task_tree_control_block bg_task_tree_hdr
= {
1240 DSP_SPOS_DC
, DSP_SPOS_DC
,
1241 DSP_SPOS_DC
, DSP_SPOS_DC
,
1245 DSP_SPOS_DC
,DSP_SPOS_DC
},
1248 NULL_SCB_ADDR
,NULL_SCB_ADDR
, /* Set up the background to do nothing */
1250 BG_TREE_SCB_ADDR
+ TCBData
,
1256 0,SPOSCB_ADDR
+ HFGFlags
,
1258 BG_TREE_SCB_ADDR
+ TCBContextBlk
,BG_STACK
1263 DSP_SPOS_DC
,DSP_SPOS_DC
,
1264 DSP_SPOS_DC
,DSP_SPOS_DC
,
1265 DSP_SPOS_DC
,DSP_SPOS_DC
,
1266 DSP_SPOS_DC
,DSP_SPOS_DC
,
1299 BG_INTERVAL_TIMER_PERIOD
,DSP_SPOS_UU
,
1304 bg_task_tree_hdr
.links
.entry_point
= task_tree_header_code
->address
;
1305 bg_task_tree_hdr
.context_blk
.stack0
= task_tree_thread
->address
;
1306 cs46xx_dsp_create_task_tree(chip
,"BGtaskTreeHdr",(u32
*)&bg_task_tree_hdr
,BG_TREE_SCB_ADDR
,0x35);
1309 /* create timing master SCB */
1310 timing_master_scb
= cs46xx_dsp_create_timing_master_scb(chip
);
1312 /* create the CODEC output task */
1313 codec_out_scb
= cs46xx_dsp_create_codec_out_scb(chip
,"CodecOutSCB_I",0x0010,0x0000,
1315 CODECOUT_SCB_ADDR
,timing_master_scb
,
1316 SCB_ON_PARENT_SUBLIST_SCB
);
1318 if (!codec_out_scb
) goto _fail_end
;
1319 /* create the master mix SCB */
1320 master_mix_scb
= cs46xx_dsp_create_mix_only_scb(chip
,"MasterMixSCB",
1321 MIX_SAMPLE_BUF1
,MASTERMIX_SCB_ADDR
,
1323 SCB_ON_PARENT_SUBLIST_SCB
);
1324 ins
->master_mix_scb
= master_mix_scb
;
1326 if (!master_mix_scb
) goto _fail_end
;
1328 /* create codec in */
1329 codec_in_scb
= cs46xx_dsp_create_codec_in_scb(chip
,"CodecInSCB",0x0010,0x00A0,
1331 CODECIN_SCB_ADDR
,codec_out_scb
,
1332 SCB_ON_PARENT_NEXT_SCB
);
1333 if (!codec_in_scb
) goto _fail_end
;
1334 ins
->codec_in_scb
= codec_in_scb
;
1336 /* create write back scb */
1337 write_back_scb
= cs46xx_dsp_create_mix_to_ostream_scb(chip
,"WriteBackSCB",
1338 WRITE_BACK_BUF1
,WRITE_BACK_SPB
,
1341 SCB_ON_PARENT_NEXT_SCB
);
1342 if (!write_back_scb
) goto _fail_end
;
1345 static struct dsp_mix2_ostream_spb mix2_ostream_spb
= {
1350 if (!cs46xx_dsp_create_task_tree(chip
, NULL
,
1351 (u32
*)&mix2_ostream_spb
,
1356 /* input sample converter */
1357 vari_decimate_scb
= cs46xx_dsp_create_vari_decimate_scb(chip
,"VariDecimateSCB",
1360 VARIDECIMATE_SCB_ADDR
,
1362 SCB_ON_PARENT_SUBLIST_SCB
);
1363 if (!vari_decimate_scb
) goto _fail_end
;
1365 /* create the record mixer SCB */
1366 record_mix_scb
= cs46xx_dsp_create_mix_only_scb(chip
,"RecordMixerSCB",
1368 RECORD_MIXER_SCB_ADDR
,
1370 SCB_ON_PARENT_SUBLIST_SCB
);
1371 ins
->record_mixer_scb
= record_mix_scb
;
1373 if (!record_mix_scb
) goto _fail_end
;
1375 valid_slots
= snd_cs46xx_peekBA0(chip
, BA0_ACOSV
);
1377 if (snd_BUG_ON(chip
->nr_ac97_codecs
!= 1 && chip
->nr_ac97_codecs
!= 2))
1380 if (chip
->nr_ac97_codecs
== 1) {
1381 /* output on slot 5 and 11
1386 /* enable slot 5 and 11 */
1387 valid_slots
|= ACOSV_SLV5
| ACOSV_SLV11
;
1389 /* output on slot 7 and 8
1390 on secondary CODEC */
1394 /* enable slot 7 and 8 */
1395 valid_slots
|= ACOSV_SLV7
| ACOSV_SLV8
;
1397 /* create CODEC tasklet for rear speakers output*/
1398 rear_codec_out_scb
= cs46xx_dsp_create_codec_out_scb(chip
,"CodecOutSCB_Rear",fifo_span
,fifo_addr
,
1399 REAR_MIXER_SCB_ADDR
,
1400 REAR_CODECOUT_SCB_ADDR
,codec_in_scb
,
1401 SCB_ON_PARENT_NEXT_SCB
);
1402 if (!rear_codec_out_scb
) goto _fail_end
;
1405 /* create the rear PCM channel mixer SCB */
1406 rear_mix_scb
= cs46xx_dsp_create_mix_only_scb(chip
,"RearMixerSCB",
1408 REAR_MIXER_SCB_ADDR
,
1410 SCB_ON_PARENT_SUBLIST_SCB
);
1411 ins
->rear_mix_scb
= rear_mix_scb
;
1412 if (!rear_mix_scb
) goto _fail_end
;
1414 if (chip
->nr_ac97_codecs
== 2) {
1415 /* create CODEC tasklet for rear Center/LFE output
1416 slot 6 and 9 on seconadry CODEC */
1417 clfe_codec_out_scb
= cs46xx_dsp_create_codec_out_scb(chip
,"CodecOutSCB_CLFE",0x0030,0x0030,
1418 CLFE_MIXER_SCB_ADDR
,
1419 CLFE_CODEC_SCB_ADDR
,
1421 SCB_ON_PARENT_NEXT_SCB
);
1422 if (!clfe_codec_out_scb
) goto _fail_end
;
1425 /* create the rear PCM channel mixer SCB */
1426 ins
->center_lfe_mix_scb
= cs46xx_dsp_create_mix_only_scb(chip
,"CLFEMixerSCB",
1428 CLFE_MIXER_SCB_ADDR
,
1430 SCB_ON_PARENT_SUBLIST_SCB
);
1431 if (!ins
->center_lfe_mix_scb
) goto _fail_end
;
1433 /* enable slot 6 and 9 */
1434 valid_slots
|= ACOSV_SLV6
| ACOSV_SLV9
;
1436 clfe_codec_out_scb
= rear_codec_out_scb
;
1437 ins
->center_lfe_mix_scb
= rear_mix_scb
;
1440 /* enable slots depending on CODEC configuration */
1441 snd_cs46xx_pokeBA0(chip
, BA0_ACOSV
, valid_slots
);
1443 /* the magic snooper */
1444 magic_snoop_scb
= cs46xx_dsp_create_magic_snoop_scb (chip
,"MagicSnoopSCB_I",OUTPUTSNOOP_SCB_ADDR
,
1445 OUTPUT_SNOOP_BUFFER
,
1448 SCB_ON_PARENT_NEXT_SCB
);
1451 if (!magic_snoop_scb
) goto _fail_end
;
1452 ins
->ref_snoop_scb
= magic_snoop_scb
;
1455 if (!cs46xx_dsp_create_spio_write_scb(chip
,"SPIOWriteSCB",SPIOWRITE_SCB_ADDR
,
1457 SCB_ON_PARENT_NEXT_SCB
))
1460 /* SPDIF input sampel rate converter */
1461 src_task_scb
= cs46xx_dsp_create_src_task_scb(chip
,"SrcTaskSCB_SPDIFI",
1462 ins
->spdif_in_sample_rate
,
1464 SRC_DELAY_BUF1
,SRCTASK_SCB_ADDR
,
1466 SCB_ON_PARENT_SUBLIST_SCB
,1);
1468 if (!src_task_scb
) goto _fail_end
;
1469 cs46xx_src_unlink(chip
,src_task_scb
);
1471 /* NOTE: when we now how to detect the SPDIF input
1472 sample rate we will use this SRC to adjust it */
1473 ins
->spdif_in_src
= src_task_scb
;
1475 cs46xx_dsp_async_init(chip
,timing_master_scb
);
1479 snd_printk(KERN_ERR
"dsp_spos: failed to setup SCB's in DSP\n");
1483 static int cs46xx_dsp_async_init (struct snd_cs46xx
*chip
,
1484 struct dsp_scb_descriptor
* fg_entry
)
1486 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1487 struct dsp_symbol_entry
* s16_async_codec_input_task
;
1488 struct dsp_symbol_entry
* spdifo_task
;
1489 struct dsp_symbol_entry
* spdifi_task
;
1490 struct dsp_scb_descriptor
* spdifi_scb_desc
, * spdifo_scb_desc
, * async_codec_scb_desc
;
1492 s16_async_codec_input_task
= cs46xx_dsp_lookup_symbol(chip
, "S16_ASYNCCODECINPUTTASK", SYMBOL_CODE
);
1493 if (s16_async_codec_input_task
== NULL
) {
1494 snd_printk(KERN_ERR
"dsp_spos: symbol S16_ASYNCCODECINPUTTASK not found\n");
1497 spdifo_task
= cs46xx_dsp_lookup_symbol(chip
, "SPDIFOTASK", SYMBOL_CODE
);
1498 if (spdifo_task
== NULL
) {
1499 snd_printk(KERN_ERR
"dsp_spos: symbol SPDIFOTASK not found\n");
1503 spdifi_task
= cs46xx_dsp_lookup_symbol(chip
, "SPDIFITASK", SYMBOL_CODE
);
1504 if (spdifi_task
== NULL
) {
1505 snd_printk(KERN_ERR
"dsp_spos: symbol SPDIFITASK not found\n");
1511 struct dsp_spdifoscb spdifo_scb
= {
1512 /* 0 */ DSP_SPOS_UUUU
,
1519 /* NOTE: the SPDIF output task read samples in mono
1520 format, the AsynchFGTxSCB task writes to buffer
1523 /* 5 */ RSCONFIG_SAMPLE_16MONO
+ RSCONFIG_MODULO_256
,
1524 /* 6 */ ( SPDIFO_IP_OUTPUT_BUFFER1
<< 0x10 ) | 0xFFFC,
1527 /* 9 */ FG_TASK_HEADER_ADDR
, NULL_SCB_ADDR
,
1528 /* A */ spdifo_task
->address
,
1529 SPDIFO_SCB_INST
+ SPDIFOFIFOPointer
,
1531 /* B */ 0x0040, /*DSP_SPOS_UUUU,*/
1532 /* C */ 0x20ff, /*DSP_SPOS_UUUU,*/
1534 /* D */ 0x804c,0, /* SPDIFOFIFOPointer:SPDIFOStatRegAddr; */
1535 /* E */ 0x0108,0x0001, /* SPDIFOStMoFormat:SPDIFOFIFOBaseAddr; */
1536 /* F */ DSP_SPOS_UUUU
/* SPDIFOFree; */
1540 struct dsp_spdifiscb spdifi_scb
= {
1541 /* 0 */ DSP_SPOS_UULO
,DSP_SPOS_UUHI
,
1544 /* 3 */ 1,4000, /* SPDIFICountLimit SPDIFICount */
1545 /* 4 */ DSP_SPOS_UUUU
, /* SPDIFIStatusData */
1546 /* 5 */ 0,DSP_SPOS_UUHI
, /* StatusData, Free4 */
1547 /* 6 */ DSP_SPOS_UUUU
, /* Free3 */
1548 /* 7 */ DSP_SPOS_UU
,DSP_SPOS_DC
, /* Free2 BitCount*/
1549 /* 8 */ DSP_SPOS_UUUU
, /* TempStatus */
1550 /* 9 */ SPDIFO_SCB_INST
, NULL_SCB_ADDR
,
1551 /* A */ spdifi_task
->address
,
1552 SPDIFI_SCB_INST
+ SPDIFIFIFOPointer
,
1553 /* NOTE: The SPDIF input task write the sample in mono
1554 format from the HW FIFO, the AsynchFGRxSCB task reads
1557 /* B */ RSCONFIG_SAMPLE_16MONO
+ RSCONFIG_MODULO_128
,
1558 /* C */ (SPDIFI_IP_OUTPUT_BUFFER1
<< 0x10) | 0xFFFC,
1560 /* E */ 0x01f0,0x0001,
1561 /* F */ DSP_SPOS_UUUU
/* SPDIN_STATUS monitor */
1565 struct dsp_async_codec_input_scb async_codec_input_scb
= {
1566 /* 0 */ DSP_SPOS_UUUU
,
1570 /* 4 */ 0x0118,0x0001,
1571 /* 5 */ RSCONFIG_SAMPLE_16MONO
+ RSCONFIG_MODULO_64
,
1572 /* 6 */ (ASYNC_IP_OUTPUT_BUFFER1
<< 0x10) | 0xFFFC,
1573 /* 7 */ DSP_SPOS_UU
,0x3,
1574 /* 8 */ DSP_SPOS_UUUU
,
1575 /* 9 */ SPDIFI_SCB_INST
,NULL_SCB_ADDR
,
1576 /* A */ s16_async_codec_input_task
->address
,
1577 HFG_TREE_SCB
+ AsyncCIOFIFOPointer
,
1579 /* B */ RSCONFIG_SAMPLE_16STEREO
+ RSCONFIG_MODULO_64
,
1580 /* C */ (ASYNC_IP_OUTPUT_BUFFER1
<< 0x10), /*(ASYNC_IP_OUTPUT_BUFFER1 << 0x10) | 0xFFFC,*/
1582 #ifdef UseASER1Input
1583 /* short AsyncCIFIFOPointer:AsyncCIStatRegAddr;
1584 Init. 0000:8042: for ASER1
1585 0000:8044: for ASER2 */
1588 /* short AsyncCIStMoFormat:AsyncCIFIFOBaseAddr;
1589 Init 1 stero:8050 ASER1
1590 Init 0 mono:8070 ASER2
1591 Init 1 Stereo : 0100 ASER1 (Set by script) */
1592 /* E */ 0x0100,0x0001,
1596 #ifdef UseASER2Input
1597 /* short AsyncCIFIFOPointer:AsyncCIStatRegAddr;
1598 Init. 0000:8042: for ASER1
1599 0000:8044: for ASER2 */
1602 /* short AsyncCIStMoFormat:AsyncCIFIFOBaseAddr;
1603 Init 1 stero:8050 ASER1
1604 Init 0 mono:8070 ASER2
1605 Init 1 Stereo : 0100 ASER1 (Set by script) */
1606 /* E */ 0x0110,0x0001,
1610 /* short AsyncCIOutputBufModulo:AsyncCIFree;
1611 AsyncCIOutputBufModulo: The modulo size for
1612 the output buffer of this task */
1613 /* F */ 0, /* DSP_SPOS_UUUU */
1616 spdifo_scb_desc
= cs46xx_dsp_create_scb(chip
,"SPDIFOSCB",(u32
*)&spdifo_scb
,SPDIFO_SCB_INST
);
1618 if (snd_BUG_ON(!spdifo_scb_desc
))
1620 spdifi_scb_desc
= cs46xx_dsp_create_scb(chip
,"SPDIFISCB",(u32
*)&spdifi_scb
,SPDIFI_SCB_INST
);
1621 if (snd_BUG_ON(!spdifi_scb_desc
))
1623 async_codec_scb_desc
= cs46xx_dsp_create_scb(chip
,"AsynCodecInputSCB",(u32
*)&async_codec_input_scb
, HFG_TREE_SCB
);
1624 if (snd_BUG_ON(!async_codec_scb_desc
))
1627 async_codec_scb_desc
->parent_scb_ptr
= NULL
;
1628 async_codec_scb_desc
->next_scb_ptr
= spdifi_scb_desc
;
1629 async_codec_scb_desc
->sub_list_ptr
= ins
->the_null_scb
;
1630 async_codec_scb_desc
->task_entry
= s16_async_codec_input_task
;
1632 spdifi_scb_desc
->parent_scb_ptr
= async_codec_scb_desc
;
1633 spdifi_scb_desc
->next_scb_ptr
= spdifo_scb_desc
;
1634 spdifi_scb_desc
->sub_list_ptr
= ins
->the_null_scb
;
1635 spdifi_scb_desc
->task_entry
= spdifi_task
;
1637 spdifo_scb_desc
->parent_scb_ptr
= spdifi_scb_desc
;
1638 spdifo_scb_desc
->next_scb_ptr
= fg_entry
;
1639 spdifo_scb_desc
->sub_list_ptr
= ins
->the_null_scb
;
1640 spdifo_scb_desc
->task_entry
= spdifo_task
;
1642 /* this one is faked, as the parnet of SPDIFO task
1643 is the FG task tree */
1644 fg_entry
->parent_scb_ptr
= spdifo_scb_desc
;
1647 cs46xx_dsp_proc_register_scb_desc (chip
,spdifo_scb_desc
);
1648 cs46xx_dsp_proc_register_scb_desc (chip
,spdifi_scb_desc
);
1649 cs46xx_dsp_proc_register_scb_desc (chip
,async_codec_scb_desc
);
1651 /* Async MASTER ENABLE, affects both SPDIF input and output */
1652 snd_cs46xx_pokeBA0(chip
, BA0_ASER_MASTER
, 0x1 );
1658 static void cs46xx_dsp_disable_spdif_hw (struct snd_cs46xx
*chip
)
1660 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1662 /* set SPDIF output FIFO slot */
1663 snd_cs46xx_pokeBA0(chip
, BA0_ASER_FADDR
, 0);
1665 /* SPDIF output MASTER ENABLE */
1666 cs46xx_poke_via_dsp (chip
,SP_SPDOUT_CONTROL
, 0);
1668 /* right and left validate bit */
1669 /*cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV, ins->spdif_csuv_default);*/
1670 cs46xx_poke_via_dsp (chip
,SP_SPDOUT_CSUV
, 0x0);
1672 /* clear fifo pointer */
1673 cs46xx_poke_via_dsp (chip
,SP_SPDIN_FIFOPTR
, 0x0);
1676 ins
->spdif_status_out
&= ~DSP_SPDIF_STATUS_HW_ENABLED
;
1679 int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx
*chip
)
1681 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1683 /* if hw-ctrl already enabled, turn off to reset logic ... */
1684 cs46xx_dsp_disable_spdif_hw (chip
);
1687 /* set SPDIF output FIFO slot */
1688 snd_cs46xx_pokeBA0(chip
, BA0_ASER_FADDR
, ( 0x8000 | ((SP_SPDOUT_FIFO
>> 4) << 4) ));
1690 /* SPDIF output MASTER ENABLE */
1691 cs46xx_poke_via_dsp (chip
,SP_SPDOUT_CONTROL
, 0x80000000);
1693 /* right and left validate bit */
1694 cs46xx_poke_via_dsp (chip
,SP_SPDOUT_CSUV
, ins
->spdif_csuv_default
);
1697 ins
->spdif_status_out
|= DSP_SPDIF_STATUS_HW_ENABLED
;
1702 int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx
*chip
)
1704 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1706 /* turn on amplifier */
1707 chip
->active_ctrl(chip
, 1);
1708 chip
->amplifier_ctrl(chip
, 1);
1710 if (snd_BUG_ON(ins
->asynch_rx_scb
))
1712 if (snd_BUG_ON(!ins
->spdif_in_src
))
1715 mutex_lock(&chip
->spos_mutex
);
1717 if ( ! (ins
->spdif_status_out
& DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED
) ) {
1718 /* time countdown enable */
1719 cs46xx_poke_via_dsp (chip
,SP_ASER_COUNTDOWN
, 0x80000005);
1720 /* NOTE: 80000005 value is just magic. With all values
1721 that I've tested this one seem to give the best result.
1722 Got no explication why. (Benny) */
1724 /* SPDIF input MASTER ENABLE */
1725 cs46xx_poke_via_dsp (chip
,SP_SPDIN_CONTROL
, 0x800003ff);
1727 ins
->spdif_status_out
|= DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED
;
1730 /* create and start the asynchronous receiver SCB */
1731 ins
->asynch_rx_scb
= cs46xx_dsp_create_asynch_fg_rx_scb(chip
,"AsynchFGRxSCB",
1734 SPDIFI_IP_OUTPUT_BUFFER1
,
1736 SCB_ON_PARENT_SUBLIST_SCB
);
1738 spin_lock_irq(&chip
->reg_lock
);
1740 /* reset SPDIF input sample buffer pointer */
1741 /*snd_cs46xx_poke (chip, (SPDIFI_SCB_INST + 0x0c) << 2,
1742 (SPDIFI_IP_OUTPUT_BUFFER1 << 0x10) | 0xFFFC);*/
1744 /* reset FIFO ptr */
1745 /*cs46xx_poke_via_dsp (chip,SP_SPDIN_FIFOPTR, 0x0);*/
1746 cs46xx_src_link(chip
,ins
->spdif_in_src
);
1748 /* unmute SRC volume */
1749 cs46xx_dsp_scb_set_volume (chip
,ins
->spdif_in_src
,0x7fff,0x7fff);
1751 spin_unlock_irq(&chip
->reg_lock
);
1753 /* set SPDIF input sample rate and unmute
1754 NOTE: only 48khz support for SPDIF input this time */
1755 /* cs46xx_dsp_set_src_sample_rate(chip,ins->spdif_in_src,48000); */
1758 ins
->spdif_status_in
= 1;
1759 mutex_unlock(&chip
->spos_mutex
);
1764 int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx
*chip
)
1766 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1768 if (snd_BUG_ON(!ins
->asynch_rx_scb
))
1770 if (snd_BUG_ON(!ins
->spdif_in_src
))
1773 mutex_lock(&chip
->spos_mutex
);
1775 /* Remove the asynchronous receiver SCB */
1776 cs46xx_dsp_remove_scb (chip
,ins
->asynch_rx_scb
);
1777 ins
->asynch_rx_scb
= NULL
;
1779 cs46xx_src_unlink(chip
,ins
->spdif_in_src
);
1782 ins
->spdif_status_in
= 0;
1783 mutex_unlock(&chip
->spos_mutex
);
1785 /* restore amplifier */
1786 chip
->active_ctrl(chip
, -1);
1787 chip
->amplifier_ctrl(chip
, -1);
1792 int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx
*chip
)
1794 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1796 if (snd_BUG_ON(ins
->pcm_input
))
1798 if (snd_BUG_ON(!ins
->ref_snoop_scb
))
1801 mutex_lock(&chip
->spos_mutex
);
1802 ins
->pcm_input
= cs46xx_add_record_source(chip
,ins
->ref_snoop_scb
,PCMSERIALIN_PCM_SCB_ADDR
,
1803 "PCMSerialInput_Wave");
1804 mutex_unlock(&chip
->spos_mutex
);
1809 int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx
*chip
)
1811 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1813 if (snd_BUG_ON(!ins
->pcm_input
))
1816 mutex_lock(&chip
->spos_mutex
);
1817 cs46xx_dsp_remove_scb (chip
,ins
->pcm_input
);
1818 ins
->pcm_input
= NULL
;
1819 mutex_unlock(&chip
->spos_mutex
);
1824 int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx
*chip
)
1826 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1828 if (snd_BUG_ON(ins
->adc_input
))
1830 if (snd_BUG_ON(!ins
->codec_in_scb
))
1833 mutex_lock(&chip
->spos_mutex
);
1834 ins
->adc_input
= cs46xx_add_record_source(chip
,ins
->codec_in_scb
,PCMSERIALIN_SCB_ADDR
,
1835 "PCMSerialInput_ADC");
1836 mutex_unlock(&chip
->spos_mutex
);
1841 int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx
*chip
)
1843 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1845 if (snd_BUG_ON(!ins
->adc_input
))
1848 mutex_lock(&chip
->spos_mutex
);
1849 cs46xx_dsp_remove_scb (chip
,ins
->adc_input
);
1850 ins
->adc_input
= NULL
;
1851 mutex_unlock(&chip
->spos_mutex
);
1856 int cs46xx_poke_via_dsp (struct snd_cs46xx
*chip
, u32 address
, u32 data
)
1861 /* santiy check the parameters. (These numbers are not 100% correct. They are
1862 a rough guess from looking at the controller spec.) */
1863 if (address
< 0x8000 || address
>= 0x9000)
1866 /* initialize the SP_IO_WRITE SCB with the data. */
1867 temp
= ( address
<< 16 ) | ( address
& 0x0000FFFF); /* offset 0 <-- address2 : address1 */
1869 snd_cs46xx_poke(chip
,( SPIOWRITE_SCB_ADDR
<< 2), temp
);
1870 snd_cs46xx_poke(chip
,((SPIOWRITE_SCB_ADDR
+ 1) << 2), data
); /* offset 1 <-- data1 */
1871 snd_cs46xx_poke(chip
,((SPIOWRITE_SCB_ADDR
+ 2) << 2), data
); /* offset 1 <-- data2 */
1873 /* Poke this location to tell the task to start */
1874 snd_cs46xx_poke(chip
,((SPIOWRITE_SCB_ADDR
+ 6) << 2), SPIOWRITE_SCB_ADDR
<< 0x10);
1876 /* Verify that the task ran */
1877 for (i
=0; i
<25; i
++) {
1880 temp
= snd_cs46xx_peek(chip
,((SPIOWRITE_SCB_ADDR
+ 6) << 2));
1881 if (temp
== 0x00000000)
1886 snd_printk(KERN_ERR
"dsp_spos: SPIOWriteTask not responding\n");
1893 int cs46xx_dsp_set_dac_volume (struct snd_cs46xx
* chip
, u16 left
, u16 right
)
1895 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1896 struct dsp_scb_descriptor
* scb
;
1898 mutex_lock(&chip
->spos_mutex
);
1901 scb
= ins
->master_mix_scb
->sub_list_ptr
;
1902 while (scb
!= ins
->the_null_scb
) {
1903 cs46xx_dsp_scb_set_volume (chip
,scb
,left
,right
);
1904 scb
= scb
->next_scb_ptr
;
1908 scb
= ins
->rear_mix_scb
->sub_list_ptr
;
1909 while (scb
!= ins
->the_null_scb
) {
1910 cs46xx_dsp_scb_set_volume (chip
,scb
,left
,right
);
1911 scb
= scb
->next_scb_ptr
;
1914 ins
->dac_volume_left
= left
;
1915 ins
->dac_volume_right
= right
;
1917 mutex_unlock(&chip
->spos_mutex
);
1922 int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx
* chip
, u16 left
, u16 right
)
1924 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1926 mutex_lock(&chip
->spos_mutex
);
1928 if (ins
->asynch_rx_scb
!= NULL
)
1929 cs46xx_dsp_scb_set_volume (chip
,ins
->asynch_rx_scb
,
1932 ins
->spdif_input_volume_left
= left
;
1933 ins
->spdif_input_volume_right
= right
;
1935 mutex_unlock(&chip
->spos_mutex
);
1941 int cs46xx_dsp_resume(struct snd_cs46xx
* chip
)
1943 struct dsp_spos_instance
* ins
= chip
->dsp_spos_instance
;
1946 /* clear parameter, sample and code areas */
1947 snd_cs46xx_clear_BA1(chip
, DSP_PARAMETER_BYTE_OFFSET
,
1948 DSP_PARAMETER_BYTE_SIZE
);
1949 snd_cs46xx_clear_BA1(chip
, DSP_SAMPLE_BYTE_OFFSET
,
1950 DSP_SAMPLE_BYTE_SIZE
);
1951 snd_cs46xx_clear_BA1(chip
, DSP_CODE_BYTE_OFFSET
, DSP_CODE_BYTE_SIZE
);
1953 for (i
= 0; i
< ins
->nmodules
; i
++) {
1954 struct dsp_module_desc
*module
= &ins
->modules
[i
];
1955 struct dsp_segment_desc
*seg
;
1958 seg
= get_segment_desc(module
, SEGTYPE_SP_PARAMETER
);
1959 err
= dsp_load_parameter(chip
, seg
);
1963 seg
= get_segment_desc(module
, SEGTYPE_SP_SAMPLE
);
1964 err
= dsp_load_sample(chip
, seg
);
1968 seg
= get_segment_desc(module
, SEGTYPE_SP_PROGRAM
);
1972 doffset
= seg
->offset
* 4 + module
->load_address
* 4
1973 + DSP_CODE_BYTE_OFFSET
;
1974 dsize
= seg
->size
* 4;
1975 err
= snd_cs46xx_download(chip
,
1976 ins
->code
.data
+ module
->load_address
,
1982 for (i
= 0; i
< ins
->ntask
; i
++) {
1983 struct dsp_task_descriptor
*t
= &ins
->tasks
[i
];
1984 _dsp_create_task_tree(chip
, t
->data
, t
->address
, t
->size
);
1987 for (i
= 0; i
< ins
->nscb
; i
++) {
1988 struct dsp_scb_descriptor
*s
= &ins
->scbs
[i
];
1991 _dsp_create_scb(chip
, s
->data
, s
->address
);
1993 for (i
= 0; i
< ins
->nscb
; i
++) {
1994 struct dsp_scb_descriptor
*s
= &ins
->scbs
[i
];
1998 cs46xx_dsp_spos_update_scb(chip
, s
);
2000 cs46xx_dsp_scb_set_volume(chip
, s
,
2001 s
->volume
[0], s
->volume
[1]);
2003 if (ins
->spdif_status_out
& DSP_SPDIF_STATUS_HW_ENABLED
) {
2004 cs46xx_dsp_enable_spdif_hw(chip
);
2005 snd_cs46xx_poke(chip
, (ins
->ref_snoop_scb
->address
+ 2) << 2,
2006 (OUTPUT_SNOOP_BUFFER
+ 0x10) << 0x10);
2007 if (ins
->spdif_status_out
& DSP_SPDIF_STATUS_PLAYBACK_OPEN
)
2008 cs46xx_poke_via_dsp(chip
, SP_SPDOUT_CSUV
,
2009 ins
->spdif_csuv_stream
);
2011 if (chip
->dsp_spos_instance
->spdif_status_in
) {
2012 cs46xx_poke_via_dsp(chip
, SP_ASER_COUNTDOWN
, 0x80000005);
2013 cs46xx_poke_via_dsp(chip
, SP_SPDIN_CONTROL
, 0x800003ff);