From b46f46bd6f4adc90a46137d7d1d8709ae922b891 Mon Sep 17 00:00:00 2001 From: funman Date: Fri, 14 May 2010 11:08:15 +0000 Subject: [PATCH] Enable recording on clipv1/m200v4/c200v2 Use smaller recording buffer and watermarks on these models with 2MB of ram Rearrange watermark calculation expressions so we can use fractional numbers of seconds but still with integer results Only enable spinup time adjustement for ATA targets Flash targets (sansas and ondiofm) should still work fine, but they were not tested git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26014 a1c6a512-1295-4272-9138-f99709370657 --- apps/recorder/pcm_record.c | 28 ++++++++++++++++++++++------ firmware/export/config/sansac200v2.h | 2 +- firmware/export/config/sansaclip.h | 2 +- firmware/export/config/sansam200v4.h | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c index 217d27666..e5a510760 100644 --- a/apps/recorder/pcm_record.c +++ b/apps/recorder/pcm_record.c @@ -127,7 +127,11 @@ static unsigned long pre_record_ticks; /* pre-record time in ticks */ ****************************************************************************/ /** buffer parameters where incoming PCM data is placed **/ +#if MEM <= 2 +#define PCM_NUM_CHUNKS 16 /* Power of 2 */ +#else #define PCM_NUM_CHUNKS 256 /* Power of 2 */ +#endif #define PCM_CHUNK_SIZE 8192 /* Power of 2 */ #define PCM_CHUNK_MASK (PCM_NUM_CHUNKS*PCM_CHUNK_SIZE - 1) @@ -168,15 +172,22 @@ static int flood_watermark; /* boost thread priority when here */ #endif /* Constants that control watermarks */ -#define LOW_SECONDS 1 /* low watermark time till empty */ #define MINI_CHUNKS 10 /* chunk count for mini flush */ #ifdef HAVE_PRIORITY_SCHEDULING #define PRIO_SECONDS 10 /* max flush time before priority boost */ #endif -#if MEM <= 16 +#if MEM <= 2 +/* fractions must be integer fractions of 4 because they are evaluated with + * X*4*XXX_SECONDS, that way we avoid float calculation */ +#define LOW_SECONDS 1/4 /* low watermark time till empty */ +#define PANIC_SECONDS 1/2 /* flood watermark time until full */ +#define FLUSH_SECONDS 1 /* flush watermark time until full */ +#elif MEM <= 16 +#define LOW_SECONDS 1 /* low watermark time till empty */ #define PANIC_SECONDS 5 /* flood watermark time until full */ #define FLUSH_SECONDS 7 /* flush watermark time until full */ #else +#define LOW_SECONDS 1 /* low watermark time till empty */ #define PANIC_SECONDS 8 #define FLUSH_SECONDS 10 #endif /* MEM */ @@ -734,7 +745,9 @@ static void pcmrec_refresh_watermarks(void) logf("ata spinup: %d", storage_spinup_time()); /* set the low mark for when flushing stops if automatic */ - low_watermark = (LOW_SECONDS*4*sample_rate + (enc_chunk_size-1)) + /* don't change the order in this expression, LOW_SECONDS can be an + * integer fraction of 4 */ + low_watermark = (sample_rate*4*LOW_SECONDS + (enc_chunk_size-1)) / enc_chunk_size; logf("low wmk: %d", low_watermark); @@ -743,8 +756,10 @@ static void pcmrec_refresh_watermarks(void) this allows encoder to boost with just under a second of pcm data (if not yet full enough to boost itself) and not falsely trip the alarm. */ + /* don't change the order in this expression, PANIC_SECONDS can be an + * integer fraction of 4 */ flood_watermark = enc_num_chunks - - (PANIC_SECONDS*4*sample_rate + (enc_chunk_size-1)) + (sample_rate*4*PANIC_SECONDS + (enc_chunk_size-1)) / enc_chunk_size; if (flood_watermark < low_watermark) @@ -756,7 +771,7 @@ static void pcmrec_refresh_watermarks(void) logf("flood at: %d", flood_watermark); #endif spinup_time = last_storage_spinup_time = storage_spinup_time(); - +#if (CONFIG_STORAGE & STORAGE_ATA) /* write at 8s + st remaining in enc_buffer - range 12s to 20s total - default to 3.5s spinup. */ if (spinup_time == 0) @@ -765,6 +780,7 @@ static void pcmrec_refresh_watermarks(void) spinup_time = 2*HZ; /* ludicrous - ramdisk? */ else if (spinup_time > 10*HZ) spinup_time = 10*HZ; /* do you have a functioning HD? */ +#endif /* try to start writing with 10s remaining after disk spinup */ high_watermark = enc_num_chunks - @@ -773,9 +789,9 @@ static void pcmrec_refresh_watermarks(void) if (high_watermark < low_watermark) { + logf("warning: low 'write at' (%d)", high_watermark); high_watermark = low_watermark; low_watermark /= 2; - logf("warning: low 'write at'"); } logf("write at: %d", high_watermark); diff --git a/firmware/export/config/sansac200v2.h b/firmware/export/config/sansac200v2.h index bf6f460ec..ff68e971a 100644 --- a/firmware/export/config/sansac200v2.h +++ b/firmware/export/config/sansac200v2.h @@ -12,7 +12,7 @@ #define HW_SAMPR_CAPS SAMPR_CAP_ALL /* define this if you have recording possibility */ -//#define HAVE_RECORDING +#define HAVE_RECORDING #define REC_SAMPR_CAPS SAMPR_CAP_ALL diff --git a/firmware/export/config/sansaclip.h b/firmware/export/config/sansaclip.h index 6cf7ec7c6..c139d9142 100644 --- a/firmware/export/config/sansaclip.h +++ b/firmware/export/config/sansaclip.h @@ -12,7 +12,7 @@ #define HW_SAMPR_CAPS SAMPR_CAP_ALL /* define this if you have recording possibility */ -//#define HAVE_RECORDING +#define HAVE_RECORDING #define REC_SAMPR_CAPS SAMPR_CAP_ALL diff --git a/firmware/export/config/sansam200v4.h b/firmware/export/config/sansam200v4.h index 9a544ffad..fa91631b3 100644 --- a/firmware/export/config/sansam200v4.h +++ b/firmware/export/config/sansam200v4.h @@ -14,7 +14,7 @@ #define HW_SAMPR_CAPS SAMPR_CAP_ALL /* define this if you have recording possibility */ -//#define HAVE_RECORDING +#define HAVE_RECORDING #define REC_SAMPR_CAPS SAMPR_CAP_ALL -- 2.11.4.GIT