diff options
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 96 |
1 files changed, 47 insertions, 49 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index df9e77a305..0eea71228c 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -326,11 +326,7 @@ unsigned long mpeg_get_last_header(void) | |||
326 | 326 | ||
327 | /* Read the frame data from the MAS and reconstruct it with the | 327 | /* Read the frame data from the MAS and reconstruct it with the |
328 | frame sync and all */ | 328 | frame sync and all */ |
329 | #if CONFIG_HWCODEC == MAS3587F | 329 | mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_1, tmp, 2); |
330 | mas_readmem(MAS_BANK_D0, 0xfd1, tmp, 2); | ||
331 | #else | ||
332 | mas_readmem(MAS_BANK_D0, 0x301, tmp, 2); | ||
333 | #endif | ||
334 | return 0xffe00000 | ((tmp[0] & 0x7c00) << 6) | (tmp[1] & 0xffff); | 330 | return 0xffe00000 | ((tmp[0] & 0x7c00) << 6) | (tmp[1] & 0xffff); |
335 | #endif | 331 | #endif |
336 | } | 332 | } |
@@ -394,13 +390,15 @@ static int prerecord_count; /* Number of seconds in the prerecord buffer */ | |||
394 | static int prerecord_timeout; /* The tick count of the next prerecord data store */ | 390 | static int prerecord_timeout; /* The tick count of the next prerecord data store */ |
395 | 391 | ||
396 | /* Shadow MAS registers */ | 392 | /* Shadow MAS registers */ |
397 | unsigned long shadow_7f0 = 0; | 393 | unsigned long shadow_encoder_control = 0; |
398 | unsigned long shadow_7f1 = 0; | ||
399 | unsigned long shadow_7f6 = 0; | ||
400 | unsigned long shadow_7f9 = 0; | ||
401 | |||
402 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 394 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ |
403 | 395 | ||
396 | #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) | ||
397 | unsigned long shadow_io_control_main = 0; | ||
398 | unsigned long shadow_app_select = 0; | ||
399 | unsigned long shadow_soft_mute = 0; | ||
400 | #endif | ||
401 | |||
404 | static int mpeg_file; | 402 | static int mpeg_file; |
405 | 403 | ||
406 | /* Synchronization variables */ | 404 | /* Synchronization variables */ |
@@ -927,10 +925,10 @@ static void track_change(void) | |||
927 | { | 925 | { |
928 | DEBUGF("Track change\n"); | 926 | DEBUGF("Track change\n"); |
929 | 927 | ||
930 | #if CONFIG_HWCODEC == MAS3587F | 928 | #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) |
931 | /* Reset the AVC */ | 929 | /* Reset the AVC */ |
932 | mpeg_sound_set(SOUND_AVC, -1); | 930 | mpeg_sound_set(SOUND_AVC, -1); |
933 | #endif /* #if CONFIG_HWCODEC == MAS3587F */ | 931 | #endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */ |
934 | remove_current_tag(); | 932 | remove_current_tag(); |
935 | 933 | ||
936 | update_playlist(); | 934 | update_playlist(); |
@@ -2100,10 +2098,10 @@ static void init_recording(void) | |||
2100 | 2098 | ||
2101 | /* Stop the current application */ | 2099 | /* Stop the current application */ |
2102 | val = 0; | 2100 | val = 0; |
2103 | mas_writemem(MAS_BANK_D0,0x7f6,&val,1); | 2101 | mas_writemem(MAS_BANK_D0, MAS_D0_APP_SELECT, &val, 1); |
2104 | do | 2102 | do |
2105 | { | 2103 | { |
2106 | mas_readmem(MAS_BANK_D0, 0x7f7, &val, 1); | 2104 | mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1); |
2107 | } while(val); | 2105 | } while(val); |
2108 | 2106 | ||
2109 | /* Perform black magic as described by the data sheet */ | 2107 | /* Perform black magic as described by the data sheet */ |
@@ -2130,19 +2128,19 @@ static void init_recording(void) | |||
2130 | mas_codec_writereg(7, 0x4000); | 2128 | mas_codec_writereg(7, 0x4000); |
2131 | 2129 | ||
2132 | /* No mute */ | 2130 | /* No mute */ |
2133 | shadow_7f9 = 0; | 2131 | shadow_soft_mute = 0; |
2134 | mas_writemem(MAS_BANK_D0, 0x7f9, &shadow_7f9, 1); | 2132 | mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute, 1); |
2135 | 2133 | ||
2136 | /* Set Demand mode, monitoring OFF and validate all settings */ | 2134 | /* Set Demand mode, monitoring OFF and validate all settings */ |
2137 | shadow_7f1 = 0x125; | 2135 | shadow_io_control_main = 0x125; |
2138 | mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1); | 2136 | mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1); |
2139 | 2137 | ||
2140 | /* Start the encoder application */ | 2138 | /* Start the encoder application */ |
2141 | val = 0x40; | 2139 | val = 0x40; |
2142 | mas_writemem(MAS_BANK_D0, 0x7f6, &val, 1); | 2140 | mas_writemem(MAS_BANK_D0, MAS_D0_APP_SELECT, &val, 1); |
2143 | do | 2141 | do |
2144 | { | 2142 | { |
2145 | mas_readmem(MAS_BANK_D0, 0x7f7, &val, 1); | 2143 | mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1); |
2146 | } while(!(val & 0x40)); | 2144 | } while(!(val & 0x40)); |
2147 | 2145 | ||
2148 | #if 1 | 2146 | #if 1 |
@@ -2154,13 +2152,13 @@ static void init_recording(void) | |||
2154 | sleep(20); | 2152 | sleep(20); |
2155 | 2153 | ||
2156 | /* Now set it to Monitoring mode as default, saves power */ | 2154 | /* Now set it to Monitoring mode as default, saves power */ |
2157 | shadow_7f1 = 0x525; | 2155 | shadow_io_control_main = 0x525; |
2158 | mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1); | 2156 | mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1); |
2159 | 2157 | ||
2160 | /* Wait until the DSP has accepted the settings */ | 2158 | /* Wait until the DSP has accepted the settings */ |
2161 | do | 2159 | do |
2162 | { | 2160 | { |
2163 | mas_readmem(MAS_BANK_D0, 0x7f1, &val,1); | 2161 | mas_readmem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &val,1); |
2164 | } while(val & 1); | 2162 | } while(val & 1); |
2165 | 2163 | ||
2166 | drain_dma_buffer(); | 2164 | drain_dma_buffer(); |
@@ -2209,14 +2207,14 @@ static void start_prerecording(void) | |||
2209 | is_prerecording = true; | 2207 | is_prerecording = true; |
2210 | 2208 | ||
2211 | /* Stop monitoring and start the encoder */ | 2209 | /* Stop monitoring and start the encoder */ |
2212 | shadow_7f1 &= ~(1 << 10); | 2210 | shadow_io_control_main &= ~(1 << 10); |
2213 | mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1); | 2211 | mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1); |
2214 | DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f1, %x)\n", shadow_7f1); | 2212 | DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main); |
2215 | 2213 | ||
2216 | /* Wait until the DSP has accepted the settings */ | 2214 | /* Wait until the DSP has accepted the settings */ |
2217 | do | 2215 | do |
2218 | { | 2216 | { |
2219 | mas_readmem(MAS_BANK_D0, 0x7f1, &val,1); | 2217 | mas_readmem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &val,1); |
2220 | } while(val & 1); | 2218 | } while(val & 1); |
2221 | 2219 | ||
2222 | is_recording = true; | 2220 | is_recording = true; |
@@ -2243,14 +2241,14 @@ static void start_recording(void) | |||
2243 | { | 2241 | { |
2244 | /* If prerecording is off, we need to stop the monitoring | 2242 | /* If prerecording is off, we need to stop the monitoring |
2245 | and start the encoder */ | 2243 | and start the encoder */ |
2246 | shadow_7f1 &= ~(1 << 10); | 2244 | shadow_io_control_main &= ~(1 << 10); |
2247 | mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1); | 2245 | mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1); |
2248 | DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f1, %x)\n", shadow_7f1); | 2246 | DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main); |
2249 | 2247 | ||
2250 | /* Wait until the DSP has accepted the settings */ | 2248 | /* Wait until the DSP has accepted the settings */ |
2251 | do | 2249 | do |
2252 | { | 2250 | { |
2253 | mas_readmem(MAS_BANK_D0, 0x7f1, &val,1); | 2251 | mas_readmem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &val,1); |
2254 | } while(val & 1); | 2252 | } while(val & 1); |
2255 | } | 2253 | } |
2256 | 2254 | ||
@@ -2275,8 +2273,8 @@ static void pause_recording(void) | |||
2275 | pause_start_time = current_tick; | 2273 | pause_start_time = current_tick; |
2276 | 2274 | ||
2277 | /* Set the pause bit */ | 2275 | /* Set the pause bit */ |
2278 | shadow_7f9 |= 2; | 2276 | shadow_soft_mute |= 2; |
2279 | mas_writemem(MAS_BANK_D0, 0x7f9, &shadow_7f9, 1); | 2277 | mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute, 1); |
2280 | 2278 | ||
2281 | paused = true; | 2279 | paused = true; |
2282 | } | 2280 | } |
@@ -2286,8 +2284,8 @@ static void resume_recording(void) | |||
2286 | paused = false; | 2284 | paused = false; |
2287 | 2285 | ||
2288 | /* Clear the pause bit */ | 2286 | /* Clear the pause bit */ |
2289 | shadow_7f9 &= ~2; | 2287 | shadow_soft_mute &= ~2; |
2290 | mas_writemem(MAS_BANK_D0, 0x7f9, &shadow_7f9, 1); | 2288 | mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute, 1); |
2291 | 2289 | ||
2292 | /* Compensate for the time we have been paused */ | 2290 | /* Compensate for the time we have been paused */ |
2293 | if(pause_start_time) | 2291 | if(pause_start_time) |
@@ -2313,17 +2311,17 @@ static void stop_recording(void) | |||
2313 | is_prerecording = false; | 2311 | is_prerecording = false; |
2314 | 2312 | ||
2315 | /* Read the number of frames recorded */ | 2313 | /* Read the number of frames recorded */ |
2316 | mas_readmem(MAS_BANK_D0, 0xfd0, &num_recorded_frames, 1); | 2314 | mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &num_recorded_frames, 1); |
2317 | 2315 | ||
2318 | /* Start monitoring */ | 2316 | /* Start monitoring */ |
2319 | shadow_7f1 |= (1 << 10); | 2317 | shadow_io_control_main |= (1 << 10); |
2320 | mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1); | 2318 | mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1); |
2321 | DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f1, %x)\n", shadow_7f1); | 2319 | DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main); |
2322 | 2320 | ||
2323 | /* Wait until the DSP has accepted the settings */ | 2321 | /* Wait until the DSP has accepted the settings */ |
2324 | do | 2322 | do |
2325 | { | 2323 | { |
2326 | mas_readmem(MAS_BANK_D0, 0x7f1, &val,1); | 2324 | mas_readmem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &val,1); |
2327 | } while(val & 1); | 2325 | } while(val & 1); |
2328 | 2326 | ||
2329 | resume_recording(); | 2327 | resume_recording(); |
@@ -2340,30 +2338,30 @@ void mpeg_set_recording_options(int frequency, int quality, | |||
2340 | rec_version_index = is_mpeg1?3:2; | 2338 | rec_version_index = is_mpeg1?3:2; |
2341 | rec_frequency_index = frequency % 3; | 2339 | rec_frequency_index = frequency % 3; |
2342 | 2340 | ||
2343 | shadow_7f0 = (quality << 17) | | 2341 | shadow_encoder_control = (quality << 17) | |
2344 | (rec_frequency_index << 10) | | 2342 | (rec_frequency_index << 10) | |
2345 | ((is_mpeg1?1:0) << 9) | | 2343 | ((is_mpeg1?1:0) << 9) | |
2346 | (((channel_mode * 2 + 1) & 3) << 6) | | 2344 | (((channel_mode * 2 + 1) & 3) << 6) | |
2347 | (1 << 5) /* MS-stereo */ | | 2345 | (1 << 5) /* MS-stereo */ | |
2348 | (1 << 2) /* Is an original */; | 2346 | (1 << 2) /* Is an original */; |
2349 | mas_writemem(MAS_BANK_D0, 0x7f0, &shadow_7f0,1); | 2347 | mas_writemem(MAS_BANK_D0, MAS_D0_ENCODER_CONTROL, &shadow_encoder_control,1); |
2350 | 2348 | ||
2351 | DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f0, %x)\n", shadow_7f0); | 2349 | DEBUGF("mas_writemem(MAS_BANK_D0, ENCODER_CONTROL, %x)\n", shadow_encoder_control); |
2352 | 2350 | ||
2353 | shadow_7f9 = editable?4:0; | 2351 | shadow_soft_mute = editable?4:0; |
2354 | mas_writemem(MAS_BANK_D0, 0x7f9, &shadow_7f9,1); | 2352 | mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute,1); |
2355 | 2353 | ||
2356 | DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f9, %x)\n", shadow_7f9); | 2354 | DEBUGF("mas_writemem(MAS_BANK_D0, SOFT_MUTE, %x)\n", shadow_soft_mute); |
2357 | 2355 | ||
2358 | shadow_7f1 = ((1 << 10) | /* Monitoring ON */ | 2356 | shadow_io_control_main = ((1 << 10) | /* Monitoring ON */ |
2359 | ((source < 2)?1:2) << 8) | /* Input select */ | 2357 | ((source < 2)?1:2) << 8) | /* Input select */ |
2360 | (1 << 5) | /* SDO strobe invert */ | 2358 | (1 << 5) | /* SDO strobe invert */ |
2361 | ((is_mpeg1?0:1) << 3) | | 2359 | ((is_mpeg1?0:1) << 3) | |
2362 | (1 << 2) | /* Inverted SIBC clock signal */ | 2360 | (1 << 2) | /* Inverted SIBC clock signal */ |
2363 | 1; /* Validate */ | 2361 | 1; /* Validate */ |
2364 | mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1,1); | 2362 | mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main,1); |
2365 | 2363 | ||
2366 | DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f1, %x)\n", shadow_7f1); | 2364 | DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main); |
2367 | 2365 | ||
2368 | if(source == 0) /* Mic */ | 2366 | if(source == 0) /* Mic */ |
2369 | { | 2367 | { |