summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorSebastian Leonhardt <sebastian.leonhardt@web.de>2014-05-30 00:26:27 +0200
committerSzymon Dziok <b0hoon@o2.pl>2014-06-01 23:25:12 +0200
commit53efa59e12f2de50bdb54e4a590c680063c39e1c (patch)
tree6c90855111fa00bd553891c3dd63b9240b4f5de4 /firmware
parent5237b36a858819378618e0d034d4b89c0bea1617 (diff)
downloadrockbox-53efa59e12f2de50bdb54e4a590c680063c39e1c.tar.gz
rockbox-53efa59e12f2de50bdb54e4a590c680063c39e1c.zip
recording on Samsung YH-820/YH-92x
Change-Id: I6eac4cf6c16a322910ad17bfbf3105e330cd0e36 Reviewed-on: http://gerrit.rockbox.org/815 Reviewed-by: Szymon Dziok <b0hoon@o2.pl> Tested: Szymon Dziok <b0hoon@o2.pl>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/audio/ak4537.c104
-rw-r--r--firmware/export/ak4537.h11
-rw-r--r--firmware/export/config/samsungyh820.h2
-rw-r--r--firmware/export/config/samsungyh920.h2
-rw-r--r--firmware/export/config/samsungyh925.h2
5 files changed, 113 insertions, 8 deletions
diff --git a/firmware/drivers/audio/ak4537.c b/firmware/drivers/audio/ak4537.c
index 90d264e445..799bf83946 100644
--- a/firmware/drivers/audio/ak4537.c
+++ b/firmware/drivers/audio/ak4537.c
@@ -223,22 +223,116 @@ void audiohw_set_frequency(int fsel)
223#if defined(HAVE_RECORDING) 223#if defined(HAVE_RECORDING)
224void audiohw_enable_recording(bool source_mic) 224void audiohw_enable_recording(bool source_mic)
225{ 225{
226 (void)source_mic; 226 if (source_mic)
227 {
228 /* enable mic power supply */
229#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
230 /* additionally select external mic */
231 akc_set(AK4537_MIC, MPWRE | MSEL);
232#else
233 akc_set(AK4537_MIC, MPWRI);
234#endif
235
236 /* mic out is connected to line1 input */
237 akc_clear(AK4537_PM3, INL | INR);
238
239 /* route ALC output to ADC input */
240 akc_set(AK4537_MIC, MICAD);
241 /* set ALC (automatic level control) to manual mode */
242 akc_clear(AK4537_ALC1, ALC1);
243 /* set gain control to 'dependent' (left&right at the same time) */
244 akc_clear(AK4537_MIC, IPGAC);
245 /* power up mic preamp, left channel ADC and line in */
246 akc_set(AK4537_PM1, PMMICL | PMIPGL | PMADL);
247 /* power up right channel ADC and line in */
248 akc_set(AK4537_PM3, PMADR | PMIPGR);
249 }
250 else
251 {
252 /* disable mic power supply */
253#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
254 akc_clear(AK4537_MIC, MPWRE);
255#else
256 akc_clear(AK4537_MIC, MPWRI);
257#endif
258 /* disable mic preamp */
259 akc_clear(AK4537_PM1, PMMICL);
260
261 /* Select line1 input */
262 akc_clear(AK4537_PM3, INL | INR);
263 /* route ALC output to ADC input */
264 akc_set(AK4537_MIC, MICAD);
265 /* set ALC (automatic level control) to manual mode */
266 akc_clear(AK4537_ALC1, ALC1);
267
268 /* set gain control to independent left & right gain */
269 akc_set(AK4537_MIC, IPGAC);
270
271 /* power up left channel input and ADC */
272 akc_set(AK4537_PM1, PMADL | PMIPGL);
273 /* power up right channel input and ADC */
274 akc_set(AK4537_PM3, PMADR | PMIPGR);
275 }
227} 276}
228 277
229void audiohw_disable_recording(void) 278void audiohw_disable_recording(void)
230{ 279{
280 /* disable mic power supply */
281#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
282 akc_clear(AK4537_MIC, MPWRE);
283#else
284 akc_clear(AK4537_MIC, MPWRI);
285#endif
286 /* power down ADC, mic preamp and line amp */
287 akc_clear(AK4537_PM1, PMADL | PMMICL | PMIPGL);
288 akc_clear(AK4537_PM3, PMADR | PMMICR | PMIPGR);
231} 289}
232 290
233void audiohw_set_recvol(int left, int right, int type) 291void audiohw_set_recvol(int left, int right, int type)
234{ 292{
235 (void)left; 293 switch (type)
236 (void)right; 294 {
237 (void)type; 295 case AUDIO_GAIN_MIC:
296 /* the mic preamp has a fixed gain of +15 dB. There's an additional
297 * activatable +20dB mic gain stage. The signal is then routed to
298 * the Line1 input, where you find the line attenuator with a range
299 * from -23.5 to +12dB, so we have a total gain range of -8.0 .. +47dB.
300 * NOTE: the datasheet state's different attenuator levels for mic and
301 * line input, but that's not precise. The +15dB difference result only
302 * from the mic stage.
303 * NOTE2: the mic is connected to the line1 input (via mic preamp),
304 * so if a line signal is present, you will always record a mixup.
305 */
306 /* If gain is > 20 dB we use the additional gain stage */
307 if (left > 20) {
308 akc_set(AK4537_MIC, MGAIN);
309 left -= 20;
310 }
311 else {
312 akc_clear(AK4537_MIC, MGAIN);
313 }
314 /* the remains is done by the line input amp */
315 left = (left+8)*2;
316 akc_write(AK4537_IPGAL, left);
317 break;
318 case AUDIO_GAIN_LINEIN:
319 /* convert dB to register value */
320 left = (left+23)*2+1;
321 right = (right+23)*2+1;
322 akc_write(AK4537_IPGAL, left);
323 akc_write(AK4537_IPGAR, right);
324 break;
325 default:
326 return;
327 }
238} 328}
239 329
240void audiohw_set_monitor(bool enable) 330void audiohw_set_monitor(bool enable)
241{ 331{
242 (void)enable; 332 if (enable)
333 /* mix input signal to headphone output */
334 akc_set(AK4537_SIGSEL2, MICL);
335 else
336 akc_clear(AK4537_SIGSEL2, MICL);
243} 337}
244#endif /* HAVE_RECORDING */ 338#endif /* HAVE_RECORDING */
diff --git a/firmware/export/ak4537.h b/firmware/export/ak4537.h
index d66205af7c..1c09b5aa2f 100644
--- a/firmware/export/ak4537.h
+++ b/firmware/export/ak4537.h
@@ -22,8 +22,19 @@
22#ifndef _AK4537_H 22#ifndef _AK4537_H
23#define _AK4537_H 23#define _AK4537_H
24 24
25
26#define AUDIOHW_CAPS (LIN_GAIN_CAP | MIC_GAIN_CAP)
27
25/* Volume goes from -127.0 ... 0 dB in 0.5 dB increments */ 28/* Volume goes from -127.0 ... 0 dB in 0.5 dB increments */
26AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -128, 0, -25) 29AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -128, 0, -25)
30#ifdef HAVE_RECORDING
31/* line input: -23 .. +12dB */
32AUDIOHW_SETTING(LEFT_GAIN, "dB", 0, 1, -23, 12, 0)
33AUDIOHW_SETTING(RIGHT_GAIN, "dB", 0, 1, -23, 12, 0)
34/* mic gain: +15dB fixed +20dB switchable mic preamp gain
35 and the line stage of -23..+12dB make a total range of -8..+47dB */
36AUDIOHW_SETTING(MIC_GAIN, "dB", 0, 1, -8, 47, 20)
37#endif /* HAVE_RECORDING */
27 38
28#define AKC_NUM_REGS 0x11 39#define AKC_NUM_REGS 0x11
29 40
diff --git a/firmware/export/config/samsungyh820.h b/firmware/export/config/samsungyh820.h
index 0b9c603850..5e4c79d3ab 100644
--- a/firmware/export/config/samsungyh820.h
+++ b/firmware/export/config/samsungyh820.h
@@ -7,7 +7,7 @@
7#define MODEL_NAME "Samsung YH-820" 7#define MODEL_NAME "Samsung YH-820"
8 8
9/* define this if you have recording possibility */ 9/* define this if you have recording possibility */
10/* todo #define HAVE_RECORDING */ 10#define HAVE_RECORDING
11 11
12/* Define bitmask of input sources - recordable bitmask can be defined 12/* Define bitmask of input sources - recordable bitmask can be defined
13 explicitly if different */ 13 explicitly if different */
diff --git a/firmware/export/config/samsungyh920.h b/firmware/export/config/samsungyh920.h
index 04487bc2db..61e6bf0017 100644
--- a/firmware/export/config/samsungyh920.h
+++ b/firmware/export/config/samsungyh920.h
@@ -7,7 +7,7 @@
7#define MODEL_NAME "Samsung YH-920" 7#define MODEL_NAME "Samsung YH-920"
8 8
9/* define this if you have recording possibility */ 9/* define this if you have recording possibility */
10/* todo #define HAVE_RECORDING */ 10#define HAVE_RECORDING
11 11
12/* Define bitmask of input sources - recordable bitmask can be defined 12/* Define bitmask of input sources - recordable bitmask can be defined
13 explicitly if different */ 13 explicitly if different */
diff --git a/firmware/export/config/samsungyh925.h b/firmware/export/config/samsungyh925.h
index aeb9cb6829..ad04f6c81e 100644
--- a/firmware/export/config/samsungyh925.h
+++ b/firmware/export/config/samsungyh925.h
@@ -7,7 +7,7 @@
7#define MODEL_NAME "Samsung YH-925" 7#define MODEL_NAME "Samsung YH-925"
8 8
9/* define this if you have recording possibility */ 9/* define this if you have recording possibility */
10/* todo #define HAVE_RECORDING */ 10#define HAVE_RECORDING
11 11
12/* Define bitmask of input sources - recordable bitmask can be defined 12/* Define bitmask of input sources - recordable bitmask can be defined
13 explicitly if different */ 13 explicitly if different */