diff options
author | Marcoen Hirschberg <marcoen@gmail.com> | 2006-12-06 13:34:15 +0000 |
---|---|---|
committer | Marcoen Hirschberg <marcoen@gmail.com> | 2006-12-06 13:34:15 +0000 |
commit | 1b967f41df90cd183c42e96d40acaeea671c1016 (patch) | |
tree | 8b529db9c07a630b61d3483568b4cfe66f8ed600 | |
parent | 3e24665c417c2dd7dc292c9f12efae4e6544aa11 (diff) | |
download | rockbox-1b967f41df90cd183c42e96d40acaeea671c1016.tar.gz rockbox-1b967f41df90cd183c42e96d40acaeea671c1016.zip |
move some audio driver specific code to the correspoding files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11675 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/tlv320.c | 16 | ||||
-rw-r--r-- | firmware/drivers/uda1380.c | 26 | ||||
-rw-r--r-- | firmware/drivers/wm8731l.c | 28 | ||||
-rw-r--r-- | firmware/drivers/wm8758.c | 31 | ||||
-rw-r--r-- | firmware/drivers/wm8975.c | 30 | ||||
-rw-r--r-- | firmware/export/sound.h | 12 | ||||
-rw-r--r-- | firmware/export/tlv320.h | 5 | ||||
-rw-r--r-- | firmware/export/uda1380.h | 8 | ||||
-rw-r--r-- | firmware/export/wm8731l.h | 7 | ||||
-rw-r--r-- | firmware/export/wm8758.h | 7 | ||||
-rw-r--r-- | firmware/export/wm8975.h | 7 | ||||
-rw-r--r-- | firmware/sound.c | 168 |
12 files changed, 179 insertions, 166 deletions
diff --git a/firmware/drivers/tlv320.c b/firmware/drivers/tlv320.c index c9ab094ef3..a88eae5f26 100644 --- a/firmware/drivers/tlv320.c +++ b/firmware/drivers/tlv320.c | |||
@@ -33,6 +33,22 @@ | |||
33 | #include "i2c-coldfire.h" | 33 | #include "i2c-coldfire.h" |
34 | #include "tlv320.h" | 34 | #include "tlv320.h" |
35 | 35 | ||
36 | /* convert tenth of dB volume (-840..0) to master volume register value */ | ||
37 | int tenthdb2master(int db) | ||
38 | { | ||
39 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | ||
40 | /* 1111111 == +6dB (0x7f) */ | ||
41 | /* 1111001 == 0dB (0x79) */ | ||
42 | /* 0110000 == -73dB (0x30 */ | ||
43 | /* 0101111 == mute (0x2f) */ | ||
44 | |||
45 | if (db < VOLUME_MIN) { | ||
46 | return 0x2f; | ||
47 | } else { | ||
48 | return((db/10)+73+0x30); | ||
49 | } | ||
50 | } | ||
51 | |||
36 | /* local functions and definations */ | 52 | /* local functions and definations */ |
37 | #define TLV320_ADDR 0x34 | 53 | #define TLV320_ADDR 0x34 |
38 | 54 | ||
diff --git a/firmware/drivers/uda1380.c b/firmware/drivers/uda1380.c index 841e7fbd19..00019148c1 100644 --- a/firmware/drivers/uda1380.c +++ b/firmware/drivers/uda1380.c | |||
@@ -35,6 +35,32 @@ | |||
35 | #include "uda1380.h" | 35 | #include "uda1380.h" |
36 | #include "pcf50606.h" | 36 | #include "pcf50606.h" |
37 | 37 | ||
38 | /* convert tenth of dB volume (-840..0) to master volume register value */ | ||
39 | int tenthdb2master(int db) | ||
40 | { | ||
41 | if (db < -720) /* 1.5 dB steps */ | ||
42 | return (2940 - db) / 15; | ||
43 | else if (db < -660) /* 0.75 dB steps */ | ||
44 | return (1110 - db) * 2 / 15; | ||
45 | else if (db < -520) /* 0.5 dB steps */ | ||
46 | return (520 - db) / 5; | ||
47 | else /* 0.25 dB steps */ | ||
48 | return -db * 2 / 5; | ||
49 | } | ||
50 | |||
51 | /* convert tenth of dB volume (-780..0) to mixer volume register value */ | ||
52 | int tenthdb2mixer(int db) | ||
53 | { | ||
54 | if (db < -660) /* 1.5 dB steps */ | ||
55 | return (2640 - db) / 15; | ||
56 | else if (db < -600) /* 0.75 dB steps */ | ||
57 | return (990 - db) * 2 / 15; | ||
58 | else if (db < -460) /* 0.5 dB steps */ | ||
59 | return (460 - db) / 5; | ||
60 | else /* 0.25 dB steps */ | ||
61 | return -db * 2 / 5; | ||
62 | } | ||
63 | |||
38 | /* ------------------------------------------------- */ | 64 | /* ------------------------------------------------- */ |
39 | /* Local functions and variables */ | 65 | /* Local functions and variables */ |
40 | /* ------------------------------------------------- */ | 66 | /* ------------------------------------------------- */ |
diff --git a/firmware/drivers/wm8731l.c b/firmware/drivers/wm8731l.c index 4fc33f882d..30521339e9 100644 --- a/firmware/drivers/wm8731l.c +++ b/firmware/drivers/wm8731l.c | |||
@@ -42,6 +42,34 @@ | |||
42 | 42 | ||
43 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ | 43 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ |
44 | 44 | ||
45 | /* convert tenth of dB volume (-730..60) to master volume register value */ | ||
46 | int tenthdb2master(int db) | ||
47 | { | ||
48 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | ||
49 | /* 1111111 == +6dB (0x7f) */ | ||
50 | /* 1111001 == 0dB (0x79) */ | ||
51 | /* 0110000 == -73dB (0x30 */ | ||
52 | /* 0101111 == mute (0x2f) */ | ||
53 | |||
54 | if (db < VOLUME_MIN) { | ||
55 | return 0x2f; | ||
56 | } else { | ||
57 | return((db/10)+0x30+73); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /* convert tenth of dB volume (-780..0) to mixer volume register value */ | ||
62 | int tenthdb2mixer(int db) | ||
63 | { | ||
64 | if (db < -660) /* 1.5 dB steps */ | ||
65 | return (2640 - db) / 15; | ||
66 | else if (db < -600) /* 0.75 dB steps */ | ||
67 | return (990 - db) * 2 / 15; | ||
68 | else if (db < -460) /* 0.5 dB steps */ | ||
69 | return (460 - db) / 5; | ||
70 | else /* 0.25 dB steps */ | ||
71 | return -db * 2 / 5; | ||
72 | } | ||
45 | 73 | ||
46 | int audiohw_mute(int mute) | 74 | int audiohw_mute(int mute) |
47 | { | 75 | { |
diff --git a/firmware/drivers/wm8758.c b/firmware/drivers/wm8758.c index 3a4256bb69..268df13f07 100644 --- a/firmware/drivers/wm8758.c +++ b/firmware/drivers/wm8758.c | |||
@@ -40,6 +40,37 @@ | |||
40 | #include "wmcodec.h" | 40 | #include "wmcodec.h" |
41 | #include "wm8758.h" | 41 | #include "wm8758.h" |
42 | 42 | ||
43 | /* convert tenth of dB volume (-57..6) to master volume register value */ | ||
44 | int tenthdb2master(int db) | ||
45 | { | ||
46 | /* +6 to -57dB in 1dB steps == 64 levels = 6 bits */ | ||
47 | /* 0111111 == +6dB (0x3f) = 63) */ | ||
48 | /* 0111001 == 0dB (0x39) = 57) */ | ||
49 | /* 0000001 == -56dB (0x01) = */ | ||
50 | /* 0000000 == -57dB (0x00) */ | ||
51 | |||
52 | /* 1000000 == Mute (0x40) */ | ||
53 | |||
54 | if (db < VOLUME_MIN) { | ||
55 | return 0x40; | ||
56 | } else { | ||
57 | return((db/10)+57); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /* convert tenth of dB volume (-780..0) to mixer volume register value */ | ||
62 | int tenthdb2mixer(int db) | ||
63 | { | ||
64 | if (db < -660) /* 1.5 dB steps */ | ||
65 | return (2640 - db) / 15; | ||
66 | else if (db < -600) /* 0.75 dB steps */ | ||
67 | return (990 - db) * 2 / 15; | ||
68 | else if (db < -460) /* 0.5 dB steps */ | ||
69 | return (460 - db) / 5; | ||
70 | else /* 0.25 dB steps */ | ||
71 | return -db * 2 / 5; | ||
72 | } | ||
73 | |||
43 | void audiohw_reset(void); | 74 | void audiohw_reset(void); |
44 | 75 | ||
45 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ | 76 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ |
diff --git a/firmware/drivers/wm8975.c b/firmware/drivers/wm8975.c index 96a563b1c9..7f2f2c4a7d 100644 --- a/firmware/drivers/wm8975.c +++ b/firmware/drivers/wm8975.c | |||
@@ -40,6 +40,36 @@ | |||
40 | #include "wmcodec.h" | 40 | #include "wmcodec.h" |
41 | #include "wm8975.h" | 41 | #include "wm8975.h" |
42 | 42 | ||
43 | /* convert tenth of dB volume (-730..60) to master volume register value */ | ||
44 | int tenthdb2master(int db) | ||
45 | { | ||
46 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | ||
47 | /* 1111111 == +6dB (0x7f) */ | ||
48 | /* 1111001 == 0dB (0x79) */ | ||
49 | /* 0110000 == -73dB (0x30 */ | ||
50 | /* 0101111 == mute (0x2f) */ | ||
51 | |||
52 | if (db < VOLUME_MIN) { | ||
53 | return 0x0; | ||
54 | } else { | ||
55 | return((db/10)+73+0x30); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | /* convert tenth of dB volume (-780..0) to mixer volume register value */ | ||
60 | int tenthdb2mixer(int db) | ||
61 | { | ||
62 | if (db < -660) /* 1.5 dB steps */ | ||
63 | return (2640 - db) / 15; | ||
64 | else if (db < -600) /* 0.75 dB steps */ | ||
65 | return (990 - db) * 2 / 15; | ||
66 | else if (db < -460) /* 0.5 dB steps */ | ||
67 | return (460 - db) / 5; | ||
68 | else /* 0.25 dB steps */ | ||
69 | return -db * 2 / 5; | ||
70 | } | ||
71 | |||
72 | |||
43 | void audiohw_reset(void); | 73 | void audiohw_reset(void); |
44 | 74 | ||
45 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ | 75 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ |
diff --git a/firmware/export/sound.h b/firmware/export/sound.h index 33175e4166..2cf2ad3136 100644 --- a/firmware/export/sound.h +++ b/firmware/export/sound.h | |||
@@ -19,6 +19,18 @@ | |||
19 | #ifndef SOUND_H | 19 | #ifndef SOUND_H |
20 | #define SOUND_H | 20 | #define SOUND_H |
21 | 21 | ||
22 | #ifdef HAVE_UDA1380 | ||
23 | #include "uda1380.h" | ||
24 | #elif defined(HAVE_WM8975) || defined(HAVE_WM8751) | ||
25 | #include "wm8975.h" | ||
26 | #elif defined(HAVE_WM8758) | ||
27 | #include "wm8758.h" | ||
28 | #elif defined(HAVE_WM8731) || defined(HAVE_WM8721) | ||
29 | #include "wm8731l.h" | ||
30 | #elif defined(HAVE_TLV320) | ||
31 | #include "tlv320.h" | ||
32 | #endif | ||
33 | |||
22 | enum { | 34 | enum { |
23 | SOUND_VOLUME = 0, | 35 | SOUND_VOLUME = 0, |
24 | SOUND_BASS, | 36 | SOUND_BASS, |
diff --git a/firmware/export/tlv320.h b/firmware/export/tlv320.h index dbb17e35bc..3cf5bd80cd 100644 --- a/firmware/export/tlv320.h +++ b/firmware/export/tlv320.h | |||
@@ -20,6 +20,11 @@ | |||
20 | #ifndef _TLV320_H_ | 20 | #ifndef _TLV320_H_ |
21 | #define _TLV320_H_ | 21 | #define _TLV320_H_ |
22 | 22 | ||
23 | #define VOLUME_MIN -730 | ||
24 | #define VOLUME_MAX 60 | ||
25 | |||
26 | extern tenthdb2master(int db); | ||
27 | |||
23 | /*** definitions ***/ | 28 | /*** definitions ***/ |
24 | 29 | ||
25 | extern void audiohw_init(void); | 30 | extern void audiohw_init(void); |
diff --git a/firmware/export/uda1380.h b/firmware/export/uda1380.h index 4b70e795bf..f8c8d6dd66 100644 --- a/firmware/export/uda1380.h +++ b/firmware/export/uda1380.h | |||
@@ -19,6 +19,14 @@ | |||
19 | 19 | ||
20 | #ifndef _UDA1380_H | 20 | #ifndef _UDA1380_H |
21 | #define _UDA1380_H | 21 | #define _UDA1380_H |
22 | |||
23 | /* volume/balance/treble/bass interdependency */ | ||
24 | #define VOLUME_MIN -840 | ||
25 | #define VOLUME_MAX 0 | ||
26 | |||
27 | extern tenthdb2master(int db); | ||
28 | extern tenthdb2mixer(int db); | ||
29 | |||
22 | extern void audiohw_reset(void); | 30 | extern void audiohw_reset(void); |
23 | extern int audiohw_init(void); | 31 | extern int audiohw_init(void); |
24 | extern void audiohw_enable_output(bool enable); | 32 | extern void audiohw_enable_output(bool enable); |
diff --git a/firmware/export/wm8731l.h b/firmware/export/wm8731l.h index 5783be17cc..b6fa13f6cb 100644 --- a/firmware/export/wm8731l.h +++ b/firmware/export/wm8731l.h | |||
@@ -20,6 +20,13 @@ | |||
20 | #ifndef _WM8731L_H | 20 | #ifndef _WM8731L_H |
21 | #define _WM8731L_H | 21 | #define _WM8731L_H |
22 | 22 | ||
23 | /* volume/balance/treble/bass interdependency */ | ||
24 | #define VOLUME_MIN -730 | ||
25 | #define VOLUME_MAX 60 | ||
26 | |||
27 | extern int tenthdb2master(int db); | ||
28 | extern int tenthdb2mixer(int db); | ||
29 | |||
23 | extern void audiohw_reset(void); | 30 | extern void audiohw_reset(void); |
24 | extern int audiohw_init(void); | 31 | extern int audiohw_init(void); |
25 | extern void audiohw_enable_output(bool enable); | 32 | extern void audiohw_enable_output(bool enable); |
diff --git a/firmware/export/wm8758.h b/firmware/export/wm8758.h index ca7074646d..20b26dc11f 100644 --- a/firmware/export/wm8758.h +++ b/firmware/export/wm8758.h | |||
@@ -20,6 +20,13 @@ | |||
20 | #ifndef _WM8758_H | 20 | #ifndef _WM8758_H |
21 | #define _WM8758_H | 21 | #define _WM8758_H |
22 | 22 | ||
23 | /* volume/balance/treble/bass interdependency */ | ||
24 | #define VOLUME_MIN -570 | ||
25 | #define VOLUME_MAX 60 | ||
26 | |||
27 | extern int tenthdb2master(int db); | ||
28 | extern int tenthdb2mixer(int db); | ||
29 | |||
23 | extern void audiohw_reset(void); | 30 | extern void audiohw_reset(void); |
24 | extern int audiohw_init(void); | 31 | extern int audiohw_init(void); |
25 | extern void audiohw_enable_output(bool enable); | 32 | extern void audiohw_enable_output(bool enable); |
diff --git a/firmware/export/wm8975.h b/firmware/export/wm8975.h index 005535bfaf..c00303a6a8 100644 --- a/firmware/export/wm8975.h +++ b/firmware/export/wm8975.h | |||
@@ -20,6 +20,13 @@ | |||
20 | #ifndef _WM8975_H | 20 | #ifndef _WM8975_H |
21 | #define _WM8975_H | 21 | #define _WM8975_H |
22 | 22 | ||
23 | /* volume/balance/treble/bass interdependency */ | ||
24 | #define VOLUME_MIN -730 | ||
25 | #define VOLUME_MAX 60 | ||
26 | |||
27 | extern int tenthdb2master(int db); | ||
28 | extern int tenthdb2mixer(int db); | ||
29 | |||
23 | extern void audiohw_reset(void); | 30 | extern void audiohw_reset(void); |
24 | extern int audiohw_init(void); | 31 | extern int audiohw_init(void); |
25 | extern void audiohw_enable_output(bool enable); | 32 | extern void audiohw_enable_output(bool enable); |
diff --git a/firmware/sound.c b/firmware/sound.c index 0c4c153797..09fa3dac94 100644 --- a/firmware/sound.c +++ b/firmware/sound.c | |||
@@ -24,17 +24,7 @@ | |||
24 | #ifndef SIMULATOR | 24 | #ifndef SIMULATOR |
25 | #include "i2c.h" | 25 | #include "i2c.h" |
26 | #include "mas.h" | 26 | #include "mas.h" |
27 | #ifdef HAVE_UDA1380 | 27 | #if CONFIG_CPU == PNX0101 |
28 | #include "uda1380.h" | ||
29 | #elif defined(HAVE_WM8975) || defined(HAVE_WM8751) | ||
30 | #include "wm8975.h" | ||
31 | #elif defined(HAVE_WM8758) | ||
32 | #include "wm8758.h" | ||
33 | #elif defined(HAVE_WM8731) || defined(HAVE_WM8721) | ||
34 | #include "wm8731l.h" | ||
35 | #elif defined(HAVE_TLV320) | ||
36 | #include "tlv320.h" | ||
37 | #elif CONFIG_CPU == PNX0101 | ||
38 | #include "pnx0101.h" | 28 | #include "pnx0101.h" |
39 | #endif | 29 | #endif |
40 | #include "dac.h" | 30 | #include "dac.h" |
@@ -269,161 +259,7 @@ static int tenthdb2reg(int db) | |||
269 | } | 259 | } |
270 | #endif | 260 | #endif |
271 | 261 | ||
272 | #ifdef HAVE_UDA1380 /* volume/balance/treble/bass interdependency */ | 262 | #if defined(HAVE_PP5024_CODEC) |
273 | #define VOLUME_MIN -840 | ||
274 | #define VOLUME_MAX 0 | ||
275 | |||
276 | /* convert tenth of dB volume (-840..0) to master volume register value */ | ||
277 | static int tenthdb2master(int db) | ||
278 | { | ||
279 | if (db < -720) /* 1.5 dB steps */ | ||
280 | return (2940 - db) / 15; | ||
281 | else if (db < -660) /* 0.75 dB steps */ | ||
282 | return (1110 - db) * 2 / 15; | ||
283 | else if (db < -520) /* 0.5 dB steps */ | ||
284 | return (520 - db) / 5; | ||
285 | else /* 0.25 dB steps */ | ||
286 | return -db * 2 / 5; | ||
287 | } | ||
288 | |||
289 | /* convert tenth of dB volume (-780..0) to mixer volume register value */ | ||
290 | static int tenthdb2mixer(int db) | ||
291 | { | ||
292 | if (db < -660) /* 1.5 dB steps */ | ||
293 | return (2640 - db) / 15; | ||
294 | else if (db < -600) /* 0.75 dB steps */ | ||
295 | return (990 - db) * 2 / 15; | ||
296 | else if (db < -460) /* 0.5 dB steps */ | ||
297 | return (460 - db) / 5; | ||
298 | else /* 0.25 dB steps */ | ||
299 | return -db * 2 / 5; | ||
300 | } | ||
301 | |||
302 | #elif defined(HAVE_TLV320) | ||
303 | #define VOLUME_MIN -730 | ||
304 | #define VOLUME_MAX 60 | ||
305 | |||
306 | /* convert tenth of dB volume (-840..0) to master volume register value */ | ||
307 | static int tenthdb2master(int db) | ||
308 | { | ||
309 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | ||
310 | /* 1111111 == +6dB (0x7f) */ | ||
311 | /* 1111001 == 0dB (0x79) */ | ||
312 | /* 0110000 == -73dB (0x30 */ | ||
313 | /* 0101111 == mute (0x2f) */ | ||
314 | |||
315 | if (db < VOLUME_MIN) { | ||
316 | return 0x2f; | ||
317 | } else { | ||
318 | return((db/10)+73+0x30); | ||
319 | } | ||
320 | } | ||
321 | |||
322 | #elif defined(HAVE_WM8975) || defined(HAVE_WM8751) | ||
323 | /* volume/balance/treble/bass interdependency */ | ||
324 | #define VOLUME_MIN -730 | ||
325 | #define VOLUME_MAX 60 | ||
326 | |||
327 | /* convert tenth of dB volume (-730..60) to master volume register value */ | ||
328 | static int tenthdb2master(int db) | ||
329 | { | ||
330 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | ||
331 | /* 1111111 == +6dB (0x7f) */ | ||
332 | /* 1111001 == 0dB (0x79) */ | ||
333 | /* 0110000 == -73dB (0x30 */ | ||
334 | /* 0101111 == mute (0x2f) */ | ||
335 | |||
336 | if (db < VOLUME_MIN) { | ||
337 | return 0x0; | ||
338 | } else { | ||
339 | return((db/10)+73+0x30); | ||
340 | } | ||
341 | } | ||
342 | |||
343 | /* convert tenth of dB volume (-780..0) to mixer volume register value */ | ||
344 | static int tenthdb2mixer(int db) | ||
345 | { | ||
346 | if (db < -660) /* 1.5 dB steps */ | ||
347 | return (2640 - db) / 15; | ||
348 | else if (db < -600) /* 0.75 dB steps */ | ||
349 | return (990 - db) * 2 / 15; | ||
350 | else if (db < -460) /* 0.5 dB steps */ | ||
351 | return (460 - db) / 5; | ||
352 | else /* 0.25 dB steps */ | ||
353 | return -db * 2 / 5; | ||
354 | } | ||
355 | |||
356 | #elif defined(HAVE_WM8758) | ||
357 | /* volume/balance/treble/bass interdependency */ | ||
358 | #define VOLUME_MIN -570 | ||
359 | #define VOLUME_MAX 60 | ||
360 | |||
361 | /* convert tenth of dB volume (-57..6) to master volume register value */ | ||
362 | static int tenthdb2master(int db) | ||
363 | { | ||
364 | /* +6 to -57dB in 1dB steps == 64 levels = 6 bits */ | ||
365 | /* 0111111 == +6dB (0x3f) = 63) */ | ||
366 | /* 0111001 == 0dB (0x39) = 57) */ | ||
367 | /* 0000001 == -56dB (0x01) = */ | ||
368 | /* 0000000 == -57dB (0x00) */ | ||
369 | |||
370 | /* 1000000 == Mute (0x40) */ | ||
371 | |||
372 | if (db < VOLUME_MIN) { | ||
373 | return 0x40; | ||
374 | } else { | ||
375 | return((db/10)+57); | ||
376 | } | ||
377 | } | ||
378 | |||
379 | /* convert tenth of dB volume (-780..0) to mixer volume register value */ | ||
380 | static int tenthdb2mixer(int db) | ||
381 | { | ||
382 | if (db < -660) /* 1.5 dB steps */ | ||
383 | return (2640 - db) / 15; | ||
384 | else if (db < -600) /* 0.75 dB steps */ | ||
385 | return (990 - db) * 2 / 15; | ||
386 | else if (db < -460) /* 0.5 dB steps */ | ||
387 | return (460 - db) / 5; | ||
388 | else /* 0.25 dB steps */ | ||
389 | return -db * 2 / 5; | ||
390 | } | ||
391 | |||
392 | #elif defined(HAVE_WM8731) || defined(HAVE_WM8721) | ||
393 | /* volume/balance/treble/bass interdependency */ | ||
394 | #define VOLUME_MIN -730 | ||
395 | #define VOLUME_MAX 60 | ||
396 | |||
397 | /* convert tenth of dB volume (-730..60) to master volume register value */ | ||
398 | static int tenthdb2master(int db) | ||
399 | { | ||
400 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | ||
401 | /* 1111111 == +6dB (0x7f) */ | ||
402 | /* 1111001 == 0dB (0x79) */ | ||
403 | /* 0110000 == -73dB (0x30 */ | ||
404 | /* 0101111 == mute (0x2f) */ | ||
405 | |||
406 | if (db < VOLUME_MIN) { | ||
407 | return 0x2f; | ||
408 | } else { | ||
409 | return((db/10)+0x30+73); | ||
410 | } | ||
411 | } | ||
412 | |||
413 | /* convert tenth of dB volume (-780..0) to mixer volume register value */ | ||
414 | static int tenthdb2mixer(int db) | ||
415 | { | ||
416 | if (db < -660) /* 1.5 dB steps */ | ||
417 | return (2640 - db) / 15; | ||
418 | else if (db < -600) /* 0.75 dB steps */ | ||
419 | return (990 - db) * 2 / 15; | ||
420 | else if (db < -460) /* 0.5 dB steps */ | ||
421 | return (460 - db) / 5; | ||
422 | else /* 0.25 dB steps */ | ||
423 | return -db * 2 / 5; | ||
424 | } | ||
425 | |||
426 | #elif defined(HAVE_PP5024_CODEC) | ||
427 | /* TODO: Work out volume/balance/treble/bass interdependency */ | 263 | /* TODO: Work out volume/balance/treble/bass interdependency */ |
428 | #define VOLUME_MIN 0 | 264 | #define VOLUME_MIN 0 |
429 | #define VOLUME_MAX 1 | 265 | #define VOLUME_MAX 1 |