summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/ibasso/dx50/audiohw-dx50.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/ibasso/dx50/audiohw-dx50.c')
-rw-r--r--firmware/target/hosted/ibasso/dx50/audiohw-dx50.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/firmware/target/hosted/ibasso/dx50/audiohw-dx50.c b/firmware/target/hosted/ibasso/dx50/audiohw-dx50.c
new file mode 100644
index 0000000000..5e61348c8d
--- /dev/null
+++ b/firmware/target/hosted/ibasso/dx50/audiohw-dx50.c
@@ -0,0 +1,68 @@
1/***************************************************************************
2 * __________ __ ___
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2014 by Ilia Sergachev: Initial Rockbox port to iBasso DX50
10 * Copyright (C) 2014 by Mario Basister: iBasso DX90 port
11 * Copyright (C) 2014 by Simon Rothen: Initial Rockbox repository submission, additional features
12 * Copyright (C) 2014 by Udo Schläpfer: Code clean up, additional features
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24
25#include "config.h"
26#include "debug.h"
27
28#include "debug-ibasso.h"
29#include "sysfs-ibasso.h"
30
31
32extern void set_software_volume(void);
33
34
35void audiohw_set_volume(int volume)
36{
37 set_software_volume();
38
39 /*
40 See codec-dx50.h.
41 -128db -> -1 (adjusted to 0, mute)
42 -127dB to 0dB -> 1 to 255 in steps of 2
43 volume is in centibels (tenth-decibels).
44 */
45 int volume_adjusted = (volume / 10) * 2 + 255;
46
47 DEBUGF("DEBUG %s: volume: %d, volume_adjusted: %d.", __func__, volume, volume_adjusted);
48
49 if(volume_adjusted > 255)
50 {
51 DEBUGF("DEBUG %s: Adjusting volume from %d to 255.", __func__, volume);
52 volume_adjusted = 255;
53 }
54 if(volume_adjusted < 0)
55 {
56 DEBUGF("DEBUG %s: Adjusting volume from %d to 0.", __func__, volume);
57 volume_adjusted = 0;
58 }
59
60 /*
61 /dev/codec_volume
62 0 ... 255
63 */
64 if(! sysfs_set_int(SYSFS_DX50_CODEC_VOLUME, volume_adjusted))
65 {
66 DEBUGF("ERROR %s: Can not set volume.", __func__);
67 }
68}