diff options
Diffstat (limited to 'firmware/sound.c')
-rw-r--r-- | firmware/sound.c | 168 |
1 files changed, 2 insertions, 166 deletions
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 |