summaryrefslogtreecommitdiff
path: root/firmware/pcm_record.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/pcm_record.c')
-rw-r--r--firmware/pcm_record.c55
1 files changed, 5 insertions, 50 deletions
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c
index 25f1f1ef64..04289f36ec 100644
--- a/firmware/pcm_record.c
+++ b/firmware/pcm_record.c
@@ -34,6 +34,9 @@
34#include "audio.h" 34#include "audio.h"
35#include "sound.h" 35#include "sound.h"
36#include "id3.h" 36#include "id3.h"
37#ifdef HAVE_SPDIF_IN
38#include "spdif.h"
39#endif
37 40
38/***************************************************************************/ 41/***************************************************************************/
39 42
@@ -349,18 +352,6 @@ unsigned long audio_num_recorded_bytes(void)
349} /* audio_num_recorded_bytes */ 352} /* audio_num_recorded_bytes */
350 353
351#ifdef HAVE_SPDIF_IN 354#ifdef HAVE_SPDIF_IN
352/* Return current SPDIF sample rate */
353static unsigned long measure_spdif_sample_rate(void)
354{
355 /* The following formula is specified in MCF5249 user's manual section
356 * 17.6.1. The 128 divide is because of the fact that the SPDIF clock is
357 * the sample rate times 128. Keep "3*(1 << 13)" part in sync with
358 * PHASECONFIG setup in pcm_init_recording in pcm-coldfire.c.
359 */
360 return (unsigned long)((unsigned long long)FREQMEAS*CPU_FREQ /
361 ((1 << 15)*3*(1 << 13))/128);
362} /* measure_spdif_sample_rate */
363
364/** 355/**
365 * Return SPDIF sample rate index in audio_master_sampr_list. Since we base 356 * Return SPDIF sample rate index in audio_master_sampr_list. Since we base
366 * our reading on the actual SPDIF sample rate (which might be a bit 357 * our reading on the actual SPDIF sample rate (which might be a bit
@@ -369,47 +360,11 @@ static unsigned long measure_spdif_sample_rate(void)
369 */ 360 */
370int audio_get_spdif_sample_rate(void) 361int audio_get_spdif_sample_rate(void)
371{ 362{
372 unsigned long measured_rate = measure_spdif_sample_rate(); 363 unsigned long measured_rate = spdif_measure_frequency();
373 /* Find which SPDIF sample rate we're closest to. */ 364 /* Find which SPDIF sample rate we're closest to. */
374 return round_value_to_list32(measured_rate, audio_master_sampr_list, 365 return round_value_to_list32(measured_rate, audio_master_sampr_list,
375 SAMPR_NUM_FREQ, false); 366 SAMPR_NUM_FREQ, false);
376} /* audio_get_spdif_sample_rate */ 367} /* audio_get_spdif_sample_rate */
377
378#ifdef HAVE_SPDIF_POWER
379static bool spdif_power_setting;
380
381void audio_set_spdif_power_setting(bool on)
382{
383 spdif_power_setting = on;
384} /* audio_set_spdif_power_setting */
385
386bool audio_get_spdif_power_setting(void)
387{
388 return spdif_power_setting;
389} /* audio_get_spdif_power_setting */
390#endif
391
392void audio_spdif_set_monitor(int monitor_spdif)
393{
394 EBU1CONFIG = 0x800; /* Reset before reprogram */
395
396 if (monitor_spdif > 0)
397 {
398#ifdef HAVE_SPDIF_POWER
399 EBU1CONFIG = spdif_power_setting ? (1 << 2) : 0;
400 /* Input source is EBUin1, Feed-through monitoring if desired */
401#else
402 EBU1CONFIG = (1 << 2);
403 /* Input source is EBUin1, Feed-through monitoring */
404#endif
405 }
406 else if (monitor_spdif == 0)
407 {
408 /* SCLK2, TXSRC = IIS1recv, validity, normal operation */
409 EBU1CONFIG = (7 << 12) | (4 << 8) | (1 << 5) | (5 << 2);
410 }
411} /* audio_spdif_set_monitor */
412
413#endif /* HAVE_SPDIF_IN */ 368#endif /* HAVE_SPDIF_IN */
414 369
415/** 370/**
@@ -434,7 +389,7 @@ void audio_set_recording_options(struct audio_recording_options *options)
434 if (rec_source == AUDIO_SRC_SPDIF) 389 if (rec_source == AUDIO_SRC_SPDIF)
435 { 390 {
436 /* must measure SPDIF sample rate before configuring codecs */ 391 /* must measure SPDIF sample rate before configuring codecs */
437 unsigned long sr = measure_spdif_sample_rate(); 392 unsigned long sr = spdif_measure_frequency();
438 /* round to master list for SPDIF rate */ 393 /* round to master list for SPDIF rate */
439 int index = round_value_to_list32(sr, audio_master_sampr_list, 394 int index = round_value_to_list32(sr, audio_master_sampr_list,
440 SAMPR_NUM_FREQ, false); 395 SAMPR_NUM_FREQ, false);