app_spdif_com.c
7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#include "os_config.h"
#include "c_def.h"
#include "debug.h"
#include "oem.h"
#include "regmap.h"
#include "mem_reloc.h"
#include "audio_dec.h"
#include "audio_com.h"
#include "hw_pll.h"
#include "hw_uart.h"
#include "hw_misc.h"
//#include "da_pp.h"
//#include "hw_rtc.h"
#include "hw_timer.h"
#include "hw_watchdog.h"
#include "hw_spdif.h"
#include "message.h"
#include "app_string_oem.h"
#include "app_main.h"
#include "app_process.h"
#include "app_dac.h"
#include "app_flash_program.h"
#include "app_cmd.h"
#include "audio_com.h"
#include "app_sdram.h"
#include "app_key.h"
#include "app_window.h"
#include "Audio_Device.h"
#include "flash_boot.h"
#ifdef SPDIF_ENABLE
extern const WINDOW optical_window;
void app_nav_sleep (U16 ms) ;
void app_save_system_data(void);
U8 spdif_input_number;
void Spdif_StreamConfig( void )
{
U8 *pStreamBuf;
U32 size;
DBG_Printf( "%s\n\r", __func__);
AUDIO_FIFO_STREAM_FLUSH();
#if 1
pStreamBuf = SPDIF_STREAM_START;
size = SPDIF_STREAM_END - SPDIF_STREAM_START;
#else
pStreamBuf = stream_buffer;
#ifdef STREAM_BUFFER_USED_POINTER
size = STREAM_BUF_MAX_SIZE;
#else
size = sizeof(stream_buffer);
#endif
#endif
AUDIO_FIFO_STREAM_FLUSH();
//fifo_file_stream_flush(&audio_env.stream_fifo)
AUDIO_FIFO_STREAM_OPEN(pStreamBuf, size);
//fifo_init(&audio_env.stream_fifo, pStreamBuf, size, TRUE);
AUDIO_FIFO_STREAM_CREATE(0,STREAM_LENTH_UNKNOWN,0,0);
//fifo_create_file_stream(&audio_env.stream_fifo, 0, STREAM_LENTH_UNKNOWN, 0, 0);
//app_main_data.playing_stream_status = STREAM_CDDA_WAIT_DATA;
app_main_data.playing_stream_status = STREAM_SPDIF_SR_DETECT ;
uDecSend (DECODE_SET, DECODE_SPDIF);
uDecSend (DECODE_INIT, 0);
//app_main_data.playback_state = PLAYING_MODE_PLAY;
}
void spdif_stream_type_detection_init(void);
void app_nav_rmt_convert_spdif(void)
{
U8 *p;
if (app_main_data.media == MEDIA_OPTICAL)
{
//return;
}
if (app_nav_media_finish())
{
return;
}
AMPLIFIER_MUTE_ON;
//spdif_stream_type_detection_init();
//misClockFreq_Set(app_main_data.sys_freq);
DBG_Printf("convert to SPDIF\n");
app_timer_window_time_set(0);
app_window_dummy_window_set();
app_main_data.ui_background = app_nav_dummy_process;
#if 1//def DOLBY_TEST_BOARD
spdif_input_number = SPDIF_IN_CH_3;
#else
spdif_input_number = SPDIF_IN_CH_0;
#endif
app_main_data.media = MEDIA_OPTICAL;
app_dac_receive_pcm_enable(FALSE);
//audio_pll_set_fnpll_clk_in ();
//audio_pll_set (SR_48000_SPDIF_2x);
hw_audio_pll_clk_fre_set(SF_BASE_DET,SPDIF_SF_4x);
#ifdef SPDIF_OUTPUT_ENABLE
spdif_output_set(TRUE);
#endif
spdif_init(spdif_input_number);
spdif_open(spdif_input_number);
Spdif_StreamConfig();
app_nav_sleep(100);
app_main_data.ui_background = app_nav_spdif_pocess;
app_nav_window_set(&optical_window, 0);
app_save_system_data();
p = (U8 *) STRING_OPTICAL_APP;
CPU_SoftReset_Flag_Setting((U8 *) p, FALSE);
#if defined AUDIO_CODEC_USED_CHANNEL
AUDIOdevice.Set_Channel(CD_AUDIO_CHANNEL);
#elif defined AUDIO_AMP_USED_CHANNEL
audioAmp_Dev.Set_Channel(CD_AUDIO_CHANNEL);
#endif
#if defined AUDIO_CODEC_USED_VOL
AUDIOdevice.Set_Volume(app_main_data.volume);
#elif defined AUDIO_AMP_USED_VOL
audioAmp_Dev.Set_Volume(app_main_data.volume);
#endif
//AMPLIFIER_MUTE_OFF;
//app_timer_mute_off_time_set(3000);
}
void app_nav_rmt_convert_coaxial(void)
{
U8 *p;
if (app_nav_media_finish())
{
return;
}
AMPLIFIER_MUTE_ON;
//spdif_stream_type_detection_init();
//misClockFreq_Set(app_main_data.sys_freq);
DBG_Printf("convert to coaxial\n");
app_timer_window_time_set(0);
app_window_dummy_window_set();
app_main_data.ui_background = app_nav_dummy_process;
spdif_input_number = SPDIF_IN_CH_1;
app_main_data.media = MEDIA_COAXIAL;
app_dac_receive_pcm_enable(FALSE);
//audio_pll_set_fnpll_clk_in ();
//audio_pll_set (SR_48000_SPDIF_2x); //detect sample rate
hw_audio_pll_clk_fre_set(SF_BASE_DET, SPDIF_SF_4x);
spdif_init(spdif_input_number);
spdif_open(spdif_input_number);
Spdif_StreamConfig();
app_nav_sleep(50);
app_main_data.ui_background = app_nav_spdif_pocess;
app_nav_window_set(&optical_window, 0);
app_save_system_data();
p = (U8 *) STRING_OPTICAL_APP;
CPU_SoftReset_Flag_Setting((U8 *) p, FALSE);
#if defined AUDIO_CODEC_USED_CHANNEL
AUDIOdevice.Set_Channel(CD_AUDIO_CHANNEL);
#elif defined AUDIO_AMP_USED_CHANNEL
audioAmp_Dev.Set_Channel(CD_AUDIO_CHANNEL);
#endif
#if defined AUDIO_CODEC_USED_VOL
AUDIOdevice.Set_Volume(app_main_data.volume);
#elif defined AUDIO_AMP_USED_VOL
audioAmp_Dev.Set_Volume(app_main_data.volume);
#endif
//AMPLIFIER_MUTE_OFF;
// app_timer_mute_off_time_set(3000);
}
void app_nav_rmt_convert_ARC(void)
{
U8 *p;
if (app_nav_media_finish()) return;
AMPLIFIER_MUTE_ON;
//spdif_stream_type_detection_init();
//misClockFreq_Set(app_main_data.sys_freq);
DBG_Printf("convert to ARC\n");
app_timer_window_time_set(0);
app_window_dummy_window_set();
app_main_data.ui_background = app_nav_dummy_process;
spdif_input_number = SPDIF_IN_CH_2;
app_main_data.media = MEDIA_ARC;
app_dac_receive_pcm_enable(FALSE);
//audio_pll_set_fnpll_clk_in ();
//audio_pll_set (SR_48000_SPDIF_2x); //detect sample rate
hw_audio_pll_clk_fre_set(SF_BASE_DET, SPDIF_SF_4x);
spdif_init(spdif_input_number);
spdif_open(spdif_input_number);
Spdif_StreamConfig();
app_nav_sleep(50);
app_main_data.ui_background = app_nav_spdif_pocess;
app_nav_window_set(&optical_window, 0);
app_save_system_data();
p = (U8 *) STRING_OPTICAL_APP;
CPU_SoftReset_Flag_Setting((U8 *) p, FALSE);
#if defined AUDIO_CODEC_USED_CHANNEL
AUDIOdevice.Set_Channel(CD_AUDIO_CHANNEL);
#elif defined AUDIO_AMP_USED_CHANNEL
audioAmp_Dev.Set_Channel(CD_AUDIO_CHANNEL);
#endif
#if defined AUDIO_CODEC_USED_VOL
AUDIOdevice.Set_Volume(app_main_data.volume);
#elif defined AUDIO_AMP_USED_VOL
audioAmp_Dev.Set_Volume(app_main_data.volume);
#endif
//AMPLIFIER_MUTE_OFF;
// app_timer_mute_off_time_set(3000);
}
const APP_NAV_KEY APP_NAV_KEY_OPTICAL[] =
{
{APP_KEY_SOURCE,NULL,app_nav_source_released,0,NULL},
{APP_KEY_POWER,NULL,app_nav_standby,0,NULL},
{APP_KEY_PLUS,app_nav_mp3_plus,NULL,800,app_nav_mp3_plus_hold},
{APP_KEY_MINUS,app_nav_mp3_minus,NULL,800,app_nav_mp3_minus_hold}
};
const WINDOW optical_window =
{
WINDOW_RESERVES,
app_window_draw_region_none, //draw region
KEY_TABLE(APP_NAV_KEY_OPTICAL),
0, //window time(ms)
NULL //window time handler
};
#ifdef DOLBY_AC3_DEC
//U8 audio_out_mode = AUDIO_OUT_L_R;
//U8 audio_out_mode = AUDIO_OUT_L_R_Center_Sub;
//U8 audio_out_mode = AUDIO_OUT_Center_Sub;
void app_ac3_output_mode_switch(void)
{
DBG_Printf("ac3 out mode switch:%d\n", audio_out_mode);
app_lcd_cancel_roll_function();
app_cmd_DecoderExit();
app_main_data.playback_state = PLAYING_MODE_STOP;
//app_main_data.status = enSTATE_STOP;
app_lcd_stream_type_icon (STREAM_UNKNOWN);
app_main_data.playing_stream_status = STREAM_IDLE;
app_main_data.playing_time = 0;
//app_main_data.playback_mode = NORMAL_PLAY;
//flush sdram buf
//app_sdram_stream_flush ();
AUDIO_FIFO_STREAM_FLUSH();
//random base
random_set_base (random ());
if (audio_out_mode == AUDIO_OUT_L_R)
{
audio_out_mode = AUDIO_OUT_LS_RS;
}
else if (audio_out_mode == AUDIO_OUT_LS_RS)
{
audio_out_mode = AUDIO_OUT_Center_Sub;
}
else if (audio_out_mode == AUDIO_OUT_Center_Sub)
{
audio_out_mode = AUDIO_OUT_L_R;
}
else
{
audio_out_mode = AUDIO_OUT_L_R;
}
app_nav_mp3_play_track(app_main_data.playing_track);
}
#endif //DOLBY_AC3_DEC
#endif //SPDIF_ENABLE